https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Assembly.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#include "Assembly.h"
11
12// MOOSE includes
13#include "SubProblem.h"
14#include "ArbitraryQuadrature.h"
15#include "SystemBase.h"
16#include "MooseTypes.h"
17#include "MooseMesh.h"
18#include "MooseVariableFE.h"
19#include "MooseVariableScalar.h"
20#include "XFEMInterface.h"
21#include "DisplacedSystem.h"
22#include "MooseMeshUtils.h"
23
24// libMesh
25#include "libmesh/coupling_matrix.h"
26#include "libmesh/dof_map.h"
27#include "libmesh/elem.h"
28#include "libmesh/equation_systems.h"
29#include "libmesh/fe_interface.h"
30#include "libmesh/node.h"
31#include "libmesh/quadrature_gauss.h"
32#include "libmesh/sparse_matrix.h"
33#include "libmesh/tensor_value.h"
34#include "libmesh/vector_value.h"
35#include "libmesh/fe.h"
36
37#include <algorithm>
38
39template <typename P, typename C>
40void
42 const SubdomainID sub_id,
43 const P & point,
44 C & factor,
45 const SubdomainID neighbor_sub_id)
46{
47 coordTransformFactor(s.mesh(), sub_id, point, factor, neighbor_sub_id);
48}
49
50template <typename P, typename C>
51void
53 const SubdomainID sub_id,
54 const P & point,
55 C & factor,
56 const SubdomainID libmesh_dbg_var(neighbor_sub_id))
57{
58 mooseAssert(neighbor_sub_id != libMesh::Elem::invalid_subdomain_id
59 ? mesh.getCoordSystem(sub_id) == mesh.getCoordSystem(neighbor_sub_id)
60 : true,
61 "Coordinate systems must be the same between element and neighbor");
62 const auto coord_type = mesh.getCoordSystem(sub_id);
63
64 if (coord_type == Moose::COORD_RZ)
65 {
66 if (mesh.usingGeneralAxisymmetricCoordAxes())
67 {
68 const auto & axis = mesh.getGeneralAxisymmetricCoordAxis(sub_id);
70 }
71 else
73 point, factor, coord_type, mesh.getAxisymmetricRadialCoord());
74 }
75 else
77}
78
80 : _sys(sys),
81 _subproblem(_sys.subproblem()),
82 _displaced(dynamic_cast<DisplacedSystem *>(&sys) ? true : false),
83 _nonlocal_cm(_subproblem.nonlocalCouplingMatrix(_sys.number())),
84 _computing_residual(_subproblem.currentlyComputingResidual()),
85 _computing_jacobian(_subproblem.currentlyComputingJacobian()),
86 _computing_residual_and_jacobian(_subproblem.currentlyComputingResidualAndJacobian()),
87 _dof_map(_sys.dofMap()),
88 _tid(tid),
89 _mesh(sys.mesh()),
90 _mesh_dimension(_mesh.dimension()),
91 _helper_type(
92 FEType(_mesh.hasSecondOrderElements() ? SECOND : FIRST, LAGRANGE).set_p_refinement(false)),
93 _user_added_fe_of_helper_type(false),
94 _user_added_fe_face_of_helper_type(false),
95 _user_added_fe_face_neighbor_of_helper_type(false),
96 _user_added_fe_neighbor_of_helper_type(false),
97 _user_added_fe_lower_of_helper_type(false),
98 _building_helpers(false),
99 _current_qrule(nullptr),
100 _current_qrule_volume(nullptr),
101 _current_qrule_arbitrary(nullptr),
102 _coord_type(Moose::COORD_XYZ),
103 _current_qrule_face(nullptr),
104 _current_qface_arbitrary(nullptr),
105 _current_qrule_neighbor(nullptr),
106 _need_JxW_neighbor(false),
107 _qrule_msm(nullptr),
108 _custom_mortar_qrule(false),
109 _current_qrule_lower(nullptr),
110
111 _current_elem(nullptr),
112 _current_elem_volume(0),
113 _current_side(0),
114 _current_side_elem(nullptr),
115 _current_side_volume(0),
116 _current_neighbor_elem(nullptr),
117 _current_neighbor_side(0),
118 _current_neighbor_side_elem(nullptr),
119 _need_neighbor_elem_volume(false),
120 _current_neighbor_volume(0),
121 _current_node(nullptr),
122 _current_neighbor_node(nullptr),
123 _current_elem_volume_computed(false),
124 _current_side_volume_computed(false),
125
126 _current_lower_d_elem(nullptr),
127 _current_neighbor_lower_d_elem(nullptr),
128 _need_lower_d_elem_volume(false),
129 _need_neighbor_lower_d_elem_volume(false),
130 _need_dual(false),
131
132 _residual_vector_tags(_subproblem.getVectorTags(Moose::VECTOR_TAG_RESIDUAL)),
133 _cached_residual_values(2), // The 2 is for TIME and NONTIME
134 _cached_residual_rows(2), // The 2 is for TIME and NONTIME
135 _max_cached_residuals(0),
136 _max_cached_jacobians(0),
137
138 _block_diagonal_matrix(false),
139 _calculate_xyz(false),
140 _calculate_face_xyz(false),
141 _calculate_curvatures(false),
142 _calculate_ad_coord(false),
143 _prepared_for_p_refinement(false)
144{
145 const Order helper_order = _mesh.hasSecondOrderElements() ? SECOND : FIRST;
146 _building_helpers = true;
147 // Build fe's for the helpers
153 _building_helpers = false;
154
155 // Build an FE helper object for this type for each dimension up to the dimension of the current
156 // mesh
157 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
158 {
163 }
164
165 for (unsigned int dim = 0; dim < _mesh_dimension; dim++)
167
168 // request phi, dphi, xyz, JxW, etc. data
170
171 // For 3D mortar, mortar segments are always TRI3 elements so we want FIRST LAGRANGE regardless
172 // of discretization
173 const auto mortar_helper_type =
174 FEType(_mesh_dimension == 2 ? helper_order : FIRST, LAGRANGE).set_p_refinement(false);
175 _fe_msm = FEGenericBase<Real>::build(_mesh_dimension - 1, mortar_helper_type);
176 // This FE object should not take part in p-refinement
177 _fe_msm->add_p_level_in_reinit(false);
178 _JxW_msm = &_fe_msm->get_JxW();
179 // Prerequest xyz so that it is computed for _fe_msm so that it can be used for calculating
180 // _coord_msm
181 _fe_msm->get_xyz();
182
183 _extra_elem_ids.resize(_mesh.getMesh().n_elem_integers() + 1);
184 _neighbor_extra_elem_ids.resize(_mesh.getMesh().n_elem_integers() + 1);
185}
186
188{
189 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
190 for (auto & it : _fe[dim])
191 delete it.second;
192
193 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
194 for (auto & it : _fe_face[dim])
195 delete it.second;
196
197 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
198 for (auto & it : _fe_neighbor[dim])
199 delete it.second;
200
201 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
202 for (auto & it : _fe_face_neighbor[dim])
203 delete it.second;
204
205 for (unsigned int dim = 0; dim <= _mesh_dimension - 1; dim++)
206 for (auto & it : _fe_lower[dim])
207 delete it.second;
208
209 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
210 for (auto & it : _vector_fe[dim])
211 delete it.second;
212
213 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
214 for (auto & it : _vector_fe_face[dim])
215 delete it.second;
216
217 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
218 for (auto & it : _vector_fe_neighbor[dim])
219 delete it.second;
220
221 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
222 for (auto & it : _vector_fe_face_neighbor[dim])
223 delete it.second;
224
225 for (unsigned int dim = 0; dim <= _mesh_dimension - 1; dim++)
226 for (auto & it : _vector_fe_lower[dim])
227 delete it.second;
228
229 for (auto & it : _ad_grad_phi_data)
230 it.second.release();
231
232 for (auto & it : _ad_vector_grad_phi_data)
233 it.second.release();
234
235 for (auto & it : _ad_grad_phi_data_face)
236 it.second.release();
237
238 for (auto & it : _ad_vector_grad_phi_data_face)
239 it.second.release();
240
242
243 _coord.release();
246
255
256 delete _qrule_msm;
257}
258
259const MooseArray<Real> &
261{
262 _need_JxW_neighbor = true;
264}
265
266void
267Assembly::buildFE(FEType type) const
268{
269 if (!_building_helpers && type == _helper_type)
271
272 if (!_fe_shape_data[type])
273 _fe_shape_data[type] = std::make_unique<FEShapeData>();
274
275 // Build an FE object for this type for each dimension up to the dimension of the current mesh
276 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
277 {
278 if (!_fe[dim][type])
279 {
280 _fe[dim][type] = FEGenericBase<Real>::build(dim, type).release();
281 _fe[dim][type]->add_p_level_in_reinit(type.p_refinement);
282 }
283
284 _fe[dim][type]->get_phi();
285 _fe[dim][type]->get_dphi();
286 // Pre-request xyz. We have always computed xyz, but due to
287 // recent optimizations in libmesh, we now need to explicity
288 // request it, since apps (Yak) may rely on it being computed.
289 _fe[dim][type]->get_xyz();
290 if (_need_second_derivative.count(type))
291 _fe[dim][type]->get_d2phi();
292 }
293}
294
295void
296Assembly::buildFaceFE(FEType type) const
297{
298 if (!_building_helpers && type == _helper_type)
300
301 if (!_fe_shape_data_face[type])
302 _fe_shape_data_face[type] = std::make_unique<FEShapeData>();
303
304 // Build an FE object for this type for each dimension up to the dimension of the current mesh
305 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
306 {
307 if (!_fe_face[dim][type])
308 {
309 _fe_face[dim][type] = FEGenericBase<Real>::build(dim, type).release();
310 _fe_face[dim][type]->add_p_level_in_reinit(type.p_refinement);
311 }
312
313 _fe_face[dim][type]->get_phi();
314 _fe_face[dim][type]->get_dphi();
315 if (_need_second_derivative.count(type))
316 _fe_face[dim][type]->get_d2phi();
317 }
318}
319
320void
322{
323 if (!_building_helpers && type == _helper_type)
325
326 if (!_fe_shape_data_neighbor[type])
327 _fe_shape_data_neighbor[type] = std::make_unique<FEShapeData>();
328
329 // Build an FE object for this type for each dimension up to the dimension of the current mesh
330 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
331 {
332 if (!_fe_neighbor[dim][type])
333 {
334 _fe_neighbor[dim][type] = FEGenericBase<Real>::build(dim, type).release();
335 _fe_neighbor[dim][type]->add_p_level_in_reinit(type.p_refinement);
336 }
337
338 _fe_neighbor[dim][type]->get_phi();
339 _fe_neighbor[dim][type]->get_dphi();
340 if (_need_second_derivative_neighbor.count(type))
341 _fe_neighbor[dim][type]->get_d2phi();
342 }
343}
344
345void
347{
348 if (!_building_helpers && type == _helper_type)
350
352 _fe_shape_data_face_neighbor[type] = std::make_unique<FEShapeData>();
353
354 // Build an FE object for this type for each dimension up to the dimension of the current mesh
355 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
356 {
357 if (!_fe_face_neighbor[dim][type])
358 {
359 _fe_face_neighbor[dim][type] = FEGenericBase<Real>::build(dim, type).release();
360 _fe_face_neighbor[dim][type]->add_p_level_in_reinit(type.p_refinement);
361 }
362
363 _fe_face_neighbor[dim][type]->get_phi();
364 _fe_face_neighbor[dim][type]->get_dphi();
365 if (_need_second_derivative_neighbor.count(type))
366 _fe_face_neighbor[dim][type]->get_d2phi();
367 }
368}
369
370void
371Assembly::buildLowerDFE(FEType type) const
372{
373 if (!_building_helpers && type == _helper_type)
375
376 if (!_fe_shape_data_lower[type])
377 _fe_shape_data_lower[type] = std::make_unique<FEShapeData>();
378
379 // Build an FE object for this type for each dimension up to the dimension of
380 // the current mesh minus one (because this is for lower-dimensional
381 // elements!)
382 for (unsigned int dim = 0; dim <= _mesh_dimension - 1; dim++)
383 {
384 if (!_fe_lower[dim][type])
385 {
386 _fe_lower[dim][type] = FEGenericBase<Real>::build(dim, type).release();
387 _fe_lower[dim][type]->add_p_level_in_reinit(type.p_refinement);
388 }
389
390 _fe_lower[dim][type]->get_phi();
391 _fe_lower[dim][type]->get_dphi();
392 if (_need_second_derivative.count(type))
393 _fe_lower[dim][type]->get_d2phi();
394 }
395}
396
397void
399{
400 if (!_fe_shape_data_dual_lower[type])
401 _fe_shape_data_dual_lower[type] = std::make_unique<FEShapeData>();
402
403 // Build an FE object for this type for each dimension up to the dimension of
404 // the current mesh minus one (because this is for lower-dimensional
405 // elements!)
406 for (unsigned int dim = 0; dim <= _mesh_dimension - 1; dim++)
407 {
408 if (!_fe_lower[dim][type])
409 {
410 _fe_lower[dim][type] = FEGenericBase<Real>::build(dim, type).release();
411 _fe_lower[dim][type]->add_p_level_in_reinit(type.p_refinement);
412 }
413
414 _fe_lower[dim][type]->get_dual_phi();
415 _fe_lower[dim][type]->get_dual_dphi();
416 if (_need_second_derivative.count(type))
417 _fe_lower[dim][type]->get_dual_d2phi();
418 }
419}
420
421void
423{
425 _vector_fe_shape_data_lower[type] = std::make_unique<VectorFEShapeData>();
426
427 // Build an FE object for this type for each dimension up to the dimension of
428 // the current mesh minus one (because this is for lower-dimensional
429 // elements!)
430 unsigned int dim = ((type.family == LAGRANGE_VEC) || (type.family == MONOMIAL_VEC)) ? 0 : 2;
431 const auto ending_dim = cast_int<unsigned int>(_mesh_dimension - 1);
432 if (ending_dim < dim)
433 return;
434 for (; dim <= ending_dim; dim++)
435 {
436 if (!_vector_fe_lower[dim][type])
437 {
438 _vector_fe_lower[dim][type] = FEVectorBase::build(dim, type).release();
439 _vector_fe_lower[dim][type]->add_p_level_in_reinit(type.p_refinement);
440 }
441
442 _vector_fe_lower[dim][type]->get_phi();
443 _vector_fe_lower[dim][type]->get_dphi();
444 if (_need_second_derivative.count(type))
445 _vector_fe_lower[dim][type]->get_d2phi();
446 }
447}
448
449void
451{
453 _vector_fe_shape_data_dual_lower[type] = std::make_unique<VectorFEShapeData>();
454
455 // Build an FE object for this type for each dimension up to the dimension of
456 // the current mesh minus one (because this is for lower-dimensional
457 // elements!)
458 unsigned int dim = ((type.family == LAGRANGE_VEC) || (type.family == MONOMIAL_VEC)) ? 0 : 2;
459 const auto ending_dim = cast_int<unsigned int>(_mesh_dimension - 1);
460 if (ending_dim < dim)
461 return;
462 for (; dim <= ending_dim; dim++)
463 {
464 if (!_vector_fe_lower[dim][type])
465 {
466 _vector_fe_lower[dim][type] = FEVectorBase::build(dim, type).release();
467 _vector_fe_lower[dim][type]->add_p_level_in_reinit(type.p_refinement);
468 }
469
470 _vector_fe_lower[dim][type]->get_dual_phi();
471 _vector_fe_lower[dim][type]->get_dual_dphi();
472 if (_need_second_derivative.count(type))
473 _vector_fe_lower[dim][type]->get_dual_d2phi();
474 }
475}
476
477void
478Assembly::buildVectorFE(const FEType type) const
479{
480 if (!_vector_fe_shape_data[type])
481 _vector_fe_shape_data[type] = std::make_unique<VectorFEShapeData>();
482
483 // Note that NEDELEC_ONE and RAVIART_THOMAS elements can only be built for dimension > 2
484 unsigned int min_dim;
485 if (type.family == NEDELEC_ONE || type.family == RAVIART_THOMAS ||
486 type.family == L2_RAVIART_THOMAS)
487 min_dim = 2;
488 else
489 min_dim = 0;
490
491 // Build an FE object for this type for each dimension from the min_dim up to the dimension of the
492 // current mesh
493 for (unsigned int dim = min_dim; dim <= _mesh_dimension; dim++)
494 {
495 if (!_vector_fe[dim][type])
496 {
497 _vector_fe[dim][type] = FEGenericBase<VectorValue<Real>>::build(dim, type).release();
498 _vector_fe[dim][type]->add_p_level_in_reinit(type.p_refinement);
499 }
500
501 _vector_fe[dim][type]->get_phi();
502 _vector_fe[dim][type]->get_dphi();
503 if (_need_curl.count(type))
504 _vector_fe[dim][type]->get_curl_phi();
505 if (_need_div.count(type))
506 _vector_fe[dim][type]->get_div_phi();
507 _vector_fe[dim][type]->get_xyz();
508 }
509}
510
511void
512Assembly::buildVectorFaceFE(const FEType type) const
513{
515 _vector_fe_shape_data_face[type] = std::make_unique<VectorFEShapeData>();
516
517 // Note that NEDELEC_ONE and RAVIART_THOMAS elements can only be built for dimension > 2
518 unsigned int min_dim;
519 if (type.family == NEDELEC_ONE || type.family == RAVIART_THOMAS ||
520 type.family == L2_RAVIART_THOMAS)
521 min_dim = 2;
522 else
523 min_dim = 0;
524
525 // Build an FE object for this type for each dimension from the min_dim up to the dimension of the
526 // current mesh
527 for (unsigned int dim = min_dim; dim <= _mesh_dimension; dim++)
528 {
529 if (!_vector_fe_face[dim][type])
530 {
531 _vector_fe_face[dim][type] = FEGenericBase<VectorValue<Real>>::build(dim, type).release();
532 _vector_fe_face[dim][type]->add_p_level_in_reinit(type.p_refinement);
533 }
534
535 _vector_fe_face[dim][type]->get_phi();
536 _vector_fe_face[dim][type]->get_dphi();
537 if (_need_curl.count(type))
538 _vector_fe_face[dim][type]->get_curl_phi();
539 if (_need_face_div.count(type))
540 _vector_fe_face[dim][type]->get_div_phi();
541 }
542}
543
544void
545Assembly::buildVectorNeighborFE(const FEType type) const
546{
548 _vector_fe_shape_data_neighbor[type] = std::make_unique<VectorFEShapeData>();
549
550 // Note that NEDELEC_ONE and RAVIART_THOMAS elements can only be built for dimension > 2
551 unsigned int min_dim;
552 if (type.family == NEDELEC_ONE || type.family == RAVIART_THOMAS ||
553 type.family == L2_RAVIART_THOMAS)
554 min_dim = 2;
555 else
556 min_dim = 0;
557
558 // Build an FE object for this type for each dimension from the min_dim up to the dimension of the
559 // current mesh
560 for (unsigned int dim = min_dim; dim <= _mesh_dimension; dim++)
561 {
562 if (!_vector_fe_neighbor[dim][type])
563 {
564 _vector_fe_neighbor[dim][type] = FEGenericBase<VectorValue<Real>>::build(dim, type).release();
565 _vector_fe_neighbor[dim][type]->add_p_level_in_reinit(type.p_refinement);
566 }
567
568 _vector_fe_neighbor[dim][type]->get_phi();
569 _vector_fe_neighbor[dim][type]->get_dphi();
570 if (_need_curl.count(type))
571 _vector_fe_neighbor[dim][type]->get_curl_phi();
572 if (_need_neighbor_div.count(type))
573 _vector_fe_neighbor[dim][type]->get_div_phi();
574 }
575}
576
577void
579{
581 _vector_fe_shape_data_face_neighbor[type] = std::make_unique<VectorFEShapeData>();
582
583 // Note that NEDELEC_ONE and RAVIART_THOMAS elements can only be built for dimension > 2
584 unsigned int min_dim;
585 if (type.family == NEDELEC_ONE || type.family == RAVIART_THOMAS ||
586 type.family == L2_RAVIART_THOMAS)
587 min_dim = 2;
588 else
589 min_dim = 0;
590
591 // Build an FE object for this type for each dimension from the min_dim up to the dimension of the
592 // current mesh
593 for (unsigned int dim = min_dim; dim <= _mesh_dimension; dim++)
594 {
595 if (!_vector_fe_face_neighbor[dim][type])
596 {
598 FEGenericBase<VectorValue<Real>>::build(dim, type).release();
599 _vector_fe_face_neighbor[dim][type]->add_p_level_in_reinit(type.p_refinement);
600 }
601
602 _vector_fe_face_neighbor[dim][type]->get_phi();
603 _vector_fe_face_neighbor[dim][type]->get_dphi();
604 if (_need_curl.count(type))
605 _vector_fe_face_neighbor[dim][type]->get_curl_phi();
606 if (_need_face_neighbor_div.count(type))
607 _vector_fe_face_neighbor[dim][type]->get_div_phi();
608 }
609}
610
611void
613{
614 auto & qdefault = _qrules[Moose::ANY_BLOCK_ID];
615 mooseAssert(qdefault.size() > 0, "default quadrature must be initialized before order bumps");
616
617 unsigned int ndims = _mesh_dimension + 1; // must account for 0-dimensional quadrature.
618 auto & qvec = _qrules[block];
619 if (qvec.size() != ndims || !qvec[0].vol)
620 createQRules(qdefault[0].vol->type(),
621 qdefault[0].arbitrary_vol->get_order(),
622 volume_order,
623 qdefault[0].face->get_order(),
624 block);
625 else if (qvec[0].vol->get_order() < volume_order)
626 createQRules(qvec[0].vol->type(),
627 qvec[0].arbitrary_vol->get_order(),
628 volume_order,
629 qvec[0].face->get_order(),
630 block);
631 // otherwise do nothing - quadrature order is already as high as requested
632}
633
634void
636{
637 auto & qdefault = _qrules[Moose::ANY_BLOCK_ID];
638 mooseAssert(qdefault.size() > 0, "default quadrature must be initialized before order bumps");
639
640 unsigned int ndims = _mesh_dimension + 1; // must account for 0-dimensional quadrature.
641 auto & qvec = _qrules[block];
642 if (qvec.size() != ndims || !qvec[0].vol)
643 createQRules(qdefault[0].vol->type(), order, order, order, block);
644 else if (qvec[0].vol->get_order() < order || qvec[0].face->get_order() < order)
645 createQRules(qvec[0].vol->type(),
646 std::max(order, qvec[0].arbitrary_vol->get_order()),
647 std::max(order, qvec[0].vol->get_order()),
648 std::max(order, qvec[0].face->get_order()),
649 block);
650 // otherwise do nothing - quadrature order is already as high as requested
651}
652
653void
654Assembly::createQRules(QuadratureType type,
655 Order order,
656 Order volume_order,
657 Order face_order,
658 SubdomainID block,
659 bool allow_negative_qweights)
660{
661 auto & qvec = _qrules[block];
662 unsigned int ndims = _mesh_dimension + 1; // must account for 0-dimensional quadrature.
663 if (qvec.size() != ndims)
664 qvec.resize(ndims);
665
666 for (unsigned int i = 0; i < qvec.size(); i++)
667 {
668 int dim = i;
669 auto & q = qvec[dim];
670 q.vol = QBase::build(type, dim, volume_order);
671 q.vol->allow_rules_with_negative_weights = allow_negative_qweights;
672 q.face = QBase::build(type, dim - 1, face_order);
673 q.face->allow_rules_with_negative_weights = allow_negative_qweights;
674 q.fv_face = QBase::build(libMesh::QMONOMIAL, dim - 1, CONSTANT);
675 q.fv_face->allow_rules_with_negative_weights = allow_negative_qweights;
676 q.neighbor = std::make_unique<ArbitraryQuadrature>(dim - 1, face_order);
677 q.neighbor->allow_rules_with_negative_weights = allow_negative_qweights;
678 q.arbitrary_vol = std::make_unique<ArbitraryQuadrature>(dim, order);
679 q.arbitrary_vol->allow_rules_with_negative_weights = allow_negative_qweights;
680 q.arbitrary_face = std::make_unique<ArbitraryQuadrature>(dim - 1, face_order);
681 q.arbitrary_face->allow_rules_with_negative_weights = allow_negative_qweights;
682 }
683
684 delete _qrule_msm;
685 _custom_mortar_qrule = false;
686 _qrule_msm = QBase::build(type, _mesh_dimension - 1, face_order).release();
687 _qrule_msm->allow_rules_with_negative_weights = allow_negative_qweights;
688 _fe_msm->attach_quadrature_rule(_qrule_msm);
689}
690
691void
692Assembly::setVolumeQRule(QBase * qrule, unsigned int dim)
693{
694 _current_qrule = qrule;
695
696 if (qrule) // Don't set a NULL qrule
697 {
698 for (auto & it : _fe[dim])
699 it.second->attach_quadrature_rule(qrule);
700 for (auto & it : _vector_fe[dim])
701 it.second->attach_quadrature_rule(qrule);
702 if (!_unique_fe_helper.empty())
703 {
704 mooseAssert(dim < _unique_fe_helper.size(), "We should not be indexing out of bounds");
705 _unique_fe_helper[dim]->attach_quadrature_rule(qrule);
706 }
707 }
708}
709
710void
711Assembly::setFaceQRule(QBase * qrule, unsigned int dim)
712{
713 _current_qrule_face = qrule;
714
715 for (auto & it : _fe_face[dim])
716 it.second->attach_quadrature_rule(qrule);
717 for (auto & it : _vector_fe_face[dim])
718 it.second->attach_quadrature_rule(qrule);
719 if (!_unique_fe_face_helper.empty())
720 {
721 mooseAssert(dim < _unique_fe_face_helper.size(), "We should not be indexing out of bounds");
722 _unique_fe_face_helper[dim]->attach_quadrature_rule(qrule);
723 }
724}
725
726void
727Assembly::setLowerQRule(QBase * qrule, unsigned int dim)
728{
729 // The lower-dimensional quadrature rule matches the face quadrature rule
730 setFaceQRule(qrule, dim);
731
732 _current_qrule_lower = qrule;
733
734 for (auto & it : _fe_lower[dim])
735 it.second->attach_quadrature_rule(qrule);
736 for (auto & it : _vector_fe_lower[dim])
737 it.second->attach_quadrature_rule(qrule);
738 if (!_unique_fe_lower_helper.empty())
739 {
740 mooseAssert(dim < _unique_fe_lower_helper.size(), "We should not be indexing out of bounds");
741 _unique_fe_lower_helper[dim]->attach_quadrature_rule(qrule);
742 }
743}
744
745void
746Assembly::setNeighborQRule(QBase * qrule, unsigned int dim)
747{
749
750 for (auto & it : _fe_face_neighbor[dim])
751 it.second->attach_quadrature_rule(qrule);
752 for (auto & it : _vector_fe_face_neighbor[dim])
753 it.second->attach_quadrature_rule(qrule);
755 {
756 mooseAssert(dim < _unique_fe_face_neighbor_helper.size(),
757 "We should not be indexing out of bounds");
758 _unique_fe_face_neighbor_helper[dim]->attach_quadrature_rule(qrule);
759 }
760}
761
762void
764{
765 _current_qrule = nullptr;
766 _current_qrule_face = nullptr;
767 _current_qrule_lower = nullptr;
768 _current_qrule_neighbor = nullptr;
769}
770
771void
773{
774 if (order != _qrule_msm->get_order())
775 {
776 // If custom mortar qrule has not yet been specified
778 {
780 const unsigned int dim = _qrule_msm->get_dim();
781 const QuadratureType type = _qrule_msm->type();
782 delete _qrule_msm;
783
784 _qrule_msm = QBase::build(type, dim, order).release();
785 _fe_msm->attach_quadrature_rule(_qrule_msm);
786 }
787 else
788 mooseError("Mortar quadrature_order: ",
789 order,
790 " does not match previously specified quadrature_order: ",
792 ". Quadrature_order (when specified) must match for all mortar constraints.");
793 }
794}
795
796void
797Assembly::reinitFE(const Elem * elem)
798{
799 unsigned int dim = elem->dim();
800
801 for (const auto & it : _fe[dim])
802 {
803 FEBase & fe = *it.second;
804 const FEType & fe_type = it.first;
805
806 _current_fe[fe_type] = &fe;
807
808 FEShapeData & fesd = *_fe_shape_data[fe_type];
809
810 fe.reinit(elem);
811
812 fesd._phi.shallowCopy(const_cast<std::vector<std::vector<Real>> &>(fe.get_phi()));
813 fesd._grad_phi.shallowCopy(
814 const_cast<std::vector<std::vector<VectorValue<Real>>> &>(fe.get_dphi()));
815 if (_need_second_derivative.count(fe_type))
816 fesd._second_phi.shallowCopy(
817 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe.get_d2phi()));
818 }
819 for (const auto & it : _vector_fe[dim])
820 {
821 FEVectorBase & fe = *it.second;
822 const FEType & fe_type = it.first;
823
824 _current_vector_fe[fe_type] = &fe;
825
826 VectorFEShapeData & fesd = *_vector_fe_shape_data[fe_type];
827
828 fe.reinit(elem);
829
830 fesd._phi.shallowCopy(const_cast<std::vector<std::vector<VectorValue<Real>>> &>(fe.get_phi()));
831 fesd._grad_phi.shallowCopy(
832 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe.get_dphi()));
833 if (_need_second_derivative.count(fe_type))
834 fesd._second_phi.shallowCopy(
835 const_cast<std::vector<std::vector<TypeNTensor<3, Real>>> &>(fe.get_d2phi()));
836 if (_need_curl.count(fe_type))
837 fesd._curl_phi.shallowCopy(
838 const_cast<std::vector<std::vector<VectorValue<Real>>> &>(fe.get_curl_phi()));
839 if (_need_div.count(fe_type))
840 fesd._div_phi.shallowCopy(const_cast<std::vector<std::vector<Real>> &>(fe.get_div_phi()));
841 }
842 if (!_unique_fe_helper.empty())
843 {
844 mooseAssert(dim < _unique_fe_helper.size(), "We should be in bounds here");
845 _unique_fe_helper[dim]->reinit(elem);
846 }
847
848 // During that last loop the helper objects will have been reinitialized as well
849 // We need to dig out the q_points and JxW from it.
851 const_cast<std::vector<Point> &>(_holder_fe_helper[dim]->get_xyz()));
852 _current_JxW.shallowCopy(const_cast<std::vector<Real> &>(_holder_fe_helper[dim]->get_JxW()));
853
854 // The AD map is needed for the AD JxW, quadrature points and coordinate transformation and for
855 // the AD shape function gradients, which use its inverse
857 {
858 auto n_qp = _current_qrule->n_points();
860 if (_displaced)
861 {
862 const auto & qw = _current_qrule->get_weights();
864 *elem, ADReal::do_derivatives && _sys.number() == _subproblem.currentNlSysNum());
865 for (unsigned int qp = 0; qp != n_qp; qp++)
867 }
868 else
869 {
870 for (unsigned qp = 0; qp < n_qp; ++qp)
871 _ad_JxW[qp] = _current_JxW[qp];
872 if (_calculate_xyz)
873 for (unsigned qp = 0; qp < n_qp; ++qp)
875 }
876
877 for (const auto & it : _fe[dim])
878 {
880 break;
881 FEBase & fe = *it.second;
882 auto fe_type = it.first;
883 auto num_shapes = FEInterface::n_shape_functions(fe_type, elem);
884 auto & grad_phi = _ad_grad_phi_data[fe_type];
885
886 grad_phi.resize(num_shapes);
887 for (decltype(num_shapes) i = 0; i < num_shapes; ++i)
888 grad_phi[i].resize(n_qp);
889
890 if (_displaced)
891 computeGradPhiAD(elem, n_qp, grad_phi, &fe);
892 else
893 {
894 const auto & regular_grad_phi = _fe_shape_data[fe_type]->_grad_phi;
895 for (decltype(num_shapes) i = 0; i < num_shapes; ++i)
896 for (unsigned qp = 0; qp < n_qp; ++qp)
897 grad_phi[i][qp] = regular_grad_phi[i][qp];
898 }
899 }
900 for (const auto & it : _vector_fe[dim])
901 {
903 break;
904 FEVectorBase & fe = *it.second;
905 auto fe_type = it.first;
906 auto num_shapes = FEInterface::n_shape_functions(fe_type, elem);
907 auto & grad_phi = _ad_vector_grad_phi_data[fe_type];
908
909 grad_phi.resize(num_shapes);
910 for (decltype(num_shapes) i = 0; i < num_shapes; ++i)
911 grad_phi[i].resize(n_qp);
912
913 if (_displaced)
914 computeGradPhiAD(elem, n_qp, grad_phi, &fe);
915 else
916 {
917 const auto & regular_grad_phi = _vector_fe_shape_data[fe_type]->_grad_phi;
918 for (decltype(num_shapes) i = 0; i < num_shapes; ++i)
919 for (unsigned qp = 0; qp < n_qp; ++qp)
920 grad_phi[i][qp] = regular_grad_phi[i][qp];
921 }
922 }
923 }
924
925 auto n = numExtraElemIntegers();
926 for (auto i : make_range(n))
927 _extra_elem_ids[i] = _current_elem->get_extra_integer(i);
928 _extra_elem_ids[n] = _current_elem->subdomain_id();
929
930 if (_xfem != nullptr)
932}
933
934template <typename OutputType>
935void
937 unsigned int n_qp,
939 FEGenericBase<OutputType> * fe)
940{
941 // This function relies on the fact that FE::reinit has already been called. FE::reinit will
942 // importantly have already called FEMap::init_shape_functions which will have computed
943 // these quantities at the integration/quadrature points: dphidxi,
944 // dphideta, and dphidzeta (e.g. \nabla phi w.r.t. reference coordinates). These *phi* quantities
945 // are independent of mesh displacements when using a quadrature rule.
946 //
947 // Note that a user could have specified custom integration points (e.g. independent of a
948 // quadrature rule) which could very well depend on displacements. In that case even the *phi*
949 // quantities from the above paragraph would be a function of the displacements and we would be
950 // missing that derivative information in the calculations below
951
952 auto dim = elem->dim();
953 const auto & dphidxi = fe->get_dphidxi();
954 const auto & dphideta = fe->get_dphideta();
955 const auto & dphidzeta = fe->get_dphidzeta();
956 auto num_shapes = grad_phi.size();
957
958 switch (dim)
959 {
960 case 0:
961 {
962 for (decltype(num_shapes) i = 0; i < num_shapes; ++i)
963 for (unsigned qp = 0; qp < n_qp; ++qp)
964 grad_phi[i][qp] = 0;
965 break;
966 }
967
968 case 1:
969 {
970 for (decltype(num_shapes) i = 0; i < num_shapes; ++i)
971 for (unsigned qp = 0; qp < n_qp; ++qp)
972 {
973 grad_phi[i][qp].slice(0) = dphidxi[i][qp] * _ad_dxidx_map[qp];
974 grad_phi[i][qp].slice(1) = dphidxi[i][qp] * _ad_dxidy_map[qp];
975 grad_phi[i][qp].slice(2) = dphidxi[i][qp] * _ad_dxidz_map[qp];
976 }
977 break;
978 }
979
980 case 2:
981 {
982 for (decltype(num_shapes) i = 0; i < num_shapes; ++i)
983 for (unsigned qp = 0; qp < n_qp; ++qp)
984 {
985 grad_phi[i][qp].slice(0) =
986 dphidxi[i][qp] * _ad_dxidx_map[qp] + dphideta[i][qp] * _ad_detadx_map[qp];
987 grad_phi[i][qp].slice(1) =
988 dphidxi[i][qp] * _ad_dxidy_map[qp] + dphideta[i][qp] * _ad_detady_map[qp];
989 grad_phi[i][qp].slice(2) =
990 dphidxi[i][qp] * _ad_dxidz_map[qp] + dphideta[i][qp] * _ad_detadz_map[qp];
991 }
992 break;
993 }
994
995 case 3:
996 {
997 for (decltype(num_shapes) i = 0; i < num_shapes; ++i)
998 for (unsigned qp = 0; qp < n_qp; ++qp)
999 {
1000 grad_phi[i][qp].slice(0) = dphidxi[i][qp] * _ad_dxidx_map[qp] +
1001 dphideta[i][qp] * _ad_detadx_map[qp] +
1002 dphidzeta[i][qp] * _ad_dzetadx_map[qp];
1003 grad_phi[i][qp].slice(1) = dphidxi[i][qp] * _ad_dxidy_map[qp] +
1004 dphideta[i][qp] * _ad_detady_map[qp] +
1005 dphidzeta[i][qp] * _ad_dzetady_map[qp];
1006 grad_phi[i][qp].slice(2) = dphidxi[i][qp] * _ad_dxidz_map[qp] +
1007 dphideta[i][qp] * _ad_detadz_map[qp] +
1008 dphidzeta[i][qp] * _ad_dzetadz_map[qp];
1009 }
1010 break;
1011 }
1012 }
1013}
1014
1015void
1016Assembly::resizeADMappingObjects(unsigned int n_qp, unsigned int dim)
1017{
1018 _ad_dxyzdxi_map.resize(n_qp);
1019 _ad_dxidx_map.resize(n_qp);
1020 _ad_dxidy_map.resize(n_qp); // 1D element may live in 2D ...
1021 _ad_dxidz_map.resize(n_qp); // ... or 3D
1022
1023 if (dim > 1)
1024 {
1025 _ad_dxyzdeta_map.resize(n_qp);
1026 _ad_detadx_map.resize(n_qp);
1027 _ad_detady_map.resize(n_qp);
1028 _ad_detadz_map.resize(n_qp);
1029
1030 if (dim > 2)
1031 {
1032 _ad_dxyzdzeta_map.resize(n_qp);
1033 _ad_dzetadx_map.resize(n_qp);
1034 _ad_dzetady_map.resize(n_qp);
1035 _ad_dzetadz_map.resize(n_qp);
1036 }
1037 }
1038
1039 _ad_jac.resize(n_qp);
1040 _ad_JxW.resize(n_qp);
1041 if (_calculate_xyz)
1042 _ad_q_points.resize(n_qp);
1043}
1044
1045void
1046Assembly::computeADElemNodePoints(const Elem & elem, const bool do_derivatives)
1047{
1048 _ad_elem_node_points.resize(elem.n_nodes());
1049 for (const auto n : elem.node_index_range())
1050 _ad_elem_node_points[n] = elem.point(n);
1051
1052 if (!do_derivatives)
1053 return;
1054
1055 const auto sys_num = _sys.number();
1056 const auto & dof_map = _sys.dofMap();
1057 for (const auto & [disp_num, direction] : _disp_numbers_and_directions)
1058 {
1059 bool has_nodes_without_dofs = false;
1060 for (const auto n : elem.node_index_range())
1061 {
1062 const Node & node = elem.node_ref(n);
1063 if (node.n_dofs(sys_num, disp_num))
1064 Moose::derivInsert(_ad_elem_node_points[n](direction).derivatives(),
1065 node.dof_number(sys_num, disp_num, 0),
1066 1.);
1067 else
1068 has_nodes_without_dofs = true;
1069 }
1070
1071 const auto & var = dof_map.variable(disp_num);
1072 if (!has_nodes_without_dofs || var.type().family != LAGRANGE ||
1073 !var.active_on_subdomain(elem.subdomain_id()))
1074 continue;
1075
1076 // DisplacedProblem displaces the nodes without degrees of freedom with the nodal_soln of the
1077 // element degrees of freedom, which is linear in them, so evaluating it for each unit degree of
1078 // freedom gives the derivatives of the node positions
1079 dof_map.dof_indices(&elem, _ad_elem_disp_dof_indices, disp_num);
1081 for (const auto j : index_range(_ad_elem_disp_dof_indices))
1082 {
1084 FEInterface::nodal_soln(
1087 for (const auto n : elem.node_index_range())
1088 if (!elem.node_ref(n).n_dofs(sys_num, disp_num) && _ad_elem_disp_nodal_soln[n] != 0)
1089 Moose::derivInsert(_ad_elem_node_points[n](direction).derivatives(),
1092 }
1093 }
1094}
1095
1096void
1098 const std::vector<Real> & qw,
1099 unsigned p,
1100 FEBase * fe)
1101{
1102 // This function relies on the fact that FE::reinit has already been called. FE::reinit will
1103 // importantly have already called FEMap::init_reference_to_physical_map which will have computed
1104 // these quantities at the integration/quadrature points: phi_map, dphidxi_map,
1105 // dphideta_map, and dphidzeta_map (e.g. phi and \nabla phi w.r.t reference coordinates). *_map is
1106 // used to denote that quantities are in reference to a mapping Lagrange FE object. The FE<Dim,
1107 // LAGRANGE> objects used for mapping will in general have an order matching the order of the
1108 // mesh. These *phi*_map quantities are independent of mesh displacements when using a quadrature
1109 // rule.
1110 //
1111 // Note that a user could have specified custom integration points (e.g. independent of a
1112 // quadrature rule) which could very well depend on displacements. In that case even the *phi*_map
1113 // quantities from the above paragraph would be a function of the displacements and we would be
1114 // missing that derivative information in the calculations below
1115 //
1116 // Important quantities calculated by this method:
1117 // - _ad_JxW;
1118 // - _ad_q_points;
1119 // And the following quantities are important because they are used in the computeGradPhiAD method
1120 // to calculate the shape function gradients with respect to the physical coordinates
1121 // dphi/dphys = dphi/dref * dref/dphys:
1122 // - _ad_dxidx_map;
1123 // - _ad_dxidy_map;
1124 // - _ad_dxidz_map;
1125 // - _ad_detadx_map;
1126 // - _ad_detady_map;
1127 // - _ad_detadz_map;
1128 // - _ad_dzetadx_map;
1129 // - _ad_dzetady_map;
1130 // - _ad_dzetadz_map;
1131 //
1132 // Some final notes. This method will be called both when we are reinit'ing in the volume and on
1133 // faces. When reinit'ing on faces, computation of _ad_JxW will be garbage because we will be
1134 // using dummy quadrature weights. _ad_q_points computation is also currently extraneous during
1135 // face reinit because we compute _ad_q_points_face in the computeFaceMap method. However,
1136 // computation of dref/dphys is absolutely necessary (and the reason we call this method for the
1137 // face case) for both volume and face reinit
1138
1139 auto dim = elem->dim();
1140 const auto & elem_nodes = elem->get_nodes();
1141 const auto & phi_map = fe->get_fe_map().get_phi_map();
1142 // The mapping basis includes every mapping node, including enriched nodes on elements such as
1143 // TET14.
1144 const auto num_shapes = phi_map.size();
1145 const auto & dphidxi_map = fe->get_fe_map().get_dphidxi_map();
1146 const auto & dphideta_map = fe->get_fe_map().get_dphideta_map();
1147 const auto & dphidzeta_map = fe->get_fe_map().get_dphidzeta_map();
1148 mooseAssert(_ad_elem_node_points.size() == elem->n_nodes(),
1149 "computeADElemNodePoints must be called for this element first");
1150
1151 switch (dim)
1152 {
1153 case 0:
1154 {
1155 _ad_jac[p] = 1.0;
1156 _ad_JxW[p] = qw[p];
1157 if (_calculate_xyz)
1158 _ad_q_points[p] = *elem_nodes[0];
1159 break;
1160 }
1161
1162 case 1:
1163 {
1164 if (_calculate_xyz)
1165 _ad_q_points[p].zero();
1166
1167 _ad_dxyzdxi_map[p].zero();
1168
1169 for (std::size_t i = 0; i < num_shapes; i++)
1170 {
1171 const auto & elem_point = _ad_elem_node_points[i];
1172
1173 _ad_dxyzdxi_map[p].add_scaled(elem_point, dphidxi_map[i][p]);
1174
1175 if (_calculate_xyz)
1176 _ad_q_points[p].add_scaled(elem_point, phi_map[i][p]);
1177 }
1178
1179 _ad_jac[p] = _ad_dxyzdxi_map[p].norm();
1180
1181 if (_ad_jac[p].value() <= -TOLERANCE * TOLERANCE)
1182 {
1183 static bool failing = false;
1184 if (!failing)
1185 {
1186 failing = true;
1187 elem->print_info(libMesh::err);
1188 libmesh_error_msg("ERROR: negative Jacobian " << _ad_jac[p].value() << " at point index "
1189 << p << " in element " << elem->id());
1190 }
1191 else
1192 return;
1193 }
1194
1195 const auto jacm2 = 1. / _ad_jac[p] / _ad_jac[p];
1196 _ad_dxidx_map[p] = jacm2 * _ad_dxyzdxi_map[p](0);
1197 _ad_dxidy_map[p] = jacm2 * _ad_dxyzdxi_map[p](1);
1198 _ad_dxidz_map[p] = jacm2 * _ad_dxyzdxi_map[p](2);
1199
1200 _ad_JxW[p] = _ad_jac[p] * qw[p];
1201
1202 break;
1203 }
1204
1205 case 2:
1206 {
1207 if (_calculate_xyz)
1208 _ad_q_points[p].zero();
1209 _ad_dxyzdxi_map[p].zero();
1210 _ad_dxyzdeta_map[p].zero();
1211
1212 for (std::size_t i = 0; i < num_shapes; i++)
1213 {
1214 const auto & elem_point = _ad_elem_node_points[i];
1215
1216 _ad_dxyzdxi_map[p].add_scaled(elem_point, dphidxi_map[i][p]);
1217 _ad_dxyzdeta_map[p].add_scaled(elem_point, dphideta_map[i][p]);
1218
1219 if (_calculate_xyz)
1220 _ad_q_points[p].add_scaled(elem_point, phi_map[i][p]);
1221 }
1222
1223 const auto &dx_dxi = _ad_dxyzdxi_map[p](0), &dx_deta = _ad_dxyzdeta_map[p](0),
1224 &dy_dxi = _ad_dxyzdxi_map[p](1), &dy_deta = _ad_dxyzdeta_map[p](1),
1225 &dz_dxi = _ad_dxyzdxi_map[p](2), &dz_deta = _ad_dxyzdeta_map[p](2);
1226
1227 const auto g11 = (dx_dxi * dx_dxi + dy_dxi * dy_dxi + dz_dxi * dz_dxi);
1228
1229 const auto g12 = (dx_dxi * dx_deta + dy_dxi * dy_deta + dz_dxi * dz_deta);
1230
1231 const auto & g21 = g12;
1232
1233 const auto g22 = (dx_deta * dx_deta + dy_deta * dy_deta + dz_deta * dz_deta);
1234
1235 auto det = (g11 * g22 - g12 * g21);
1236
1237 if (det.value() <= -TOLERANCE * TOLERANCE)
1238 {
1239 static bool failing = false;
1240 if (!failing)
1241 {
1242 failing = true;
1243 elem->print_info(libMesh::err);
1244 libmesh_error_msg("ERROR: negative Jacobian " << det << " at point index " << p
1245 << " in element " << elem->id());
1246 }
1247 else
1248 return;
1249 }
1250 else if (det.value() <= 0.)
1251 det.value() = TOLERANCE * TOLERANCE;
1252
1253 const auto inv_det = 1. / det;
1254 using std::sqrt;
1255 _ad_jac[p] = sqrt(det);
1256
1257 _ad_JxW[p] = _ad_jac[p] * qw[p];
1258
1259 const auto g11inv = g22 * inv_det;
1260 const auto g12inv = -g12 * inv_det;
1261 const auto g21inv = -g21 * inv_det;
1262 const auto g22inv = g11 * inv_det;
1263
1264 _ad_dxidx_map[p] = g11inv * dx_dxi + g12inv * dx_deta;
1265 _ad_dxidy_map[p] = g11inv * dy_dxi + g12inv * dy_deta;
1266 _ad_dxidz_map[p] = g11inv * dz_dxi + g12inv * dz_deta;
1267
1268 _ad_detadx_map[p] = g21inv * dx_dxi + g22inv * dx_deta;
1269 _ad_detady_map[p] = g21inv * dy_dxi + g22inv * dy_deta;
1270 _ad_detadz_map[p] = g21inv * dz_dxi + g22inv * dz_deta;
1271
1272 break;
1273 }
1274
1275 case 3:
1276 {
1277 if (_calculate_xyz)
1278 _ad_q_points[p].zero();
1279 _ad_dxyzdxi_map[p].zero();
1280 _ad_dxyzdeta_map[p].zero();
1281 _ad_dxyzdzeta_map[p].zero();
1282
1283 for (std::size_t i = 0; i < num_shapes; i++)
1284 {
1285 const auto & elem_point = _ad_elem_node_points[i];
1286
1287 _ad_dxyzdxi_map[p].add_scaled(elem_point, dphidxi_map[i][p]);
1288 _ad_dxyzdeta_map[p].add_scaled(elem_point, dphideta_map[i][p]);
1289 _ad_dxyzdzeta_map[p].add_scaled(elem_point, dphidzeta_map[i][p]);
1290
1291 if (_calculate_xyz)
1292 _ad_q_points[p].add_scaled(elem_point, phi_map[i][p]);
1293 }
1294
1295 const auto &dx_dxi = _ad_dxyzdxi_map[p](0), &dy_dxi = _ad_dxyzdxi_map[p](1),
1296 &dz_dxi = _ad_dxyzdxi_map[p](2), &dx_deta = _ad_dxyzdeta_map[p](0),
1297 &dy_deta = _ad_dxyzdeta_map[p](1), &dz_deta = _ad_dxyzdeta_map[p](2),
1298 &dx_dzeta = _ad_dxyzdzeta_map[p](0), &dy_dzeta = _ad_dxyzdzeta_map[p](1),
1299 &dz_dzeta = _ad_dxyzdzeta_map[p](2);
1300
1301 _ad_jac[p] = (dx_dxi * (dy_deta * dz_dzeta - dz_deta * dy_dzeta) +
1302 dy_dxi * (dz_deta * dx_dzeta - dx_deta * dz_dzeta) +
1303 dz_dxi * (dx_deta * dy_dzeta - dy_deta * dx_dzeta));
1304
1305 if (_ad_jac[p].value() <= -TOLERANCE * TOLERANCE)
1306 {
1307 static bool failing = false;
1308 if (!failing)
1309 {
1310 failing = true;
1311 elem->print_info(libMesh::err);
1312 libmesh_error_msg("ERROR: negative Jacobian " << _ad_jac[p].value() << " at point index "
1313 << p << " in element " << elem->id());
1314 }
1315 else
1316 return;
1317 }
1318
1319 _ad_JxW[p] = _ad_jac[p] * qw[p];
1320
1321 const auto inv_jac = 1. / _ad_jac[p];
1322
1323 _ad_dxidx_map[p] = (dy_deta * dz_dzeta - dz_deta * dy_dzeta) * inv_jac;
1324 _ad_dxidy_map[p] = (dz_deta * dx_dzeta - dx_deta * dz_dzeta) * inv_jac;
1325 _ad_dxidz_map[p] = (dx_deta * dy_dzeta - dy_deta * dx_dzeta) * inv_jac;
1326
1327 _ad_detadx_map[p] = (dz_dxi * dy_dzeta - dy_dxi * dz_dzeta) * inv_jac;
1328 _ad_detady_map[p] = (dx_dxi * dz_dzeta - dz_dxi * dx_dzeta) * inv_jac;
1329 _ad_detadz_map[p] = (dy_dxi * dx_dzeta - dx_dxi * dy_dzeta) * inv_jac;
1330
1331 _ad_dzetadx_map[p] = (dy_dxi * dz_deta - dz_dxi * dy_deta) * inv_jac;
1332 _ad_dzetady_map[p] = (dz_dxi * dx_deta - dx_dxi * dz_deta) * inv_jac;
1333 _ad_dzetadz_map[p] = (dx_dxi * dy_deta - dy_dxi * dx_deta) * inv_jac;
1334
1335 break;
1336 }
1337
1338 default:
1339 libmesh_error_msg("Invalid dim = " << dim);
1340 }
1341}
1342
1343void
1344Assembly::reinitFEFace(const Elem * elem, unsigned int side)
1345{
1346 unsigned int dim = elem->dim();
1347
1348 for (const auto & it : _fe_face[dim])
1349 {
1350 FEBase & fe_face = *it.second;
1351 const FEType & fe_type = it.first;
1352 FEShapeData & fesd = *_fe_shape_data_face[fe_type];
1353 fe_face.reinit(elem, side);
1354 _current_fe_face[fe_type] = &fe_face;
1355
1356 fesd._phi.shallowCopy(const_cast<std::vector<std::vector<Real>> &>(fe_face.get_phi()));
1357 fesd._grad_phi.shallowCopy(
1358 const_cast<std::vector<std::vector<VectorValue<Real>>> &>(fe_face.get_dphi()));
1359 if (_need_second_derivative.count(fe_type))
1360 fesd._second_phi.shallowCopy(
1361 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe_face.get_d2phi()));
1362 }
1363 for (const auto & it : _vector_fe_face[dim])
1364 {
1365 FEVectorBase & fe_face = *it.second;
1366 const FEType & fe_type = it.first;
1367
1368 _current_vector_fe_face[fe_type] = &fe_face;
1369
1371
1372 fe_face.reinit(elem, side);
1373
1374 fesd._phi.shallowCopy(
1375 const_cast<std::vector<std::vector<VectorValue<Real>>> &>(fe_face.get_phi()));
1376 fesd._grad_phi.shallowCopy(
1377 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe_face.get_dphi()));
1378 if (_need_second_derivative.count(fe_type))
1379 fesd._second_phi.shallowCopy(
1380 const_cast<std::vector<std::vector<TypeNTensor<3, Real>>> &>(fe_face.get_d2phi()));
1381 if (_need_curl.count(fe_type))
1382 fesd._curl_phi.shallowCopy(
1383 const_cast<std::vector<std::vector<VectorValue<Real>>> &>(fe_face.get_curl_phi()));
1384 if (_need_face_div.count(fe_type))
1385 fesd._div_phi.shallowCopy(
1386 const_cast<std::vector<std::vector<Real>> &>(fe_face.get_div_phi()));
1387 }
1388 if (!_unique_fe_face_helper.empty())
1389 {
1390 mooseAssert(dim < _unique_fe_face_helper.size(), "We should be in bounds here");
1392 }
1393
1394 // During that last loop the helper objects will have been reinitialized as well
1395 // We need to dig out the q_points and JxW from it.
1397 const_cast<std::vector<Point> &>(_holder_fe_face_helper[dim]->get_xyz()));
1399 const_cast<std::vector<Real> &>(_holder_fe_face_helper[dim]->get_JxW()));
1401 const_cast<std::vector<Point> &>(_holder_fe_face_helper[dim]->get_normals()));
1402
1403 _mapped_normals.resize(_current_normals.size(), Eigen::Map<RealDIMValue>(nullptr));
1404 for (unsigned int i = 0; i < _current_normals.size(); i++)
1405 // Note: this does NOT do any allocation. It is "reconstructing" the object in place
1406 new (&_mapped_normals[i]) Eigen::Map<RealDIMValue>(const_cast<Real *>(&_current_normals[i](0)));
1407
1410 const_cast<std::vector<Real> &>(_holder_fe_face_helper[dim]->get_curvatures()));
1411
1413
1414 if (_xfem != nullptr)
1416
1417 auto n = numExtraElemIntegers();
1418 for (auto i : make_range(n))
1419 _extra_elem_ids[i] = _current_elem->get_extra_integer(i);
1420 _extra_elem_ids[n] = _current_elem->subdomain_id();
1421}
1422
1423void
1424Assembly::computeFaceMap(const Elem & elem, const unsigned int side, const std::vector<Real> & qw)
1425{
1426 // Important quantities calculated by this method:
1427 // - _ad_JxW_face
1428 // - _ad_q_points_face
1429 // - _ad_normals
1430 // - _ad_curvatures
1431
1432 const Elem & side_elem = _compute_face_map_side_elem_builder(elem, side);
1433 const auto dim = elem.dim();
1434 const auto n_qp = qw.size();
1435 const auto & dpsidxi_map = _holder_fe_face_helper[dim]->get_fe_map().get_dpsidxi();
1436 const auto & dpsideta_map = _holder_fe_face_helper[dim]->get_fe_map().get_dpsideta();
1437 const auto & psi_map = _holder_fe_face_helper[dim]->get_fe_map().get_psi();
1438 std::vector<std::vector<Real>> const * d2psidxi2_map = nullptr;
1439 std::vector<std::vector<Real>> const * d2psidxideta_map = nullptr;
1440 std::vector<std::vector<Real>> const * d2psideta2_map = nullptr;
1441 mooseAssert(_ad_elem_node_points.size() == elem.n_nodes(),
1442 "computeADElemNodePoints must be called for this element first");
1443
1445 {
1446 d2psidxi2_map = &_holder_fe_face_helper[dim]->get_fe_map().get_d2psidxi2();
1447 d2psidxideta_map = &_holder_fe_face_helper[dim]->get_fe_map().get_d2psidxideta();
1448 d2psideta2_map = &_holder_fe_face_helper[dim]->get_fe_map().get_d2psideta2();
1449 }
1450
1451 switch (dim)
1452 {
1453 case 1:
1454 {
1455 if (!n_qp)
1456 break;
1457
1458 if (side_elem.node_id(0) == elem.node_id(0))
1459 _ad_normals[0] = Point(-1.);
1460 else
1461 _ad_normals[0] = Point(1.);
1462
1463 VectorValue<ADReal> side_point;
1465 side_point = _ad_elem_node_points[elem.local_side_node(side, 0)];
1466
1467 for (const auto p : make_range(n_qp))
1468 {
1470 {
1471 _ad_q_points_face[p].zero();
1472 _ad_q_points_face[p].add_scaled(side_point, psi_map[0][p]);
1473 }
1474
1475 _ad_normals[p] = _ad_normals[0];
1476 _ad_JxW_face[p] = 1.0 * qw[p];
1477 }
1478
1479 break;
1480 }
1481
1482 case 2:
1483 {
1484 _ad_dxyzdxi_map.resize(n_qp);
1486 _ad_d2xyzdxi2_map.resize(n_qp);
1487
1488 for (const auto p : make_range(n_qp))
1489 _ad_dxyzdxi_map[p].zero();
1491 for (const auto p : make_range(n_qp))
1492 _ad_q_points_face[p].zero();
1494 for (const auto p : make_range(n_qp))
1495 _ad_d2xyzdxi2_map[p].zero();
1496
1497 const auto n_mapping_shape_functions =
1498 libMesh::FE<2, LAGRANGE>::n_dofs(&side_elem, side_elem.default_order());
1499
1500 for (unsigned int i = 0; i < n_mapping_shape_functions; i++)
1501 {
1502 const auto & side_point = _ad_elem_node_points[elem.local_side_node(side, i)];
1503
1504 for (const auto p : make_range(n_qp))
1505 _ad_dxyzdxi_map[p].add_scaled(side_point, dpsidxi_map[i][p]);
1507 for (const auto p : make_range(n_qp))
1508 _ad_q_points_face[p].add_scaled(side_point, psi_map[i][p]);
1510 for (const auto p : make_range(n_qp))
1511 _ad_d2xyzdxi2_map[p].add_scaled(side_point, (*d2psidxi2_map)[i][p]);
1512 }
1513
1514 for (const auto p : make_range(n_qp))
1515 {
1516 _ad_normals[p] =
1517 (VectorValue<ADReal>(_ad_dxyzdxi_map[p](1), -_ad_dxyzdxi_map[p](0), 0.)).unit();
1518 const auto the_jac = _ad_dxyzdxi_map[p].norm();
1519 _ad_JxW_face[p] = the_jac * qw[p];
1521 {
1522 const auto numerator = _ad_d2xyzdxi2_map[p] * _ad_normals[p];
1523 const auto denominator = _ad_dxyzdxi_map[p].norm_sq();
1524 libmesh_assert_not_equal_to(denominator, 0);
1525 _ad_curvatures[p] = numerator / denominator;
1526 }
1527 }
1528
1529 break;
1530 }
1531
1532 case 3:
1533 {
1534 _ad_dxyzdxi_map.resize(n_qp);
1535 _ad_dxyzdeta_map.resize(n_qp);
1537 {
1538 _ad_d2xyzdxi2_map.resize(n_qp);
1539 _ad_d2xyzdxideta_map.resize(n_qp);
1540 _ad_d2xyzdeta2_map.resize(n_qp);
1541 }
1542
1543 for (const auto p : make_range(n_qp))
1544 {
1545 _ad_dxyzdxi_map[p].zero();
1546 _ad_dxyzdeta_map[p].zero();
1547 }
1549 for (const auto p : make_range(n_qp))
1550 _ad_q_points_face[p].zero();
1552 for (const auto p : make_range(n_qp))
1553 {
1554 _ad_d2xyzdxi2_map[p].zero();
1555 _ad_d2xyzdxideta_map[p].zero();
1556 _ad_d2xyzdeta2_map[p].zero();
1557 }
1558
1559 const unsigned int n_mapping_shape_functions =
1560 libMesh::FE<3, LAGRANGE>::n_dofs(&side_elem, side_elem.default_order());
1561
1562 for (unsigned int i = 0; i < n_mapping_shape_functions; i++)
1563 {
1564 const auto & side_point = _ad_elem_node_points[elem.local_side_node(side, i)];
1565
1566 for (const auto p : make_range(n_qp))
1567 {
1568 _ad_dxyzdxi_map[p].add_scaled(side_point, dpsidxi_map[i][p]);
1569 _ad_dxyzdeta_map[p].add_scaled(side_point, dpsideta_map[i][p]);
1570 }
1572 for (const auto p : make_range(n_qp))
1573 _ad_q_points_face[p].add_scaled(side_point, psi_map[i][p]);
1575 for (const auto p : make_range(n_qp))
1576 {
1577 _ad_d2xyzdxi2_map[p].add_scaled(side_point, (*d2psidxi2_map)[i][p]);
1578 _ad_d2xyzdxideta_map[p].add_scaled(side_point, (*d2psidxideta_map)[i][p]);
1579 _ad_d2xyzdeta2_map[p].add_scaled(side_point, (*d2psideta2_map)[i][p]);
1580 }
1581 }
1582
1583 for (const auto p : make_range(n_qp))
1584 {
1585 _ad_normals[p] = _ad_dxyzdxi_map[p].cross(_ad_dxyzdeta_map[p]).unit();
1586
1587 const auto &dxdxi = _ad_dxyzdxi_map[p](0), &dxdeta = _ad_dxyzdeta_map[p](0),
1588 &dydxi = _ad_dxyzdxi_map[p](1), &dydeta = _ad_dxyzdeta_map[p](1),
1589 &dzdxi = _ad_dxyzdxi_map[p](2), &dzdeta = _ad_dxyzdeta_map[p](2);
1590
1591 const auto g11 = (dxdxi * dxdxi + dydxi * dydxi + dzdxi * dzdxi);
1592
1593 const auto g12 = (dxdxi * dxdeta + dydxi * dydeta + dzdxi * dzdeta);
1594
1595 const auto & g21 = g12;
1596
1597 const auto g22 = (dxdeta * dxdeta + dydeta * dydeta + dzdeta * dzdeta);
1598
1599 using std::sqrt;
1600 const auto the_jac = sqrt(g11 * g22 - g12 * g21);
1601
1602 _ad_JxW_face[p] = the_jac * qw[p];
1603
1605 {
1606 const auto L = -_ad_d2xyzdxi2_map[p] * _ad_normals[p];
1607 const auto M = -_ad_d2xyzdxideta_map[p] * _ad_normals[p];
1608 const auto N = -_ad_d2xyzdeta2_map[p] * _ad_normals[p];
1609 const auto E = _ad_dxyzdxi_map[p].norm_sq();
1610 const auto F = _ad_dxyzdxi_map[p] * _ad_dxyzdeta_map[p];
1611 const auto G = _ad_dxyzdeta_map[p].norm_sq();
1612
1613 const auto numerator = E * N - 2. * F * M + G * L;
1614 const auto denominator = E * G - F * F;
1615 libmesh_assert_not_equal_to(denominator, 0.);
1616 _ad_curvatures[p] = 0.5 * numerator / denominator;
1617 }
1618 }
1619
1620 break;
1621 }
1622
1623 default:
1624 mooseError("Invalid dimension dim = ", dim);
1625 }
1626}
1627
1628void
1629Assembly::reinitFEFaceNeighbor(const Elem * neighbor, const std::vector<Point> & reference_points)
1630{
1631 unsigned int neighbor_dim = neighbor->dim();
1632
1633 // reinit neighbor face
1634 for (const auto & it : _fe_face_neighbor[neighbor_dim])
1635 {
1636 FEBase & fe_face_neighbor = *it.second;
1637 FEType fe_type = it.first;
1638 FEShapeData & fesd = *_fe_shape_data_face_neighbor[fe_type];
1639
1640 fe_face_neighbor.reinit(neighbor, &reference_points);
1641
1642 _current_fe_face_neighbor[fe_type] = &fe_face_neighbor;
1643
1644 fesd._phi.shallowCopy(const_cast<std::vector<std::vector<Real>> &>(fe_face_neighbor.get_phi()));
1645 fesd._grad_phi.shallowCopy(
1646 const_cast<std::vector<std::vector<RealGradient>> &>(fe_face_neighbor.get_dphi()));
1647 if (_need_second_derivative_neighbor.count(fe_type))
1648 fesd._second_phi.shallowCopy(
1649 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe_face_neighbor.get_d2phi()));
1650 }
1651 for (const auto & it : _vector_fe_face_neighbor[neighbor_dim])
1652 {
1653 FEVectorBase & fe_face_neighbor = *it.second;
1654 const FEType & fe_type = it.first;
1655
1656 _current_vector_fe_face_neighbor[fe_type] = &fe_face_neighbor;
1657
1659
1660 fe_face_neighbor.reinit(neighbor, &reference_points);
1661
1662 fesd._phi.shallowCopy(
1663 const_cast<std::vector<std::vector<VectorValue<Real>>> &>(fe_face_neighbor.get_phi()));
1664 fesd._grad_phi.shallowCopy(
1665 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe_face_neighbor.get_dphi()));
1666 if (_need_second_derivative.count(fe_type))
1667 fesd._second_phi.shallowCopy(const_cast<std::vector<std::vector<TypeNTensor<3, Real>>> &>(
1668 fe_face_neighbor.get_d2phi()));
1669 if (_need_curl.count(fe_type))
1670 fesd._curl_phi.shallowCopy(const_cast<std::vector<std::vector<VectorValue<Real>>> &>(
1671 fe_face_neighbor.get_curl_phi()));
1672 if (_need_face_neighbor_div.count(fe_type))
1673 fesd._div_phi.shallowCopy(
1674 const_cast<std::vector<std::vector<Real>> &>(fe_face_neighbor.get_div_phi()));
1675 }
1677 {
1678 mooseAssert(neighbor_dim < _unique_fe_face_neighbor_helper.size(),
1679 "We should be in bounds here");
1680 _unique_fe_face_neighbor_helper[neighbor_dim]->reinit(neighbor, &reference_points);
1681 }
1682
1684 const_cast<std::vector<Point> &>(_holder_fe_face_neighbor_helper[neighbor_dim]->get_xyz()));
1685}
1686
1687void
1688Assembly::reinitFENeighbor(const Elem * neighbor, const std::vector<Point> & reference_points)
1689{
1690 unsigned int neighbor_dim = neighbor->dim();
1691
1692 // reinit neighbor face
1693 for (const auto & it : _fe_neighbor[neighbor_dim])
1694 {
1695 FEBase & fe_neighbor = *it.second;
1696 FEType fe_type = it.first;
1697 FEShapeData & fesd = *_fe_shape_data_neighbor[fe_type];
1698
1699 fe_neighbor.reinit(neighbor, &reference_points);
1700
1701 _current_fe_neighbor[fe_type] = &fe_neighbor;
1702
1703 fesd._phi.shallowCopy(const_cast<std::vector<std::vector<Real>> &>(fe_neighbor.get_phi()));
1704 fesd._grad_phi.shallowCopy(
1705 const_cast<std::vector<std::vector<RealGradient>> &>(fe_neighbor.get_dphi()));
1706 if (_need_second_derivative_neighbor.count(fe_type))
1707 fesd._second_phi.shallowCopy(
1708 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe_neighbor.get_d2phi()));
1709 }
1710 for (const auto & it : _vector_fe_neighbor[neighbor_dim])
1711 {
1712 FEVectorBase & fe_neighbor = *it.second;
1713 const FEType & fe_type = it.first;
1714
1715 _current_vector_fe_neighbor[fe_type] = &fe_neighbor;
1716
1718
1719 fe_neighbor.reinit(neighbor, &reference_points);
1720
1721 fesd._phi.shallowCopy(
1722 const_cast<std::vector<std::vector<VectorValue<Real>>> &>(fe_neighbor.get_phi()));
1723 fesd._grad_phi.shallowCopy(
1724 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe_neighbor.get_dphi()));
1725 if (_need_second_derivative.count(fe_type))
1726 fesd._second_phi.shallowCopy(
1727 const_cast<std::vector<std::vector<TypeNTensor<3, Real>>> &>(fe_neighbor.get_d2phi()));
1728 if (_need_curl.count(fe_type))
1729 fesd._curl_phi.shallowCopy(
1730 const_cast<std::vector<std::vector<VectorValue<Real>>> &>(fe_neighbor.get_curl_phi()));
1731 if (_need_neighbor_div.count(fe_type))
1732 fesd._div_phi.shallowCopy(
1733 const_cast<std::vector<std::vector<Real>> &>(fe_neighbor.get_div_phi()));
1734 }
1735 if (!_unique_fe_neighbor_helper.empty())
1736 {
1737 mooseAssert(neighbor_dim < _unique_fe_neighbor_helper.size(), "We should be in bounds here");
1738 _unique_fe_neighbor_helper[neighbor_dim]->reinit(neighbor, &reference_points);
1739 }
1740}
1741
1742void
1743Assembly::reinitNeighbor(const Elem * neighbor, const std::vector<Point> & reference_points)
1744{
1745 unsigned int neighbor_dim = neighbor->dim();
1746 mooseAssert(_current_neighbor_subdomain_id == neighbor->subdomain_id(),
1747 "Neighbor subdomain ID has not been correctly set");
1748
1749 ArbitraryQuadrature * neighbor_rule =
1750 qrules(neighbor_dim, _current_neighbor_subdomain_id).neighbor.get();
1751 neighbor_rule->setPoints(reference_points);
1752 setNeighborQRule(neighbor_rule, neighbor_dim);
1753
1755 mooseAssert(_current_neighbor_subdomain_id == _current_neighbor_elem->subdomain_id(),
1756 "current neighbor subdomain has been set incorrectly");
1757
1758 // Calculate the volume of the neighbor
1760 {
1761 unsigned int dim = neighbor->dim();
1762 FEBase & fe = *_holder_fe_neighbor_helper[dim];
1763 QBase * qrule = qrules(dim).vol.get();
1764
1765 fe.attach_quadrature_rule(qrule);
1766 fe.reinit(neighbor);
1767
1768 const std::vector<Real> & JxW = fe.get_JxW();
1769 MooseArray<Point> q_points;
1770 q_points.shallowCopy(const_cast<std::vector<Point> &>(fe.get_xyz()));
1771
1773
1775 for (unsigned int qp = 0; qp < qrule->n_points(); qp++)
1777 }
1778
1779 auto n = numExtraElemIntegers();
1780 for (auto i : make_range(n))
1781 _neighbor_extra_elem_ids[i] = _current_neighbor_elem->get_extra_integer(i);
1783}
1784
1785template <typename Points, typename Coords>
1786void
1788 const Points & q_points,
1789 Coords & coord,
1790 SubdomainID sub_id)
1791{
1792
1793 mooseAssert(qrule, "The quadrature rule is null in Assembly::setCoordinateTransformation");
1794 auto n_points = qrule->n_points();
1795 mooseAssert(n_points == q_points.size(),
1796 "The number of points in the quadrature rule doesn't match the number of passed-in "
1797 "points in Assembly::setCoordinateTransformation");
1798
1799 // Make sure to honor the name of this method and set the _coord_type member because users may
1800 // make use of the const Moose::CoordinateSystem & coordTransformation() { return _coord_type; }
1801 // API. MaterialBase for example uses it
1803
1804 coord.resize(n_points);
1805 for (unsigned int qp = 0; qp < n_points; qp++)
1806 coordTransformFactor(_subproblem, sub_id, q_points[qp], coord[qp]);
1807}
1808
1809void
1811{
1813 return;
1814
1820
1822 for (unsigned int qp = 0; qp < _current_qrule->n_points(); qp++)
1824
1826}
1827
1828void
1846
1847void
1848Assembly::reinitAtPhysical(const Elem * elem, const std::vector<Point> & physical_points)
1849{
1851 _current_neighbor_elem = nullptr;
1852 mooseAssert(_current_subdomain_id == _current_elem->subdomain_id(),
1853 "current subdomain has been set incorrectly");
1855
1856 FEMap::inverse_map(elem->dim(), elem, physical_points, _temp_reference_points);
1857
1859
1860 // Save off the physical points
1861 _current_physical_points = physical_points;
1862}
1863
1864void
1865Assembly::setVolumeQRule(const Elem * const elem)
1866{
1867 unsigned int elem_dimension = elem->dim();
1868 _current_qrule_volume = qrules(elem_dimension).vol.get();
1869 // Make sure the qrule is the right one
1871 setVolumeQRule(_current_qrule_volume, elem_dimension);
1872}
1873
1874void
1875Assembly::reinit(const Elem * elem)
1876{
1878 _current_neighbor_elem = nullptr;
1879 mooseAssert(_current_subdomain_id == _current_elem->subdomain_id(),
1880 "current subdomain has been set incorrectly");
1883 reinitFE(elem);
1884
1886}
1887
1888void
1889Assembly::reinit(const Elem * elem, const std::vector<Point> & reference_points)
1890{
1892 _current_neighbor_elem = nullptr;
1893 mooseAssert(_current_subdomain_id == _current_elem->subdomain_id(),
1894 "current subdomain has been set incorrectly");
1896
1897 unsigned int elem_dimension = _current_elem->dim();
1898
1899 _current_qrule_arbitrary = qrules(elem_dimension).arbitrary_vol.get();
1900
1901 // Make sure the qrule is the right one
1904
1905 _current_qrule_arbitrary->setPoints(reference_points);
1906
1907 reinitFE(elem);
1908
1910}
1911
1912void
1914{
1915 _current_elem = &fi.elem();
1919 mooseAssert(_current_subdomain_id == _current_elem->subdomain_id(),
1920 "current subdomain has been set incorrectly");
1921
1924
1928
1929 unsigned int dim = _current_elem->dim();
1930 if (_current_qrule_face != qrules(dim).fv_face.get())
1931 {
1932 setFaceQRule(qrules(dim).fv_face.get(), dim);
1933 // The order of the element that is used for initing here doesn't matter since this will just
1934 // be used for constant monomials (which only need a single integration point)
1935 if (dim == 3)
1936 _current_qrule_face->init(QUAD4, /* p_level = */ 0, /* simple_type_only = */ true);
1937 else
1938 _current_qrule_face->init(EDGE2, /* p_level = */ 0, /* simple_type_only = */ true);
1939 }
1940
1942
1943 mooseAssert(_current_qrule_face->n_points() == 1,
1944 "Our finite volume quadrature rule should always yield a single point");
1945
1946 // We've initialized the reference points. Now we need to compute the physical location of the
1947 // quadrature points. We do not do any FE initialization so we cannot simply copy over FE
1948 // results like we do in reinitFEFace. Instead we handle the computation of the physical
1949 // locations manually
1951 const auto & ref_points = _current_qrule_face->get_points();
1952 const auto & ref_point = ref_points[0];
1953 auto physical_point = FEMap::map(_current_side_elem->dim(), _current_side_elem, ref_point);
1954 _current_q_points_face[0] = physical_point;
1955
1957 {
1958 mooseAssert(_current_neighbor_subdomain_id == _current_neighbor_elem->subdomain_id(),
1959 "current neighbor subdomain has been set incorrectly");
1960 // Now handle the neighbor qrule/qpoints
1961 ArbitraryQuadrature * const neighbor_rule =
1963 // Here we are setting a reference point that is correct for the neighbor *side* element. It
1964 // would be wrong if this reference point is used for a volumetric FE reinit with the neighbor
1965 neighbor_rule->setPoints(ref_points);
1966 setNeighborQRule(neighbor_rule, _current_neighbor_elem->dim());
1968 _current_q_points_face_neighbor[0] = std::move(physical_point);
1969 }
1970}
1971
1972QBase *
1973Assembly::qruleFace(const Elem * elem, unsigned int side)
1974{
1975 return qruleFaceHelper<QBase>(elem, side, [](QRules & q) { return q.face.get(); });
1976}
1977
1979Assembly::qruleArbitraryFace(const Elem * elem, unsigned int side)
1980{
1981 return qruleFaceHelper<ArbitraryQuadrature>(
1982 elem, side, [](QRules & q) { return q.arbitrary_face.get(); });
1983}
1984
1985void
1986Assembly::setFaceQRule(const Elem * const elem, const unsigned int side)
1987{
1988 const auto elem_dimension = elem->dim();
1990 auto rule = qruleFace(elem, side);
1991 if (_current_qrule_face != rule)
1992 setFaceQRule(rule, elem_dimension);
1993}
1994
1995void
1996Assembly::reinit(const Elem * const elem, const unsigned int side)
1997{
1999 _current_neighbor_elem = nullptr;
2000 mooseAssert(_current_subdomain_id == _current_elem->subdomain_id(),
2001 "current subdomain has been set incorrectly");
2005
2007
2010
2012}
2013
2014void
2015Assembly::reinit(const Elem * elem, unsigned int side, const std::vector<Point> & reference_points)
2016{
2018 _current_neighbor_elem = nullptr;
2019 mooseAssert(_current_subdomain_id == _current_elem->subdomain_id(),
2020 "current subdomain has been set incorrectly");
2024
2025 unsigned int elem_dimension = _current_elem->dim();
2026
2028
2029 // Make sure the qrule is the right one
2032
2033 _current_qrule_arbitrary->setPoints(reference_points);
2034
2036
2038
2040}
2041
2042void
2043Assembly::reinit(const Node * node)
2044{
2047}
2048
2049void
2051 unsigned int side,
2052 const Elem * neighbor,
2053 unsigned int neighbor_side,
2054 const std::vector<Point> * neighbor_reference_points)
2055{
2056 _current_neighbor_side = neighbor_side;
2057
2058 reinit(elem, side);
2059
2060 unsigned int neighbor_dim = neighbor->dim();
2061
2062 if (neighbor_reference_points)
2063 _current_neighbor_ref_points = *neighbor_reference_points;
2064 else
2065 FEMap::inverse_map(
2067
2069
2072}
2073
2074void
2076 unsigned int elem_side,
2077 Real tolerance,
2078 const std::vector<Point> * const pts,
2079 const std::vector<Real> * const weights)
2080{
2082
2083 unsigned int elem_dim = elem->dim();
2084
2085 // Attach the quadrature rules
2086 if (pts)
2087 {
2088 auto face_rule = qruleArbitraryFace(elem, elem_side);
2089 face_rule->setPoints(*pts);
2090 setFaceQRule(face_rule, elem_dim);
2091 }
2092 else
2093 {
2094 auto rule = qruleFace(elem, elem_side);
2095 if (_current_qrule_face != rule)
2096 setFaceQRule(rule, elem_dim);
2097 }
2098
2099 // reinit face
2100 for (const auto & it : _fe_face[elem_dim])
2101 {
2102 FEBase & fe_face = *it.second;
2103 FEType fe_type = it.first;
2104 FEShapeData & fesd = *_fe_shape_data_face[fe_type];
2105
2106 fe_face.reinit(elem, elem_side, tolerance, pts, weights);
2107
2108 _current_fe_face[fe_type] = &fe_face;
2109
2110 fesd._phi.shallowCopy(const_cast<std::vector<std::vector<Real>> &>(fe_face.get_phi()));
2111 fesd._grad_phi.shallowCopy(
2112 const_cast<std::vector<std::vector<RealGradient>> &>(fe_face.get_dphi()));
2113 if (_need_second_derivative_neighbor.count(fe_type))
2114 fesd._second_phi.shallowCopy(
2115 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe_face.get_d2phi()));
2116 }
2117 for (const auto & it : _vector_fe_face[elem_dim])
2118 {
2119 FEVectorBase & fe_face = *it.second;
2120 const FEType & fe_type = it.first;
2121
2122 _current_vector_fe_face[fe_type] = &fe_face;
2123
2125
2126 fe_face.reinit(elem, elem_side, tolerance, pts, weights);
2127
2128 fesd._phi.shallowCopy(
2129 const_cast<std::vector<std::vector<VectorValue<Real>>> &>(fe_face.get_phi()));
2130 fesd._grad_phi.shallowCopy(
2131 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe_face.get_dphi()));
2132 if (_need_second_derivative.count(fe_type))
2133 fesd._second_phi.shallowCopy(
2134 const_cast<std::vector<std::vector<TypeNTensor<3, Real>>> &>(fe_face.get_d2phi()));
2135 if (_need_curl.count(fe_type))
2136 fesd._curl_phi.shallowCopy(
2137 const_cast<std::vector<std::vector<VectorValue<Real>>> &>(fe_face.get_curl_phi()));
2138 if (_need_face_div.count(fe_type))
2139 fesd._div_phi.shallowCopy(
2140 const_cast<std::vector<std::vector<Real>> &>(fe_face.get_div_phi()));
2141 }
2142 if (!_unique_fe_face_helper.empty())
2143 {
2144 mooseAssert(elem_dim < _unique_fe_face_helper.size(), "We should be in bounds here");
2145 _unique_fe_face_helper[elem_dim]->reinit(elem, elem_side, tolerance, pts, weights);
2146 }
2147
2148 // During that last loop the helper objects will have been reinitialized
2150 const_cast<std::vector<Point> &>(_holder_fe_face_helper[elem_dim]->get_xyz()));
2152 const_cast<std::vector<Point> &>(_holder_fe_face_helper[elem_dim]->get_normals()));
2153 _current_tangents.shallowCopy(const_cast<std::vector<std::vector<Point>> &>(
2154 _holder_fe_face_helper[elem_dim]->get_tangents()));
2155 // Note that if the user did pass in points and not weights to this method, JxW will be garbage
2156 // and should not be used
2158 const_cast<std::vector<Real> &>(_holder_fe_face_helper[elem_dim]->get_JxW()));
2161 const_cast<std::vector<Real> &>(_holder_fe_face_helper[elem_dim]->get_curvatures()));
2162
2163 computeADFace(*elem, elem_side);
2164
2165 // Keep the current-side bookkeeping consistent with the other elem/side reinit overloads so
2166 // that consumers of _current_side, _current_side_elem, and _current_side_volume (e.g.
2167 // InterfaceKernelBase) see correct values rather than whatever was left over from a previous
2168 // reinit.
2169 _current_side = elem_side;
2173}
2174
2175void
2176Assembly::computeADFace(const Elem & elem, const unsigned int side)
2177{
2178 const auto dim = elem.dim();
2179
2181 {
2182 auto n_qp = _current_qrule_face->n_points();
2184 _ad_normals.resize(n_qp);
2185 _ad_JxW_face.resize(n_qp);
2189 _ad_curvatures.resize(n_qp);
2190
2191 if (_displaced)
2192 {
2193 const auto & qw = _current_qrule_face->get_weights();
2196 elem, ADReal::do_derivatives && _sys.number() == _subproblem.currentNlSysNum());
2197 // computeFaceMap supplies the AD face JxW, normals and points; the single-point map only adds
2198 // the inverse map that computeGradPhiAD needs
2200 computeFaceMap(elem, side, qw);
2202 {
2203 // Faces can have different numbers of quadrature points, so grow the weights as needed
2204 static thread_local std::vector<Real> dummy_qw;
2205 dummy_qw.resize(n_qp, 1.);
2206
2207 for (unsigned int qp = 0; qp != n_qp; qp++)
2209 }
2210 }
2211 else
2212 {
2213 for (unsigned qp = 0; qp < n_qp; ++qp)
2214 {
2216 _ad_normals[qp] = _current_normals[qp];
2217 }
2219 for (unsigned qp = 0; qp < n_qp; ++qp)
2222 for (unsigned qp = 0; qp < n_qp; ++qp)
2223 _ad_curvatures[qp] = _curvatures[qp];
2224 }
2225
2227 {
2228 for (const auto & it : _fe_face[dim])
2229 {
2230 FEBase & fe = *it.second;
2231 auto fe_type = it.first;
2232 auto num_shapes = FEInterface::n_shape_functions(fe_type, &elem);
2233 auto & grad_phi = _ad_grad_phi_data_face[fe_type];
2234
2235 grad_phi.resize(num_shapes);
2236 for (decltype(num_shapes) i = 0; i < num_shapes; ++i)
2237 grad_phi[i].resize(n_qp);
2238
2239 const auto & regular_grad_phi = _fe_shape_data_face[fe_type]->_grad_phi;
2240
2241 if (_displaced)
2242 computeGradPhiAD(&elem, n_qp, grad_phi, &fe);
2243 else
2244 for (decltype(num_shapes) i = 0; i < num_shapes; ++i)
2245 for (unsigned qp = 0; qp < n_qp; ++qp)
2246 grad_phi[i][qp] = regular_grad_phi[i][qp];
2247 }
2248 for (const auto & it : _vector_fe_face[dim])
2249 {
2250 FEVectorBase & fe = *it.second;
2251 auto fe_type = it.first;
2252 auto num_shapes = FEInterface::n_shape_functions(fe_type, &elem);
2253 auto & grad_phi = _ad_vector_grad_phi_data_face[fe_type];
2254
2255 grad_phi.resize(num_shapes);
2256 for (decltype(num_shapes) i = 0; i < num_shapes; ++i)
2257 grad_phi[i].resize(n_qp);
2258
2259 const auto & regular_grad_phi = _vector_fe_shape_data_face[fe_type]->_grad_phi;
2260
2261 if (_displaced)
2262 computeGradPhiAD(&elem, n_qp, grad_phi, &fe);
2263 else
2264 for (decltype(num_shapes) i = 0; i < num_shapes; ++i)
2265 for (unsigned qp = 0; qp < n_qp; ++qp)
2266 grad_phi[i][qp] = regular_grad_phi[i][qp];
2267 }
2268 }
2269 }
2270}
2271
2272void
2274 unsigned int neighbor_side,
2275 Real tolerance,
2276 const std::vector<Point> * const pts,
2277 const std::vector<Real> * const weights)
2278{
2280
2281 unsigned int neighbor_dim = neighbor->dim();
2282
2283 ArbitraryQuadrature * neighbor_rule =
2284 qrules(neighbor_dim, neighbor->subdomain_id()).neighbor.get();
2285 neighbor_rule->setPoints(*pts);
2286
2287 // Attach this quadrature rule to all the _fe_face_neighbor FE objects. This
2288 // has to have garbage quadrature weights but that's ok because we never
2289 // actually use the JxW coming from these FE reinit'd objects, e.g. we use the
2290 // JxW coming from the element face reinit for DGKernels or we use the JxW
2291 // coming from reinit of the mortar segment element in the case of mortar
2292 setNeighborQRule(neighbor_rule, neighbor_dim);
2293
2294 // reinit neighbor face
2295 for (const auto & it : _fe_face_neighbor[neighbor_dim])
2296 {
2297 FEBase & fe_face_neighbor = *it.second;
2298 FEType fe_type = it.first;
2299 FEShapeData & fesd = *_fe_shape_data_face_neighbor[fe_type];
2300
2301 fe_face_neighbor.reinit(neighbor, neighbor_side, tolerance, pts, weights);
2302
2303 _current_fe_face_neighbor[fe_type] = &fe_face_neighbor;
2304
2305 fesd._phi.shallowCopy(const_cast<std::vector<std::vector<Real>> &>(fe_face_neighbor.get_phi()));
2306 fesd._grad_phi.shallowCopy(
2307 const_cast<std::vector<std::vector<RealGradient>> &>(fe_face_neighbor.get_dphi()));
2308 if (_need_second_derivative_neighbor.count(fe_type))
2309 fesd._second_phi.shallowCopy(
2310 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe_face_neighbor.get_d2phi()));
2311 }
2312 for (const auto & it : _vector_fe_face_neighbor[neighbor_dim])
2313 {
2314 FEVectorBase & fe_face_neighbor = *it.second;
2315 const FEType & fe_type = it.first;
2316
2317 _current_vector_fe_face_neighbor[fe_type] = &fe_face_neighbor;
2318
2320
2321 fe_face_neighbor.reinit(neighbor, neighbor_side, tolerance, pts, weights);
2322
2323 fesd._phi.shallowCopy(
2324 const_cast<std::vector<std::vector<VectorValue<Real>>> &>(fe_face_neighbor.get_phi()));
2325 fesd._grad_phi.shallowCopy(
2326 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe_face_neighbor.get_dphi()));
2327 if (_need_second_derivative.count(fe_type))
2328 fesd._second_phi.shallowCopy(const_cast<std::vector<std::vector<TypeNTensor<3, Real>>> &>(
2329 fe_face_neighbor.get_d2phi()));
2330 if (_need_curl.count(fe_type))
2331 fesd._curl_phi.shallowCopy(const_cast<std::vector<std::vector<VectorValue<Real>>> &>(
2332 fe_face_neighbor.get_curl_phi()));
2333 if (_need_face_neighbor_div.count(fe_type))
2334 fesd._div_phi.shallowCopy(
2335 const_cast<std::vector<std::vector<Real>> &>(fe_face_neighbor.get_div_phi()));
2336 }
2338 {
2339 mooseAssert(neighbor_dim < _unique_fe_face_neighbor_helper.size(),
2340 "We should be in bounds here");
2341 _unique_fe_face_neighbor_helper[neighbor_dim]->reinit(
2342 neighbor, neighbor_side, tolerance, pts, weights);
2343 }
2344 // During that last loop the helper objects will have been reinitialized as well
2345 // We need to dig out the q_points from it
2347 const_cast<std::vector<Point> &>(_holder_fe_face_neighbor_helper[neighbor_dim]->get_xyz()));
2348}
2349
2350void
2351Assembly::reinitNeighborSurfaceElemRef(const Elem * neighbor, const std::vector<Point> & pts)
2352{
2354
2355 const unsigned int neighbor_dim = neighbor->dim();
2356
2357 // As in reinitNeighborFaceRef, the quadrature weights are never used
2358 ArbitraryQuadrature * neighbor_rule =
2359 qrules(neighbor_dim, neighbor->subdomain_id()).neighbor.get();
2360 neighbor_rule->setPoints(pts);
2361 setNeighborQRule(neighbor_rule, neighbor_dim);
2362
2363 // The neighbor is the face, so the face neighbor FE objects are reinitialized on the element
2365}
2366
2367void
2368Assembly::reinitDual(const Elem * elem,
2369 const std::vector<Point> & pts,
2370 const std::vector<Real> & JxW)
2371{
2372 const unsigned int elem_dim = elem->dim();
2373 mooseAssert(elem_dim == _mesh_dimension - 1,
2374 "Dual shape functions should only be computed on lower dimensional face elements");
2375
2376 for (const auto & [fe_type, fe_lower] : _fe_lower[elem_dim])
2377 {
2378 const auto dual_shape_data = _fe_shape_data_dual_lower.find(fe_type);
2379 if (dual_shape_data == _fe_shape_data_dual_lower.end() || !dual_shape_data->second)
2380 continue;
2381
2382 // We use customized quadrature rule for integration along the mortar segment elements
2383 fe_lower->set_calculate_default_dual_coeff(false);
2384 fe_lower->reinit_dual_shape_coeffs(elem, pts, JxW);
2385 }
2386}
2387
2388void
2390 const std::vector<Point> * const pts,
2391 const std::vector<Real> * const weights)
2392{
2394
2395 const unsigned int elem_dim = elem->dim();
2396 mooseAssert(elem_dim < _mesh_dimension,
2397 "The lower dimensional element should truly be a lower dimensional element");
2398
2399 if (pts)
2400 {
2401 // Lower rule matches the face rule for the higher dimensional element
2402 ArbitraryQuadrature * lower_rule = qrules(elem_dim + 1).arbitrary_face.get();
2403
2404 // This also sets the quadrature weights to unity
2405 lower_rule->setPoints(*pts);
2406
2407 if (weights)
2408 lower_rule->setWeights(*weights);
2409
2410 setLowerQRule(lower_rule, elem_dim);
2411 }
2412 else if (_current_qrule_lower != qrules(elem_dim + 1).face.get())
2413 setLowerQRule(qrules(elem_dim + 1).face.get(), elem_dim);
2414
2415 for (const auto & it : _fe_lower[elem_dim])
2416 {
2417 FEBase & fe_lower = *it.second;
2418 FEType fe_type = it.first;
2419
2420 fe_lower.reinit(elem);
2421
2422 if (FEShapeData * fesd = _fe_shape_data_lower[fe_type].get())
2423 {
2424 fesd->_phi.shallowCopy(const_cast<std::vector<std::vector<Real>> &>(fe_lower.get_phi()));
2425 fesd->_grad_phi.shallowCopy(
2426 const_cast<std::vector<std::vector<RealGradient>> &>(fe_lower.get_dphi()));
2427 if (_need_second_derivative_neighbor.count(fe_type))
2428 fesd->_second_phi.shallowCopy(
2429 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe_lower.get_d2phi()));
2430 }
2431
2432 // Dual shape functions need to be computed after primal basis being initialized
2433 if (FEShapeData * fesd = _fe_shape_data_dual_lower[fe_type].get())
2434 {
2435 fesd->_phi.shallowCopy(const_cast<std::vector<std::vector<Real>> &>(fe_lower.get_dual_phi()));
2436 fesd->_grad_phi.shallowCopy(
2437 const_cast<std::vector<std::vector<RealGradient>> &>(fe_lower.get_dual_dphi()));
2438 if (_need_second_derivative_neighbor.count(fe_type))
2439 fesd->_second_phi.shallowCopy(
2440 const_cast<std::vector<std::vector<TensorValue<Real>>> &>(fe_lower.get_dual_d2phi()));
2441 }
2442 }
2443 if (!_unique_fe_lower_helper.empty())
2444 {
2445 mooseAssert(elem_dim < _unique_fe_lower_helper.size(), "We should be in bounds here");
2446 _unique_fe_lower_helper[elem_dim]->reinit(elem);
2447 }
2448
2450 return;
2451
2452 if (pts && !weights)
2453 {
2454 // We only have dummy weights so the JxWs computed during our FE reinits are meaningless and
2455 // we cannot use them
2456
2458 // We are in a Cartesian coordinate system and we can just use the element volume method
2459 // which has fast computation for certain element types
2461 else
2462 // We manually compute the volume taking the curvilinear coordinate transformations into
2463 // account
2465 }
2466 else
2467 {
2468 // During that last loop the helper objects will have been reinitialized as well
2469 FEBase & helper_fe = *_holder_fe_lower_helper[elem_dim];
2470 const auto & physical_q_points = helper_fe.get_xyz();
2471 const auto & JxW = helper_fe.get_JxW();
2472 MooseArray<Real> coord;
2474 _current_qrule_lower, physical_q_points, coord, elem->subdomain_id());
2476 for (const auto qp : make_range(_current_qrule_lower->n_points()))
2477 _current_lower_d_elem_volume += JxW[qp] * coord[qp];
2478 }
2479}
2480
2481void
2483{
2484 mooseAssert(elem->dim() < _mesh_dimension,
2485 "You should be calling reinitNeighborLowerDElem on a lower dimensional element");
2486
2488
2490 return;
2491
2493 // We are in a Cartesian coordinate system and we can just use the element volume method which
2494 // has fast computation for certain element types
2496 else
2497 // We manually compute the volume taking the curvilinear coordinate transformations into
2498 // account
2500}
2501
2502void
2504{
2505 mooseAssert(elem->dim() == _mesh_dimension - 1,
2506 "You should be calling reinitMortarElem on a lower dimensional element");
2507
2508 _fe_msm->reinit(elem);
2509 _msm_elem = elem;
2510
2511 MooseArray<Point> array_q_points;
2512 array_q_points.shallowCopy(const_cast<std::vector<Point> &>(_fe_msm->get_xyz()));
2513 setCoordinateTransformation(_qrule_msm, array_q_points, _coord_msm, elem->subdomain_id());
2514}
2515
2516void
2518 unsigned int neighbor_side,
2519 const std::vector<Point> & physical_points)
2520{
2521 unsigned int neighbor_dim = neighbor->dim();
2522 FEMap::inverse_map(neighbor_dim, neighbor, physical_points, _current_neighbor_ref_points);
2523
2525 {
2526 mooseAssert(
2527 physical_points.size() == 1,
2528 "If reinitializing with more than one point, then I am dubious of your use case. Perhaps "
2529 "you are performing a DG type method and you are reinitializing using points from the "
2530 "element face. In such a case your neighbor JxW must have its index order 'match' the "
2531 "element JxW index order, e.g. imagining a vertical 1D face with two quadrature points, "
2532 "if "
2533 "index 0 for elem JxW corresponds to the 'top' quadrature point, then index 0 for "
2534 "neighbor "
2535 "JxW must also correspond to the 'top' quadrature point. And libMesh/MOOSE has no way to "
2536 "guarantee that with multiple quadrature points.");
2537
2538 // An invalid side means the neighbor is itself the face, e.g. a primary surface element
2540 neighbor_side == libMesh::invalid_uint
2541 ? neighbor
2543
2544 // With a single point our size-1 JxW should just be the element volume
2547 }
2548
2551
2552 // Save off the physical points
2553 _current_physical_points = physical_points;
2554}
2555
2556void
2558 const std::vector<Point> & physical_points)
2559{
2560 unsigned int neighbor_dim = neighbor->dim();
2561 FEMap::inverse_map(neighbor_dim, neighbor, physical_points, _current_neighbor_ref_points);
2562
2565 // Save off the physical points
2566 _current_physical_points = physical_points;
2567}
2568
2569void
2570Assembly::init(const CouplingMatrix * cm)
2571{
2572 _cm = cm;
2573
2574 unsigned int n_vars = _sys.nVariables();
2575
2576 _cm_ss_entry.clear();
2577 _cm_sf_entry.clear();
2578 _cm_fs_entry.clear();
2579 _cm_ff_entry.clear();
2580
2581 auto & vars = _sys.getVariables(_tid);
2582
2584 for (auto & ivar : vars)
2585 {
2586 auto i = ivar->number();
2587 if (i >= _component_block_diagonal.size())
2588 _component_block_diagonal.resize(i + 1, true);
2589
2590 auto ivar_start = _cm_ff_entry.size();
2591 for (unsigned int k = 0; k < ivar->count(); ++k)
2592 {
2593 unsigned int iv = i + k;
2594 for (const auto & j : libMesh::ConstCouplingRow(iv, *_cm))
2595 {
2596 if (_sys.isScalarVariable(j))
2597 {
2598 auto & jvar = _sys.getScalarVariable(_tid, j);
2599 _cm_fs_entry.push_back(std::make_pair(ivar, &jvar));
2600 _block_diagonal_matrix = false;
2601 }
2602 else
2603 {
2604 auto & jvar = _sys.getVariable(_tid, j);
2605 auto pair = std::make_pair(ivar, &jvar);
2606 auto c = ivar_start;
2607 // check if the pair has been pushed or not
2608 bool has_pair = false;
2609 for (; c < _cm_ff_entry.size(); ++c)
2610 if (_cm_ff_entry[c] == pair)
2611 {
2612 has_pair = true;
2613 break;
2614 }
2615 if (!has_pair)
2616 _cm_ff_entry.push_back(pair);
2617 // only set having diagonal matrix to false when ivar and jvar numbers are different
2618 // Note: for array variables, since we save the entire local Jacobian of all components,
2619 // even there are couplings among components of the same array variable, we still
2620 // do not set the flag to false.
2621 if (i != jvar.number())
2622 _block_diagonal_matrix = false;
2623 else if (iv != j)
2624 _component_block_diagonal[i] = false;
2625 }
2626 }
2627 }
2628 }
2629
2630 auto & scalar_vars = _sys.getScalarVariables(_tid);
2631
2632 for (auto & ivar : scalar_vars)
2633 {
2634 auto i = ivar->number();
2635 if (i >= _component_block_diagonal.size())
2636 _component_block_diagonal.resize(i + 1, true);
2637
2638 for (const auto & j : libMesh::ConstCouplingRow(i, *_cm))
2639 if (_sys.isScalarVariable(j))
2640 {
2641 auto & jvar = _sys.getScalarVariable(_tid, j);
2642 _cm_ss_entry.push_back(std::make_pair(ivar, &jvar));
2643 }
2644 else
2645 {
2646 auto & jvar = _sys.getVariable(_tid, j);
2647 _cm_sf_entry.push_back(std::make_pair(ivar, &jvar));
2648 }
2649 }
2650
2651 if (_block_diagonal_matrix && scalar_vars.size() != 0)
2652 _block_diagonal_matrix = false;
2653
2654 auto num_vector_tags = _residual_vector_tags.size();
2655
2656 _sub_Re.resize(num_vector_tags);
2657 _sub_Rn.resize(num_vector_tags);
2658 _sub_Rl.resize(num_vector_tags);
2659 for (MooseIndex(_sub_Re) i = 0; i < _sub_Re.size(); i++)
2660 {
2661 _sub_Re[i].resize(n_vars);
2662 _sub_Rn[i].resize(n_vars);
2663 _sub_Rl[i].resize(n_vars);
2664 }
2665
2666 _cached_residual_values.resize(num_vector_tags);
2667 _cached_residual_rows.resize(num_vector_tags);
2668
2669 auto num_matrix_tags = _subproblem.numMatrixTags();
2670
2671 _cached_jacobian_values.resize(num_matrix_tags);
2672 _cached_jacobian_rows.resize(num_matrix_tags);
2673 _cached_jacobian_cols.resize(num_matrix_tags);
2674
2675 // Element matrices
2676 _sub_Kee.resize(num_matrix_tags);
2677 _sub_Keg.resize(num_matrix_tags);
2678 _sub_Ken.resize(num_matrix_tags);
2679 _sub_Kne.resize(num_matrix_tags);
2680 _sub_Knn.resize(num_matrix_tags);
2681 _sub_Kll.resize(num_matrix_tags);
2682 _sub_Kle.resize(num_matrix_tags);
2683 _sub_Kln.resize(num_matrix_tags);
2684 _sub_Kel.resize(num_matrix_tags);
2685 _sub_Knl.resize(num_matrix_tags);
2686
2687 _jacobian_block_used.resize(num_matrix_tags);
2688 _jacobian_block_neighbor_used.resize(num_matrix_tags);
2689 _jacobian_block_lower_used.resize(num_matrix_tags);
2690 _jacobian_block_nonlocal_used.resize(num_matrix_tags);
2691
2692 for (MooseIndex(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
2693 {
2694 _sub_Keg[tag].resize(n_vars);
2695 _sub_Ken[tag].resize(n_vars);
2696 _sub_Kne[tag].resize(n_vars);
2697 _sub_Knn[tag].resize(n_vars);
2698 _sub_Kee[tag].resize(n_vars);
2699 _sub_Kll[tag].resize(n_vars);
2700 _sub_Kle[tag].resize(n_vars);
2701 _sub_Kln[tag].resize(n_vars);
2702 _sub_Kel[tag].resize(n_vars);
2703 _sub_Knl[tag].resize(n_vars);
2704
2705 _jacobian_block_used[tag].resize(n_vars);
2706 _jacobian_block_neighbor_used[tag].resize(n_vars);
2707 _jacobian_block_lower_used[tag].resize(n_vars);
2708 _jacobian_block_nonlocal_used[tag].resize(n_vars);
2709 for (MooseIndex(n_vars) i = 0; i < n_vars; ++i)
2710 {
2712 {
2713 _sub_Kee[tag][i].resize(n_vars);
2714 _sub_Keg[tag][i].resize(n_vars);
2715 _sub_Ken[tag][i].resize(n_vars);
2716 _sub_Kne[tag][i].resize(n_vars);
2717 _sub_Knn[tag][i].resize(n_vars);
2718 _sub_Kll[tag][i].resize(n_vars);
2719 _sub_Kle[tag][i].resize(n_vars);
2720 _sub_Kln[tag][i].resize(n_vars);
2721 _sub_Kel[tag][i].resize(n_vars);
2722 _sub_Knl[tag][i].resize(n_vars);
2723
2724 _jacobian_block_used[tag][i].resize(n_vars);
2725 _jacobian_block_neighbor_used[tag][i].resize(n_vars);
2726 _jacobian_block_lower_used[tag][i].resize(n_vars);
2727 _jacobian_block_nonlocal_used[tag][i].resize(n_vars);
2728 }
2729 else
2730 {
2731 _sub_Kee[tag][i].resize(1);
2732 _sub_Keg[tag][i].resize(1);
2733 _sub_Ken[tag][i].resize(1);
2734 _sub_Kne[tag][i].resize(1);
2735 _sub_Knn[tag][i].resize(1);
2736 _sub_Kll[tag][i].resize(1);
2737 _sub_Kle[tag][i].resize(1);
2738 _sub_Kln[tag][i].resize(1);
2739 _sub_Kel[tag][i].resize(1);
2740 _sub_Knl[tag][i].resize(1);
2741
2742 _jacobian_block_used[tag][i].resize(1);
2743 _jacobian_block_neighbor_used[tag][i].resize(1);
2744 _jacobian_block_lower_used[tag][i].resize(1);
2745 _jacobian_block_nonlocal_used[tag][i].resize(1);
2746 }
2747 }
2748 }
2749}
2750
2751void
2753{
2754 _cm_nonlocal_entry.clear();
2755
2756 auto & vars = _sys.getVariables(_tid);
2757
2758 for (auto & ivar : vars)
2759 {
2760 auto i = ivar->number();
2761 auto ivar_start = _cm_nonlocal_entry.size();
2762 for (unsigned int k = 0; k < ivar->count(); ++k)
2763 {
2764 unsigned int iv = i + k;
2765 for (const auto & j : libMesh::ConstCouplingRow(iv, _nonlocal_cm))
2766 if (!_sys.isScalarVariable(j))
2767 {
2768 auto & jvar = _sys.getVariable(_tid, j);
2769 auto pair = std::make_pair(ivar, &jvar);
2770 auto c = ivar_start;
2771 // check if the pair has been pushed or not
2772 bool has_pair = false;
2773 for (; c < _cm_nonlocal_entry.size(); ++c)
2774 if (_cm_nonlocal_entry[c] == pair)
2775 {
2776 has_pair = true;
2777 break;
2778 }
2779 if (!has_pair)
2780 _cm_nonlocal_entry.push_back(pair);
2781 }
2782 }
2783 }
2784}
2785
2786void
2788{
2789 for (const auto & it : _cm_ff_entry)
2790 {
2791 MooseVariableFEBase & ivar = *(it.first);
2792 MooseVariableFEBase & jvar = *(it.second);
2793
2794 unsigned int vi = ivar.number();
2795 unsigned int vj = jvar.number();
2796
2797 const bool array_block_diagonal_purely_diagonal = vi == vj && _component_block_diagonal[vi];
2798 auto num_cols = jvar.dofIndices().size();
2799 if (array_block_diagonal_purely_diagonal)
2800 num_cols /= jvar.count();
2801
2802 for (MooseIndex(_jacobian_block_used) tag = 0; tag < _jacobian_block_used.size(); tag++)
2803 {
2804 jacobianBlock(vi, vj, LocalDataKey{}, tag).resize(ivar.dofIndices().size(), num_cols);
2805 jacobianBlockUsed(tag, vi, vj, false);
2806 }
2807 }
2808}
2809
2810void
2812{
2813 const std::vector<MooseVariableFEBase *> & vars = _sys.getVariables(_tid);
2814 for (const auto & var : vars)
2815 for (auto & tag_Re : _sub_Re)
2816 tag_Re[var->number()].resize(var->dofIndices().size());
2817}
2818
2819void
2825
2826void
2828{
2829 for (const auto & it : _cm_nonlocal_entry)
2830 {
2831 MooseVariableFEBase & ivar = *(it.first);
2832 MooseVariableFEBase & jvar = *(it.second);
2833
2834 unsigned int vi = ivar.number();
2835 unsigned int vj = jvar.number();
2836
2837 const bool array_block_diagonal_purely_diagonal = vi == vj && _component_block_diagonal[vi];
2838 auto num_cols = jvar.allDofIndices().size();
2839 if (array_block_diagonal_purely_diagonal)
2840 num_cols /= jvar.count();
2841
2842 for (MooseIndex(_jacobian_block_nonlocal_used) tag = 0;
2843 tag < _jacobian_block_nonlocal_used.size();
2844 tag++)
2845 {
2846 jacobianBlockNonlocal(vi, vj, LocalDataKey{}, tag).resize(ivar.dofIndices().size(), num_cols);
2847 jacobianBlockNonlocalUsed(tag, vi, vj, false);
2848 }
2849 }
2850}
2851
2852void
2854{
2855 for (const auto & it : _cm_ff_entry)
2856 {
2857 MooseVariableFEBase & ivar = *(it.first);
2858 MooseVariableFEBase & jvar = *(it.second);
2859
2860 unsigned int vi = ivar.number();
2861 unsigned int vj = jvar.number();
2862
2863 const bool array_block_diagonal_purely_diagonal = vi == vj && _component_block_diagonal[vi];
2864 auto num_cols = jvar.dofIndices().size();
2865 if (array_block_diagonal_purely_diagonal)
2866 num_cols /= jvar.count();
2867
2868 if (vi == var->number() || vj == var->number())
2869 {
2870 for (MooseIndex(_jacobian_block_used) tag = 0; tag < _jacobian_block_used.size(); tag++)
2871 {
2872 jacobianBlock(vi, vj, LocalDataKey{}, tag).resize(ivar.dofIndices().size(), num_cols);
2873 jacobianBlockUsed(tag, vi, vj, false);
2874 }
2875 }
2876 }
2877
2878 for (auto & tag_Re : _sub_Re)
2879 tag_Re[var->number()].resize(var->dofIndices().size());
2880}
2881
2882void
2884{
2885 for (const auto & it : _cm_nonlocal_entry)
2886 {
2887 MooseVariableFEBase & ivar = *(it.first);
2888 MooseVariableFEBase & jvar = *(it.second);
2889
2890 unsigned int vi = ivar.number();
2891 unsigned int vj = jvar.number();
2892
2893 const bool array_block_diagonal_purely_diagonal = vi == vj && _component_block_diagonal[vi];
2894 auto num_cols = jvar.dofIndices().size();
2895 if (array_block_diagonal_purely_diagonal)
2896 num_cols /= jvar.count();
2897
2898 if (vi == var->number() || vj == var->number())
2899 {
2900 for (MooseIndex(_jacobian_block_nonlocal_used) tag = 0;
2901 tag < _jacobian_block_nonlocal_used.size();
2902 tag++)
2903 {
2904 jacobianBlockNonlocal(vi, vj, LocalDataKey{}, tag)
2905 .resize(ivar.dofIndices().size(), num_cols);
2906 jacobianBlockNonlocalUsed(tag, vi, vj);
2907 }
2908 }
2909 }
2910}
2911
2912void
2914{
2915 for (const auto & it : _cm_ff_entry)
2916 {
2917 MooseVariableFEBase & ivar = *(it.first);
2918 MooseVariableFEBase & jvar = *(it.second);
2919
2920 unsigned int vi = ivar.number();
2921 unsigned int vj = jvar.number();
2922
2923 const bool array_block_diagonal_purely_diagonal = vi == vj && _component_block_diagonal[vi];
2924 const auto dofs_divisor = array_block_diagonal_purely_diagonal ? jvar.count() : 1;
2925
2926 for (MooseIndex(_jacobian_block_neighbor_used) tag = 0;
2927 tag < _jacobian_block_neighbor_used.size();
2928 tag++)
2929 {
2931 .resize(ivar.dofIndices().size(), jvar.dofIndicesNeighbor().size() / dofs_divisor);
2932
2934 .resize(ivar.dofIndicesNeighbor().size(), jvar.dofIndices().size() / dofs_divisor);
2935
2937 .resize(ivar.dofIndicesNeighbor().size(),
2938 jvar.dofIndicesNeighbor().size() / dofs_divisor);
2939
2940 jacobianBlockNeighborUsed(tag, vi, vj, false);
2941 }
2942 }
2943
2944 const std::vector<MooseVariableFEBase *> & vars = _sys.getVariables(_tid);
2945 for (const auto & var : vars)
2946 for (auto & tag_Rn : _sub_Rn)
2947 tag_Rn[var->number()].resize(var->dofIndicesNeighbor().size());
2948}
2949
2950void
2952{
2953 for (const auto & it : _cm_ff_entry)
2954 {
2955 MooseVariableFEBase & ivar = *(it.first);
2956 MooseVariableFEBase & jvar = *(it.second);
2957
2958 unsigned int vi = ivar.number();
2959 unsigned int vj = jvar.number();
2960
2961 const bool array_block_diagonal_purely_diagonal = vi == vj && _component_block_diagonal[vi];
2962 const auto dofs_divisor = array_block_diagonal_purely_diagonal ? jvar.count() : 1;
2963
2964 for (MooseIndex(_jacobian_block_lower_used) tag = 0; tag < _jacobian_block_lower_used.size();
2965 tag++)
2966 {
2967 // To cover all possible cases we should have 9 combinations below for every 2-permutation
2968 // of Lower,Secondary,Primary. However, 4 cases will in general be covered by calls to
2969 // prepare() and prepareNeighbor(). These calls will cover SecondarySecondary
2970 // (ElementElement), SecondaryPrimary (ElementNeighbor), PrimarySecondary (NeighborElement),
2971 // and PrimaryPrimary (NeighborNeighbor). With these covered we only need to prepare the 5
2972 // remaining below
2973
2974 // derivatives w.r.t. lower dimensional residuals
2976 .resize(ivar.dofIndicesLower().size(), jvar.dofIndicesLower().size() / dofs_divisor);
2977
2979 .resize(ivar.dofIndicesLower().size(), jvar.dofIndices().size() / dofs_divisor);
2980
2982 .resize(ivar.dofIndicesLower().size(), jvar.dofIndicesNeighbor().size() / dofs_divisor);
2983
2984 // derivatives w.r.t. interior secondary residuals
2986 .resize(ivar.dofIndices().size(), jvar.dofIndicesLower().size() / dofs_divisor);
2987
2988 // derivatives w.r.t. interior primary residuals
2990 .resize(ivar.dofIndicesNeighbor().size(), jvar.dofIndicesLower().size() / dofs_divisor);
2991
2992 jacobianBlockLowerUsed(tag, vi, vj, false);
2993 }
2994 }
2995
2996 const std::vector<MooseVariableFEBase *> & vars = _sys.getVariables(_tid);
2997 for (const auto & var : vars)
2998 for (auto & tag_Rl : _sub_Rl)
2999 tag_Rl[var->number()].resize(var->dofIndicesLower().size());
3000}
3001
3002void
3003Assembly::prepareBlock(unsigned int ivar,
3004 unsigned int jvar,
3005 const std::vector<dof_id_type> & dof_indices)
3006{
3007 const auto & iv = _sys.getVariable(_tid, ivar);
3008 const auto & jv = _sys.getVariable(_tid, jvar);
3009 const unsigned int ivn = iv.number();
3010 const unsigned int jvn = jv.number();
3011 const unsigned int icount = iv.count();
3012 unsigned int jcount = jv.count();
3013 if (ivn == jvn && _component_block_diagonal[ivn])
3014 jcount = 1;
3015
3016 for (MooseIndex(_jacobian_block_used) tag = 0; tag < _jacobian_block_used.size(); tag++)
3017 {
3018 jacobianBlock(ivn, jvn, LocalDataKey{}, tag)
3019 .resize(dof_indices.size() * icount, dof_indices.size() * jcount);
3020 jacobianBlockUsed(tag, ivn, jvn, false);
3021 }
3022
3023 for (auto & tag_Re : _sub_Re)
3024 tag_Re[ivn].resize(dof_indices.size() * icount);
3025}
3026
3027void
3029 unsigned int jvar,
3030 const std::vector<dof_id_type> & idof_indices,
3031 const std::vector<dof_id_type> & jdof_indices)
3032{
3033 const auto & iv = _sys.getVariable(_tid, ivar);
3034 const auto & jv = _sys.getVariable(_tid, jvar);
3035 const unsigned int ivn = iv.number();
3036 const unsigned int jvn = jv.number();
3037 const unsigned int icount = iv.count();
3038 unsigned int jcount = jv.count();
3039 if (ivn == jvn && _component_block_diagonal[ivn])
3040 jcount = 1;
3041
3042 for (MooseIndex(_jacobian_block_nonlocal_used) tag = 0;
3043 tag < _jacobian_block_nonlocal_used.size();
3044 tag++)
3045 {
3046 jacobianBlockNonlocal(ivn, jvn, LocalDataKey{}, tag)
3047 .resize(idof_indices.size() * icount, jdof_indices.size() * jcount);
3048
3049 jacobianBlockNonlocalUsed(tag, ivn, jvn, false);
3050 }
3051}
3052
3053void
3055{
3056 const std::vector<MooseVariableScalar *> & vars = _sys.getScalarVariables(_tid);
3057 for (const auto & ivar : vars)
3058 {
3059 auto idofs = ivar->dofIndices().size();
3060
3061 for (auto & tag_Re : _sub_Re)
3062 tag_Re[ivar->number()].resize(idofs);
3063
3064 for (const auto & jvar : vars)
3065 {
3066 auto jdofs = jvar->dofIndices().size();
3067
3068 for (MooseIndex(_jacobian_block_used) tag = 0; tag < _jacobian_block_used.size(); tag++)
3069 {
3070 jacobianBlock(ivar->number(), jvar->number(), LocalDataKey{}, tag).resize(idofs, jdofs);
3071 jacobianBlockUsed(tag, ivar->number(), jvar->number(), false);
3072 }
3073 }
3074 }
3075}
3076
3077void
3079{
3080 const std::vector<MooseVariableFEBase *> & vars = _sys.getVariables(_tid);
3081 const std::vector<MooseVariableScalar *> & scalar_vars = _sys.getScalarVariables(_tid);
3082
3083 for (const auto & ivar : scalar_vars)
3084 {
3085 auto idofs = ivar->dofIndices().size();
3086
3087 for (const auto & jvar : vars)
3088 {
3089 auto jdofs = jvar->dofIndices().size() * jvar->count();
3090 for (MooseIndex(_jacobian_block_used) tag = 0; tag < _jacobian_block_used.size(); tag++)
3091 {
3092 jacobianBlock(ivar->number(), jvar->number(), LocalDataKey{}, tag).resize(idofs, jdofs);
3093 jacobianBlockUsed(tag, ivar->number(), jvar->number(), false);
3094
3095 jacobianBlock(jvar->number(), ivar->number(), LocalDataKey{}, tag).resize(jdofs, idofs);
3096 jacobianBlockUsed(tag, jvar->number(), ivar->number(), false);
3097 }
3098 }
3099 }
3100}
3101
3102template <typename T>
3103void
3105{
3106 phi(v).shallowCopy(v.phi());
3107 gradPhi(v).shallowCopy(v.gradPhi());
3108 if (v.computingSecond())
3109 secondPhi(v).shallowCopy(v.secondPhi());
3110}
3111
3112void
3113Assembly::copyShapes(unsigned int var)
3114{
3115 auto & v = _sys.getVariable(_tid, var);
3116 if (v.fieldType() == Moose::VarFieldType::VAR_FIELD_STANDARD)
3117 {
3118 auto & v = _sys.getActualFieldVariable<Real>(_tid, var);
3119 copyShapes(v);
3120 }
3121 else if (v.fieldType() == Moose::VarFieldType::VAR_FIELD_ARRAY)
3122 {
3123 auto & v = _sys.getActualFieldVariable<RealEigenVector>(_tid, var);
3124 copyShapes(v);
3125 }
3126 else if (v.fieldType() == Moose::VarFieldType::VAR_FIELD_VECTOR)
3127 {
3128 auto & v = _sys.getActualFieldVariable<RealVectorValue>(_tid, var);
3129 copyShapes(v);
3130 if (v.computingCurl())
3131 curlPhi(v).shallowCopy(v.curlPhi());
3132 if (v.computingDiv())
3133 divPhi(v).shallowCopy(v.divPhi());
3134 }
3135 else
3136 mooseError("Unsupported variable field type!");
3137}
3138
3139template <typename T>
3140void
3142{
3143 phiFace(v).shallowCopy(v.phiFace());
3144 gradPhiFace(v).shallowCopy(v.gradPhiFace());
3145 if (v.computingSecond())
3146 secondPhiFace(v).shallowCopy(v.secondPhiFace());
3147}
3148
3149void
3151{
3152 auto & v = _sys.getVariable(_tid, var);
3153 if (v.fieldType() == Moose::VarFieldType::VAR_FIELD_STANDARD)
3154 {
3155 auto & v = _sys.getActualFieldVariable<Real>(_tid, var);
3156 copyFaceShapes(v);
3157 }
3158 else if (v.fieldType() == Moose::VarFieldType::VAR_FIELD_ARRAY)
3159 {
3160 auto & v = _sys.getActualFieldVariable<RealEigenVector>(_tid, var);
3161 copyFaceShapes(v);
3162 }
3163 else if (v.fieldType() == Moose::VarFieldType::VAR_FIELD_VECTOR)
3164 {
3165 auto & v = _sys.getActualFieldVariable<RealVectorValue>(_tid, var);
3166 copyFaceShapes(v);
3167 if (v.computingCurl())
3168 _vector_curl_phi_face.shallowCopy(v.curlPhi());
3169 if (v.computingDiv())
3170 _vector_div_phi_face.shallowCopy(v.divPhi());
3171 }
3172 else
3173 mooseError("Unsupported variable field type!");
3174}
3175
3176template <typename T>
3177void
3179{
3180 if (v.usesPhiNeighbor())
3181 {
3182 phiFaceNeighbor(v).shallowCopy(v.phiFaceNeighbor());
3183 phiNeighbor(v).shallowCopy(v.phiNeighbor());
3184 }
3185 if (v.usesGradPhiNeighbor())
3186 {
3187 gradPhiFaceNeighbor(v).shallowCopy(v.gradPhiFaceNeighbor());
3188 gradPhiNeighbor(v).shallowCopy(v.gradPhiNeighbor());
3189 }
3190 if (v.usesSecondPhiNeighbor())
3191 {
3192 secondPhiFaceNeighbor(v).shallowCopy(v.secondPhiFaceNeighbor());
3193 secondPhiNeighbor(v).shallowCopy(v.secondPhiNeighbor());
3194 }
3195}
3196
3197void
3199{
3200 auto & v = _sys.getVariable(_tid, var);
3201 if (v.fieldType() == Moose::VarFieldType::VAR_FIELD_STANDARD)
3202 {
3203 auto & v = _sys.getActualFieldVariable<Real>(_tid, var);
3205 }
3206 else if (v.fieldType() == Moose::VarFieldType::VAR_FIELD_ARRAY)
3207 {
3208 auto & v = _sys.getActualFieldVariable<RealEigenVector>(_tid, var);
3210 }
3211 else if (v.fieldType() == Moose::VarFieldType::VAR_FIELD_VECTOR)
3212 {
3213 auto & v = _sys.getActualFieldVariable<RealVectorValue>(_tid, var);
3215 }
3216 else
3217 mooseError("Unsupported variable field type!");
3218}
3219
3220DenseMatrix<Number> &
3222 Moose::DGJacobianType type, unsigned int ivar, unsigned int jvar, LocalDataKey, TagID tag)
3223{
3224 if (type == Moose::ElementElement)
3225 jacobianBlockUsed(tag, ivar, jvar, true);
3226 else
3227 jacobianBlockNeighborUsed(tag, ivar, jvar, true);
3228
3230 {
3231 switch (type)
3232 {
3233 default:
3235 return _sub_Kee[tag][ivar][0];
3237 return _sub_Ken[tag][ivar][0];
3239 return _sub_Kne[tag][ivar][0];
3241 return _sub_Knn[tag][ivar][0];
3242 }
3243 }
3244 else
3245 {
3246 switch (type)
3247 {
3248 default:
3250 return _sub_Kee[tag][ivar][jvar];
3252 return _sub_Ken[tag][ivar][jvar];
3254 return _sub_Kne[tag][ivar][jvar];
3256 return _sub_Knn[tag][ivar][jvar];
3257 }
3258 }
3259}
3260
3261DenseMatrix<Number> &
3263 unsigned int ivar,
3264 unsigned int jvar,
3266 TagID tag)
3267{
3268 jacobianBlockLowerUsed(tag, ivar, jvar, true);
3270 {
3271 switch (type)
3272 {
3273 default:
3274 case Moose::LowerLower:
3275 return _sub_Kll[tag][ivar][0];
3277 return _sub_Kle[tag][ivar][0];
3279 return _sub_Kln[tag][ivar][0];
3281 return _sub_Kel[tag][ivar][0];
3283 return _sub_Kee[tag][ivar][0];
3285 return _sub_Ken[tag][ivar][0];
3287 return _sub_Knl[tag][ivar][0];
3289 return _sub_Kne[tag][ivar][0];
3291 return _sub_Knn[tag][ivar][0];
3292 }
3293 }
3294 else
3295 {
3296 switch (type)
3297 {
3298 default:
3299 case Moose::LowerLower:
3300 return _sub_Kll[tag][ivar][jvar];
3302 return _sub_Kle[tag][ivar][jvar];
3304 return _sub_Kln[tag][ivar][jvar];
3306 return _sub_Kel[tag][ivar][jvar];
3308 return _sub_Kee[tag][ivar][jvar];
3310 return _sub_Ken[tag][ivar][jvar];
3312 return _sub_Knl[tag][ivar][jvar];
3314 return _sub_Kne[tag][ivar][jvar];
3316 return _sub_Knn[tag][ivar][jvar];
3317 }
3318 }
3319}
3320
3321void
3322Assembly::processLocalResidual(DenseVector<Number> & res_block,
3323 std::vector<dof_id_type> & dof_indices,
3324 const std::vector<Real> & scaling_factor)
3325{
3326 mooseAssert(res_block.size() == dof_indices.size(),
3327 "The size of residual and degree of freedom container must be the same");
3328
3329 // For an array variable, ndof is the number of dofs of the zero-th component and
3330 // ntdof is the number of dofs of all components.
3331 // For standard or vector variables, ndof will be the same as ntdof.
3332 const auto ntdof = res_block.size();
3333 const auto count = scaling_factor.size();
3334 const auto ndof = ntdof / count;
3335 if (count > 1)
3336 {
3337 unsigned int p = 0;
3338 for (MooseIndex(count) j = 0; j < count; ++j)
3339 for (MooseIndex(ndof) i = 0; i < ndof; ++i)
3340 res_block(p++) *= scaling_factor[j];
3341 }
3342 else
3343 {
3344 if (scaling_factor[0] != 1.0)
3345 res_block *= scaling_factor[0];
3346 }
3347
3348 _dof_map.constrain_element_vector(res_block, dof_indices, false);
3349}
3350
3351void
3352Assembly::addResidualBlock(NumericVector<Number> & residual,
3353 DenseVector<Number> & res_block,
3354 const std::vector<dof_id_type> & dof_indices,
3355 const std::vector<Real> & scaling_factor)
3356{
3357 if (dof_indices.size() > 0 && res_block.size())
3358 {
3359 _temp_dof_indices = dof_indices;
3360 _tmp_Re = res_block;
3362 residual.add_vector(_tmp_Re, _temp_dof_indices);
3363 }
3364}
3365
3366void
3367Assembly::cacheResidualBlock(std::vector<Real> & cached_residual_values,
3368 std::vector<dof_id_type> & cached_residual_rows,
3369 DenseVector<Number> & res_block,
3370 const std::vector<dof_id_type> & dof_indices,
3371 const std::vector<Real> & scaling_factor)
3372{
3373 if (dof_indices.size() > 0 && res_block.size())
3374 {
3375 _temp_dof_indices = dof_indices;
3376 _tmp_Re = res_block;
3378
3379 for (MooseIndex(_tmp_Re) i = 0; i < _tmp_Re.size(); i++)
3380 {
3381 cached_residual_values.push_back(_tmp_Re(i));
3382 cached_residual_rows.push_back(_temp_dof_indices[i]);
3383 }
3384 }
3385
3386 res_block.zero();
3387}
3388
3389void
3390Assembly::setResidualBlock(NumericVector<Number> & residual,
3391 DenseVector<Number> & res_block,
3392 const std::vector<dof_id_type> & dof_indices,
3393 const std::vector<Real> & scaling_factor)
3394{
3395 if (dof_indices.size() > 0)
3396 {
3397 std::vector<dof_id_type> di(dof_indices);
3398 _tmp_Re = res_block;
3399 processLocalResidual(_tmp_Re, di, scaling_factor);
3400 residual.insert(_tmp_Re, di);
3401 }
3402}
3403
3404void
3406{
3407 mooseAssert(vector_tag._type == Moose::VECTOR_TAG_RESIDUAL,
3408 "Non-residual tag in Assembly::addResidual");
3409
3410 auto & tag_Re = _sub_Re[vector_tag._type_id];
3411 NumericVector<Number> & residual = _sys.getVector(vector_tag._id);
3412 const std::vector<MooseVariableFEBase *> & vars = _sys.getVariables(_tid);
3413 for (const auto & var : vars)
3414 addResidualBlock(residual, tag_Re[var->number()], var->dofIndices(), var->arrayScalingFactor());
3415}
3416
3417void
3418Assembly::addResidual(GlobalDataKey, const std::vector<VectorTag> & vector_tags)
3419{
3420 for (const auto & vector_tag : vector_tags)
3421 if (_sys.hasVector(vector_tag._id))
3422 addResidual(vector_tag);
3423}
3424
3425void
3427{
3428 mooseAssert(vector_tag._type == Moose::VECTOR_TAG_RESIDUAL,
3429 "Non-residual tag in Assembly::addResidualNeighbor");
3430
3431 auto & tag_Rn = _sub_Rn[vector_tag._type_id];
3432 NumericVector<Number> & residual = _sys.getVector(vector_tag._id);
3433 const std::vector<MooseVariableFEBase *> & vars = _sys.getVariables(_tid);
3434 for (const auto & var : vars)
3436 residual, tag_Rn[var->number()], var->dofIndicesNeighbor(), var->arrayScalingFactor());
3437}
3438
3439void
3440Assembly::addResidualNeighbor(GlobalDataKey, const std::vector<VectorTag> & vector_tags)
3441{
3442 for (const auto & vector_tag : vector_tags)
3443 if (_sys.hasVector(vector_tag._id))
3444 addResidualNeighbor(vector_tag);
3445}
3446
3447void
3449{
3450 mooseAssert(vector_tag._type == Moose::VECTOR_TAG_RESIDUAL,
3451 "Non-residual tag in Assembly::addResidualLower");
3452
3453 auto & tag_Rl = _sub_Rl[vector_tag._type_id];
3454 NumericVector<Number> & residual = _sys.getVector(vector_tag._id);
3455 const std::vector<MooseVariableFEBase *> & vars = _sys.getVariables(_tid);
3456 for (const auto & var : vars)
3458 residual, tag_Rl[var->number()], var->dofIndicesLower(), var->arrayScalingFactor());
3459}
3460
3461void
3462Assembly::addResidualLower(GlobalDataKey, const std::vector<VectorTag> & vector_tags)
3463{
3464 for (const auto & vector_tag : vector_tags)
3465 if (_sys.hasVector(vector_tag._id))
3466 addResidualLower(vector_tag);
3467}
3468
3469// private method, so no key required
3470void
3472{
3473 mooseAssert(vector_tag._type == Moose::VECTOR_TAG_RESIDUAL,
3474 "Non-residual tag in Assembly::addResidualScalar");
3475
3476 // add the scalar variables residuals
3477 auto & tag_Re = _sub_Re[vector_tag._type_id];
3478 NumericVector<Number> & residual = _sys.getVector(vector_tag._id);
3479 const std::vector<MooseVariableScalar *> & vars = _sys.getScalarVariables(_tid);
3480 for (const auto & var : vars)
3481 addResidualBlock(residual, tag_Re[var->number()], var->dofIndices(), var->arrayScalingFactor());
3482}
3483
3484void
3485Assembly::addResidualScalar(GlobalDataKey, const std::vector<VectorTag> & vector_tags)
3486{
3487 for (const auto & vector_tag : vector_tags)
3488 if (_sys.hasVector(vector_tag._id))
3489 addResidualScalar(vector_tag);
3490}
3491
3492void
3493Assembly::cacheResidual(GlobalDataKey, const std::vector<VectorTag> & tags)
3494{
3495 const std::vector<MooseVariableFEBase *> & vars = _sys.getVariables(_tid);
3496 for (const auto & var : vars)
3497 for (const auto & vector_tag : tags)
3498 if (_sys.hasVector(vector_tag._id))
3499 cacheResidualBlock(_cached_residual_values[vector_tag._type_id],
3500 _cached_residual_rows[vector_tag._type_id],
3501 _sub_Re[vector_tag._type_id][var->number()],
3502 var->dofIndices(),
3503 var->arrayScalingFactor());
3504}
3505
3506// private method, so no key required
3507void
3508Assembly::cacheResidual(dof_id_type dof, Real value, TagID tag_id)
3509{
3510 const VectorTag & tag = _subproblem.getVectorTag(tag_id);
3511
3512 _cached_residual_values[tag._type_id].push_back(value);
3513 _cached_residual_rows[tag._type_id].push_back(dof);
3514}
3515
3516// private method, so no key required
3517void
3518Assembly::cacheResidual(dof_id_type dof, Real value, const std::set<TagID> & tags)
3519{
3520 for (auto & tag : tags)
3521 cacheResidual(dof, value, tag);
3522}
3523
3524void
3525Assembly::cacheResidualNodes(const DenseVector<Number> & res,
3526 const std::vector<dof_id_type> & dof_index,
3528 TagID tag)
3529{
3530 // Add the residual value and dof_index to cached_residual_values and cached_residual_rows
3531 // respectively.
3532 // This is used by NodalConstraint.C to cache the residual calculated for primary and secondary
3533 // node.
3534 const VectorTag & vector_tag = _subproblem.getVectorTag(tag);
3535 for (MooseIndex(dof_index) i = 0; i < dof_index.size(); ++i)
3536 {
3537 _cached_residual_values[vector_tag._type_id].push_back(res(i));
3538 _cached_residual_rows[vector_tag._type_id].push_back(dof_index[i]);
3539 }
3540}
3541
3542void
3543Assembly::cacheResidualNeighbor(GlobalDataKey, const std::vector<VectorTag> & tags)
3544{
3545 const std::vector<MooseVariableFEBase *> & vars = _sys.getVariables(_tid);
3546 for (const auto & var : vars)
3547 for (const auto & vector_tag : tags)
3548 if (_sys.hasVector(vector_tag._id))
3549 cacheResidualBlock(_cached_residual_values[vector_tag._type_id],
3550 _cached_residual_rows[vector_tag._type_id],
3551 _sub_Rn[vector_tag._type_id][var->number()],
3552 var->dofIndicesNeighbor(),
3553 var->arrayScalingFactor());
3554}
3555
3556void
3557Assembly::cacheResidualLower(GlobalDataKey, const std::vector<VectorTag> & tags)
3558{
3559 const std::vector<MooseVariableFEBase *> & vars = _sys.getVariables(_tid);
3560 for (const auto & var : vars)
3561 for (const auto & vector_tag : tags)
3562 if (_sys.hasVector(vector_tag._id))
3563 cacheResidualBlock(_cached_residual_values[vector_tag._type_id],
3564 _cached_residual_rows[vector_tag._type_id],
3565 _sub_Rl[vector_tag._type_id][var->number()],
3566 var->dofIndicesLower(),
3567 var->arrayScalingFactor());
3568}
3569
3570void
3571Assembly::addCachedResiduals(GlobalDataKey, const std::vector<VectorTag> & tags)
3572{
3573 for (const auto & vector_tag : tags)
3574 {
3575 if (!_sys.hasVector(vector_tag._id))
3576 {
3577 _cached_residual_values[vector_tag._type_id].clear();
3578 _cached_residual_rows[vector_tag._type_id].clear();
3579 continue;
3580 }
3581 addCachedResidualDirectly(_sys.getVector(vector_tag._id), GlobalDataKey{}, vector_tag);
3582 }
3583}
3584
3585void
3587{
3588 for (const auto & vector_tag : _residual_vector_tags)
3589 clearCachedResiduals(vector_tag);
3590}
3591
3592// private method, so no key required
3593void
3595{
3596 auto & values = _cached_residual_values[vector_tag._type_id];
3597 auto & rows = _cached_residual_rows[vector_tag._type_id];
3598
3599 mooseAssert(values.size() == rows.size(),
3600 "Number of cached residuals and number of rows must match!");
3601
3602 // Keep track of the largest size so we can use it to reserve and avoid
3603 // as much dynamic allocation as possible
3604 if (_max_cached_residuals < values.size())
3606
3607 // Clear both vectors (keeps the capacity the same)
3608 values.clear();
3609 rows.clear();
3610 // And then reserve: use 2 as a fudge factor to *really* avoid dynamic allocation!
3611 values.reserve(_max_cached_residuals * 2);
3612 rows.reserve(_max_cached_residuals * 2);
3613}
3614
3615void
3616Assembly::addCachedResidualDirectly(NumericVector<Number> & residual,
3618 const VectorTag & vector_tag)
3619{
3620 const auto & values = _cached_residual_values[vector_tag._type_id];
3621 const auto & rows = _cached_residual_rows[vector_tag._type_id];
3622
3623 mooseAssert(values.size() == rows.size(),
3624 "Number of cached residuals and number of rows must match!");
3625
3626 if (!values.empty())
3627 {
3628 residual.add_vector(values, rows);
3629 clearCachedResiduals(vector_tag);
3630 }
3631}
3632
3633void
3634Assembly::setResidual(NumericVector<Number> & residual, GlobalDataKey, const VectorTag & vector_tag)
3635{
3636 auto & tag_Re = _sub_Re[vector_tag._type_id];
3637 const std::vector<MooseVariableFEBase *> & vars = _sys.getVariables(_tid);
3638 for (const auto & var : vars)
3639 setResidualBlock(residual, tag_Re[var->number()], var->dofIndices(), var->arrayScalingFactor());
3640}
3641
3642void
3643Assembly::setResidualNeighbor(NumericVector<Number> & residual,
3645 const VectorTag & vector_tag)
3646{
3647 auto & tag_Rn = _sub_Rn[vector_tag._type_id];
3648 const std::vector<MooseVariableFEBase *> & vars = _sys.getVariables(_tid);
3649 for (const auto & var : vars)
3651 residual, tag_Rn[var->number()], var->dofIndicesNeighbor(), var->arrayScalingFactor());
3652}
3653
3654// private method, so no key required
3655void
3656Assembly::addJacobianBlock(SparseMatrix<Number> & jacobian,
3657 DenseMatrix<Number> & jac_block,
3658 const MooseVariableBase & ivar,
3659 const MooseVariableBase & jvar,
3660 const std::vector<dof_id_type> & idof_indices,
3661 const std::vector<dof_id_type> & jdof_indices)
3662{
3663 if (idof_indices.size() == 0 || jdof_indices.size() == 0)
3664 return;
3665 if (jac_block.n() == 0 || jac_block.m() == 0)
3666 return;
3667
3668 const auto & scaling_factors = ivar.arrayScalingFactor();
3669 const unsigned int iv = ivar.number();
3670 const unsigned int jv = jvar.number();
3671
3672 for (unsigned int i = 0; i < ivar.count(); ++i)
3673 {
3674 for (const auto & jt : libMesh::ConstCouplingRow(iv + i, *_cm))
3675 {
3676 if (jt < jv || jt >= jv + jvar.count())
3677 continue;
3678 unsigned int j = jt - jv;
3679
3680 auto di = ivar.componentDofIndices(idof_indices, i);
3681 auto dj = jvar.componentDofIndices(jdof_indices, j);
3682 auto indof = di.size();
3683 auto jndof = dj.size();
3684
3685 unsigned int jj = j;
3686 if (iv == jv && _component_block_diagonal[iv])
3687 // here i must be equal to j
3688 jj = 0;
3689
3690 auto sub = jac_block.sub_matrix(i * indof, indof, jj * jndof, jndof);
3691 if (scaling_factors[i] != 1.0)
3692 sub *= scaling_factors[i];
3693
3694 // If we're computing the jacobian for automatically scaling variables we do not want
3695 // to constrain the element matrix because it introduces 1s on the diagonal for the
3696 // constrained dofs
3698 _dof_map.constrain_element_matrix(sub, di, dj, false);
3699
3700 jacobian.add_matrix(sub, di, dj);
3701 }
3702 }
3703}
3704
3705// private method, so no key required
3706void
3707Assembly::cacheJacobianBlock(const DenseMatrix<Number> & jac_block,
3708 const MooseVariableBase & ivar,
3709 const MooseVariableBase & jvar,
3710 const std::vector<dof_id_type> & idof_indices,
3711 const std::vector<dof_id_type> & jdof_indices,
3712 TagID tag)
3713{
3714 if (idof_indices.size() == 0 || jdof_indices.size() == 0)
3715 return;
3716 if (jac_block.n() == 0 || jac_block.m() == 0)
3717 return;
3718 if (!_sys.hasMatrix(tag))
3719 return;
3720
3721 auto & scaling_factors = ivar.arrayScalingFactor();
3722 const unsigned int iv = ivar.number();
3723 const unsigned int jv = jvar.number();
3724
3725 for (unsigned int i = 0; i < ivar.count(); ++i)
3726 {
3727 for (const auto & jt : libMesh::ConstCouplingRow(iv + i, *_cm))
3728 {
3729 if (jt < jv || jt >= jv + jvar.count())
3730 continue;
3731 unsigned int j = jt - jv;
3732
3733 auto di = ivar.componentDofIndices(idof_indices, i);
3734 auto dj = jvar.componentDofIndices(jdof_indices, j);
3735 auto indof = di.size();
3736 auto jndof = dj.size();
3737
3738 unsigned int jj = j;
3739 if (iv == jv && _component_block_diagonal[iv])
3740 // here i must be equal to j
3741 jj = 0;
3742
3743 auto sub = jac_block.sub_matrix(i * indof, indof, jj * jndof, jndof);
3744 if (scaling_factors[i] != 1.0)
3745 sub *= scaling_factors[i];
3746
3747 // If we're computing the jacobian for automatically scaling variables we do not want
3748 // to constrain the element matrix because it introduces 1s on the diagonal for the
3749 // constrained dofs
3751 _dof_map.constrain_element_matrix(sub, di, dj, false);
3752
3753 for (MooseIndex(di) i = 0; i < di.size(); i++)
3754 for (MooseIndex(dj) j = 0; j < dj.size(); j++)
3755 {
3756 _cached_jacobian_values[tag].push_back(sub(i, j));
3757 _cached_jacobian_rows[tag].push_back(di[i]);
3758 _cached_jacobian_cols[tag].push_back(dj[j]);
3759 }
3760 }
3761 }
3762}
3763
3764// private method, so no key required
3765void
3766Assembly::cacheJacobianBlockNonzero(const DenseMatrix<Number> & jac_block,
3767 const MooseVariableBase & ivar,
3768 const MooseVariableBase & jvar,
3769 const std::vector<dof_id_type> & idof_indices,
3770 const std::vector<dof_id_type> & jdof_indices,
3771 TagID tag)
3772{
3773 if (idof_indices.size() == 0 || jdof_indices.size() == 0)
3774 return;
3775 if (jac_block.n() == 0 || jac_block.m() == 0)
3776 return;
3777 if (!_sys.hasMatrix(tag))
3778 return;
3779
3780 auto & scaling_factor = ivar.arrayScalingFactor();
3781
3782 for (unsigned int i = 0; i < ivar.count(); ++i)
3783 {
3784 unsigned int iv = ivar.number();
3785 for (const auto & jt : libMesh::ConstCouplingRow(iv + i, *_cm))
3786 {
3787 unsigned int jv = jvar.number();
3788 if (jt < jv || jt >= jv + jvar.count())
3789 continue;
3790 unsigned int j = jt - jv;
3791
3792 auto di = ivar.componentDofIndices(idof_indices, i);
3793 auto dj = jvar.componentDofIndices(jdof_indices, j);
3794 auto indof = di.size();
3795 auto jndof = dj.size();
3796
3797 unsigned int jj = j;
3798 if (iv == jv && _component_block_diagonal[iv])
3799 // here i must be equal to j
3800 jj = 0;
3801
3802 auto sub = jac_block.sub_matrix(i * indof, indof, jj * jndof, jndof);
3803 if (scaling_factor[i] != 1.0)
3804 sub *= scaling_factor[i];
3805
3806 _dof_map.constrain_element_matrix(sub, di, dj, false);
3807
3808 for (MooseIndex(di) i = 0; i < di.size(); i++)
3809 for (MooseIndex(dj) j = 0; j < dj.size(); j++)
3810 if (sub(i, j) != 0.0) // no storage allocated for unimplemented jacobian terms,
3811 // maintaining maximum sparsity possible
3812 {
3813 _cached_jacobian_values[tag].push_back(sub(i, j));
3814 _cached_jacobian_rows[tag].push_back(di[i]);
3815 _cached_jacobian_cols[tag].push_back(dj[j]);
3816 }
3817 }
3818 }
3819}
3820
3821void
3822Assembly::cacheJacobianBlock(const DenseMatrix<Number> & jac_block,
3823 const std::vector<dof_id_type> & idof_indices,
3824 const std::vector<dof_id_type> & jdof_indices,
3825 Real scaling_factor,
3827 const std::set<TagID> & tags)
3828{
3829 const auto has_matrix =
3830 std::any_of(tags.begin(), tags.end(), [this](const auto tag) { return _sys.hasMatrix(tag); });
3831
3832 // Work on a reusable Assembly-owned copy so callers retain their local matrix. This also lets us
3833 // apply constraints and scaling once before caching the same block to every requested matrix tag.
3834 if ((idof_indices.size() > 0) && (jdof_indices.size() > 0) && jac_block.n() && jac_block.m() &&
3835 has_matrix)
3836 {
3837 _row_indices.assign(idof_indices.begin(), idof_indices.end());
3838 _column_indices.assign(jdof_indices.begin(), jdof_indices.end());
3839 _element_matrix = jac_block;
3840
3841 // If we're computing the jacobian for automatically scaling variables we do not want to
3842 // constrain the element matrix because it introduces 1s on the diagonal for the constrained
3843 // dofs
3846
3847 if (scaling_factor != 1.0)
3848 _element_matrix *= scaling_factor;
3849
3850 for (const auto i : index_range(_row_indices))
3851 for (const auto j : index_range(_column_indices))
3854 }
3855}
3856
3857Real
3858Assembly::elementVolume(const Elem * elem) const
3859{
3860 FEType fe_type(elem->default_order(), LAGRANGE);
3861 std::unique_ptr<FEBase> fe(FEBase::build(elem->dim(), fe_type));
3862
3863 // references to the quadrature points and weights
3864 const std::vector<Real> & JxW = fe->get_JxW();
3865 const std::vector<Point> & q_points = fe->get_xyz();
3866
3867 // The default quadrature rule should integrate the mass matrix,
3868 // thus it should be plenty to compute the volume
3869 QGauss qrule(elem->dim(), fe_type.default_quadrature_order());
3870 fe->attach_quadrature_rule(&qrule);
3871 fe->reinit(elem);
3872
3873 // perform a sanity check to ensure that size of quad rule and size of q_points is
3874 // identical
3875 mooseAssert(qrule.n_points() == q_points.size(),
3876 "The number of points in the quadrature rule doesn't match the number of passed-in "
3877 "points in Assembly::setCoordinateTransformation");
3878
3879 // compute the coordinate transformation
3880 Real vol = 0;
3881 for (unsigned int qp = 0; qp < qrule.n_points(); ++qp)
3882 {
3883 Real coord;
3884 coordTransformFactor(_subproblem, elem->subdomain_id(), q_points[qp], coord);
3885 vol += JxW[qp] * coord;
3886 }
3887 return vol;
3888}
3889
3890void
3891Assembly::saveLocalADArray(std::vector<ADReal> & re,
3892 unsigned int i,
3893 unsigned int ntest,
3894 const ADRealEigenVector & v) const
3895{
3896 for (unsigned int j = 0; j < v.size(); ++j, i += ntest)
3897 re[i] += v(j);
3898}
3899
3900void
3902{
3903#ifndef NDEBUG
3905 {
3906 mooseAssert(_cached_jacobian_rows.size() == _cached_jacobian_cols.size(),
3907 "Error: Cached data sizes MUST be the same!");
3908 for (MooseIndex(_cached_jacobian_rows) i = 0; i < _cached_jacobian_rows.size(); i++)
3909 mooseAssert(_cached_jacobian_rows[i].size() == _cached_jacobian_cols[i].size(),
3910 "Error: Cached data sizes MUST be the same for a given tag!");
3911 }
3912#endif
3913
3914 for (MooseIndex(_cached_jacobian_rows) i = 0; i < _cached_jacobian_rows.size(); i++)
3915 if (_sys.hasMatrix(i))
3916 for (MooseIndex(_cached_jacobian_rows[i]) j = 0; j < _cached_jacobian_rows[i].size(); j++)
3920
3921 for (MooseIndex(_cached_jacobian_rows) i = 0; i < _cached_jacobian_rows.size(); i++)
3922 {
3923 if (!_sys.hasMatrix(i))
3924 continue;
3925
3928
3929 // Try to be more efficient from now on
3930 // The 2 is just a fudge factor to keep us from having to grow the vector during assembly
3931 _cached_jacobian_values[i].clear();
3933
3934 _cached_jacobian_rows[i].clear();
3936
3937 _cached_jacobian_cols[i].clear();
3939 }
3940}
3941
3942inline void
3944{
3945 auto i = ivar.number();
3946 auto j = jvar.number();
3947 for (MooseIndex(_jacobian_block_used) tag = 0; tag < _jacobian_block_used.size(); tag++)
3948 if (jacobianBlockUsed(tag, i, j) && _sys.hasMatrix(tag))
3950 jacobianBlock(i, j, LocalDataKey{}, tag),
3951 ivar,
3952 jvar,
3953 ivar.dofIndices(),
3954 jvar.dofIndices());
3955}
3956
3957void
3959{
3960 for (const auto & it : _cm_ff_entry)
3961 addJacobianCoupledVarPair(*it.first, *it.second);
3962
3963 for (const auto & it : _cm_sf_entry)
3964 addJacobianCoupledVarPair(*it.first, *it.second);
3965
3966 for (const auto & it : _cm_fs_entry)
3967 addJacobianCoupledVarPair(*it.first, *it.second);
3968}
3969
3970void
3972{
3973 for (const auto & it : _cm_nonlocal_entry)
3974 {
3975 auto ivar = it.first;
3976 auto jvar = it.second;
3977 auto i = ivar->number();
3978 auto j = jvar->number();
3979 for (MooseIndex(_jacobian_block_nonlocal_used) tag = 0;
3980 tag < _jacobian_block_nonlocal_used.size();
3981 tag++)
3982 if (jacobianBlockNonlocalUsed(tag, i, j) && _sys.hasMatrix(tag))
3984 jacobianBlockNonlocal(i, j, LocalDataKey{}, tag),
3985 *ivar,
3986 *jvar,
3987 ivar->dofIndices(),
3988 jvar->allDofIndices());
3989 }
3990}
3991
3992void
3994{
3995 for (const auto & it : _cm_ff_entry)
3996 {
3997 auto ivar = it.first;
3998 auto jvar = it.second;
3999 auto i = ivar->number();
4000 auto j = jvar->number();
4001 for (MooseIndex(_jacobian_block_neighbor_used) tag = 0;
4002 tag < _jacobian_block_neighbor_used.size();
4003 tag++)
4004 if (jacobianBlockNeighborUsed(tag, i, j) && _sys.hasMatrix(tag))
4005 {
4008 *ivar,
4009 *jvar,
4010 ivar->dofIndices(),
4011 jvar->dofIndicesNeighbor());
4012
4015 *ivar,
4016 *jvar,
4017 ivar->dofIndicesNeighbor(),
4018 jvar->dofIndices());
4019
4022 *ivar,
4023 *jvar,
4024 ivar->dofIndicesNeighbor(),
4025 jvar->dofIndicesNeighbor());
4026 }
4027 }
4028}
4029
4030void
4032{
4033 for (const auto & it : _cm_ff_entry)
4034 {
4035 auto ivar = it.first;
4036 auto jvar = it.second;
4037 auto i = ivar->number();
4038 auto j = jvar->number();
4039 for (MooseIndex(_jacobian_block_lower_used) tag = 0; tag < _jacobian_block_lower_used.size();
4040 tag++)
4041 if (jacobianBlockLowerUsed(tag, i, j) && _sys.hasMatrix(tag))
4042 {
4045 *ivar,
4046 *jvar,
4047 ivar->dofIndicesLower(),
4048 jvar->dofIndicesLower());
4049
4052 *ivar,
4053 *jvar,
4054 ivar->dofIndicesLower(),
4055 jvar->dofIndicesNeighbor());
4056
4059 *ivar,
4060 *jvar,
4061 ivar->dofIndicesLower(),
4062 jvar->dofIndices());
4063
4066 *ivar,
4067 *jvar,
4068 ivar->dofIndicesNeighbor(),
4069 jvar->dofIndicesLower());
4070
4073 *ivar,
4074 *jvar,
4075 ivar->dofIndices(),
4076 jvar->dofIndicesLower());
4077 }
4078
4079 for (MooseIndex(_jacobian_block_neighbor_used) tag = 0;
4080 tag < _jacobian_block_neighbor_used.size();
4081 tag++)
4082 if (jacobianBlockNeighborUsed(tag, i, j) && _sys.hasMatrix(tag))
4083 {
4086 *ivar,
4087 *jvar,
4088 ivar->dofIndices(),
4089 jvar->dofIndicesNeighbor());
4090
4093 *ivar,
4094 *jvar,
4095 ivar->dofIndicesNeighbor(),
4096 jvar->dofIndices());
4097
4100 *ivar,
4101 *jvar,
4102 ivar->dofIndicesNeighbor(),
4103 jvar->dofIndicesNeighbor());
4104 }
4105 }
4106}
4107
4108void
4110{
4111 for (const auto & it : _cm_ff_entry)
4112 {
4113 auto ivar = it.first;
4114 auto jvar = it.second;
4115 auto i = ivar->number();
4116 auto j = jvar->number();
4117 for (MooseIndex(_jacobian_block_lower_used) tag = 0; tag < _jacobian_block_lower_used.size();
4118 tag++)
4119 if (jacobianBlockLowerUsed(tag, i, j) && _sys.hasMatrix(tag))
4120 {
4123 *ivar,
4124 *jvar,
4125 ivar->dofIndicesLower(),
4126 jvar->dofIndicesLower());
4127
4130 *ivar,
4131 *jvar,
4132 ivar->dofIndicesLower(),
4133 jvar->dofIndices());
4134
4137 *ivar,
4138 *jvar,
4139 ivar->dofIndices(),
4140 jvar->dofIndicesLower());
4141 }
4142 }
4143}
4144
4145void
4147{
4148 for (const auto & it : _cm_ff_entry)
4149 cacheJacobianCoupledVarPair(*it.first, *it.second);
4150
4151 for (const auto & it : _cm_fs_entry)
4152 cacheJacobianCoupledVarPair(*it.first, *it.second);
4153
4154 for (const auto & it : _cm_sf_entry)
4155 cacheJacobianCoupledVarPair(*it.first, *it.second);
4156}
4157
4158// private method, so no key required
4159void
4161 const MooseVariableBase & jvar)
4162{
4163 auto i = ivar.number();
4164 auto j = jvar.number();
4165 for (MooseIndex(_jacobian_block_used) tag = 0; tag < _jacobian_block_used.size(); tag++)
4166 if (jacobianBlockUsed(tag, i, j) && _sys.hasMatrix(tag))
4168 ivar,
4169 jvar,
4170 ivar.dofIndices(),
4171 jvar.dofIndices(),
4172 tag);
4173}
4174
4175void
4177{
4178 for (const auto & it : _cm_nonlocal_entry)
4179 {
4180 auto ivar = it.first;
4181 auto jvar = it.second;
4182 auto i = ivar->number();
4183 auto j = jvar->number();
4184 for (MooseIndex(_jacobian_block_nonlocal_used) tag = 0;
4185 tag < _jacobian_block_nonlocal_used.size();
4186 tag++)
4187 if (jacobianBlockNonlocalUsed(tag, i, j) && _sys.hasMatrix(tag))
4189 *ivar,
4190 *jvar,
4191 ivar->dofIndices(),
4192 jvar->allDofIndices(),
4193 tag);
4194 }
4195}
4196
4197void
4199{
4200 for (const auto & it : _cm_ff_entry)
4201 {
4202 auto ivar = it.first;
4203 auto jvar = it.second;
4204 auto i = ivar->number();
4205 auto j = jvar->number();
4206
4207 for (MooseIndex(_jacobian_block_neighbor_used) tag = 0;
4208 tag < _jacobian_block_neighbor_used.size();
4209 tag++)
4210 if (jacobianBlockNeighborUsed(tag, i, j) && _sys.hasMatrix(tag))
4211 {
4213 *ivar,
4214 *jvar,
4215 ivar->dofIndices(),
4216 jvar->dofIndicesNeighbor(),
4217 tag);
4219 *ivar,
4220 *jvar,
4221 ivar->dofIndicesNeighbor(),
4222 jvar->dofIndices(),
4223 tag);
4226 *ivar,
4227 *jvar,
4228 ivar->dofIndicesNeighbor(),
4229 jvar->dofIndicesNeighbor(),
4230 tag);
4231 }
4232 }
4233}
4234
4235void
4237{
4238 for (const auto & it : _cm_ff_entry)
4239 {
4240 auto ivar = it.first;
4241 auto jvar = it.second;
4242 auto i = ivar->number();
4243 auto j = jvar->number();
4244 for (MooseIndex(_jacobian_block_lower_used) tag = 0; tag < _jacobian_block_lower_used.size();
4245 tag++)
4246 if (jacobianBlockLowerUsed(tag, i, j) && _sys.hasMatrix(tag))
4247 {
4249 *ivar,
4250 *jvar,
4251 ivar->dofIndicesLower(),
4252 jvar->dofIndicesLower(),
4253 tag);
4254
4256 *ivar,
4257 *jvar,
4258 ivar->dofIndicesLower(),
4259 jvar->dofIndices(),
4260 tag);
4261
4263 *ivar,
4264 *jvar,
4265 ivar->dofIndicesLower(),
4266 jvar->dofIndicesNeighbor(),
4267 tag);
4268
4270 *ivar,
4271 *jvar,
4272 ivar->dofIndices(),
4273 jvar->dofIndicesLower(),
4274 tag);
4275
4278 *ivar,
4279 *jvar,
4280 ivar->dofIndices(),
4281 jvar->dofIndices(),
4282 tag);
4283
4285 *ivar,
4286 *jvar,
4287 ivar->dofIndices(),
4288 jvar->dofIndicesNeighbor(),
4289 tag);
4290
4292 *ivar,
4293 *jvar,
4294 ivar->dofIndicesNeighbor(),
4295 jvar->dofIndicesLower(),
4296 tag);
4297
4299 *ivar,
4300 *jvar,
4301 ivar->dofIndicesNeighbor(),
4302 jvar->dofIndices(),
4303 tag);
4304
4306 *ivar,
4307 *jvar,
4308 ivar->dofIndicesNeighbor(),
4309 jvar->dofIndicesNeighbor(),
4310 tag);
4311 }
4312 }
4313}
4314
4315void
4316Assembly::addJacobianBlockTags(SparseMatrix<Number> & jacobian,
4317 unsigned int ivar,
4318 unsigned int jvar,
4319 const DofMap & dof_map,
4320 std::vector<dof_id_type> & dof_indices,
4322 const std::set<TagID> & tags)
4323{
4324 for (auto tag : tags)
4325 addJacobianBlock(jacobian, ivar, jvar, dof_map, dof_indices, GlobalDataKey{}, tag);
4326}
4327
4328void
4329Assembly::addJacobianBlock(SparseMatrix<Number> & jacobian,
4330 unsigned int ivar,
4331 unsigned int jvar,
4332 const DofMap & dof_map,
4333 std::vector<dof_id_type> & dof_indices,
4334 GlobalDataKey,
4335 TagID tag)
4336{
4337 if (dof_indices.size() == 0)
4338 return;
4339 if (!(*_cm)(ivar, jvar))
4340 return;
4341
4342 auto & iv = _sys.getVariable(_tid, ivar);
4343 auto & jv = _sys.getVariable(_tid, jvar);
4344 auto & scaling_factor = iv.arrayScalingFactor();
4345
4346 const unsigned int ivn = iv.number();
4347 const unsigned int jvn = jv.number();
4348 auto & ke = jacobianBlock(ivn, jvn, LocalDataKey{}, tag);
4349
4350 // It is guaranteed by design iv.number <= ivar since iv is obtained
4351 // through SystemBase::getVariable with ivar.
4352 // Most of times ivar will just be equal to iv.number except for array variables,
4353 // where ivar could be a number for a component of an array variable but calling
4354 // getVariable will return the array variable that has the number of the 0th component.
4355 // It is the same for jvar.
4356 const unsigned int i = ivar - ivn;
4357 const unsigned int j = jvar - jvn;
4358
4359 // DoF indices are independently given
4360 auto di = dof_indices;
4361 auto dj = dof_indices;
4362
4363 auto indof = di.size();
4364 auto jndof = dj.size();
4365
4366 unsigned int jj = j;
4367 if (ivar == jvar && _component_block_diagonal[ivn])
4368 jj = 0;
4369
4370 auto sub = ke.sub_matrix(i * indof, indof, jj * jndof, jndof);
4371 // If we're computing the jacobian for automatically scaling variables we do not want to
4372 // constrain the element matrix because it introduces 1s on the diagonal for the constrained
4373 // dofs
4375 dof_map.constrain_element_matrix(sub, di, dj, false);
4376
4377 if (scaling_factor[i] != 1.0)
4378 sub *= scaling_factor[i];
4379
4380 jacobian.add_matrix(sub, di, dj);
4381}
4382
4383void
4384Assembly::addJacobianBlockNonlocal(SparseMatrix<Number> & jacobian,
4385 const unsigned int ivar,
4386 const unsigned int jvar,
4387 const DofMap & dof_map,
4388 const std::vector<dof_id_type> & idof_indices,
4389 const std::vector<dof_id_type> & jdof_indices,
4391 const TagID tag)
4392{
4393 if (idof_indices.size() == 0 || jdof_indices.size() == 0)
4394 return;
4395 if (jacobian.n() == 0 || jacobian.m() == 0)
4396 return;
4397 if (!(*_cm)(ivar, jvar))
4398 return;
4399
4400 auto & iv = _sys.getVariable(_tid, ivar);
4401 auto & jv = _sys.getVariable(_tid, jvar);
4402 auto & scaling_factor = iv.arrayScalingFactor();
4403
4404 const unsigned int ivn = iv.number();
4405 const unsigned int jvn = jv.number();
4406 auto & keg = jacobianBlockNonlocal(ivn, jvn, LocalDataKey{}, tag);
4407
4408 // It is guaranteed by design iv.number <= ivar since iv is obtained
4409 // through SystemBase::getVariable with ivar.
4410 // Most of times ivar will just be equal to iv.number except for array variables,
4411 // where ivar could be a number for a component of an array variable but calling
4412 // getVariable will return the array variable that has the number of the 0th component.
4413 // It is the same for jvar.
4414 const unsigned int i = ivar - ivn;
4415 const unsigned int j = jvar - jvn;
4416
4417 // DoF indices are independently given
4418 auto di = idof_indices;
4419 auto dj = jdof_indices;
4420
4421 auto indof = di.size();
4422 auto jndof = dj.size();
4423
4424 unsigned int jj = j;
4425 if (ivar == jvar && _component_block_diagonal[ivn])
4426 jj = 0;
4427
4428 auto sub = keg.sub_matrix(i * indof, indof, jj * jndof, jndof);
4429 // If we're computing the jacobian for automatically scaling variables we do not want to
4430 // constrain the element matrix because it introduces 1s on the diagonal for the constrained
4431 // dofs
4433 dof_map.constrain_element_matrix(sub, di, dj, false);
4434
4435 if (scaling_factor[i] != 1.0)
4436 sub *= scaling_factor[i];
4437
4438 jacobian.add_matrix(sub, di, dj);
4439}
4440
4441void
4442Assembly::addJacobianBlockNonlocalTags(SparseMatrix<Number> & jacobian,
4443 const unsigned int ivar,
4444 const unsigned int jvar,
4445 const DofMap & dof_map,
4446 const std::vector<dof_id_type> & idof_indices,
4447 const std::vector<dof_id_type> & jdof_indices,
4449 const std::set<TagID> & tags)
4450{
4451 for (auto tag : tags)
4453 jacobian, ivar, jvar, dof_map, idof_indices, jdof_indices, GlobalDataKey{}, tag);
4454}
4455
4456void
4457Assembly::addJacobianNeighbor(SparseMatrix<Number> & jacobian,
4458 const unsigned int ivar,
4459 const unsigned int jvar,
4460 const DofMap & dof_map,
4461 std::vector<dof_id_type> & dof_indices,
4462 std::vector<dof_id_type> & neighbor_dof_indices,
4463 GlobalDataKey,
4464 const TagID tag)
4465{
4466 if (dof_indices.size() == 0 && neighbor_dof_indices.size() == 0)
4467 return;
4468 if (!(*_cm)(ivar, jvar))
4469 return;
4470
4471 auto & iv = _sys.getVariable(_tid, ivar);
4472 auto & jv = _sys.getVariable(_tid, jvar);
4473 auto & scaling_factor = iv.arrayScalingFactor();
4474
4475 const unsigned int ivn = iv.number();
4476 const unsigned int jvn = jv.number();
4477 auto & ken = jacobianBlockNeighbor(Moose::ElementNeighbor, ivn, jvn, LocalDataKey{}, tag);
4478 auto & kne = jacobianBlockNeighbor(Moose::NeighborElement, ivn, jvn, LocalDataKey{}, tag);
4479 auto & knn = jacobianBlockNeighbor(Moose::NeighborNeighbor, ivn, jvn, LocalDataKey{}, tag);
4480
4481 // It is guaranteed by design iv.number <= ivar since iv is obtained
4482 // through SystemBase::getVariable with ivar.
4483 // Most of times ivar will just be equal to iv.number except for array variables,
4484 // where ivar could be a number for a component of an array variable but calling
4485 // getVariable will return the array variable that has the number of the 0th component.
4486 // It is the same for jvar.
4487 const unsigned int i = ivar - ivn;
4488 const unsigned int j = jvar - jvn;
4489 // DoF indices are independently given
4490 auto dc = dof_indices;
4491 auto dn = neighbor_dof_indices;
4492 auto cndof = dc.size();
4493 auto nndof = dn.size();
4494
4495 unsigned int jj = j;
4496 if (ivar == jvar && _component_block_diagonal[ivn])
4497 jj = 0;
4498
4499 auto suben = ken.sub_matrix(i * cndof, cndof, jj * nndof, nndof);
4500 auto subne = kne.sub_matrix(i * nndof, nndof, jj * cndof, cndof);
4501 auto subnn = knn.sub_matrix(i * nndof, nndof, jj * nndof, nndof);
4502
4503 // If we're computing the jacobian for automatically scaling variables we do not want to
4504 // constrain the element matrix because it introduces 1s on the diagonal for the constrained
4505 // dofs
4507 {
4508 dof_map.constrain_element_matrix(suben, dc, dn, false);
4509 dof_map.constrain_element_matrix(subne, dn, dc, false);
4510 dof_map.constrain_element_matrix(subnn, dn, dn, false);
4511 }
4512
4513 if (scaling_factor[i] != 1.0)
4514 {
4515 suben *= scaling_factor[i];
4516 subne *= scaling_factor[i];
4517 subnn *= scaling_factor[i];
4518 }
4519
4520 jacobian.add_matrix(suben, dc, dn);
4521 jacobian.add_matrix(subne, dn, dc);
4522 jacobian.add_matrix(subnn, dn, dn);
4523}
4524
4525void
4526Assembly::addJacobianNeighborTags(SparseMatrix<Number> & jacobian,
4527 const unsigned int ivar,
4528 const unsigned int jvar,
4529 const DofMap & dof_map,
4530 std::vector<dof_id_type> & dof_indices,
4531 std::vector<dof_id_type> & neighbor_dof_indices,
4533 const std::set<TagID> & tags)
4534{
4535 for (const auto tag : tags)
4537 jacobian, ivar, jvar, dof_map, dof_indices, neighbor_dof_indices, GlobalDataKey{}, tag);
4538}
4539
4540void
4542{
4543 for (const auto & it : _cm_ss_entry)
4544 addJacobianCoupledVarPair(*it.first, *it.second);
4545}
4546
4547void
4549{
4550 for (const auto & it : _cm_sf_entry)
4551 if (it.first->number() == ivar)
4552 addJacobianCoupledVarPair(*it.first, *it.second);
4553}
4554
4555void
4557 numeric_index_type i, numeric_index_type j, Real value, LocalDataKey, TagID tag)
4558{
4559 _cached_jacobian_rows[tag].push_back(i);
4560 _cached_jacobian_cols[tag].push_back(j);
4561 _cached_jacobian_values[tag].push_back(value);
4562}
4563
4564void
4565Assembly::cacheJacobian(numeric_index_type i,
4566 numeric_index_type j,
4567 Real value,
4569 const std::set<TagID> & tags)
4570{
4571 for (auto tag : tags)
4572 if (_sys.hasMatrix(tag))
4573 cacheJacobian(i, j, value, LocalDataKey{}, tag);
4574}
4575
4576void
4578{
4579 for (MooseIndex(_cached_jacobian_rows) tag = 0; tag < _cached_jacobian_rows.size(); tag++)
4580 if (_sys.hasMatrix(tag))
4581 {
4582 // First zero the rows (including the diagonals) to prepare for
4583 // setting the cached values.
4585
4586 // TODO: Use SparseMatrix::set_values() for efficiency
4587 for (MooseIndex(_cached_jacobian_values) i = 0; i < _cached_jacobian_values[tag].size(); ++i)
4589 _cached_jacobian_cols[tag][i],
4590 _cached_jacobian_values[tag][i]);
4591 }
4592
4594}
4595
4596void
4598{
4599 for (MooseIndex(_cached_jacobian_rows) tag = 0; tag < _cached_jacobian_rows.size(); tag++)
4600 if (_sys.hasMatrix(tag))
4602
4604}
4605
4606void
4608{
4609 for (MooseIndex(_cached_jacobian_rows) tag = 0; tag < _cached_jacobian_rows.size(); tag++)
4610 {
4611 _cached_jacobian_rows[tag].clear();
4612 _cached_jacobian_cols[tag].clear();
4613 _cached_jacobian_values[tag].clear();
4614 }
4615}
4616
4617void
4619{
4620 mooseAssert(_xfem != nullptr, "This function should not be called if xfem is inactive");
4621
4623 return;
4624
4625 MooseArray<Real> xfem_weight_multipliers;
4626 if (_xfem->getXFEMWeights(xfem_weight_multipliers, elem, _current_qrule, _current_q_points))
4627 {
4628 mooseAssert(xfem_weight_multipliers.size() == _current_JxW.size(),
4629 "Size of weight multipliers in xfem doesn't match number of quadrature points");
4630 for (unsigned i = 0; i < xfem_weight_multipliers.size(); i++)
4631 _current_JxW[i] = _current_JxW[i] * xfem_weight_multipliers[i];
4632
4633 xfem_weight_multipliers.release();
4634 }
4635}
4636
4637void
4638Assembly::modifyFaceWeightsDueToXFEM(const Elem * elem, unsigned int side)
4639{
4640 mooseAssert(_xfem != nullptr, "This function should not be called if xfem is inactive");
4641
4643 return;
4644
4645 MooseArray<Real> xfem_face_weight_multipliers;
4646 if (_xfem->getXFEMFaceWeights(
4647 xfem_face_weight_multipliers, elem, _current_qrule_face, _current_q_points_face, side))
4648 {
4649 mooseAssert(xfem_face_weight_multipliers.size() == _current_JxW_face.size(),
4650 "Size of weight multipliers in xfem doesn't match number of quadrature points");
4651 for (unsigned i = 0; i < xfem_face_weight_multipliers.size(); i++)
4652 _current_JxW_face[i] = _current_JxW_face[i] * xfem_face_weight_multipliers[i];
4653
4654 xfem_face_weight_multipliers.release();
4655 }
4656}
4657
4658void
4659Assembly::modifyArbitraryWeights(const std::vector<Real> & weights)
4660{
4661 mooseAssert(_current_qrule == _current_qrule_arbitrary, "Rule should be arbitrary");
4662 mooseAssert(weights.size() == _current_physical_points.size(), "Size mismatch");
4663
4664 for (MooseIndex(weights.size()) i = 0; i < weights.size(); ++i)
4665 _current_JxW[i] = weights[i];
4666}
4667
4668template <>
4670Assembly::fePhi<VectorValue<Real>>(FEType type) const
4671{
4672 buildVectorFE(type);
4673 return _vector_fe_shape_data[type]->_phi;
4674}
4675
4676template <>
4678Assembly::feGradPhi<VectorValue<Real>>(FEType type) const
4679{
4680 buildVectorFE(type);
4681 return _vector_fe_shape_data[type]->_grad_phi;
4682}
4683
4684template <>
4686Assembly::feSecondPhi<VectorValue<Real>>(FEType type) const
4687{
4688 _need_second_derivative.insert(type);
4689 buildVectorFE(type);
4690 return _vector_fe_shape_data[type]->_second_phi;
4691}
4692
4693template <>
4695Assembly::fePhiLower<VectorValue<Real>>(FEType type) const
4696{
4697 buildVectorLowerDFE(type);
4698 return _vector_fe_shape_data_lower[type]->_phi;
4699}
4700
4701template <>
4703Assembly::feDualPhiLower<VectorValue<Real>>(FEType type) const
4704{
4705 buildVectorDualLowerDFE(type);
4706 return _vector_fe_shape_data_dual_lower[type]->_phi;
4707}
4708
4709template <>
4711Assembly::feGradPhiLower<VectorValue<Real>>(FEType type) const
4712{
4713 buildVectorLowerDFE(type);
4714 return _vector_fe_shape_data_lower[type]->_grad_phi;
4715}
4716
4717template <>
4719Assembly::feGradDualPhiLower<VectorValue<Real>>(FEType type) const
4720{
4721 buildVectorDualLowerDFE(type);
4722 return _vector_fe_shape_data_dual_lower[type]->_grad_phi;
4723}
4724
4725template <>
4727Assembly::fePhiFace<VectorValue<Real>>(FEType type) const
4728{
4729 buildVectorFaceFE(type);
4730 return _vector_fe_shape_data_face[type]->_phi;
4731}
4732
4733template <>
4735Assembly::feGradPhiFace<VectorValue<Real>>(FEType type) const
4736{
4737 buildVectorFaceFE(type);
4738 return _vector_fe_shape_data_face[type]->_grad_phi;
4739}
4740
4741template <>
4743Assembly::feSecondPhiFace<VectorValue<Real>>(FEType type) const
4744{
4745 _need_second_derivative.insert(type);
4746 buildVectorFaceFE(type);
4747
4748 // If we're building for a face we probably need to build for a
4749 // neighbor while _need_second_derivative is set;
4750 // onInterface/reinitNeighbor/etc don't distinguish
4751 buildVectorFaceNeighborFE(type);
4752
4753 return _vector_fe_shape_data_face[type]->_second_phi;
4754}
4755
4756template <>
4758Assembly::fePhiNeighbor<VectorValue<Real>>(FEType type) const
4759{
4760 buildVectorNeighborFE(type);
4761 return _vector_fe_shape_data_neighbor[type]->_phi;
4762}
4763
4764template <>
4766Assembly::feGradPhiNeighbor<VectorValue<Real>>(FEType type) const
4767{
4768 buildVectorNeighborFE(type);
4769 return _vector_fe_shape_data_neighbor[type]->_grad_phi;
4770}
4771
4772template <>
4774Assembly::feSecondPhiNeighbor<VectorValue<Real>>(FEType type) const
4775{
4776 _need_second_derivative_neighbor.insert(type);
4777 buildVectorNeighborFE(type);
4778 return _vector_fe_shape_data_neighbor[type]->_second_phi;
4779}
4780
4781template <>
4783Assembly::fePhiFaceNeighbor<VectorValue<Real>>(FEType type) const
4784{
4785 buildVectorFaceNeighborFE(type);
4786 return _vector_fe_shape_data_face_neighbor[type]->_phi;
4787}
4788
4789template <>
4791Assembly::feGradPhiFaceNeighbor<VectorValue<Real>>(FEType type) const
4792{
4793 buildVectorFaceNeighborFE(type);
4794 return _vector_fe_shape_data_face_neighbor[type]->_grad_phi;
4795}
4796
4797template <>
4799Assembly::feSecondPhiFaceNeighbor<VectorValue<Real>>(FEType type) const
4800{
4801 _need_second_derivative_neighbor.insert(type);
4802 buildVectorFaceNeighborFE(type);
4803 return _vector_fe_shape_data_face_neighbor[type]->_second_phi;
4804}
4805
4806template <>
4808Assembly::feCurlPhi<VectorValue<Real>>(FEType type) const
4809{
4810 _need_curl.insert(type);
4811 buildVectorFE(type);
4812 return _vector_fe_shape_data[type]->_curl_phi;
4813}
4814
4815template <>
4817Assembly::feCurlPhiFace<VectorValue<Real>>(FEType type) const
4818{
4819 _need_curl.insert(type);
4820 buildVectorFaceFE(type);
4821
4822 // If we're building for a face we probably need to build for a
4823 // neighbor while _need_curl is set;
4824 // onInterface/reinitNeighbor/etc don't distinguish
4825 buildVectorFaceNeighborFE(type);
4826
4827 return _vector_fe_shape_data_face[type]->_curl_phi;
4828}
4829
4830template <>
4832Assembly::feCurlPhiNeighbor<VectorValue<Real>>(FEType type) const
4833{
4834 _need_curl.insert(type);
4835 buildVectorNeighborFE(type);
4836 return _vector_fe_shape_data_neighbor[type]->_curl_phi;
4837}
4838
4839template <>
4841Assembly::feCurlPhiFaceNeighbor<VectorValue<Real>>(FEType type) const
4842{
4843 _need_curl.insert(type);
4844 buildVectorFaceNeighborFE(type);
4845
4846 return _vector_fe_shape_data_face_neighbor[type]->_curl_phi;
4847}
4848
4849template <>
4851Assembly::feDivPhi<VectorValue<Real>>(FEType type) const
4852{
4853 _need_div.insert(type);
4854 buildVectorFE(type);
4855 return _vector_fe_shape_data[type]->_div_phi;
4856}
4857
4858template <>
4860Assembly::feDivPhiFace<VectorValue<Real>>(FEType type) const
4861{
4862 _need_face_div.insert(type);
4863 buildVectorFaceFE(type);
4864
4865 // If we're building for a face we probably need to build for a
4866 // neighbor while _need_face_div is set;
4867 // onInterface/reinitNeighbor/etc don't distinguish
4868 buildVectorFaceNeighborFE(type);
4869
4870 return _vector_fe_shape_data_face[type]->_div_phi;
4871}
4872
4873template <>
4875Assembly::feDivPhiNeighbor<VectorValue<Real>>(FEType type) const
4876{
4877 _need_neighbor_div.insert(type);
4878 buildVectorNeighborFE(type);
4879 return _vector_fe_shape_data_neighbor[type]->_div_phi;
4880}
4881
4882template <>
4884Assembly::feDivPhiFaceNeighbor<VectorValue<Real>>(FEType type) const
4885{
4886 _need_face_neighbor_div.insert(type);
4887 buildVectorFaceNeighborFE(type);
4888 return _vector_fe_shape_data_face_neighbor[type]->_div_phi;
4889}
4890
4891const MooseArray<ADReal> &
4893{
4894 _calculate_curvatures = true;
4895 _need_ad_face_map = true;
4896 // Must prerequest the second derivatives. Sadly because there is only one
4897 // _need_second_derivative map for both volumetric and face FE objects we must request both here
4898 feSecondPhi<Real>(_helper_type);
4899 feSecondPhiFace<Real>(_helper_type);
4900 return _ad_curvatures;
4901}
4902
4903void
4905{
4906 for (unsigned int dim = 0; dim <= _mesh_dimension; dim++)
4907 {
4908 _holder_fe_helper[dim]->get_phi();
4909 _holder_fe_helper[dim]->get_dphi();
4910 _holder_fe_helper[dim]->get_xyz();
4911 _holder_fe_helper[dim]->get_JxW();
4912
4913 _holder_fe_face_helper[dim]->get_phi();
4914 _holder_fe_face_helper[dim]->get_dphi();
4915 _holder_fe_face_helper[dim]->get_xyz();
4916 _holder_fe_face_helper[dim]->get_JxW();
4917 _holder_fe_face_helper[dim]->get_normals();
4918
4921 _holder_fe_face_neighbor_helper[dim]->get_normals();
4922
4923 _holder_fe_neighbor_helper[dim]->get_xyz();
4924 _holder_fe_neighbor_helper[dim]->get_JxW();
4925 }
4926
4927 for (unsigned int dim = 0; dim < _mesh_dimension; dim++)
4928 {
4929 // We need these computations in order to compute correct lower-d element volumes in
4930 // curvilinear coordinates
4931 _holder_fe_lower_helper[dim]->get_xyz();
4932 _holder_fe_lower_helper[dim]->get_JxW();
4933 }
4934}
4935
4936void
4938{
4940 // Already performed tasks for p-refinement
4941 return;
4942
4943 const auto helper_type = _helper_type;
4944 auto process_fe_and_helpers = [&helper_type](auto & unique_helper_container,
4945 auto & helper_container,
4946 const unsigned int num_dimensionalities,
4947 const bool user_added_helper_type,
4948 auto & fe_container)
4949 {
4950 unique_helper_container.resize(num_dimensionalities);
4951 for (const auto dim : make_range(num_dimensionalities))
4952 {
4953 auto & unique_helper = unique_helper_container[dim];
4954 unique_helper = FEGenericBase<Real>::build(dim, helper_type);
4955 // don't participate in p-refinement
4956 unique_helper->add_p_level_in_reinit(false);
4957 helper_container[dim] = unique_helper.get();
4958
4959 // If the user did not request the helper type then we should erase the original helper FE
4960 // from the ordinary FE container. The unique helper above replaces it for helper use.
4961 if (!user_added_helper_type)
4962 {
4963 auto & fe_container_dim = libmesh_map_find(fe_container, dim);
4964 auto fe_it = fe_container_dim.find(helper_type);
4965 mooseAssert(fe_it != fe_container_dim.end(), "We should have the helper type");
4966 delete fe_it->second;
4967 fe_container_dim.erase(fe_it);
4968 }
4969 }
4970 };
4971
4972 // Handle scalar field families
4973 process_fe_and_helpers(_unique_fe_helper,
4975 _mesh_dimension + 1,
4977 _fe);
4978 process_fe_and_helpers(_unique_fe_face_helper,
4980 _mesh_dimension + 1,
4982 _fe_face);
4983 process_fe_and_helpers(_unique_fe_face_neighbor_helper,
4985 _mesh_dimension + 1,
4988 process_fe_and_helpers(_unique_fe_neighbor_helper,
4990 _mesh_dimension + 1,
4992 _fe_neighbor);
4993 process_fe_and_helpers(_unique_fe_lower_helper,
4997 _fe_lower);
4998
5000
5002}
5003
5005 SubdomainID sub_id,
5006 const Point & point,
5007 Real & factor,
5008 SubdomainID neighbor_sub_id);
5010 SubdomainID sub_id,
5011 const ADPoint & point,
5012 ADReal & factor,
5013 SubdomainID neighbor_sub_id);
5015 SubdomainID sub_id,
5016 const Point & point,
5017 Real & factor,
5018 SubdomainID neighbor_sub_id);
5020 SubdomainID sub_id,
5021 const ADPoint & point,
5022 ADReal & factor,
5023 SubdomainID neighbor_sub_id);
5024
5025template <>
5027Assembly::genericQPoints<false>() const
5028{
5029 return qPoints();
5030}
5031
5032template <>
5034Assembly::genericQPoints<true>() const
5035{
5036 return adQPoints();
5037}
DualNumber< Real, DNDerivativeType, true > ADReal
template void coordTransformFactor< ADPoint, ADReal >(const SubProblem &s, SubdomainID sub_id, const ADPoint &point, ADReal &factor, SubdomainID neighbor_sub_id)
void coordTransformFactor(const SubProblem &s, const SubdomainID sub_id, const P &point, C &factor, const SubdomainID neighbor_sub_id)
Computes a conversion multiplier for use when computing integraals for the current coordinate system ...
Definition Assembly.C:41
template void coordTransformFactor< Point, Real >(const SubProblem &s, SubdomainID sub_id, const Point &point, Real &factor, SubdomainID neighbor_sub_id)
void coordTransformFactor(const SubProblem &s, SubdomainID sub_id, const P &point, C &factor, SubdomainID neighbor_sub_id=libMesh::Elem::invalid_subdomain_id)
Computes a conversion multiplier for use when computing integraals for the current coordinate system ...
Definition Assembly.C:41
subdomain_id_type SubdomainID
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
OutputTools< Real >::VariablePhiValue VariablePhiValue
Definition MooseTypes.h:353
OutputTools< Real >::VariablePhiCurl VariablePhiCurl
Definition MooseTypes.h:356
unsigned int TagID
Definition MooseTypes.h:238
OutputTools< Real >::VariablePhiGradient VariablePhiGradient
Definition MooseTypes.h:354
typename OutputTools< typename Moose::ADType< T >::type >::VariablePhiGradient ADTemplateVariablePhiGradient
Definition MooseTypes.h:692
unsigned int THREAD_ID
Definition MooseTypes.h:237
OutputTools< Real >::VariablePhiSecond VariablePhiSecond
Definition MooseTypes.h:355
OutputTools< Real >::VariablePhiDivergence VariablePhiDivergence
Definition MooseTypes.h:357
unsigned int count
Definition MortarUtils.C:53
std::array< Real, 2 > values
Definition MortarUtils.C:52
char ** vars
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
unsigned int n_vars
unsigned int dim
Implements a fake quadrature rule where you can specify the locations (in the reference domain) of th...
void setWeights(const std::vector< libMesh::Real > &weights)
Set the quadrature weights.
void setPoints(const std::vector< libMesh::Point > &points)
Set the quadrature points.
VariablePhiValue _phi
Definition Assembly.h:2761
VariablePhiGradient _grad_phi
Definition Assembly.h:2762
VariablePhiSecond _second_phi
Definition Assembly.h:2763
Key structure for APIs manipulating global vectors/matrices.
Definition Assembly.h:847
Key structure for APIs adding/caching local element residuals/Jacobians.
Definition Assembly.h:865
VectorVariablePhiValue _phi
Definition Assembly.h:2771
VectorVariablePhiGradient _grad_phi
Definition Assembly.h:2772
VectorVariablePhiSecond _second_phi
Definition Assembly.h:2773
VectorVariablePhiCurl _curl_phi
Definition Assembly.h:2774
VectorVariablePhiDivergence _div_phi
Definition Assembly.h:2775
DenseMatrix< Number > & jacobianBlockNonlocal(unsigned int ivar, unsigned int jvar, LocalDataKey, TagID tag)
Get local Jacobian block from non-local contribution for a pair of variables and a tag.
Definition Assembly.h:1155
std::vector< std::vector< std::vector< DenseMatrix< Number > > > > _sub_Kll
dlower/dlower
Definition Assembly.h:2703
std::vector< bool > _component_block_diagonal
An flag array Indiced by variable index to show if there is no component-wise coupling for the variab...
Definition Assembly.h:2846
void cacheJacobianNonlocal(GlobalDataKey)
Takes the values that are currently in _sub_Keg and appends them to the cached values.
Definition Assembly.C:4176
SystemBase & _sys
Definition Assembly.h:2326
std::map< unsigned int, FEBase * > _holder_fe_lower_helper
helper object for transforming coordinates for lower dimensional element quadrature points
Definition Assembly.h:2574
const VariablePhiSecond & secondPhiNeighbor(const MooseVariableField< Real > &) const
Definition Assembly.h:1358
std::vector< std::pair< MooseVariableScalar *, MooseVariableFieldBase * > > _cm_sf_entry
Entries in the coupling matrix for scalar variables vs field variables.
Definition Assembly.h:2349
void addJacobian(GlobalDataKey)
Adds all local Jacobian to the global Jacobian matrices.
Definition Assembly.C:3958
void jacobianBlockLowerUsed(TagID tag, unsigned int ivar, unsigned int jvar, bool used)
Sets whether or not lower Jacobian coupling between ivar and jvar is used to the value used.
Definition Assembly.h:2289
void addResidualScalar(GlobalDataKey, const std::vector< VectorTag > &vector_tags)
Add residuals of all scalar variables for a set of tags onto the global residual vectors associated w...
Definition Assembly.C:3485
std::map< FEType, std::unique_ptr< VectorFEShapeData > > _vector_fe_shape_data
Shape function values, gradients, second derivatives for each vector FE type.
Definition Assembly.h:2787
MooseArray< Point > _current_q_points
The current list of quadrature points.
Definition Assembly.h:2432
const std::vector< Real > * _JxW_msm
A JxW for working on mortar segement elements.
Definition Assembly.h:2593
std::vector< std::vector< std::vector< DenseMatrix< Number > > > > _sub_Kee
Definition Assembly.h:2693
std::set< FEType > _need_face_neighbor_div
Definition Assembly.h:2906
void prepareLowerD()
Prepare the Jacobians and residuals for a lower dimensional element.
Definition Assembly.C:2951
void modifyWeightsDueToXFEM(const Elem *elem)
Update the integration weights for XFEM partial elements.
Definition Assembly.C:4618
void reinitFVFace(const FaceInfo &fi)
Definition Assembly.C:1913
std::vector< VectorValue< ADReal > > _ad_elem_node_points
The positions of the nodes of the element passed to computeADElemNodePoints.
Definition Assembly.h:2886
std::vector< std::vector< DenseVector< Number > > > _sub_Re
Definition Assembly.h:2674
void cacheResidualNeighbor(GlobalDataKey, const std::vector< VectorTag > &tags)
Takes the values that are currently in _sub_Rn of all field variables and appends them to the cached ...
Definition Assembly.C:3543
void reinitFE(const Elem *elem)
Just an internal helper function to reinit the volume FE objects.
Definition Assembly.C:797
DenseMatrix< Number > _element_matrix
A working matrix to avoid repeated heap allocations when caching Jacobians that must have libMesh-lev...
Definition Assembly.h:2925
const VariablePhiValue & phiFace() const
Definition Assembly.h:1338
void createQRules(QuadratureType type, Order order, Order volume_order, Order face_order, SubdomainID block, bool allow_negative_qweights=true)
Creates block-specific volume, face and arbitrary qrules based on the orders and the flag of whether ...
Definition Assembly.C:654
MooseArray< Real > _curvatures
Definition Assembly.h:2877
std::vector< std::unique_ptr< FEBase > > _unique_fe_lower_helper
Definition Assembly.h:2387
MooseArray< Real > _coord_neighbor
The current coordinate transformation coefficients.
Definition Assembly.h:2585
const bool _displaced
Definition Assembly.h:2329
void reinitFEFaceNeighbor(const Elem *neighbor, const std::vector< Point > &reference_points)
Definition Assembly.C:1629
void reinitFENeighbor(const Elem *neighbor, const std::vector< Point > &reference_points)
Definition Assembly.C:1688
void prepareVariableNonlocal(MooseVariableFieldBase *var)
Definition Assembly.C:2883
void prepareBlock(unsigned int ivar, unsigned jvar, const std::vector< dof_id_type > &dof_indices)
Definition Assembly.C:3003
std::vector< ADReal > _ad_dzetady_map
Definition Assembly.h:2871
libMesh::QBase * _current_qrule_face
quadrature rule used on faces
Definition Assembly.h:2536
bool _block_diagonal_matrix
Will be true if our preconditioning matrix is a block-diagonal matrix. Which means that we can take s...
Definition Assembly.h:2843
virtual ~Assembly()
Definition Assembly.C:187
std::vector< std::vector< std::vector< unsigned char > > > _jacobian_block_neighbor_used
Flag that indicates if the jacobian block for neighbor was used.
Definition Assembly.h:2358
bool _need_ad_grad_phi_face
Whether any object needs the AD face shape function gradients.
Definition Assembly.h:2802
void jacobianBlockUsed(TagID tag, unsigned int ivar, unsigned int jvar, bool used)
Sets whether or not Jacobian coupling between ivar and jvar is used to the value used.
Definition Assembly.h:2253
std::vector< Number > _ad_elem_disp_nodal_soln
Definition Assembly.h:2890
void processLocalResidual(DenseVector< Number > &res_block, std::vector< dof_id_type > &dof_indices, const std::vector< Real > &scaling_factor)
Appling scaling, constraints to the local residual block and populate the full DoF indices for array ...
Definition Assembly.C:3322
MooseArray< VectorValue< ADReal > > _ad_q_points
Definition Assembly.h:2863
std::vector< Number > _ad_elem_disp_unit_soln
Definition Assembly.h:2889
bool _current_side_volume_computed
Boolean to indicate whether current element side volumes has been computed.
Definition Assembly.h:2642
bool _need_ad_volume_map
Whether any object needs the AD element JxW, quadrature points or coordinate transformation.
Definition Assembly.h:2809
MooseArray< Real > _current_JxW_face
The current transformed jacobian weights on a face.
Definition Assembly.h:2542
const FEType _helper_type
The finite element type of the FE helper classes.
Definition Assembly.h:2372
Real _current_elem_volume
Volume of the current element.
Definition Assembly.h:2616
const VectorVariablePhiDivergence & divPhi(const MooseVariableField< RealVectorValue > &) const
Definition Assembly.h:1392
void cacheJacobianCoupledVarPair(const MooseVariableBase &ivar, const MooseVariableBase &jvar)
Caches element matrix for ivar rows and jvar columns.
Definition Assembly.C:4160
bool _building_helpers
Whether we are currently building the FE classes for the helpers.
Definition Assembly.h:2390
void addJacobianScalar(GlobalDataKey)
Add Jacobians for pairs of scalar variables into the global Jacobian matrices.
Definition Assembly.C:4541
void setVolumeQRule(libMesh::QBase *qrule, unsigned int dim)
Set the qrule to be used for volume integration.
const VariablePhiGradient & gradPhi() const
Definition Assembly.h:1330
void cacheJacobianBlockNonzero(const DenseMatrix< Number > &jac_block, const MooseVariableBase &ivar, const MooseVariableBase &jvar, const std::vector< dof_id_type > &idof_indices, const std::vector< dof_id_type > &jdof_indices, TagID tag)
Push non-zeros of a local Jacobian block with proper scaling into cache for a certain tag.
Definition Assembly.C:3766
MooseArray< Point > _current_physical_points
This will be filled up with the physical points passed into reinitAtPhysical() if it is called....
Definition Assembly.h:2660
void addJacobianLowerD(GlobalDataKey)
Add portions of the Jacobian of LowerLower, LowerSecondary, and SecondaryLower for boundary condition...
Definition Assembly.C:4109
libMesh::QBase * _current_qrule
The current current quadrature rule being used (could be either volumetric or arbitrary - for dirac k...
Definition Assembly.h:2424
const MooseArray< Point > & qPoints() const
Returns the reference to the quadrature points.
Definition Assembly.h:250
MooseArray< VectorValue< ADReal > > _ad_normals
Definition Assembly.h:2875
void addJacobianOffDiagScalar(unsigned int ivar, GlobalDataKey)
Add Jacobians for a scalar variables with all other field variables into the global Jacobian matrices...
Definition Assembly.C:4548
void modifyArbitraryWeights(const std::vector< Real > &weights)
Modify the weights when using the arbitrary quadrature rule.
Definition Assembly.C:4659
void computeCurrentFaceVolume()
Definition Assembly.C:1829
const VariablePhiGradient & gradPhiFace() const
Definition Assembly.h:1340
bool _need_JxW_neighbor
Flag to indicate that JxW_neighbor is needed.
Definition Assembly.h:2581
bool _user_added_fe_of_helper_type
Whether user code requested a FEType the same as our _helper_type.
Definition Assembly.h:2375
std::map< FEType, ADTemplateVariablePhiGradient< RealVectorValue > > _ad_vector_grad_phi_data
Definition Assembly.h:2795
std::map< unsigned int, std::map< FEType, FEVectorBase * > > _vector_fe
Each dimension's actual vector fe objects indexed on type.
Definition Assembly.h:2418
MooseArray< ADReal > _ad_JxW_face
Definition Assembly.h:2874
bool _calculate_xyz
Definition Assembly.h:2892
const VariablePhiValue & phi() const
Definition Assembly.h:1322
void buildFaceNeighborFE(FEType type) const
Build FEs for a neighbor face with a type.
Definition Assembly.C:346
SubdomainID _current_subdomain_id
The current subdomain ID.
Definition Assembly.h:2612
std::map< FEType, std::unique_ptr< VectorFEShapeData > > _vector_fe_shape_data_face
Definition Assembly.h:2788
const libMesh::CouplingMatrix & _nonlocal_cm
Definition Assembly.h:2333
Real _current_neighbor_volume
Volume of the current neighbor.
Definition Assembly.h:2634
bool _need_neighbor_lower_d_elem_volume
Whether we need to compute the neighboring lower dimensional element volume.
Definition Assembly.h:2653
Moose::CoordinateSystemType _coord_type
The coordinate system.
Definition Assembly.h:2436
void reinitNeighborFaceRef(const Elem *neighbor_elem, unsigned int neighbor_side, Real tolerance, const std::vector< Point > *const pts, const std::vector< Real > *const weights=nullptr)
Reinitialize FE data for the given neighbor_element on the given side with a given set of reference p...
Definition Assembly.C:2273
std::map< FEType, FEBase * > _current_fe_neighbor
The "neighbor" fe object that matches the current elem.
Definition Assembly.h:2400
std::map< unsigned int, std::map< FEType, FEBase * > > _fe_lower
FE objects for lower dimensional elements.
Definition Assembly.h:2570
std::vector< std::vector< DenseVector< Number > > > _sub_Rn
Definition Assembly.h:2675
void buildVectorNeighborFE(FEType type) const
Build Vector FEs for a neighbor with a type.
Definition Assembly.C:545
std::vector< Eigen::Map< RealDIMValue > > _mapped_normals
Mapped normals.
Definition Assembly.h:2546
const libMesh::DofMap & _dof_map
DOF map.
Definition Assembly.h:2362
const VariablePhiSecond & secondPhiFace(const MooseVariableField< Real > &) const
Definition Assembly.h:1345
void setFaceQRule(libMesh::QBase *qrule, unsigned int dim)
Set the qrule to be used for face integration.
std::map< unsigned int, std::map< FEType, FEBase * > > _fe_face_neighbor
Definition Assembly.h:2561
void prepareScalar()
Definition Assembly.C:3054
std::set< FEType > _need_second_derivative_neighbor
Definition Assembly.h:2901
std::vector< std::vector< std::vector< DenseMatrix< Number > > > > _sub_Ken
jacobian contributions from the element and neighbor <Tag, ivar, jvar>
Definition Assembly.h:2697
std::vector< VectorValue< ADReal > > _ad_dxyzdxi_map
AD quantities.
Definition Assembly.h:2855
const MooseArray< ADReal > & adCurvatures() const
Definition Assembly.C:4892
bool _prepared_for_p_refinement
Whether helper FEs have been prepared for p-refinement.
Definition Assembly.h:2933
std::vector< std::unique_ptr< FEBase > > _unique_fe_face_neighbor_helper
Definition Assembly.h:2385
std::vector< Point > _temp_reference_points
Temporary work data for reinitAtPhysical()
Definition Assembly.h:2852
std::vector< std::pair< MooseVariableScalar *, MooseVariableScalar * > > _cm_ss_entry
Entries in the coupling matrix for scalar variables.
Definition Assembly.h:2351
const Elem * _current_lower_d_elem
The current lower dimensional element.
Definition Assembly.h:2645
bool _need_ad_face_map
Whether any object needs the AD face JxW, normals, quadrature points, curvatures or coordinate transf...
Definition Assembly.h:2812
unsigned int _current_side
The current side of the selected element (valid only when working with sides)
Definition Assembly.h:2618
void buildNeighborFE(FEType type) const
Build FEs for a neighbor with a type.
Definition Assembly.C:321
ArbitraryQuadrature * qruleArbitraryFace(const Elem *elem, unsigned int side)
Definition Assembly.C:1979
std::unordered_map< SubdomainID, std::vector< QRules > > _qrules
Holds quadrature rules for each dimension.
Definition Assembly.h:2473
void setCoordinateTransformation(const libMesh::QBase *qrule, const Points &q_points, Coords &coord, SubdomainID sub_id)
void reinitAtPhysical(const Elem *elem, const std::vector< Point > &physical_points)
Reinitialize the assembly data at specific physical point in the given element.
Definition Assembly.C:1848
std::map< FEType, FEVectorBase * > _current_vector_fe
The "volume" vector fe object that matches the current elem.
Definition Assembly.h:2405
std::vector< VectorValue< ADReal > > _ad_dxyzdzeta_map
Definition Assembly.h:2857
std::unique_ptr< FEBase > _fe_msm
A FE object for working on mortar segement elements.
Definition Assembly.h:2595
std::vector< ADReal > _ad_detadx_map
Definition Assembly.h:2867
void addJacobianNonlocal(GlobalDataKey)
Adds non-local Jacobian to the global Jacobian matrices.
Definition Assembly.C:3971
const VariablePhiGradient & gradPhiNeighbor(const MooseVariableField< Real > &) const
Definition Assembly.h:1354
void addResidualNeighbor(GlobalDataKey, const std::vector< VectorTag > &vector_tags)
Add local neighbor residuals of all field variables for a set of tags onto the global residual vector...
Definition Assembly.C:3440
void prepareNeighbor()
Definition Assembly.C:2913
const Elem *const & elem() const
Return the current element.
Definition Assembly.h:410
std::map< FEType, FEVectorBase * > _current_vector_fe_face_neighbor
The "neighbor face" vector fe object that matches the current elem.
Definition Assembly.h:2411
void reinitNeighborAtPhysical(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points)
Reinitializes the neighbor at the physical coordinates on neighbor side given.
Definition Assembly.C:2517
const Node * _current_neighbor_node
The current neighboring node we are working with.
Definition Assembly.h:2638
std::vector< ADReal > _ad_dxidx_map
Definition Assembly.h:2864
void buildFE(FEType type) const
Build FEs with a type.
Definition Assembly.C:267
const Elem * _current_neighbor_side_elem
The current side element of the ncurrent neighbor element.
Definition Assembly.h:2630
std::vector< ADReal > _ad_dxidz_map
Definition Assembly.h:2866
void cacheResidualLower(GlobalDataKey, const std::vector< VectorTag > &tags)
Takes the values that are currently in _sub_Rl and appends them to the cached values.
Definition Assembly.C:3557
std::map< unsigned int, std::map< FEType, FEVectorBase * > > _vector_fe_neighbor
Definition Assembly.h:2562
std::vector< std::vector< std::vector< DenseMatrix< Number > > > > _sub_Kle
dlower/dsecondary (or dlower/delement)
Definition Assembly.h:2705
MooseArray< ADReal > _ad_JxW
Definition Assembly.h:2862
void cacheResidualNodes(const DenseVector< Number > &res, const std::vector< dof_id_type > &dof_index, LocalDataKey, TagID tag)
Lets an external class cache residual at a set of nodes.
Definition Assembly.C:3525
void copyFaceShapes(MooseVariableField< T > &v)
Definition Assembly.C:3141
void addResidual(GlobalDataKey, const std::vector< VectorTag > &vector_tags)
Add local residuals of all field variables for a set of tags onto the global residual vectors associa...
Definition Assembly.C:3418
DenseVector< Number > _tmp_Re
auxiliary vector for scaling residuals (optimization to avoid expensive construction/destruction)
Definition Assembly.h:2680
void setResidualBlock(NumericVector< Number > &residual, DenseVector< Number > &res_block, const std::vector< dof_id_type > &dof_indices, const std::vector< Real > &scaling_factor)
Set a local residual block to a global residual vector with proper scaling.
Definition Assembly.C:3390
bool _calculate_ad_coord
Whether to calculate coord with AD.
Definition Assembly.h:2898
const libMesh::CouplingMatrix * _cm
Coupling matrices.
Definition Assembly.h:2332
VectorVariablePhiCurl _vector_curl_phi_face
Definition Assembly.h:2743
MooseArray< Point > _current_q_points_face
The current quadrature points on a face.
Definition Assembly.h:2540
std::map< FEType, std::unique_ptr< VectorFEShapeData > > _vector_fe_shape_data_neighbor
Definition Assembly.h:2789
void cacheJacobianNeighbor(GlobalDataKey)
Takes the values that are currently in the neighbor Dense Matrices and appends them to the cached val...
Definition Assembly.C:4198
DenseMatrix< Number > & jacobianBlockMortar(Moose::ConstraintJacobianType type, unsigned int ivar, unsigned int jvar, LocalDataKey, TagID tag)
Returns the jacobian block for the given mortar Jacobian type.
Definition Assembly.C:3262
void reinitLowerDElem(const Elem *elem, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)
Reinitialize FE data for a lower dimenesional element with a given set of reference points.
Definition Assembly.C:2389
void setNeighborQRule(libMesh::QBase *qrule, unsigned int dim)
Set the qrule to be used for neighbor integration.
Definition Assembly.C:746
void helpersRequestData()
request phi, dphi, xyz, JxW, etc.
Definition Assembly.C:4904
std::vector< std::vector< std::vector< DenseMatrix< Number > > > > _sub_Knn
jacobian contributions from the neighbor <Tag, ivar, jvar>
Definition Assembly.h:2701
const MooseArray< ADPoint > & adQPoints() const
Definition Assembly.h:389
void clearCachedQRules()
Set the cached quadrature rules to nullptr.
Definition Assembly.C:763
std::vector< std::vector< std::vector< DenseMatrix< Number > > > > _sub_Kln
dlower/dprimary (or dlower/dneighbor)
Definition Assembly.h:2707
libMesh::QBase * _current_qrule_neighbor
quadrature rule used on neighbors
Definition Assembly.h:2577
void setLowerQRule(libMesh::QBase *qrule, unsigned int dim)
Set the qrule to be used for lower dimensional integration.
Definition Assembly.C:727
void buildLowerDFE(FEType type) const
Build FEs for a lower dimensional element with a type.
Definition Assembly.C:371
std::vector< std::vector< std::vector< unsigned char > > > _jacobian_block_lower_used
Flag that indicates if the jacobian block for the lower dimensional element was used.
Definition Assembly.h:2360
Real elementVolume(const Elem *elem) const
On-demand computation of volume element accounting for RZ/RSpherical.
Definition Assembly.C:3858
std::map< unsigned int, std::map< FEType, FEBase * > > _fe_neighbor
types of finite elements
Definition Assembly.h:2560
void computeGradPhiAD(const Elem *elem, unsigned int n_qp, ADTemplateVariablePhiGradient< OutputType > &grad_phi, libMesh::FEGenericBase< OutputType > *fe)
compute gradient of phi possibly with derivative information with respect to nonlinear displacement v...
const VariablePhiGradient & gradPhiFaceNeighbor(const MooseVariableField< Real > &) const
Definition Assembly.h:1367
const unsigned int & side() const
Returns the current side.
Definition Assembly.h:442
std::vector< VectorValue< ADReal > > _ad_d2xyzdeta2_map
Definition Assembly.h:2860
MooseArray< std::vector< Point > > _current_tangents
The current tangent vectors at the quadrature points.
Definition Assembly.h:2548
std::vector< std::unique_ptr< FEBase > > _unique_fe_face_helper
Definition Assembly.h:2384
std::map< FEType, FEBase * > _current_fe
The "volume" fe object that matches the current elem.
Definition Assembly.h:2396
const VectorVariablePhiCurl & curlPhi(const MooseVariableField< RealVectorValue > &) const
Definition Assembly.h:1388
void prepareBlockNonlocal(unsigned int ivar, unsigned jvar, const std::vector< dof_id_type > &idof_indices, const std::vector< dof_id_type > &jdof_indices)
Definition Assembly.C:3028
std::map< FEType, std::unique_ptr< FEShapeData > > _fe_shape_data_lower
Definition Assembly.h:2783
void cacheJacobianBlock(const DenseMatrix< Number > &jac_block, const std::vector< dof_id_type > &idof_indices, const std::vector< dof_id_type > &jdof_indices, Real scaling_factor, LocalDataKey, const std::set< TagID > &tags)
Cache a local Jacobian block with the provided rows (idof_indices) and columns (jdof_indices) for eve...
Definition Assembly.C:3822
std::vector< VectorValue< ADReal > > _ad_d2xyzdxideta_map
Definition Assembly.h:2859
std::vector< std::pair< unsigned int, unsigned short > > _disp_numbers_and_directions
Container of displacement numbers and directions.
Definition Assembly.h:2883
std::map< unsigned int, std::map< FEType, FEVectorBase * > > _vector_fe_face
types of vector finite elements
Definition Assembly.h:2530
void buildVectorLowerDFE(FEType type) const
Build Vector FEs for a lower dimensional element with a type.
Definition Assembly.C:422
void addJacobianNeighborTags(libMesh::SparseMatrix< Number > &jacobian, unsigned int ivar, unsigned int jvar, const libMesh::DofMap &dof_map, std::vector< dof_id_type > &dof_indices, std::vector< dof_id_type > &neighbor_dof_indices, GlobalDataKey, const std::set< TagID > &tags)
Adds three neighboring element matrices for ivar rows and jvar columns to the global Jacobian matrix.
Definition Assembly.C:4526
std::map< unsigned int, std::map< FEType, FEBase * > > _fe
Each dimension's actual fe objects indexed on type.
Definition Assembly.h:2416
std::set< FEType > _need_curl
Definition Assembly.h:2902
const VariablePhiSecond & secondPhiFaceNeighbor(const MooseVariableField< Real > &) const
Definition Assembly.h:1371
std::vector< std::unique_ptr< FEBase > > _unique_fe_helper
Containers for holding unique FE helper types if we are doing p-refinement.
Definition Assembly.h:2383
unsigned int numExtraElemIntegers() const
Number of extra element integers Assembly tracked.
Definition Assembly.h:363
std::vector< std::pair< MooseVariableFieldBase *, MooseVariableFieldBase * > > _cm_ff_entry
Entries in the coupling matrix for field variables.
Definition Assembly.h:2345
std::vector< std::pair< MooseVariableFieldBase *, MooseVariableFieldBase * > > _cm_nonlocal_entry
Entries in the coupling matrix for field variables for nonlocal calculations.
Definition Assembly.h:2353
bool _current_elem_volume_computed
Boolean to indicate whether current element volumes has been computed.
Definition Assembly.h:2640
void reinitNeighborSurfaceElemRef(const Elem *neighbor_elem, const std::vector< Point > &pts)
Reinitialize FE data for a neighbor element that is itself the face, i.e.
Definition Assembly.C:2351
void buildLowerDDualFE(FEType type) const
Definition Assembly.C:398
void addCachedResidualDirectly(NumericVector< Number > &residual, GlobalDataKey, const VectorTag &vector_tag)
Adds the values that have been cached by calling cacheResidual(), cacheResidualNeighbor(),...
Definition Assembly.C:3616
std::map< unsigned int, std::map< FEType, FEBase * > > _fe_face
types of finite elements
Definition Assembly.h:2528
std::vector< ADReal > _ad_jac
Definition Assembly.h:2861
void addJacobianNeighbor(GlobalDataKey)
Add ElementNeighbor, NeighborElement, and NeighborNeighbor portions of the Jacobian for compute objec...
Definition Assembly.C:3993
void setMortarQRule(Order order)
Specifies a custom qrule for integration on mortar segment mesh.
Definition Assembly.C:772
void saveLocalADArray(std::vector< ADReal > &re, unsigned int i, unsigned int ntest, const ADRealEigenVector &v) const
Definition Assembly.C:3891
const std::vector< VectorTag > & _residual_vector_tags
The residual vector tags that Assembly could possibly contribute to.
Definition Assembly.h:2823
const Elem * _current_neighbor_elem
The current neighbor "element".
Definition Assembly.h:2624
VectorVariablePhiDivergence _vector_div_phi_face
Definition Assembly.h:2744
bool _user_added_fe_face_neighbor_of_helper_type
Definition Assembly.h:2377
std::vector< ADReal > _ad_dzetadx_map
Definition Assembly.h:2870
std::vector< dof_id_type > _column_indices
Definition Assembly.h:2930
const VariablePhiValue & phiNeighbor(const MooseVariableField< Real > &) const
Definition Assembly.h:1350
MooseMesh & _mesh
Definition Assembly.h:2366
DenseMatrix< Number > & jacobianBlockNeighbor(Moose::DGJacobianType type, unsigned int ivar, unsigned int jvar, LocalDataKey, TagID tag)
Get local Jacobian block of a DG Jacobian type for a pair of variables and a tag.
Definition Assembly.C:3221
std::vector< ADReal > _ad_detadz_map
Definition Assembly.h:2869
DenseMatrix< Number > & jacobianBlock(unsigned int ivar, unsigned int jvar, LocalDataKey, TagID tag)
Get local Jacobian block for a pair of variables and a tag.
Definition Assembly.h:1144
std::vector< dof_id_type > _temp_dof_indices
Temporary work vector to keep from reallocating it.
Definition Assembly.h:2849
std::vector< std::vector< std::vector< unsigned char > > > _jacobian_block_used
Flag that indicates if the jacobian block was used.
Definition Assembly.h:2355
void buildVectorFaceNeighborFE(FEType type) const
Build Vector FEs for a neighbor face with a type.
Definition Assembly.C:578
void prepareJacobianBlock()
Sizes and zeroes the Jacobian blocks used for the current element.
Definition Assembly.C:2787
void jacobianBlockNonlocalUsed(TagID tag, unsigned int ivar, unsigned int jvar, bool used)
Sets whether or not nonlocal Jacobian coupling between ivar and jvar is used to the value used.
Definition Assembly.h:2307
void resizeADMappingObjects(unsigned int n_qp, unsigned int dim)
resize any objects that contribute to automatic differentiation-related mapping calculations
Definition Assembly.C:1016
void cacheResidualBlock(std::vector< Real > &cached_residual_values, std::vector< dof_id_type > &cached_residual_rows, DenseVector< Number > &res_block, const std::vector< dof_id_type > &dof_indices, const std::vector< Real > &scaling_factor)
Push a local residual block with proper scaling into cache.
Definition Assembly.C:3367
std::vector< VectorValue< ADReal > > _ad_dxyzdeta_map
Definition Assembly.h:2856
const Node * _current_node
The current node we are working with.
Definition Assembly.h:2636
std::map< FEType, ADTemplateVariablePhiGradient< RealVectorValue > > _ad_vector_grad_phi_data_face
Definition Assembly.h:2798
void cacheJacobianMortar(GlobalDataKey)
Cache all portions of the Jacobian, e.g.
Definition Assembly.C:4236
void bumpVolumeQRuleOrder(Order volume_order, SubdomainID block)
Increases the element/volume quadrature order for the specified mesh block if and only if the current...
Definition Assembly.C:612
THREAD_ID _tid
Thread number (id)
Definition Assembly.h:2364
bool _calculate_face_xyz
Definition Assembly.h:2893
std::vector< std::vector< std::vector< DenseMatrix< Number > > > > _sub_Kel
dsecondary/dlower (or delement/dlower)
Definition Assembly.h:2709
std::map< FEType, std::unique_ptr< VectorFEShapeData > > _vector_fe_shape_data_dual_lower
Definition Assembly.h:2792
MooseArray< Point > _current_normals
The current Normal vectors at the quadrature points.
Definition Assembly.h:2544
void cacheJacobian(GlobalDataKey)
Takes the values that are currently in _sub_Kee and appends them to the cached values.
Definition Assembly.C:4146
bool _calculate_curvatures
Definition Assembly.h:2894
std::vector< std::vector< Real > > _cached_residual_values
Values cached by calling cacheResidual() (the first vector is for TIME vs NONTIME)
Definition Assembly.h:2826
const Node *const & node() const
Returns the reference to the node.
Definition Assembly.h:541
std::vector< std::vector< dof_id_type > > _cached_jacobian_cols
Column where the corresponding cached value should go.
Definition Assembly.h:2838
ArbitraryQuadrature * _current_qrule_arbitrary
The current arbitrary quadrature rule used within the element interior.
Definition Assembly.h:2428
void computeADFace(const Elem &elem, const unsigned int side)
compute AD things on an element face
Definition Assembly.C:2176
libMesh::ElemSideBuilder _current_side_elem_builder
In place side element builder for _current_side_elem.
Definition Assembly.h:2909
void computeFaceMap(const Elem &elem, const unsigned int side, const std::vector< Real > &qw)
Definition Assembly.C:1424
std::map< unsigned int, std::map< FEType, FEVectorBase * > > _vector_fe_lower
Vector FE objects for lower dimensional elements.
Definition Assembly.h:2572
void setCachedJacobian(GlobalDataKey)
Sets previously-cached Jacobian values via SparseMatrix::set() calls.
Definition Assembly.C:4577
void bumpAllQRuleOrder(Order order, SubdomainID block)
Increases the element/volume and face/area quadrature orders for the specified mesh block if and only...
Definition Assembly.C:635
libMesh::QBase * qruleFace(const Elem *elem, unsigned int side)
This is an abstraction over the internal qrules function.
Definition Assembly.C:1973
void preparePRefinement()
Prepare helper FEs for p-refinement.
Definition Assembly.C:4937
std::vector< std::vector< DenseVector< Number > > > _sub_Rl
residual contributions for each variable from the lower dimensional element
Definition Assembly.h:2677
std::map< FEType, FEBase * > _current_fe_face
The "face" fe object that matches the current elem.
Definition Assembly.h:2398
void addCachedJacobian(GlobalDataKey)
Adds the values that have been cached by calling cacheJacobian() and or cacheJacobianNeighbor() to th...
Definition Assembly.C:3901
void reinit(const Elem *elem)
Reinitialize objects (JxW, q_points, ...) for an elements.
Definition Assembly.C:1875
std::vector< dof_id_type > _neighbor_extra_elem_ids
Extra element IDs of neighbor.
Definition Assembly.h:2553
libMesh::ElemSideBuilder _compute_face_map_side_elem_builder
In place side element builder for computeFaceMap()
Definition Assembly.h:2913
void cacheResidual(GlobalDataKey, const std::vector< VectorTag > &tags)
Takes the values that are currently in _sub_Re of all field variables and appends them to the cached ...
Definition Assembly.C:3493
void modifyFaceWeightsDueToXFEM(const Elem *elem, unsigned int side=0)
Update the face integration weights for XFEM partial elements.
Definition Assembly.C:4638
unsigned int _max_cached_residuals
Definition Assembly.h:2831
void buildFaceFE(FEType type) const
Build FEs for a face with a type.
Definition Assembly.C:296
std::shared_ptr< XFEMInterface > _xfem
The XFEM controller.
Definition Assembly.h:2393
std::map< unsigned int, FEBase * > _holder_fe_face_neighbor_helper
Definition Assembly.h:2567
std::set< FEType > _need_neighbor_div
Definition Assembly.h:2905
SubdomainID _current_neighbor_subdomain_id
The current neighbor subdomain ID.
Definition Assembly.h:2626
std::vector< dof_id_type > _ad_elem_disp_dof_indices
Working vectors for computeADElemNodePoints.
Definition Assembly.h:2888
std::map< FEType, FEVectorBase * > _current_vector_fe_face
The "face" vector fe object that matches the current elem.
Definition Assembly.h:2407
bool _custom_mortar_qrule
Flag specifying whether a custom quadrature rule has been specified for mortar segment mesh.
Definition Assembly.h:2602
libMesh::ElemSideBuilder _current_neighbor_side_elem_builder
In place side element builder for _current_neighbor_side_elem.
Definition Assembly.h:2911
std::vector< std::vector< dof_id_type > > _cached_jacobian_rows
Row where the corresponding cached value should go.
Definition Assembly.h:2836
std::map< FEType, ADTemplateVariablePhiGradient< Real > > _ad_grad_phi_data_face
Definition Assembly.h:2796
MooseArray< ADReal > _ad_coord
The AD version of the current coordinate transformation coefficients.
Definition Assembly.h:2440
std::vector< std::unique_ptr< FEBase > > _unique_fe_neighbor_helper
Definition Assembly.h:2386
std::map< FEType, FEBase * > _current_fe_face_neighbor
The "neighbor face" fe object that matches the current elem.
Definition Assembly.h:2402
void computeSinglePointMapAD(const Elem *elem, const std::vector< Real > &qw, unsigned p, FEBase *fe)
compute the finite element reference-physical mapping quantities (such as JxW) with possible dependen...
Definition Assembly.C:1097
std::map< FEType, std::unique_ptr< FEShapeData > > _fe_shape_data_neighbor
Definition Assembly.h:2781
void jacobianBlockNeighborUsed(TagID tag, unsigned int ivar, unsigned int jvar, bool used)
Sets whether or not neighbor Jacobian coupling between ivar and jvar is used to the value used.
Definition Assembly.h:2271
bool _need_lower_d_elem_volume
Whether we need to compute the lower dimensional element volume.
Definition Assembly.h:2649
std::map< FEType, std::unique_ptr< VectorFEShapeData > > _vector_fe_shape_data_face_neighbor
Definition Assembly.h:2790
QRules & qrules(unsigned int dim)
Definition Assembly.h:2504
void reinitDual(const Elem *elem, const std::vector< Point > &pts, const std::vector< Real > &JxW)
Reintialize dual basis coefficients based on a customized quadrature rule.
Definition Assembly.C:2368
bool _need_neighbor_elem_volume
true is apps need to compute neighbor element volume
Definition Assembly.h:2632
std::vector< std::vector< std::vector< DenseMatrix< Number > > > > _sub_Keg
Definition Assembly.h:2694
SubProblem & _subproblem
Definition Assembly.h:2327
std::set< FEType > _need_face_div
Definition Assembly.h:2904
void reinitElemAndNeighbor(const Elem *elem, unsigned int side, const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > *neighbor_reference_points=nullptr)
Reinitialize an element and its neighbor along a particular side.
Definition Assembly.C:2050
void addJacobianCoupledVarPair(const MooseVariableBase &ivar, const MooseVariableBase &jvar)
Adds element matrices for ivar rows and jvar columns to the global Jacobian matrices.
Definition Assembly.C:3943
void reinitElemFaceRef(const Elem *elem, unsigned int elem_side, Real tolerance, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)
Reinitialize FE data for the given element on the given side, optionally with a given set of referenc...
Definition Assembly.C:2075
void init(const libMesh::CouplingMatrix *cm)
Initialize the Assembly object and set the CouplingMatrix for use throughout.
void addJacobianBlockNonlocal(libMesh::SparseMatrix< Number > &jacobian, unsigned int ivar, unsigned int jvar, const libMesh::DofMap &dof_map, const std::vector< dof_id_type > &idof_indices, const std::vector< dof_id_type > &jdof_indices, GlobalDataKey, TagID tag)
Adds non-local element matrix for ivar rows and jvar columns to the global Jacobian matrix.
Definition Assembly.C:4384
std::vector< std::pair< MooseVariableFieldBase *, MooseVariableScalar * > > _cm_fs_entry
Entries in the coupling matrix for field variables vs scalar variables.
Definition Assembly.h:2347
Real _current_side_volume
Volume of the current side element.
Definition Assembly.h:2622
void copyShapes(MooseVariableField< T > &v)
Definition Assembly.C:3104
void addResidualBlock(NumericVector< Number > &residual, DenseVector< Number > &res_block, const std::vector< dof_id_type > &dof_indices, const std::vector< Real > &scaling_factor)
Add a local residual block to a global residual vector with proper scaling.
Definition Assembly.C:3352
Real _current_neighbor_lower_d_elem_volume
The current neighboring lower dimensional element volume.
Definition Assembly.h:2655
MooseArray< Real > _coord
The current coordinate transformation coefficients.
Definition Assembly.h:2438
void prepare()
Definition Assembly.C:2820
std::map< FEType, std::unique_ptr< VectorFEShapeData > > _vector_fe_shape_data_lower
Definition Assembly.h:2791
void buildVectorFE(FEType type) const
Build Vector FEs with a type.
Definition Assembly.C:478
ArbitraryQuadrature * _current_qrule_arbitrary_face
The current arbitrary quadrature rule used on the element face.
Definition Assembly.h:2430
const MooseArray< Real > & JxW() const
Returns the reference to the transformed jacobian weights.
Definition Assembly.h:268
std::vector< std::vector< std::vector< unsigned char > > > _jacobian_block_nonlocal_used
Definition Assembly.h:2356
void prepareResidual()
Sizes and zeroes the residual for the current element.
Definition Assembly.C:2811
void buildVectorFaceFE(FEType type) const
Build Vector FEs for a face with a type.
Definition Assembly.C:512
const MooseArray< Real > & JxWNeighbor() const
Returns the reference to the transformed jacobian weights on a current face.
Definition Assembly.C:260
bool _user_added_fe_neighbor_of_helper_type
Definition Assembly.h:2378
void reinitFEFace(const Elem *elem, unsigned int side)
Just an internal helper function to reinit the face FE objects.
Definition Assembly.C:1344
std::map< unsigned int, FEBase * > _holder_fe_neighbor_helper
Each dimension's helper objects.
Definition Assembly.h:2566
void addJacobianBlockTags(libMesh::SparseMatrix< Number > &jacobian, unsigned int ivar, unsigned int jvar, const libMesh::DofMap &dof_map, std::vector< dof_id_type > &dof_indices, GlobalDataKey, const std::set< TagID > &tags)
Add element matrix for ivar rows and jvar columns to the global Jacobian matrix for given tags.
Definition Assembly.C:4316
void reinitNeighborLowerDElem(const Elem *elem)
reinitialize a neighboring lower dimensional element
Definition Assembly.C:2482
void initNonlocalCoupling()
Create pair of variables requiring nonlocal jacobian contributions.
Definition Assembly.C:2752
MooseArray< ADReal > _ad_curvatures
Definition Assembly.h:2878
bool _need_ad_grad_phi
Whether any object needs the AD element shape function gradients.
Definition Assembly.h:2804
libMesh::QBase * _qrule_msm
A qrule object for working on mortar segement elements.
Definition Assembly.h:2600
unsigned int _max_cached_jacobians
Definition Assembly.h:2840
const Elem * _current_side_elem
The current "element" making up the side we are currently on.
Definition Assembly.h:2620
std::set< FEType > _need_div
Definition Assembly.h:2903
std::vector< std::vector< dof_id_type > > _cached_residual_rows
Where the cached values should go (the first vector is for TIME vs NONTIME)
Definition Assembly.h:2829
std::map< FEType, ADTemplateVariablePhiGradient< Real > > _ad_grad_phi_data
Definition Assembly.h:2794
std::map< unsigned int, FEBase * > _holder_fe_helper
Each dimension's helper objects.
Definition Assembly.h:2420
MooseArray< Point > _current_q_points_face_neighbor
The current quadrature points on the neighbor face.
Definition Assembly.h:2579
std::vector< ADReal > _ad_dzetadz_map
Definition Assembly.h:2872
std::vector< ADReal > _ad_detady_map
Definition Assembly.h:2868
std::vector< std::vector< std::vector< DenseMatrix< Number > > > > _sub_Kne
jacobian contributions from the neighbor and element <Tag, ivar, jvar>
Definition Assembly.h:2699
MooseArray< Real > _current_JxW
The current list of transformed jacobian weights.
Definition Assembly.h:2434
void zeroCachedJacobian(GlobalDataKey)
Zero out previously-cached Jacobian rows.
Definition Assembly.C:4597
void buildVectorDualLowerDFE(FEType type) const
Definition Assembly.C:450
const Elem * _current_neighbor_lower_d_elem
The current neighboring lower dimensional element.
Definition Assembly.h:2647
libMesh::QBase * _current_qrule_lower
quadrature rule used on lower dimensional elements.
Definition Assembly.h:2606
const VariablePhiValue & phiFaceNeighbor(const MooseVariableField< Real > &) const
Definition Assembly.h:1363
void clearCachedResiduals(GlobalDataKey)
Clears all of the residuals in _cached_residual_rows and _cached_residual_values.
Definition Assembly.C:3586
void addJacobianBlockNonlocalTags(libMesh::SparseMatrix< Number > &jacobian, unsigned int ivar, unsigned int jvar, const libMesh::DofMap &dof_map, const std::vector< dof_id_type > &idof_indices, const std::vector< dof_id_type > &jdof_indices, GlobalDataKey, const std::set< TagID > &tags)
Adds non-local element matrix for ivar rows and jvar columns to the global Jacobian matrix.
Definition Assembly.C:4442
void computeCurrentElemVolume()
Definition Assembly.C:1810
unsigned int _current_neighbor_side
The current side of the selected neighboring element (valid only when working with sides)
Definition Assembly.h:2628
std::vector< std::vector< std::vector< DenseMatrix< Number > > > > _sub_Knl
dprimary/dlower (or dneighbor/dlower)
Definition Assembly.h:2711
void addResidualLower(GlobalDataKey, const std::vector< VectorTag > &vector_tags)
Add local neighbor residuals of all field variables for a set of tags onto the global residual vector...
Definition Assembly.C:3462
MooseArray< VectorValue< ADReal > > _ad_q_points_face
Definition Assembly.h:2876
void reinitMortarElem(const Elem *elem)
reinitialize a mortar segment mesh element in order to get a proper JxW
Definition Assembly.C:2503
std::vector< VectorValue< ADReal > > _ad_d2xyzdxi2_map
Definition Assembly.h:2858
const Elem * _current_elem
The current "element" we are currently on.
Definition Assembly.h:2610
std::map< unsigned int, FEBase * > _holder_fe_face_helper
Each dimension's helper objects.
Definition Assembly.h:2532
std::map< unsigned int, std::map< FEType, FEVectorBase * > > _vector_fe_face_neighbor
Definition Assembly.h:2563
void reinitNeighbor(const Elem *neighbor, const std::vector< Point > &reference_points)
Reinitializes the neighbor side using reference coordinates.
Definition Assembly.C:1743
const Elem * _msm_elem
Definition Assembly.h:2915
libMesh::QBase * _current_qrule_volume
The current volumetric quadrature for the element.
Definition Assembly.h:2426
void addJacobianNeighborLowerD(GlobalDataKey)
Add all portions of the Jacobian except PrimaryPrimary, e.g.
Definition Assembly.C:4031
std::map< FEType, FEVectorBase * > _current_vector_fe_neighbor
The "neighbor" vector fe object that matches the current elem.
Definition Assembly.h:2409
MooseArray< Real > _coord_msm
The coordinate transformation coefficients evaluated on the quadrature points of the mortar segment m...
Definition Assembly.h:2588
Real _current_lower_d_elem_volume
The current lower dimensional element volume.
Definition Assembly.h:2651
void setResidualNeighbor(NumericVector< Number > &residual, GlobalDataKey, const VectorTag &vector_tag)
Sets local neighbor residuals of all field variables to the global residual vector for a tag.
Definition Assembly.C:3643
std::vector< std::vector< Real > > _cached_jacobian_values
Values cached by calling cacheJacobian()
Definition Assembly.h:2834
bool _user_added_fe_face_of_helper_type
Definition Assembly.h:2376
void clearCachedJacobian()
Clear any currently cached jacobians.
Definition Assembly.C:4607
void addJacobianBlock(libMesh::SparseMatrix< Number > &jacobian, unsigned int ivar, unsigned int jvar, const libMesh::DofMap &dof_map, std::vector< dof_id_type > &dof_indices, GlobalDataKey, TagID tag)
Adds element matrix for ivar rows and jvar columns to the global Jacobian matrix.
std::map< FEType, std::unique_ptr< FEShapeData > > _fe_shape_data_dual_lower
Definition Assembly.h:2784
std::map< FEType, std::unique_ptr< FEShapeData > > _fe_shape_data
Shape function values, gradients, second derivatives for each FE type.
Definition Assembly.h:2779
std::vector< Point > _current_neighbor_ref_points
The current reference points on the neighbor element.
Definition Assembly.h:2936
void copyNeighborShapes(MooseVariableField< T > &v)
Definition Assembly.C:3178
std::set< FEType > _need_second_derivative
Definition Assembly.h:2900
std::vector< dof_id_type > _row_indices
Working vectors to avoid repeated heap allocations when caching residuals/Jacobians that must have li...
Definition Assembly.h:2930
std::vector< dof_id_type > _extra_elem_ids
Extra element IDs.
Definition Assembly.h:2551
void addCachedResiduals(GlobalDataKey, const std::vector< VectorTag > &tags)
Pushes all cached residuals to the global residual vectors associated with each tag.
Definition Assembly.C:3571
void computeADElemNodePoints(const Elem &elem, bool do_derivatives)
Fill _ad_elem_node_points with the positions of the nodes of elem, with derivatives with respect to t...
Definition Assembly.C:1046
Assembly(SystemBase &sys, THREAD_ID tid)
Definition Assembly.C:79
std::map< FEType, std::unique_ptr< FEShapeData > > _fe_shape_data_face_neighbor
Definition Assembly.h:2782
bool _user_added_fe_lower_of_helper_type
Definition Assembly.h:2379
MooseArray< Real > _current_JxW_neighbor
The current transformed jacobian weights on a neighbor's face.
Definition Assembly.h:2583
std::vector< ADReal > _ad_dxidy_map
Definition Assembly.h:2865
unsigned int _mesh_dimension
Definition Assembly.h:2368
void setResidual(NumericVector< Number > &residual, GlobalDataKey, const VectorTag &vector_tag)
Sets local residuals of all field variables to the global residual vector for a tag.
Definition Assembly.C:3634
std::map< FEType, std::unique_ptr< FEShapeData > > _fe_shape_data_face
Definition Assembly.h:2780
const VariablePhiSecond & secondPhi() const
Definition Assembly.h:1332
const Elem *const & neighbor() const
Return the neighbor element.
Definition Assembly.h:466
void prepareOffDiagScalar()
Definition Assembly.C:3078
void prepareNonlocal()
Definition Assembly.C:2827
void prepareVariable(MooseVariableFieldBase *var)
Used for preparing the dense residual and jacobian blocks for one particular variable.
Definition Assembly.C:2853
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition FaceInfo.h:38
unsigned int neighborSideID() const
Definition FaceInfo.h:114
const Elem & elem() const
Definition FaceInfo.h:85
const Elem * neighborPtr() const
Definition FaceInfo.h:88
unsigned int elemSideID() const
Definition FaceInfo.h:113
forward declarations
Definition MooseArray.h:18
void resize(unsigned int size)
Change the number of elements the array can store.
Definition MooseArray.h:216
std::vector< T > stdVector() const
Extremely inefficient way to produce a std::vector from a MooseArray!
Definition MooseArray.h:344
unsigned int size() const
The number of elements that can currently be stored in the array.
Definition MooseArray.h:259
void shallowCopy(const MooseArray &rhs)
Doesn't actually make a copy of the data.
Definition MooseArray.h:296
void release()
Manually deallocates the data pointer.
Definition MooseArray.h:66
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3581
bool hasSecondOrderElements()
check if the mesh has SECOND order elements
Definition MooseMesh.C:3861
Base variable class.
std::vector< dof_id_type > componentDofIndices(const std::vector< dof_id_type > &dof_indices, unsigned int component) const
Obtain DoF indices of a component with the indices of the 0th component.
virtual const std::vector< dof_id_type > & dofIndices() const
Get local DoF indices.
const std::vector< Real > & arrayScalingFactor() const
const std::vector< dof_id_type > & allDofIndices() const
Get all global dofindices for the variable.
unsigned int number() const
Get variable number coming from libMesh.
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one.
This class provides an interface for common operations on field variables of both FE and FV types wit...
virtual const std::vector< dof_id_type > & dofIndicesLower() const =0
Get dof indices for the current lower dimensional element (this is meaningful when performing mortar ...
virtual const std::vector< dof_id_type > & dofIndicesNeighbor() const =0
Get neighbor DOF indices for currently selected element.
Class for stuff related to variables.
virtual const FieldVariablePhiGradient & gradPhiFaceNeighbor() const =0
Return the gradients of the variable's shape functions on a neighboring element face.
virtual const FieldVariablePhiGradient & gradPhiNeighbor() const =0
Return the gradients of the variable's shape functions on a neighboring element.
virtual const FieldVariablePhiValue & phiFaceNeighbor() const =0
Return the variable's shape functions on a neighboring element face.
virtual const FieldVariablePhiGradient & gradPhiFace() const =0
Return the gradients of the variable's shape functions on an element face.
virtual const FieldVariablePhiSecond & secondPhi() const =0
Return the rank-2 tensor of second derivatives of the variable's elemental shape functions.
bool usesPhiNeighbor() const
Whether or not this variable is actually using the shape function value.
virtual const FieldVariablePhiValue & phi() const =0
Return the variable's elemental shape functions.
virtual const FieldVariablePhiSecond & secondPhiFace() const =0
Return the rank-2 tensor of second derivatives of the variable's shape functions on an element face.
virtual const FieldVariablePhiSecond & secondPhiFaceNeighbor() const =0
Return the rank-2 tensor of second derivatives of the variable's shape functions on a neighboring ele...
virtual bool computingSecond() const =0
Whether or not this variable is computing any second derivatives.
virtual const FieldVariablePhiValue & phiFace() const =0
Return the variable's shape functions on an element face.
virtual const FieldVariablePhiSecond & secondPhiNeighbor() const =0
Return the rank-2 tensor of second derivatives of the variable's shape functions on a neighboring ele...
virtual bool usesSecondPhiNeighbor() const =0
Whether or not this variable is actually using the shape function second derivatives.
virtual const FieldVariablePhiGradient & gradPhi() const =0
Return the gradients of the variable's elemental shape functions.
virtual const FieldVariablePhiValue & phiNeighbor() const =0
Return the variable's shape functions on a neighboring element.
bool usesGradPhiNeighbor() const
Whether or not this variable is actually using the shape function gradient.
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
virtual MooseMesh & mesh()=0
virtual unsigned int currentNlSysNum() const =0
virtual const VectorTag & getVectorTag(const TagID tag_id) const
Get a VectorTag from a TagID.
Definition SubProblem.C:153
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition SubProblem.h:251
virtual void haveADObjects(bool have_ad_objects)
Method for setting whether we have any ad objects.
Definition SubProblem.h:787
virtual bool checkNonlocalCouplingRequirement() const =0
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
Base class for a system (of equations)
Definition SystemBase.h:87
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition SystemBase.C:924
virtual unsigned int nVariables() const
Get the number of variables in this system.
Definition SystemBase.C:891
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition SystemBase.C:92
unsigned int number() const
Gets the number of this system.
virtual bool isScalarVariable(unsigned int var_name) const
Definition SystemBase.C:885
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition SystemBase.C:933
const std::vector< MooseVariableFieldBase * > & getVariables(THREAD_ID tid)
Definition SystemBase.h:782
MooseVariableField< T > & getActualFieldVariable(THREAD_ID tid, const std::string &var_name)
Returns a field variable pointer - this includes finite volume variables.
Definition SystemBase.C:120
bool computingScalingJacobian() const
Whether we are computing an initial Jacobian for automatic variable scaling.
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a scalar variable with specified number.
Definition SystemBase.C:147
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition SystemBase.h:391
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
Definition SystemBase.h:789
Storage for all of the information pretaining to a vector tag.
Definition VectorTag.h:18
TagID _id
The id associated with the vector tag.
Definition VectorTag.h:30
Moose::VectorTagType _type
The type of the vector tag.
Definition VectorTag.h:53
TagTypeID _type_id
The index for this tag into a vector that contains tags of only its type ordered by ID.
Definition VectorTag.h:47
DenseMatrix sub_matrix(unsigned int row_id, unsigned int row_size, unsigned int col_id, unsigned int col_size) const
void resize(const unsigned int new_m, const unsigned int new_n)
virtual unsigned int size() const override final
void constrain_element_matrix(DenseMatrix< Number > &matrix, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
void constrain_element_vector(DenseVector< Number > &rhs, std::vector< dof_id_type > &dofs, bool asymmetric_constraint_rows=true) const
const Variable & variable(const unsigned int c) const override
unsigned int n_dofs(const ElemType t, const Order o)
Order get_order() const
const std::vector< Point > & get_points() const
unsigned int n_points() const
virtual QuadratureType type() const=0
bool allow_rules_with_negative_weights
unsigned int get_dim() const
const std::vector< Real > & get_weights() const
virtual void init(const Elem &e, unsigned int p_level=invalid_uint)
virtual void zero_rows(std::vector< numeric_index_type > &rows, T diag_value=0.0)
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value)=0
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value)=0
MeshBase & mesh
void coordTransformFactorRZGeneral(const P &point, const std::pair< Point, RealVectorValue > &axis, C &factor)
Computes a coordinate transformation factor for a general axisymmetric axis.
void coordTransformFactor(const P &point, C &factor, const Moose::CoordinateSystemType coord_type, const unsigned int rz_radial_coord=libMesh::invalid_uint)
Compute a coordinate transformation volume integration factor.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
@ VAR_FIELD_STANDARD
Definition MooseTypes.h:782
@ VAR_FIELD_ARRAY
Definition MooseTypes.h:785
@ VAR_FIELD_VECTOR
Definition MooseTypes.h:784
ConstraintJacobianType
Definition MooseTypes.h:856
@ LowerLower
Definition MooseTypes.h:861
@ SecondarySecondary
Definition MooseTypes.h:857
@ PrimaryLower
Definition MooseTypes.h:865
@ LowerSecondary
Definition MooseTypes.h:862
@ LowerPrimary
Definition MooseTypes.h:863
@ SecondaryPrimary
Definition MooseTypes.h:858
@ PrimarySecondary
Definition MooseTypes.h:859
@ PrimaryPrimary
Definition MooseTypes.h:860
@ SecondaryLower
Definition MooseTypes.h:864
const SubdomainID ANY_BLOCK_ID
Definition MooseTypes.C:19
@ VECTOR_TAG_RESIDUAL
@ COORD_RZ
Definition MooseTypes.h:871
@ COORD_XYZ
Definition MooseTypes.h:870
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N > > &derivs, libMesh::dof_id_type index, Real value)
Definition ADReal.h:21
DGJacobianType
Definition MooseTypes.h:809
@ NeighborNeighbor
Definition MooseTypes.h:813
@ ElementElement
Definition MooseTypes.h:810
@ NeighborElement
Definition MooseTypes.h:812
@ ElementNeighbor
Definition MooseTypes.h:811
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
const unsigned int invalid_uint
OStreamProxy err(std::cerr)
Data structure for tracking/grouping a set of quadrature rules for a particular dimensionality of mes...
Definition Assembly.h:2445
std::unique_ptr< ArbitraryQuadrature > arbitrary_vol
volume/elem (meshdim) custom points quadrature rule
Definition Assembly.h:2462
std::unique_ptr< ArbitraryQuadrature > neighbor
area/face (meshdim-1) custom points quadrature rule for DG
Definition Assembly.h:2466
std::unique_ptr< libMesh::QBase > vol
volume/elem (meshdim) quadrature rule
Definition Assembly.h:2456
std::unique_ptr< ArbitraryQuadrature > arbitrary_face
area/face (meshdim-1) custom points quadrature rule
Definition Assembly.h:2464
std::unique_ptr< libMesh::QBase > face
area/face (meshdim-1) quadrature rule
Definition Assembly.h:2458