https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMVariableValueSamplerBase.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 "MFEMVectorUtils.h"
16#include "MooseError.h"
17
18#include "mfem/fem/fespace.hpp"
19
25
27 const std::vector<Point> & points)
28 : MFEMVariableSamplerBase(parameters, points),
29 _var(*getMFEMProblem().getGridFunction(_var_name)),
30 _interp_vals(points.size())
31{
32 // declare value vectors for outputting
33 const auto val_dim = _var.VectorDim();
34 for (const auto i : make_range(val_dim))
35 {
36 auto & declared = this->declareVector(_var_name + "_" + std::to_string(i));
37 declared.resize(points.size());
38 _declared_vals.push_back(declared);
39 }
40}
41
42int
44{
45 return _var.FESpace()->FEColl()->GetContType();
46}
47
48void
53
54void
56{
57 _interp_vals.HostReadWrite();
58
59 const auto val_dims = _var.VectorDim();
60 const auto num_points = _declared_points[0].get().size();
61 const auto val_fespace_ordering = _var.FESpace()->GetOrdering();
62 for (const auto i_dim : make_range(val_dims))
63 for (const auto i_point : make_range(num_points))
64 {
65 const auto mfem_idx =
66 Moose::MFEM::MFEMIndex(i_dim, i_point, val_dims, num_points, val_fespace_ordering);
67 _declared_vals[i_dim].get()[i_point] = _interp_vals[mfem_idx];
68 }
69}
70
71#endif // MOOSE_MFEM_ENABLED
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
mfem::FindPointsGSLIB _finder
GSLIB point finder used to locate and interpolate the query points.
std::vector< std::reference_wrapper< VectorPostprocessorValue > > _declared_points
Declared VPP output vectors for spatial coordinates ("x_0", "x_1", ...).
Base class for sampling real or complex MFEM variables at points.
static InputParameters validParams()
const VariableName _var_name
Name of the variable being sampled.
int getFESpaceContinuityType() const override
Return the continuity type of the sampled variable's finite element collection.
void execute() override
Interpolate the real variable at all query points.
mfem::Vector _interp_vals
Values interpolated from the grid function.
const mfem::GridFunction & _var
Grid function being sampled.
std::vector< std::reference_wrapper< VectorPostprocessorValue > > _declared_vals
VectorPostprocessor output columns for the variable components.
MFEMVariableValueSamplerBase(const InputParameters &parameters, const std::vector< Point > &points)
void finalizeValues() override
Copies interpolated values into the subclass VPP vectors.
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.
std::size_t MFEMIndex(const std::size_t i_dim, const std::size_t i_point, const std::size_t num_dims, const std::size_t num_points, const mfem::Ordering::Type ordering)
Convert an index of a vector of libMesh::Points to an MFEM vector index, given an MFEM ordering.