https://mooseframework.inl.gov
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PressureBase Class Referenceabstract

#include <PressureBase.h>

Inheritance diagram for PressureBase:
[legend]

Public Member Functions

 PressureBase (const InputParameters &parameters)
 
virtual void initialSetup () override
 

Static Public Member Functions

static InputParameters validParams ()
 
static InputParameters actionParams ()
 

Protected Member Functions

virtual Real computeQpJacobian () override final
 
virtual void precalculateQpJacobian () override final
 
virtual Real computeQpOffDiagJacobian (const unsigned int jvar_num) override final
 
virtual void precalculateQpOffDiagJacobian (const MooseVariableFEBase &jvar) override final
 
Real computeStiffness (const unsigned int coupled_component)
 
Real computeFaceStiffness (const unsigned int local_j, const unsigned int coupled_component)
 
virtual GenericReal< is_ad > computePressure () const=0
 
virtual GenericReal< is_ad > computeQpResidual () override final
 

Protected Attributes

const std::vector< RealGradient > * _q_dxi
 
const std::vector< RealGradient > * _q_deta
 
const std::vector< std::vector< Real > > * _phi_dxi
 
const std::vector< std::vector< Real > > * _phi_deta
 
const bool _use_displaced_mesh
 
std::vector< std::unique_ptr< FEBase > > _fe
 
std::map< unsigned int, unsigned int_node_map
 
std::vector< unsigned int_disp_var
 Variable numbers of coupled displacement variables. More...
 
const unsigned int _ndisp
 Number of displacement variables. More...
 
const unsigned int _component
 displacement component to apply the bc to More...
 
Moose::CoordinateSystemType _coord_type
 Coordinate system type. More...
 
 usingTransientInterfaceMembers
 

Detailed Description

Definition at line 70 of file PressureBase.h.

Constructor & Destructor Documentation

◆ PressureBase()

PressureBase::PressureBase ( const InputParameters parameters)

Definition at line 104 of file PressureBase.C.

105  : PressureBaseTempl<false>(parameters),
106  _q_dxi(nullptr),
107  _q_deta(nullptr),
108  _phi_dxi(nullptr),
109  _phi_deta(nullptr),
110  _use_displaced_mesh(this->template getParam<bool>("use_displaced_mesh")),
112 {
113 }
unsigned int n_threads()
const std::vector< std::vector< Real > > * _phi_dxi
Definition: PressureBase.h:86
const bool _use_displaced_mesh
Definition: PressureBase.h:88
const std::vector< RealGradient > * _q_dxi
Definition: PressureBase.h:84
std::vector< std::unique_ptr< FEBase > > _fe
Definition: PressureBase.h:91
const std::vector< RealGradient > * _q_deta
Definition: PressureBase.h:85
const std::vector< std::vector< Real > > * _phi_deta
Definition: PressureBase.h:87

Member Function Documentation

◆ actionParams()

InputParameters PressureBaseTempl< is_ad >::actionParams ( )
staticinherited

Definition at line 30 of file PressureBase.C.

31 {
32  auto params = emptyInputParameters();
33  params.addRequiredCoupledVar("displacements",
34  "The string of displacements suitable for the problem statement");
35  return params;
36 }
InputParameters emptyInputParameters()

◆ computeFaceStiffness()

Real PressureBase::computeFaceStiffness ( const unsigned int  local_j,
const unsigned int  coupled_component 
)
protected

Definition at line 116 of file PressureBase.C.

Referenced by computeStiffness().

117 {
118  //
119  // Note that this approach will break down for shell elements, i.e.,
120  // topologically 2D elements in 3D space with pressure loads on
121  // the faces.
122  //
123  const Real phi_dxi = (*_phi_dxi)[local_j][_qp];
124  const Real phi_deta = _phi_deta ? (*_phi_deta)[local_j][_qp] : 0;
125 
126  const RealGradient & dqdxi = (*_q_dxi)[_qp];
127  const RealGradient out_of_plane(0, 0, 1);
128  const RealGradient & dqdeta = _q_deta ? (*_q_deta)[_qp] : out_of_plane;
129  // Here, b is dqdxi (cross) dqdeta
130  // Then, normal is b/length(b)
131  RealGradient b(dqdxi(1) * dqdeta(2) - dqdxi(2) * dqdeta(1),
132  dqdxi(2) * dqdeta(0) - dqdxi(0) * dqdeta(2),
133  dqdxi(0) * dqdeta(1) - dqdxi(1) * dqdeta(0));
134  const Real inv_length = 1 / (b * _normals[_qp]);
135 
136  const unsigned int i = _component;
137  const unsigned int j = coupled_component;
138 
139  // const int posneg[3][3] = {{0, -1, 1}, {1, 0, -1}, {-1, 1, 0}};
140  const int posneg = 1 - (j + (2 - (i + 1) % 3)) % 3;
141 
142  // const unsigned int index[3][3] = {{0, 2, 1}, {2, 1, 0}, {1, 0, 2}};
143  const unsigned int index = 2 - (j + (i + 2) % 3) % 3;
144 
145  const Real variation_b = posneg * (phi_deta * dqdxi(index) - phi_dxi * dqdeta(index));
146 
147  Real rz_term = 0;
148  if (_coord_type == Moose::COORD_RZ && j == _subproblem.getAxisymmetricRadialCoord())
149  {
150  rz_term = _normals[_qp](i) * _phi[_j][_qp] / _q_point[_qp](0);
151  }
152 
153  return computePressure() * _test[_i][_qp] * (inv_length * variation_b + rz_term);
154 }
Moose::CoordinateSystemType _coord_type
Coordinate system type.
Definition: PressureBase.h:54
virtual GenericReal< is_ad > computePressure() const=0
const unsigned int _component
displacement component to apply the bc to
Definition: PressureBase.h:51
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::vector< RealGradient > * _q_deta
Definition: PressureBase.h:85
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const std::vector< std::vector< Real > > * _phi_deta
Definition: PressureBase.h:87

◆ computePressure()

virtual GenericReal<is_ad> PressureBaseTempl< is_ad >::computePressure ( ) const
protectedpure virtualinherited

◆ computeQpJacobian()

Real PressureBase::computeQpJacobian ( )
finaloverrideprotectedvirtual

Definition at line 184 of file PressureBase.C.

185 {
188 
189  return 0;
190 }
const bool _use_displaced_mesh
Definition: PressureBase.h:88
Real computeStiffness(const unsigned int coupled_component)
Definition: PressureBase.C:157
const unsigned int _component
displacement component to apply the bc to
Definition: PressureBase.h:51

◆ computeQpOffDiagJacobian()

Real PressureBase::computeQpOffDiagJacobian ( const unsigned int  jvar_num)
finaloverrideprotectedvirtual

Definition at line 193 of file PressureBase.C.

194 {
196  for (unsigned int j = 0; j < _ndisp; ++j)
197  if (jvar_num == _disp_var[j])
198  return computeStiffness(j);
199 
200  return 0;
201 }
const bool _use_displaced_mesh
Definition: PressureBase.h:88
Real computeStiffness(const unsigned int coupled_component)
Definition: PressureBase.C:157
std::vector< unsigned int > _disp_var
Variable numbers of coupled displacement variables.
Definition: PressureBase.h:45
const unsigned int _ndisp
Number of displacement variables.
Definition: PressureBase.h:48
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")

◆ computeQpResidual()

GenericReal< is_ad > PressureBaseTempl< is_ad >::computeQpResidual ( )
finaloverrideprotectedvirtualinherited

Definition at line 99 of file PressureBase.C.

100 {
101  return computePressure() * (_normals[_qp](_component) * _test[_i][_qp]);
102 }
virtual GenericReal< is_ad > computePressure() const=0
const unsigned int _component
displacement component to apply the bc to
Definition: PressureBase.h:51

◆ computeStiffness()

Real PressureBase::computeStiffness ( const unsigned int  coupled_component)
protected

Definition at line 157 of file PressureBase.C.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

158 {
159  if (_ndisp > 1)
160  {
161  const std::map<unsigned int, unsigned int>::iterator j_it = _node_map.find(_j);
162  if (_test[_i][_qp] == 0 || j_it == _node_map.end())
163  return 0;
164 
165  return computeFaceStiffness(j_it->second, coupled_component);
166  }
167 
169  {
170  return computePressure() * _normals[_qp](_component) * _test[_i][_qp] * _phi[_j][_qp] *
171  (2 / _q_point[_qp](0));
172  }
173 
175  {
176  return computePressure() * _normals[_qp](_component) * _test[_i][_qp] * _phi[_j][_qp] /
177  _q_point[_qp](0);
178  }
179 
180  return 0;
181 }
Moose::CoordinateSystemType _coord_type
Coordinate system type.
Definition: PressureBase.h:54
virtual GenericReal< is_ad > computePressure() const=0
COORD_RSPHERICAL
const unsigned int _component
displacement component to apply the bc to
Definition: PressureBase.h:51
const unsigned int _ndisp
Number of displacement variables.
Definition: PressureBase.h:48
std::map< unsigned int, unsigned int > _node_map
Definition: PressureBase.h:93
Real computeFaceStiffness(const unsigned int local_j, const unsigned int coupled_component)
Definition: PressureBase.C:116

◆ initialSetup()

void PressureBaseTempl< is_ad >::initialSetup ( )
overridevirtualinherited

Definition at line 72 of file PressureBase.C.

73 {
74  auto boundary_ids = this->boundaryIDs();
75  std::set<SubdomainID> block_ids;
76  for (auto bndry_id : boundary_ids)
77  {
78  auto bids = _mesh.getBoundaryConnectedBlocks(bndry_id);
79  block_ids.insert(bids.begin(), bids.end());
80  }
81 
82  if (block_ids.size())
83  _coord_type = _fe_problem.getCoordSystem(*block_ids.begin());
84  else
85  {
86  mooseInfo(
87  "No connected blocks were found, the coordinate system type is obtained from the mesh.");
88  _coord_type = _fe_problem.mesh().getUniqueCoordSystem();
89  }
90  for (auto blk_id : block_ids)
91  {
92  if (_coord_type != _fe_problem.getCoordSystem(blk_id))
93  mooseError("The Pressure BC requires subdomains to have the same coordinate system.");
94  }
95 }
void mooseError(Args &&... args)
Moose::CoordinateSystemType _coord_type
Coordinate system type.
Definition: PressureBase.h:54
void mooseInfo(Args &&... args)

◆ precalculateQpJacobian()

void PressureBase::precalculateQpJacobian ( )
finaloverrideprotectedvirtual

Definition at line 204 of file PressureBase.C.

Referenced by precalculateQpOffDiagJacobian().

205 {
206  if (_ndisp == 1)
207  return;
208 
209  if (_fe[_tid] == nullptr)
210  {
211  const unsigned int dim = _sys.mesh().dimension() - 1;
212  QBase * const & qrule = _assembly.writeableQRuleFace();
213  _fe[_tid] = FEBase::build(dim, _var.feType());
214  _fe[_tid]->attach_quadrature_rule(qrule);
215  }
216 
217  _q_dxi = &_fe[_tid]->get_dxyzdxi();
218  _phi_dxi = &_fe[_tid]->get_dphidxi();
220  {
221  _q_deta = &_fe[_tid]->get_dxyzdeta();
222  _phi_deta = &_fe[_tid]->get_dphideta();
223  }
224 
225  _fe[_tid]->reinit(_current_side_elem);
226 
228  {
229  if (_q_deta->empty())
230  _q_deta = nullptr;
231  if (_phi_deta->empty())
232  _phi_deta = nullptr;
233  }
234 
235  // Compute node map (given elem node, supply face node)
236  _node_map.clear();
237  const unsigned int num_node_elem = _current_elem->n_nodes();
238  const Node * const * elem_nodes = _current_elem->get_nodes();
239  const unsigned int num_node_face = _current_side_elem->n_nodes();
240  const Node * const * face_nodes = _current_side_elem->get_nodes();
241  unsigned int num_found = 0;
242  for (unsigned i = 0; i < num_node_elem; ++i)
243  {
244  for (unsigned j = 0; j < num_node_face; ++j)
245  if (**(elem_nodes + i) == **(face_nodes + j))
246  {
247  _node_map[i] = j;
248  ++num_found;
249  break;
250  }
251  if (num_found == num_node_face)
252  break;
253  }
254 }
std::unique_ptr< FEGenericBase< Real > > build(const unsigned int dim, const FEType &fet)
const std::vector< std::vector< Real > > * _phi_dxi
Definition: PressureBase.h:86
unsigned int dim
Moose::CoordinateSystemType _coord_type
Coordinate system type.
Definition: PressureBase.h:54
const std::vector< RealGradient > * _q_dxi
Definition: PressureBase.h:84
std::vector< std::unique_ptr< FEBase > > _fe
Definition: PressureBase.h:91
const std::vector< RealGradient > * _q_deta
Definition: PressureBase.h:85
const unsigned int _ndisp
Number of displacement variables.
Definition: PressureBase.h:48
std::map< unsigned int, unsigned int > _node_map
Definition: PressureBase.h:93
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const std::vector< std::vector< Real > > * _phi_deta
Definition: PressureBase.h:87

◆ precalculateQpOffDiagJacobian()

void PressureBase::precalculateQpOffDiagJacobian ( const MooseVariableFEBase jvar)
finaloverrideprotectedvirtual

Definition at line 257 of file PressureBase.C.

258 {
260 }
virtual void precalculateQpJacobian() override final
Definition: PressureBase.C:204

◆ validParams()

InputParameters PressureBaseTempl< is_ad >::validParams ( )
staticinherited

Definition at line 19 of file PressureBase.C.

20 {
22  params.addDeprecatedParam<unsigned int>(
23  "component", "The component for the pressure", "This parameter is no longer necessary");
24  params.addParam<bool>("use_displaced_mesh", true, "Whether to use the displaced mesh.");
25  return params;
26 }
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
InputParameters validParams()

Member Data Documentation

◆ _component

const unsigned int PressureBaseTempl< is_ad >::_component
protectedinherited

displacement component to apply the bc to

Definition at line 51 of file PressureBase.h.

Referenced by computeFaceStiffness(), computeQpJacobian(), and computeStiffness().

◆ _coord_type

Moose::CoordinateSystemType PressureBaseTempl< is_ad >::_coord_type
protectedinherited

Coordinate system type.

Definition at line 54 of file PressureBase.h.

Referenced by computeFaceStiffness(), computeStiffness(), and precalculateQpJacobian().

◆ _disp_var

std::vector<unsigned int> PressureBaseTempl< is_ad >::_disp_var
protectedinherited

Variable numbers of coupled displacement variables.

Definition at line 45 of file PressureBase.h.

Referenced by computeQpOffDiagJacobian().

◆ _fe

std::vector<std::unique_ptr<FEBase> > PressureBase::_fe
protected

Definition at line 91 of file PressureBase.h.

Referenced by precalculateQpJacobian().

◆ _ndisp

const unsigned int PressureBaseTempl< is_ad >::_ndisp
protectedinherited

Number of displacement variables.

Definition at line 48 of file PressureBase.h.

Referenced by computeQpOffDiagJacobian(), computeStiffness(), and precalculateQpJacobian().

◆ _node_map

std::map<unsigned int, unsigned int> PressureBase::_node_map
protected

Definition at line 93 of file PressureBase.h.

Referenced by computeStiffness(), and precalculateQpJacobian().

◆ _phi_deta

const std::vector<std::vector<Real> >* PressureBase::_phi_deta
protected

Definition at line 87 of file PressureBase.h.

Referenced by computeFaceStiffness(), and precalculateQpJacobian().

◆ _phi_dxi

const std::vector<std::vector<Real> >* PressureBase::_phi_dxi
protected

Definition at line 86 of file PressureBase.h.

Referenced by precalculateQpJacobian().

◆ _q_deta

const std::vector<RealGradient>* PressureBase::_q_deta
protected

Definition at line 85 of file PressureBase.h.

Referenced by computeFaceStiffness(), and precalculateQpJacobian().

◆ _q_dxi

const std::vector<RealGradient>* PressureBase::_q_dxi
protected

Definition at line 84 of file PressureBase.h.

Referenced by precalculateQpJacobian().

◆ _use_displaced_mesh

const bool PressureBase::_use_displaced_mesh
protected

Definition at line 88 of file PressureBase.h.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

◆ usingTransientInterfaceMembers

PressureBaseTempl< is_ad >::usingTransientInterfaceMembers
protectedinherited

Definition at line 56 of file PressureBase.h.


The documentation for this class was generated from the following files: