31#include "libmesh/dof_map.h"
32#include "libmesh/string_to_enum.h"
33#include "libmesh/fe_interface.h"
34#include "libmesh/static_condensation.h"
47 std::vector<dof_id_type> & n_nz,
48 std::vector<dof_id_type> & n_oz,
57 const std::string & name,
59 :
libMesh::ParallelObject(subproblem),
61 _subproblem(subproblem),
62 _fe_problem(fe_problem),
63 _app(subproblem.getMooseApp()),
64 _factory(_app.getFactory()),
65 _mesh(subproblem.
mesh()),
73 _u_dotdot_old(nullptr),
75 _saved_older(nullptr),
76 _saved_dot_old(nullptr),
77 _saved_dotdot_old(nullptr),
79 _max_var_n_dofs_per_elem(0),
80 _max_var_n_dofs_per_node(0),
81 _automatic_scaling(false),
83 _solution_states_initialized(false),
84 _skip_next_solution_to_old_copy(false)
94 mooseError(
"Variable '", var_name,
"' does not exist in this system");
112 return *
_vars[tid].getFieldVariable<T>(var_name);
119 return *
_vars[tid].getActualFieldVariable<T>(var_name);
126 return *
_vars[tid].getFVVariable<T>(var_name);
133 return *
_vars[tid].getFieldVariable<T>(var_number);
140 return *
_vars[tid].getActualFieldVariable<T>(var_number);
148 mooseError(
"Scalar variable '" + var_name +
"' does not exist in this system");
162const std::set<SubdomainID> *
165 mooseAssert(
_var_map.find(var_number) !=
_var_map.end(),
"Variable does not exist.");
192 aldit.dofIndicesSetUnion();
194 const auto & all_dof_indices = aldit.getDofIndices();
201 if (vars_to_be_zeroed.size() > 0)
207 mooseError(
"System needs to be registered in FEProblemBase for using zeroVariables.");
217 for (
const auto & dof : dof_indices_to_zero)
242 Order order = CONSTANT;
243 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[0].fieldVariables();
244 for (
const auto & var :
vars)
246 FEType fe_type = var->feType();
247 if (fe_type.default_quadrature_order() > order)
248 order = fe_type.default_quadrature_order();
259 const std::set<MooseVariableFieldBase *> & active_elemental_moose_variables =
261 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
262 for (
const auto & var :
vars)
263 var->clearDofIndices();
265 for (
const auto & var : active_elemental_moose_variables)
266 if (&(var->sys()) ==
this)
271 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
272 for (
const auto & var :
vars)
283 const std::set<MooseVariableFieldBase *> & active_elemental_moose_variables =
286 std::vector<MooseVariableFieldBase *> newly_prepared_vars;
288 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
289 for (
const auto & var :
vars)
291 mooseAssert(&var->sys() ==
this,
292 "I will cry if we store variables in our warehouse that don't belong to us");
304 if (!active_elemental_moose_variables.count(var))
307 newly_prepared_vars.push_back(var);
313 for (
const auto var_ptr : newly_prepared_vars)
325 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
326 for (
const auto & var :
vars)
333 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
334 for (
const auto & var :
vars)
335 var->prepareLowerD();
343 const std::set<MooseVariableFieldBase *> & active_elemental_moose_variables =
345 for (
const auto & var : active_elemental_moose_variables)
346 if (&(var->sys()) ==
this)
347 var->computeElemValues();
351 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
352 for (
const auto & var :
vars)
353 var->computeElemValues();
360 cast_ptr<libMesh::StaticCondensation *>(matrix)->set_current_elem(*elem);
367 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
368 for (
const auto & var :
vars)
369 var->computeElemValuesFace();
375 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
376 for (
const auto & var :
vars)
377 var->computeNeighborValuesFace();
383 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
384 for (
const auto & var :
vars)
385 var->computeNeighborValues();
391 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
392 for (
const auto & var :
vars)
393 var->computeLowerDValues();
399 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
400 for (
const auto & var :
vars)
403 if (var->isNodalDefined())
404 var->computeNodalValues();
411 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
412 for (
const auto & var :
vars)
415 if (var->isNodalDefined())
416 var->computeNodalValues();
423 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
424 for (
const auto & var :
vars)
426 var->reinitNodes(nodes);
427 var->computeNodalValues();
434 const std::vector<MooseVariableFieldBase *> &
vars =
_vars[tid].fieldVariables();
435 for (
const auto & var :
vars)
437 var->reinitNodesNeighbor(nodes);
438 var->computeNodalNeighborValues();
445 const std::vector<MooseVariableScalar *> &
vars =
_vars[tid].scalars();
446 for (
const auto & var :
vars)
447 var->reinit(reinit_for_derivative_reordering);
455 DofMap & dof_map =
dofMap();
457 std::vector<dof_id_type> dof_indices;
461 unsigned int sys_num = sys.number();
463 unsigned int n_vars = sys.n_vars();
465 for (
const auto & elem_id : ghosted_elems)
471 dof_map.dof_indices(elem, dof_indices);
474 for (
const auto & dof : dof_indices)
475 if (dof < dof_map.first_dof() || dof >= dof_map.end_dof())
476 send_list.push_back(dof);
481 for (
unsigned int n = 0; n < elem->n_nodes(); n++)
483 Node * node = elem->node_ptr(n);
486 for (
unsigned int v = 0; v <
n_vars; v++)
489 unsigned int var_num = var.
number();
493 if (node->n_dofs(sys_num, var_num) > 0)
496 for (
unsigned int c = 0; c < n_comp; c++)
497 send_list.push_back(node->dof_number(sys_num, var_num, c));
515 for (
unsigned int i = 1; i <= num_states - 1; ++i)
518 &
addVector(
"save_solution_state_" + std::to_string(i),
false, PARALLEL);
520 for (
unsigned int i = 1; i <= num_states - 1; ++i)
544 for (
unsigned int i = 1; i <= num_states - 1; ++i)
548 removeVector(
"save_solution_state_" + std::to_string(i));
566SparseMatrix<Number> &
570 mooseError(
"Cannot add tagged matrix with TagID ",
574 "' because the tag does not exist in the problem");
590 mooseError(
"Cannot remove the matrix with TagID ",
594 "', because that tag does not exist in the problem");
604NumericVector<Number> &
612 NumericVector<Number> & vec =
system().
add_vector(vector_name, project, type);
616NumericVector<Number> &
620 mooseError(
"Cannot add tagged vector with TagID ",
624 "' because the tag does not exist in the problem");
630 if (type != AUTOMATIC && vec.type() != type)
635 "' because a vector with the same name was found with a different parallel type");
641 NumericVector<Number> & vec =
system().
add_vector(vector_name, project, type);
655 "' because that tag does not exist in the problem");
657 mooseError(
"Cannot close vector tag with name '",
661 "' because there is no vector associated with that tag");
668 for (
const auto tag : tags)
680 "' because that tag does not exist in the problem");
682 mooseError(
"Cannot zero vector tag with name '",
686 "' because there is no vector associated with that tag");
694 for (
const auto tag : tags)
702 mooseError(
"Cannot remove the vector with TagID ",
706 "', because that tag does not exist in the problem");
718 const std::string & name,
723 const auto components = parameters.
get<
unsigned int>(
"components");
727 std::set<SubdomainID>
blocks;
728 const auto & block_param = parameters.
get<std::vector<SubdomainName>>(
"block");
729 for (
const auto & subdomain_name : block_param)
736 const auto fe_field_type = FEInterface::field_type(fe_type);
738 unsigned int var_num;
740 if (var_type ==
"ArrayMooseVariable")
743 mooseError(
"Vector family type cannot be used in an array variable");
745 std::vector<std::string> array_var_component_names;
746 const bool has_array_names = parameters.
isParamValid(
"array_var_component_names");
749 array_var_component_names =
750 parameters.
get<std::vector<std::string>>(
"array_var_component_names");
751 if (array_var_component_names.size() != components)
752 parameters.
paramError(
"array_var_component_names",
753 "Must be the same size as 'components' (size ",
755 ") for array variable '",
761 std::vector<std::string> var_names;
762 for (
unsigned int i = 0; i < components; i++)
764 if (!has_array_names)
765 array_var_component_names.push_back(std::to_string(i));
766 var_names.push_back(
name +
"_" + array_var_component_names[i]);
770 parameters.
set<std::vector<std::string>>(
"array_var_component_names") =
771 array_var_component_names;
780 "Must be set to true for variable '",
782 "' because 'components' > 1 (is an array variable)");
783 parameters.
set<
bool>(
"array") =
true;
788 parameters.
paramError(
"array_var_component_names",
789 "Should not be set because this variable (",
791 ") is a non-array variable");
795 parameters.
set<
unsigned int>(
"_var_num") = var_num;
801 std::shared_ptr<MooseVariableBase> var =
808 auto required_size = var_num + components;
811 for (MooseIndex(components) component = 0; component < components; ++component)
829 mooseError(
"Scalar variables should be functors");
832 if (var->blockRestricted())
834 for (MooseIndex(components) component = 0; component < components; ++component)
835 _var_map[var_num + component].insert(
id);
837 for (MooseIndex(components) component = 0; component < components; ++component)
838 _var_map[var_num + component] = std::set<SubdomainID>();
851 if (
system().has_variable(var_name))
853 if (std::find(names.begin(), names.end(), var_name) != names.end())
864 if (!
system().has_variable(var_name) &&
865 std::find(names.begin(), names.end(), var_name) != names.end())
875 if (
system().has_variable(var_name))
884 return (
system().variable(var_num).type().family == SCALAR);
891 n +=
_vars[0].scalars().size();
900 for (
auto & var :
_vars[0].fieldVariables())
910 for (
auto & var :
_vars[0].fieldVariables())
929NumericVector<Number> &
935const NumericVector<Number> &
941NumericVector<Number> &
947 mooseError(
"Cannot retrieve vector with tag ", tag,
" because that tag does not exist");
949 mooseError(
"Cannot retrieve vector with tag ",
953 "'\nbecause a vector has not been associated with that tag.");
959const NumericVector<Number> &
965 mooseError(
"Cannot retrieve vector with tag ", tag,
" because that tag does not exist");
967 mooseError(
"Cannot retrieve vector with tag ",
971 "'\nbecause a vector has not been associated with that tag.");
981 mooseError(
"Cannot associate vector to tag ", tag,
" because that tag does not exist");
993 mooseError(
"Cannot disassociate vector from tag ", tag,
" because that tag does not exist");
995 mooseError(
"You can not disassociate a vector from a tag which it was not associated to");
1004 mooseError(
"Cannot disassociate vector from tag ", tag,
" because that tag does not exist");
1015 for (
const auto tag : tags)
1020SparseMatrix<Number> &
1026 mooseError(
"Cannot retrieve matrix with tag ", tag,
" because that tag does not exist");
1028 mooseError(
"Cannot retrieve matrix with tag ",
1032 "'\nbecause a matrix has not been associated with that tag.");
1038const SparseMatrix<Number> &
1044 mooseError(
"Cannot retrieve matrix with tag ", tag,
" because that tag does not exist");
1046 mooseError(
"Cannot retrieve matrix with tag ",
1050 "'\nbecause a matrix has not been associated with that tag.");
1059 for (
auto tag : tags)
1067 for (
auto tag : tags)
1076 mooseError(
"Cannot associate matrix to tag ", tag,
" because that tag does not exist");
1088 mooseError(
"Cannot disassociate matrix from tag ", tag,
" because that tag does not exist");
1090 mooseError(
"You can not disassociate a matrix from a tag which it was not associated to");
1099 mooseError(
"Cannot disassociate matrix from tag ", tag,
" because that tag does not exist");
1110 for (
const auto tag : tags)
1122 for (
decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
1135 for (
const auto tag : make_range(num_matrix_tags))
1173 const std::string & source_name,
1174 const std::string & timestep)
1182 int n_steps = io.get_num_time_steps();
1184 bool did_copy =
false;
1189 if (vci._timestep ==
"LATEST")
1194 timestep = MooseUtils::convert<int>(vci._timestep);
1195 if (timestep > n_steps)
1196 mooseError(
"Invalid value passed as \"initial_from_file_timestep\". Expected \"LATEST\" or "
1197 "a valid integer between 1 and ",
1199 " inclusive, received ",
1207 const auto & var =
getVariable(0, vci._dest_name);
1210 const auto & array_var = getFieldVariable<RealEigenVector>(0, vci._dest_name);
1211 for (MooseIndex(var.count()) i = 0; i < var.count(); ++i)
1213 const auto & exodus_var = var.arrayVariableComponent(i);
1214 const auto & system_var = array_var.componentName(i);
1216 io.copy_nodal_solution(
system(), exodus_var, system_var, timestep);
1218 io.copy_elemental_solution(
system(), exodus_var, system_var, timestep);
1224 io.copy_nodal_solution(
system(), vci._dest_name, vci._source_name, timestep);
1226 io.copy_elemental_solution(
system(), vci._dest_name, vci._source_name, timestep);
1230 io.copy_scalar_solution(
system(), {vci._dest_name}, {vci._source_name}, timestep);
1232 mooseError(
"Unrecognized variable ", vci._dest_name,
" in variables to copy.");
1275 const bool skip_old =
1281 const std::size_t stop = skip_old ? 1 : 0;
1282 for (std::size_t i = num_states - 1; i > stop; --i)
1287 switch (iteration_type)
1310 const bool skip_current_to_old =
1332 mooseError(
"Cannot restore solutions without old solution");
1364NumericVector<Number> *
1373const NumericVector<Number> *
1386 unsigned int state = 0;
1390 state = std::max(state, var->oldestSolutionStateRequested());
1392 state = std::max(state, var->oldestSolutionStateRequested());
1403 mooseAssert(state != 0,
"Not an old state");
1404 mooseAssert(
static_cast<unsigned short>(iteration_type) <
1406 "Invalid iteration_type");
1408 switch (iteration_type)
1413 else if (state == 2)
1432 return "solution_state_" + std::to_string(state) +
"_" +
Moose::stringify(iteration_type);
1435const NumericVector<Number> &
1444 "': solution state ",
1446 " was requested in ",
1448 " but only up to state ",
1449 (num_states == 0) ? 0 : num_states - 1,
1456 mooseAssert(solution_states[0] == &
solutionInternal(),
"Inconsistent current solution");
1458 mooseAssert(solution_states[state] ==
1460 "Inconsistent solution state");
1462 return *solution_states[state];
1465NumericVector<Number> &
1479 mooseError(
"solutionStateParallelType() may only be called if the solution state exists.");
1488 libmesh_parallel_only(this->
comm());
1490 "This routine is not thread-safe. Request the solution state before using it in "
1491 "a threaded region.");
1497 solution_states.resize(state + 1);
1500 if (!solution_states[0])
1503 mooseAssert(solution_states[0] == &
solutionInternal(),
"Inconsistent current solution");
1506 for (
unsigned int i = 1; i <= state; ++i)
1507 if (!solution_states[i])
1511 solution_states[i] = &
addVector(tag,
true, parallel_type);
1521 mooseError(
"The solution state has already been declared as PARALLEL");
1524 "Inconsistent solution state");
1531 for (MooseIndex(
_vars) thread = 0; thread <
_vars.size(); ++thread)
1533 auto & field_variables =
_vars[thread].fieldVariables();
1534 for (MooseIndex(field_variables) i = 0, p = 0; i < field_variables.size(); ++i)
1536 auto factors = field_variables[i]->arrayScalingFactor();
1537 for (
unsigned int j = 0; j < field_variables[i]->count(); ++j, ++p)
1538 factors[j] /= inverse_scaling_factors[p];
1540 field_variables[i]->scalingFactor(factors);
1543 auto offset = field_variables.size();
1545 auto & scalar_variables =
_vars[thread].scalars();
1546 for (MooseIndex(scalar_variables) i = 0; i < scalar_variables.size(); ++i)
1547 scalar_variables[i]->scalingFactor(
1548 {1. / inverse_scaling_factors[offset + i] * scalar_variables[i]->scalingFactor()});
1552 _console <<
"Automatic scaling factors:\n";
1558 for (
const auto & field_variable : field_variables)
1560 const auto & factors = field_variable->arrayScalingFactor();
1561 _console <<
" " << field_variable->name() <<
":";
1562 for (
const auto i : make_range(field_variable->count()))
1566 for (
const auto & scalar_variable : scalar_variables)
1567 _console <<
" " << scalar_variable->name() <<
": " << scalar_variable->scalingFactor()
1581 addVector(
"scaling_factors",
false, GHOSTED);
1636 for (
auto & var_warehouse :
_vars)
1637 var_warehouse.clearAllDofIndices();
1643 _vars[tid].setActiveVariableCoupleableVectorTags(vtags);
1650 _vars[tid].setActiveScalarVariableCoupleableVectorTags(vtags);
1666NumericVector<Number> &
1680 const std::string & name,
1697 if (ti->integratesVar(var_num))
1711 mooseError(
"No time integrator found that integrates variable number ",
1712 std::to_string(var_num));
1715const std::vector<std::shared_ptr<TimeIntegrator>> &
1727const std::set<SubdomainID> &
1742 for (
const auto & warehouse :
_vars)
1743 for (
const auto & [var_num, var_ptr] : warehouse.numberToVariableMap())
1744 var_ptr->sizeMatrixTagData();
1748 const std::string & var_name);
1751SystemBase::getFieldVariable<RealVectorValue>(
THREAD_ID tid,
const std::string & var_name);
1754SystemBase::getFieldVariable<RealEigenVector>(
THREAD_ID tid,
const std::string & var_name);
1757 unsigned int var_number);
1760SystemBase::getFieldVariable<RealVectorValue>(
THREAD_ID tid,
unsigned int var_number);
1763SystemBase::getFieldVariable<RealEigenVector>(
THREAD_ID tid,
unsigned int var_number);
1766SystemBase::getActualFieldVariable<Real>(
THREAD_ID tid,
const std::string & var_name);
1769SystemBase::getActualFieldVariable<RealVectorValue>(
THREAD_ID tid,
const std::string & var_name);
1772SystemBase::getActualFieldVariable<RealEigenVector>(
THREAD_ID tid,
const std::string & var_name);
1775SystemBase::getActualFieldVariable<Real>(
THREAD_ID tid,
unsigned int var_number);
1778SystemBase::getActualFieldVariable<RealVectorValue>(
THREAD_ID tid,
unsigned int var_number);
1781SystemBase::getActualFieldVariable<RealEigenVector>(
THREAD_ID tid,
unsigned int var_number);
1784 const std::string & var_name);
boundary_id_type BoundaryID
subdomain_id_type SubdomainID
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
for(PetscInt i=0;i< nvars;++i)
void extraSendList(std::vector< dof_id_type > &send_list, void *context)
Free function used for a libMesh callback.
void extraSparsity(libMesh::SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz, void *context)
Free function used for a libMesh callback.
Grab all the (possibly semi)local dof indices for the variables passed in, in the system passed in.
const std::set< dof_id_type > & getDofIndices() const
An inteface for the _console for outputting to the Console object.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
std::ios_base::fmtflags flags() const
Return the current flags.
std::streamsize precision() const
Return the current precision.
void unsetf(std::ios_base::fmtflags mask) const
Unset format flags.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual bool uDotRequested()
Get boolean flag to check whether solution time derivative needs to be stored.
virtual bool uDotOldRequested()
Get boolean flag to check whether old solution time derivative needs to be stored.
virtual bool uDotDotRequested()
Get boolean flag to check whether solution second time derivative needs to be stored.
virtual bool uDotDotOldRequested()
Get boolean flag to check whether old solution second time derivative needs to be stored.
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, const InputParameters ¶meters, THREAD_ID tid=0, bool print_deprecated=true)
Class for containing MooseEnum item information.
virtual Elem * elemPtr(const dof_id_type i)
SubdomainID getSubdomainID(const SubdomainName &subdomain_name) const
Get the associated subdomain ID for the subdomain name.
const libMesh::ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems,...
Class for stuff related to variables.
This class provides variable solution values for other classes/objects to bind to when looping over f...
This class provides an interface for common operations on field variables of both FE and FV types wit...
Class for stuff related to variables.
Class for scalar variables (they are different).
Base class template for functor objects.
Generic class for solving transient nonlinear problems.
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
virtual bool computingScalingJacobian() const =0
Getter for whether we're computing the scaling jacobian.
virtual const std::set< MooseVariableFieldBase * > & getActiveElementalMooseVariables(const THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
void hasScalingVector(const unsigned int nl_sys_num)
Tells this problem that the assembly associated with the given nonlinear system number involves a sca...
virtual std::set< dof_id_type > & ghostedElems()
Return the list of elements that should have their DoFs ghosted to this processor.
virtual unsigned int numMatrixTags() const
The total number of tags.
virtual TagName matrixTagName(TagID tag)
Retrieve the name associated with a TagID.
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num)=0
virtual bool hasActiveElementalMooseVariables(const THREAD_ID tid) const
Whether or not a list of active elemental moose variables has been set.
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
virtual bool checkNonlocalCouplingRequirement() const =0
bool vectorTagNotZeroed(const TagID tag) const
Checks if a vector tag is in the list of vectors that will not be zeroed when other tagged vectors ar...
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
void addFunctor(const std::string &name, const Moose::FunctorBase< T > &functor, const THREAD_ID tid)
add a functor to the problem functor container
Base class for a system (of equations)
std::unique_ptr< NumericVector< Number > > _serialized_solution
Serialized version of the solution vector, or nullptr if a serialized solution is not needed.
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
virtual void addVariableToZeroOnJacobian(std::string var_name)
Adds this variable to the list of variables to be zeroed during each Jacobian evaluation.
void zeroTaggedVector(const TagID tag)
Zero vector with the given tag.
virtual void zeroVariables(std::vector< std::string > &vars_to_be_zeroed)
Zero out the solution for the list of variables passed in.
NumericVector< Number > * _u_dot
solution vector for u^dot
virtual void prepareNeighbor(THREAD_ID tid)
Prepare the system for use.
virtual const NumericVector< Number > *const & currentSolution() const =0
The solution vector that is currently being operated on.
virtual void reinitNode(const Node *node, THREAD_ID tid)
Reinit nodal assembly info.
virtual void addVariableToZeroOnResidual(std::string var_name)
Adds this variable to the list of variables to be zeroed during each residual evaluation.
virtual void copySolutionsBackwards()
Copy current solution into old and older.
virtual void zeroVariablesForJacobian()
Zero out the solution for the variables that were registered as needing to have their solutions zeroe...
virtual void augmentSparsity(libMesh::SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz)=0
Will modify the sparsity pattern to add logical geometric connections.
bool _solution_states_initialized
Whether or not the solution states have been initialized.
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
virtual std::set< TagID > defaultMatrixTags() const
Get the default matrix tags associted with this system.
virtual void deactivateAllMatrixTags()
Make matrices inactive.
virtual NumericVector< Number > & solutionInternal() const =0
Internal getter for solution owned by libMesh.
virtual void reinitElem(const Elem *elem, THREAD_ID tid)
Reinit an element assembly info.
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of nodes.
bool _verbose
True if printing out additional information.
void copyOldSolutions()
Copy the solution back in time (older -> old, etc).
FEProblemBase & _fe_problem
the governing finite element/volume problem
virtual void reinitNeighbor(const Elem *elem, THREAD_ID tid)
Compute the values of the variables at all the current points.
TagName oldSolutionStateVectorName(const unsigned int, Moose::SolutionIterationType iteration_type) const
Gets the vector name used for an old (not current) solution state.
const std::set< SubdomainID > & getSubdomainsForVar(unsigned int var_number) const
virtual void subdomainSetup()
virtual void reinitNeighborFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Compute the values of the variables at all the current points.
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
void addTimeIntegrator(const std::string &type, const std::string &name, InputParameters ¶meters)
std::string prefix() const
std::vector< std::string > _vars_to_be_zeroed_on_residual
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
virtual unsigned int nVariables() const
Get the number of variables in this system.
MooseVariableFE< T > & getFieldVariable(THREAD_ID tid, const std::string &var_name)
Gets a reference to a variable of with specified name.
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
virtual NumericVector< Number > * solutionUDot()
virtual bool isArrayVariable(const std::string &var_name) const
If a variable is an array variable.
virtual void augmentSendList(std::vector< dof_id_type > &send_list)
Will modify the send_list to add all of the extra ghosted dofs for this system.
virtual void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering=false)
Reinit scalar varaibles.
unsigned int number() const
Gets the number of this system.
virtual void saveOldSolutions()
Save the old and older solutions.
virtual void restoreOldSolutions()
Restore the old and older solutions when the saved solutions present.
virtual bool isScalarVariable(unsigned int var_name) const
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
void restoreStateHistory()
Restore solution vectors and additional system-owned state together.
virtual void activateAllMatrixTags()
Make all existing matrices active.
unsigned int nFieldVariables() const
Get the number of field variables in this system.
void advanceStateHistory(Moose::SolutionIterationType iteration_type)
Advance solution vectors and additional system-owned state together.
virtual void addVariableToCopy(const std::string &dest_name, const std::string &source_name, const std::string ×tep)
Add info about variable that will be copied.
const std::vector< VariableName > & getVariableNames() const
void removeVector(const std::string &name)
Remove a vector from the system with the given name.
virtual void zeroVariablesForResidual()
Zero out the solution for the variables that were registered as needing to have their solutions zeroe...
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters ¶meters)
Canonical method for adding a variable.
MooseVariableFV< T > & getFVVariable(THREAD_ID tid, const std::string &var_name)
Return a finite volume variable.
std::unordered_map< TagID, libMesh::SparseMatrix< Number > * > _active_tagged_matrices
Active tagged matrices. A matrix is active if its tag-matrix pair is present in the map....
virtual void addDotVectors()
Add u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator.
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
virtual void needSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time, libMesh::ParallelType parallel_type=GHOSTED)
Registers that the solution state state is needed.
const std::vector< MooseVariableFieldBase * > & getVariables(THREAD_ID tid)
virtual bool matrixTagActive(TagID tag) const
If or not a matrix tag is active.
virtual void customSetup(const ExecFlagType &exec_type)
NumericVector< Number > & solutionOld()
const TimeIntegrator & getTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable's equation.
unsigned int nFVVariables() const
Get the number of finite volume variables in this system.
virtual void disassociateMatrixFromTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.
void setActiveScalarVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the scalar variables.
NumericVector< Real > * _saved_dotdot_old
void copyStateHistoryBackwards()
Copy solution vectors and additional system-owned state into older states.
void setVariableGlobalDoFs(const std::string &var_name)
set all the global dof indices for a variable
virtual void initialSetup()
Setup Functions.
virtual void initSolutionState()
Initializes the solution state.
virtual void timestepSetup()
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
virtual void jacobianSetup()
virtual void residualSetup()
MooseVariableField< T > & getActualFieldVariable(THREAD_ID tid, const std::string &var_name)
Returns a field variable pointer - this includes finite volume variables.
bool computingScalingJacobian() const
Whether we are computing an initial Jacobian for automatic variable scaling.
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of neighbor nodes.
std::vector< Real > _du_dot_du
Derivative of time derivative of u with respect to uj.
virtual void disassociateDefaultVectorTags()
Disassociate the vectors associated with the default vector tags of this system.
virtual void restoreSolutions()
Restore current solutions (call after your solve failed)
libMesh::ParallelType solutionStateParallelType(const unsigned int state, const Moose::SolutionIterationType iteration_type) const
Returns the parallel type of the given solution state.
virtual void reinitLowerD(THREAD_ID tid)
Compute the values of the variables on the lower dimensional element.
virtual NumericVector< Number > * solutionUDotOld()
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
virtual void prepare(THREAD_ID tid)
Prepare the system for use.
SystemBase(SubProblem &subproblem, FEProblemBase &fe_problem, const std::string &name, Moose::VarKindType var_kind)
void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
std::size_t getNumSolutionStates(const Moose::SolutionIterationType iteration_type) const
Get the number of solution states (0 = current, 1 = current + old, ...) for the given iteration type.
virtual const std::set< SubdomainID > * getVariableBlocks(unsigned int var_number)
Get the block where a variable of this system is defined.
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a scalar variable with specified number.
virtual bool hasScalarVariable(const std::string &var_name) const
virtual void reinitElemFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Reinit assembly info for a side of an element.
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid)
Reinit nodal assembly info on a face.
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
void copyPreviousSolutions(const Moose::SolutionIterationType iteration_type)
Copy a specific type of solution back in time (current -> old -> older, etc).
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
void closeTaggedMatrices(const std::set< TagID > &tags)
Close all matrices associated the tags.
virtual const NumericVector< Number > * solutionPreviousNewton() const
const std::vector< std::shared_ptr< TimeIntegrator > > & getTimeIntegrators()
const std::vector< NumericVector< Number > * > & getSolutionStates(const Moose::SolutionIterationType iteration_type) const
Get all of the solution states (current, old, ...) for the given iteration type.
virtual const Number & duDotDu(unsigned int var_num=0) const
void flushTaggedMatrices(const std::set< TagID > &tags)
flushes all matrices associated to tags.
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
void applyScalingFactors(const std::vector< Real > &inverse_scaling_factors)
Applies scaling factors to the system's variables.
NumericVector< Real > * _saved_dot_old
virtual void restoreAdditionalStates()
Restore system-owned state not represented by solution vectors.
virtual void associateMatrixToTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Associate a matrix to a tag.
libMesh::SparseMatrix< Number > & addMatrix(TagID tag)
Adds a matrix with a given tag.
void clearAllDofIndices()
Clear all dof indices from moose variables.
NumericVector< Number > * _u_dotdot_old
old solution vector for u^dotdot
virtual const std::string & name() const
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
void addScalingVector()
Add the scaling factor vector to the system.
void copyTimeIntegrators(const SystemBase &other_sys)
Copy time integrators from another system.
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
unsigned int _max_var_number
Maximum variable number.
virtual void disassociateDefaultMatrixTags()
Disassociate the matrices associated with the default matrix tags of this system.
void copyVars(libMesh::ExodusII_IO &io)
void removeMatrix(TagID tag)
Removes a matrix with a given tag.
void setActiveVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the variables.
bool _skip_next_solution_to_old_copy
Whether to skip the next copy from the solution to the old vector.
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
virtual bool hasSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
Whether or not the system has the solution state (0 = current, 1 = old, 2 = older,...
std::vector< VarCopyInfo > _var_to_copy
NumericVector< Number > & solution()
NumericVector< Number > * _u_dot_old
old solution vector for u^dot
std::vector< NumericVector< Number > * > _saved_solution_states
The saved solution states (0 = current, 1 = old, 2 = older, etc)
virtual NumericVector< Number > * solutionUDotDotOld()
void sizeVariableMatrixData()
size the matrix data for each variable for the number of matrix tags we have
virtual void copyAdditionalStateBackwards(Moose::SolutionIterationType, bool)
Copy system-owned state not represented by solution vectors.
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
std::vector< dof_id_type > _var_all_dof_indices
Container for the dof indices of a given variable.
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
const TimeIntegrator * queryTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable's equation.
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
virtual libMesh::Order getMinQuadratureOrder()
Get minimal quadrature order needed for integrating variables in this system.
void update()
Update the system (doing libMesh magic)
virtual void prepareFace(THREAD_ID tid, bool resize_data)
Prepare the system for use on sides.
virtual std::set< TagID > defaultVectorTags() const
Get the default vector tags associated with this system.
void closeTaggedVector(const TagID tag)
Close vector with the given tag.
virtual void solve()
Solve the system (using libMesh magic)
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual NumericVector< Number > * solutionUDotDot()
virtual NumericVector< Number > & serializedSolution()
Returns a reference to a serialized version of the solution vector for this subproblem.
std::vector< std::vector< MooseVariableFieldBase * > > _numbered_vars
Map variable number to its pointer.
virtual void prepareLowerD(THREAD_ID tid)
Prepare the system for use for lower dimensional elements.
Base class for time integrators.
virtual void set(const numeric_index_type i, const T value)=0
const Parallel::Communicator & _communicator
const Parallel::Communicator & comm() const
SparseMatrix< Number > & add_matrix(std::string_view mat_name, ParallelType type=PARALLEL, MatrixBuildType mat_build_type=MatrixBuildType::AUTOMATIC)
const std::string & name() const
void remove_matrix(std::string_view mat_name)
void remove_vector(std::string_view vec_name)
const FEType & variable_type(const unsigned int i) const
void prefix_with_name(bool value)
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
unsigned int add_variable_array(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
bool has_static_condensation() const
std::string prefix() const
const DofMap & get_dof_map() const
unsigned int number() const
const NumericVector< Number > & get_vector(std::string_view vec_name) const
bool have_vector(std::string_view vec_name) const
unsigned int n_components() const
unsigned int number() const
libMesh::FEType variableFEType(const InputParameters ¶ms)
const TagName PREVIOUS_MULTISYSTEM_FP_SOLUTION_TAG
const TagName OLDER_SOLUTION_TAG
const TagName PREVIOUS_NL_SOLUTION_TAG
const TagName PREVIOUS_MULTIAPP_FP_SOLUTION_TAG
std::string stringify(const T &t)
conversion to string
const TagName OLD_SOLUTION_TAG
VarKindType
Framework-wide stuff.
void parallel_reduce(const Range &range, Body &body, unsigned int n_threads=libMesh::n_threads())
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Information about variables that will be copied.