Skip to content

Commit

Permalink
Merge pull request idaholab#37 from jessecarterMOOSE/default_cause_fo…
Browse files Browse the repository at this point in the history
…r_circle_averages_34

return closest element info in Circle UserObjects, closes idaholab#34
  • Loading branch information
jessecarterMOOSE authored Sep 15, 2016
2 parents 340ef71 + 5a2d4ed commit 3f28687
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/userobjects/CircleAverageMaterialProperty.C
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ CircleAverageMaterialProperty::averageValue(const Point & p, const Real & radius
Real integral_sum = 0.0;
Real volume_sum = 0.0;

Real min_distance = std::numeric_limits<Real>::max();
dof_id_type closest_element;

for (std::map<dof_id_type, Point>::const_iterator it = _centroids.begin();
it != _centroids.end();
++it)
Expand All @@ -87,6 +90,13 @@ CircleAverageMaterialProperty::averageValue(const Point & p, const Real & radius

Real r = distance(p, centroid);

// save closest element in case mesh too coarse
if (r < min_distance)
{
min_distance = r;
closest_element = id;
}

// check if distance between points is less than supplied radius
if (r < radius)
{
Expand All @@ -103,6 +113,8 @@ CircleAverageMaterialProperty::averageValue(const Point & p, const Real & radius

if (volume_sum > 0.0)
return integral_sum/volume_sum;
else
return _integral_values.at(closest_element)/_volume_values.at(closest_element); // return at least the information of the closest element

return 0.0;
}
Expand Down Expand Up @@ -153,7 +165,8 @@ CircleAverageMaterialProperty::execute()
Real r = distance(_current_elem->centroid(), _old_event_list[i].second);

// check if distance between points is less than supplied radius
if (r < _radius)
// or if point is in element
if ((r < _radius) || (_current_elem->contains_point(_old_event_list[i].second)))
{
_integral_sum[i] += computeIntegral();
_volume_sum[i] += _current_elem_volume;
Expand Down
15 changes: 15 additions & 0 deletions src/userobjects/CircleMaxOriginalElementSize.C
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ CircleMaxOriginalElementSize::value(const Point & p, const Real & radius) const
{
Real max_element_size = 0.0;

Real min_distance = std::numeric_limits<Real>::max();
dof_id_type closest_element;
bool found_max = false;

// Loop over elements
for (std::map<dof_id_type, Point>::const_iterator it = _centroids.begin();
it != _centroids.end();
Expand All @@ -47,6 +51,13 @@ CircleMaxOriginalElementSize::value(const Point & p, const Real & radius) const

Real r = distance(p, centroid);

// save closest element in case mesh too coarse
if (r < min_distance)
{
min_distance = r;
closest_element = id;
}

// check if distance between points is less than supplied radius
if (r < radius)
{
Expand All @@ -60,6 +71,10 @@ CircleMaxOriginalElementSize::value(const Point & p, const Real & radius) const
}
}
}

if (min_distance == std::numeric_limits<Real>::max())
return _original_element_sizes.at(closest_element);

return max_element_size;
}

Expand Down

0 comments on commit 3f28687

Please sign in to comment.