Skip to content

Commit

Permalink
Always use skew-weights instead of our original weighting formula
Browse files Browse the repository at this point in the history
This dramatically improves our results on skewed meshes, as demonstrated
on one of Sinan's cask setups
  • Loading branch information
lindsayad committed Apr 6, 2022
1 parent 86bcfcf commit 8a977ee
Show file tree
Hide file tree
Showing 25 changed files with 84 additions and 218 deletions.
71 changes: 19 additions & 52 deletions framework/include/base/MooseFunctor.h
Expand Up @@ -37,13 +37,12 @@ namespace Moose
struct ElemArg
{
const libMesh::Elem * elem;
bool correct_skewness;
bool apply_gradient_to_skewness;

friend bool operator<(const ElemArg & l, const ElemArg & r)
{
return std::make_tuple(l.elem, l.correct_skewness, l.apply_gradient_to_skewness) <
std::make_tuple(r.elem, r.correct_skewness, r.apply_gradient_to_skewness);
return std::make_tuple(l.elem, l.apply_gradient_to_skewness) <
std::make_tuple(r.elem, r.apply_gradient_to_skewness);
}
};

Expand All @@ -64,12 +63,7 @@ struct ElemFromFaceArg
/// information object will be used to help construct a ghost value evaluation
const FaceInfo * fi;

/// Whether to apply skew correction weights
bool correct_skewness;

/// Whether to apply the face gradient when computing a skew corrected face value. A true value
/// for this data member in conjunction with a false value for \p correct_skewness does not make
/// sense
/// Whether to apply the face gradient when computing a skew corrected face value
bool apply_gradient_to_skewness;

/// a subdomain ID. This is useful when the functor is a material property and the user wants
Expand All @@ -81,14 +75,12 @@ struct ElemFromFaceArg
/**
* Make a \p ElemArg from our data
*/
ElemArg makeElem() const { return {elem, correct_skewness, apply_gradient_to_skewness}; }
ElemArg makeElem() const { return {elem, apply_gradient_to_skewness}; }

friend bool operator<(const ElemFromFaceArg & l, const ElemFromFaceArg & r)
{
return std::make_tuple(
l.elem, l.fi, l.correct_skewness, l.apply_gradient_to_skewness, l.sub_id) <
std::make_tuple(
r.elem, r.fi, r.correct_skewness, r.apply_gradient_to_skewness, r.sub_id);
return std::make_tuple(l.elem, l.fi, l.apply_gradient_to_skewness, l.sub_id) <
std::make_tuple(r.elem, r.fi, r.apply_gradient_to_skewness, r.sub_id);
}
};

Expand All @@ -107,12 +99,7 @@ struct FaceArg
/// a boolean which states whether the face information element is upwind of the face
bool elem_is_upwind;

/// Whether to apply skew correction weights
bool correct_skewness;

/// Whether to apply the face gradient when computing a skew corrected face value. A true value
/// for this data member in conjunction with a false value for \p correct_skewness does not make
/// sense
/// Whether to apply the face gradient when computing a skew corrected face value
bool apply_gradient_to_skewness;

///@{
Expand All @@ -130,44 +117,39 @@ struct FaceArg
/**
* Make a \p ElemArg from our data using the face information element
*/
ElemArg makeElem() const { return {&fi->elem(), correct_skewness, apply_gradient_to_skewness}; }
ElemArg makeElem() const { return {&fi->elem(), apply_gradient_to_skewness}; }

/**
* Make a \p ElemArg from our data using the face information neighbor
*/
ElemArg makeNeighbor() const
{
return {fi->neighborPtr(), correct_skewness, apply_gradient_to_skewness};
}
ElemArg makeNeighbor() const { return {fi->neighborPtr(), apply_gradient_to_skewness}; }

/**
* Make a \p ElemFromFaceArg from our data using the face information element
*/
ElemFromFaceArg elemFromFace() const
{
return {&fi->elem(), fi, correct_skewness, apply_gradient_to_skewness, elem_sub_id};
return {&fi->elem(), fi, apply_gradient_to_skewness, elem_sub_id};
}

/**
* Make a \p ElemFromFaceArg from our data using the face information neighbor
*/
ElemFromFaceArg neighborFromFace() const
{
return {fi->neighborPtr(), fi, correct_skewness, apply_gradient_to_skewness, neighbor_sub_id};
return {fi->neighborPtr(), fi, apply_gradient_to_skewness, neighbor_sub_id};
}

friend bool operator<(const FaceArg & l, const FaceArg & r)
{
return std::make_tuple(l.fi,
l.limiter_type,
l.elem_is_upwind,
l.correct_skewness,
l.apply_gradient_to_skewness,
l.elem_sub_id,
l.neighbor_sub_id) < std::make_tuple(r.fi,
r.limiter_type,
r.elem_is_upwind,
r.correct_skewness,
r.apply_gradient_to_skewness,
r.elem_sub_id,
l.neighbor_sub_id);
Expand All @@ -194,12 +176,7 @@ struct SingleSidedFaceArg
/// a boolean which states whether the face information element is upwind of the face
bool elem_is_upwind;

/// Whether to apply skew correction weights
bool correct_skewness;

/// Whether to apply the face gradient when computing a skew corrected face value. A true value
/// for this data member in conjunction with a false value for \p correct_skewness does not make
/// sense
/// Whether to apply the face gradient when computing a skew corrected face value
bool apply_gradient_to_skewness;

/// The subdomain ID which denotes the side of the face information we are evaluating on
Expand All @@ -221,35 +198,25 @@ struct SingleSidedFaceArg

const Elem * const ret_elem =
sub_id == fi->elem().subdomain_id() ? &fi->elem() : fi->neighborPtr();
return {ret_elem, correct_skewness, apply_gradient_to_skewness};
return {ret_elem, apply_gradient_to_skewness};
}

/**
* Make a \p ElemArg from our data using the face information element
*/
ElemArg makeElem() const { return {&fi->elem(), correct_skewness, apply_gradient_to_skewness}; }
ElemArg makeElem() const { return {&fi->elem(), apply_gradient_to_skewness}; }

/**
* Make a \p ElemArg from our data using the face information neighbor
*/
ElemArg makeNeighbor() const
{
return {fi->neighborPtr(), correct_skewness, apply_gradient_to_skewness};
}
ElemArg makeNeighbor() const { return {fi->neighborPtr(), apply_gradient_to_skewness}; }

friend bool operator<(const SingleSidedFaceArg & l, const SingleSidedFaceArg & r)
{
return std::make_tuple(l.fi,
l.limiter_type,
l.elem_is_upwind,
l.correct_skewness,
l.apply_gradient_to_skewness,
l.sub_id) < std::make_tuple(r.fi,
r.limiter_type,
r.elem_is_upwind,
r.correct_skewness,
r.apply_gradient_to_skewness,
r.sub_id);
return std::make_tuple(
l.fi, l.limiter_type, l.elem_is_upwind, l.apply_gradient_to_skewness, l.sub_id) <
std::make_tuple(
r.fi, r.limiter_type, r.elem_is_upwind, r.apply_gradient_to_skewness, r.sub_id);
}
};

Expand Down
11 changes: 2 additions & 9 deletions framework/include/mesh/FaceInfo.h
Expand Up @@ -165,9 +165,6 @@ class FaceInfo
/// Return the geometric weighting factor
Real gC() const { return _gc; }

/// Return the weighting factor for skewed element-pairs
Real gCSkewed() const { return _gc_skewed; }

/**
* @return the distance vector drawn from centroid C to F, or in terms of MOOSE implementation,
* the distance vector obtained from subtracting the element centroid from the neighbor centroid
Expand Down Expand Up @@ -241,9 +238,6 @@ class FaceInfo
const Point _neighbor_centroid;
const Real _neighbor_volume;

/// Geometric weighting factor for face value interpolation
const Real _gc;

/// the distance vector between neighbor and element centroids
const RealVectorValue _d_cf;

Expand All @@ -256,9 +250,8 @@ class FaceInfo
/// The vector to the intersection of d_{CF} and the face.
Point _r_intersection;

/// Geometric weighting factor for face value interpolation in case of skewed
/// cell-connections
Real _gc_skewed;
/// Geometric weighting factor for face value interpolation
Real _gc;

/// cached locations of variables in solution vectors
/// TODO: make this more efficient by not using a map if possible
Expand Down
4 changes: 1 addition & 3 deletions framework/include/utils/GreenGaussGradient.h
Expand Up @@ -130,9 +130,7 @@ greenGaussGradient(const ElemArg & elem_arg,
grad_b += surface_vector * elem_value;
}
else
grad_b += surface_vector * functor(makeCDFace(*fi,
elem_arg.correct_skewness,
elem_arg.apply_gradient_to_skewness));
grad_b += surface_vector * functor(makeCDFace(*fi, elem_arg.apply_gradient_to_skewness));

if (!volume_set)
{
Expand Down

0 comments on commit 8a977ee

Please sign in to comment.