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 "MFEMCrossProductAux.h" 13 : #include "MFEMProblem.h" 14 : #include "mfem.hpp" 15 : 16 : registerMooseObject("MooseApp", MFEMCrossProductAux); 17 : 18 : InputParameters 19 9366 : MFEMCrossProductAux::validParams() 20 : { 21 9366 : InputParameters params = MFEMAuxKernel::validParams(); 22 18732 : params.addClassDescription("Projects s(x) * (U x V) onto a vector MFEM auxvariable"); 23 37464 : params.addRequiredParam<VariableName>("first_source_vec", "Vector MFEMVariable U (vdim=3)"); 24 37464 : params.addRequiredParam<VariableName>("second_source_vec", "Vector MFEMVariable V (vdim=3)"); 25 18732 : params.addParam<mfem::real_t>( 26 18732 : "scale_factor", 1.0, "Constant multiplier applied to the cross product"); 27 9366 : return params; 28 0 : } 29 : 30 7 : MFEMCrossProductAux::MFEMCrossProductAux(const InputParameters & parameters) 31 : : MFEMAuxKernel(parameters), 32 7 : _u_var_name(getParam<VariableName>("first_source_vec")), 33 14 : _v_var_name(getParam<VariableName>("second_source_vec")), 34 7 : _u_var(*getMFEMProblem().getProblemData().gridfunctions.Get(_u_var_name)), 35 7 : _v_var(*getMFEMProblem().getProblemData().gridfunctions.Get(_v_var_name)), 36 14 : _scale_factor(getParam<mfem::real_t>("scale_factor")), 37 7 : _u_coef(&_u_var), 38 7 : _v_coef(&_v_var), 39 7 : _cross_uv(_u_coef, _v_coef), 40 7 : _scale_c(_scale_factor), 41 14 : _final_coef(_scale_c, _cross_uv) 42 : { 43 : // Check the target variable type and dimensions 44 7 : mfem::ParFiniteElementSpace * fes = _result_var.ParFESpace(); 45 7 : const int mesh_dim = fes->GetMesh()->Dimension(); 46 : 47 : // Enforce 3D cross product 48 7 : if (mesh_dim != 3) 49 0 : mooseError("MFEMCrossProductAux requires a 3D mesh (Dimension == 3)."); 50 : 51 7 : if (fes->GetVDim() != 3) 52 0 : mooseError("MFEMCrossProductAux requires AuxVariable to have vdim == 3."); 53 : 54 : // Must be L2 55 7 : if (!dynamic_cast<const mfem::L2_FECollection *>(fes->FEColl())) 56 0 : mooseError("MFEMCrossProductAux requires the target variable to use L2_FECollection."); 57 : 58 : // Must have no shared/constrained DOFs (pure interior DOFs) 59 7 : if (fes->GetTrueVSize() != fes->GetVSize()) 60 0 : mooseError("MFEMCrossProductAux currently supports only L2 spaces with interior DOFs " 61 : "(no shared/constrained DOFs)."); 62 7 : } 63 : 64 : void 65 7 : MFEMCrossProductAux::execute() 66 : { 67 : 68 : // MFEM element projection for L2 69 7 : _result_var = 0.0; 70 7 : _result_var.ProjectCoefficient(_final_coef); 71 7 : } 72 : 73 : #endif // MOOSE_MFEM_ENABLED