www.mooseframework.org
Transfer.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 const Number Transfer::OutOfMeshValue = -999999;
23 
26 {
28  params.addParam<bool>("use_displaced_mesh",
29  false,
30  "Whether or not this object should use the "
31  "displaced mesh for computation. Note that "
32  "in the case this is true but no "
33  "displacements are provided in the Mesh block "
34  "the undisplaced mesh will still be used.");
35  // Add the SetupInterface parameter, 'execute_on', and set it to a default of 'timestep_begin'
36  params += SetupInterface::validParams();
37  params.set<ExecFlagEnum>("execute_on", true) = EXEC_TIMESTEP_BEGIN;
38 
39  params.set<bool>("_called_legacy_params") = true;
40  MultiMooseEnum possible_directions(Transfer::possibleDirections());
41  params.addDeprecatedParam<MultiMooseEnum>(
42  "direction",
43  possible_directions,
44  "Whether this Transfer will be 'to' or 'from' a MultiApp, or "
45  "bidirectional, by providing both FROM_MULTIAPP and TO_MULTIAPP.",
46  "Specifying direction+multiapp is deprecated. Specify the to_multi_app and from_multi_app");
47  params.registerBase("Transfer");
48 
49  params.addParamNamesToGroup("use_displaced_mesh", "Advanced");
50  params.addParamNamesToGroup("_called_legacy_params", "Advanced");
51 
52  params.declareControllable("enable");
53  return params;
54 }
55 
57  : MooseObject(parameters),
58  SetupInterface(this),
59  Restartable(this, "Transfers"),
60  PerfGraphInterface(this, "Transfers"),
61  _subproblem(*getCheckedPointerParam<SubProblem *>("_subproblem")),
62  _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
63  _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
64  _tid(parameters.get<THREAD_ID>("_tid")),
65  _direction(possibleDirections()),
66  _current_direction(possibleDirections()),
67  _directions(isParamValid("direction") ? getParam<MultiMooseEnum>("direction")
68  : possibleDirections())
69 {
70  if (parameters.isParamSetByUser("direction") && _directions.size() == 0)
71  paramError("direction", "At least one direction is required");
72 
73  // If we have just one direction in _directions, set it now so that it can be used in the
74  // constructor
75  if (_directions.size() == 1)
76  {
77  auto only_direction = _directions.get(0);
78  _current_direction = only_direction;
79  _direction = only_direction;
80  }
81 }
82 
88 System *
89 Transfer::find_sys(EquationSystems & es, const std::string & var_name)
90 {
91  // Find the system this variable is from
92  for (unsigned int i = 0; i < es.n_systems(); i++)
93  if (es.get_system(i).has_variable(var_name))
94  return &es.get_system(i);
95 
96  ::mooseError("Unable to find variable " + var_name + " in any system.");
97 
98  // Unreachable
99  return &es.get_system(0);
100 }
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
A class for creating restricted objects.
Definition: Restartable.h:28
MooseEnum _current_direction
Definition: Transfer.h:106
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1147
unsigned int size() const
Return the number of active items in the MultiMooseEnum.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static std::string possibleDirections()
Used to construct InputParameters.
Definition: Transfer.h:76
Base class for a system (of equations)
Definition: SystemBase.h:84
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:33
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition: Moose.C:33
static InputParameters validParams()
Definition: Transfer.C:25
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Transfer(const InputParameters &parameters)
Definition: Transfer.C:56
static const Number OutOfMeshValue
Definition: Transfer.h:113
static InputParameters validParams()
Interface for objects interacting with the PerfGraph.
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was by the user.
unsigned int get(unsigned int i) const
Indexing operator Operator to retrieve an item from the MultiMooseEnum.
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:75
MultiMooseEnum _directions
The directions this Transfer is to be executed on.
Definition: Transfer.h:110
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const InputParameters & parameters() const
Get the parameters of the object.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
MooseEnum _direction
Definition: Transfer.h:105
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
static System * find_sys(EquationSystems &es, const std::string &var_name)
Small helper function for finding the system containing the variable.
Definition: Transfer.C:89
static InputParameters validParams()
Definition: MooseObject.C:24
Real Number
unsigned int THREAD_ID
Definition: MooseTypes.h:198