https://mooseframework.inl.gov
MFEMLineVariableValueSampler.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 "libmesh/point.h"
15 #include "MooseError.h"
16 #include "MFEMProblem.h"
17 
18 #include <vector>
19 
22  MFEMLineValueSampler,
23  "06/30/2027 24:00",
25 
26 namespace
27 {
28 std::vector<Point>
29 generateLinePoints(const Point & start_point,
30  const Point & end_point,
31  unsigned int num_points,
32  const std::string & object_name)
33 {
34  if (num_points < 2)
35  {
36  mooseError("In MFEMLineVariableValueSampler \"",
37  object_name,
38  "\": line must have at least 2 points, "
39  "for single points use MFEMPointVariableValueSampler.");
40  }
41 
42  // initialize and populate vector with linearly-spaced points along line
43  std::vector<Point> points;
44  points.reserve(num_points);
45  for (unsigned int i_point = 0; i_point < num_points; i_point++)
46  {
47  // fractional distance along line [0, 1]
48  Real t = static_cast<Real>(i_point) / static_cast<Real>(num_points - 1);
49  points.push_back(t * end_point + (1 - t) * start_point);
50  }
51 
52  return points;
53 }
54 }
55 
58 {
60 
61  params.addClassDescription("Sample an MFEM variable along a specified line.");
62 
63  // these should not be of type libmesh::Point - need mfem::Point parsing
64  params.addRequiredParam<Point>("start_point", "The beginning of the line");
65  params.addRequiredParam<Point>("end_point", "The ending of the line");
66 
67  params.addRequiredParam<unsigned int>("num_points",
68  "The number of points to sample along the line");
69 
70  return params;
71 }
72 
74  : MFEMVariableValueSamplerBase(parameters,
75  // can't call getParam as that requires initialized base class
76  // so calling parameters.get directly
77  generateLinePoints(parameters.get<Point>("start_point"),
78  parameters.get<Point>("end_point"),
79  parameters.get<unsigned int>("num_points"),
80  parameters.getObjectName()))
81 {
82 }
83 
84 #endif // MOOSE_MFEM_ENABLED
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
MFEM VectorPostprocessor base class for sampling a real-valued variable at a set of points...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
registerMooseObject("MooseApp", MFEMLineVariableValueSampler)
MFEMLineVariableValueSampler(const InputParameters &parameters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObjectRenamed("MooseApp", MFEMLineValueSampler, "06/30/2027 24:00", MFEMLineVariableValueSampler)
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void ErrorVector unsigned int
const Elem & get(const ElemType type_in)