https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Transfer.C
Go to the documentation of this file.
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
22using namespace libMesh;
23
24const Number Transfer::OutOfMeshValue = -999999;
25
28{
30 params.addParam<bool>("use_displaced_mesh",
31 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'
39 params.set<ExecFlagEnum>("execute_on", true) = EXEC_TIMESTEP_BEGIN;
40
41 params.set<bool>("_called_legacy_params") = true;
42 MultiMooseEnum possible_directions(Transfer::possibleDirections());
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 params.registerBase("Transfer");
50
51 params.addParamNamesToGroup("use_displaced_mesh", "Advanced");
52 params.addParamNamesToGroup("_called_legacy_params", "Advanced");
53
54 params.declareControllable("enable");
55 return params;
56}
57
59 : MooseObject(parameters),
60 SetupInterface(this),
61 Restartable(this, "Transfers"),
62 PerfGraphInterface(this, "Transfers"),
63 _subproblem(*getCheckedPointerParam<SubProblem *>("_subproblem")),
64 _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
65 _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
66 _tid(parameters.get<THREAD_ID>("_tid")),
67 _direction(possibleDirections()),
68 _current_direction(possibleDirections()),
69 _directions(isParamValid("direction") ? getParam<MultiMooseEnum>("direction")
70 : possibleDirections())
71{
72 if (parameters.isParamSetByUser("direction") && _directions.size() == 0)
73 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 if (_directions.size() == 1)
78 {
79 auto only_direction = _directions.get(0);
80 _current_direction = only_direction;
81 _direction = only_direction;
82 }
83}
84
90System *
91Transfer::find_sys(EquationSystems & es, const std::string & var_name)
92{
93 // Find the system this variable is from
94 for (unsigned int i = 0; i < es.n_systems(); i++)
95 if (es.get_system(i).has_variable(var_name))
96 return &es.get_system(i);
97
98 ::mooseError("Unable to find variable " + var_name + " in any system.");
99
100 // Unreachable
101 return &es.get_system(0);
102}
unsigned int THREAD_ID
Definition MooseTypes.h:237
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition Moose.C:37
A MultiMooseEnum object to hold "execute_on" flags.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was set by the user.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
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 ...
Definition MooseBase.h:457
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition MooseBase.h:271
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
static InputParameters validParams()
Definition MooseObject.C:25
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type.
unsigned int get(unsigned int i) const
Indexing operator Operator to retrieve the id of an item from the MultiMooseEnum.
unsigned int size() const
Return the number of active items in the MultiMooseEnum.
Interface for objects interacting with the PerfGraph.
A class for creating restricted objects.
Definition Restartable.h:29
static InputParameters validParams()
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
Base class for a system (of equations)
Definition SystemBase.h:87
MooseEnum _direction
Definition Transfer.h:105
static InputParameters validParams()
Definition Transfer.C:27
MultiMooseEnum _directions
The directions this Transfer is to be executed on.
Definition Transfer.h:110
static const libMesh::Number OutOfMeshValue
Definition Transfer.h:113
MooseEnum _current_direction
Definition Transfer.h:106
static std::string possibleDirections()
Used to construct InputParameters.
Definition Transfer.h:76
static libMesh::System * find_sys(libMesh::EquationSystems &es, const std::string &var_name)
Small helper function for finding the system containing the variable.
Definition Transfer.C:91
Transfer(const InputParameters &parameters)
Definition Transfer.C:58
unsigned int n_systems() const
const T_sys & get_system(std::string_view name) const
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Real Number