LCOV - code coverage report
Current view: top level - src/mfem/auxkernels - MFEMComplexAuxKernel.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 22 26 84.6 %
Date: 2026-05-29 20:35:17 Functions: 4 5 80.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 "MFEMComplexAuxKernel.h"
      13             : #include "MFEMProblem.h"
      14             : 
      15             : InputParameters
      16       16820 : MFEMComplexAuxKernel::validParams()
      17             : {
      18       16820 :   InputParameters params = MFEMExecutedObject::validParams();
      19       33640 :   params.registerBase("AuxKernel");
      20       33640 :   params.addClassDescription("Base class for MFEM objects that update auxiliary variables outside "
      21             :                              "of the main solve step.");
      22       50460 :   params.addRequiredParam<AuxVariableName>("variable",
      23             :                                            "The name of the variable that this object applies to");
      24       16820 :   return params;
      25           0 : }
      26             : 
      27          20 : MFEMComplexAuxKernel::MFEMComplexAuxKernel(const InputParameters & parameters)
      28             :   : MFEMExecutedObject(parameters),
      29          20 :     _result_var_name(getParam<AuxVariableName>("variable")),
      30          40 :     _result_var(*getMFEMProblem().getComplexGridFunction(_result_var_name))
      31             : {
      32          20 : }
      33             : 
      34             : std::optional<std::string>
      35           0 : MFEMComplexAuxKernel::suppliedVariableName() const
      36             : {
      37           0 :   return _result_var_name;
      38             : }
      39             : 
      40             : void
      41          16 : MFEMComplexAuxKernel::complexAdd(mfem::ParComplexGridFunction & a,
      42             :                                  const mfem::ParComplexGridFunction & b,
      43             :                                  const std::complex<mfem::real_t> scale)
      44             : {
      45             :   // a += scale * b
      46             : 
      47             :   // check that the parfespaces match
      48          16 :   if (a.ParFESpace() != b.ParFESpace())
      49           0 :     mooseError("MFEMComplexAuxKernel::complexAdd: ParFESpaces of input variables do not match.");
      50             : 
      51          16 :   a.real().Add(scale.real(), b.real());
      52          16 :   a.real().Add(-scale.imag(), b.imag());
      53          16 :   a.imag().Add(scale.imag(), b.real());
      54          16 :   a.imag().Add(scale.real(), b.imag());
      55          16 : }
      56             : 
      57             : void
      58          10 : MFEMComplexAuxKernel::complexScale(mfem::ParComplexGridFunction & a,
      59             :                                    const std::complex<mfem::real_t> scale)
      60             : {
      61             :   // a *= scale
      62             : 
      63          10 :   mfem::ParComplexGridFunction b(a.ParFESpace());
      64          10 :   static_cast<mfem::Vector &>(b) = a;
      65             : 
      66          10 :   complexAdd(a, b, scale - 1);
      67          10 : }
      68             : 
      69             : #endif

Generated by: LCOV version 1.14