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 
17 
18 template <>
19 InputParameters
21 {
22  InputParameters params = validParams<DiracKernel>();
23  params.addRequiredParam<unsigned int>("component", "The component for the pressure");
24  params.addParam<Real>("factor", 1.0, "The magnitude to use in computing the pressure");
25  params.addParam<FunctionName>("function", "The function that describes the pressure");
26  return params;
27 }
28 
29 XFEMPressure::XFEMPressure(const InputParameters & parameters)
30  : DiracKernel(parameters),
31  _component(getParam<unsigned int>("component")),
32  _factor(getParam<Real>("factor")),
33  _function(isParamValid("function") ? &getFunction("function") : NULL)
34 {
35  GeometricSearchData & geo_search_data = _subproblem.geomSearchData();
36  _element_pair_locators = &geo_search_data._element_pair_locators;
37 }
38 
39 void
41 {
42  _elem_qp_normal.clear();
43  _elem_qp_JxW.clear();
44 
45  for (std::map<unsigned int, std::shared_ptr<ElementPairLocator>>::iterator it_epl =
46  _element_pair_locators->begin();
47  it_epl != _element_pair_locators->end();
48  ++it_epl)
49  {
50  ElementPairLocator & elem_pair_loc = *it_epl->second;
51  // go over pair elements
52  const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
53  elem_pair_loc.getElemPairs();
54  for (std::list<std::pair<const Elem *, const Elem *>>::const_iterator it_ep =
55  elem_pairs.begin();
56  it_ep != elem_pairs.end();
57  ++it_ep)
58  {
59  const Elem * elem1 = it_ep->first;
60  const Elem * elem2 = it_ep->second;
61  const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(*it_ep);
62 
63  for (unsigned int i = 0; i < info._elem1_constraint_q_point.size(); ++i)
64  {
65  _elem_qp_normal[elem1][i] = -info._elem1_normal;
66  _elem_qp_normal[elem2][i] = -info._elem2_normal;
67  _elem_qp_JxW[elem1][i] = info._elem1_constraint_JxW[i];
68  _elem_qp_JxW[elem2][i] = info._elem2_constraint_JxW[i];
69  addPoint(elem1, info._elem1_constraint_q_point[i]);
70  addPoint(elem2, info._elem2_constraint_q_point[i]);
71  }
72  }
73  }
74 }
75 
76 Real
78 {
79  Real factor = _factor;
80 
81  if (_function)
82  factor *= _function->value(_t, _current_point);
83 
84  Point normal = _elem_qp_normal[_current_elem][_qp];
85  Real JxW = _elem_qp_JxW[_current_elem][_qp];
86 
87  return -factor * JxW * (normal(_component) * _test[_i][_qp]);
88 }
XFEMPressure::_elem_qp_normal
std::map< const Elem *, std::map< unsigned int, Point > > _elem_qp_normal
Definition: XFEMPressure.h:31
validParams< XFEMPressure >
InputParameters validParams< XFEMPressure >()
Definition: XFEMPressure.C:20
XFEMPressure::_function
const Function *const _function
Definition: XFEMPressure.h:28
XFEMPressure::_factor
const Real _factor
Definition: XFEMPressure.h:27
XFEMPressure::addPoints
virtual void addPoints()
Definition: XFEMPressure.C:40
registerMooseObject
registerMooseObject("XFEMApp", XFEMPressure)
XFEMPressure::_elem_qp_JxW
std::map< const Elem *, std::map< unsigned int, Real > > _elem_qp_JxW
Definition: XFEMPressure.h:32
XFEMPressure
Definition: XFEMPressure.h:17
XFEMPressure.h
XFEMPressure::_component
const int _component
Definition: XFEMPressure.h:26
XFEMPressure::computeQpResidual
virtual Real computeQpResidual()
Definition: XFEMPressure.C:77
XFEMPressure::_element_pair_locators
std::map< unsigned int, std::shared_ptr< ElementPairLocator > > * _element_pair_locators
Definition: XFEMPressure.h:30
XFEMPressure::XFEMPressure
XFEMPressure(const InputParameters &parameters)
Definition: XFEMPressure.C:29