https://mooseframework.inl.gov
MFEMVariableSamplerBase.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 #ifdef MOOSE_MFEM_ENABLED
11 
13 
14 #include "MFEMProblem.h"
15 #include "MooseEnum.h"
16 #include "SubProblem.h"
17 
18 namespace
19 {
20 CreateMooseEnumClass(L2AverageType, NONE, ARITHMETIC, HARMONIC);
21 
22 mfem::ParMesh &
23 variableMesh(const InputParameters & parameters)
24 {
25  auto & problem =
26  static_cast<MFEMProblem &>(*parameters.getCheckedPointerParam<SubProblem *>("_subproblem"));
27  return const_cast<mfem::ParMesh &>(
28  problem.getMFEMVariableMesh(parameters.get<VariableName>("variable")));
29 }
30 }
31 
34 {
36  MFEMExecutedObject::addRequiredDependencyParam<VariableName>(
37  params, "variable", "The variable that this VectorPostprocessor samples");
38  MooseEnum avg_type(getL2AverageTypeOptions(), "ARITHMETIC", false);
39  params.addParam<MooseEnum>("side_interpolation_type",
40  avg_type,
41  "Average type used when sampling L2 functions at element boundaries.");
42  return params;
43 }
44 
46  const std::vector<Point> & points)
47  : MFEMSamplerBase(parameters, points, variableMesh(parameters)),
48  _var_name(getParam<VariableName>("variable"))
49 {
50  _finder.SetL2AvgType(static_cast<mfem::FindPointsGSLIB::AvgType>(
51  getParam<MooseEnum>("side_interpolation_type").getEnum<L2AverageType>()));
52 }
53 
54 void
56 {
58 
59  const auto continuity_type = getFESpaceContinuityType();
60  if (continuity_type == mfem::FiniteElementCollection::CONTINUOUS)
61  return;
62 
63  const auto & point_codes = _finder.GetCode();
64  for (const auto i : index_range(_query_points))
65  if (PointLocationCode(point_codes[i]) == PointLocationCode::BORDER)
66  switch (continuity_type)
67  {
68  case mfem::FiniteElementCollection::DISCONTINUOUS:
70  " found a point on an element boundary but the FE space is discontinuous at "
71  "element boundaries: ",
72  _query_points[i],
73  ".");
74  break;
75  case mfem::FiniteElementCollection::TANGENTIAL:
77  " found point ",
78  _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  break;
83  case mfem::FiniteElementCollection::NORMAL:
85  " found point ",
86  _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  break;
91  }
92 }
93 
94 #endif // MOOSE_MFEM_ENABLED
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
T getCheckedPointerParam(const std::string &name, const std::string &error_string="") const
Verifies that the requested parameter exists and is not NULL and returns it to the caller...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void initialSetup() override
Checks point locations and warns when sampled components may be discontinuous at boundaries.
void mooseWarning(Args &&... args) const
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:54
void initialSetup() override
Checks that all query points were found.
std::string typeAndName() const
Get the class&#39;s combined type and name; useful in error handling.
Definition: MooseBase.C:57
Abstract base class for sampling MFEM quantities at points.
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
mfem::FindPointsGSLIB _finder
GSLIB point finder used to locate and interpolate the query points.
PointLocationCode
Classification returned by GSLIB for a query point&#39;s location.
virtual int getFESpaceContinuityType() const =0
Return the continuity type of the sampled variable&#39;s finite element collection.
static InputParameters validParams()
CreateMooseEnumClass(Mortar3DSubpatchPlane, GEOMETRIC_NORMAL, AVERAGED_NODAL_NORMAL)
static InputParameters validParams()
const std::vector< Point > _query_points
Original query points used for point-location diagnostics.
MFEMVariableSamplerBase(const InputParameters &parameters, const std::vector< Point > &points)
auto index_range(const T &sizable)