LCOV - code coverage report
Current view: top level - src/systems - AuxiliarySystem.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31706 (f8ed4a) with base bb0a08 Lines: 454 491 92.5 %
Date: 2025-11-03 17:23:24 Functions: 37 40 92.5 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "AuxiliarySystem.h"
      11             : #include "FEProblem.h"
      12             : #include "Factory.h"
      13             : #include "AuxKernel.h"
      14             : #include "AuxScalarKernel.h"
      15             : #include "MaterialData.h"
      16             : #include "Assembly.h"
      17             : #include "GeometricSearchData.h"
      18             : #include "ComputeNodalAuxVarsThread.h"
      19             : #include "ComputeNodalAuxBcsThread.h"
      20             : #include "ComputeElemAuxVarsThread.h"
      21             : #include "ComputeElemAuxBcsThread.h"
      22             : #include "ComputeMortarNodalAuxBndThread.h"
      23             : #include "Parser.h"
      24             : #include "TimeIntegrator.h"
      25             : #include "Conversion.h"
      26             : 
      27             : #include "libmesh/quadrature_gauss.h"
      28             : #include "libmesh/node_range.h"
      29             : #include "libmesh/numeric_vector.h"
      30             : #include "libmesh/default_coupling.h"
      31             : #include "libmesh/string_to_enum.h"
      32             : #include "libmesh/fe_interface.h"
      33             : 
      34             : using namespace libMesh;
      35             : 
      36             : // AuxiliarySystem ////////
      37             : 
      38       64776 : AuxiliarySystem::AuxiliarySystem(FEProblemBase & subproblem, const std::string & name)
      39             :   : SystemBase(subproblem, subproblem, name, Moose::VAR_AUXILIARY),
      40       64776 :     PerfGraphInterface(subproblem.getMooseApp().perfGraph(), "AuxiliarySystem"),
      41       64776 :     _sys(subproblem.es().add_system<System>(name)),
      42       64776 :     _current_solution(_sys.current_local_solution.get()),
      43       64776 :     _aux_scalar_storage(_app.getExecuteOnEnum()),
      44       64776 :     _nodal_aux_storage(_app.getExecuteOnEnum()),
      45       64776 :     _mortar_nodal_aux_storage(_app.getExecuteOnEnum()),
      46       64776 :     _elemental_aux_storage(_app.getExecuteOnEnum()),
      47       64776 :     _nodal_vec_aux_storage(_app.getExecuteOnEnum()),
      48       64776 :     _elemental_vec_aux_storage(_app.getExecuteOnEnum()),
      49       64776 :     _nodal_array_aux_storage(_app.getExecuteOnEnum()),
      50      172751 :     _elemental_array_aux_storage(_app.getExecuteOnEnum())
      51             : #ifdef MOOSE_KOKKOS_ENABLED
      52             :     ,
      53       43181 :     _kokkos_nodal_aux_storage(_app.getExecuteOnEnum()),
      54      259086 :     _kokkos_elemental_aux_storage(_app.getExecuteOnEnum())
      55             : #endif
      56             : {
      57       64776 :   _nodal_vars.resize(libMesh::n_threads());
      58       64776 :   _elem_vars.resize(libMesh::n_threads());
      59             : 
      60       64776 :   if (!_fe_problem.defaultGhosting())
      61             :   {
      62       64694 :     auto & dof_map = _sys.get_dof_map();
      63       64694 :     dof_map.remove_algebraic_ghosting_functor(dof_map.default_algebraic_ghosting());
      64       64694 :     dof_map.set_implicit_neighbor_dofs(false);
      65             :   }
      66       64776 : }
      67             : 
      68       60312 : AuxiliarySystem::~AuxiliarySystem() = default;
      69             : 
      70             : void
      71       61758 : AuxiliarySystem::initialSetup()
      72             : {
      73      308790 :   TIME_SECTION("initialSetup", 3, "Initializing Auxiliary System");
      74             : 
      75       61758 :   SystemBase::initialSetup();
      76             : 
      77      129155 :   for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
      78             :   {
      79       67401 :     _aux_scalar_storage.sort(tid);
      80       67401 :     _aux_scalar_storage.initialSetup(tid);
      81             : 
      82       67401 :     _nodal_aux_storage.sort(tid);
      83       67401 :     _nodal_aux_storage.initialSetup(tid);
      84             : 
      85       67397 :     _mortar_nodal_aux_storage.sort(tid);
      86       67397 :     _mortar_nodal_aux_storage.initialSetup(tid);
      87             : 
      88       67397 :     _nodal_vec_aux_storage.sort(tid);
      89       67397 :     _nodal_vec_aux_storage.initialSetup(tid);
      90             : 
      91       67397 :     _nodal_array_aux_storage.sort(tid);
      92       67397 :     _nodal_array_aux_storage.initialSetup(tid);
      93             : 
      94       67397 :     _elemental_aux_storage.sort(tid);
      95       67397 :     _elemental_aux_storage.initialSetup(tid);
      96             : 
      97       67397 :     _elemental_vec_aux_storage.sort(tid);
      98       67397 :     _elemental_vec_aux_storage.initialSetup(tid);
      99             : 
     100       67397 :     _elemental_array_aux_storage.sort(tid);
     101       67397 :     _elemental_array_aux_storage.initialSetup(tid);
     102             :   }
     103             : 
     104             : #ifdef MOOSE_KOKKOS_ENABLED
     105       41472 :   _kokkos_nodal_aux_storage.sort(/*tid=*/0);
     106       41472 :   _kokkos_nodal_aux_storage.initialSetup(/*tid=*/0);
     107             : 
     108       41472 :   _kokkos_elemental_aux_storage.sort(/*tid=*/0);
     109       41472 :   _kokkos_elemental_aux_storage.initialSetup(/*tid=*/0);
     110             : #endif
     111       61754 : }
     112             : 
     113             : void
     114      289626 : AuxiliarySystem::timestepSetup()
     115             : {
     116      289626 :   SystemBase::timestepSetup();
     117             : 
     118      604897 :   for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
     119             :   {
     120      315271 :     _aux_scalar_storage.timestepSetup(tid);
     121      315271 :     _nodal_aux_storage.timestepSetup(tid);
     122      315271 :     _mortar_nodal_aux_storage.timestepSetup(tid);
     123      315271 :     _nodal_vec_aux_storage.timestepSetup(tid);
     124      315271 :     _nodal_array_aux_storage.timestepSetup(tid);
     125      315271 :     _elemental_aux_storage.timestepSetup(tid);
     126      315271 :     _elemental_vec_aux_storage.timestepSetup(tid);
     127      315271 :     _elemental_array_aux_storage.timestepSetup(tid);
     128             :   }
     129             : 
     130             : #ifdef MOOSE_KOKKOS_ENABLED
     131      190755 :   _kokkos_nodal_aux_storage.timestepSetup(/*tid=*/0);
     132      190755 :   _kokkos_elemental_aux_storage.timestepSetup(/*tid=*/0);
     133             : #endif
     134      289626 : }
     135             : 
     136             : void
     137     1920711 : AuxiliarySystem::customSetup(const ExecFlagType & exec_type)
     138             : {
     139     1920711 :   SystemBase::customSetup(exec_type);
     140             : 
     141     4013103 :   for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
     142             :   {
     143     2092392 :     _aux_scalar_storage.customSetup(exec_type, tid);
     144     2092392 :     _nodal_aux_storage.customSetup(exec_type, tid);
     145     2092392 :     _mortar_nodal_aux_storage.customSetup(exec_type, tid);
     146     2092392 :     _nodal_vec_aux_storage.customSetup(exec_type, tid);
     147     2092392 :     _nodal_array_aux_storage.customSetup(exec_type, tid);
     148     2092392 :     _elemental_aux_storage.customSetup(exec_type, tid);
     149     2092392 :     _elemental_vec_aux_storage.customSetup(exec_type, tid);
     150     2092392 :     _elemental_array_aux_storage.customSetup(exec_type, tid);
     151             :   }
     152             : 
     153             : #ifdef MOOSE_KOKKOS_ENABLED
     154     1264237 :   _kokkos_nodal_aux_storage.customSetup(exec_type, /*tid=*/0);
     155     1264237 :   _kokkos_elemental_aux_storage.customSetup(exec_type, /*tid=*/0);
     156             : #endif
     157     1920711 : }
     158             : 
     159             : void
     160           0 : AuxiliarySystem::subdomainSetup()
     161             : {
     162           0 :   SystemBase::subdomainSetup();
     163             : 
     164           0 :   for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
     165             :   {
     166           0 :     _aux_scalar_storage.subdomainSetup(tid);
     167           0 :     _nodal_aux_storage.subdomainSetup(tid);
     168           0 :     _mortar_nodal_aux_storage.subdomainSetup(tid);
     169           0 :     _nodal_vec_aux_storage.subdomainSetup(tid);
     170           0 :     _nodal_array_aux_storage.subdomainSetup(tid);
     171           0 :     _elemental_aux_storage.subdomainSetup(tid);
     172           0 :     _elemental_vec_aux_storage.subdomainSetup(tid);
     173           0 :     _elemental_array_aux_storage.subdomainSetup(tid);
     174             :   }
     175           0 : }
     176             : 
     177             : void
     178      533632 : AuxiliarySystem::jacobianSetup()
     179             : {
     180      533632 :   SystemBase::jacobianSetup();
     181             : 
     182     1116074 :   for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
     183             :   {
     184      582442 :     _aux_scalar_storage.jacobianSetup(tid);
     185      582442 :     _nodal_aux_storage.jacobianSetup(tid);
     186      582442 :     _mortar_nodal_aux_storage.jacobianSetup(tid);
     187      582442 :     _nodal_vec_aux_storage.jacobianSetup(tid);
     188      582442 :     _nodal_array_aux_storage.jacobianSetup(tid);
     189      582442 :     _elemental_aux_storage.jacobianSetup(tid);
     190      582442 :     _elemental_vec_aux_storage.jacobianSetup(tid);
     191      582442 :     _elemental_array_aux_storage.jacobianSetup(tid);
     192             :   }
     193             : 
     194             : #ifdef MOOSE_KOKKOS_ENABLED
     195      348556 :   _kokkos_nodal_aux_storage.jacobianSetup(/*tid=*/0);
     196      348556 :   _kokkos_elemental_aux_storage.jacobianSetup(/*tid=*/0);
     197             : #endif
     198      533632 : }
     199             : 
     200             : void
     201     3343428 : AuxiliarySystem::residualSetup()
     202             : {
     203     3343428 :   SystemBase::residualSetup();
     204             : 
     205     6986939 :   for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
     206             :   {
     207     3643511 :     _aux_scalar_storage.residualSetup(tid);
     208     3643511 :     _nodal_aux_storage.residualSetup(tid);
     209     3643511 :     _mortar_nodal_aux_storage.residualSetup(tid);
     210     3643511 :     _nodal_vec_aux_storage.residualSetup(tid);
     211     3643511 :     _nodal_array_aux_storage.residualSetup(tid);
     212     3643511 :     _elemental_aux_storage.residualSetup(tid);
     213     3643511 :     _elemental_vec_aux_storage.residualSetup(tid);
     214     3643511 :     _elemental_array_aux_storage.residualSetup(tid);
     215             :   }
     216             : 
     217             : #ifdef MOOSE_KOKKOS_ENABLED
     218     2194256 :   _kokkos_nodal_aux_storage.residualSetup(/*tid=*/0);
     219     2194256 :   _kokkos_elemental_aux_storage.residualSetup(/*tid=*/0);
     220             : #endif
     221     3343428 : }
     222             : 
     223             : void
     224      368161 : AuxiliarySystem::updateActive(THREAD_ID tid)
     225             : {
     226      368161 :   _aux_scalar_storage.updateActive(tid);
     227      368161 :   _nodal_aux_storage.updateActive(tid);
     228      368161 :   _mortar_nodal_aux_storage.updateActive(tid);
     229      368161 :   _nodal_vec_aux_storage.updateActive(tid);
     230      368161 :   _nodal_array_aux_storage.updateActive(tid);
     231      368161 :   _elemental_aux_storage.updateActive(tid);
     232      368161 :   _elemental_vec_aux_storage.updateActive(tid);
     233      368161 :   _elemental_array_aux_storage.updateActive(tid);
     234             : 
     235             : #ifdef MOOSE_KOKKOS_ENABLED
     236      252291 :   if (tid == 0)
     237             :   {
     238      222986 :     _kokkos_nodal_aux_storage.updateActive(/*tid=*/0);
     239      222986 :     _kokkos_elemental_aux_storage.updateActive(/*tid=*/0);
     240             :   }
     241             : #endif
     242      368161 : }
     243             : 
     244             : void
     245       96516 : AuxiliarySystem::addVariable(const std::string & var_type,
     246             :                              const std::string & name,
     247             :                              InputParameters & parameters)
     248             : {
     249       96516 :   SystemBase::addVariable(var_type, name, parameters);
     250             : 
     251      193032 :   auto fe_type = FEType(Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")),
     252      289548 :                         Utility::string_to_enum<FEFamily>(parameters.get<MooseEnum>("family")));
     253             : 
     254       96516 :   if (var_type == "MooseVariableScalar")
     255        1805 :     return;
     256             : 
     257      198227 :   for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
     258             :   {
     259      103516 :     if (FEInterface::field_type(fe_type) == TYPE_VECTOR)
     260             :     {
     261         393 :       auto * var = _vars[tid].getActualFieldVariable<RealVectorValue>(name);
     262         393 :       if (var)
     263             :       {
     264         393 :         if (var->feType().family == LAGRANGE_VEC)
     265         140 :           _nodal_vars[tid].push_back(var);
     266             :         else
     267         253 :           _elem_vars[tid].push_back(var);
     268             :       }
     269             :     }
     270             : 
     271             :     else
     272             :     {
     273      103123 :       MooseVariableBase * var_base = _vars[tid].getVariable(name);
     274             : 
     275      103123 :       auto * const var = dynamic_cast<MooseVariableField<Real> *>(var_base);
     276             : 
     277      103123 :       if (var)
     278             :       {
     279      101913 :         if (var->feType().family == LAGRANGE)
     280       36516 :           _nodal_vars[tid].push_back(var);
     281             :         else
     282       65397 :           _elem_vars[tid].push_back(var);
     283             :       }
     284             : 
     285      103123 :       auto * const avar = dynamic_cast<MooseVariableField<RealEigenVector> *>(var_base);
     286             : 
     287      103123 :       if (avar)
     288             :       {
     289        1210 :         if (avar->feType().family == LAGRANGE)
     290         546 :           _nodal_vars[tid].push_back(avar);
     291             :         else
     292         664 :           _elem_vars[tid].push_back(avar);
     293             :       }
     294             :     }
     295             :   }
     296             : }
     297             : 
     298             : void
     299       68429 : AuxiliarySystem::addKernel(const std::string & kernel_name,
     300             :                            const std::string & name,
     301             :                            InputParameters & parameters)
     302             : {
     303      142622 :   for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
     304             :   {
     305       74345 :     const auto & base = parameters.getBase();
     306       74345 :     if (base == "AuxKernel" || base == "Bounds")
     307             :     {
     308             :       std::shared_ptr<AuxKernel> kernel =
     309       73937 :           _factory.create<AuxKernel>(kernel_name, name, parameters, tid);
     310       73809 :       if (kernel->isNodal())
     311             :       {
     312       23961 :         if (kernel->isMortar())
     313          84 :           _mortar_nodal_aux_storage.addObject(kernel, tid);
     314             :         else
     315       23877 :           _nodal_aux_storage.addObject(kernel, tid);
     316             :       }
     317             :       else
     318       49848 :         _elemental_aux_storage.addObject(kernel, tid);
     319       73805 :     }
     320             : 
     321         408 :     else if (base == "VectorAuxKernel")
     322             :     {
     323             :       std::shared_ptr<VectorAuxKernel> kernel =
     324         220 :           _factory.create<VectorAuxKernel>(kernel_name, name, parameters, tid);
     325         220 :       if (kernel->isNodal())
     326             :       {
     327          56 :         if (kernel->isMortar())
     328           0 :           mooseError("Vector mortar aux kernels not yet implemented");
     329          56 :         _nodal_vec_aux_storage.addObject(kernel, tid);
     330             :       }
     331             :       else
     332         164 :         _elemental_vec_aux_storage.addObject(kernel, tid);
     333         220 :     }
     334             : 
     335         188 :     else if (base == "ArrayAuxKernel")
     336             :     {
     337             :       std::shared_ptr<ArrayAuxKernel> kernel =
     338         188 :           _factory.create<ArrayAuxKernel>(kernel_name, name, parameters, tid);
     339         168 :       if (kernel->isNodal())
     340             :       {
     341          98 :         if (kernel->isMortar())
     342           0 :           mooseError("Vector mortar aux kernels not yet implemented");
     343          98 :         _nodal_array_aux_storage.addObject(kernel, tid);
     344             :       }
     345             :       else
     346          70 :         _elemental_array_aux_storage.addObject(kernel, tid);
     347         168 :     }
     348             :     else
     349             :       mooseAssert(false,
     350             :                   "Attempting to add AuxKernel of type '" + kernel_name + "' and name '" + name +
     351             :                       "' to the auxiliary system with invalid _moose_base: " + base);
     352             :   }
     353       68277 : }
     354             : 
     355             : void
     356         537 : AuxiliarySystem::addScalarKernel(const std::string & kernel_name,
     357             :                                  const std::string & name,
     358             :                                  InputParameters & parameters)
     359             : {
     360        1113 :   for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
     361             :   {
     362             :     std::shared_ptr<AuxScalarKernel> kernel =
     363         580 :         _factory.create<AuxScalarKernel>(kernel_name, name, parameters, tid);
     364         576 :     _aux_scalar_storage.addObject(kernel, tid);
     365         576 :   }
     366         533 : }
     367             : 
     368             : void
     369   431501406 : AuxiliarySystem::reinitElem(const Elem * /*elem*/, THREAD_ID tid)
     370             : {
     371   592051942 :   for (auto * var : _nodal_vars[tid])
     372   160550536 :     var->computeElemValues();
     373             : 
     374   592136195 :   for (auto * var : _elem_vars[tid])
     375             :   {
     376   160634789 :     var->reinitAux();
     377   160634789 :     var->computeElemValues();
     378             :   }
     379   431501406 : }
     380             : 
     381             : void
     382    13069227 : AuxiliarySystem::reinitElemFace(const Elem * /*elem*/, unsigned int /*side*/, THREAD_ID tid)
     383             : {
     384    15693188 :   for (auto * var : _nodal_vars[tid])
     385     2623961 :     var->computeElemValuesFace();
     386             : 
     387    19204889 :   for (auto * var : _elem_vars[tid])
     388             :   {
     389     6135662 :     var->reinitAux();
     390     6135662 :     var->reinitAuxNeighbor();
     391     6135662 :     var->computeElemValuesFace();
     392             :   }
     393    13069227 : }
     394             : 
     395             : void
     396        2269 : AuxiliarySystem::serializeSolution()
     397             : {
     398        4538 :   if (_serialized_solution.get() &&
     399        2269 :       _sys.n_dofs() > 0) // libMesh does not like serializing of empty vectors
     400             :   {
     401        2269 :     if (!_serialized_solution->initialized() || _serialized_solution->size() != _sys.n_dofs())
     402             :     {
     403          63 :       _serialized_solution->clear();
     404          63 :       _serialized_solution->init(_sys.n_dofs(), false, SERIAL);
     405             :     }
     406             : 
     407        2269 :     solution().localize(*_serialized_solution);
     408             :   }
     409        2269 : }
     410             : 
     411             : void
     412     6357818 : AuxiliarySystem::compute(ExecFlagType type)
     413             : {
     414             :   // avoid division by dt which might be zero.
     415     6357818 :   if (_fe_problem.dt() > 0.)
     416    10982613 :     for (auto & ti : _time_integrators)
     417     5481078 :       ti->preStep();
     418             : 
     419             :   // We need to compute time derivatives every time each kind of the variables is finished, because:
     420             :   //
     421             :   //  a) the user might want to use the aux variable value somewhere, thus we need to provide the
     422             :   //  up-to-date value
     423             :   //  b) time integration system works with the whole vectors of solutions, thus we cannot update
     424             :   //  only a part of the vector
     425             :   //
     426             : 
     427     6357818 :   if (_vars[0].scalars().size() > 0)
     428             :   {
     429       56031 :     computeScalarVars(type);
     430             :     // compute time derivatives of scalar aux variables _after_ the values were updated
     431       56031 :     if (_fe_problem.dt() > 0.)
     432       88162 :       for (auto & ti : _time_integrators)
     433       44081 :         ti->computeTimeDerivatives();
     434             :   }
     435             : 
     436     6357818 :   if (_vars[0].fieldVariables().size() > 0)
     437             :   {
     438     2190132 :     computeNodalArrayVars(type);
     439     2190132 :     computeNodalVecVars(type);
     440     2190132 :     computeNodalVars(type);
     441     2190128 :     computeMortarNodalVars(type);
     442     2190128 :     computeElementalArrayVars(type);
     443     2190128 :     computeElementalVecVars(type);
     444     2190128 :     computeElementalVars(type);
     445             : 
     446             : #ifdef MOOSE_KOKKOS_ENABLED
     447     1454084 :     kokkosCompute(type);
     448             : #endif
     449             : 
     450             :     // compute time derivatives of nodal aux variables _after_ the values were updated
     451     2190087 :     if (_fe_problem.dt() > 0.)
     452     3788510 :       for (auto & ti : _time_integrators)
     453     1876259 :         ti->computeTimeDerivatives();
     454             :   }
     455             : 
     456     6357773 :   if (_serialized_solution.get())
     457        2269 :     serializeSolution();
     458     6357773 : }
     459             : 
     460             : std::set<std::string>
     461     1672262 : AuxiliarySystem::getDependObjects(ExecFlagType type)
     462             : {
     463     1672262 :   std::set<std::string> depend_objects;
     464             : 
     465             :   // Elemental AuxKernels
     466             :   {
     467             :     const std::vector<std::shared_ptr<AuxKernel>> & auxs =
     468     1672262 :         _elemental_aux_storage[type].getActiveObjects();
     469     1755707 :     for (const auto & aux : auxs)
     470             :     {
     471       83445 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     472       83445 :       depend_objects.insert(uo.begin(), uo.end());
     473             :     }
     474             :   }
     475             : 
     476             :   // Elemental VectorAuxKernels
     477             :   {
     478             :     const std::vector<std::shared_ptr<VectorAuxKernel>> & auxs =
     479     1672262 :         _elemental_vec_aux_storage[type].getActiveObjects();
     480     1672557 :     for (const auto & aux : auxs)
     481             :     {
     482         295 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     483         295 :       depend_objects.insert(uo.begin(), uo.end());
     484             :     }
     485             :   }
     486             : 
     487             :   // Elemental ArrayAuxKernels
     488             :   {
     489             :     const std::vector<std::shared_ptr<ArrayAuxKernel>> & auxs =
     490     1672262 :         _elemental_array_aux_storage[type].getActiveObjects();
     491     1672366 :     for (const auto & aux : auxs)
     492             :     {
     493         104 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     494         104 :       depend_objects.insert(uo.begin(), uo.end());
     495             :     }
     496             :   }
     497             : 
     498             :   // Nodal AuxKernels
     499             :   {
     500             :     const std::vector<std::shared_ptr<AuxKernel>> & auxs =
     501     1672262 :         _nodal_aux_storage[type].getActiveObjects();
     502     1714176 :     for (const auto & aux : auxs)
     503             :     {
     504       41914 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     505       41914 :       depend_objects.insert(uo.begin(), uo.end());
     506             :     }
     507             :   }
     508             : 
     509             :   // Mortar Nodal AuxKernels
     510             :   {
     511             :     const std::vector<std::shared_ptr<AuxKernel>> & auxs =
     512     1672262 :         _mortar_nodal_aux_storage[type].getActiveObjects();
     513     1672418 :     for (const auto & aux : auxs)
     514             :     {
     515         156 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     516         156 :       depend_objects.insert(uo.begin(), uo.end());
     517             :     }
     518             :   }
     519             : 
     520             :   // Nodal VectorAuxKernels
     521             :   {
     522             :     const std::vector<std::shared_ptr<VectorAuxKernel>> & auxs =
     523     1672262 :         _nodal_vec_aux_storage[type].getActiveObjects();
     524     1672353 :     for (const auto & aux : auxs)
     525             :     {
     526          91 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     527          91 :       depend_objects.insert(uo.begin(), uo.end());
     528             :     }
     529             :   }
     530             : 
     531             :   // Nodal ArrayAuxKernels
     532             :   {
     533             :     const std::vector<std::shared_ptr<ArrayAuxKernel>> & auxs =
     534     1672262 :         _nodal_array_aux_storage[type].getActiveObjects();
     535     1672418 :     for (const auto & aux : auxs)
     536             :     {
     537         156 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     538         156 :       depend_objects.insert(uo.begin(), uo.end());
     539             :     }
     540             :   }
     541             : 
     542             : #ifdef MOOSE_KOKKOS_ENABLED
     543             :   // Nodal KokkosAuxKernels
     544             :   {
     545             :     const std::vector<std::shared_ptr<AuxKernelBase>> & auxs =
     546     1122218 :         _kokkos_nodal_aux_storage[type].getActiveObjects();
     547     1122458 :     for (const auto & aux : auxs)
     548             :     {
     549         240 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     550         240 :       depend_objects.insert(uo.begin(), uo.end());
     551             :     }
     552             :   }
     553             : 
     554             :   // Nodal ElementalAuxKernels
     555             :   {
     556             :     const std::vector<std::shared_ptr<AuxKernelBase>> & auxs =
     557     1122218 :         _kokkos_elemental_aux_storage[type].getActiveObjects();
     558     1122422 :     for (const auto & aux : auxs)
     559             :     {
     560         204 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     561         204 :       depend_objects.insert(uo.begin(), uo.end());
     562             :     }
     563             :   }
     564             : #endif
     565             : 
     566     1672262 :   return depend_objects;
     567           0 : }
     568             : 
     569             : std::set<std::string>
     570       61936 : AuxiliarySystem::getDependObjects()
     571             : {
     572       61936 :   std::set<std::string> depend_objects;
     573             : 
     574             :   // Elemental AuxKernels
     575             :   {
     576             :     const std::vector<std::shared_ptr<AuxKernel>> & auxs =
     577       61936 :         _elemental_aux_storage.getActiveObjects();
     578      105860 :     for (const auto & aux : auxs)
     579             :     {
     580       43924 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     581       43924 :       depend_objects.insert(uo.begin(), uo.end());
     582             :     }
     583             :   }
     584             : 
     585             :   // Elemental VectorAuxKernels
     586             :   {
     587             :     const std::vector<std::shared_ptr<VectorAuxKernel>> & auxs =
     588       61936 :         _elemental_vec_aux_storage.getActiveObjects();
     589       62090 :     for (const auto & aux : auxs)
     590             :     {
     591         154 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     592         154 :       depend_objects.insert(uo.begin(), uo.end());
     593             :     }
     594             :   }
     595             : 
     596             :   // Elemental ArrayAuxKernels
     597             :   {
     598             :     const std::vector<std::shared_ptr<ArrayAuxKernel>> & auxs =
     599       61936 :         _elemental_array_aux_storage.getActiveObjects();
     600       62001 :     for (const auto & aux : auxs)
     601             :     {
     602          65 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     603          65 :       depend_objects.insert(uo.begin(), uo.end());
     604             :     }
     605             :   }
     606             : 
     607             :   // Nodal AuxKernels
     608             :   {
     609       61936 :     const std::vector<std::shared_ptr<AuxKernel>> & auxs = _nodal_aux_storage.getActiveObjects();
     610       83948 :     for (const auto & aux : auxs)
     611             :     {
     612       22012 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     613       22012 :       depend_objects.insert(uo.begin(), uo.end());
     614             :     }
     615             :   }
     616             : 
     617             :   // Mortar Nodal AuxKernels
     618             :   {
     619             :     const std::vector<std::shared_ptr<AuxKernel>> & auxs =
     620       61936 :         _mortar_nodal_aux_storage.getActiveObjects();
     621       62014 :     for (const auto & aux : auxs)
     622             :     {
     623          78 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     624          78 :       depend_objects.insert(uo.begin(), uo.end());
     625             :     }
     626             :   }
     627             : 
     628             :   // Nodal VectorAuxKernels
     629             :   {
     630             :     const std::vector<std::shared_ptr<VectorAuxKernel>> & auxs =
     631       61936 :         _nodal_vec_aux_storage.getActiveObjects();
     632       61988 :     for (const auto & aux : auxs)
     633             :     {
     634          52 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     635          52 :       depend_objects.insert(uo.begin(), uo.end());
     636             :     }
     637             :   }
     638             : 
     639             :   // Nodal ArrayAuxKernels
     640             :   {
     641             :     const std::vector<std::shared_ptr<ArrayAuxKernel>> & auxs =
     642       61936 :         _nodal_array_aux_storage.getActiveObjects();
     643       62027 :     for (const auto & aux : auxs)
     644             :     {
     645          91 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     646          91 :       depend_objects.insert(uo.begin(), uo.end());
     647             :     }
     648             :   }
     649             : 
     650             : #ifdef MOOSE_KOKKOS_ENABLED
     651             :   // Nodal KokkosAuxKernels
     652             :   {
     653             :     const std::vector<std::shared_ptr<AuxKernelBase>> & auxs =
     654       41564 :         _kokkos_nodal_aux_storage.getActiveObjects();
     655       41720 :     for (const auto & aux : auxs)
     656             :     {
     657         156 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     658         156 :       depend_objects.insert(uo.begin(), uo.end());
     659             :     }
     660             :   }
     661             : 
     662             :   // Nodal ElementalAuxKernels
     663             :   {
     664             :     const std::vector<std::shared_ptr<AuxKernelBase>> & auxs =
     665       41564 :         _kokkos_elemental_aux_storage.getActiveObjects();
     666       41684 :     for (const auto & aux : auxs)
     667             :     {
     668         120 :       const std::set<UserObjectName> & uo = aux->getDependObjects();
     669         120 :       depend_objects.insert(uo.begin(), uo.end());
     670             :     }
     671             :   }
     672             : #endif
     673             : 
     674       61936 :   return depend_objects;
     675           0 : }
     676             : 
     677             : void
     678       56031 : AuxiliarySystem::setScalarVariableCoupleableTags(ExecFlagType type)
     679             : {
     680       56031 :   const MooseObjectWarehouse<AuxScalarKernel> & storage = _aux_scalar_storage[type];
     681       56031 :   const std::vector<std::shared_ptr<AuxScalarKernel>> & objects = storage.getActiveObjects(0);
     682             : 
     683       56031 :   std::set<TagID> needed_sc_var_matrix_tags;
     684       56031 :   std::set<TagID> needed_sc_var_vector_tags;
     685       75911 :   for (const auto & obj : objects)
     686             :   {
     687       19880 :     auto & sc_var_coup_vtags = obj->getScalarVariableCoupleableVectorTags();
     688       19880 :     needed_sc_var_vector_tags.insert(sc_var_coup_vtags.begin(), sc_var_coup_vtags.end());
     689             : 
     690       19880 :     auto & sc_var_coup_mtags = obj->getScalarVariableCoupleableMatrixTags();
     691       19880 :     needed_sc_var_matrix_tags.insert(sc_var_coup_mtags.begin(), sc_var_coup_mtags.end());
     692             :   }
     693             : 
     694       56031 :   _fe_problem.setActiveScalarVariableCoupleableMatrixTags(needed_sc_var_matrix_tags, 0);
     695       56031 :   _fe_problem.setActiveScalarVariableCoupleableVectorTags(needed_sc_var_vector_tags, 0);
     696       56031 : }
     697             : 
     698             : void
     699       56031 : AuxiliarySystem::clearScalarVariableCoupleableTags()
     700             : {
     701       56031 :   _fe_problem.clearActiveScalarVariableCoupleableMatrixTags(0);
     702       56031 :   _fe_problem.clearActiveScalarVariableCoupleableVectorTags(0);
     703       56031 : }
     704             : 
     705             : void
     706       56031 : AuxiliarySystem::computeScalarVars(ExecFlagType type)
     707             : {
     708       56031 :   setScalarVariableCoupleableTags(type);
     709             : 
     710             :   // Reference to the current storage container
     711       56031 :   const MooseObjectWarehouse<AuxScalarKernel> & storage = _aux_scalar_storage[type];
     712             : 
     713       56031 :   if (storage.hasActiveObjects())
     714             :   {
     715       54489 :     TIME_SECTION("computeScalarVars", 1);
     716             : 
     717             :     PARALLEL_TRY
     718             :     {
     719             :       // FIXME: run multi-threaded
     720       18163 :       THREAD_ID tid = 0;
     721       18163 :       if (storage.hasActiveObjects())
     722             :       {
     723       18163 :         _fe_problem.reinitScalars(tid);
     724             : 
     725             :         const std::vector<std::shared_ptr<AuxScalarKernel>> & objects =
     726       18163 :             storage.getActiveObjects(tid);
     727             : 
     728             :         // Call compute() method on all active AuxScalarKernel objects
     729       38043 :         for (const auto & obj : objects)
     730       19880 :           obj->compute();
     731             : 
     732       18163 :         const std::vector<MooseVariableScalar *> & scalar_vars = getScalarVariables(tid);
     733       56490 :         for (const auto & var : scalar_vars)
     734       38327 :           var->insert(solution());
     735             :       }
     736             :     }
     737       18163 :     PARALLEL_CATCH;
     738             : 
     739       18163 :     solution().close();
     740       18163 :     _sys.update();
     741       18163 :   }
     742             : 
     743       56031 :   clearScalarVariableCoupleableTags();
     744       56031 : }
     745             : 
     746             : void
     747     2190132 : AuxiliarySystem::computeNodalVars(ExecFlagType type)
     748             : {
     749     6570396 :   TIME_SECTION("computeNodalVars", 3);
     750             : 
     751     2190132 :   const MooseObjectWarehouse<AuxKernel> & nodal = _nodal_aux_storage[type];
     752     2190132 :   computeNodalVarsHelper<AuxKernel>(nodal);
     753     2190128 : }
     754             : 
     755             : void
     756     2190132 : AuxiliarySystem::computeNodalVecVars(ExecFlagType type)
     757             : {
     758     6570396 :   TIME_SECTION("computeNodalVecVars", 3);
     759             : 
     760     2190132 :   const MooseObjectWarehouse<VectorAuxKernel> & nodal = _nodal_vec_aux_storage[type];
     761     2190132 :   computeNodalVarsHelper<VectorAuxKernel>(nodal);
     762     2190132 : }
     763             : 
     764             : void
     765     2190132 : AuxiliarySystem::computeNodalArrayVars(ExecFlagType type)
     766             : {
     767     2190132 :   const MooseObjectWarehouse<ArrayAuxKernel> & nodal = _nodal_array_aux_storage[type];
     768     2190132 :   computeNodalVarsHelper<ArrayAuxKernel>(nodal);
     769     2190132 : }
     770             : 
     771             : void
     772     2190128 : AuxiliarySystem::computeMortarNodalVars(const ExecFlagType type)
     773             : {
     774     6570384 :   TIME_SECTION("computeMortarNodalVars", 3);
     775             : 
     776     2190128 :   const MooseObjectWarehouse<AuxKernel> & mortar_nodal_warehouse = _mortar_nodal_aux_storage[type];
     777             : 
     778             :   mooseAssert(!mortar_nodal_warehouse.hasActiveBlockObjects(),
     779             :               "We don't allow creation of block restricted mortar nodal aux kernels.");
     780             : 
     781     2190128 :   if (mortar_nodal_warehouse.hasActiveBoundaryObjects())
     782             :   {
     783         186 :     ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
     784         372 :     for (const auto & [bnd_id, mortar_nodal_auxes] :
     785         558 :          mortar_nodal_warehouse.getActiveBoundaryObjects())
     786         372 :       for (const auto index : index_range(mortar_nodal_auxes))
     787             :       {
     788             :         PARALLEL_TRY
     789             :         {
     790             :           try
     791             :           {
     792             :             ComputeMortarNodalAuxBndThread<AuxKernel> mnabt(
     793         186 :                 _fe_problem, mortar_nodal_warehouse, bnd_id, index);
     794         186 :             Threads::parallel_reduce(bnd_nodes, mnabt);
     795         186 :           }
     796           0 :           catch (libMesh::LogicError & e)
     797             :           {
     798           0 :             _fe_problem.setException("The following libMesh::LogicError was raised during mortar "
     799           0 :                                      "nodal Auxiliary variable computation:\n" +
     800           0 :                                      std::string(e.what()));
     801           0 :           }
     802           0 :           catch (MooseException & e)
     803             :           {
     804           0 :             _fe_problem.setException("The following MooseException was raised during mortar nodal "
     805           0 :                                      "Auxiliary variable computation:\n" +
     806           0 :                                      std::string(e.what()));
     807           0 :           }
     808           0 :           catch (MetaPhysicL::LogicError & e)
     809             :           {
     810           0 :             moose::translateMetaPhysicLError(e);
     811           0 :           }
     812             :         }
     813         186 :         PARALLEL_CATCH;
     814             : 
     815             :         // We need to make sure we propagate exceptions to all processes before trying to close
     816             :         // here, which is a parallel operation
     817         186 :         solution().close();
     818         186 :         _sys.update();
     819             :       }
     820             :   }
     821     2190128 : }
     822             : 
     823             : void
     824     2190128 : AuxiliarySystem::computeElementalVars(ExecFlagType type)
     825             : {
     826     6570384 :   TIME_SECTION("computeElementalVars", 3);
     827             : 
     828     2190128 :   const MooseObjectWarehouse<AuxKernel> & elemental = _elemental_aux_storage[type];
     829     2190128 :   computeElementalVarsHelper<AuxKernel>(elemental);
     830     2190087 : }
     831             : 
     832             : void
     833     2190128 : AuxiliarySystem::computeElementalVecVars(ExecFlagType type)
     834             : {
     835     6570384 :   TIME_SECTION("computeElementalVecVars", 3);
     836             : 
     837     2190128 :   const MooseObjectWarehouse<VectorAuxKernel> & elemental = _elemental_vec_aux_storage[type];
     838     2190128 :   computeElementalVarsHelper<VectorAuxKernel>(elemental);
     839     2190128 : }
     840             : 
     841             : void
     842     2190128 : AuxiliarySystem::computeElementalArrayVars(ExecFlagType type)
     843             : {
     844     2190128 :   const MooseObjectWarehouse<ArrayAuxKernel> & elemental = _elemental_array_aux_storage[type];
     845     2190128 :   computeElementalVarsHelper<ArrayAuxKernel>(elemental);
     846     2190128 : }
     847             : 
     848             : void
     849           0 : AuxiliarySystem::augmentSparsity(SparsityPattern::Graph & /*sparsity*/,
     850             :                                  std::vector<dof_id_type> & /*n_nz*/,
     851             :                                  std::vector<dof_id_type> &
     852             :                                  /*n_oz*/)
     853             : {
     854           0 : }
     855             : 
     856             : Order
     857       69341 : AuxiliarySystem::getMinQuadratureOrder()
     858             : {
     859       69341 :   Order order = CONSTANT;
     860       69341 :   std::vector<MooseVariableFEBase *> vars = _vars[0].fieldVariables();
     861      151449 :   for (const auto & var : vars)
     862             :   {
     863       82108 :     if (!var->isNodal()) // nodal aux variables do not need quadrature
     864             :     {
     865       41875 :       FEType fe_type = var->feType();
     866       41875 :       if (fe_type.default_quadrature_order() > order)
     867       21434 :         order = fe_type.default_quadrature_order();
     868             :     }
     869             :   }
     870             : 
     871       69341 :   return order;
     872       69341 : }
     873             : 
     874             : bool
     875       31243 : AuxiliarySystem::needMaterialOnSide(BoundaryID bnd_id)
     876             : {
     877       61908 :   return _elemental_aux_storage.hasActiveBoundaryObjects(bnd_id) ||
     878       61908 :          _elemental_vec_aux_storage.hasActiveBoundaryObjects(bnd_id);
     879             : }
     880             : 
     881             : void
     882         556 : AuxiliarySystem::copyCurrentIntoPreviousNL()
     883             : {
     884         556 :   if (solutionPreviousNewton())
     885         556 :     *solutionPreviousNewton() = *currentSolution();
     886         556 : }
     887             : 
     888             : template <typename AuxKernelType>
     889             : void
     890     6570384 : AuxiliarySystem::computeElementalVarsHelper(const MooseObjectWarehouse<AuxKernelType> & warehouse)
     891             : {
     892     6570384 :   if (warehouse.hasActiveBlockObjects())
     893             :   {
     894             :     // Block Elemental AuxKernels
     895             :     PARALLEL_TRY
     896             :     {
     897       81078 :       ConstElemRange & range = *_mesh.getActiveLocalElementRange();
     898       81078 :       ComputeElemAuxVarsThread<AuxKernelType> eavt(_fe_problem, warehouse, true);
     899             :       try
     900             :       {
     901       81078 :         Threads::parallel_reduce(range, eavt);
     902             :       }
     903           0 :       catch (MooseException & e)
     904             :       {
     905           0 :         _fe_problem.setException("The following MooseException was raised during elemental "
     906             :                                  "Auxiliary variable computation:\n" +
     907           0 :                                  std::string(e.what()));
     908             :       }
     909       81045 :     }
     910       81045 :     PARALLEL_CATCH;
     911             : 
     912             :     // We need to make sure we propagate exceptions to all processes before trying to close
     913             :     // here, which is a parallel operation
     914       81045 :     solution().close();
     915       81045 :     _sys.update();
     916             :   }
     917             : 
     918             :   // Boundary Elemental AuxKernels
     919     6570351 :   if (warehouse.hasActiveBoundaryObjects())
     920             :   {
     921       82011 :     TIME_SECTION("computeElementalVecVars", 3);
     922             : 
     923             :     PARALLEL_TRY
     924             :     {
     925       27337 :       ConstBndElemRange & bnd_elems = *_mesh.getBoundaryElementRange();
     926       27337 :       ComputeElemAuxBcsThread<AuxKernelType> eabt(_fe_problem, warehouse, true);
     927             :       try
     928             :       {
     929       27337 :         Threads::parallel_reduce(bnd_elems, eabt);
     930             :       }
     931           0 :       catch (MooseException & e)
     932             :       {
     933           0 :         _fe_problem.setException("The following MooseException was raised during boundary "
     934             :                                  "elemental Auxiliary variable computation:\n" +
     935           0 :                                  std::string(e.what()));
     936             :       }
     937       27329 :     }
     938       27329 :     PARALLEL_CATCH;
     939             : 
     940             :     // We need to make sure we propagate exceptions to all processes before trying to close
     941             :     // here, which is a parallel operation
     942       27329 :     solution().close();
     943       27329 :     _sys.update();
     944       27329 :   }
     945     6570343 : }
     946             : 
     947             : template <typename AuxKernelType>
     948             : void
     949     6570396 : AuxiliarySystem::computeNodalVarsHelper(const MooseObjectWarehouse<AuxKernelType> & warehouse)
     950             : {
     951     6570396 :   if (warehouse.hasActiveBlockObjects())
     952             :   {
     953             :     // Block Nodal AuxKernels
     954             :     PARALLEL_TRY
     955             :     {
     956      148550 :       ConstNodeRange & range = *_mesh.getLocalNodeRange();
     957      148550 :       ComputeNodalAuxVarsThread<AuxKernelType> navt(_fe_problem, warehouse);
     958      148550 :       Threads::parallel_reduce(range, navt);
     959             : 
     960      148546 :       solution().close();
     961      148546 :       _sys.update();
     962      148546 :     }
     963      148546 :     PARALLEL_CATCH;
     964             :   }
     965             : 
     966     6570392 :   if (warehouse.hasActiveBoundaryObjects())
     967             :   {
     968      276711 :     TIME_SECTION("computeBoundaryObjects", 3);
     969             : 
     970             :     // Boundary Nodal AuxKernels
     971             :     PARALLEL_TRY
     972             :     {
     973       92237 :       ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
     974       92237 :       ComputeNodalAuxBcsThread<AuxKernelType> nabt(_fe_problem, warehouse);
     975       92237 :       Threads::parallel_reduce(bnd_nodes, nabt);
     976             : 
     977       92237 :       solution().close();
     978       92237 :       _sys.update();
     979       92237 :     }
     980       92237 :     PARALLEL_CATCH;
     981       92237 :   }
     982     6570392 : }
     983             : 
     984             : void
     985         553 : AuxiliarySystem::variableWiseRelativeSolutionDifferenceNorm(
     986             :     std::vector<Number> & rel_diff_norms) const
     987             : {
     988         553 :   rel_diff_norms.resize(nVariables(), 0);
     989             :   // Get dof map from system
     990         553 :   const auto & dof_map = _sys.get_dof_map();
     991             : 
     992        1659 :   for (const auto n : make_range(nVariables()))
     993             :   {
     994             :     // Get local indices from dof map for each variable
     995        1106 :     std::vector<dof_id_type> local_indices_n;
     996        1106 :     dof_map.local_variable_indices(local_indices_n, _mesh, n);
     997        1106 :     Number diff_norm_n = 0;
     998        1106 :     Number norm_n = 0;
     999             :     // Get values from system, update norm
    1000      101536 :     for (const auto local_index : local_indices_n)
    1001             :     {
    1002      100430 :       const Number & value = solution()(local_index);
    1003      100430 :       const Number & value_old = solutionOld()(local_index);
    1004      100430 :       diff_norm_n += Utility::pow<2, Number>(value - value_old);
    1005      100430 :       norm_n += Utility::pow<2, Number>(value);
    1006             :     }
    1007             :     // Aggregate norm over proceccors
    1008        1106 :     _communicator.sum(diff_norm_n);
    1009        1106 :     _communicator.sum(norm_n);
    1010        1106 :     diff_norm_n = sqrt(diff_norm_n);
    1011        1106 :     norm_n = sqrt(norm_n);
    1012        1106 :     rel_diff_norms[n] = diff_norm_n / norm_n;
    1013        1106 :   }
    1014         553 : }
    1015             : 
    1016             : template void
    1017             : AuxiliarySystem::computeElementalVarsHelper<AuxKernel>(const MooseObjectWarehouse<AuxKernel> &);
    1018             : template void AuxiliarySystem::computeElementalVarsHelper<VectorAuxKernel>(
    1019             :     const MooseObjectWarehouse<VectorAuxKernel> &);
    1020             : template void
    1021             : AuxiliarySystem::computeNodalVarsHelper<AuxKernel>(const MooseObjectWarehouse<AuxKernel> &);
    1022             : template void AuxiliarySystem::computeNodalVarsHelper<VectorAuxKernel>(
    1023             :     const MooseObjectWarehouse<VectorAuxKernel> &);

Generated by: LCOV version 1.14