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 9533907 : 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 2510863 : libmesh_assert(elem);
118 2510863 : 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 9533907 : if (this->calculating_nothing())
126 : {
127 550655 : this->calculations_started = true; // Ironic
128 550655 : 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 8983252 : this->_fe_map->add_calculations();
135 2345150 : this->_fe_map->get_JxW();
136 2345150 : this->_fe_map->get_xyz();
137 8983252 : this->determine_calculations();
138 :
139 : // Build the side of interest
140 8983252 : 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 8983252 : unsigned int side_p_level = elem->p_level();
145 11328402 : if (elem->neighbor_ptr(s) != nullptr)
146 10176816 : 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 8983252 : if (pts != nullptr)
151 : {
152 : // The shape functions do not correspond to the qrule
153 1113 : this->shapes_on_quadrature = false;
154 :
155 : // Initialize the face shape functions
156 1113 : this->_fe_map->template init_face_shape_functions<Dim>(*pts, side.get());
157 :
158 : // Compute the Jacobian*Weight on the face for integration
159 1113 : if (weights != nullptr)
160 : {
161 0 : this->_fe_map->compute_face_map (Dim, *weights, side.get());
162 : }
163 : else
164 : {
165 1749 : std::vector<Real> dummy_weights (pts->size(), 1.);
166 1113 : 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 8982139 : this->qrule->init(*side, side_p_level);
175 :
176 8982139 : 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 15520024 : if ((this->get_type() != elem->type()) ||
183 8842291 : (elem->runtime_topology() &&
184 0 : this->_elem != elem) ||
185 8842291 : (side->type() != last_side) ||
186 13033539 : (this->_elem_p_level != side_p_level) ||
187 15506308 : this->shapes_need_reinit() ||
188 4525134 : !this->shapes_on_quadrature)
189 : {
190 : // Set the element
191 4457062 : this->_elem = elem;
192 4457062 : this->_elem_type = elem->type();
193 :
194 : // Set the last_side
195 4457062 : last_side = side->type();
196 :
197 : // Set the last p level
198 4457062 : this->_p_level = this->_add_p_level_in_reinit * side_p_level;
199 :
200 : // Initialize the face shape functions
201 5603211 : this->_fe_map->template init_face_shape_functions<Dim>(this->qrule->get_points(), side.get());
202 : }
203 : else
204 4525077 : this->_elem = elem;
205 :
206 : // Compute the Jacobian*Weight on the face for integration
207 11326971 : this->_fe_map->compute_face_map (Dim, this->qrule->get_weights(), side.get());
208 :
209 : // The shape functions correspond to the qrule
210 8982139 : this->shapes_on_quadrature = true;
211 : }
212 :
213 : // make a copy of the Jacobian for integration
214 11328402 : const std::vector<Real> JxW_int(this->_fe_map->get_JxW());
215 :
216 : // make a copy of shape on quadrature info
217 8983252 : 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 8983252 : if (pts != nullptr)
223 318 : ref_qp = pts;
224 : else
225 8982139 : ref_qp = &this->qrule->get_points();
226 :
227 4690300 : std::vector<Point> qp;
228 8983252 : 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 8983252 : this->reinit (elem, &qp);
233 :
234 8983252 : this->shapes_on_quadrature = shapes_on_quadrature_side;
235 :
236 8983252 : this->_elem_p_level = side_p_level;
237 :
238 : // copy back old data
239 8983252 : this->_fe_map->get_JxW() = JxW_int;
240 4292952 : }
241 :
242 :
243 :
244 : template <unsigned int Dim, FEFamily T>
245 58746 : 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 15095 : libmesh_assert(elem);
252 15095 : 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 58746 : this->_fe_map->add_calculations();
260 15095 : this->_fe_map->get_JxW();
261 15095 : this->_fe_map->get_xyz();
262 58746 : this->determine_calculations();
263 :
264 : // Build the side of interest
265 58746 : 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 58746 : 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 73841 : this->qrule->init(*edge, elem->p_level());
294 :
295 58746 : 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 100964 : if ((this->get_type() != elem->type()) ||
300 56770 : (elem->runtime_topology() &&
301 0 : this->_elem != elem) ||
302 84436 : (edge->type() != last_edge) ||
303 100964 : this->shapes_need_reinit() ||
304 10782 : !this->shapes_on_quadrature)
305 : {
306 : // Set the element
307 58746 : this->_elem = elem;
308 58746 : this->_elem_type = elem->type();
309 :
310 : // Set the last_edge
311 58746 : last_edge = edge->type();
312 :
313 : // Initialize the edge shape functions
314 73841 : 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 73841 : this->_fe_map->compute_edge_map (Dim, this->qrule->get_weights(), edge.get());
321 :
322 : // The shape functions correspond to the qrule
323 58746 : this->shapes_on_quadrature = true;
324 : }
325 :
326 : // make a copy of the Jacobian for integration
327 73841 : 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 58746 : if (pts != nullptr)
333 0 : ref_qp = pts;
334 : else
335 58746 : ref_qp = & this->qrule->get_points();
336 :
337 30190 : std::vector<Point> qp;
338 58746 : 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 58746 : this->reinit (elem, &qp);
343 :
344 : // copy back old data
345 58746 : this->_fe_map->get_JxW() = JxW_int;
346 58746 : }
347 :
348 : template <unsigned int Dim, FEFamily T>
349 8992532 : 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 8992532 : this->calculate_phi = true;
357 8992532 : this->determine_calculations();
358 :
359 8992532 : unsigned int side_p_level = elem->p_level();
360 11340002 : if (elem->neighbor_ptr(s) != nullptr)
361 10188443 : side_p_level = std::max(side_p_level, elem->neighbor_ptr(s)->p_level());
362 :
363 15636774 : if (side->type() != last_side ||
364 8991384 : (elem->runtime_topology() &&
365 0 : this->_elem != elem) ||
366 20330782 : side_p_level != this->_elem_p_level ||
367 8990300 : !this->shapes_on_quadrature)
368 : {
369 : // Set the element type
370 11450 : this->_elem = elem;
371 11450 : this->_elem_type = elem->type();
372 11450 : this->_elem_p_level = side_p_level;
373 11450 : this->_p_level = this->_add_p_level_in_reinit * side_p_level;
374 :
375 : // Set the last_side
376 11450 : last_side = side->type();
377 :
378 : // Initialize the face shape functions
379 11450 : this->_fe_map->template init_face_shape_functions<Dim>(reference_side_points, side);
380 : }
381 : else
382 8981082 : this->_elem = elem;
383 :
384 : const unsigned int n_points =
385 4694940 : cast_int<unsigned int>(reference_side_points.size());
386 8992532 : reference_points.resize(n_points);
387 37352689 : for (unsigned int i = 0; i < n_points; i++)
388 28360157 : reference_points[i].zero();
389 :
390 4694940 : std::vector<Point> refspace_nodes;
391 8992532 : this->get_refspace_nodes(elem->type(), refspace_nodes);
392 :
393 2347470 : const std::vector<std::vector<Real>> & psi_map = this->_fe_map->get_psi();
394 :
395 : // sum over the nodes
396 50649113 : for (auto i : index_range(psi_map))
397 : {
398 41656581 : const Point & side_node = refspace_nodes[elem->local_side_node(s,i)];
399 200561385 : for (unsigned int p=0; p<n_points; p++)
400 239594356 : reference_points[p].add_scaled (side_node, psi_map[i][p]);
401 : }
402 8992532 : }
403 :
404 : template <unsigned int Dim, FEFamily T>
405 58746 : 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 58746 : this->calculate_phi = true;
413 58746 : this->determine_calculations();
414 :
415 30190 : unsigned int edge_p_level = elem->p_level();
416 :
417 102397 : if (edge->type() != last_edge ||
418 58746 : (elem->runtime_topology() &&
419 0 : this->_elem != elem) ||
420 132587 : edge_p_level != this->_elem_p_level ||
421 58746 : !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 58746 : this->_elem = elem;
437 :
438 : const unsigned int n_points =
439 30190 : cast_int<unsigned int>(reference_edge_points.size());
440 58746 : reference_points.resize(n_points);
441 283884 : for (unsigned int i = 0; i < n_points; i++)
442 225138 : reference_points[i].zero();
443 :
444 30190 : std::vector<Point> refspace_nodes;
445 58746 : this->get_refspace_nodes(elem->type(), refspace_nodes);
446 :
447 15095 : const std::vector<std::vector<Real>> & psi_map = this->_fe_map->get_psi();
448 :
449 : // sum over the nodes
450 234972 : for (auto i : index_range(psi_map))
451 : {
452 176226 : const Point & edge_node = refspace_nodes[elem->local_edge_node(e,i)];
453 851616 : for (unsigned int p=0; p<n_points; p++)
454 1022454 : reference_points[p].add_scaled (edge_node, psi_map[i][p]);
455 : }
456 58746 : }
457 :
458 :
459 : template<unsigned int Dim>
460 5043297 : void FEMap::init_face_shape_functions(const std::vector<Point> & qp,
461 : const Elem * side)
462 : {
463 : // Start logging the shape function initialization
464 3878387 : LOG_SCOPE("init_face_shape_functions()", "FEMap");
465 :
466 1292793 : libmesh_assert(side);
467 :
468 : // We're calculating now!
469 1292793 : this->determine_calculations();
470 :
471 : // The element type and order to use in
472 : // the map
473 5043297 : const FEFamily mapping_family = FEMap::map_fe_type(*side);
474 5043297 : const FEType map_fe_type(side->default_order(), mapping_family);
475 :
476 : // The number of quadrature points.
477 2585594 : 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 5043297 : 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 5043297 : if (calculate_xyz)
486 5034017 : this->psi_map.resize (n_mapping_shape_functions);
487 :
488 : if (Dim > 1)
489 : {
490 5019902 : if (calculate_dxyz)
491 4959950 : this->dpsidxi_map.resize (n_mapping_shape_functions);
492 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
493 5019902 : if (calculate_d2xyz)
494 141075 : this->d2psidxi2_map.resize (n_mapping_shape_functions);
495 : #endif
496 : }
497 :
498 : if (Dim == 3)
499 : {
500 3132728 : if (calculate_dxyz)
501 3083576 : this->dpsideta_map.resize (n_mapping_shape_functions);
502 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
503 3132728 : if (calculate_d2xyz)
504 : {
505 97600 : this->d2psidxideta_map.resize (n_mapping_shape_functions);
506 97600 : this->d2psideta2_map.resize (n_mapping_shape_functions);
507 : }
508 : #endif
509 : }
510 :
511 : FEInterface::shape_ptr shape_ptr =
512 5043297 : FEInterface::shape_function(map_fe_type, side);
513 :
514 : FEInterface::shape_deriv_ptr shape_deriv_ptr =
515 5043297 : 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 5043297 : FEInterface::shape_second_deriv_function(map_fe_type, side);
520 : #endif
521 :
522 32676854 : 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 27633557 : if (calculate_xyz)
527 34592538 : this->psi_map[i].resize (n_qp);
528 : if (Dim > 1)
529 : {
530 27610162 : if (calculate_dxyz)
531 34139100 : this->dpsidxi_map[i].resize (n_qp);
532 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
533 27610162 : if (calculate_d2xyz)
534 1052591 : this->d2psidxi2_map[i].resize (n_qp);
535 : #endif
536 : }
537 : if (Dim == 3)
538 : {
539 21965343 : if (calculate_dxyz)
540 27029757 : this->dpsideta_map[i].resize (n_qp);
541 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
542 21965343 : if (calculate_d2xyz)
543 : {
544 890000 : this->d2psidxideta_map[i].resize (n_qp);
545 890000 : 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 143505070 : for (unsigned int p=0; p<n_qp; p++)
554 : {
555 115871513 : if (calculate_xyz)
556 144749020 : this->psi_map[i][p] = shape_ptr (map_fe_type, side, i, qp[p], false);
557 : if (Dim > 1)
558 : {
559 115848118 : if (calculate_dxyz)
560 143308202 : this->dpsidxi_map[i][p] = shape_deriv_ptr (map_fe_type, side, i, 0, qp[p], false);
561 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
562 115848118 : if (calculate_d2xyz)
563 8397982 : 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 100614778 : if (calculate_dxyz)
574 124098786 : this->dpsideta_map[i][p] = shape_deriv_ptr (map_fe_type, side, i, 1, qp[p], false);
575 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
576 100614778 : if (calculate_d2xyz)
577 : {
578 8042800 : this->d2psidxideta_map[i][p] = shape_second_deriv_ptr(map_fe_type, side, i, 1, qp[p], false);
579 8042800 : 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 5043297 : }
586 :
587 : template<unsigned int Dim>
588 58746 : void FEMap::init_edge_shape_functions(const std::vector<Point> & qp,
589 : const Elem * edge)
590 : {
591 : // Start logging the shape function initialization
592 45285 : LOG_SCOPE("init_edge_shape_functions()", "FEMap");
593 :
594 15095 : libmesh_assert(edge);
595 :
596 : // We're calculating now!
597 15095 : this->determine_calculations();
598 :
599 : // The element type and order to use in
600 : // the map
601 58746 : const FEFamily mapping_family = FEMap::map_fe_type(*edge);
602 58746 : const FEType map_fe_type(edge->default_order(), mapping_family);
603 :
604 : // The number of quadrature points.
605 30190 : 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 58746 : 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 58746 : if (calculate_xyz)
614 58746 : this->psi_map.resize (n_mapping_shape_functions);
615 58746 : if (calculate_dxyz)
616 58746 : this->dpsidxi_map.resize (n_mapping_shape_functions);
617 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
618 58746 : if (calculate_d2xyz)
619 0 : this->d2psidxi2_map.resize (n_mapping_shape_functions);
620 : #endif
621 :
622 : FEInterface::shape_ptr shape_ptr =
623 58746 : FEInterface::shape_function(map_fe_type, edge);
624 :
625 : FEInterface::shape_deriv_ptr shape_deriv_ptr =
626 58746 : 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 58746 : FEInterface::shape_second_deriv_function(map_fe_type, edge);
631 : #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
632 :
633 234972 : 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 176226 : if (calculate_xyz)
638 221508 : this->psi_map[i].resize (n_qp);
639 176226 : if (calculate_dxyz)
640 221508 : this->dpsidxi_map[i].resize (n_qp);
641 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
642 176226 : 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 851616 : for (unsigned int p=0; p<n_qp; p++)
649 : {
650 675390 : if (calculate_xyz)
651 848922 : this->psi_map[i][p] = shape_ptr (map_fe_type, edge, i, qp[p], false);
652 675390 : if (calculate_dxyz)
653 848922 : this->dpsidxi_map[i][p] = shape_deriv_ptr (map_fe_type, edge, i, 0, qp[p], false);
654 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
655 675390 : 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 58746 : }
661 :
662 :
663 :
664 9556924 : void FEMap::compute_face_map(int dim, const std::vector<Real> & qw,
665 : const Elem * side)
666 : {
667 2488568 : libmesh_assert(side);
668 :
669 : // We're calculating now!
670 2488568 : this->determine_calculations();
671 :
672 7465704 : LOG_ONE_ENTITY_SCOPE("compute_face_map()", "FEMap");
673 :
674 : // The number of quadrature points.
675 4977136 : const unsigned int n_qp = cast_int<unsigned int>(qw.size());
676 :
677 9556924 : const FEFamily mapping_family = FEMap::map_fe_type(*side);
678 9556924 : const Order mapping_order (side->default_order());
679 2488568 : 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 9556924 : FEInterface::n_shape_functions(map_fe_type, /*extra_order=*/0, side);
684 :
685 9556924 : switch (dim)
686 : {
687 24218 : 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 24218 : if (calculate_xyz)
696 24218 : this->xyz.resize(n_qp);
697 24218 : if (calculate_dxyz)
698 24218 : normals.resize(n_qp);
699 :
700 24218 : if (calculate_dxyz)
701 24218 : this->JxW.resize(n_qp);
702 : }
703 :
704 : // If we have no quadrature points, there's nothing else to do
705 24218 : 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 24218 : const Elem * elem = side->interior_parent();
711 6059 : libmesh_assert (elem);
712 24218 : if (calculate_dxyz)
713 : {
714 36336 : if (side->node_id(0) == elem->node_id(0))
715 : {
716 2185 : const Point reference_point = Point(-1.);
717 8730 : Point dx_dxi = FEMap::map_deriv (1, elem, 0, reference_point);
718 8730 : 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 15488 : Point dx_dxi = FEMap::map_deriv (1, elem, 0, reference_point);
726 15488 : normals[0] = dx_dxi.unit();
727 : }
728 : }
729 :
730 : // Calculate x at the point
731 24218 : 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 48436 : for (unsigned int p=0; p<n_qp; p++)
736 : {
737 24218 : if (calculate_xyz)
738 : {
739 24218 : this->xyz[p].zero();
740 30277 : this->xyz[p].add_scaled (side->point(0), this->psi_map[0][p]);
741 : }
742 24218 : if (calculate_dxyz)
743 : {
744 24218 : normals[p] = normals[0];
745 36336 : this->JxW[p] = 1.0*qw[p];
746 : }
747 : }
748 :
749 : // done computing the map
750 6059 : break;
751 : }
752 :
753 4638157 : 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 4638157 : if (calculate_xyz)
761 4638157 : this->xyz.resize(n_qp);
762 4638157 : if (calculate_dxyz)
763 : {
764 4627357 : this->dxyzdxi_map.resize(n_qp);
765 4627357 : this->tangents.resize(n_qp);
766 4627357 : this->normals.resize(n_qp);
767 :
768 4627357 : this->JxW.resize(n_qp);
769 : }
770 :
771 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
772 4638157 : if (calculate_d2xyz)
773 : {
774 43475 : this->d2xyzdxi2_map.resize(n_qp);
775 43475 : 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 13470698 : for (unsigned int p=0; p<n_qp; p++)
783 : {
784 8832541 : if (calculate_xyz)
785 8832541 : this->xyz[p].zero();
786 8832541 : if (calculate_dxyz)
787 : {
788 11171534 : this->tangents[p].resize(LIBMESH_DIM-1); // 1 Tangent in 2D, 2 in 3D
789 4721186 : this->dxyzdxi_map[p].zero();
790 : }
791 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
792 8832541 : if (calculate_d2xyz)
793 94950 : this->d2xyzdxi2_map[p].zero();
794 : #endif
795 : }
796 :
797 : // compute x, dxdxi at the quadrature points
798 16439368 : for (unsigned int i=0; i<n_mapping_shape_functions; i++) // sum over the nodes
799 : {
800 6350116 : const Point & side_point = side->point(i);
801 :
802 36089606 : for (unsigned int p=0; p<n_qp; p++) // for each quadrature point...
803 : {
804 24288395 : if (calculate_xyz)
805 37262097 : this->xyz[p].add_scaled (side_point, this->psi_map[i][p]);
806 24288395 : if (calculate_dxyz)
807 37164897 : this->dxyzdxi_map[p].add_scaled (side_point, this->dpsidxi_map[i][p]);
808 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
809 24288395 : if (calculate_d2xyz)
810 425514 : 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 4638157 : if (calculate_dxyz)
817 : {
818 13438298 : for (unsigned int p=0; p<n_qp; p++)
819 : {
820 : // The first tangent comes from just the edge's Jacobian
821 11171534 : 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 8810941 : const Elem * elem = side->interior_parent();
833 2360593 : libmesh_assert(elem);
834 :
835 : // Inverse map xyz[p] to a reference point on the parent...
836 11171534 : Point reference_point = FEMap::inverse_map(2, elem, this->xyz[p]);
837 :
838 : // Get dxyz/dxi and dxyz/deta from the parent map.
839 8810941 : Point dx_dxi = FEMap::map_deriv (2, elem, 0, reference_point);
840 8810941 : Point dx_deta = FEMap::map_deriv (2, elem, 1, reference_point);
841 :
842 : // The second tangent vector is formed by crossing these vectors.
843 8810941 : 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 8810941 : 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 8810941 : 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 118394 : curvatures[p] = numerator / denominator;
867 : }
868 : #endif
869 : }
870 :
871 : // compute the jacobian at the quadrature points
872 13438298 : for (unsigned int p=0; p<n_qp; p++)
873 : {
874 8810941 : const Real the_jac = this->dxyzdxi_map[p].norm();
875 :
876 2360593 : libmesh_assert_greater (the_jac, 0.);
877 :
878 13532127 : this->JxW[p] = the_jac*qw[p];
879 : }
880 : }
881 :
882 : // done computing the map
883 1253736 : break;
884 : }
885 :
886 :
887 :
888 4894549 : 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 4894549 : if (calculate_xyz)
894 4894549 : this->xyz.resize(n_qp);
895 4894549 : if (calculate_dxyz)
896 : {
897 4845397 : this->dxyzdxi_map.resize(n_qp);
898 4845397 : this->dxyzdeta_map.resize(n_qp);
899 4845397 : this->tangents.resize(n_qp);
900 4845397 : this->normals.resize(n_qp);
901 4845397 : this->JxW.resize(n_qp);
902 : }
903 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
904 4894549 : if (calculate_d2xyz)
905 : {
906 97600 : this->d2xyzdxi2_map.resize(n_qp);
907 97600 : this->d2xyzdxideta_map.resize(n_qp);
908 97600 : this->d2xyzdeta2_map.resize(n_qp);
909 97600 : this->curvatures.resize(n_qp);
910 : }
911 : #endif
912 : }
913 :
914 : // Clear the entities that will be summed
915 26456523 : for (unsigned int p=0; p<n_qp; p++)
916 : {
917 21561974 : if (calculate_xyz)
918 21561974 : this->xyz[p].zero();
919 21561974 : if (calculate_dxyz)
920 : {
921 26740826 : this->tangents[p].resize(LIBMESH_DIM-1); // 1 Tangent in 2D, 2 in 3D
922 10750920 : this->dxyzdxi_map[p].zero();
923 10750920 : this->dxyzdeta_map[p].zero();
924 : }
925 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
926 21561974 : if (calculate_d2xyz)
927 : {
928 873920 : 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 38425085 : for (unsigned int i=0; i<n_mapping_shape_functions; i++) // sum over the nodes
937 : {
938 16818580 : const Point & side_point = side->point(i);
939 :
940 182445783 : for (unsigned int p=0; p<n_qp; p++) // for each quadrature point...
941 : {
942 148915247 : if (calculate_xyz)
943 223780507 : this->xyz[p].add_scaled (side_point, this->psi_map[i][p]);
944 148915247 : if (calculate_dxyz)
945 : {
946 221716123 : this->dxyzdxi_map[p].add_scaled (side_point, this->dpsidxi_map[i][p]);
947 221716123 : this->dxyzdeta_map[p].add_scaled(side_point, this->dpsideta_map[i][p]);
948 : }
949 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
950 148915247 : if (calculate_d2xyz)
951 : {
952 9651360 : this->d2xyzdxi2_map[p].add_scaled (side_point, this->d2psidxi2_map[i][p]);
953 9651360 : this->d2xyzdxideta_map[p].add_scaled(side_point, this->d2psidxideta_map[i][p]);
954 9651360 : 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 4894549 : if (calculate_dxyz)
962 : {
963 26210763 : for (unsigned int p=0; p<n_qp; p++)
964 : {
965 26740826 : const Point n = this->dxyzdxi_map[p].cross(this->dxyzdeta_map[p]);
966 21365366 : this->normals[p] = n.unit();
967 26740826 : this->tangents[p][0] = this->dxyzdxi_map[p].unit();
968 26740826 : this->tangents[p][1] = n.cross(this->dxyzdxi_map[p]).unit();
969 :
970 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
971 21365366 : 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 873920 : const Real numerator = E*N -2.*F*M + G*L;
987 873920 : const Real denominator = E*G - F*F;
988 218480 : libmesh_assert_not_equal_to (denominator, 0.);
989 1092400 : 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 26210763 : for (unsigned int p=0; p<n_qp; p++)
997 : {
998 21365366 : const Real g11 = (dxdxi_map(p)*dxdxi_map(p) +
999 21365366 : dydxi_map(p)*dydxi_map(p) +
1000 21365366 : dzdxi_map(p)*dzdxi_map(p));
1001 :
1002 21365366 : const Real g12 = (dxdxi_map(p)*dxdeta_map(p) +
1003 21365366 : dydxi_map(p)*dydeta_map(p) +
1004 21365366 : dzdxi_map(p)*dzdeta_map(p));
1005 :
1006 5375460 : const Real g21 = g12;
1007 :
1008 26740826 : const Real g22 = (dxdeta_map(p)*dxdeta_map(p) +
1009 21365366 : dydeta_map(p)*dydeta_map(p) +
1010 21365366 : dzdeta_map(p)*dzdeta_map(p));
1011 :
1012 :
1013 21365366 : const Real the_jac = std::sqrt(g11*g22 - g12*g21);
1014 :
1015 5375460 : libmesh_assert_greater (the_jac, 0.);
1016 :
1017 32116286 : this->JxW[p] = the_jac*qw[p];
1018 : }
1019 : }
1020 :
1021 : // done computing the map
1022 1228773 : break;
1023 : }
1024 :
1025 :
1026 0 : default:
1027 0 : libmesh_error_msg("Invalid dimension dim = " << dim);
1028 : }
1029 9556924 : }
1030 :
1031 :
1032 :
1033 :
1034 58746 : void FEMap::compute_edge_map(int dim,
1035 : const std::vector<Real> & qw,
1036 : const Elem * edge)
1037 : {
1038 15095 : libmesh_assert(edge);
1039 :
1040 58746 : 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 15095 : libmesh_assert_equal_to (dim, 3); // 1D is unnecessary and currently unsupported
1050 :
1051 45285 : LOG_ONE_ENTITY_SCOPE("compute_edge_map()", "FEMap");
1052 :
1053 : // We're calculating now!
1054 15095 : this->determine_calculations();
1055 :
1056 : // The number of quadrature points.
1057 30190 : const unsigned int n_qp = cast_int<unsigned int>(qw.size());
1058 :
1059 : // Resize the vectors to hold data at the quadrature points
1060 58746 : if (calculate_xyz)
1061 58746 : this->xyz.resize(n_qp);
1062 58746 : if (calculate_dxyz)
1063 : {
1064 58746 : this->dxyzdxi_map.resize(n_qp);
1065 58746 : this->dxyzdeta_map.resize(n_qp);
1066 58746 : this->tangents.resize(n_qp);
1067 58746 : this->normals.resize(n_qp);
1068 58746 : this->JxW.resize(n_qp);
1069 : }
1070 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1071 58746 : 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 283884 : for (unsigned int p=0; p<n_qp; p++)
1082 : {
1083 225138 : if (calculate_xyz)
1084 225138 : this->xyz[p].zero();
1085 225138 : if (calculate_dxyz)
1086 : {
1087 282984 : this->tangents[p].resize(1);
1088 115692 : this->dxyzdxi_map[p].zero();
1089 115692 : this->dxyzdeta_map[p].zero();
1090 : }
1091 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1092 225138 : 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 204782 : for (unsigned int i=0,
1103 30190 : psi_map_size=cast_int<unsigned int>(psi_map.size());
1104 234972 : i != psi_map_size; i++) // sum over the nodes
1105 : {
1106 90564 : const Point & edge_point = edge->point(i);
1107 :
1108 851616 : for (unsigned int p=0; p<n_qp; p++) // for each quadrature point...
1109 : {
1110 675390 : if (calculate_xyz)
1111 848922 : this->xyz[p].add_scaled (edge_point, this->psi_map[i][p]);
1112 675390 : if (calculate_dxyz)
1113 1022454 : this->dxyzdxi_map[p].add_scaled (edge_point, this->dpsidxi_map[i][p]);
1114 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1115 675390 : 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 58746 : if (calculate_dxyz)
1124 283884 : for (unsigned int p=0; p<n_qp; p++)
1125 : {
1126 : // const Point n = this->dxyzdxi_map[p].cross(this->dxyzdeta_map[p]);
1127 282984 : this->tangents[p][0] = this->dxyzdxi_map[p].unit();
1128 :
1129 : // compute the jacobian at the quadrature points
1130 225138 : const Real the_jac = std::sqrt(this->dxdxi_map(p)*this->dxdxi_map(p) +
1131 225138 : this->dydxi_map(p)*this->dydxi_map(p) +
1132 225138 : this->dzdxi_map(p)*this->dzdxi_map(p));
1133 :
1134 57846 : libmesh_assert_greater (the_jac, 0.);
1135 :
1136 340830 : 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
|