LCOV - code coverage report
Current view: top level - src/mfem/auxkernels - MFEMComplexDivAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 28 33 84.8 %
Date: 2026-05-29 20:35:17 Functions: 4 4 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 "MFEMComplexDivAux.h"
      13             : #include "MFEMProblem.h"
      14             : 
      15             : registerMooseObject("MooseApp", MFEMComplexDivAux);
      16             : 
      17             : InputParameters
      18        2102 : MFEMComplexDivAux::validParams()
      19             : {
      20        2102 :   InputParameters params = MFEMComplexAuxKernel::validParams();
      21        4204 :   params.addClassDescription("Calculates the divergence of a complex H(div) conforming RT source "
      22             :                              "variable and stores the result"
      23             :                              " on an L2 conforming result complex auxvariable");
      24        8408 :   MFEMExecutedObject::addRequiredDependencyParam<VariableName>(
      25             :       params, "source", "Vector H(div) MFEMComplexVariable to take the divergence of.");
      26        6306 :   params.addParam<mfem::real_t>(
      27        4204 :       "scale_factor_real", 1.0, "Real part of the factor to scale result auxvariable by.");
      28        4204 :   params.addParam<mfem::real_t>(
      29        4204 :       "scale_factor_imag", 0.0, "Imaginary part of the factor to scale result auxvariable by.");
      30             : 
      31        2102 :   return params;
      32           0 : }
      33             : 
      34           2 : MFEMComplexDivAux::MFEMComplexDivAux(const InputParameters & parameters)
      35             :   : MFEMComplexAuxKernel(parameters),
      36           2 :     _source_var_name(getParam<VariableName>("source")),
      37           2 :     _source_var(*getMFEMProblem().getComplexGridFunction(_source_var_name)),
      38           2 :     _scale_factor(getParam<mfem::real_t>("scale_factor_real"),
      39           6 :                   getParam<mfem::real_t>("scale_factor_imag")),
      40           4 :     _div(_source_var.ParFESpace(), _result_var.ParFESpace())
      41             : {
      42           2 :   _sequence = _source_var.GetSequence() + _result_var.GetSequence();
      43           2 :   _div.Assemble();
      44           2 :   _div.Finalize();
      45           2 : }
      46             : 
      47             : // Computes the auxvariable.
      48             : void
      49           2 : MFEMComplexDivAux::execute()
      50             : {
      51           2 :   update();
      52           2 :   _div.AddMult(_source_var.real(), _result_var.real() = 0);
      53           2 :   _div.AddMult(_source_var.imag(), _result_var.imag() = 0);
      54             : 
      55           2 :   complexScale(_result_var, _scale_factor);
      56           2 : }
      57             : 
      58             : void
      59           2 : MFEMComplexDivAux::update()
      60             : {
      61           2 :   if (long sequence = _source_var.GetSequence() + _result_var.GetSequence() > _sequence)
      62             :   {
      63           0 :     _sequence = sequence;
      64           0 :     _div.Update();
      65           0 :     _div.Assemble();
      66           0 :     _div.Finalize();
      67             :   }
      68           2 : }
      69             : 
      70             : #endif

Generated by: LCOV version 1.14