LCOV - code coverage report
Current view: top level - src/mfem/vectorpostprocessors - MFEMComplexVariableValueSamplerBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 329044 Lines: 34 34 100.0 %
Date: 2026-08-03 21:12:22 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      12             : #include "MFEMComplexVariableValueSamplerBase.h"
      13             : #include "MFEMProblem.h"
      14             : #include "MFEMVectorUtils.h"
      15             : 
      16             : #include "mfem/fem/fespace.hpp"
      17             : 
      18             : InputParameters
      19        2154 : MFEMComplexVariableValueSamplerBase::validParams()
      20             : {
      21        2154 :   return MFEMVariableSamplerBase::validParams();
      22             : }
      23             : 
      24          12 : MFEMComplexVariableValueSamplerBase::MFEMComplexVariableValueSamplerBase(
      25          12 :     const InputParameters & parameters, const std::vector<Point> & points)
      26             :   : MFEMVariableSamplerBase(parameters, points),
      27          12 :     _var(*getMFEMProblem().getComplexGridFunction(_var_name)),
      28          12 :     _real_interp_vals(points.size()),
      29          24 :     _imag_interp_vals(points.size())
      30             : {
      31          12 :   const auto val_dim = _var.real().VectorDim();
      32          24 :   for (const auto i : make_range(val_dim))
      33             :   {
      34          12 :     auto & real_declared = this->declareVector(_var_name + "_real_" + std::to_string(i));
      35          12 :     real_declared.resize(points.size());
      36          12 :     _declared_real_vals.push_back(real_declared);
      37             : 
      38          12 :     auto & imag_declared = this->declareVector(_var_name + "_imag_" + std::to_string(i));
      39          12 :     imag_declared.resize(points.size());
      40          12 :     _declared_imag_vals.push_back(imag_declared);
      41             :   }
      42          12 : }
      43             : 
      44             : int
      45          10 : MFEMComplexVariableValueSamplerBase::getFESpaceContinuityType() const
      46             : {
      47          10 :   return _var.real().FESpace()->FEColl()->GetContType();
      48             : }
      49             : 
      50             : void
      51          14 : MFEMComplexVariableValueSamplerBase::execute()
      52             : {
      53          14 :   _finder.Interpolate(_var.real(), _real_interp_vals);
      54          14 :   _finder.Interpolate(_var.imag(), _imag_interp_vals);
      55          14 : }
      56             : 
      57             : void
      58          14 : MFEMComplexVariableValueSamplerBase::finalizeValues()
      59             : {
      60          14 :   _real_interp_vals.HostReadWrite();
      61          14 :   _imag_interp_vals.HostReadWrite();
      62             : 
      63          14 :   const auto val_dims = _var.real().VectorDim();
      64          14 :   const auto num_points = _declared_points[0].get().size();
      65          14 :   const auto val_fespace_ordering = _var.real().FESpace()->GetOrdering();
      66          28 :   for (const auto i_dim : index_range(_declared_real_vals))
      67          28 :     for (const auto i_point : make_range(num_points))
      68             :     {
      69             :       const auto idx =
      70          14 :           Moose::MFEM::MFEMIndex(i_dim, i_point, val_dims, num_points, val_fespace_ordering);
      71          14 :       _declared_real_vals[i_dim].get()[i_point] = _real_interp_vals[idx];
      72          14 :       _declared_imag_vals[i_dim].get()[i_point] = _imag_interp_vals[idx];
      73             :     }
      74          14 : }
      75             : 
      76             : #endif // MOOSE_MFEM_ENABLED

Generated by: LCOV version 1.14