https://mooseframework.inl.gov
NormalBoundaryDisplacement.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 
11 
12 #include "libmesh/quadrature.h"
13 
15 
18 {
20  params.addRequiredCoupledVar("displacements", "The names of the displacement variables");
21  MooseEnum type_options("average=0 absolute_average=1 max=2 absolute_max=3");
23  "value_type", type_options, "Type of extreme value to return.");
24  params.addClassDescription(
25  "This postprocessor computes the normal displacement on a given set of boundaries.");
26  return params;
27 }
28 
30  : SidePostprocessor(parameters),
31  _value_type(getParam<MooseEnum>("value_type").getEnum<NormalValType>()),
32  _ncomp(coupledComponents("displacements"))
33 {
34  if (_ncomp != _mesh.dimension())
35  paramError("displacements", "Number of entries must match the mesh dimension.");
36 
37  _disp.resize(_ncomp);
38  for (unsigned int j = 0; j < _ncomp; ++j)
39  _disp[j] = &coupledValue("displacements", j);
40 }
41 
42 void
44 {
46  _area = 0;
47 }
48 
49 void
51 {
52  for (unsigned int qp = 0; qp < _qrule->n_points(); qp++)
53  {
54  Real ddn = 0;
55  for (unsigned int j = 0; j < _ncomp; ++j)
56  ddn += _normals[qp](j) * (*_disp[j])[qp];
57 
58  _area += _JxW[qp] * _coord[qp];
59  switch (_value_type)
60  {
62  _boundary_displacement += _JxW[qp] * _coord[qp] * ddn;
63  break;
65  _boundary_displacement += _JxW[qp] * _coord[qp] * std::abs(ddn);
66  break;
67  case NormalValType::MAX:
68  if (ddn > _boundary_displacement)
70  break;
72  ddn = std::abs(ddn);
73  if (ddn > _boundary_displacement)
75  break;
76  }
77  }
78 }
79 
80 Real
82 {
84 }
85 
86 void
88 {
89  const auto & pps = static_cast<const NormalBoundaryDisplacement &>(y);
90 
91  switch (_value_type)
92  {
94  _boundary_displacement += pps._boundary_displacement;
95  break;
97  _boundary_displacement += pps._boundary_displacement;
98  break;
99  case NormalValType::MAX:
100  if (pps._boundary_displacement > _boundary_displacement)
101  _boundary_displacement = pps._boundary_displacement;
102  break;
104  if (pps._boundary_displacement > _boundary_displacement)
105  _boundary_displacement = pps._boundary_displacement;
106  break;
107  }
108 
109  _area += pps._area;
110 }
111 
112 void
114 {
115  gatherSum(_area);
116  switch (_value_type)
117  {
121  break;
125  break;
126  case NormalValType::MAX:
128  break;
131  break;
132  }
133 }
std::vector< const VariableValue * > _disp
displacement variable disp_x, disp_y, disp_z
void gatherMax(T &value)
virtual void initialize() override
This postprocessor computes displacements normal to a provided set of boundaries. ...
const std::vector< double > y
registerMooseObject("SolidMechanicsApp", NormalBoundaryDisplacement)
void addRequiredParam(const std::string &name, const std::string &doc_string)
const MooseArray< Real > & _JxW
virtual const VariableValue & coupledValue(const std::string &var_name, unsigned int comp=0) const
void gatherSum(T &value)
virtual unsigned int dimension() const
NormalValType _value_type
the type of the normal displacement value
void paramError(const std::string &param, Args... args) const
const MooseArray< Real > & _coord
virtual Real getValue() const override
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
Real _area
area of the boundary/boundaries
NormalBoundaryDisplacement(const InputParameters &parameters)
virtual void threadJoin(const UserObject &y) override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MooseMesh & _mesh
unsigned int _ncomp
number of components in _disp
static InputParameters validParams()
const QBase *const & _qrule
const MooseArray< Point > & _normals
Real _boundary_displacement
boundary displacement value accumulated during execute
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
static InputParameters validParams()