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 
24 template <>
27 {
29  params.addParam<bool>("use_displaced_mesh",
30  false,
31  "Whether or not this object should use the "
32  "displaced mesh for computation. Note that "
33  "in the case this is true but no "
34  "displacements are provided in the Mesh block "
35  "the undisplaced mesh will still be used.");
36  // Add the SetupInterface parameter, 'execute_on', and set it to a default of 'timestep_begin'
37  params += validParams<SetupInterface>();
38  params.set<ExecFlagEnum>("execute_on", true) = EXEC_TIMESTEP_BEGIN;
39 
40  params.registerBase("Transfer");
41 
42  params.addParamNamesToGroup("use_displaced_mesh", "Advanced");
43 
44  params.declareControllable("enable");
45  return params;
46 }
47 
49  : MooseObject(parameters),
50  SetupInterface(this),
51  Restartable(this, "Transfers"),
52  _subproblem(*getCheckedPointerParam<SubProblem *>("_subproblem")),
53  _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
54  _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
55  _tid(parameters.get<THREAD_ID>("_tid"))
56 {
57 }
58 
64 System *
65 Transfer::find_sys(EquationSystems & es, const std::string & var_name)
66 {
67  // Find the system this variable is from
68  for (unsigned int i = 0; i < es.n_systems(); i++)
69  if (es.get_system(i).has_variable(var_name))
70  return &es.get_system(i);
71 
72  ::mooseError("Unable to find variable " + var_name + " in any system.");
73 
74  // Unreachable
75  return &es.get_system(0);
76 }
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:24
A class for creating restricted objects.
Definition: Restartable.h:29
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< SetupInterface >()
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
Base class for a system (of equations)
Definition: SystemBase.h:92
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:42
const ExecFlagType EXEC_TIMESTEP_BEGIN
InputParameters validParams< Transfer >()
Definition: Transfer.C:26
Transfer(const InputParameters &parameters)
Definition: Transfer.C:48
static const Number OutOfMeshValue
Definition: Transfer.h:75
InputParameters validParams< MooseObject >()
Definition: MooseObject.C:25
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:59
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...
static System * find_sys(EquationSystems &es, const std::string &var_name)
Small helper function for finding the system containing the variable.
Definition: Transfer.C:65
unsigned int THREAD_ID
Definition: MooseTypes.h:161