16 #include "libmesh/dense_vector.h" 31 "vector_tags", vtags,
"The tag for the vectors this Kernel should fill");
34 "matrix_tags", mtags,
"The tag for the matrices this Kernel should fill");
36 params.
addParam<std::vector<TagName>>(
"extra_vector_tags",
37 "The extra tags for the vectors this Kernel should fill");
39 params.
addParam<std::vector<TagName>>(
40 "absolute_value_vector_tags",
41 "The tags for the vectors this residual object should fill with the " 42 "absolute value of the residual contribution");
44 params.
addParam<std::vector<TagName>>(
"extra_matrix_tags",
45 "The extra tags for the matrices this Kernel should fill");
48 "vector_tags matrix_tags extra_vector_tags extra_matrix_tags absolute_value_vector_tags",
55 : _subproblem(*moose_object->parameters().getCheckedPointerParam<
SubProblem *>(
"_subproblem")),
56 _moose_object(*moose_object),
57 _tag_params(_moose_object.parameters())
61 if (!vector_tag_names.isValid())
68 for (
auto & vector_tag_name : vector_tag_names)
73 vector_tag_name.name(),
76 "' is not a residual vector tag");
83 auto & extra_vector_tags =
_tag_params.
get<std::vector<TagName>>(
"extra_vector_tags");
85 for (
auto & vector_tag_name : extra_vector_tags)
93 "' is not a residual vector tag");
99 auto & abs_vector_tags =
_tag_params.
get<std::vector<TagName>>(
"absolute_value_vector_tags");
101 for (
auto & vector_tag_name : abs_vector_tags)
109 "' is not a residual vector tag");
115 if (matrix_tag_names.isValid())
116 for (
auto & matrix_tag_name : matrix_tag_names)
119 auto & extra_matrix_tags =
_tag_params.
get<std::vector<TagName>>(
"extra_matrix_tags");
121 for (
auto & matrix_tag_name : extra_matrix_tags)
128 const auto *
const fe_problem =
130 if (
const auto *
const ref_problem = dynamic_cast<const ReferenceResidualProblem *>(fe_problem))
132 const auto reference_tag = ref_problem->referenceVectorTagID({});
133 auto create_tags_split =
134 [reference_tag](
const auto & tags,
auto & non_ref_tags,
auto & ref_tags)
136 for (
const auto tag : tags)
137 if (tag == reference_tag)
138 ref_tags.insert(tag);
140 non_ref_tags.insert(tag);
156 mooseError(
"Vector tag ", tag_name,
" does not exist in system");
165 mooseError(
"Matrix tag ", tag_name,
" does not exist in system");
174 mooseError(
"Vector tag ", tag_id,
" does not exist in system");
183 mooseError(
"Matrix tag ", tag_id,
" does not exist in system");
196 const unsigned int ivar,
207 const unsigned int ivar,
208 const std::set<TagID> & vector_tags,
209 const std::set<TagID> & absolute_value_vector_tags)
211 auto prepare = [
this, ivar, &assembly](
auto & re_blocks,
const auto & tags)
214 re_blocks.reserve(tags.size());
215 for (
const auto tag_id : tags)
234 mooseAssert(
_vector_tags.size() >= 1,
"we need at least one active tag");
257 mooseAssert(
_vector_tags.size() >= 1,
"we need at least one active tag");
279 mooseAssert(
_matrix_tags.size() >= 1,
"we need at least one active tag");
293 mooseAssert(!
_matrix_tags.empty(),
"No matrix tags exist");
294 const auto & ij_mat =
296 k.
resize(ij_mat.m(), ij_mat.n());
305 mooseAssert(
_matrix_tags.size() >= 1,
"we need at least one active tag");
321 mooseAssert(
_matrix_tags.size() >= 1,
"we need at least one active tag");
337 mooseAssert(!
_matrix_tags.empty(),
"No matrix tags exist");
340 k.
resize(ij_mat.m(), ij_mat.n());
350 mooseAssert(
_matrix_tags.size() >= 1,
"we need at least one active tag");
388 const unsigned int ivar,
389 const unsigned int jvar,
393 mooseAssert(
_matrix_tags.size() >= 1,
"we need at least one active tag");
398 "Passed-in k must match the blocks we are about to sum into");
405 const unsigned int ivar,
406 const unsigned int jvar,
411 mooseAssert(
_matrix_tags.size() >= 1,
"we need at least one active tag");
417 "Passed-in k must match the blocks we are about to sum into");
virtual TagID getVectorTagID(const TagName &tag_name) const
Get a TagID from a TagName.
void accumulateTaggedNonlocalMatrix()
Nonlocal Jacobian blocks will be appended by adding the current nonlocal kernel Jacobian.
std::set< TagID > _ref_abs_vector_tags
A set of either size 1 or 0.
SubProblem & _subproblem
SubProblem that contains tag info.
const InputParameters & _tag_params
Parameters from moose object.
void accumulateTaggedLocalResidual()
Local residual blocks will be appended by adding the current local kernel residual.
Keeps track of stuff related to assembling.
DenseMatrix< Number > & jacobianBlockNonlocal(unsigned int ivar, unsigned int jvar, LocalDataKey, TagID tag)
Get local Jacobian block from non-local contribution for a pair of variables and a tag...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
DenseMatrix< Number > & jacobianBlockNeighbor(Moose::DGJacobianType type, unsigned int ivar, unsigned int jvar, LocalDataKey, TagID tag)
Get local Jacobian block of a DG Jacobian type for a pair of variables and a tag. ...
void assignTaggedLocalMatrix()
Local Jacobian blocks will assigned as the current local kernel Jacobian.
void resize(const unsigned int n)
TagTypeID _type_id
The index for this tag into a vector that contains tags of only its type ordered by ID...
void assignTaggedLocalResidual()
Local residual blocks will assigned as the current local kernel residual.
std::vector< DenseVector< Number > * > _absre_blocks
Residual blocks for absolute value residual tags.
ResidualTagType
Enumerate whether a (residual) vector tag is to be of a non-reference or reference tag type...
std::vector< DenseVector< Number > * > _re_blocks
Residual blocks Vectors For each Tag.
std::set< TagID > _ref_vector_tags
A set of either size 1 or 0.
DenseMatrix< Number > & jacobianBlock(unsigned int ivar, unsigned int jvar, LocalDataKey, TagID tag)
Get local Jacobian block for a pair of variables and a tag.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
DenseMatrix< Number > _local_ke
Holds local Jacobian entries as they are accumulated by this Kernel.
virtual const std::string & name() const
Get the name of the class.
std::set< TagID > _abs_vector_tags
The absolute value residual tag ids.
DenseMatrix< Number > & jacobianBlockMortar(Moose::ConstraintJacobianType type, unsigned int ivar, unsigned int jvar, LocalDataKey, TagID tag)
Returns the jacobian block for the given mortar Jacobian type.
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
void prepareMatrixTagNeighbor(Assembly &assembly, unsigned int ivar, unsigned int jvar, Moose::DGJacobianType type)
Prepare data for computing element jacobian according to the active tags for DG and interface kernels...
TaggingInterface(const MooseObject *moose_object)
std::set< TagID > _non_ref_abs_vector_tags
A set to hold absolute value vector tags excluding the reference residual tag.
void prepareMatrixTagNonlocal(Assembly &assembly, unsigned int ivar, unsigned int jvar)
Prepare data for computing nonlocal element jacobian according to the active tags.
Every object that can be built by the factory should be derived from this class.
virtual TagID getMatrixTagID(const TagName &tag_name) const
Get a TagID from a TagName.
std::set< TagID > _matrix_tags
The matrices this Kernel will contribute to.
virtual Moose::VectorTagType vectorTagType(const TagID tag_id) const
DenseVector< Number > & residualBlockLower(unsigned int var_num, LocalDataKey, TagID tag_id)
Get residual block for lower.
std::set< TagID > _non_ref_vector_tags
A set to hold vector tags excluding the reference residual tag.
std::set< TagID > _vector_tags
The residual tag ids this Kernel will contribute to.
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
void accumulateTaggedLocalMatrix()
Local Jacobian blocks will be appended by adding the current local kernel Jacobian.
void useMatrixTag(const TagName &tag_name, MatrixTagsKey)
void prepareVectorTagNeighbor(Assembly &assembly, unsigned int ivar)
Prepare data for computing element residual the according to active tags for DG and interface kernels...
Generic class for solving transient nonlinear problems.
DenseVector< Number > & residualBlockNeighbor(unsigned int var_num, LocalDataKey, TagID tag_id)
Get local neighbor residual block for a variable and a tag.
DenseVector< Number > & residualBlock(unsigned int var_num, LocalDataKey, TagID tag_id)
Get local residual block for a variable and a tag.
void prepareMatrixTagLower(Assembly &assembly, unsigned int ivar, unsigned int jvar, Moose::ConstraintJacobianType type)
Prepare data for computing the jacobian according to the active tags for mortar.
DenseVector< Number > _local_re
Holds local residual entries as they are accumulated by this Kernel.
const MooseObject & _moose_object
Moose objct this tag works on.
void resize(const unsigned int new_m, const unsigned int new_n)
virtual ~TaggingInterface()
const InputParameters & parameters() const
Get the parameters of the object.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
std::vector< DenseMatrix< Number > * > _ke_blocks
Kernel blocks Vectors For each Tag.
void prepareVectorTagLower(Assembly &assembly, unsigned int ivar)
Prepare data for computing the residual according to active tags for mortar constraints.
void prepareVectorTagInternal(Assembly &assembly, unsigned int ivar, const std::set< TagID > &vector_tags, const std::set< TagID > &absolute_value_vector_tags)
Prepare data for computing element residual according to the specified tags Residual blocks for diffe...
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
Prepare data for computing element residual according to active tags.
void prepareMatrixTag(Assembly &assembly, unsigned int ivar, unsigned int jvar)
Prepare data for computing element jacobian according to the active tags.
Storage for all of the information pretaining to a vector tag.
DenseMatrix< Number > _nonlocal_ke
Holds nonlocal Jacobian entries as they are accumulated by this Kernel.
static InputParameters validParams()
virtual const VectorTag & getVectorTag(const TagID tag_id) const
Get a VectorTag from a TagID.
auto index_range(const T &sizable)
Key structure for APIs adding/caching local element residuals/Jacobians.
void useVectorTag(const TagName &tag_name, VectorTagsKey)
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.