www.mooseframework.org
NeighborCoupleable.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 #include "NeighborCoupleable.h"
11 
12 #include "FEProblem.h"
13 #include "MooseError.h" // mooseDeprecated
14 #include "MooseVariableFE.h"
15 #include "Problem.h"
16 #include "SubProblem.h"
17 
19  bool nodal,
20  bool neighbor_nodal)
21  : Coupleable(moose_object, nodal), _neighbor_nodal(neighbor_nodal)
22 {
23 }
24 
26 
27 const VariableValue &
28 NeighborCoupleable::coupledNeighborValue(const std::string & var_name, unsigned int comp)
29 {
30  MooseVariable * var = getVar(var_name, comp);
31  if (_neighbor_nodal)
32  return (_c_is_implicit) ? var->dofValuesNeighbor() : var->dofValuesOldNeighbor();
33  else
34  return (_c_is_implicit) ? var->slnNeighbor() : var->slnOldNeighbor();
35 }
36 
37 const VariableValue &
38 NeighborCoupleable::coupledNeighborValueDot(const std::string & var_name, unsigned int comp)
39 {
40  MooseVariable * var = getVar(var_name, comp);
41  if (_neighbor_nodal)
42  return var->dofValuesDotNeighbor();
43  else
44  return var->uDotNeighbor();
45 }
46 
47 const VariableValue &
48 NeighborCoupleable::coupledNeighborValueDotDu(const std::string & var_name, unsigned int comp)
49 {
50  MooseVariable * var = getVar(var_name, comp);
51  if (_neighbor_nodal)
52  return var->dofValuesDuDotDuNeighbor();
53  else
54  return var->duDotDuNeighbor();
55 }
56 
57 const VariableValue &
58 NeighborCoupleable::coupledNeighborValueOld(const std::string & var_name, unsigned int comp)
59 {
60  validateExecutionerType(var_name, "coupledNeighborValueOld");
61 
62  MooseVariable * var = getVar(var_name, comp);
63  if (_neighbor_nodal)
65  else
66  return (_c_is_implicit) ? var->slnOldNeighbor() : var->slnOlderNeighbor();
67 }
68 
69 const VariableValue &
70 NeighborCoupleable::coupledNeighborValueOlder(const std::string & var_name, unsigned int comp)
71 {
72  validateExecutionerType(var_name, "coupledNeighborValueOlder");
73 
74  MooseVariable * var = getVar(var_name, comp);
75  if (_neighbor_nodal)
76  {
77  if (_c_is_implicit)
78  return var->dofValuesOlderNeighbor();
79  else
80  mooseError("Older values not available for explicit schemes");
81  }
82  else
83  {
84  if (_c_is_implicit)
85  return var->slnOlderNeighbor();
86  else
87  mooseError("Older values not available for explicit schemes");
88  }
89 }
90 
91 const VariableGradient &
92 NeighborCoupleable::coupledNeighborGradient(const std::string & var_name, unsigned int comp)
93 {
94  if (_neighbor_nodal)
95  mooseError("Nodal variables do not have gradients");
96 
97  MooseVariable * var = getVar(var_name, comp);
98  return (_c_is_implicit) ? var->gradSlnNeighbor() : var->gradSlnOldNeighbor();
99 }
100 
101 const VariableGradient &
102 NeighborCoupleable::coupledNeighborGradientOld(const std::string & var_name, unsigned int comp)
103 {
104  if (_neighbor_nodal)
105  mooseError("Nodal variables do not have gradients");
106 
107  validateExecutionerType(var_name, "coupledNeighborGradientOld");
108  MooseVariable * var = getVar(var_name, comp);
109  return (_c_is_implicit) ? var->gradSlnOldNeighbor() : var->gradSlnOlderNeighbor();
110 }
111 
112 const VariableGradient &
113 NeighborCoupleable::coupledNeighborGradientOlder(const std::string & var_name, unsigned int comp)
114 {
115  if (_neighbor_nodal)
116  mooseError("Nodal variables do not have gradients");
117 
118  validateExecutionerType(var_name, "coupledNeighborGradientOlder");
119  MooseVariable * var = getVar(var_name, comp);
120  if (_c_is_implicit)
121  return var->gradSlnOlderNeighbor();
122  else
123  mooseError("Older values not available for explicit schemes");
124 }
125 
127 NeighborCoupleable::coupledVectorNeighborGradient(const std::string & var_name, unsigned int comp)
128 {
129  if (_neighbor_nodal)
130  mooseError("Gradients are non-sensical with nodal compute objects");
131 
132  VectorMooseVariable * var = getVectorVar(var_name, comp);
133  return (_c_is_implicit) ? var->gradSlnNeighbor() : var->gradSlnOldNeighbor();
134 }
135 
138  unsigned int comp)
139 {
140  if (_neighbor_nodal)
141  mooseError("Gradients are non-sensical with nodal compute objects");
142 
143  validateExecutionerType(var_name, "coupledNeighborGradientOld");
144  VectorMooseVariable * var = getVectorVar(var_name, comp);
145  return (_c_is_implicit) ? var->gradSlnOldNeighbor() : var->gradSlnOlderNeighbor();
146 }
147 
150  unsigned int comp)
151 {
152  if (_neighbor_nodal)
153  mooseError("Gradients are non-sensical with nodal compute objects");
154 
155  validateExecutionerType(var_name, "coupledNeighborGradientOlder");
156  VectorMooseVariable * var = getVectorVar(var_name, comp);
157  if (_c_is_implicit)
158  return var->gradSlnOlderNeighbor();
159  else
160  mooseError("Older values not available for explicit schemes");
161 }
162 
163 const VariableSecond &
164 NeighborCoupleable::coupledNeighborSecond(const std::string & var_name, unsigned int comp)
165 {
166  if (_neighbor_nodal)
167  mooseError("Nodal variables do not have second derivatives");
168 
169  MooseVariable * var = getVar(var_name, comp);
170  return (_c_is_implicit) ? var->secondSlnNeighbor() : var->secondSlnOldNeighbor();
171 }
172 
173 const VariableValue &
174 NeighborCoupleable::coupledNeighborDofValues(const std::string & var_name, unsigned int comp)
175 {
176  if (_neighbor_nodal)
177  mooseError("nodal objects should not call coupledDofValues");
178 
179  MooseVariable * var = getVar(var_name, comp);
180  return (_c_is_implicit) ? var->dofValuesNeighbor() : var->dofValuesOldNeighbor();
181 }
182 
183 const VariableValue &
184 NeighborCoupleable::coupledNeighborDofValuesOld(const std::string & var_name, unsigned int comp)
185 {
186  if (_neighbor_nodal)
187  mooseError("nodal objects should not call coupledDofValuesOld");
188 
189  validateExecutionerType(var_name, "coupledNeighborDofValuesOld");
190  MooseVariable * var = getVar(var_name, comp);
192 }
193 
194 const VariableValue &
195 NeighborCoupleable::coupledNeighborDofValuesOlder(const std::string & var_name, unsigned int comp)
196 {
197  if (_neighbor_nodal)
198  mooseError("nodal objects should not call coupledDofValuesOlder");
199 
200  validateExecutionerType(var_name, "coupledNeighborDofValuesOlder");
201  MooseVariable * var = getVar(var_name, comp);
202  if (_c_is_implicit)
203  return var->dofValuesOlderNeighbor();
204  else
205  mooseError("Older values not available for explicit schemes");
206 }
virtual const VectorVariableGradient & coupledVectorNeighborGradientOlder(const std::string &var_name, unsigned int comp=0)
OutputTools< Real >::VariableGradient VariableGradient
Definition: MooseTypes.h:198
void validateExecutionerType(const std::string &name, const std::string &fn_name) const
Checks to make sure that the current Executioner has set "_is_transient" when old/older values are co...
Definition: Coupleable.C:1467
VectorMooseVariable * getVectorVar(const std::string &var_name, unsigned int comp)
Extract pointer to a coupled vector variable.
Definition: Coupleable.C:247
virtual const VectorVariableGradient & coupledVectorNeighborGradientOld(const std::string &var_name, unsigned int comp=0)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
const VariableValue & duDotDuNeighbor() const
const FieldVariableValue & slnOlderNeighbor() const
virtual const VariableValue & coupledNeighborValueDotDu(const std::string &var_name, unsigned int comp=0)
MooseVariable * getVar(const std::string &var_name, unsigned int comp)
Extract pointer to a coupled variable.
Definition: Coupleable.C:241
const FieldVariableGradient & gradSlnOlderNeighbor() const
const FieldVariableSecond & secondSlnOldNeighbor() const
const FieldVariableGradient & gradSlnOldNeighbor() const
virtual const VariableSecond & coupledNeighborSecond(const std::string &var_name, unsigned int i=0)
bool _c_is_implicit
True if implicit value is required.
Definition: Coupleable.h:752
NeighborCoupleable(const MooseObject *moose_object, bool nodal, bool neighbor_nodal)
Constructing the object.
virtual const VariableValue & coupledNeighborDofValues(const std::string &var_name, unsigned int comp=0)
const MooseArray< Number > & dofValuesDotNeighbor() override
Returns time derivative of neighboring degrees of freedom.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:42
const FieldVariableSecond & secondSlnNeighbor() const
neighbor solution seconds
const FieldVariableValue & uDotNeighbor() const
neighbor dots
virtual const VariableValue & coupledNeighborValueDot(const std::string &var_name, unsigned int comp=0)
virtual const VariableGradient & coupledNeighborGradientOlder(const std::string &var_name, unsigned int comp=0)
virtual const VariableValue & coupledNeighborValueOld(const std::string &var_name, unsigned int comp=0)
virtual const VariableValue & coupledNeighborValueOlder(const std::string &var_name, unsigned int comp=0)
const FieldVariableValue & slnNeighbor() const
neighbor solutions
virtual const VariableGradient & coupledNeighborGradientOld(const std::string &var_name, unsigned int comp=0)
virtual const VariableValue & coupledNeighborValue(const std::string &var_name, unsigned int comp=0)
OutputTools< Real >::VariableValue VariableValue
Definition: MooseTypes.h:197
Interface for objects that needs coupling capabilities.
Definition: Coupleable.h:62
virtual const VectorVariableGradient & coupledVectorNeighborGradient(const std::string &var_name, unsigned int comp=0)
const MooseArray< Number > & dofValuesNeighbor() override
Returns dof solution on neighbor element.
const MooseArray< Number > & dofValuesDuDotDuNeighbor() override
Returns derivative of time derivative of neighboring degrees of freedom.
virtual const VariableValue & coupledNeighborDofValuesOld(const std::string &var_name, unsigned int comp=0)
const FieldVariableValue & slnOldNeighbor() const
virtual const VariableValue & coupledNeighborDofValuesOlder(const std::string &var_name, unsigned int comp=0)
OutputTools< Real >::VariableSecond VariableSecond
Definition: MooseTypes.h:199
const MooseArray< Number > & dofValuesOlderNeighbor() override
Returns older dof solution on neighbor element.
OutputTools< RealVectorValue >::VariableGradient VectorVariableGradient
Definition: MooseTypes.h:212
const MooseArray< Number > & dofValuesOldNeighbor() override
Returns old dof solution on neighbor element.
const FieldVariableGradient & gradSlnNeighbor() const
neighbor solution gradients
virtual const VariableGradient & coupledNeighborGradient(const std::string &var_name, unsigned int comp=0)