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 "MFEMVariableValueSamplerBase.h" 13 : 14 : #include "MFEMProblem.h" 15 : #include "MFEMVectorUtils.h" 16 : #include "MooseError.h" 17 : 18 : #include "mfem/fem/fespace.hpp" 19 : 20 : InputParameters 21 9288 : MFEMVariableValueSamplerBase::validParams() 22 : { 23 9288 : return MFEMVariableSamplerBase::validParams(); 24 : } 25 : 26 383 : MFEMVariableValueSamplerBase::MFEMVariableValueSamplerBase(const InputParameters & parameters, 27 383 : const std::vector<Point> & points) 28 : : MFEMVariableSamplerBase(parameters, points), 29 383 : _var(*getMFEMProblem().getGridFunction(_var_name)), 30 766 : _interp_vals(points.size()) 31 : { 32 : // declare value vectors for outputting 33 383 : const auto val_dim = _var.VectorDim(); 34 838 : for (const auto i : make_range(val_dim)) 35 : { 36 455 : auto & declared = this->declareVector(_var_name + "_" + std::to_string(i)); 37 455 : declared.resize(points.size()); 38 455 : _declared_vals.push_back(declared); 39 : } 40 383 : } 41 : 42 : int 43 379 : MFEMVariableValueSamplerBase::getFESpaceContinuityType() const 44 : { 45 379 : return _var.FESpace()->FEColl()->GetContType(); 46 : } 47 : 48 : void 49 1035 : MFEMVariableValueSamplerBase::execute() 50 : { 51 1035 : _finder.Interpolate(_var, _interp_vals); 52 1035 : } 53 : 54 : void 55 1035 : MFEMVariableValueSamplerBase::finalizeValues() 56 : { 57 1035 : _interp_vals.HostReadWrite(); 58 : 59 1035 : const auto val_dims = _var.VectorDim(); 60 1035 : const auto num_points = _declared_points[0].get().size(); 61 1035 : const auto val_fespace_ordering = _var.FESpace()->GetOrdering(); 62 2134 : for (const auto i_dim : make_range(val_dims)) 63 5815 : for (const auto i_point : make_range(num_points)) 64 : { 65 : const auto mfem_idx = 66 4716 : Moose::MFEM::MFEMIndex(i_dim, i_point, val_dims, num_points, val_fespace_ordering); 67 4716 : _declared_vals[i_dim].get()[i_point] = _interp_vals[mfem_idx]; 68 : } 69 1035 : } 70 : 71 : #endif // MOOSE_MFEM_ENABLED