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 "MFEMComplexInnerProductAux.h" 13 : #include "MFEMProblem.h" 14 : 15 : registerMooseObject("MooseApp", MFEMComplexInnerProductAux); 16 : 17 : InputParameters 18 2102 : MFEMComplexInnerProductAux::validParams() 19 : { 20 2102 : InputParameters params = MFEMComplexAuxKernel::validParams(); 21 4204 : params.addClassDescription( 22 : "Projects $s \\vec u \\cdot \\vec v*$ onto a complex scalar MFEM auxvariable"); 23 8408 : MFEMExecutedObject::addRequiredDependencyParam<VariableName>( 24 : params, "first_source_vec", "Complex vector variable"); 25 8408 : MFEMExecutedObject::addRequiredDependencyParam<VariableName>( 26 : params, "second_source_vec", "Complex vector variable"); 27 8408 : params.addParam<mfem::real_t>("scale_factor_real", 1.0, "Real part of constant multiplier"); 28 6306 : params.addParam<mfem::real_t>("scale_factor_imag", 0.0, "Imaginary part of constant multiplier"); 29 : 30 2102 : return params; 31 0 : } 32 : 33 2 : MFEMComplexInnerProductAux::MFEMComplexInnerProductAux(const InputParameters & parameters) 34 : : MFEMComplexAuxKernel(parameters), 35 2 : _scale_factor(getParam<mfem::real_t>("scale_factor_real"), 36 4 : getParam<mfem::real_t>("scale_factor_imag")), 37 4 : _u_coef_real(getVectorCoefficientByName(getParam<VariableName>("first_source_vec") + "_real")), 38 4 : _u_coef_imag(getVectorCoefficientByName(getParam<VariableName>("first_source_vec") + "_imag")), 39 4 : _v_coef_real(getVectorCoefficientByName(getParam<VariableName>("second_source_vec") + "_real")), 40 4 : _v_coef_imag(getVectorCoefficientByName(getParam<VariableName>("second_source_vec") + "_imag")), 41 2 : _dot_ur_vr(_u_coef_real, _v_coef_real), 42 2 : _dot_ur_vi(_u_coef_real, _v_coef_imag), 43 2 : _dot_ui_vr(_u_coef_imag, _v_coef_real), 44 2 : _dot_ui_vi(_u_coef_imag, _v_coef_imag), 45 2 : _final_coef_real(_dot_ur_vr, _dot_ui_vi, 1.0, 1.0), // Accounting for hermitian conjugation 46 4 : _final_coef_imag(_dot_ur_vi, _dot_ui_vr, -1.0, 1.0) 47 : { 48 : // The target variable's finite element space 49 2 : mfem::ParFiniteElementSpace * fes = _result_var.ParFESpace(); 50 : 51 : // Must be scalar L2 52 2 : if (!dynamic_cast<const mfem::L2_FECollection *>(fes->FEColl()) || fes->GetVDim() != 1) 53 0 : mooseError("MFEMComplexInnerProductAux requires the target variable to be scalar L2."); 54 : 55 : // Must have no shared/constrained DOFs (pure interior DOFs) 56 2 : if (fes->GetTrueVSize() != fes->GetVSize()) 57 0 : mooseError("MFEMComplexInnerProductAux currently supports only L2 spaces with interior DOFs " 58 : "(no shared/constrained DOFs)."); 59 2 : } 60 : 61 : void 62 2 : MFEMComplexInnerProductAux::execute() 63 : { 64 2 : _result_var.ProjectCoefficient(_final_coef_real, _final_coef_imag); 65 : 66 2 : complexScale(_result_var, _scale_factor); 67 2 : } 68 : 69 : #endif // MOOSE_MFEM_ENABLED