www.mooseframework.org
XFEMPressure.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 "XFEMPressure.h"
11 #include "Function.h"
12 #include "GeometricSearchData.h"
13 #include "ElementPairLocator.h"
14 #include "FEProblem.h"
15 
16 #include "libmesh/int_range.h"
17 
19 
22 {
24  params.addRequiredParam<unsigned int>("component", "The component for the pressure");
25  params.addParam<Real>("factor", 1.0, "The magnitude to use in computing the pressure");
26  params.addParam<FunctionName>("function", "The function that describes the pressure");
27  params.addClassDescription("Applies a pressure on an interface cut by XFEM.");
28  return params;
29 }
30 
32  : DiracKernel(parameters),
33  _component(getParam<unsigned int>("component")),
34  _factor(getParam<Real>("factor")),
35  _function(isParamValid("function") ? &getFunction("function") : nullptr),
36  _element_pair_locators(_subproblem.geomSearchData()._element_pair_locators)
37 {
38 }
39 
40 void
42 {
43  _elem_qp_normal.clear();
44  _elem_qp_JxW.clear();
45 
46  for (const auto & epl : _element_pair_locators)
47  {
48  ElementPairLocator & elem_pair_loc = *epl.second;
49  // go over element pairs
50  const auto & elem_pairs = elem_pair_loc.getElemPairs();
51  for (const auto & elem_pair : elem_pairs)
52  {
53  const auto [elem1, elem2] = elem_pair;
54  const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(elem_pair);
55 
56  for (const auto i : index_range(info._elem1_constraint_q_point))
57  {
58  _elem_qp_normal[elem1][i] = -info._elem1_normal;
59  _elem_qp_normal[elem2][i] = -info._elem2_normal;
60  _elem_qp_JxW[elem1][i] = info._elem1_constraint_JxW[i];
61  _elem_qp_JxW[elem2][i] = info._elem2_constraint_JxW[i];
62  addPoint(elem1, info._elem1_constraint_q_point[i]);
63  addPoint(elem2, info._elem2_constraint_q_point[i]);
64  }
65  }
66  }
67 }
68 
69 Real
71 {
72  Real factor = _factor;
73 
74  if (_function)
75  factor *= _function->value(_t, _current_point);
76 
77  Point normal = _elem_qp_normal[_current_elem][_qp];
79 
80  return -factor * JxW * (normal(_component) * _test[_i][_qp]);
81 }
const Function *const _function
Definition: XFEMPressure.h:30
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
MPI_Info info
std::map< const Elem *, std::map< unsigned int, Point > > _elem_qp_normal
Definition: XFEMPressure.h:33
const int _component
Definition: XFEMPressure.h:28
void addPoint(const Elem *elem, Point p, unsigned id=libMesh::invalid_uint)
const OutputTools< T >::VariableTestValue & _test
std::map< const Elem *, std::map< unsigned int, Real > > _elem_qp_JxW
Definition: XFEMPressure.h:34
const ElementPairInfo & getElemPairInfo(std::pair< const Elem *, const Elem * > elem_pair) const
const std::map< BoundaryID, std::shared_ptr< ElementPairLocator > > & _element_pair_locators
Definition: XFEMPressure.h:32
void addRequiredParam(const std::string &name, const std::string &doc_string)
XFEMPressure(const InputParameters &parameters)
Definition: XFEMPressure.C:31
const ElementPairList & getElemPairs() const
const Elem *const & _current_elem
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Real _factor
Definition: XFEMPressure.h:29
unsigned int _qp
void addClassDescription(const std::string &doc_string)
virtual void addPoints()
Definition: XFEMPressure.C:41
virtual Real value(Real t, const Point &p) const
unsigned int _i
static InputParameters validParams()
Definition: XFEMPressure.C:21
void ErrorVector unsigned int
auto index_range(const T &sizable)
virtual Real computeQpResidual()
Definition: XFEMPressure.C:70
static InputParameters validParams()
registerMooseObject("XFEMApp", XFEMPressure)