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

Generated by: LCOV version 1.14