31 {
32 const Real minpos = 1.5, maxpos = 5.5;
33 const unsigned int N = 2;
34
35 _mesh = std::make_unique<Mesh>(*TestCommWorld);
36
37 std::unique_ptr<Elem> test_elem;
38
41
42#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
43#if LIBMESH_DIM > 1
44 if (test_elem.get() && test_elem->infinite())
45 {
46 Elem * elem =
_mesh->add_elem(std::move(test_elem));
47
48 const auto add_point =
49 [this, elem](const unsigned int i,
53#if LIBMESH_DIM == 3
54 z
55#endif
56 )
57 {
58#if LIBMESH_DIM == 2
60#else
61 auto node =
_mesh->add_point(
Point(x, y, z), i);
62#endif
64 };
65
66 const Real halfpos = (minpos + maxpos) / 2.;
67
70 {
72
73 add_point(0, minpos, minpos, minpos);
74 add_point(1, maxpos, minpos, minpos);
75 add_point(2+is_quad, maxpos, maxpos, minpos);
76 add_point(3-is_quad, minpos, maxpos, minpos);
77
79 {
80 add_point(4, halfpos, minpos, minpos);
81 add_point(5, halfpos, maxpos, minpos);
82 }
83 }
85 {
86 add_point(4, minpos, minpos, maxpos);
87 add_point(5, maxpos, minpos, maxpos);
88 add_point(6, maxpos, maxpos, maxpos);
89 add_point(7, minpos, maxpos, maxpos);
90
92 {
93 add_point(8, halfpos, minpos, minpos);
94 add_point(9, maxpos, halfpos, minpos);
95 add_point(10, halfpos, maxpos, minpos);
96 add_point(11, minpos, halfpos, minpos);
97 add_point(12, halfpos, minpos, maxpos);
98 add_point(13, maxpos, halfpos, maxpos);
99 add_point(14, halfpos, maxpos, maxpos);
100 add_point(15, minpos, halfpos, maxpos);
101 }
103 {
104 add_point(16, halfpos, halfpos, minpos);
105 add_point(17, halfpos, halfpos, maxpos);
106 }
107 }
109 {
110 add_point(0, minpos, minpos, minpos);
111 add_point(1, maxpos, minpos, minpos);
112 add_point(2, halfpos, maxpos, minpos);
113 add_point(3, minpos, minpos, maxpos);
114 add_point(4, maxpos, minpos, maxpos);
115 add_point(5, halfpos, maxpos, maxpos);
116
118 {
119 add_point(6, halfpos, minpos, minpos);
120 add_point(7, (halfpos + maxpos) / 2., halfpos, minpos);
121 add_point(8, (halfpos + minpos) / 2., halfpos, minpos);
122 add_point(9, halfpos, minpos, maxpos);
123 add_point(10, (halfpos + maxpos) / 2., halfpos, maxpos);
124 add_point(11, (halfpos + minpos) / 2., halfpos, maxpos);
125 }
126 }
127
128 _mesh->prepare_for_use();
129 }
130 else
131#endif
132#endif
134 {
135
136
137
138
139
140
141
147
148 std::unique_ptr<Elem> polygon = std::make_unique<C0Polygon>(5);
150 polygon->set_node(i,
_mesh->node_ptr(i));
151 polygon->set_id() = 0;
152
153 _mesh->add_elem(std::move(polygon));
154 _mesh->prepare_for_use();
155 }
157 {
158
159
160
161
162#if 0
163
164
165
166
167
176
177
182
183
188
189
198
199 const std::vector<std::vector<unsigned int>> nodes_on_side =
200 { {0, 1, 2, 3, 4, 5, 6, 7},
201 {0, 1, 9, 13, 17, 16, 12, 8},
202 {2, 3, 10, 14, 19, 18, 13, 9},
203 {4, 5, 11, 15, 21, 20, 14, 10},
204 {6, 7, 8, 12, 23, 22, 15, 11},
205 {16, 17, 18, 19, 20, 21, 22, 23},
206 {7, 0, 8},
207 {1, 2, 9},
208 {3, 4, 10},
209 {5, 6, 11},
210 {23, 16, 12},
211 {17, 18, 13},
212 {19, 20, 14},
213 {21, 22, 15} };
214#endif
215
216#if 1
217
218
219
228
229
230
231
232
233
234
235
236
237
238 const std::vector<std::vector<unsigned int>> nodes_on_side =
239 { {0, 1, 2, 3},
240 {5, 6, 7, 4},
241 {0, 1, 5, 4},
242
243 {2, 6, 5, 1},
244 {2, 3, 7, 6},
245
246 {0, 4, 7, 3} };
247#endif
248
249
250 std::vector<std::shared_ptr<Polygon>> sides(nodes_on_side.size());
251
253 {
254 const auto & nodes_on_s = nodes_on_side[s];
255 sides[s] = std::make_shared<C0Polygon>(nodes_on_s.size());
257 sides[s]->set_node(i,
_mesh->node_ptr(nodes_on_s[i]));
258 }
259
260 std::unique_ptr<libMesh::Node> mid_elem_node;
261 std::unique_ptr<Elem> polyhedron = std::make_unique<C0Polyhedron>(sides, mid_elem_node);
262 _mesh->add_elem(std::move(polyhedron));
263 if (mid_elem_node)
264 _mesh->add_node(std::move(mid_elem_node));
265 _mesh->prepare_for_use();
266 }
267 else
268 {
269 const unsigned int dim = test_elem->dim();
270 const unsigned int use_x =
dim > 0;
271 const unsigned int use_y =
dim > 1;
272 const unsigned int use_z =
dim > 2;
273
275 N*use_x, N*use_y, N*use_z,
276 minpos, maxpos,
277 minpos, use_y*maxpos,
278 minpos, use_z*maxpos,
279 elem_type);
280 }
281
282
283
284
285
286
287 for (const auto & elem :
288 this->
_mesh->element_ptr_range())
289 {
292 std::ostringstream sbdname;
293 sbdname <<
294 "a_very_long_subdomain_name_for_the_subdomain_with_number_" << sbdid;
295 this->
_mesh->set_subdomain_name(sbdid, sbdname.str());
296 }
297
298
299
300 this->
_mesh->cache_elem_data();
301
302
303
304
305 this->
_mesh->sync_subdomain_name_map();
306 }
std::unique_ptr< Mesh > _mesh
This is the base class from which all geometric element types are derived.
virtual Node *& set_node(const unsigned int i)
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
subdomain_id_type subdomain_id() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...