LCOV - code coverage report
Current view: top level - src/kernels - ADMatWaveReaction.C (source / functions) Hit Total Coverage
Test: idaholab/moose electromagnetics: #31405 (292dce) with base fef103 Lines: 28 28 100.0 %
Date: 2025-09-04 07:52:56 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             : #include "ADMatWaveReaction.h"
      11             : #include "ElectromagneticEnums.h"
      12             : #include "ElectromagneticConstants.h"
      13             : #include "Function.h"
      14             : #include <complex>
      15             : 
      16             : registerMooseObject("ElectromagneticsApp", ADMatWaveReaction);
      17             : 
      18             : InputParameters
      19         668 : ADMatWaveReaction::validParams()
      20             : {
      21         668 :   InputParameters params = ADVectorKernel::validParams();
      22         668 :   params.addClassDescription(
      23             :       "Calculates the current source term in the Helmholtz wave equation using "
      24             :       "the dielectric formulation of the current.");
      25        1336 :   params.addRequiredCoupledVar("E_real", "The real component of the electric field.");
      26        1336 :   params.deprecateParam("E_real", "field_real", "10/01/2025");
      27        1336 :   params.addRequiredCoupledVar("field_real", "The real component of the electric field.");
      28        1336 :   params.addRequiredCoupledVar("E_imag", "The imaginary component of the electric field.");
      29        1336 :   params.deprecateParam("E_imag", "field_imag", "10/01/2025");
      30        1336 :   params.addRequiredCoupledVar("field_imag", "The imaginary component of the electric field.");
      31             : 
      32        1336 :   params.addParam<MaterialPropertyName>(
      33             :       "wave_coef_real",
      34             :       "wave_equation_coefficient_real",
      35             :       "The real component of the coefficient for the Helmholtz wave equation.");
      36        1336 :   params.addParam<MaterialPropertyName>(
      37             :       "wave_coef_imag",
      38             :       "wave_equation_coefficient_imaginary",
      39             :       "The imaginary component of the coefficient for the Helmholtz wave equation.");
      40             : 
      41        1336 :   MooseEnum component("real imaginary");
      42        1336 :   params.addParam<MooseEnum>("component", component, "Component of field (real or imaginary).");
      43         668 :   return params;
      44         668 : }
      45             : 
      46         352 : ADMatWaveReaction::ADMatWaveReaction(const InputParameters & parameters)
      47             :   : ADVectorKernel(parameters),
      48         352 :     _field_real(adCoupledVectorValue("field_real")),
      49         352 :     _field_imag(adCoupledVectorValue("field_imag")),
      50             : 
      51         704 :     _coef_real(getADMaterialProperty<Real>("wave_coef_real")),
      52         704 :     _coef_imag(getADMaterialProperty<Real>("wave_coef_imag")),
      53             : 
      54        1056 :     _component(getParam<MooseEnum>("component"))
      55             : {
      56         352 : }
      57             : 
      58             : ADReal
      59     3279672 : ADMatWaveReaction::computeQpResidual()
      60             : {
      61             :   // TODO: In the future, need to add an AD capability to std::complex
      62     3279672 :   if (_component == EM::REAL)
      63     1639836 :     return -_test[_i][_qp] *
      64     1639836 :            (_coef_real[_qp] * _field_real[_qp] - _coef_imag[_qp] * _field_imag[_qp]);
      65             :   else
      66     1639836 :     return -_test[_i][_qp] *
      67     1639836 :            (_coef_imag[_qp] * _field_real[_qp] + _coef_real[_qp] * _field_imag[_qp]);
      68             : }

Generated by: LCOV version 1.14