17 #include "libmesh/dense_vector.h" 30 "matrix_only",
false,
"Whether this object is only doing assembly to matrices (no vectors)");
33 "vector_tags", vtags,
"The tag for the vectors this Kernel should fill");
36 "matrix_tags", mtags,
"The tag for the matrices this Kernel should fill");
38 params.
addParam<std::vector<TagName>>(
"extra_vector_tags",
39 "The extra tags for the vectors this Kernel should fill");
41 params.
addParam<std::vector<TagName>>(
42 "absolute_value_vector_tags",
43 "The tags for the vectors this residual object should fill with the " 44 "absolute value of the residual contribution");
46 params.
addParam<std::vector<TagName>>(
"extra_matrix_tags",
47 "The extra tags for the matrices this Kernel should fill");
50 "vector_tags matrix_tags extra_vector_tags extra_matrix_tags absolute_value_vector_tags",
51 "Contribution to tagged field data");
57 : _subproblem(*moose_object->parameters().getCheckedPointerParam<
SubProblem *>(
"_subproblem")),
58 _moose_object(*moose_object),
59 _tag_params(_moose_object.parameters())
63 if (!vector_tag_names.isValid())
70 for (
auto & vector_tag_name : vector_tag_names)
75 vector_tag_name.name(),
78 "' is not a residual vector tag");
85 auto & extra_vector_tags =
_tag_params.
get<std::vector<TagName>>(
"extra_vector_tags");
87 for (
auto & vector_tag_name : extra_vector_tags)
95 "' is not a residual vector tag");
101 auto & abs_vector_tags =
_tag_params.
get<std::vector<TagName>>(
"absolute_value_vector_tags");
103 for (
auto & vector_tag_name : abs_vector_tags)
111 "' is not a residual vector tag");
117 if (matrix_tag_names.isValid())
118 for (
auto & matrix_tag_name : matrix_tag_names)
121 auto & extra_matrix_tags =
_tag_params.
get<std::vector<TagName>>(
"extra_matrix_tags");
123 for (
auto & matrix_tag_name : extra_matrix_tags)
130 const auto *
const fe_problem =
133 for (
const auto & conv : fe_problem->getConvergenceObjects())
139 auto create_tags_split =
140 [reference_tag](
const auto & tags,
auto & non_ref_tags,
auto & ref_tags)
142 for (
const auto tag : tags)
143 if (tag == reference_tag)
144 ref_tags.insert(tag);
146 non_ref_tags.insert(tag);
163 mooseError(
"Vector tag ", tag_name,
" does not exist in system");
172 mooseError(
"Matrix tag ", tag_name,
" does not exist in system");
181 mooseError(
"Vector tag ", tag_id,
" does not exist in system");
190 mooseError(
"Matrix tag ", tag_id,
" does not exist in system");
203 const unsigned int ivar,
214 const unsigned int ivar,
215 const std::set<TagID> & vector_tags,
216 const std::set<TagID> & absolute_value_vector_tags)
218 auto prepare = [
this, ivar, &assembly](
auto & re_blocks,
const auto & tags)
221 re_blocks.reserve(tags.size());
222 for (
const auto tag_id : tags)
241 mooseAssert(
_vector_tags.size() >= 1,
"we need at least one active tag");
264 mooseAssert(
_vector_tags.size() >= 1,
"we need at least one active tag");
286 mooseAssert(
_matrix_tags.size() >= 1,
"we need at least one active tag");
300 mooseAssert(!
_matrix_tags.empty(),
"No matrix tags exist");
301 const auto & ij_mat =
303 k.
resize(ij_mat.m(), ij_mat.n());
312 mooseAssert(
_matrix_tags.size() >= 1,
"we need at least one active tag");
328 mooseAssert(
_matrix_tags.size() >= 1,
"we need at least one active tag");
344 mooseAssert(!
_matrix_tags.empty(),
"No matrix tags exist");
347 k.
resize(ij_mat.m(), ij_mat.n());
357 mooseAssert(
_matrix_tags.size() >= 1,
"we need at least one active tag");
395 const unsigned int ivar,
396 const unsigned int jvar,
400 mooseAssert(
_matrix_tags.size() >= 1,
"we need at least one active tag");
405 "Passed-in k must match the blocks we are about to sum into");
412 const unsigned int ivar,
413 const unsigned int jvar,
418 mooseAssert(
_matrix_tags.size() >= 1,
"we need at least one active tag");
424 "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.
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
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.
const InputParameters & parameters() const
Get the parameters of the object.
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.
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.
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.
const std::string & name() const
Get the name of the class.
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.
TagID referenceVectorTagID(ReferenceVectorTagIDKey) const
Returns the tag ID associated with the reference vector tag ID key.
std::set< TagID > _non_ref_vector_tags
A set to hold vector tags excluding the reference residual tag.
std::set< TagID > _vector_tags
The vector 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)
Uses a reference residual to define relative convergence criteria.
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()
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
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.