libMesh
|
Tools for Mesh
modification.
More...
Functions | |
void | distort (MeshBase &mesh, const Real factor, const bool perturb_boundary=false) |
Randomly perturb the nodal locations. More... | |
void | permute_elements (MeshBase &mesh) |
Randomly permute the nodal ordering of each element (without twisting the element mapping). More... | |
void | orient_elements (MeshBase &mesh) |
Redo the nodal ordering of each element as necessary to give the element Jacobian a positive orientation. More... | |
void | redistribute (MeshBase &mesh, const FunctionBase< Real > &mapfunc) |
Deterministically perturb the nodal locations. More... | |
void | translate (MeshBase &mesh, const Real xt=0., const Real yt=0., const Real zt=0.) |
Translates the mesh. More... | |
RealTensorValue | rotate (MeshBase &mesh, const Real phi, const Real theta=0., const Real psi=0.) |
Rotates the mesh in the xy plane. More... | |
void | scale (MeshBase &mesh, const Real xs, const Real ys=0., const Real zs=0.) |
Scales the mesh. More... | |
void | all_tri (MeshBase &mesh) |
Subdivides any non-simplex elements in a Mesh to produce simplex (triangular in 2D, tetrahedral in 3D) elements. More... | |
void | smooth (MeshBase &, unsigned int, Real) |
Smooth the mesh with a simple Laplace smoothing algorithm. More... | |
void | flatten (MeshBase &mesh) |
Removes all the refinement tree structure of Mesh, leaving only the highest-level (most-refined) elements. More... | |
void | change_boundary_id (MeshBase &mesh, const boundary_id_type old_id, const boundary_id_type new_id) |
Finds any boundary ids that are currently old_id, changes them to new_id. More... | |
void | change_subdomain_id (MeshBase &mesh, const subdomain_id_type old_id, const subdomain_id_type new_id) |
Finds any subdomain ids that are currently old_id, changes them to new_id. More... | |
Tools for Mesh
modification.
void libMesh::MeshTools::Modification::all_tri | ( | MeshBase & | mesh | ) |
Subdivides any non-simplex elements in a Mesh to produce simplex (triangular in 2D, tetrahedral in 3D) elements.
flatten()
removes its coarser layers. Definition at line 409 of file mesh_modification.C.
References libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), libMesh::BoundaryInfo::add_side(), libMesh::BoundaryInfo::boundary_ids(), libMesh::Elem::build(), libMesh::Elem::build_side_ptr(), libMesh::ParallelObject::comm(), libMesh::MeshBase::delete_elem(), libMesh::EDGE2, libMesh::EDGE3, libMesh::EDGE4, libMesh::err, libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::get_extra_integer(), libMesh::HEX8, libMesh::DofObject::id(), libMesh::index_range(), libMesh::INFEDGE2, libMesh::INFPRISM12, libMesh::INFPRISM6, libMesh::INFQUAD4, libMesh::INFQUAD6, libMesh::DofObject::invalid_id, libMesh::BoundaryInfo::invalid_id, libMesh::MeshBase::is_prepared(), libMesh::MeshBase::is_replicated(), libMesh::MeshBase::is_serial(), libMesh::libmesh_assert(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::Elem::mapping_data(), libMesh::Elem::mapping_type(), TIMPI::Communicator::max(), libMesh::MeshBase::max_elem_id(), mesh, libMesh::MeshBase::mesh_dimension(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::MeshBase::n_elem(), libMesh::DofObject::n_extra_integers(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::node_id(), libMesh::Elem::node_ptr(), libMesh::Elem::nodes_on_side(), libMesh::TensorTools::norm(), libMesh::MeshBase::parallel_max_unique_id(), libMesh::Elem::parent(), libMesh::Elem::point(), libMesh::MeshBase::point(), libMesh::MeshBase::prepare_for_use(), libMesh::PRISM18, libMesh::PRISM20, libMesh::PRISM21, libMesh::PRISM6, libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::QUAD4, libMesh::QUAD8, libMesh::QUAD9, libMesh::remote_elem, libMesh::BoundaryInfo::remove(), libMesh::Elem::side_index_range(), libMesh::Elem::subdomain_id(), libMesh::TET10, libMesh::TET14, libMesh::TET4, libMesh::TRI3, libMesh::TRI6, libMesh::TRI7, libMesh::Elem::type(), and libMesh::DofObject::unique_id().
Referenced by OverlappingFunctorTest::checkCouplingFunctorTri(), OverlappingFunctorTest::checkCouplingFunctorTriUnifRef(), main(), AllTriTest::test_helper_2D(), AllTriTest::test_helper_3D(), and libMesh::MeshTetInterface::volume_to_surface_mesh().
void libMesh::MeshTools::Modification::change_boundary_id | ( | MeshBase & | mesh, |
const boundary_id_type | old_id, | ||
const boundary_id_type | new_id | ||
) |
Finds any boundary ids that are currently old_id, changes them to new_id.
Definition at line 1719 of file mesh_modification.C.
References libMesh::MeshBase::get_boundary_info(), mesh, and libMesh::BoundaryInfo::renumber_id().
Referenced by MeshStitchTest::renameAndShift().
void libMesh::MeshTools::Modification::change_subdomain_id | ( | MeshBase & | mesh, |
const subdomain_id_type | old_id, | ||
const subdomain_id_type | new_id | ||
) |
Finds any subdomain ids that are currently old_id, changes them to new_id.
Definition at line 1729 of file mesh_modification.C.
References mesh, and libMesh::Elem::subdomain_id().
void libMesh::MeshTools::Modification::distort | ( | MeshBase & | mesh, |
const Real | factor, | ||
const bool | perturb_boundary = false |
||
) |
Randomly perturb the nodal locations.
This function will move each node factor
fraction of its minimum neighboring node separation distance. Nodes on the boundary are not moved by default, however they may be by setting the flag perturb_boundary
true.
Definition at line 141 of file mesh_modification.C.
References libMesh::MeshTools::find_boundary_nodes(), libMesh::Elem::hmin(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshBase::max_node_id(), mesh, libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::Elem::node_ref_range(), libMesh::MeshBase::query_node_ptr(), and libMesh::TypeVector< T >::unit().
Referenced by main(), DistortTest::perturb_and_check(), VolumeTest::test_true_centroid_and_volume(), and VolumeTest::testQuad4TrueCentroid().
void libMesh::MeshTools::Modification::flatten | ( | MeshBase & | mesh | ) |
Removes all the refinement tree structure of Mesh, leaving only the highest-level (most-refined) elements.
This is useful when you want to write out a uniformly-refined grid to be treated later as an initial mesh.
Definition at line 1593 of file mesh_modification.C.
References libMesh::MeshBase::add_elem(), libMesh::BoundaryInfo::add_side(), libMesh::BoundaryInfo::boundary_ids(), libMesh::Elem::build(), libMesh::MeshBase::delete_elem(), libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::get_extra_integer(), libMesh::DofObject::id(), libMesh::index_range(), libMesh::BoundaryInfo::invalid_id, libMesh::MeshBase::is_prepared(), libMesh::MeshBase::is_replicated(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), libMesh::Elem::mapping_data(), libMesh::Elem::mapping_type(), mesh, libMesh::MeshBase::n_active_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::DofObject::n_extra_integers(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::node_index_range(), libMesh::Elem::node_ptr(), libMesh::MeshBase::prepare_for_use(), libMesh::DofObject::processor_id(), libMesh::remote_elem, libMesh::Elem::side_index_range(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), and libMesh::DofObject::unique_id().
Referenced by main().
void libMesh::MeshTools::Modification::orient_elements | ( | MeshBase & | mesh | ) |
Redo the nodal ordering of each element as necessary to give the element Jacobian a positive orientation.
This function does not currently handle meshes with any element refinement.
Definition at line 262 of file mesh_modification.C.
References libMesh::MeshBase::get_boundary_info(), mesh, libMesh::MeshTools::n_levels(), and libMesh::Elem::orient().
Referenced by ElemTest< elem_type >::test_orient_elements().
void libMesh::MeshTools::Modification::permute_elements | ( | MeshBase & | mesh | ) |
Randomly permute the nodal ordering of each element (without twisting the element mapping).
This is useful for regression testing with a variety of element orientations.
This function does not currently handle meshes with any element refinement.
This function does not currently permute BoundaryInfo data associated with element sides, which will likely be scrambled by the permutation.
Definition at line 222 of file mesh_modification.C.
References libMesh::make_range(), libMesh::MeshBase::max_elem_id(), mesh, libMesh::MeshTools::n_levels(), libMesh::Elem::n_permutations(), libMesh::Elem::permute(), and libMesh::MeshBase::query_elem_ptr().
Referenced by main(), and FETestBase< order, family, elem_type, 1 >::setUp().
void libMesh::MeshTools::Modification::redistribute | ( | MeshBase & | mesh, |
const FunctionBase< Real > & | mapfunc | ||
) |
Deterministically perturb the nodal locations.
This function will move each node from it's current x/y/z coordinates to a new x/y/z coordinate given by the first LIBMESH_DIM components of the specified function mapfunc
Nodes on the boundary are also moved.
Currently, non-vertex nodes are moved in the same way as vertex nodes, according to (newx,newy,newz) = mapfunc(x,y,z). This behavior is often suboptimal for higher order geometries and may be subject to change in future libMesh versions.
Definition at line 280 of file mesh_modification.C.
References libMesh::FunctionBase< Output >::clone(), libMesh::libmesh_assert(), mesh, libMesh::MeshBase::n_elem(), and libMesh::MeshBase::n_nodes().
Referenced by libMesh::MeshTools::Generation::build_cube(), FETestBase< order, family, elem_type, 1 >::setUp(), and MeshSmootherTest::testSmoother().
RealTensorValue libMesh::MeshTools::Modification::rotate | ( | MeshBase & | mesh, |
const Real | phi, | ||
const Real | theta = 0. , |
||
const Real | psi = 0. |
||
) |
Rotates the mesh in the xy plane.
The rotation is counter-clock-wise (mathematical definition). The angle is in degrees (360 make a full circle) Rotates the mesh in 3D space. Here the standard Euler angles are adopted (http://mathworld.wolfram.com/EulerAngles.html) The angles are in degrees (360 make a full circle)
Definition at line 344 of file mesh_modification.C.
References libMesh::TensorValue< T >::intrinsic_rotation_matrix(), libMesh::libmesh_ignore(), mesh, and libMesh::MeshBase::set_spatial_dimension().
Referenced by main(), libMesh::Prism6::permute(), libMesh::Hex8::permute(), libMesh::Hex20::permute(), libMesh::Tet10::permute(), libMesh::Tet14::permute(), libMesh::Prism15::permute(), libMesh::Tet4::permute(), libMesh::Hex27::permute(), libMesh::Prism18::permute(), libMesh::Prism20::permute(), libMesh::Prism21::permute(), FETestBase< order, family, elem_type, 1 >::setUp(), BBoxTest::test_no_degenerate(), and BBoxTest::test_two_degenerate().
void libMesh::MeshTools::Modification::scale | ( | MeshBase & | mesh, |
const Real | xs, | ||
const Real | ys = 0. , |
||
const Real | zs = 0. |
||
) |
Scales the mesh.
The grid points are scaled in the x
direction by xs
, in the y
direction by ys
, etc... If only xs
is specified then the scaling is assumed uniform in all directions.
Definition at line 372 of file mesh_modification.C.
References mesh, and libMesh::Real.
Referenced by libMesh::PetscVector< libMesh::Number >::add(), main(), libMesh::DenseVector< Output >::operator*=(), libMesh::DenseMatrix< Real >::operator*=(), libMesh::PetscMatrix< T >::scale(), and libMesh::SparseMatrix< ValOut >::scale().
void libMesh::MeshTools::Modification::smooth | ( | MeshBase & | mesh, |
unsigned int | n_iterations, | ||
Real | power | ||
) |
Smooth the mesh with a simple Laplace smoothing algorithm.
The mesh is smoothed n_iterations
times. If the parameter power
is 0, each node is moved to the average position of the neighboring connected nodes. If power
> 0, the node positions are weighted by their distance. The positions of higher order nodes, and nodes living in refined elements, are calculated from the vertex positions of their parent nodes. Only works in 2D.
This implementation assumes every element "side" has only 2 nodes.
Definition at line 1437 of file mesh_modification.C.
References libMesh::TypeVector< T >::add(), libMesh::TypeVector< T >::add_scaled(), libMesh::as_range(), libMesh::Elem::embedding_matrix(), libMesh::MeshTools::find_boundary_nodes(), libMesh::DofObject::id(), libMesh::make_range(), mesh, libMesh::MeshBase::mesh_dimension(), libMesh::MeshTools::n_levels(), libMesh::MeshBase::n_nodes(), libMesh::Elem::n_nodes(), libMesh::Elem::n_second_order_adjacent_vertices(), libMesh::Elem::n_vertices(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::node_index_range(), libMesh::Elem::node_ptr(), libMesh::Elem::node_ref(), libMesh::MeshBase::node_ref(), libMesh::TypeVector< T >::norm(), libMesh::Elem::parent(), libMesh::Elem::point(), libMesh::Utility::pow(), libMesh::Real, libMesh::Elem::second_order_adjacent_vertex(), libMesh::Elem::side_index_range(), libMesh::MeshTools::weight(), and libMesh::Elem::which_child_am_i().
void libMesh::MeshTools::Modification::translate | ( | MeshBase & | mesh, |
const Real | xt = 0. , |
||
const Real | yt = 0. , |
||
const Real | zt = 0. |
||
) |
Translates the mesh.
The grid points are translated in the x
direction by xt
, in the y
direction by yt
, etc...
Definition at line 309 of file mesh_modification.C.
References mesh.
Referenced by MeshStitchTest::testMeshStitchElemsets(), and MeshTriangulationTest::testTriangulatorRoundHole().