https://mooseframework.inl.gov
Loading...
Searching...
No Matches
AuxScalarKernel.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#include "AuxScalarKernel.h"
11#include "Assembly.h"
12#include "MooseVariableScalar.h"
13#include "Problem.h"
14#include "SubProblem.h"
15#include "SystemBase.h"
16
19{
23
24 params.addRequiredParam<AuxVariableName>("variable",
25 "The name of the variable that this kernel operates on");
26 params.addParam<bool>("use_displaced_mesh",
27 false,
28 "Whether or not this object should use the "
29 "displaced mesh for computation. Note that "
30 "in the case this is true but no "
31 "displacements are provided in the Mesh block "
32 "the undisplaced mesh will still be used.");
33 params.addParamNamesToGroup("use_displaced_mesh", "Advanced");
34
35 params.declareControllable("enable"); // allows Control to enable/disable this type of object
36 params.registerBase("AuxScalarKernel");
37
38 return params;
39}
40
42 : MooseObject(parameters),
43 ScalarCoupleable(this),
44 SetupInterface(this),
50 MeshChangedInterface(parameters),
51 _subproblem(*getCheckedPointerParam<SubProblem *>("_subproblem")),
52 _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
53 _tid(parameters.get<THREAD_ID>("_tid")),
54 _assembly(_subproblem.assembly(_tid, 0)),
55 _var(_sys.getScalarVariable(_tid, parameters.get<AuxVariableName>("variable"))),
56 _mesh(_subproblem.mesh()),
57 _u(_var.sln())
58{
59 _supplied_vars.insert(parameters.get<AuxVariableName>("variable"));
60
61 const std::vector<MooseVariableScalar *> & coupled_vars = getCoupledMooseScalarVars();
62 for (const auto & var : coupled_vars)
63 _depend_vars.insert(var->name());
64}
65
67
68void
70{
71 // In general, we want to compute AuxScalarKernel values
72 // redundantly, on every processor, to avoid communication.
73 //
74 // However, in rare cases not all processors will have access to a
75 // particular scalar variable, in which case we skip computation
76 // there.
78 return;
79
80 for (_i = 0; _i < _var.order(); ++_i)
81 {
82 Real value = computeValue();
83 _var.setValue(_i, value); // update variable data, which is referenced by other kernels, so the
84 // value is up-to-date
85 }
86}
87
88const std::set<std::string> &
93
94const std::set<std::string> &
99
100bool
102{
103 return true;
104}
105
106const VariableValue &
108{
110 mooseError("The solution states have already been initialized when calling ",
111 type(),
112 "::uOld().\n\n",
113 "Make sure to call uOld() within the object constructor.");
114
115 return _var.slnOld();
116}
OutputTools< Real >::VariableValue VariableValue
Definition MooseTypes.h:348
unsigned int THREAD_ID
Definition MooseTypes.h:237
unsigned int _i
AuxScalarKernel(const InputParameters &parameters)
SystemBase & _sys
virtual ~AuxScalarKernel()
static InputParameters validParams()
virtual const std::set< std::string > & getSuppliedItems() override
Return a set containing the names of items owned by the object.
virtual Real computeValue()=0
Compute the value of this kernel.
MooseVariableScalar & _var
virtual bool isActive()
Use this to enable/disable the constraint.
virtual const std::set< std::string > & getRequestedItems() override
Return a set containing the names of items requested by the object.
std::set< std::string > _supplied_vars
std::set< std::string > _depend_vars
Depend AuxKernels.
const VariableValue & uOld() const
Retrieves the old value of the variable that this AuxScalarKernel operates on.
virtual void compute()
Evaluate the kernel.
Interface for sorting dependent vectors of objects.
Interface for objects that need to use functions.
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...
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 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...
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
Interface for notifications that the mesh has changed.
static InputParameters validParams()
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
const std::string & type() const
Get the type of this class.
Definition MooseBase.h:93
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
virtual const std::vector< dof_id_type > & dofIndices() const
Get local DoF indices.
const libMesh::DofMap & dofMap() const
The DofMap associated with the system this variable is in.
libMesh::Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int.
const VariableValue & slnOld() const
void setValue(unsigned int i, Number value)
Set the nodal value for this variable (to keep everything up to date.
Interface class for classes which interact with Postprocessors.
Interface for objects that needs scalar coupling capabilities.
const std::vector< MooseVariableScalar * > & getCoupledMooseScalarVars()
Get the list of coupled scalar variables.
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
bool solutionStatesInitialized() const
Whether or not the solution states have been initialized via initSolutionState()
Definition SystemBase.h:917
Interface for objects that needs transient capabilities.
Interface for objects that need to use UserObjects.
bool all_semilocal_indices(const std::vector< dof_id_type > &dof_indices) const
MeshBase & mesh