-
Notifications
You must be signed in to change notification settings - Fork 297
Added sliding boundary nodes to VariationalMeshSmoother #4216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Added sliding boundary nodes to VariationalMeshSmoother #4216
Conversation
… 3D, not sliding edge nodes.
…re considered for sliding boundary constraints. This helps with adjacent corners nodes in triangular elements.
…ain tests to account for barely-moved subdomain boundary nodes that coincide with the mesh boundary.
… sides are sometimes not found.
…ks better, but both constaints should be conmbined for strict enforcement.
Implemented structs to represent Point, Line, and Plane constraints and logic to combine (intersect) them. This is more robust than the previous version and gives the correct constraints for nodes that are both subdomain boundary nodes and external boundary nodes. Ref libMesh#4082
Replaced DistortSquare class with the DistortHypercube class, which generalizes dimension and distorts boundary nodes within boundaries instead of leaving them unchanged. The helper also checks all applicable node dimensions instead of receiving the dimension to check as a parameter. Renamed the `center_distortion_is` helper function to `distortion_is` and updated to check sliding boundary nodes for distortion.
Instead of looking for the boundary between sub_id2 and sub_id2, we now look for the boundary between sub_id1 and "not sub_id1". This better handles cases where multiple faces of an element have neighbors of multiple different subdomain ids.
…LaplaceSmoother functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's surprisingly little for me to complain about, for such a large PR.
/// Query whether a point lies on the line. | ||
/// @param p The point in question | ||
/// @return bool indicating whether p lies on the line. | ||
bool contains_point(const PointConstraint &p) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance we can get away with moving these struct definitions to the .C file?
If they're basically invisible to the rest of the library, then the code here is fine, great way to refactor stuff for internal use.
If not, then we may want to do things like change them into classes encapsulating the members, change TOLERANCE
into an (optional, defaulting to TOLERANCE*TOLERANCE
or whatever) tol
argument on all the functions that rely on comparison to within a tolerance, etc. etc., before we start getting unexpected external uses of APIs we didn't intend to support directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The determine_constraint
and impose_constraint
methods of VariationalSmootherConstraint
use ConstraintVariant
, so it doesn't seem like I can move the Point/Line/PlaneConstraint
structs fully into src
. I'll go ahead and lock them down.
bool LineConstraint::operator<(const LineConstraint &other) const { | ||
if (!(dir.absolute_fuzzy_equals(other.dir, TOLERANCE))) | ||
return dir < other.dir; | ||
return (dir * r0) < (other.dir * other.r0) - TOLERANCE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't an antisymmetric relation - is that intentional, to get set
etc. to consider nearly-identical lines as identical and drop one of them? If so we should document that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to get set etc. to consider nearly-identical lines as identical and drop one of them?
That was the AI's idea. Good point on the asymmetry. I'm taking that out and putting in a check for fuzzy equality prior to checking less than.
libmesh_error_msg_if(this->is_parallel(o), | ||
"Lines are parallel and do not intersect."); | ||
|
||
// Solve for t in the equation p1 + t·d1 = p2 + s·d2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thrilled with the idea of unleashing unicode in comments, and we've got it in a bunch of our contrib/ codes already, but I think this will be the first time it's in libMesh proper, so I want to make sure @jwpeterson is fine with it too.
If we can talk the C++ people into giving us operator×
and operator⊗
then I'm stripping the library of cross()
and outer_product()
calls approximately five minutes after we upgrade.
} | ||
catch (const std::exception & e) | ||
{ | ||
// This will catch cases where constraints have no intersection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things:
This should probably be libmesh_try
/libmesh_catch
to compile on builds with exceptions disabled.
How are we going to hit this at all? Every constrant we're creating contains the node itself, right? So at the very least shouldn't we already get something within epsilon of PointConstraint(node)
as the intersection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the next comment regarding the other place I use try/catch. I included it here as well to avoid issues similar to what I explained below.
ConstraintVariant current = *it++; | ||
for (; it != valid_planes.end(); ++it) | ||
{ | ||
try |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "how are we possibly getting an empty constraint" question here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question. I asked myself the same thing when an error was thrown and crashed the program. This is from the testVariationalHexMultipleSubdomains
test. First, I think it is work including a picture of the results. I'll update the PR description to do so, and will copy the result here:
Consider this view of the z=0 boundary of the distorted mesh:
Let's look at subdomain 0 only:
Zoom in on this element:
The top of this element, which forms part of the subdomain boundary is the union of two different planar surfaces. valid_planes
, when determining the constraint for the front left node, ends up holding 3 planes: The two seen in the figure, plus their "average". The average plane does not intersect both of the first two planes, and we end up with the case of a line (the combination of two of the planes) being parallel but not coincident with the third plane. Thus, an exception is thrown and we fall back to fixing the node.
Pull Request: Sliding Boundary Constraint Refinement and Dimensional Generalization
Summary
This pull request implements sliding external and subdomain boundary node constraints in the
VariationalMeshSmoother
In addition to expanding test coverage to test sliding boundary nodes, 1D and 3D test cases were added to the unit test suite.
Highlights
Constraint Framework Refactor
PointConstraint
,LineConstraint
, andPlaneConstraint
structs to represent fixed nodes, nodes constrained to a line, and nodes constrained to a planeintersect()
interface for combining constraints usingstd::variant
PointConstraint
if constraints fail to intersect cleanlySliding Boundary Enhancements
Expanded Tests and Validation
DistortSquare
withDistortHypercube
, supporting 1D, 2D, and 3D skewingReferences
Visualization of
testVariationalHexMultipleSubdomains
TestThe distorted mesh is on the left, smoothed mesh is on the right.
