LCOV - code coverage report
Current view: top level - src/transfers - Transfer.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 34 36 94.4 %
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             : // MOOSE includes
      11             : #include "Transfer.h"
      12             : #include "FEProblem.h"
      13             : #include "MooseMesh.h"
      14             : #include "Assembly.h"
      15             : #include "MooseVariableFE.h"
      16             : #include "MooseEnum.h"
      17             : #include "InputParameters.h"
      18             : 
      19             : // libMesh
      20             : #include "libmesh/system.h"
      21             : 
      22             : using namespace libMesh;
      23             : 
      24             : const Number Transfer::OutOfMeshValue = -999999;
      25             : 
      26             : InputParameters
      27      331339 : Transfer::validParams()
      28             : {
      29      331339 :   InputParameters params = MooseObject::validParams();
      30      994017 :   params.addParam<bool>("use_displaced_mesh",
      31      662678 :                         false,
      32             :                         "Whether or not this object should use the "
      33             :                         "displaced mesh for computation.  Note that "
      34             :                         "in the case this is true but no "
      35             :                         "displacements are provided in the Mesh block "
      36             :                         "the undisplaced mesh will still be used.");
      37             :   // Add the SetupInterface parameter, 'execute_on', and set it to a default of 'timestep_begin'
      38      331339 :   params += SetupInterface::validParams();
      39      331339 :   params.set<ExecFlagEnum>("execute_on", true) = EXEC_TIMESTEP_BEGIN;
      40             : 
      41      331339 :   params.set<bool>("_called_legacy_params") = true;
      42      331339 :   MultiMooseEnum possible_directions(Transfer::possibleDirections());
      43      331339 :   params.addDeprecatedParam<MultiMooseEnum>(
      44             :       "direction",
      45             :       possible_directions,
      46             :       "Whether this Transfer will be 'to' or 'from' a MultiApp, or "
      47             :       "bidirectional, by providing both FROM_MULTIAPP and TO_MULTIAPP.",
      48             :       "Specifying direction+multiapp is deprecated. Specify the to_multi_app and from_multi_app");
      49      331339 :   params.registerBase("Transfer");
      50             : 
      51      331339 :   params.addParamNamesToGroup("use_displaced_mesh", "Advanced");
      52      331339 :   params.addParamNamesToGroup("_called_legacy_params", "Advanced");
      53             : 
      54      331339 :   params.declareControllable("enable");
      55      662678 :   return params;
      56      331339 : }
      57             : 
      58       11560 : Transfer::Transfer(const InputParameters & parameters)
      59             :   : MooseObject(parameters),
      60             :     SetupInterface(this),
      61             :     Restartable(this, "Transfers"),
      62             :     PerfGraphInterface(this, "Transfers"),
      63       11560 :     _subproblem(*getCheckedPointerParam<SubProblem *>("_subproblem")),
      64       11560 :     _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
      65       11560 :     _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
      66       11560 :     _tid(parameters.get<THREAD_ID>("_tid")),
      67       11560 :     _direction(possibleDirections()),
      68       11560 :     _current_direction(possibleDirections()),
      69       34624 :     _directions(isParamValid("direction") ? getParam<MultiMooseEnum>("direction")
      70       34624 :                                           : possibleDirections())
      71             : {
      72       11560 :   if (parameters.isParamSetByUser("direction") && _directions.size() == 0)
      73           0 :     paramError("direction", "At least one direction is required");
      74             : 
      75             :   // If we have just one direction in _directions, set it now so that it can be used in the
      76             :   // constructor
      77       11560 :   if (_directions.size() == 1)
      78             :   {
      79          56 :     auto only_direction = _directions.get(0);
      80          56 :     _current_direction = only_direction;
      81          56 :     _direction = only_direction;
      82             :   }
      83       11560 : }
      84             : 
      85             : /**
      86             :  * Small helper function for finding the system containing the variable.
      87             :  *
      88             :  * Note that this implies that variable names are unique across all systems!
      89             :  */
      90             : System *
      91      128289 : Transfer::find_sys(EquationSystems & es, const std::string & var_name)
      92             : {
      93             :   // Find the system this variable is from
      94      256164 :   for (unsigned int i = 0; i < es.n_systems(); i++)
      95      256164 :     if (es.get_system(i).has_variable(var_name))
      96      128289 :       return &es.get_system(i);
      97             : 
      98           0 :   ::mooseError("Unable to find variable " + var_name + " in any system.");
      99             : 
     100             :   // Unreachable
     101             :   return &es.get_system(0);
     102             : }

Generated by: LCOV version 1.14