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 | 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... | |
void | rotate (MeshBase &mesh, const Real phi, const Real theta=0., const Real psi=0.) |
void | scale (MeshBase &mesh, const Real xs, const Real ys=0., const Real zs=0.) |
Scales the mesh. More... | |
void | all_tri (MeshBase &mesh) |
Converts the 2D quadrilateral elements of a Mesh into triangular 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 | ) |
Converts the 2D quadrilateral elements of a Mesh into triangular elements.
Definition at line 280 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_side_ptr(), libMesh::ParallelObject::comm(), libMesh::MeshBase::delete_elem(), libMesh::EDGE2, libMesh::EDGE3, libMesh::EDGE4, libMesh::MeshBase::element_ptr_range(), libMesh::err, libMesh::MeshBase::get_boundary_info(), 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_serial(), libMesh::libmesh_assert(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshBase::max_elem_id(), mesh, libMesh::MeshBase::mesh_dimension(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::MeshBase::n_elem(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::node_id(), libMesh::Elem::node_ptr(), std::norm(), libMesh::MeshBase::parallel_max_unique_id(), libMesh::Elem::parent(), libMesh::Elem::point(), libMesh::MeshBase::point(), libMesh::MeshBase::prepare_for_use(), libMesh::PRISM18, libMesh::PRISM6, libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::QUAD4, libMesh::QUAD8, libMesh::QUAD9, libMesh::remote_elem, libMesh::BoundaryInfo::remove(), libMesh::Elem::set_node(), libMesh::Elem::side_index_range(), libMesh::Elem::subdomain_id(), libMesh::TET10, libMesh::TET4, libMesh::TRI3, libMesh::TRI6, libMesh::Elem::type(), and libMesh::DofObject::unique_id().
Referenced by OverlappingFunctorTest::checkCouplingFunctorTri(), OverlappingFunctorTest::checkCouplingFunctorTriUnifRef(), main(), AllTriTest::test_helper_2D(), and AllTriTest::test_helper_3D().
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 1379 of file mesh_modification.C.
References libMesh::BoundaryInfo::add_edge(), libMesh::BoundaryInfo::add_node(), libMesh::BoundaryInfo::add_shellface(), libMesh::BoundaryInfo::add_side(), libMesh::BoundaryInfo::boundary_ids(), libMesh::BoundaryInfo::build_edge_list(), libMesh::BoundaryInfo::build_node_list(), libMesh::BoundaryInfo::build_shellface_list(), libMesh::BoundaryInfo::build_side_list(), libMesh::BoundaryInfo::edge_boundary_ids(), libMesh::MeshBase::elem_ptr(), libMesh::MeshBase::get_boundary_info(), mesh, libMesh::MeshBase::node_ptr(), libMesh::BoundaryInfo::remove(), libMesh::BoundaryInfo::remove_edge(), libMesh::BoundaryInfo::remove_id(), libMesh::BoundaryInfo::remove_shellface(), libMesh::BoundaryInfo::remove_side(), and libMesh::BoundaryInfo::shellface_boundary_ids().
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 1508 of file mesh_modification.C.
References libMesh::MeshBase::element_ptr_range(), 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 65 of file mesh_modification.C.
References libMesh::MeshBase::active_element_ptr_range(), libMesh::MeshTools::find_boundary_nodes(), libMesh::Elem::hmin(), libMesh::libmesh_assert(), 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(), and DistortTest::perturb_and_check().
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 1265 of file mesh_modification.C.
References libMesh::MeshBase::active_element_ptr_range(), libMesh::MeshBase::add_elem(), libMesh::BoundaryInfo::add_side(), libMesh::BoundaryInfo::boundary_ids(), libMesh::Elem::build(), libMesh::MeshBase::delete_elem(), libMesh::MeshBase::element_ptr_range(), libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::id(), libMesh::index_range(), libMesh::BoundaryInfo::invalid_id, libMesh::libmesh_ignore(), mesh, libMesh::MeshBase::n_active_elem(), libMesh::BoundaryInfo::n_boundary_conds(), 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::DofObject::set_id(), libMesh::Elem::set_neighbor(), libMesh::Elem::set_node(), libMesh::DofObject::set_unique_id(), libMesh::Elem::side_index_range(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), and libMesh::DofObject::unique_id().
Referenced by main().
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 146 of file mesh_modification.C.
References libMesh::FunctionBase< Output >::clone(), libMesh::libmesh_assert(), mesh, libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), and libMesh::MeshBase::node_ptr_range().
Referenced by libMesh::MeshTools::Generation::build_cube().
void 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) ‍/
void rotate2D (MeshBase & mesh, const Real alpha=0.);
/** 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 209 of file mesh_modification.C.
References libMesh::libmesh_ignore(), mesh, libMesh::MeshBase::node_ptr_range(), libMesh::pi, and libMesh::Real.
Referenced by 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 243 of file mesh_modification.C.
References mesh, libMesh::MeshBase::node_ptr_range(), and libMesh::Real.
Referenced by main(), libMesh::DenseVector< Output >::operator*=(), and libMesh::DenseMatrix< Real >::operator*=().
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 1111 of file mesh_modification.C.
References libMesh::TypeVector< T >::add(), libMesh::TypeVector< T >::add_scaled(), libMesh::as_range(), libMesh::Elem::build_side_ptr(), libMesh::Elem::embedding_matrix(), libMesh::MeshTools::find_boundary_nodes(), libMesh::DofObject::id(), libMesh::MeshBase::level_elements_begin(), libMesh::MeshBase::level_elements_end(), 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::MeshBase::node_ref(), libMesh::TypeVector< T >::norm(), libMesh::Elem::parent(), libMesh::Elem::point(), std::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 175 of file mesh_modification.C.
References mesh, and libMesh::MeshBase::node_ptr_range().