https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMVariableLineValueSampler.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
21
22namespace
23{
24std::vector<Point>
25generateLinePoints(const Point & start_point,
26 const Point & end_point,
27 unsigned int num_points,
28 const std::string & object_name)
29{
30 if (num_points < 2)
31 mooseError("In MFEMVariableLineValueSampler \"",
32 object_name,
33 "\": line must have at least 2 points, "
34 "for single points use MFEMVariablePointValueSampler.");
35
36 // initialize and populate vector with linearly-spaced points along line
37 std::vector<Point> points;
38 points.reserve(num_points);
39 for (const auto i_point : make_range(num_points))
40 {
41 // fractional distance along line [0, 1]
42 Real t = static_cast<Real>(i_point) / static_cast<Real>(num_points - 1);
43 points.push_back(t * end_point + (1 - t) * start_point);
44 }
45
46 return points;
47}
48}
49
52{
54
55 params.addClassDescription("Sample an MFEM variable along a specified line.");
56
57 // these should not be of type libmesh::Point - need mfem::Point parsing
58 params.addRequiredParam<Point>("start_point", "The beginning of the line");
59 params.addRequiredParam<Point>("end_point", "The ending of the line");
60
61 params.addRequiredParam<unsigned int>("num_points",
62 "The number of points to sample along the line");
63
64 return params;
65}
66
69 // can't call getParam as that requires initialized base class
70 // so calling parameters.get directly
71 generateLinePoints(parameters.get<Point>("start_point"),
72 parameters.get<Point>("end_point"),
73 parameters.get<unsigned int>("num_points"),
74 parameters.getObjectName()))
75{
76}
77
78#endif // MOOSE_MFEM_ENABLED
registerMooseObject("MooseApp", MFEMVariableLineValueSampler)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
void ErrorVector unsigned int
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...
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.
MFEMVariableLineValueSampler(const InputParameters &parameters)
MFEM VectorPostprocessor base class for sampling a real-valued variable at a set of points.