https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
18namespace
19{
20CreateMooseEnumClass(L2AverageType, NONE, ARITHMETIC, HARMONIC);
21
22mfem::ParMesh &
23variableMesh(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");
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
54void
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: ",
73 ".");
74 break;
75 case mfem::FiniteElementCollection::TANGENTIAL:
77 " found point ",
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 ",
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
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition MooseError.h:345
CreateMooseEnumClass(Mortar3DSubpatchPlane, GEOMETRIC_NORMAL, AVERAGED_NODAL_NORMAL)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
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.
Abstract base class for sampling MFEM quantities at points.
mfem::FindPointsGSLIB _finder
GSLIB point finder used to locate and interpolate the query points.
static InputParameters validParams()
PointLocationCode
Classification returned by GSLIB for a query point's location.
const std::vector< Point > _query_points
Original query points used for point-location diagnostics.
void initialSetup() override
Checks that all query points were found.
virtual int getFESpaceContinuityType() const =0
Return the continuity type of the sampled variable's finite element collection.
static InputParameters validParams()
void initialSetup() override
Checks point locations and warns when sampled components may be discontinuous at boundaries.
MFEMVariableSamplerBase(const InputParameters &parameters, const std::vector< Point > &points)
std::string typeAndName() const
Get the class's combined type and name; useful in error handling.
Definition MooseBase.C:57
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79