libMesh
Loading...
Searching...
No Matches
face_tri7.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18// Local includes
19#include "libmesh/edge_edge3.h"
20#include "libmesh/face_tri7.h"
21#include "libmesh/enum_io_package.h"
22#include "libmesh/enum_order.h"
23
24#ifdef LIBMESH_ENABLE_AMR
25namespace {
26 constexpr libMesh::Real r18 = 18;
27}
28#endif
29
30namespace libMesh
31{
32
33
34
35
36// ------------------------------------------------------------
37// Tri7 class static member initializations
38const int Tri7::num_nodes;
39const int Tri7::nodes_per_side;
40
41
42#ifdef LIBMESH_ENABLE_AMR
43
45 {
46 // embedding matrix for child 0
47 {
48 // 0 1 2 3 4 5 6
49 { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 0
50 { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // 1
51 { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 2
52 { .375, -.125, 0.0, .75, 0.0, 0.0, 0.0}, // 3
53 {.09375,-.03125,-.03125, .125, -.125, .125,.84375}, // 4
54 { .375, 0.0, -.125, 0.0, 0.0, .75, 0.0}, // 5
55 { 5/r18,-1/r18,-1/r18,4/r18,-2/r18,4/r18, 0.5} // 6
56 },
57
58 // embedding matrix for child 1
59 {
60 // 0 1 2 3 4 5 6
61 { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // 0
62 { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 1
63 { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 2
64 { -.125, .375, 0.0, .75, 0.0, 0.0, 0.0}, // 3
65 { 0.0, .375, -.125, 0.0, .75, 0.0, 0.0}, // 4
66 {-.03125,.09375,-.03125, .125, .125, -.125,.84375}, // 5
67 {-1/r18, 5/r18,-1/r18,4/r18,4/r18,-2/r18, 0.5} // 6
68 },
69
70 // embedding matrix for child 2
71 {
72 // 0 1 2 3 4 5 6
73 { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 0
74 { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 1
75 { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0}, // 2
76 {-.03125,-.03125,.09375, -.125, .125, .125,.84375}, // 3
77 { 0.0, -.125, .375, 0.0, .75, 0.0, 0.0}, // 4
78 { -.125, 0.0, .375, 0.0, 0.0, .75, 0.0}, // 5
79 {-1/r18,-1/r18, 5/r18,-2/r18,4/r18,4/r18, 0.5} // 6
80 },
81
82 // embedding matrix for child 3
83 {
84 // 0 1 2 3 4 5 6
85 { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // 0
86 { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 1
87 { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 2
88 {-.03125,.09375,-.03125, .125, .125,-.125,.84375}, // 3
89 {-.03125,-.03125,.09375,-.125, .125, .125,.84375}, // 4
90 {.09375,-.03125,-.03125, .125,-.125, .125,.84375}, // 5
91 { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0} // 6
92 }
93 };
94
95const std::vector<std::pair<unsigned char, unsigned char>>
97 {
98 // Child 0
99 { {},{{0,1}},{{0,2}},{{0,3}},{{3,5}},{{0,5}},{{0,6}} },
100 // Child 1
101 { {{0,1}}, {},{{1,2}},{{1,3}},{{1,4}},{{3,4}},{{1,6}} },
102 // Child 2
103 { {{0,2}},{{1,2}}, {},{{4,5}},{{2,4}},{{2,5}},{{2,6}} },
104 // Child 3
105 { {{0,1}},{{1,2}},{{0,2}},{{3,4}},{{4,5}},{{3,5}},{{0,4},{1,5},{2,3}} }
106 };
107#endif
108
109
110
111// ------------------------------------------------------------
112// Tri7 class member functions
113
114bool Tri7::is_vertex(const unsigned int i) const
115{
116 if (i < 3)
117 return true;
118 return false;
119}
120
121bool Tri7::is_edge(const unsigned int i) const
122{
123 if (i < 3 || i == 6)
124 return false;
125 return true;
126}
127
128bool Tri7::is_face(const unsigned int i) const
129{
130 if (i > 5)
131 return true;
132 return false;
133}
134
135bool Tri7::is_node_on_side(const unsigned int n,
136 const unsigned int s) const
137{
138 libmesh_assert_less (s, n_sides());
139 return std::find(std::begin(side_nodes_map[s]),
140 std::end(side_nodes_map[s]),
141 n) != std::end(side_nodes_map[s]);
142}
143
144std::vector<unsigned>
145Tri7::nodes_on_side(const unsigned int s) const
146{
147 libmesh_assert_less(s, n_sides());
148 return {std::begin(side_nodes_map[s]), std::end(side_nodes_map[s])};
149}
150
151std::vector<unsigned>
152Tri7::nodes_on_edge(const unsigned int e) const
153{
154 return nodes_on_side(e);
155}
156
158{
159 // Make sure edges are straight
160 Point v = this->point(2) - this->point(1);
162 ((this->point(4) - this->point(1))*2))
163 return false;
164 v = this->point(1) - this->point(0);
166 ((this->point(3) - this->point(0))*2))
167 return false;
168 Point v20 = this->point(2) - this->point(0);
169 if (!v20.relative_fuzzy_equals
170 ((this->point(5) - this->point(0))*2))
171 return false;
172
173 // Make sure center node is centered
174 v += v20;
176 ((this->point(6) - this->point(0))*3))
177 return false;
178
179 return true;
180}
181
182
183
185{
186 return THIRD;
187}
188
189
190
192{
193 return SECOND;
194}
195
196
197
198dof_id_type Tri7::key (const unsigned int s) const
199{
200 libmesh_assert_less (s, this->n_sides());
201
202 switch (s)
203 {
204 case 0:
205
206 return
207 this->compute_key (this->node_id(3));
208
209 case 1:
210
211 return
212 this->compute_key (this->node_id(4));
213
214 case 2:
215
216 return
217 this->compute_key (this->node_id(5));
218
219 default:
220 libmesh_error_msg("Invalid side s = " << s);
221 }
222}
223
224
225
226unsigned int Tri7::local_side_node(unsigned int side,
227 unsigned int side_node) const
228{
229 libmesh_assert_less (side, this->n_sides());
230 libmesh_assert_less (side_node, Tri7::nodes_per_side);
231
232 return Tri7::side_nodes_map[side][side_node];
233}
234
235
236
237std::unique_ptr<Elem> Tri7::build_side_ptr (const unsigned int i)
238{
239 return this->simple_build_side_ptr<Edge3, Tri7>(i);
240}
241
242
243
244void Tri7::build_side_ptr (std::unique_ptr<Elem> & side,
245 const unsigned int i)
246{
247 this->simple_build_side_ptr<Tri7>(side, i, EDGE3);
248}
249
250
251
252void Tri7::connectivity(const unsigned int sf,
253 const IOPackage iop,
254 std::vector<dof_id_type> & conn) const
255{
256 libmesh_assert_less (sf, this->n_sub_elem());
257 libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
258
259 switch (iop)
260 {
261 case TECPLOT:
262 {
263 conn.resize(4);
264 switch(sf)
265 {
266 case 0:
267 // linear sub-triangle 0
268 conn[0] = this->node_id(0)+1;
269 conn[1] = this->node_id(3)+1;
270 conn[2] = this->node_id(5)+1;
271 conn[3] = this->node_id(5)+1;
272
273 return;
274
275 case 1:
276 // linear sub-triangle 1
277 conn[0] = this->node_id(3)+1;
278 conn[1] = this->node_id(1)+1;
279 conn[2] = this->node_id(4)+1;
280 conn[3] = this->node_id(4)+1;
281
282 return;
283
284 case 2:
285 // linear sub-triangle 2
286 conn[0] = this->node_id(5)+1;
287 conn[1] = this->node_id(4)+1;
288 conn[2] = this->node_id(2)+1;
289 conn[3] = this->node_id(2)+1;
290
291 return;
292
293 case 3:
294 // linear sub-triangle 3
295 conn[0] = this->node_id(3)+1;
296 conn[1] = this->node_id(4)+1;
297 conn[2] = this->node_id(5)+1;
298 conn[3] = this->node_id(5)+1;
299
300 return;
301
302 default:
303 libmesh_error_msg("Invalid sf = " << sf);
304 }
305 }
306
307 case VTK:
308 {
309 // VTK has a vtkBiQuadraticTriangle class whose connectivity matches libMesh's
310 conn.resize(Tri7::num_nodes);
311 for (auto i : index_range(conn))
312 conn[i] = this->node_id(i);
313 return;
314 }
315
316 default:
317 libmesh_error_msg("Unsupported IO package " << iop);
318 }
319}
320
321
322
324{
325 // This might have curved edges, or might be a curved surface in
326 // 3-space, in which case the full bounding box can be larger than
327 // the bounding box of just the nodes.
328 //
329 //
330 // FIXME - I haven't yet proven the formula below to be correct for
331 // quadratics in 2D - RHS
332 //
333 // FIXME - This doesn't take into account curvature caused by the
334 // center node in 3D - RHS
335 Point pmin, pmax;
336
337 for (unsigned d=0; d<LIBMESH_DIM; ++d)
338 {
339 Real center = this->point(0)(d);
340 for (unsigned int p=1; p != 6; ++p)
341 center += this->point(p)(d);
342 center /= 6;
343
344 Real hd = std::abs(center - this->point(0)(d));
345 for (unsigned int p=1; p != 6; ++p)
346 hd = std::max(hd, std::abs(center - this->point(p)(d)));
347
348 pmin(d) = center - hd;
349 pmax(d) = center + hd;
350 }
351
352 return BoundingBox(pmin, pmax);
353}
354
355
356
357unsigned int Tri7::n_second_order_adjacent_vertices (const unsigned int n) const
358{
359 switch (n)
360 {
361 case 3:
362 case 4:
363 case 5:
364 return 2;
365
366 case 6:
367 return 3;
368
369 default:
370 libmesh_error_msg("Invalid n = " << n);
371 }
372}
373
374
375
376unsigned short int Tri7::second_order_adjacent_vertex (const unsigned int n,
377 const unsigned int v) const
378{
379 libmesh_assert_greater_equal (n, this->n_vertices());
380 libmesh_assert_less (n, this->n_nodes());
381
382 switch (n)
383 {
384 case 6:
385 {
386 libmesh_assert_less (v, 3);
387 return static_cast<unsigned short int>(v);
388 }
389
390 default:
391 {
392 libmesh_assert_less (v, 2);
393 return _second_order_adjacent_vertices[n-this->n_vertices()][v];
394 }
395 }
396}
397
398
399
400const unsigned short int Tri7::_second_order_adjacent_vertices[Tri7::num_sides][2] =
401 {
402 {0, 1}, // vertices adjacent to node 3
403 {1, 2}, // vertices adjacent to node 4
404 {0, 2} // vertices adjacent to node 5
405 };
406
407
408
409std::pair<unsigned short int, unsigned short int>
410Tri7::second_order_child_vertex (const unsigned int n) const
411{
412 libmesh_assert_greater_equal (n, this->n_vertices());
413 libmesh_assert_less (n, this->n_nodes());
414 return std::pair<unsigned short int, unsigned short int>
417}
418
419
420
422 {
423 99,99,99, // Vertices
424 0,1,0, // Edges
425 3 // Interior
426 };
427
428
429
431 {
432 99,99,99, // Vertices
433 1,2,2, // Edges
434 6 // Interior
435 };
436
437
438void Tri7::permute(unsigned int perm_num)
439{
440 libmesh_assert_less (perm_num, 3);
441
442 for (unsigned int i = 0; i != perm_num; ++i)
443 {
444 swap3nodes(0,1,2);
445 swap3nodes(3,4,5);
446 swap3neighbors(0,1,2);
447 }
448}
449
450
451void Tri7::flip(BoundaryInfo * boundary_info)
452{
453 libmesh_assert(boundary_info);
454
455 swap2nodes(0,1);
456 swap2nodes(4,5);
457 swap2neighbors(1,2);
458 swap2boundarysides(1,2,boundary_info);
459 swap2boundaryedges(1,2,boundary_info);
460}
461
462
463unsigned int Tri7::center_node_on_side(const unsigned short side) const
464{
465 libmesh_assert_less (side, Tri7::num_sides);
466 return side + 3;
467}
468
469
471Tri7::side_type (const unsigned int libmesh_dbg_var(s)) const
472{
473 libmesh_assert_less (s, 3);
474 return EDGE3;
475}
476
477
478} // namespace libMesh
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
Defines a Cartesian bounding box by the two corner extremum.
const Point & point(const unsigned int i) const
Definition elem.h:2583
void swap2nodes(unsigned int n1, unsigned int n2)
Swaps two node_ptrs.
Definition elem.h:2222
void swap3neighbors(unsigned int n1, unsigned int n2, unsigned int n3)
Swaps three neighbor_ptrs, "rotating" them.
Definition elem.h:2263
void swap2neighbors(unsigned int n1, unsigned int n2)
Swaps two neighbor_ptrs.
Definition elem.h:2232
void swap2boundarysides(unsigned short s1, unsigned short s2, BoundaryInfo *boundary_info) const
Swaps two sides in boundary_info, if it is non-null.
Definition elem.C:3982
static dof_id_type compute_key(dof_id_type n0)
Definition elem.h:3432
void swap3nodes(unsigned int n1, unsigned int n2, unsigned int n3)
Swaps three node_ptrs, "rotating" them.
Definition elem.h:2254
void swap2boundaryedges(unsigned short e1, unsigned short e2, BoundaryInfo *boundary_info) const
Swaps two edges in boundary_info, if it is non-null.
Definition elem.C:3998
dof_id_type node_id(const unsigned int i) const
Definition elem.h:2605
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
virtual Order default_order() const override
Definition face_tri7.C:184
virtual void connectivity(const unsigned int sf, const IOPackage iop, std::vector< dof_id_type > &conn) const override
Definition face_tri7.C:252
static constexpr const unsigned int(& side_nodes_map)[num_sides][nodes_per_side]
Definition face_tri7.h:216
virtual Order default_side_order() const override
Definition face_tri7.C:191
ElemType side_type(const unsigned int s) const override final
Definition face_tri7.C:471
virtual std::pair< unsigned short int, unsigned short int > second_order_child_vertex(const unsigned int n) const override
Definition face_tri7.C:410
virtual unsigned int local_side_node(unsigned int side, unsigned int side_node) const override
Definition face_tri7.C:226
virtual BoundingBox loose_bounding_box() const override
Definition face_tri7.C:323
virtual bool has_affine_map() const override
Definition face_tri7.C:157
virtual void flip(BoundaryInfo *) override final
Flips the element (by swapping node and neighbor pointers) to have a mapping Jacobian of opposite sig...
Definition face_tri7.C:451
virtual std::vector< unsigned int > nodes_on_side(const unsigned int s) const override
Definition face_tri7.C:145
virtual bool is_edge(const unsigned int i) const override
Definition face_tri7.C:121
virtual unsigned int n_nodes() const override
Definition face_tri7.h:88
virtual bool is_face(const unsigned int i) const override
Definition face_tri7.C:128
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i) override
Definition face_tri7.C:237
static const int nodes_per_side
Definition face_tri7.h:207
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const override
Definition face_tri7.C:135
unsigned int center_node_on_side(const unsigned short side) const override final
Definition face_tri7.C:463
virtual std::vector< unsigned int > nodes_on_edge(const unsigned int e) const override
Definition face_tri7.C:152
virtual unsigned int n_second_order_adjacent_vertices(const unsigned int) const override
Definition face_tri7.C:357
virtual dof_id_type key() const
Don't hide Elem::key() defined in the base class.
Definition elem.C:678
virtual void permute(unsigned int perm_num) override final
Permutes the element (by swapping node and neighbor pointers) according to the specified index.
Definition face_tri7.C:438
static const int num_nodes
Geometric constants for Tri7.
Definition face_tri7.h:206
virtual unsigned int n_sub_elem() const override
Definition face_tri7.h:93
static const unsigned short int _second_order_adjacent_vertices[num_sides][2]
Matrix that tells which vertices define the location of mid-side (or second-order) nodes.
Definition face_tri7.h:282
static const std::vector< std::pair< unsigned char, unsigned char > > _parent_bracketing_nodes[num_children][num_nodes]
Pairs of nodes that bracket child nodes when doing mesh refinement.
Definition face_tri7.h:270
virtual unsigned short int second_order_adjacent_vertex(const unsigned int n, const unsigned int v) const override
Definition face_tri7.C:376
static const unsigned short int _second_order_vertex_child_number[num_nodes]
Vector that names a child sharing each second order node.
Definition face_tri7.h:287
static const unsigned short int _second_order_vertex_child_index[num_nodes]
Vector that names the child vertex index for each second order node.
Definition face_tri7.h:292
static const Real _embedding_matrix[num_children][num_nodes][num_nodes]
Matrix that computes new nodal locations/solution values from current nodes/solution.
Definition face_tri7.h:263
virtual bool is_vertex(const unsigned int i) const override
Definition face_tri7.C:114
virtual unsigned int n_vertices() const override final
Definition face_tri.h:103
static const int num_children
Definition face_tri.h:87
virtual unsigned int n_sides() const override final
Definition face_tri.h:98
static const int num_sides
Geometric constants for all Tris.
Definition face_tri.h:86
bool relative_fuzzy_equals(const TypeVector< T > &rhs, Real tol=TOLERANCE) const
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153
IOPackage
libMesh interfaces with several different software packages for the purposes of creating,...
ElemType
Defines an enum for geometric element types.
libmesh_assert(ctx)
uint8_t dof_id_type
Definition id_types.h:67
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real