https://mooseframework.inl.gov
Loading...
Searching...
No Matches
XFEMPressure.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
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
40void
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
69Real
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];
78 Real JxW = _elem_qp_JxW[_current_elem][_qp];
79
80 return -factor * JxW * (normal(_component) * _test[_i][_qp]);
81}
registerMooseObject("XFEMApp", XFEMPressure)
void ErrorVector unsigned int
unsigned int _i
const Elem *const & _current_elem
unsigned int _qp
void addPoint(const Elem *elem, Point p, unsigned id=libMesh::invalid_uint, Real value=1.0)
static InputParameters validParams()
const OutputTools< T >::VariableTestValue & _test
const ElementPairList & getElemPairs() const
const ElementPairInfo & getElemPairInfo(std::pair< const Elem *, const Elem * > elem_pair) const
virtual Real value(Real t, const Point &p) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const std::map< BoundaryID, std::shared_ptr< ElementPairLocator > > & _element_pair_locators
XFEMPressure(const InputParameters &parameters)
const Real _factor
virtual void addPoints()
virtual Real computeQpResidual()
std::map< const Elem *, std::map< unsigned int, Real > > _elem_qp_JxW
static InputParameters validParams()
const int _component
const Function *const _function
std::map< const Elem *, std::map< unsigned int, Point > > _elem_qp_normal