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 : #ifdef MOOSE_MFEM_ENABLED 11 : 12 : #include "MFEMVariableSamplerBase.h" 13 : 14 : #include "MFEMProblem.h" 15 : #include "MooseEnum.h" 16 : #include "SubProblem.h" 17 : 18 : namespace 19 : { 20 125862 : CreateMooseEnumClass(L2AverageType, NONE, ARITHMETIC, HARMONIC); 21 : 22 : mfem::ParMesh & 23 395 : variableMesh(const InputParameters & parameters) 24 : { 25 : auto & problem = 26 1185 : static_cast<MFEMProblem &>(*parameters.getCheckedPointerParam<SubProblem *>("_subproblem")); 27 : return const_cast<mfem::ParMesh &>( 28 395 : problem.getMFEMVariableMesh(parameters.get<VariableName>("variable"))); 29 : } 30 : } 31 : 32 : InputParameters 33 11442 : MFEMVariableSamplerBase::validParams() 34 : { 35 11442 : InputParameters params = MFEMSamplerBase::validParams(); 36 45768 : MFEMExecutedObject::addRequiredDependencyParam<VariableName>( 37 : params, "variable", "The variable that this VectorPostprocessor samples"); 38 22884 : MooseEnum avg_type(getL2AverageTypeOptions(), "ARITHMETIC", false); 39 34326 : params.addParam<MooseEnum>("side_interpolation_type", 40 : avg_type, 41 : "Average type used when sampling L2 functions at element boundaries."); 42 22884 : return params; 43 11442 : } 44 : 45 395 : MFEMVariableSamplerBase::MFEMVariableSamplerBase(const InputParameters & parameters, 46 395 : const std::vector<Point> & points) 47 : : MFEMSamplerBase(parameters, points, variableMesh(parameters)), 48 790 : _var_name(getParam<VariableName>("variable")) 49 : { 50 395 : _finder.SetL2AvgType(static_cast<mfem::FindPointsGSLIB::AvgType>( 51 1185 : getParam<MooseEnum>("side_interpolation_type").getEnum<L2AverageType>())); 52 395 : } 53 : 54 : void 55 395 : MFEMVariableSamplerBase::initialSetup() 56 : { 57 395 : MFEMSamplerBase::initialSetup(); 58 : 59 389 : const auto continuity_type = getFESpaceContinuityType(); 60 389 : if (continuity_type == mfem::FiniteElementCollection::CONTINUOUS) 61 208 : return; 62 : 63 181 : const auto & point_codes = _finder.GetCode(); 64 1866 : for (const auto i : index_range(_query_points)) 65 1693 : if (PointLocationCode(point_codes[i]) == PointLocationCode::BORDER) 66 239 : switch (continuity_type) 67 : { 68 235 : case mfem::FiniteElementCollection::DISCONTINUOUS: 69 235 : mooseWarning(typeAndName(), 70 : " found a point on an element boundary but the FE space is discontinuous at " 71 : "element boundaries: ", 72 235 : _query_points[i], 73 : "."); 74 231 : break; 75 2 : case mfem::FiniteElementCollection::TANGENTIAL: 76 2 : mooseWarning(typeAndName(), 77 : " found point ", 78 2 : _query_points[i], 79 : " on an element boundary. The H(curl) finite element space has a continuous " 80 : "tangential trace there, but the normal component may differ between " 81 : "elements. The element selected by GSLIB will supply the sampled value."); 82 0 : break; 83 2 : case mfem::FiniteElementCollection::NORMAL: 84 2 : mooseWarning(typeAndName(), 85 : " found point ", 86 2 : _query_points[i], 87 : " on an element boundary. The H(div) finite element space has a continuous " 88 : "normal trace there, but the tangential component may differ between " 89 : "elements. The element selected by GSLIB will supply the sampled value."); 90 0 : break; 91 : } 92 : } 93 : 94 : #endif // MOOSE_MFEM_ENABLED