LCOV - code coverage report
Current view: top level - src/mfem/auxkernels - MFEMComplexExteriorProductAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 29 32 90.6 %
Date: 2026-05-29 20:35:17 Functions: 3 3 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 "MFEMComplexExteriorProductAux.h"
      13             : #include "MFEMProblem.h"
      14             : 
      15             : registerMooseObject("MooseApp", MFEMComplexExteriorProductAux);
      16             : 
      17             : InputParameters
      18        2102 : MFEMComplexExteriorProductAux::validParams()
      19             : {
      20        2102 :   InputParameters params = MFEMComplexAuxKernel::validParams();
      21        4204 :   params.addClassDescription(
      22             :       "Projects $s \\vec u \\wedge \\vec v*$ onto a complex vector MFEM auxvariable");
      23        8408 :   MFEMExecutedObject::addRequiredDependencyParam<VariableName>(
      24             :       params, "first_source_vec", "Complex vector variable (3D)");
      25        8408 :   MFEMExecutedObject::addRequiredDependencyParam<VariableName>(
      26             :       params, "second_source_vec", "Complex vector variable (3D)");
      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 : MFEMComplexExteriorProductAux::MFEMComplexExteriorProductAux(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 :     _cross_ur_vr(_u_coef_real, _v_coef_real),
      42           2 :     _cross_ur_vi(_u_coef_real, _v_coef_imag),
      43           2 :     _cross_ui_vr(_u_coef_imag, _v_coef_real),
      44           2 :     _cross_ui_vi(_u_coef_imag, _v_coef_imag),
      45           2 :     _final_coef_real(_cross_ur_vr, _cross_ui_vi, 1.0, 1.0), // Accounting for hermitian conjugation
      46           4 :     _final_coef_imag(_cross_ur_vi, _cross_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 [L2]^3
      52           2 :   if (!dynamic_cast<const mfem::L2_FECollection *>(fes->FEColl()) || fes->GetVDim() != 3)
      53           0 :     mooseError("MFEMComplexExteriorProductAux requires the target variable to be vector [L2]^3.");
      54             : 
      55             :   // Must have no shared/constrained DOFs (pure interior DOFs)
      56           2 :   if (fes->GetTrueVSize() != fes->GetVSize())
      57           0 :     mooseError("MFEMComplexExteriorProductAux currently supports only L2 spaces with interior DOFs "
      58             :                "(no shared/constrained DOFs).");
      59           2 : }
      60             : 
      61             : void
      62           2 : MFEMComplexExteriorProductAux::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

Generated by: LCOV version 1.14