libMesh
face_inf_quad.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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 
19 // Local includes
20 #include "libmesh/libmesh_config.h"
21 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
22 
23 // Local includes cont'd
24 #include "libmesh/face_inf_quad.h"
25 #include "libmesh/edge_edge2.h"
26 #include "libmesh/edge_inf_edge2.h"
27 #include "libmesh/face_inf_quad4.h"
28 #include "libmesh/enum_elem_quality.h"
29 
30 namespace libMesh
31 {
32 
33 
34 // ------------------------------------------------------------
35 // InfQuad class static member initializations
36 
37 
38 // We need to require C++11...
39 const Real InfQuad::_master_points[6][3] =
40  {
41  {-1, 0},
42  {1, 0},
43  {-1, 1},
44  {1, 1},
45  {0, 0},
46  {0, 1}
47  };
48 
49 
50 // ------------------------------------------------------------
51 // InfQuad class member functions
52 dof_id_type InfQuad::key (const unsigned int s) const
53 {
54  libmesh_assert_less (s, this->n_sides());
55 
56  // The order of the node ids does not matter, they are sorted by the
57  // compute_key() function.
58  return this->compute_key(this->node_id(InfQuad4::side_nodes_map[s][0]),
59  this->node_id(InfQuad4::side_nodes_map[s][1]));
60 }
61 
62 
63 
64 dof_id_type InfQuad::low_order_key (const unsigned int s) const
65 {
66  libmesh_assert_less (s, this->n_sides());
67 
68  // The order of the node ids does not matter, they are sorted by the
69  // compute_key() function.
70  return this->compute_key(this->node_id(InfQuad4::side_nodes_map[s][0]),
71  this->node_id(InfQuad4::side_nodes_map[s][1]));
72 }
73 
74 
75 
76 unsigned int InfQuad::local_side_node(unsigned int side,
77  unsigned int side_node) const
78 {
79  libmesh_assert_less (side, this->n_sides());
80  libmesh_assert_less (side_node, 2);
81 
82  return InfQuad4::side_nodes_map[side][side_node];
83 }
84 
85 
86 
87 unsigned int InfQuad::local_edge_node(unsigned int edge,
88  unsigned int edge_node) const
89 {
90  return local_side_node(edge, edge_node);
91 }
92 
93 
94 
95 std::unique_ptr<Elem> InfQuad::side_ptr (const unsigned int i)
96 {
97  libmesh_assert_less (i, this->n_sides());
98 
99  // Return value
100  std::unique_ptr<Elem> edge;
101 
102  switch (i)
103  {
104  case 0: // base face
105  {
106  edge = std::make_unique<Edge2>();
107  break;
108  }
109 
110  case 1: // adjacent to another infinite element
111  case 2: // adjacent to another infinite element
112  {
113  edge = std::make_unique<InfEdge2>();
114  break;
115  }
116 
117  default:
118  libmesh_error_msg("Invalid side i = " << i);
119  }
120 
121  // Set the nodes
122  for (auto n : edge->node_index_range())
123  edge->set_node(n) = this->node_ptr(InfQuad4::side_nodes_map[i][n]);
124 
125  return edge;
126 }
127 
128 
129 
130 void InfQuad::side_ptr (std::unique_ptr<Elem> & side,
131  const unsigned int i)
132 {
133  libmesh_assert_less (i, this->n_sides());
134 
135  switch (i)
136  {
137  // the base face
138  case 0:
139  {
140  if (!side.get() || side->type() != EDGE2)
141  {
142  side = this->side_ptr(i);
143  return;
144  }
145  break;
146  }
147 
148  // connecting to another infinite element
149  case 1:
150  case 2:
151  {
152  if (!side.get() || side->type() != INFEDGE2)
153  {
154  side = this->side_ptr(i);
155  return;
156  }
157  break;
158  }
159 
160  default:
161  libmesh_error_msg("Invalid side i = " << i);
162  }
163 
164  side->subdomain_id() = this->subdomain_id();
165 
166  // Set the nodes
167  for (auto n : side->node_index_range())
168  side->set_node(n) = this->node_ptr(InfQuad4::side_nodes_map[i][n]);
169 }
170 
171 
172 bool InfQuad::is_child_on_side(const unsigned int c,
173  const unsigned int s) const
174 {
175  libmesh_assert_less (c, this->n_children());
176  libmesh_assert_less (s, this->n_sides());
177 
178  return (s == 0 || s == c+1);
179 }
180 
181 
182 bool
184 {
185  return (
186 #if LIBMESH_DIM > 2
187  // Don't bother outside the XY plane
188  this->point(0)(2) && this->point(1)(2) &&
189  this->point(2)(2) && this->point(3)(2) &&
190 #endif
191  ((this->point(1)(0)-this->point(0)(0))*
192  (this->point(2)(1)-this->point(0)(1)) >
193  (this->point(2)(0)-this->point(0)(0))*
194  (this->point(1)(1)-this->point(0)(1))));
195 }
196 
197 
199 {
200  return Elem::quality(q); // Not implemented
201 }
202 
203 
204 
205 
206 std::pair<Real, Real> InfQuad::qual_bounds (const ElemQuality q) const
207 {
208  std::pair<Real, Real> bounds;
209 
210  switch (q)
211  {
212 
213  case ASPECT_RATIO:
214  bounds.first = 1.;
215  bounds.second = 4.;
216  break;
217 
218  case SKEW:
219  bounds.first = 0.;
220  bounds.second = 0.5;
221  break;
222 
223  case TAPER:
224  bounds.first = 0.;
225  bounds.second = 0.7;
226  break;
227 
228  case WARP:
229  bounds.first = 0.9;
230  bounds.second = 1.;
231  break;
232 
233  case STRETCH:
234  bounds.first = 0.25;
235  bounds.second = 1.;
236  break;
237 
238  case MIN_ANGLE:
239  bounds.first = 45.;
240  bounds.second = 90.;
241  break;
242 
243  case MAX_ANGLE:
244  bounds.first = 90.;
245  bounds.second = 135.;
246  break;
247 
248  case CONDITION:
249  bounds.first = 1.;
250  bounds.second = 4.;
251  break;
252 
253  case JACOBIAN:
254  bounds.first = 0.5;
255  bounds.second = 1.;
256  break;
257 
258  case SHEAR:
259  case SHAPE:
260  case SIZE:
261  bounds.first = 0.3;
262  bounds.second = 1.;
263  break;
264 
265  case DISTORTION:
266  bounds.first = 0.6;
267  bounds.second = 1.;
268  break;
269 
270  default:
271  libMesh::out << "Warning: Invalid quality measure chosen." << std::endl;
272  bounds.first = -1;
273  bounds.second = -1;
274  }
275 
276  return bounds;
277 }
278 
279 } // namespace libMesh
280 
281 
282 
283 #endif // ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
virtual std::pair< Real, Real > qual_bounds(const ElemQuality q) const override
virtual unsigned int local_side_node(unsigned int side, unsigned int side_node) const override
Definition: face_inf_quad.C:76
virtual dof_id_type key() const
Definition: elem.C:563
static const unsigned int side_nodes_map[num_sides][nodes_per_side]
This maps the node of the side to element node numbers.
static const Real _master_points[6][3]
Master element node locations.
The libMesh namespace provides an interface to certain functionality in the library.
virtual bool is_child_on_side(const unsigned int c, const unsigned int s) const override final
ElemQuality
Defines an enum for element quality metrics.
virtual Real quality(const ElemQuality q) const override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
subdomain_id_type subdomain_id() const
Definition: elem.h:2391
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:2331
virtual unsigned int n_sides() const override final
OStreamProxy out
virtual bool is_flipped() const override final
virtual Real quality(const ElemQuality q) const
Definition: elem.C:1582
virtual unsigned int n_children() const override final
virtual dof_id_type low_order_key(const unsigned int s) const override
Definition: face_inf_quad.C:64
static dof_id_type compute_key(dof_id_type n0)
Definition: elem.h:3131
virtual unsigned int local_edge_node(unsigned int edge, unsigned int edge_node) const override
Calls local_side_node(edge, edge_node).
Definition: face_inf_quad.C:87
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:2299
const Point & point(const unsigned int i) const
Definition: elem.h:2277
virtual std::unique_ptr< Elem > side_ptr(const unsigned int i) override final
Definition: face_inf_quad.C:95
uint8_t dof_id_type
Definition: id_types.h:67