19 #include "libmesh/dense_vector.h" 20 #include "metaphysicl/raw_type.h" 30 #ifdef MOOSE_KOKKOS_ENABLED 61 #ifdef MOOSE_KOKKOS_ENABLED 83 #ifdef MOOSE_KOKKOS_ENABLED 103 #ifdef MOOSE_KOKKOS_ENABLED 121 void useVectorTag(
const TagName & tag_name, VectorTagsKey);
123 void useMatrixTag(
const TagName & tag_name, MatrixTagsKey);
266 template <
typename Res
iduals,
typename Indices>
268 const Residuals & residuals,
269 const Indices & dof_indices,
270 Real scaling_factor);
272 template <
typename Res
iduals,
typename Indices>
274 const Residuals & residuals,
275 const Indices & dof_indices,
276 const std::vector<Real> & scaling_factors);
281 template <
typename T,
typename Indices>
283 const DenseVector<T> & residuals,
284 const Indices & dof_indices,
285 Real scaling_factor);
291 template <
typename Res
iduals,
typename Indices>
293 const Residuals & residuals,
294 const Indices & dof_indices,
295 Real scaling_factor);
300 template <
typename Res
iduals,
typename Indices>
302 const Residuals & residuals,
303 const Indices & dof_indices,
304 Real scaling_factor);
310 template <
typename Res
iduals,
typename Indices>
312 const Residuals & residuals,
313 const Indices & dof_indices,
314 const std::vector<Real> & scaling_factors);
337 template <
typename Res
iduals,
typename Indices>
339 const Residuals & residuals,
340 const Indices & dof_indices,
341 Real scaling_factor);
348 template <
typename Res
iduals,
typename Indices>
350 const Residuals & residuals,
351 const Indices & dof_indices,
352 Real scaling_factor);
359 template <
typename Res
iduals,
typename Indices>
361 const Residuals & residuals,
362 const Indices & dof_indices,
363 Real scaling_factor);
372 Real scaling_factor);
379 const std::vector<dof_id_type> & row_indices,
380 const std::vector<dof_id_type> & column_indices,
381 Real scaling_factor);
386 template <
typename T>
397 template <
typename SetRes
idualFunctor>
421 const std::set<TagID> & vector_tags,
422 const std::set<TagID> & absolute_value_vector_tags);
480 #define usingTaggingInterfaceMembers \ 481 using TaggingInterface::_subproblem; \ 482 using TaggingInterface::accumulateTaggedLocalResidual; \ 483 using TaggingInterface::accumulateTaggedLocalMatrix; \ 484 using TaggingInterface::prepareVectorTag; \ 485 using TaggingInterface::prepareMatrixTag; \ 486 using TaggingInterface::prepareVectorTagNeighbor; \ 487 using TaggingInterface::_local_re; \ 488 using TaggingInterface::prepareVectorTagLower; \ 489 using TaggingInterface::prepareMatrixTagNeighbor; \ 490 using TaggingInterface::prepareMatrixTagLower; \ 491 using TaggingInterface::_local_ke 493 template <
typename Res
iduals,
typename Indices>
496 const Residuals & residuals,
497 const Indices & dof_indices,
498 const Real scaling_factor)
516 template <
typename Res
iduals,
typename Indices>
519 const Residuals & residuals,
520 const Indices & dof_indices,
521 const std::vector<Real> & scaling_factors)
523 const auto count = scaling_factors.size();
524 mooseAssert(dof_indices.size() % count == 0,
525 "The number of dof indices should be divided cleanly by the variable count");
526 const auto nshapes = dof_indices.size() / count;
537 template <
typename T,
typename Indices>
540 const DenseVector<T> & residuals,
541 const Indices & dof_indices,
542 const Real scaling_factor)
544 addResiduals(assembly, residuals.get_values(), dof_indices, scaling_factor);
547 template <
typename Res
iduals,
typename Indices>
550 const Residuals & residuals,
551 const Indices & dof_indices,
552 const Real scaling_factor)
570 template <
typename Res
iduals,
typename Indices>
573 const Residuals & residuals,
574 const Indices & dof_indices,
577 addResiduals(assembly, residuals, dof_indices, scaling_factor);
578 addJacobian(assembly, residuals, dof_indices, scaling_factor);
581 template <
typename Res
iduals,
typename Indices>
584 const Residuals & residuals,
585 const Indices & dof_indices,
592 template <
typename Res
iduals,
typename Indices>
595 const Residuals & residuals,
596 const Indices & dof_indices,
597 const std::vector<Real> & scaling_factors)
599 const auto count = scaling_factors.size();
600 mooseAssert(dof_indices.size() % count == 0,
601 "The number of dof indices should be divided cleanly by the variable count");
602 const auto nshapes = dof_indices.size() / count;
613 template <
typename Res
iduals,
typename Indices>
616 const Residuals & residuals,
617 const Indices & dof_indices,
624 template <
typename Res
iduals,
typename Indices>
627 const Residuals & residuals,
628 const Indices & dof_indices,
640 const Real scaling_factor)
649 const std::vector<dof_id_type> & row_indices,
650 const std::vector<dof_id_type> & column_indices,
651 const Real scaling_factor)
658 template <
typename T>
675 template <
typename SetRes
idualFunctor>
681 set_residual_functor(sys.
getVector(tag_id));
Nonlinear eigenvalue system to be solved.
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.
void addResidualsAndJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided incoming residuals and derivatives for the Jacobian, corresponding to the provided d...
const InputParameters & _tag_params
Parameters from moose object.
void accumulateTaggedLocalResidual()
Local residual blocks will be appended by adding the current local kernel residual.
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
bool hasVectorTags() const
Keeps track of stuff related to assembling.
const std::vector< dof_id_type > & dof_indices
void assignTaggedLocalMatrix()
Local Jacobian blocks will assigned as the current local kernel Jacobian.
void addResiduals(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided incoming residuals corresponding to the provided dof indices.
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.
void insertNodalValue(libMesh::NumericVector< libMesh::Number > &residual, const DofValue &v)
Write a nodal value to the passed-in solution vector.
The base class for Kokkos residual objects.
const Real scaling_factor
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.
const DenseVector< ADReal > & residuals
std::set< TagID > _ref_vector_tags
A set of either size 1 or 0.
Base class for a system (of 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.
void cacheJacobian(GlobalDataKey)
Takes the values that are currently in _sub_Kee and appends them to the cached values.
Nonlinear system to be solved.
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)
void addJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided residual derivatives into the Jacobian for the provided dof indices.
InputParameters validParams()
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.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
Every object that can be built by the factory should be derived from this class.
std::set< TagID > _matrix_tags
The matrices this Kernel will contribute to.
void cacheJacobianWithoutConstraints(const Residuals &residuals, const Indices &row_indices, Real scaling_factor, LocalDataKey, const std::set< TagID > &matrix_tags)
Process the derivatives() data of a vector of ADReals.
void addResidualsAndJacobianWithoutConstraints(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided incoming residuals and derivatives for the Jacobian, corresponding to the provided d...
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.
void accumulateTaggedLocalMatrix()
Local Jacobian blocks will be appended by adding the current local kernel Jacobian.
Utility structure for packaging up all of the residual object's information needed to add into the sy...
A storage container for MooseObjects that inherit from SetupInterface.
void cacheResiduals(const Residuals &residuals, const Indices &row_indices, Real scaling_factor, LocalDataKey, const std::set< TagID > &vector_tags)
Process the supplied residual values.
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...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
This is the common base class for objects that give residual contributions.
Generic class for solving transient nonlinear problems.
This is the common base class for objects that give contributions to a linear system.
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.
const std::set< TagID > & getMatrixTags(MatrixTagsKey) const
IntRange< T > make_range(T beg, T end)
void addResidualsWithoutConstraints(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided incoming residuals corresponding to the provided dof indices.
virtual ~TaggingInterface()
virtual void set(const numeric_index_type i, const Number value)=0
void checkForNans() const
Checks _local_re for NaNs/Infs and returns an error if found.
void cacheJacobianBlock(DenseMatrix< Number > &jac_block, const std::vector< dof_id_type > &idof_indices, const std::vector< dof_id_type > &jdof_indices, Real scaling_factor, LocalDataKey, TagID tag)
Cache a local Jacobian block with the provided rows (idof_indices) and columns (jdof_indices) for eve...
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 addJacobianWithoutConstraints(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided residual derivatives into the Jacobian for the provided dof indices.
void prepareMatrixTag(Assembly &assembly, unsigned int ivar, unsigned int jvar)
Prepare data for computing element jacobian according to the active tags.
void addJacobianElement(Assembly &assembly, Real value, dof_id_type row_index, dof_id_type column_index, Real scaling_factor)
Add into a single Jacobian element.
DenseMatrix< Number > _nonlocal_ke
Holds nonlocal Jacobian entries as they are accumulated by this Kernel.
static InputParameters validParams()
void setResidual(SystemBase &sys, const T &residual, MooseVariableFE< T > &var)
Set residual using the variables' insertion API.
auto makeSpan(C &container, std::size_t offset, std::size_t n)
Helper function for creating a span from a given container.
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
auto index_range(const T &sizable)
std::vector< Real > _absolute_residuals
A container to hold absolute values of residuals passed into addResiduals.
Key structure for APIs adding/caching local element residuals/Jacobians.
void useVectorTag(const TagName &tag_name, VectorTagsKey)
void cacheResidualsWithoutConstraints(const Residuals &residuals, const Indices &row_indices, Real scaling_factor, LocalDataKey, const std::set< TagID > &vector_tags)
Process the supplied residual values.
const std::set< TagID > & getVectorTags(VectorTagsKey) const