https://mooseframework.inl.gov
LinearSystemContributionObject.C
Go to the documentation of this file.
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 
11 #include "SubProblem.h"
12 #include "InputParameters.h"
13 #include "libmesh/linear_implicit_system.h"
14 
17 {
18  auto params = MooseObject::validParams();
20  params += RandomInterface::validParams();
23 
24  MultiMooseEnum vtags("rhs time", "rhs", true);
25  auto & vector_tag_enum = params.set<MultiMooseEnum>("vector_tags", true);
26  vector_tag_enum = vtags;
27 
28  params.addRequiredParam<LinearVariableName>(
29  "variable", "The name of the variable whose linear system this object contributes to");
30 
31  params.declareControllable("enable");
32  params.set<bool>("_residual_object") = false;
33  return params;
34 }
35 
37  : MooseObject(parameters),
38  SetupInterface(this),
39  FunctionInterface(this),
40  UserObjectInterface(this),
41  TransientInterface(this),
43  VectorPostprocessorInterface(this, false),
44  RandomInterface(parameters,
45  *parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base"),
46  parameters.get<THREAD_ID>("_tid"),
47  false),
48  Restartable(this, parameters.get<std::string>("_moose_base") + "s"),
49  MeshChangedInterface(parameters),
50  TaggingInterface(this),
51  _fe_problem(*parameters.get<FEProblemBase *>("_fe_problem_base")),
52  _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
53  _linear_system(libMesh::cast_ref<libMesh::LinearImplicitSystem &>(_sys.system())),
54  _tid(parameters.get<THREAD_ID>("_tid")),
55  _mesh(_subproblem.mesh())
56 {
57 }
58 
59 void
61  const std::set<TagID> & matrix_tags)
62 {
63  _vectors.clear();
64  _matrices.clear();
65  // The requested tags can be a subset of the stored vector/matrix tags
66  std::set<TagID> vector_intersection;
67  std::set_intersection(vector_tags.begin(),
68  vector_tags.end(),
69  this->getVectorTags({}).begin(),
70  this->getVectorTags({}).end(),
71  std::inserter(vector_intersection, vector_intersection.begin()));
72 
73  std::set<TagID> matrix_intersection;
74  std::set_intersection(matrix_tags.begin(),
75  matrix_tags.end(),
76  this->getMatrixTags({}).begin(),
77  this->getMatrixTags({}).end(),
78  std::inserter(matrix_intersection, matrix_intersection.begin()));
79 
80  for (const auto tag : vector_intersection)
81  _vectors.push_back(&_sys.getVector(tag));
82 
83  for (const auto tag : matrix_intersection)
84  _matrices.push_back(&_sys.getMatrix(tag));
85 }
Interface for objects that need parallel consistent random numbers without patterns over the course o...
A class for creating restricted objects.
Definition: Restartable.h:28
Tnew cast_ref(Told &oldvar)
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1155
MeshBase & mesh
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void linkTaggedVectorsAndMatrices(const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Function which sets up the vectors and matrices this kernel will contribute to.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
static InputParameters validParams()
Base class for a system (of equations)
Definition: SystemBase.h:84
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
std::vector< NumericVector< Number > * > _vectors
Pointers to the vectors that need contributions from this kernel.
Interface for objects that needs transient capabilities.
static InputParameters validParams()
Interface for notifications that the mesh has changed.
std::vector< SparseMatrix< Number > * > _matrices
Pointers to the matrices that need contributions from this kernel.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
static InputParameters validParams()
Interface for objects that need to use UserObjects.
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:1007
const std::set< TagID > & getMatrixTags(MatrixTagsKey) const
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
static InputParameters validParams()
Definition: MooseObject.C:25
static InputParameters validParams()
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:916
SystemBase & _sys
Reference to the system this object contributes to.
Interface for objects that need to use functions.
Interface class for classes which interact with Postprocessors.
unsigned int THREAD_ID
Definition: MooseTypes.h:209
const std::set< TagID > & getVectorTags(VectorTagsKey) const
LinearSystemContributionObject(const InputParameters &parameters)
Class constructor.