LCOV - code coverage report
Current view: top level - src/base - LinearSystemContributionObject.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 40 40 100.0 %
Date: 2025-07-17 01:28:37 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       91318 : LinearSystemContributionObject::validParams()
      17             : {
      18       91318 :   auto params = MooseObject::validParams();
      19       91318 :   params += TransientInterface::validParams();
      20       91318 :   params += RandomInterface::validParams();
      21       91318 :   params += MeshChangedInterface::validParams();
      22       91318 :   params += TaggingInterface::validParams();
      23             : 
      24       91318 :   MultiMooseEnum vtags("rhs time", "rhs", true);
      25       91318 :   auto & vector_tag_enum = params.set<MultiMooseEnum>("vector_tags", true);
      26       91318 :   vector_tag_enum = vtags;
      27             : 
      28       91318 :   params.addRequiredParam<LinearVariableName>(
      29             :       "variable", "The name of the variable whose linear system this object contributes to");
      30             : 
      31       91318 :   params.declareControllable("enable");
      32       91318 :   params.set<bool>("_residual_object") = false;
      33      182636 :   return params;
      34       91318 : }
      35             : 
      36        2864 : 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        5728 :                     *parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base"),
      46        2864 :                     parameters.get<THREAD_ID>("_tid"),
      47             :                     false),
      48        5728 :     Restartable(this, parameters.get<std::string>("_moose_base") + "s"),
      49             :     MeshChangedInterface(parameters),
      50             :     TaggingInterface(this),
      51        2864 :     _fe_problem(*parameters.get<FEProblemBase *>("_fe_problem_base")),
      52        2864 :     _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
      53        2864 :     _linear_system(libMesh::cast_ref<libMesh::LinearImplicitSystem &>(_sys.system())),
      54        2864 :     _tid(parameters.get<THREAD_ID>("_tid")),
      55       20048 :     _mesh(_subproblem.mesh())
      56             : {
      57        2864 : }
      58             : 
      59             : void
      60       11266 : LinearSystemContributionObject::linkTaggedVectorsAndMatrices(const std::set<TagID> & vector_tags,
      61             :                                                              const std::set<TagID> & matrix_tags)
      62             : {
      63       11266 :   _vectors.clear();
      64       11266 :   _matrices.clear();
      65             :   // The requested tags can be a subset of the stored vector/matrix tags
      66       11266 :   std::set<TagID> vector_intersection;
      67       33798 :   std::set_intersection(vector_tags.begin(),
      68             :                         vector_tags.end(),
      69       11266 :                         this->getVectorTags({}).begin(),
      70       11266 :                         this->getVectorTags({}).end(),
      71             :                         std::inserter(vector_intersection, vector_intersection.begin()));
      72             : 
      73       11266 :   std::set<TagID> matrix_intersection;
      74       33798 :   std::set_intersection(matrix_tags.begin(),
      75             :                         matrix_tags.end(),
      76       11266 :                         this->getMatrixTags({}).begin(),
      77       11266 :                         this->getMatrixTags({}).end(),
      78             :                         std::inserter(matrix_intersection, matrix_intersection.begin()));
      79             : 
      80       22554 :   for (const auto tag : vector_intersection)
      81       11288 :     _vectors.push_back(&_sys.getVector(tag));
      82             : 
      83       22554 :   for (const auto tag : matrix_intersection)
      84       11288 :     _matrices.push_back(&_sys.getMatrix(tag));
      85       11266 : }

Generated by: LCOV version 1.14