Skip to content

Commit

Permalink
Address comments (libMesh#3385)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Sep 28, 2022
1 parent a1a7590 commit 412c777
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/mesh/mesh_smoother_laplace.C
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,30 @@ void LaplaceMeshSmoother::smooth(unsigned int n_iterations)
return true;
}

// 2D - collinear - check cross product of first edge with all other edges
// 2D - collinear - check cross product of first edge with all other edges.
// curvature is only zero if the second connected edge spans a zero area
// parallelogram with teh first edge. There shouldn't be a third edge, but if there
// ever is, we enforce it to be collinear as well.
if (_mesh.mesh_dimension() == 2)
return (base.cross(vec).norm_sq() < libMesh::TOLERANCE * libMesh::TOLERANCE);

// 3D
// 3D - we compute the cross product of the first and second edge...
if (n_edges == 2)
{
const auto cross = base.cross(vec);
const auto cross_norm_sq = cross.norm_sq();
// if the second edge is collinear to the first we simply drop it. This does not violate
// coplanarity, but it is insufficient to construct a normal for the tangent plane to check the
// remaining edges against.
if (cross_norm_sq < libMesh::TOLERANCE * libMesh::TOLERANCE)
n_edges--;
else
base = cross / std::sqrt(cross_norm_sq);
return true;
}

// edges 3 and up are coplanar if they are orthogonal to the normal vector of the tangent
// plane calculated above.
return (base * vec < libMesh::TOLERANCE);
};

Expand Down
4 changes: 2 additions & 2 deletions src/mesh/mesh_tools.C
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ MeshTools::find_block_boundary_nodes(const MeshBase & mesh)
// mark them as true in on_boundary.
for (const auto & elem : mesh.active_element_ptr_range())
for (auto s : elem->side_index_range())
if (elem->neighbor_ptr(s) && elem->neighbor_ptr(s)->subdomain_id() != elem->subdomain_id())
if (elem->neighbor_ptr(s) && (elem->neighbor_ptr(s)->subdomain_id() != elem->subdomain_id()))
{
auto nodes_on_side = elem->nodes_on_side(s);

Expand Down Expand Up @@ -569,7 +569,7 @@ MeshTools::build_subdomain_boundary_node_map(const MeshBase & mesh)
auto nodes_on_side = elem->nodes_on_side(s);

for (auto & local_id : nodes_on_side)
block_boundary_node_map[elem->node_ptr(local_id)->id()].insert(std::make_pair(std::min(id1, id2), std::max(id1, id2)));
block_boundary_node_map[elem->node_ptr(local_id)->id()].insert(std::minmax(id1, id2));
}
}
}
Expand Down

0 comments on commit 412c777

Please sign in to comment.