22 "Modifier that will snap nodes, that are within a tolerated distance of a "
23 "plane, to the plane. This modifier is useful for straitening a boundary "
24 "edge or aligning vertices that misaligned during meshing.");
28 "normal",
"The normal of the plane to which the nodes are to be snapped.");
35 "If set to true, only boundary nodes will be snapped.");
38 "check_face_alignment",
40 "If set, only faces that match the plane normal (within tolerance) will "
41 "have their nodes snapped.");
46 "Tolerance per dimension within which a face/edge will be aligned");
54 normal_(params.GetParamVectorValue<double>(
"normal")),
55 point_(params.GetParamVectorValue<double>(
"point")),
56 boundary_nodes_only_(params.GetParamValue<bool>(
"boundaries_only")),
57 check_face_alignment_(params.GetParamValue<bool>(
"check_face_alignment")),
58 tol_(params.GetParamValue<double>(
"tolerance"))
61 "Cannot only be used in serial");
68 std::vector<uint64_t> snapped_vertex_ids;
69 std::set<uint64_t> cell_ids_modified;
72 for (
const auto& cell : grid.local_cells)
74 for (
const auto& face : cell.faces_)
79 for (
size_t d = 0; d < 3; ++d)
80 if (std::fabs(face.normal_[d] -
normal_[d]) >=
tol_) matches =
false;
83 for (uint64_t vid : face.vertex_ids_)
87 if (std::fabs(d) <
tol_)
89 grid.vertices[vid] -= d *
normal_;
90 snapped_vertex_ids.push_back(vid);
91 cell_ids_modified.insert(cell.local_id_);
97 for (
const auto& cell : grid.local_cells)
99 for (
const uint64_t vid : cell.vertex_ids_)
103 if (std::fabs(d) <
tol_)
105 grid.vertices[vid] -= d *
normal_;
106 snapped_vertex_ids.push_back(vid);
107 cell_ids_modified.insert(cell.local_id_);
113 for (
const uint64_t cell_local_id : cell_ids_modified)
115 grid.local_cells[cell_local_id].RecomputeCentroidsAndNormals(grid);
121 << cell_ids_modified.size();
#define ChiLogicalErrorIf(condition, message)
static chi::MPI_Info & mpi
static chi::InputParameters GetInputParameters()
chi_mesh::MeshContinuumPtr & GetGrid() const
const chi_mesh::Vector3 point_
const bool check_face_alignment_
const chi_mesh::Vector3 normal_
static chi::InputParameters GetInputParameters()
SnapToPlaneMeshModifier(const chi::InputParameters ¶ms)
const bool boundary_nodes_only_
double Dot(const VecDbl &x, const VecDbl &y)
RegisterChiObject(chi_mesh, BooleanLogicalVolume)
MeshHandler & GetCurrentHandler()