14 #include "libmesh/face_tri3.h" 15 #include "libmesh/mesh_modification.h" 16 #include "libmesh/mesh_refinement.h" 17 #include "libmesh/sphere.h" 18 #include "libmesh/unstructured_mesh.h" 19 #include "libmesh/replicated_mesh.h" 28 "Generated sphere mesh - a two dimensional manifold embedded in three dimensional space");
30 params.
addParam<Point>(
"center", Point(0, 0, 0),
"Center of the sphere");
32 "depth", 3,
"Iteration steps in the triangle bisection construction");
38 _radius(getParam<
Real>(
"radius")),
39 _center(getParam<Point>(
"center")),
40 _depth(getParam<unsigned
int>(
"depth"))
44 std::unique_ptr<MeshBase>
49 mesh->set_mesh_dimension(2);
50 mesh->set_spatial_dimension(3);
57 const Real Z = X * phi;
58 const Point vdata[12] = {{-X, 0.0,
Z},
70 for (
unsigned int i = 0; i < 12; ++i)
74 const unsigned int tindices[20][3] = {{0, 4, 1}, {0, 9, 4}, {9, 5, 4}, {4, 5, 8}, {4, 8, 1},
75 {8, 10, 1}, {8, 3, 10}, {5, 3, 8}, {5, 2, 3}, {2, 7, 3},
76 {7, 10, 3}, {7, 6, 10}, {7, 11, 6}, {11, 0, 6}, {0, 1, 6},
77 {6, 1, 10}, {9, 0, 11}, {9, 11, 2}, {9, 2, 5}, {7, 2, 11}};
78 for (
unsigned int i = 0; i < 20; ++i)
80 Elem * elem =
mesh->add_elem(
new Tri3);
81 elem->set_node(0) =
mesh->node_ptr(tindices[i][0]);
82 elem->set_node(1) =
mesh->node_ptr(tindices[i][1]);
83 elem->set_node(2) =
mesh->node_ptr(tindices[i][2]);
87 if (!
mesh->is_replicated())
88 mesh->prepare_for_use();
93 MeshRefinement mesh_refinement(*
mesh);
96 for (
unsigned int r = 0; r <
_depth; ++r)
98 mesh_refinement.uniformly_refine(1);
100 auto it =
mesh->active_nodes_begin();
101 const auto end =
mesh->active_nodes_end();
103 for (; it != end; ++it)
106 node = sphere.closest_point(node);
111 MeshTools::Modification::flatten(*
mesh);
std::unique_ptr< MeshBase > generate() override
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
static InputParameters validParams()
const Real _radius
sphere radius
SphereSurfaceMeshGenerator(const InputParameters ¶meters)
Create a sphere surface mesh based on the recursive subdivision of the faces of a regular icosahedron...
static InputParameters validParams()
static const std::string Z
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObject("PhaseFieldApp", SphereSurfaceMeshGenerator)
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
const unsigned int _depth
recursion levels for triangle subdivision
void ErrorVector unsigned int