Line data Source code
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 :
19 :
20 : // C++ includes
21 : #include <cstdlib> // *must* precede <cmath> for proper std:abs() on PGI, Sun Studio CC
22 : #include <cmath> // for std::sqrt
23 :
24 :
25 : // Local includes
26 : #include "libmesh/libmesh_common.h"
27 : #include "libmesh/fe.h"
28 : #include "libmesh/fe_interface.h"
29 : #include "libmesh/quadrature.h"
30 : #include "libmesh/elem.h"
31 : #include "libmesh/libmesh_logging.h"
32 : #include "libmesh/tensor_value.h" // May be necessary if destructors
33 : // get instantiated here
34 :
35 : namespace libMesh
36 : {
37 :
38 : //-------------------------------------------------------
39 : // Full specializations for useless methods in 0D, 1D
40 : #define REINIT_ERROR(_dim, _type, _func) \
41 : template <> \
42 : void FE<_dim,_type>::_func(const Elem *, \
43 : const unsigned int, \
44 : const Real, \
45 : const std::vector<Point> * const, \
46 : const std::vector<Real> * const)
47 :
48 : #define SIDEMAP_ERROR(_dim, _type, _func) \
49 : template <> \
50 : void FE<_dim,_type>::_func(const Elem *, \
51 : const Elem *, \
52 : const unsigned int, \
53 : const std::vector<Point> &, \
54 : std::vector<Point> &)
55 :
56 : #define FACE_EDGE_SHAPE_ERROR(_dim, _func) \
57 : template <> \
58 : void FEMap::_func<_dim>(const std::vector<Point> &, \
59 : const Elem *) \
60 : { \
61 : libmesh_error_msg("ERROR: This method makes no sense for low-D elements!"); \
62 : }
63 :
64 : // 0D error instantiations
65 : #define LIBMESH_ERRORS_IN_LOW_D(_type) \
66 : REINIT_ERROR(0, _type, reinit) { libmesh_error_msg("ERROR: Cannot reinit 0D " #_type " elements!"); } \
67 : REINIT_ERROR(0, _type, edge_reinit) { libmesh_error_msg("ERROR: Cannot edge_reinit 0D " #_type " elements!"); } \
68 : SIDEMAP_ERROR(0, _type, side_map) { libmesh_error_msg("ERROR: Cannot side_map 0D " #_type " elements!"); } \
69 : SIDEMAP_ERROR(0, _type, edge_map) { libmesh_error_msg("ERROR: Cannot edge_map 0D " #_type " elements!"); } \
70 : REINIT_ERROR(1, _type, edge_reinit) { libmesh_error_msg("ERROR: Cannot edge_reinit 1D " #_type " elements!"); } \
71 : SIDEMAP_ERROR(1, _type, edge_map) { libmesh_error_msg("ERROR: Cannot edge_map 1D " #_type " elements!"); }
72 :
73 0 : LIBMESH_ERRORS_IN_LOW_D(CLOUGH)
74 0 : LIBMESH_ERRORS_IN_LOW_D(HERMITE)
75 0 : LIBMESH_ERRORS_IN_LOW_D(HIERARCHIC)
76 0 : LIBMESH_ERRORS_IN_LOW_D(L2_HIERARCHIC)
77 0 : LIBMESH_ERRORS_IN_LOW_D(HIERARCHIC_VEC)
78 0 : LIBMESH_ERRORS_IN_LOW_D(L2_HIERARCHIC_VEC)
79 0 : LIBMESH_ERRORS_IN_LOW_D(SIDE_HIERARCHIC)
80 0 : LIBMESH_ERRORS_IN_LOW_D(LAGRANGE)
81 0 : LIBMESH_ERRORS_IN_LOW_D(L2_LAGRANGE)
82 0 : LIBMESH_ERRORS_IN_LOW_D(L2_LAGRANGE_GLL)
83 0 : LIBMESH_ERRORS_IN_LOW_D(LAGRANGE_GLL)
84 0 : LIBMESH_ERRORS_IN_LOW_D(LAGRANGE_VEC)
85 0 : LIBMESH_ERRORS_IN_LOW_D(L2_LAGRANGE_VEC)
86 0 : LIBMESH_ERRORS_IN_LOW_D(MONOMIAL)
87 0 : LIBMESH_ERRORS_IN_LOW_D(MONOMIAL_VEC)
88 0 : LIBMESH_ERRORS_IN_LOW_D(NEDELEC_ONE)
89 0 : LIBMESH_ERRORS_IN_LOW_D(RAVIART_THOMAS)
90 0 : LIBMESH_ERRORS_IN_LOW_D(L2_RAVIART_THOMAS)
91 0 : LIBMESH_ERRORS_IN_LOW_D(SCALAR)
92 0 : LIBMESH_ERRORS_IN_LOW_D(XYZ)
93 :
94 : #ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
95 0 : LIBMESH_ERRORS_IN_LOW_D(BERNSTEIN)
96 0 : LIBMESH_ERRORS_IN_LOW_D(SZABAB)
97 0 : LIBMESH_ERRORS_IN_LOW_D(RATIONAL_BERNSTEIN)
98 : #endif
99 :
100 : // Special error instantiations
101 0 : REINIT_ERROR(1, NEDELEC_ONE, reinit) { libmesh_error_msg("ERROR: Cannot reinit 1D NEDELEC_ONE elements!"); }
102 0 : SIDEMAP_ERROR(1, NEDELEC_ONE, side_map) { libmesh_error_msg("ERROR: Cannot side_map 1D NEDELEC_ONE elements!"); }
103 0 : REINIT_ERROR(1, RAVIART_THOMAS, reinit) { libmesh_error_msg("ERROR: Cannot reinit 1D RAVIART_THOMAS elements!"); }
104 0 : SIDEMAP_ERROR(1, RAVIART_THOMAS, side_map) { libmesh_error_msg("ERROR: Cannot side_map 1D RAVIART_THOMAS elements!"); }
105 0 : REINIT_ERROR(1, L2_RAVIART_THOMAS, reinit) { libmesh_error_msg("ERROR: Cannot reinit 1D L2_RAVIART_THOMAS elements!"); }
106 0 : SIDEMAP_ERROR(1, L2_RAVIART_THOMAS, side_map) { libmesh_error_msg("ERROR: Cannot side_map 1D L2_RAVIART_THOMAS elements!"); }
107 :
108 : //-------------------------------------------------------
109 : // Methods for 2D, 3D
110 : template <unsigned int Dim, FEFamily T>
111 27860068 : void FE<Dim,T>::reinit(const Elem * elem,
112 : const unsigned int s,
113 : const Real /* tolerance */,
114 : const std::vector<Point> * const pts,
115 : const std::vector<Real> * const weights)
116 : {
117 2510425 : libmesh_assert(elem);
118 2510425 : libmesh_assert (this->qrule != nullptr || pts != nullptr);
119 : // We now do this for 1D elements!
120 : // libmesh_assert_not_equal_to (Dim, 1);
121 :
122 : // If we called this function redundantly (e.g. in an FEMContext
123 : // that is asked not to do any side calculations) then let's skip the
124 : // whole inverse_map process that calculates side points
125 27860068 : if (this->calculating_nothing())
126 : {
127 1891557 : this->calculations_started = true; // Ironic
128 1891557 : return;
129 : }
130 :
131 : // We're (possibly re-) calculating now! FIXME - we currently
132 : // expect to be able to use side_map and JxW later, but we could
133 : // optimize further here.
134 25968511 : this->_fe_map->add_calculations();
135 2344712 : this->_fe_map->get_JxW();
136 2344712 : this->_fe_map->get_xyz();
137 25968511 : this->determine_calculations();
138 :
139 : // Build the side of interest
140 25968511 : const std::unique_ptr<const Elem> side(elem->build_side_ptr(s));
141 :
142 : // Find the max p_level to select
143 : // the right quadrature rule for side integration
144 25968511 : unsigned int side_p_level = elem->p_level();
145 28313223 : if (elem->neighbor_ptr(s) != nullptr)
146 25243838 : side_p_level = std::max(side_p_level, elem->neighbor_ptr(s)->p_level());
147 :
148 : // Initialize the shape functions at the user-specified
149 : // points
150 25968511 : if (pts != nullptr)
151 : {
152 : // The shape functions do not correspond to the qrule
153 9399 : this->shapes_on_quadrature = false;
154 :
155 : // Initialize the face shape functions
156 9399 : this->_fe_map->template init_face_shape_functions<Dim>(*pts, side.get());
157 :
158 : // Compute the Jacobian*Weight on the face for integration
159 9399 : if (weights != nullptr)
160 : {
161 0 : this->_fe_map->compute_face_map (Dim, *weights, side.get());
162 : }
163 : else
164 : {
165 10035 : std::vector<Real> dummy_weights (pts->size(), 1.);
166 9399 : this->_fe_map->compute_face_map (Dim, dummy_weights, side.get());
167 : }
168 : }
169 : // If there are no user specified points, we use the
170 : // quadrature rule
171 : else
172 : {
173 : // initialize quadrature rule
174 25959112 : this->qrule->init(*side, side_p_level);
175 :
176 25959112 : if (this->qrule->shapes_need_reinit())
177 0 : this->shapes_on_quadrature = false;
178 :
179 : // FIXME - could this break if the same FE object was used
180 : // for both volume and face integrals? - RHS
181 : // We might not need to reinitialize the shape functions
182 49084305 : if ((this->get_type() != elem->type()) ||
183 25429321 : (elem->runtime_topology() &&
184 0 : this->_elem != elem) ||
185 25429321 : (side->type() != last_side) ||
186 46112115 : (this->_elem_p_level != side_p_level) ||
187 49021967 : this->shapes_need_reinit() ||
188 12243740 : !this->shapes_on_quadrature)
189 : {
190 : // Set the element
191 13715543 : this->_elem = elem;
192 13715543 : this->_elem_type = elem->type();
193 :
194 : // Set the last_side
195 13715543 : last_side = side->type();
196 :
197 : // Set the last p level
198 13715543 : this->_p_level = this->_add_p_level_in_reinit * side_p_level;
199 :
200 : // Initialize the face shape functions
201 14861254 : this->_fe_map->template init_face_shape_functions<Dim>(this->qrule->get_points(), side.get());
202 : }
203 : else
204 12243569 : this->_elem = elem;
205 :
206 : // Compute the Jacobian*Weight on the face for integration
207 28303506 : this->_fe_map->compute_face_map (Dim, this->qrule->get_weights(), side.get());
208 :
209 : // The shape functions correspond to the qrule
210 25959112 : this->shapes_on_quadrature = true;
211 : }
212 :
213 : // make a copy of the Jacobian for integration
214 28313223 : const std::vector<Real> JxW_int(this->_fe_map->get_JxW());
215 :
216 : // make a copy of shape on quadrature info
217 25968511 : bool shapes_on_quadrature_side = this->shapes_on_quadrature;
218 :
219 : // Find where the integration points are located on the
220 : // full element.
221 : const std::vector<Point> * ref_qp;
222 25968511 : if (pts != nullptr)
223 318 : ref_qp = pts;
224 : else
225 25959112 : ref_qp = &this->qrule->get_points();
226 :
227 4689424 : std::vector<Point> qp;
228 25968511 : this->side_map(elem, side.get(), s, *ref_qp, qp);
229 :
230 : // compute the shape function and derivative values
231 : // at the points qp
232 25968511 : this->reinit (elem, &qp);
233 :
234 25968511 : this->shapes_on_quadrature = shapes_on_quadrature_side;
235 :
236 25968511 : this->_elem_p_level = side_p_level;
237 :
238 : // copy back old data
239 25968511 : this->_fe_map->get_JxW() = JxW_int;
240 21279087 : }
241 :
242 :
243 :
244 : template <unsigned int Dim, FEFamily T>
245 199598 : void FE<Dim,T>::edge_reinit(const Elem * elem,
246 : const unsigned int e,
247 : const Real /* tolerance */,
248 : const std::vector<Point> * const pts,
249 : const std::vector<Real> * const weights)
250 : {
251 14539 : libmesh_assert(elem);
252 14539 : libmesh_assert (this->qrule != nullptr || pts != nullptr);
253 : // We don't do this for 1D elements!
254 : libmesh_assert_not_equal_to (Dim, 1);
255 :
256 : // We're (possibly re-) calculating now! Time to determine what.
257 : // FIXME - we currently just assume that we're using JxW and calling
258 : // edge_map later.
259 199598 : this->_fe_map->add_calculations();
260 14539 : this->_fe_map->get_JxW();
261 14539 : this->_fe_map->get_xyz();
262 199598 : this->determine_calculations();
263 :
264 : // Build the side of interest
265 199598 : const std::unique_ptr<const Elem> edge(elem->build_edge_ptr(e));
266 :
267 : // Initialize the shape functions at the user-specified
268 : // points
269 199598 : if (pts != nullptr)
270 : {
271 : // The shape functions do not correspond to the qrule
272 0 : this->shapes_on_quadrature = false;
273 :
274 : // Initialize the edge shape functions
275 0 : this->_fe_map->template init_edge_shape_functions<Dim> (*pts, edge.get());
276 :
277 : // Compute the Jacobian*Weight on the face for integration
278 0 : if (weights != nullptr)
279 : {
280 0 : this->_fe_map->compute_edge_map (Dim, *weights, edge.get());
281 : }
282 : else
283 : {
284 0 : std::vector<Real> dummy_weights (pts->size(), 1.);
285 0 : this->_fe_map->compute_edge_map (Dim, dummy_weights, edge.get());
286 : }
287 : }
288 : // If there are no user specified points, we use the
289 : // quadrature rule
290 : else
291 : {
292 : // initialize quadrature rule
293 214137 : this->qrule->init(*edge, elem->p_level());
294 :
295 199598 : if (this->qrule->shapes_need_reinit())
296 0 : this->shapes_on_quadrature = false;
297 :
298 : // We might not need to reinitialize the shape functions
299 375267 : if ((this->get_type() != elem->type()) ||
300 189699 : (elem->runtime_topology() &&
301 0 : this->_elem != elem) ||
302 351338 : (edge->type() != last_edge) ||
303 375267 : this->shapes_need_reinit() ||
304 36096 : !this->shapes_on_quadrature)
305 : {
306 : // Set the element
307 199598 : this->_elem = elem;
308 199598 : this->_elem_type = elem->type();
309 :
310 : // Set the last_edge
311 199598 : last_edge = edge->type();
312 :
313 : // Initialize the edge shape functions
314 214137 : this->_fe_map->template init_edge_shape_functions<Dim> (this->qrule->get_points(), edge.get());
315 : }
316 : else
317 0 : this->_elem = elem;
318 :
319 : // Compute the Jacobian*Weight on the face for integration
320 214137 : this->_fe_map->compute_edge_map (Dim, this->qrule->get_weights(), edge.get());
321 :
322 : // The shape functions correspond to the qrule
323 199598 : this->shapes_on_quadrature = true;
324 : }
325 :
326 : // make a copy of the Jacobian for integration
327 214137 : const std::vector<Real> JxW_int(this->_fe_map->get_JxW());
328 :
329 : // Find where the integration points are located on the
330 : // full element.
331 : const std::vector<Point> * ref_qp;
332 199598 : if (pts != nullptr)
333 0 : ref_qp = pts;
334 : else
335 199598 : ref_qp = & this->qrule->get_points();
336 :
337 29078 : std::vector<Point> qp;
338 199598 : this->edge_map(elem, edge.get(), e, *ref_qp, qp);
339 :
340 : // compute the shape function and derivative values
341 : // at the points qp
342 199598 : this->reinit (elem, &qp);
343 :
344 : // copy back old data
345 199598 : this->_fe_map->get_JxW() = JxW_int;
346 199598 : }
347 :
348 : template <unsigned int Dim, FEFamily T>
349 25996351 : void FE<Dim,T>::side_map (const Elem * elem,
350 : const Elem * side,
351 : const unsigned int s,
352 : const std::vector<Point> & reference_side_points,
353 : std::vector<Point> & reference_points)
354 : {
355 : // We're calculating mappings - we need at least first order info
356 25996351 : this->calculate_phi = true;
357 25996351 : this->determine_calculations();
358 :
359 25996351 : unsigned int side_p_level = elem->p_level();
360 28343383 : if (elem->neighbor_ptr(s) != nullptr)
361 25274200 : side_p_level = std::max(side_p_level, elem->neighbor_ptr(s)->p_level());
362 :
363 49636244 : if (side->type() != last_side ||
364 25986597 : (elem->runtime_topology() &&
365 0 : this->_elem != elem) ||
366 54329364 : side_p_level != this->_elem_p_level ||
367 25982064 : !this->shapes_on_quadrature)
368 : {
369 : // Set the element type
370 41589 : this->_elem = elem;
371 41589 : this->_elem_type = elem->type();
372 41589 : this->_elem_p_level = side_p_level;
373 41589 : this->_p_level = this->_add_p_level_in_reinit * side_p_level;
374 :
375 : // Set the last_side
376 41589 : last_side = side->type();
377 :
378 : // Initialize the face shape functions
379 41589 : this->_fe_map->template init_face_shape_functions<Dim>(reference_side_points, side);
380 : }
381 : else
382 25954762 : this->_elem = elem;
383 :
384 : const unsigned int n_points =
385 4694064 : cast_int<unsigned int>(reference_side_points.size());
386 25996351 : reference_points.resize(n_points);
387 110831347 : for (unsigned int i = 0; i < n_points; i++)
388 84834996 : reference_points[i].zero();
389 :
390 4694064 : std::vector<Point> refspace_nodes;
391 25996351 : this->get_refspace_nodes(elem->type(), refspace_nodes);
392 :
393 2347032 : const std::vector<std::vector<Real>> & psi_map = this->_fe_map->get_psi();
394 :
395 : // sum over the nodes
396 149459022 : for (auto i : index_range(psi_map))
397 : {
398 123462671 : const Point & side_node = refspace_nodes[elem->local_side_node(s,i)];
399 601235428 : for (unsigned int p=0; p<n_points; p++)
400 558396169 : reference_points[p].add_scaled (side_node, psi_map[i][p]);
401 : }
402 25996351 : }
403 :
404 : template <unsigned int Dim, FEFamily T>
405 199598 : void FE<Dim,T>::edge_map (const Elem * elem,
406 : const Elem * edge,
407 : const unsigned int e,
408 : const std::vector<Point> & reference_edge_points,
409 : std::vector<Point> & reference_points)
410 : {
411 : // We're calculating mappings - we need at least first order info
412 199598 : this->calculate_phi = true;
413 199598 : this->determine_calculations();
414 :
415 29078 : unsigned int edge_p_level = elem->p_level();
416 :
417 384657 : if (edge->type() != last_edge ||
418 199598 : (elem->runtime_topology() &&
419 0 : this->_elem != elem) ||
420 413735 : edge_p_level != this->_elem_p_level ||
421 199598 : !this->shapes_on_quadrature)
422 : {
423 : // Set the element type
424 0 : this->_elem = elem;
425 0 : this->_elem_type = elem->type();
426 0 : this->_elem_p_level = edge_p_level;
427 0 : this->_p_level = this->_add_p_level_in_reinit * edge_p_level;
428 :
429 : // Set the last_edge
430 0 : last_edge = edge->type();
431 :
432 : // Initialize the edge shape functions
433 0 : this->_fe_map->template init_edge_shape_functions<Dim>(reference_edge_points, edge);
434 : }
435 : else
436 199598 : this->_elem = elem;
437 :
438 : const unsigned int n_points =
439 29078 : cast_int<unsigned int>(reference_edge_points.size());
440 199598 : reference_points.resize(n_points);
441 963107 : for (unsigned int i = 0; i < n_points; i++)
442 763509 : reference_points[i].zero();
443 :
444 29078 : std::vector<Point> refspace_nodes;
445 199598 : this->get_refspace_nodes(elem->type(), refspace_nodes);
446 :
447 14539 : const std::vector<std::vector<Real>> & psi_map = this->_fe_map->get_psi();
448 :
449 : // sum over the nodes
450 798356 : for (auto i : index_range(psi_map))
451 : {
452 598758 : const Point & edge_node = refspace_nodes[elem->local_edge_node(e,i)];
453 2889213 : for (unsigned int p=0; p<n_points; p++)
454 2625099 : reference_points[p].add_scaled (edge_node, psi_map[i][p]);
455 : }
456 199598 : }
457 :
458 :
459 : template<unsigned int Dim>
460 15487547 : void FEMap::init_face_shape_functions(const std::vector<Point> & qp,
461 : const Elem * side)
462 : {
463 : // Start logging the shape function initialization
464 3877097 : LOG_SCOPE("init_face_shape_functions()", "FEMap");
465 :
466 1292367 : libmesh_assert(side);
467 :
468 : // We're calculating now!
469 1292367 : this->determine_calculations();
470 :
471 : // The element type and order to use in
472 : // the map
473 15487547 : const FEFamily mapping_family = FEMap::map_fe_type(*side);
474 15487547 : const FEType map_fe_type(side->default_order(), mapping_family);
475 :
476 : // The number of quadrature points.
477 2584730 : const unsigned int n_qp = cast_int<unsigned int>(qp.size());
478 :
479 : // Do not use the p_level(), if any, that is inherited by the side.
480 : const unsigned int n_mapping_shape_functions =
481 15487547 : FEInterface::n_shape_functions(map_fe_type, /*extra_order=*/0, side);
482 :
483 : // resize the vectors to hold current data
484 : // Psi are the shape functions used for the FE mapping
485 15487547 : if (calculate_xyz)
486 15459707 : this->psi_map.resize (n_mapping_shape_functions);
487 :
488 : if (Dim > 1)
489 : {
490 15416125 : if (calculate_dxyz)
491 15236269 : this->dpsidxi_map.resize (n_mapping_shape_functions);
492 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
493 15416125 : if (calculate_d2xyz)
494 421949 : this->d2psidxi2_map.resize (n_mapping_shape_functions);
495 : #endif
496 : }
497 :
498 : if (Dim == 3)
499 : {
500 9448607 : if (calculate_dxyz)
501 9301151 : this->dpsideta_map.resize (n_mapping_shape_functions);
502 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
503 9448607 : if (calculate_d2xyz)
504 : {
505 292800 : this->d2psidxideta_map.resize (n_mapping_shape_functions);
506 292800 : this->d2psideta2_map.resize (n_mapping_shape_functions);
507 : }
508 : #endif
509 : }
510 :
511 : FEInterface::shape_ptr shape_ptr =
512 15487547 : FEInterface::shape_function(map_fe_type, side);
513 :
514 : FEInterface::shape_deriv_ptr shape_deriv_ptr =
515 15487547 : FEInterface::shape_deriv_function(map_fe_type, side);
516 :
517 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
518 : FEInterface::shape_second_deriv_ptr shape_second_deriv_ptr =
519 15487547 : FEInterface::shape_second_deriv_function(map_fe_type, side);
520 : #endif
521 :
522 99688578 : for (unsigned int i=0; i<n_mapping_shape_functions; i++)
523 : {
524 : // Allocate space to store the values of the shape functions
525 : // and their first and second derivatives at the quadrature points.
526 84201031 : if (calculate_xyz)
527 91083222 : this->psi_map[i].resize (n_qp);
528 : if (Dim > 1)
529 : {
530 84129609 : if (calculate_dxyz)
531 89903069 : this->dpsidxi_map[i].resize (n_qp);
532 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
533 84129609 : if (calculate_d2xyz)
534 2733613 : this->d2psidxi2_map[i].resize (n_qp);
535 : #endif
536 : }
537 : if (Dim == 3)
538 : {
539 66274544 : if (calculate_dxyz)
540 70648820 : this->dpsideta_map[i].resize (n_qp);
541 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
542 66274544 : if (calculate_d2xyz)
543 : {
544 2314000 : this->d2psidxideta_map[i].resize (n_qp);
545 2314000 : this->d2psideta2_map[i].resize (n_qp);
546 : }
547 : #endif
548 : }
549 :
550 :
551 : // Compute the value of mapping shape function i, and its first
552 : // and second derivatives at quadrature point p
553 436656376 : for (unsigned int p=0; p<n_qp; p++)
554 : {
555 352455345 : if (calculate_xyz)
556 380676364 : this->psi_map[i][p] = shape_ptr (map_fe_type, side, i, qp[p], false);
557 : if (Dim > 1)
558 : {
559 352383923 : if (calculate_dxyz)
560 376928819 : this->dpsidxi_map[i][p] = shape_deriv_ptr (map_fe_type, side, i, 0, qp[p], false);
561 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
562 352383923 : if (calculate_d2xyz)
563 21828506 : this->d2psidxi2_map[i][p] = shape_second_deriv_ptr(map_fe_type, side, i, 0, qp[p], false);
564 : #endif
565 : }
566 : // libMesh::out << "this->d2psidxi2_map["<<i<<"][p]=" << d2psidxi2_map[i][p] << std::endl;
567 :
568 : // If we are in 3D, then our sides are 2D faces.
569 : // For the second derivatives, we must also compute the cross
570 : // derivative d^2() / dxi deta
571 : if (Dim == 3)
572 : {
573 304149857 : if (calculate_dxyz)
574 324850431 : this->dpsideta_map[i][p] = shape_deriv_ptr (map_fe_type, side, i, 1, qp[p], false);
575 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
576 304149857 : if (calculate_d2xyz)
577 : {
578 20911280 : this->d2psidxideta_map[i][p] = shape_second_deriv_ptr(map_fe_type, side, i, 1, qp[p], false);
579 20911280 : this->d2psideta2_map[i][p] = shape_second_deriv_ptr(map_fe_type, side, i, 2, qp[p], false);
580 : }
581 : #endif
582 : }
583 : }
584 : }
585 15487547 : }
586 :
587 : template<unsigned int Dim>
588 199598 : void FEMap::init_edge_shape_functions(const std::vector<Point> & qp,
589 : const Elem * edge)
590 : {
591 : // Start logging the shape function initialization
592 43617 : LOG_SCOPE("init_edge_shape_functions()", "FEMap");
593 :
594 14539 : libmesh_assert(edge);
595 :
596 : // We're calculating now!
597 14539 : this->determine_calculations();
598 :
599 : // The element type and order to use in
600 : // the map
601 199598 : const FEFamily mapping_family = FEMap::map_fe_type(*edge);
602 199598 : const FEType map_fe_type(edge->default_order(), mapping_family);
603 :
604 : // The number of quadrature points.
605 29078 : const unsigned int n_qp = cast_int<unsigned int>(qp.size());
606 :
607 : // Do not use the p_level(), if any, that is inherited by the side.
608 : const unsigned int n_mapping_shape_functions =
609 199598 : FEInterface::n_shape_functions(map_fe_type, /*extra_order=*/0, edge);
610 :
611 : // resize the vectors to hold current data
612 : // Psi are the shape functions used for the FE mapping
613 199598 : if (calculate_xyz)
614 199598 : this->psi_map.resize (n_mapping_shape_functions);
615 199598 : if (calculate_dxyz)
616 199598 : this->dpsidxi_map.resize (n_mapping_shape_functions);
617 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
618 199598 : if (calculate_d2xyz)
619 0 : this->d2psidxi2_map.resize (n_mapping_shape_functions);
620 : #endif
621 :
622 : FEInterface::shape_ptr shape_ptr =
623 199598 : FEInterface::shape_function(map_fe_type, edge);
624 :
625 : FEInterface::shape_deriv_ptr shape_deriv_ptr =
626 199598 : FEInterface::shape_deriv_function(map_fe_type, edge);
627 :
628 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
629 : FEInterface::shape_second_deriv_ptr shape_second_deriv_ptr =
630 199598 : FEInterface::shape_second_deriv_function(map_fe_type, edge);
631 : #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
632 :
633 798356 : for (unsigned int i=0; i<n_mapping_shape_functions; i++)
634 : {
635 : // Allocate space to store the values of the shape functions
636 : // and their first and second derivatives at the quadrature points.
637 598758 : if (calculate_xyz)
638 642372 : this->psi_map[i].resize (n_qp);
639 598758 : if (calculate_dxyz)
640 642372 : this->dpsidxi_map[i].resize (n_qp);
641 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
642 598758 : if (calculate_d2xyz)
643 0 : this->d2psidxi2_map[i].resize (n_qp);
644 : #endif
645 :
646 : // Compute the value of mapping shape function i, and its first
647 : // and second derivatives at quadrature point p
648 2889213 : for (unsigned int p=0; p<n_qp; p++)
649 : {
650 2290455 : if (calculate_xyz)
651 2457777 : this->psi_map[i][p] = shape_ptr (map_fe_type, edge, i, qp[p], false);
652 2290455 : if (calculate_dxyz)
653 2457777 : this->dpsidxi_map[i][p] = shape_deriv_ptr (map_fe_type, edge, i, 0, qp[p], false);
654 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
655 2290455 : if (calculate_d2xyz)
656 0 : this->d2psidxi2_map[i][p] = shape_second_deriv_ptr(map_fe_type, edge, i, 0, qp[p], false);
657 : #endif
658 : }
659 : }
660 199598 : }
661 :
662 :
663 :
664 27689527 : void FEMap::compute_face_map(int dim, const std::vector<Real> & qw,
665 : const Elem * side)
666 : {
667 2488130 : libmesh_assert(side);
668 :
669 : // We're calculating now!
670 2488130 : this->determine_calculations();
671 :
672 7464390 : LOG_ONE_ENTITY_SCOPE("compute_face_map()", "FEMap");
673 :
674 : // The number of quadrature points.
675 4976260 : const unsigned int n_qp = cast_int<unsigned int>(qw.size());
676 :
677 27689527 : const FEFamily mapping_family = FEMap::map_fe_type(*side);
678 27689527 : const Order mapping_order (side->default_order());
679 2488130 : const FEType map_fe_type(mapping_order, mapping_family);
680 :
681 : // Do not use the p_level(), if any, that is inherited by the side.
682 : const unsigned int n_mapping_shape_functions =
683 27689527 : FEInterface::n_shape_functions(map_fe_type, /*extra_order=*/0, side);
684 :
685 27689527 : switch (dim)
686 : {
687 73008 : case 1:
688 : {
689 : // A 1D finite element, potentially in 2D or 3D space.
690 : // This means the boundary is a "0D finite element", a
691 : // NODEELEM.
692 :
693 : // Resize the vectors to hold data at the quadrature points
694 : {
695 73008 : if (calculate_xyz)
696 73008 : this->xyz.resize(n_qp);
697 73008 : if (calculate_dxyz)
698 73008 : normals.resize(n_qp);
699 :
700 73008 : if (calculate_dxyz)
701 73008 : this->JxW.resize(n_qp);
702 : }
703 :
704 : // If we have no quadrature points, there's nothing else to do
705 73008 : if (!n_qp)
706 0 : break;
707 :
708 : // We need to look back at the full edge to figure out the normal
709 : // vector
710 73008 : const Elem * elem = side->interior_parent();
711 6059 : libmesh_assert (elem);
712 73008 : if (calculate_dxyz)
713 : {
714 85126 : if (side->node_id(0) == elem->node_id(0))
715 : {
716 2185 : const Point reference_point = Point(-1.);
717 28112 : Point dx_dxi = FEMap::map_deriv (1, elem, 0, reference_point);
718 28112 : normals[0] = -dx_dxi.unit();
719 : }
720 : else
721 : {
722 3874 : libmesh_assert_equal_to (side->node_id(0),
723 : elem->node_id(1));
724 3874 : const Point reference_point = Point(1.);
725 44896 : Point dx_dxi = FEMap::map_deriv (1, elem, 0, reference_point);
726 44896 : normals[0] = dx_dxi.unit();
727 : }
728 : }
729 :
730 : // Calculate x at the point
731 73008 : if (calculate_xyz)
732 6059 : libmesh_assert_equal_to (this->psi_map.size(), 1);
733 : // In the unlikely event we have multiple quadrature
734 : // points, they'll be in the same place
735 146016 : for (unsigned int p=0; p<n_qp; p++)
736 : {
737 73008 : if (calculate_xyz)
738 : {
739 73008 : this->xyz[p].zero();
740 79067 : this->xyz[p].add_scaled (side->point(0), this->psi_map[0][p]);
741 : }
742 73008 : if (calculate_dxyz)
743 : {
744 73008 : normals[p] = normals[0];
745 85126 : this->JxW[p] = 1.0*qw[p];
746 : }
747 : }
748 :
749 : // done computing the map
750 6059 : break;
751 : }
752 :
753 12875690 : case 2:
754 : {
755 : // A 2D finite element living in either 2D or 3D space.
756 : // This means the boundary is a 1D finite element, i.e.
757 : // and EDGE2 or EDGE3.
758 : // Resize the vectors to hold data at the quadrature points
759 : {
760 12875690 : if (calculate_xyz)
761 12875690 : this->xyz.resize(n_qp);
762 12875690 : if (calculate_dxyz)
763 : {
764 12843290 : this->dxyzdxi_map.resize(n_qp);
765 12843290 : this->tangents.resize(n_qp);
766 12843290 : this->normals.resize(n_qp);
767 :
768 12843290 : this->JxW.resize(n_qp);
769 : }
770 :
771 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
772 12875690 : if (calculate_d2xyz)
773 : {
774 129149 : this->d2xyzdxi2_map.resize(n_qp);
775 129149 : this->curvatures.resize(n_qp);
776 : }
777 : #endif
778 : }
779 :
780 : // Clear the entities that will be summed
781 : // Compute the tangent & normal at the quadrature point
782 38863112 : for (unsigned int p=0; p<n_qp; p++)
783 : {
784 25987422 : if (calculate_xyz)
785 25987422 : this->xyz[p].zero();
786 25987422 : if (calculate_dxyz)
787 : {
788 28282499 : this->tangents[p].resize(LIBMESH_DIM-1); // 1 Tangent in 2D, 2 in 3D
789 4719754 : this->dxyzdxi_map[p].zero();
790 : }
791 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
792 25987422 : if (calculate_d2xyz)
793 282298 : this->d2xyzdxi2_map[p].zero();
794 : #endif
795 : }
796 :
797 : // compute x, dxdxi at the quadrature points
798 46491209 : for (unsigned int i=0; i<n_mapping_shape_functions; i++) // sum over the nodes
799 : {
800 6349036 : const Point & side_point = side->point(i);
801 :
802 106257287 : for (unsigned int p=0; p<n_qp; p++) // for each quadrature point...
803 : {
804 72641768 : if (calculate_xyz)
805 85611174 : this->xyz[p].add_scaled (side_point, this->psi_map[i][p]);
806 72641768 : if (calculate_dxyz)
807 85384374 : this->dxyzdxi_map[p].add_scaled (side_point, this->dpsidxi_map[i][p]);
808 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
809 72641768 : if (calculate_d2xyz)
810 987558 : this->d2xyzdxi2_map[p].add_scaled(side_point, this->d2psidxi2_map[i][p]);
811 : #endif
812 : }
813 : }
814 :
815 : // Compute the tangent & normal at the quadrature point
816 12875690 : if (calculate_dxyz)
817 : {
818 38765912 : for (unsigned int p=0; p<n_qp; p++)
819 : {
820 : // The first tangent comes from just the edge's Jacobian
821 28282499 : this->tangents[p][0] = this->dxyzdxi_map[p].unit();
822 :
823 : #if LIBMESH_DIM == 2
824 : // For a 2D element living in 2D, the normal is given directly
825 : // from the entries in the edge Jacobian.
826 : this->normals[p] = (Point(this->dxyzdxi_map[p](1), -this->dxyzdxi_map[p](0), 0.)).unit();
827 :
828 : #elif LIBMESH_DIM == 3
829 : // For a 2D element living in 3D, there is a second tangent.
830 : // For the second tangent, we need to refer to the full
831 : // element's (not just the edge's) Jacobian.
832 25922622 : const Elem * elem = side->interior_parent();
833 2359877 : libmesh_assert(elem);
834 :
835 : // Inverse map xyz[p] to a reference point on the parent...
836 28282499 : Point reference_point = FEMap::inverse_map(2, elem, this->xyz[p]);
837 :
838 : // Get dxyz/dxi and dxyz/deta from the parent map.
839 25922622 : Point dx_dxi = FEMap::map_deriv (2, elem, 0, reference_point);
840 25922622 : Point dx_deta = FEMap::map_deriv (2, elem, 1, reference_point);
841 :
842 : // The second tangent vector is formed by crossing these vectors.
843 25922622 : tangents[p][1] = dx_dxi.cross(dx_deta).unit();
844 :
845 : // Finally, the normal in this case is given by crossing these
846 : // two tangents.
847 25922622 : normals[p] = tangents[p][0].cross(tangents[p][1]).unit();
848 : #endif
849 :
850 :
851 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
852 : // The curvature is computed via the familiar Frenet formula:
853 : // curvature = [d^2(x) / d (xi)^2] dot [normal]
854 : // For a reference, see:
855 : // F.S. Merritt, Mathematics Manual, 1962, McGraw-Hill, p. 310
856 : //
857 : // Note: The sign convention here is different from the
858 : // 3D case. Concave-upward curves (smiles) have a positive
859 : // curvature. Concave-downward curves (frowns) have a
860 : // negative curvature. Be sure to take that into account!
861 25922622 : if (calculate_d2xyz)
862 : {
863 46888 : const Real numerator = this->d2xyzdxi2_map[p] * this->normals[p];
864 46888 : const Real denominator = this->dxyzdxi_map[p].norm_sq();
865 23444 : libmesh_assert_not_equal_to (denominator, 0);
866 305742 : curvatures[p] = numerator / denominator;
867 : }
868 : #endif
869 : }
870 :
871 : // compute the jacobian at the quadrature points
872 38765912 : for (unsigned int p=0; p<n_qp; p++)
873 : {
874 25922622 : const Real the_jac = this->dxyzdxi_map[p].norm();
875 :
876 2359877 : libmesh_assert_greater (the_jac, 0.);
877 :
878 30642376 : this->JxW[p] = the_jac*qw[p];
879 : }
880 : }
881 :
882 : // done computing the map
883 1253556 : break;
884 : }
885 :
886 :
887 :
888 14740829 : case 3:
889 : {
890 : // A 3D finite element living in 3D space.
891 : // Resize the vectors to hold data at the quadrature points
892 : {
893 14740829 : if (calculate_xyz)
894 14740829 : this->xyz.resize(n_qp);
895 14740829 : if (calculate_dxyz)
896 : {
897 14593373 : this->dxyzdxi_map.resize(n_qp);
898 14593373 : this->dxyzdeta_map.resize(n_qp);
899 14593373 : this->tangents.resize(n_qp);
900 14593373 : this->normals.resize(n_qp);
901 14593373 : this->JxW.resize(n_qp);
902 : }
903 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
904 14740829 : if (calculate_d2xyz)
905 : {
906 292800 : this->d2xyzdxi2_map.resize(n_qp);
907 292800 : this->d2xyzdxideta_map.resize(n_qp);
908 292800 : this->d2xyzdeta2_map.resize(n_qp);
909 292800 : this->curvatures.resize(n_qp);
910 : }
911 : #endif
912 : }
913 :
914 : // Clear the entities that will be summed
915 79691174 : for (unsigned int p=0; p<n_qp; p++)
916 : {
917 64950345 : if (calculate_xyz)
918 64950345 : this->xyz[p].zero();
919 64950345 : if (calculate_dxyz)
920 : {
921 69732023 : this->tangents[p].resize(LIBMESH_DIM-1); // 1 Tangent in 2D, 2 in 3D
922 10743004 : this->dxyzdxi_map[p].zero();
923 10743004 : this->dxyzdeta_map[p].zero();
924 : }
925 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
926 64950345 : if (calculate_d2xyz)
927 : {
928 2621760 : this->d2xyzdxi2_map[p].zero();
929 436960 : this->d2xyzdxideta_map[p].zero();
930 436960 : this->d2xyzdeta2_map[p].zero();
931 : }
932 : #endif
933 : }
934 :
935 : // compute x, dxdxi at the quadrature points
936 115613125 : for (unsigned int i=0; i<n_mapping_shape_functions; i++) // sum over the nodes
937 : {
938 16814560 : const Point & side_point = side->point(i);
939 :
940 548899445 : for (unsigned int p=0; p<n_qp; p++) // for each quadrature point...
941 : {
942 448027149 : if (calculate_xyz)
943 522830565 : this->xyz[p].add_scaled (side_point, this->psi_map[i][p]);
944 448027149 : if (calculate_dxyz)
945 : {
946 518013669 : this->dxyzdxi_map[p].add_scaled (side_point, this->dpsidxi_map[i][p]);
947 518013669 : this->dxyzdeta_map[p].add_scaled(side_point, this->dpsideta_map[i][p]);
948 : }
949 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
950 448027149 : if (calculate_d2xyz)
951 : {
952 22519840 : this->d2xyzdxi2_map[p].add_scaled (side_point, this->d2psidxi2_map[i][p]);
953 22519840 : this->d2xyzdxideta_map[p].add_scaled(side_point, this->d2psidxideta_map[i][p]);
954 22519840 : this->d2xyzdeta2_map[p].add_scaled (side_point, this->d2psideta2_map[i][p]);
955 : }
956 : #endif
957 : }
958 : }
959 :
960 : // Compute the tangents, normal, and curvature at the quadrature point
961 14740829 : if (calculate_dxyz)
962 : {
963 78953894 : for (unsigned int p=0; p<n_qp; p++)
964 : {
965 69732023 : const Point n = this->dxyzdxi_map[p].cross(this->dxyzdeta_map[p]);
966 64360521 : this->normals[p] = n.unit();
967 69732023 : this->tangents[p][0] = this->dxyzdxi_map[p].unit();
968 69732023 : this->tangents[p][1] = n.cross(this->dxyzdxi_map[p]).unit();
969 :
970 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
971 64360521 : if (calculate_d2xyz)
972 : {
973 : // Compute curvature using the typical nomenclature
974 : // of the first and second fundamental forms.
975 : // For reference, see:
976 : // 1) http://mathworld.wolfram.com/MeanCurvature.html
977 : // (note -- they are using inward normal)
978 : // 2) F.S. Merritt, Mathematics Manual, 1962, McGraw-Hill
979 655440 : const Real L = -this->d2xyzdxi2_map[p] * this->normals[p];
980 436960 : const Real M = -this->d2xyzdxideta_map[p] * this->normals[p];
981 436960 : const Real N = -this->d2xyzdeta2_map[p] * this->normals[p];
982 436960 : const Real E = this->dxyzdxi_map[p].norm_sq();
983 436960 : const Real F = this->dxyzdxi_map[p] * this->dxyzdeta_map[p];
984 218480 : const Real G = this->dxyzdeta_map[p].norm_sq();
985 :
986 2621760 : const Real numerator = E*N -2.*F*M + G*L;
987 2621760 : const Real denominator = E*G - F*F;
988 218480 : libmesh_assert_not_equal_to (denominator, 0.);
989 2840240 : curvatures[p] = 0.5*numerator/denominator;
990 : }
991 : #endif
992 : }
993 :
994 : // compute the jacobian at the quadrature points, see
995 : // http://sp81.msi.umn.edu:999/fluent/fidap/help/theory/thtoc.htm
996 78953894 : for (unsigned int p=0; p<n_qp; p++)
997 : {
998 64360521 : const Real g11 = (dxdxi_map(p)*dxdxi_map(p) +
999 64360521 : dydxi_map(p)*dydxi_map(p) +
1000 64360521 : dzdxi_map(p)*dzdxi_map(p));
1001 :
1002 64360521 : const Real g12 = (dxdxi_map(p)*dxdeta_map(p) +
1003 64360521 : dydxi_map(p)*dydeta_map(p) +
1004 64360521 : dzdxi_map(p)*dzdeta_map(p));
1005 :
1006 5371502 : const Real g21 = g12;
1007 :
1008 69732023 : const Real g22 = (dxdeta_map(p)*dxdeta_map(p) +
1009 64360521 : dydeta_map(p)*dydeta_map(p) +
1010 64360521 : dzdeta_map(p)*dzdeta_map(p));
1011 :
1012 :
1013 64360521 : const Real the_jac = std::sqrt(g11*g22 - g12*g21);
1014 :
1015 5371502 : libmesh_assert_greater (the_jac, 0.);
1016 :
1017 75103525 : this->JxW[p] = the_jac*qw[p];
1018 : }
1019 : }
1020 :
1021 : // done computing the map
1022 1228515 : break;
1023 : }
1024 :
1025 :
1026 0 : default:
1027 0 : libmesh_error_msg("Invalid dimension dim = " << dim);
1028 : }
1029 27689527 : }
1030 :
1031 :
1032 :
1033 :
1034 199598 : void FEMap::compute_edge_map(int dim,
1035 : const std::vector<Real> & qw,
1036 : const Elem * edge)
1037 : {
1038 14539 : libmesh_assert(edge);
1039 :
1040 199598 : if (dim == 2)
1041 : {
1042 : // A 2D finite element living in either 2D or 3D space.
1043 : // The edges here are the sides of the element, so the
1044 : // (misnamed) compute_face_map function does what we want
1045 0 : this->compute_face_map(dim, qw, edge);
1046 0 : return;
1047 : }
1048 :
1049 14539 : libmesh_assert_equal_to (dim, 3); // 1D is unnecessary and currently unsupported
1050 :
1051 43617 : LOG_ONE_ENTITY_SCOPE("compute_edge_map()", "FEMap");
1052 :
1053 : // We're calculating now!
1054 14539 : this->determine_calculations();
1055 :
1056 : // The number of quadrature points.
1057 29078 : const unsigned int n_qp = cast_int<unsigned int>(qw.size());
1058 :
1059 : // Resize the vectors to hold data at the quadrature points
1060 199598 : if (calculate_xyz)
1061 199598 : this->xyz.resize(n_qp);
1062 199598 : if (calculate_dxyz)
1063 : {
1064 199598 : this->dxyzdxi_map.resize(n_qp);
1065 199598 : this->dxyzdeta_map.resize(n_qp);
1066 199598 : this->tangents.resize(n_qp);
1067 199598 : this->normals.resize(n_qp);
1068 199598 : this->JxW.resize(n_qp);
1069 : }
1070 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1071 199598 : if (calculate_d2xyz)
1072 : {
1073 0 : this->d2xyzdxi2_map.resize(n_qp);
1074 0 : this->d2xyzdxideta_map.resize(n_qp);
1075 0 : this->d2xyzdeta2_map.resize(n_qp);
1076 0 : this->curvatures.resize(n_qp);
1077 : }
1078 : #endif
1079 :
1080 : // Clear the entities that will be summed
1081 963107 : for (unsigned int p=0; p<n_qp; p++)
1082 : {
1083 763509 : if (calculate_xyz)
1084 763509 : this->xyz[p].zero();
1085 763509 : if (calculate_dxyz)
1086 : {
1087 819285 : this->tangents[p].resize(1);
1088 111552 : this->dxyzdxi_map[p].zero();
1089 111552 : this->dxyzdeta_map[p].zero();
1090 : }
1091 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1092 763509 : if (calculate_d2xyz)
1093 : {
1094 0 : this->d2xyzdxi2_map[p].zero();
1095 0 : this->d2xyzdxideta_map[p].zero();
1096 0 : this->d2xyzdeta2_map[p].zero();
1097 : }
1098 : #endif
1099 : }
1100 :
1101 : // compute x, dxdxi at the quadrature points
1102 769278 : for (unsigned int i=0,
1103 29078 : psi_map_size=cast_int<unsigned int>(psi_map.size());
1104 798356 : i != psi_map_size; i++) // sum over the nodes
1105 : {
1106 87228 : const Point & edge_point = edge->point(i);
1107 :
1108 2889213 : for (unsigned int p=0; p<n_qp; p++) // for each quadrature point...
1109 : {
1110 2290455 : if (calculate_xyz)
1111 2457777 : this->xyz[p].add_scaled (edge_point, this->psi_map[i][p]);
1112 2290455 : if (calculate_dxyz)
1113 2625099 : this->dxyzdxi_map[p].add_scaled (edge_point, this->dpsidxi_map[i][p]);
1114 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1115 2290455 : if (calculate_d2xyz)
1116 0 : this->d2xyzdxi2_map[p].add_scaled (edge_point, this->d2psidxi2_map[i][p]);
1117 : #endif
1118 : }
1119 : }
1120 :
1121 : // Compute the tangents at the quadrature point
1122 : // FIXME: normals (plural!) and curvatures are uncalculated
1123 199598 : if (calculate_dxyz)
1124 963107 : for (unsigned int p=0; p<n_qp; p++)
1125 : {
1126 : // const Point n = this->dxyzdxi_map[p].cross(this->dxyzdeta_map[p]);
1127 819285 : this->tangents[p][0] = this->dxyzdxi_map[p].unit();
1128 :
1129 : // compute the jacobian at the quadrature points
1130 763509 : const Real the_jac = std::sqrt(this->dxdxi_map(p)*this->dxdxi_map(p) +
1131 763509 : this->dydxi_map(p)*this->dydxi_map(p) +
1132 763509 : this->dzdxi_map(p)*this->dzdxi_map(p));
1133 :
1134 55776 : libmesh_assert_greater (the_jac, 0.);
1135 :
1136 875061 : this->JxW[p] = the_jac*qw[p];
1137 : }
1138 : }
1139 :
1140 :
1141 : // Explicit FEMap Instantiations
1142 0 : FACE_EDGE_SHAPE_ERROR(0,init_face_shape_functions)
1143 : template LIBMESH_EXPORT void FEMap::init_face_shape_functions<1>(const std::vector<Point> &, const Elem *);
1144 : template LIBMESH_EXPORT void FEMap::init_face_shape_functions<2>(const std::vector<Point> &, const Elem *);
1145 : template LIBMESH_EXPORT void FEMap::init_face_shape_functions<3>(const std::vector<Point> &, const Elem *);
1146 :
1147 0 : FACE_EDGE_SHAPE_ERROR(0,init_edge_shape_functions)
1148 : template LIBMESH_EXPORT void FEMap::init_edge_shape_functions<1>(const std::vector<Point> &, const Elem *);
1149 : template LIBMESH_EXPORT void FEMap::init_edge_shape_functions<2>(const std::vector<Point> &, const Elem *);
1150 : template LIBMESH_EXPORT void FEMap::init_edge_shape_functions<3>(const std::vector<Point> &, const Elem *);
1151 :
1152 : //--------------------------------------------------------------
1153 : // Explicit FE instantiations
1154 : #define REINIT_AND_SIDE_MAPS(_type) \
1155 : template LIBMESH_EXPORT void FE<1,_type>::reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const); \
1156 : template LIBMESH_EXPORT void FE<1,_type>::side_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &); \
1157 : template LIBMESH_EXPORT void FE<2,_type>::reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const); \
1158 : template LIBMESH_EXPORT void FE<2,_type>::side_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &); \
1159 : template LIBMESH_EXPORT void FE<2,_type>::edge_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &); \
1160 : template LIBMESH_EXPORT void FE<2,_type>::edge_reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const); \
1161 : template LIBMESH_EXPORT void FE<3,_type>::reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const); \
1162 : template LIBMESH_EXPORT void FE<3,_type>::side_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &); \
1163 : template LIBMESH_EXPORT void FE<3,_type>::edge_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &); \
1164 : template LIBMESH_EXPORT void FE<3,_type>::edge_reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const)
1165 :
1166 : REINIT_AND_SIDE_MAPS(LAGRANGE);
1167 : REINIT_AND_SIDE_MAPS(LAGRANGE_VEC);
1168 : REINIT_AND_SIDE_MAPS(L2_LAGRANGE);
1169 : REINIT_AND_SIDE_MAPS(L2_LAGRANGE_GLL);
1170 : REINIT_AND_SIDE_MAPS(LAGRANGE_GLL);
1171 : REINIT_AND_SIDE_MAPS(L2_LAGRANGE_VEC);
1172 : REINIT_AND_SIDE_MAPS(HIERARCHIC);
1173 : REINIT_AND_SIDE_MAPS(HIERARCHIC_VEC);
1174 : REINIT_AND_SIDE_MAPS(L2_HIERARCHIC);
1175 : REINIT_AND_SIDE_MAPS(L2_HIERARCHIC_VEC);
1176 : REINIT_AND_SIDE_MAPS(SIDE_HIERARCHIC);
1177 : REINIT_AND_SIDE_MAPS(CLOUGH);
1178 : REINIT_AND_SIDE_MAPS(HERMITE);
1179 : REINIT_AND_SIDE_MAPS(MONOMIAL);
1180 : REINIT_AND_SIDE_MAPS(MONOMIAL_VEC);
1181 : REINIT_AND_SIDE_MAPS(SCALAR);
1182 : REINIT_AND_SIDE_MAPS(XYZ);
1183 :
1184 : #ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
1185 : REINIT_AND_SIDE_MAPS(BERNSTEIN);
1186 : REINIT_AND_SIDE_MAPS(SZABAB);
1187 : REINIT_AND_SIDE_MAPS(RATIONAL_BERNSTEIN);
1188 : #endif
1189 :
1190 : template LIBMESH_EXPORT void FE<2,SUBDIVISION>::reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const);
1191 : template LIBMESH_EXPORT void FE<2,SUBDIVISION>::edge_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &);
1192 :
1193 : template LIBMESH_EXPORT void FE<2,NEDELEC_ONE>::reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const);
1194 : template LIBMESH_EXPORT void FE<2,NEDELEC_ONE>::side_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &);
1195 : template LIBMESH_EXPORT void FE<2,NEDELEC_ONE>::edge_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &);
1196 : template LIBMESH_EXPORT void FE<2,NEDELEC_ONE>::edge_reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const);
1197 :
1198 : template LIBMESH_EXPORT void FE<2,RAVIART_THOMAS>::reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const);
1199 : template LIBMESH_EXPORT void FE<2,RAVIART_THOMAS>::side_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &);
1200 : template LIBMESH_EXPORT void FE<2,RAVIART_THOMAS>::edge_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &);
1201 : template LIBMESH_EXPORT void FE<2,RAVIART_THOMAS>::edge_reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const);
1202 :
1203 : template LIBMESH_EXPORT void FE<2,L2_RAVIART_THOMAS>::reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const);
1204 : template LIBMESH_EXPORT void FE<2,L2_RAVIART_THOMAS>::side_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &);
1205 : template LIBMESH_EXPORT void FE<2,L2_RAVIART_THOMAS>::edge_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &);
1206 : template LIBMESH_EXPORT void FE<2,L2_RAVIART_THOMAS>::edge_reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const);
1207 :
1208 : template LIBMESH_EXPORT void FE<3,NEDELEC_ONE>::reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const);
1209 : template LIBMESH_EXPORT void FE<3,NEDELEC_ONE>::side_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &);
1210 : template LIBMESH_EXPORT void FE<3,NEDELEC_ONE>::edge_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &);
1211 : template LIBMESH_EXPORT void FE<3,NEDELEC_ONE>::edge_reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const);
1212 :
1213 : template LIBMESH_EXPORT void FE<3,RAVIART_THOMAS>::reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const);
1214 : template LIBMESH_EXPORT void FE<3,RAVIART_THOMAS>::side_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &);
1215 : template LIBMESH_EXPORT void FE<3,RAVIART_THOMAS>::edge_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &);
1216 : template LIBMESH_EXPORT void FE<3,RAVIART_THOMAS>::edge_reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const);
1217 :
1218 : template LIBMESH_EXPORT void FE<3,L2_RAVIART_THOMAS>::reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const);
1219 : template LIBMESH_EXPORT void FE<3,L2_RAVIART_THOMAS>::side_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &);
1220 : template LIBMESH_EXPORT void FE<3,L2_RAVIART_THOMAS>::edge_map(Elem const *, Elem const *, const unsigned int, const std::vector<Point> &, std::vector<Point> &);
1221 : template LIBMESH_EXPORT void FE<3,L2_RAVIART_THOMAS>::edge_reinit(Elem const *, unsigned int, Real, const std::vector<Point> * const, const std::vector<Real> * const);
1222 :
1223 : // Intel 9.1 complained it needed this in devel mode.
1224 : //template LIBMESH_EXPORT void FE<2,XYZ>::init_face_shape_functions(const std::vector<Point> &, const Elem *);
1225 : //template LIBMESH_EXPORT void FE<3,XYZ>::init_face_shape_functions(const std::vector<Point> &, const Elem *);
1226 :
1227 : } // namespace libMesh
|