LCOV - code coverage report
Current view: top level - src/base - LinearSystemContributionObject.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 40 40 100.0 %
Date: 2025-08-08 20:01:16 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      10             : #include "LinearSystemContributionObject.h"
      11             : #include "SubProblem.h"
      12             : #include "InputParameters.h"
      13             : #include "libmesh/linear_implicit_system.h"
      14             : 
      15             : InputParameters
      16       92076 : LinearSystemContributionObject::validParams()
      17             : {
      18       92076 :   auto params = MooseObject::validParams();
      19       92076 :   params += TransientInterface::validParams();
      20       92076 :   params += RandomInterface::validParams();
      21       92076 :   params += MeshChangedInterface::validParams();
      22       92076 :   params += TaggingInterface::validParams();
      23             : 
      24       92076 :   MultiMooseEnum vtags("rhs time", "rhs", true);
      25       92076 :   auto & vector_tag_enum = params.set<MultiMooseEnum>("vector_tags", true);
      26       92076 :   vector_tag_enum = vtags;
      27             : 
      28       92076 :   params.addRequiredParam<LinearVariableName>(
      29             :       "variable", "The name of the variable whose linear system this object contributes to");
      30             : 
      31       92076 :   params.declareControllable("enable");
      32       92076 :   params.set<bool>("_residual_object") = false;
      33      184152 :   return params;
      34       92076 : }
      35             : 
      36        3243 : LinearSystemContributionObject::LinearSystemContributionObject(const InputParameters & parameters)
      37             :   : MooseObject(parameters),
      38             :     SetupInterface(this),
      39             :     FunctionInterface(this),
      40             :     UserObjectInterface(this),
      41             :     TransientInterface(this),
      42             :     PostprocessorInterface(this),
      43             :     VectorPostprocessorInterface(this, false),
      44             :     RandomInterface(parameters,
      45        6486 :                     *parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base"),
      46        3243 :                     parameters.get<THREAD_ID>("_tid"),
      47             :                     false),
      48        6486 :     Restartable(this, parameters.get<std::string>("_moose_base") + "s"),
      49             :     MeshChangedInterface(parameters),
      50             :     TaggingInterface(this),
      51        3243 :     _fe_problem(*parameters.get<FEProblemBase *>("_fe_problem_base")),
      52        3243 :     _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
      53        3243 :     _linear_system(libMesh::cast_ref<libMesh::LinearImplicitSystem &>(_sys.system())),
      54        3243 :     _tid(parameters.get<THREAD_ID>("_tid")),
      55       22701 :     _mesh(_subproblem.mesh())
      56             : {
      57        3243 : }
      58             : 
      59             : void
      60       12090 : LinearSystemContributionObject::linkTaggedVectorsAndMatrices(const std::set<TagID> & vector_tags,
      61             :                                                              const std::set<TagID> & matrix_tags)
      62             : {
      63       12090 :   _vectors.clear();
      64       12090 :   _matrices.clear();
      65             :   // The requested tags can be a subset of the stored vector/matrix tags
      66       12090 :   std::set<TagID> vector_intersection;
      67       36270 :   std::set_intersection(vector_tags.begin(),
      68             :                         vector_tags.end(),
      69       12090 :                         this->getVectorTags({}).begin(),
      70       12090 :                         this->getVectorTags({}).end(),
      71             :                         std::inserter(vector_intersection, vector_intersection.begin()));
      72             : 
      73       12090 :   std::set<TagID> matrix_intersection;
      74       36270 :   std::set_intersection(matrix_tags.begin(),
      75             :                         matrix_tags.end(),
      76       12090 :                         this->getMatrixTags({}).begin(),
      77       12090 :                         this->getMatrixTags({}).end(),
      78             :                         std::inserter(matrix_intersection, matrix_intersection.begin()));
      79             : 
      80       24204 :   for (const auto tag : vector_intersection)
      81       12114 :     _vectors.push_back(&_sys.getVector(tag));
      82             : 
      83       24204 :   for (const auto tag : matrix_intersection)
      84       12114 :     _matrices.push_back(&_sys.getMatrix(tag));
      85       12090 : }

Generated by: LCOV version 1.14