Line data Source code
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 : 18 : registerMooseObject("XFEMApp", XFEMPressure); 19 : 20 : InputParameters 21 72 : XFEMPressure::validParams() 22 : { 23 72 : InputParameters params = DiracKernel::validParams(); 24 144 : params.addRequiredParam<unsigned int>("component", "The component for the pressure"); 25 144 : params.addParam<Real>("factor", 1.0, "The magnitude to use in computing the pressure"); 26 144 : params.addParam<FunctionName>("function", "The function that describes the pressure"); 27 72 : params.addClassDescription("Applies a pressure on an interface cut by XFEM."); 28 72 : return params; 29 0 : } 30 : 31 36 : XFEMPressure::XFEMPressure(const InputParameters & parameters) 32 : : DiracKernel(parameters), 33 36 : _component(getParam<unsigned int>("component")), 34 72 : _factor(getParam<Real>("factor")), 35 108 : _function(isParamValid("function") ? &getFunction("function") : nullptr), 36 72 : _element_pair_locators(_subproblem.geomSearchData()._element_pair_locators) 37 : { 38 36 : } 39 : 40 : void 41 5519 : XFEMPressure::addPoints() 42 : { 43 : _elem_qp_normal.clear(); 44 : _elem_qp_JxW.clear(); 45 : 46 11038 : 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 93669 : for (const auto & elem_pair : elem_pairs) 52 : { 53 88150 : const auto [elem1, elem2] = elem_pair; 54 88150 : const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(elem_pair); 55 : 56 287190 : for (const auto i : index_range(info._elem1_constraint_q_point)) 57 : { 58 199040 : _elem_qp_normal[elem1][i] = -info._elem1_normal; 59 199040 : _elem_qp_normal[elem2][i] = -info._elem2_normal; 60 199040 : _elem_qp_JxW[elem1][i] = info._elem1_constraint_JxW[i]; 61 199040 : _elem_qp_JxW[elem2][i] = info._elem2_constraint_JxW[i]; 62 199040 : addPoint(elem1, info._elem1_constraint_q_point[i]); 63 199040 : addPoint(elem2, info._elem2_constraint_q_point[i]); 64 : } 65 : } 66 : } 67 5519 : } 68 : 69 : Real 70 731840 : XFEMPressure::computeQpResidual() 71 : { 72 731840 : Real factor = _factor; 73 : 74 731840 : if (_function) 75 731840 : factor *= _function->value(_t, _current_point); 76 : 77 731840 : Point normal = _elem_qp_normal[_current_elem][_qp]; 78 731840 : Real JxW = _elem_qp_JxW[_current_elem][_qp]; 79 : 80 731840 : return -factor * JxW * (normal(_component) * _test[_i][_qp]); 81 : }