https://mooseframework.inl.gov
MFEMComplexVariableValueSamplerBase.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 #include "MFEMProblem.h"
14 #include "MFEMVectorUtils.h"
15 
16 #include "mfem/fem/fespace.hpp"
17 
20 {
22 }
23 
25  const InputParameters & parameters, const std::vector<Point> & points)
26  : MFEMVariableSamplerBase(parameters, points),
27  _var(*getMFEMProblem().getComplexGridFunction(_var_name)),
28  _real_interp_vals(points.size()),
29  _imag_interp_vals(points.size())
30 {
31  const auto val_dim = _var.real().VectorDim();
32  for (const auto i : make_range(val_dim))
33  {
34  auto & real_declared = this->declareVector(_var_name + "_real_" + std::to_string(i));
35  real_declared.resize(points.size());
36  _declared_real_vals.push_back(real_declared);
37 
38  auto & imag_declared = this->declareVector(_var_name + "_imag_" + std::to_string(i));
39  imag_declared.resize(points.size());
40  _declared_imag_vals.push_back(imag_declared);
41  }
42 }
43 
44 int
46 {
47  return _var.real().FESpace()->FEColl()->GetContType();
48 }
49 
50 void
52 {
53  _finder.Interpolate(_var.real(), _real_interp_vals);
54  _finder.Interpolate(_var.imag(), _imag_interp_vals);
55 }
56 
57 void
59 {
60  _real_interp_vals.HostReadWrite();
61  _imag_interp_vals.HostReadWrite();
62 
63  const auto val_dims = _var.real().VectorDim();
64  const auto num_points = _declared_points[0].get().size();
65  const auto val_fespace_ordering = _var.real().FESpace()->GetOrdering();
66  for (const auto i_dim : index_range(_declared_real_vals))
67  for (const auto i_point : make_range(num_points))
68  {
69  const auto idx =
70  Moose::MFEM::MFEMIndex(i_dim, i_point, val_dims, num_points, val_fespace_ordering);
71  _declared_real_vals[i_dim].get()[i_point] = _real_interp_vals[idx];
72  _declared_imag_vals[i_dim].get()[i_point] = _imag_interp_vals[idx];
73  }
74 }
75 
76 #endif // MOOSE_MFEM_ENABLED
mfem::Vector _imag_interp_vals
Values interpolated from the imaginary part of the grid function.
MFEMComplexVariableValueSamplerBase(const InputParameters &parameters, const std::vector< Point > &points)
std::vector< std::reference_wrapper< VectorPostprocessorValue > > _declared_imag_vals
VectorPostprocessor output columns for the imaginary components.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::vector< std::reference_wrapper< VectorPostprocessorValue > > _declared_real_vals
VectorPostprocessor output columns for the real components.
Base class for sampling real or complex MFEM variables at points.
void execute() override
Interpolate the real and imaginary parts of the complex variable.
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.
const mfem::ParComplexGridFunction & _var
Complex grid function being sampled.
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...
int getFESpaceContinuityType() const override
Return the continuity type of the sampled variable&#39;s finite element collection.
mfem::Vector _real_interp_vals
Values interpolated from the real part of the grid function.
std::vector< std::reference_wrapper< VectorPostprocessorValue > > _declared_points
Declared VPP output vectors for spatial coordinates ("x_0", "x_1", ...).
mfem::FindPointsGSLIB _finder
GSLIB point finder used to locate and interpolate the query points.
IntRange< T > make_range(T beg, T end)
static InputParameters validParams()
auto index_range(const T &sizable)
void finalizeValues() override
Copies interpolated values into the subclass VPP vectors.
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
const VariableName _var_name
Name of the variable being sampled.