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 "MFEMComplexVectorPeriodAveragedPostprocessor.h" 13 : #include "MFEMProblem.h" 14 : 15 : registerMooseObject("MooseApp", MFEMComplexVectorPeriodAveragedPostprocessor); 16 : 17 : InputParameters 18 2110 : MFEMComplexVectorPeriodAveragedPostprocessor::validParams() 19 : { 20 2110 : InputParameters params = MFEMPostprocessor::validParams(); 21 2110 : params += MFEMBlockRestrictable::validParams(); 22 4220 : params.addClassDescription("Calculates the time average of the inner product between two " 23 : "complex MFEM vector FE variables, scaled by an optional scalar " 24 : "coefficient."); 25 8440 : params.addParam<MFEMScalarCoefficientName>( 26 : "coefficient", "1.", "Name of optional scalar coefficient to scale integrand by."); 27 8440 : MFEMExecutedObject::addRequiredDependencyParam<VariableName>( 28 : params, "primal_variable", "Name of the first complex vector variable in the inner product."); 29 6330 : MFEMExecutedObject::addRequiredDependencyParam<VariableName>( 30 : params, "dual_variable", "Name of the second complex vector variable in the inner product."); 31 2110 : return params; 32 0 : } 33 : 34 6 : MFEMComplexVectorPeriodAveragedPostprocessor::MFEMComplexVectorPeriodAveragedPostprocessor( 35 6 : const InputParameters & parameters) 36 : : MFEMPostprocessor(parameters), 37 : MFEMBlockRestrictable( 38 : parameters, 39 18 : getMFEMProblem().getMFEMVariableMesh(getParam<VariableName>("primal_variable"))), 40 12 : _l2_fec(getMFEMProblem() 41 18 : .getComplexGridFunction(getParam<VariableName>("primal_variable")) 42 6 : ->ParFESpace() 43 6 : ->GetMaxElementOrder(), 44 6 : getMesh().Dimension()), 45 6 : _scalar_test_fespace(const_cast<mfem::ParMesh *>(&getMesh()), &_l2_fec), 46 6 : _scalar_var(&_scalar_test_fespace), 47 12 : _scalar_coef(getScalarCoefficient("coefficient")), 48 6 : _primal_var_real_coef( 49 12 : getVectorCoefficientByName(getParam<VariableName>("primal_variable") + "_real")), 50 6 : _primal_var_imag_coef( 51 12 : getVectorCoefficientByName(getParam<VariableName>("primal_variable") + "_imag")), 52 6 : _dual_var_real_coef( 53 12 : getVectorCoefficientByName(getParam<VariableName>("dual_variable") + "_real")), 54 6 : _dual_var_imag_coef( 55 12 : getVectorCoefficientByName(getParam<VariableName>("dual_variable") + "_imag")), 56 6 : _real_inner_product_coef(_primal_var_real_coef, _dual_var_real_coef), 57 6 : _imag_inner_product_coef(_primal_var_imag_coef, _dual_var_imag_coef), 58 6 : _sum_coef(_real_inner_product_coef, _imag_inner_product_coef, 0.5, 0.5), 59 24 : _subdomain_integrator(&_scalar_test_fespace) 60 : { 61 6 : if (isSubdomainRestricted()) 62 6 : _subdomain_integrator.AddDomainIntegrator(new mfem::DomainLFIntegrator(_sum_coef), 63 : getSubdomainMarkers()); 64 : else 65 0 : _subdomain_integrator.AddDomainIntegrator(new mfem::DomainLFIntegrator(_sum_coef)); 66 6 : } 67 : 68 : void 69 6 : MFEMComplexVectorPeriodAveragedPostprocessor::execute() 70 : { 71 6 : _scalar_var.ProjectCoefficient(_scalar_coef); 72 6 : _subdomain_integrator.Assemble(); 73 6 : _integral = _subdomain_integrator(_scalar_var); 74 6 : } 75 : 76 : PostprocessorValue 77 6 : MFEMComplexVectorPeriodAveragedPostprocessor::getValue() const 78 : { 79 6 : return _integral; 80 : } 81 : 82 : #endif