https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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();
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),
44 RandomInterface(parameters,
45 *parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base"),
46 parameters.get<THREAD_ID>("_tid"),
47 false),
48 Restartable(this, getBase() + "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
59void
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}
unsigned int THREAD_ID
Definition MooseTypes.h:237
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Interface for objects that need to use functions.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
std::vector< SparseMatrix< Number > * > _matrices
Pointers to the matrices that need contributions from this kernel.
std::vector< NumericVector< Number > * > _vectors
Pointers to the vectors that need contributions from this kernel.
LinearSystemContributionObject(const InputParameters &parameters)
Class constructor.
SystemBase & _sys
Reference to the system this object contributes to.
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.
Interface for notifications that the mesh has changed.
static InputParameters validParams()
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
static InputParameters validParams()
Definition MooseObject.C:25
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type.
Interface class for classes which interact with Postprocessors.
Interface for objects that need parallel consistent random numbers without patterns over the course o...
static InputParameters validParams()
A class for creating restricted objects.
Definition Restartable.h:29
Base class for a system (of equations)
Definition SystemBase.h:87
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition SystemBase.C:932
static InputParameters validParams()
Interface for objects that needs transient capabilities.
static InputParameters validParams()
Interface for objects that need to use UserObjects.
MeshBase & mesh
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...