www.mooseframework.org
AuxScalarKernel.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "AuxScalarKernel.h"
16 #include "Assembly.h"
17 #include "MooseVariableScalar.h"
18 #include "Problem.h"
19 #include "SubProblem.h"
20 #include "SystemBase.h"
21 
22 template <>
25 {
27  params += validParams<SetupInterface>();
29 
30  params.addRequiredParam<AuxVariableName>("variable",
31  "The name of the variable that this kernel operates on");
32  params.addParam<bool>("use_displaced_mesh",
33  false,
34  "Whether or not this object should use the "
35  "displaced mesh for computation. Note that "
36  "in the case this is true but no "
37  "displacements are provided in the Mesh block "
38  "the undisplaced mesh will still be used.");
39  params.addParamNamesToGroup("use_displaced_mesh", "Advanced");
40 
41  params.declareControllable("enable"); // allows Control to enable/disable this type of object
42  params.registerBase("AuxScalarKernel");
43 
44  return params;
45 }
46 
48  : MooseObject(parameters),
49  ScalarCoupleable(this),
50  SetupInterface(this),
51  FunctionInterface(this),
52  UserObjectInterface(this),
55  TransientInterface(this),
56  ZeroInterface(parameters),
57  MeshChangedInterface(parameters),
58  _subproblem(*parameters.get<SubProblem *>("_subproblem")),
59  _sys(*parameters.get<SystemBase *>("_sys")),
60  _tid(parameters.get<THREAD_ID>("_tid")),
61  _assembly(_subproblem.assembly(_tid)),
62  _var(_sys.getScalarVariable(_tid, parameters.get<AuxVariableName>("variable"))),
63  _mesh(_subproblem.mesh()),
64  _u(_var.sln()),
65  _u_old(_var.slnOld())
66 {
67  _supplied_vars.insert(parameters.get<AuxVariableName>("variable"));
68 
69  const std::vector<MooseVariableScalar *> & coupled_vars = getCoupledMooseScalarVars();
70  for (const auto & var : coupled_vars)
71  _depend_vars.insert(var->name());
72 }
73 
75 
76 void
78 {
79  // In general, we want to compute AuxScalarKernel values
80  // redundantly, on every processor, to avoid communication.
81  //
82  // However, in rare cases not all processors will have access to a
83  // particular scalar variable, in which case we skip computation
84  // there.
85  if (_var.dofIndices().empty() || !_var.dofMap().all_semilocal_indices(_var.dofIndices()))
86  return;
87 
88  for (_i = 0; _i < _var.order(); ++_i)
89  {
90  Real value = computeValue();
91  _var.setValue(_i, value); // update variable data, which is referenced by other kernels, so the
92  // value is up-to-date
93  }
94 }
95 
96 const std::set<std::string> &
98 {
99  return _depend_vars;
100 }
101 
102 const std::set<std::string> &
104 {
105  return _supplied_vars;
106 }
107 
108 bool
110 {
111  return true;
112 }
MooseVariableScalar & _var
InputParameters validParams< AuxScalarKernel >()
const std::vector< MooseVariableScalar * > & getCoupledMooseScalarVars()
Get the list of coupled scalar variables.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< SetupInterface >()
Base class for a system (of equations)
Definition: SystemBase.h:91
virtual bool isActive()
Use this to enable/disable the constraint.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
virtual const std::set< std::string > & getSuppliedItems() override
Return a set containing the names of items owned by the object.
const DofMap & dofMap() const
The DofMap associated with the system this variable is in.
Interface for objects that needs transient capabilities.
virtual void compute()
Evaluate the kernel.
std::set< std::string > _supplied_vars
Interface for notifications that the mesh has changed.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:36
void setValue(unsigned int i, Number value)
Set the nodal value for this variable (to keep everything up to date.
InputParameters validParams< MeshChangedInterface >()
Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
Interface for objects that need to use UserObjects.
InputParameters validParams< MooseObject >()
Definition: MooseObject.C:22
virtual Real computeValue()=0
Compute the value of this kernel.
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:53
std::vector< dof_id_type > & dofIndices()
Interface to bring zero values inside objects.
Definition: ZeroInterface.h:35
std::set< std::string > _depend_vars
Depend AuxKernels.
Interface for sorting dependent vectors of objects.
Interface for objects that needs scalar coupling capabilities.
unsigned int _i
AuxScalarKernel(const InputParameters &parameters)
virtual const std::set< std::string > & getRequestedItems() override
Return a set containing the names of items requested by the object.
Interface for objects that need to use functions.
virtual ~AuxScalarKernel()
Interface class for classes which interact with Postprocessors.
unsigned int THREAD_ID
Definition: MooseTypes.h:79