https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
23
25 const InputParameters & parameters, const std::vector<Point> & points)
26 : MFEMVariableSamplerBase(parameters, points),
27 _real_interp_vals(_var_names.size()),
28 _imag_interp_vals(_var_names.size())
29{
30 _vars.reserve(_var_names.size());
31 _declared_real_vals.reserve(_var_names.size());
32 _declared_imag_vals.reserve(_var_names.size());
33
34 for (const auto & var_name : _var_names)
35 {
36 auto & var = *getMFEMProblem().getComplexGridFunction(var_name);
37 _vars.push_back(var);
38
39 std::vector<std::reference_wrapper<VectorPostprocessorValue>> declared_real_vals;
40 std::vector<std::reference_wrapper<VectorPostprocessorValue>> declared_imag_vals;
41 const auto val_dim = var.VectorDim();
42 for (const auto i : make_range(val_dim))
43 {
44 auto & real_declared = this->declareVector(var_name + "_real_" + std::to_string(i));
45 real_declared.resize(points.size());
46 declared_real_vals.push_back(real_declared);
47
48 auto & imag_declared = this->declareVector(var_name + "_imag_" + std::to_string(i));
49 imag_declared.resize(points.size());
50 declared_imag_vals.push_back(imag_declared);
51 }
52 _declared_real_vals.push_back(declared_real_vals);
53 _declared_imag_vals.push_back(declared_imag_vals);
54 }
55}
56
57int
59{
60 return _vars[i_var].get().FESpace()->FEColl()->GetContType();
61}
62
63void
65{
66 for (size_t i_var : index_range(_vars))
67 {
68 _finder.Interpolate(_vars[i_var].get().real(), _real_interp_vals[i_var]);
69 _finder.Interpolate(_vars[i_var].get().imag(), _imag_interp_vals[i_var]);
70 }
71}
72
73void
75{
76 for (size_t i_var : index_range(_vars))
77 {
78 _real_interp_vals[i_var].HostReadWrite();
79 _imag_interp_vals[i_var].HostReadWrite();
80
81 const auto val_dims = _vars[i_var].get().VectorDim();
82 const auto num_points = _declared_points[0].get().size();
83 const auto val_fespace_ordering = _vars[i_var].get().FESpace()->GetOrdering();
84 for (const auto i_dim : make_range(val_dims))
85 for (const auto i_point : make_range(num_points))
86 {
87 const auto idx =
88 Moose::MFEM::MFEMIndex(i_dim, i_point, val_dims, num_points, val_fespace_ordering);
89 _declared_real_vals[i_var][i_dim].get()[i_point] = _real_interp_vals[i_var][idx];
90 _declared_imag_vals[i_var][i_dim].get()[i_point] = _imag_interp_vals[i_var][idx];
91 }
92 }
93}
94
95#endif // MOOSE_MFEM_ENABLED
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
std::vector< mfem::Vector > _real_interp_vals
Values interpolated from the real part of the grid function.
std::vector< std::reference_wrapper< const mfem::ParComplexGridFunction > > _vars
Complex grid function being sampled.
std::vector< std::vector< std::reference_wrapper< VectorPostprocessorValue > > > _declared_real_vals
VectorPostprocessor output columns for the real components.
MFEMComplexVariableValueSamplerBase(const InputParameters &parameters, const std::vector< Point > &points)
void execute() override
Interpolate the real and imaginary parts of the complex variable.
std::vector< std::vector< std::reference_wrapper< VectorPostprocessorValue > > > _declared_imag_vals
VectorPostprocessor output columns for the imaginary components.
int getFESpaceContinuityType(size_t i_var) const override
Return the continuity type of the i-th sampled variable's finite element collection.
void finalize() override
Copies interpolated values into the VPP vectors.
std::vector< mfem::Vector > _imag_interp_vals
Values interpolated from the imaginary part of the grid function.
MFEMProblem & getMFEMProblem()
Return the owning MFEM problem.
Definition MFEMObject.h:45
std::shared_ptr< mfem::ParComplexGridFunction > getComplexGridFunction(const std::string &name)
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 std::vector< VariableName > _var_names
Names of the variables being sampled.
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.