LCOV - code coverage report
Current view: top level - src/materials - WaveEquationCoefficient.C (source / functions) Hit Total Coverage
Test: idaholab/moose electromagnetics: #31405 (292dce) with base fef103 Lines: 34 35 97.1 %
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 "WaveEquationCoefficient.h"
      11             : #include "ElectromagneticEnums.h"
      12             : #include <complex>
      13             : 
      14             : registerMooseObject("ElectromagneticsApp", WaveEquationCoefficient);
      15             : 
      16             : InputParameters
      17         798 : WaveEquationCoefficient::validParams()
      18             : {
      19         798 :   InputParameters params = ADMaterial::validParams();
      20         798 :   params.addClassDescription("Material for use as coefficient $a k^2 \\mu_r \\epsilon_r$ (where a "
      21             :                              "is a scalar coefficient) "
      22             :                              "in standard-form Helmholtz wave equation applications with "
      23             :                              "derivatives calculated using automatic differentiation.");
      24        1596 :   params.addRequiredParam<MaterialPropertyName>("eps_rel_real",
      25             :                                                 "Relative permittivity, real component.");
      26        1596 :   params.addRequiredParam<MaterialPropertyName>("eps_rel_imag",
      27             :                                                 "Relative permittivity, imaginary component.");
      28        1596 :   params.addRequiredParam<MaterialPropertyName>("mu_rel_real",
      29             :                                                 "Relative permeability, real component.");
      30        1596 :   params.addRequiredParam<MaterialPropertyName>("mu_rel_imag",
      31             :                                                 "Relative permeability, imaginary component.");
      32        1596 :   params.addRequiredParam<MaterialPropertyName>("k_real", "Wave number, real component.");
      33        1596 :   params.addParam<MaterialPropertyName>("k_imag", 0, "Wave number, imaginary component.");
      34        1596 :   params.addParam<Real>("coef", 1.0, "Real-valued function coefficient.");
      35        1596 :   params.addParam<MaterialPropertyName>(
      36             :       "prop_name_real",
      37             :       "wave_equation_coefficient_real",
      38             :       "User-specified material property name for the real component.");
      39        1596 :   params.addParam<MaterialPropertyName>(
      40             :       "prop_name_imaginary",
      41             :       "wave_equation_coefficient_imaginary",
      42             :       "User-specified material property name for the imaginary component.");
      43         798 :   return params;
      44           0 : }
      45             : 
      46         621 : WaveEquationCoefficient::WaveEquationCoefficient(const InputParameters & parameters)
      47             :   : ADMaterial(parameters),
      48         621 :     _eps_r_real(getADMaterialProperty<Real>("eps_rel_real")),
      49        1242 :     _eps_r_imag(getADMaterialProperty<Real>("eps_rel_imag")),
      50        1242 :     _mu_r_real(getADMaterialProperty<Real>("mu_rel_real")),
      51        1242 :     _mu_r_imag(getADMaterialProperty<Real>("mu_rel_imag")),
      52        1242 :     _k_real(getADMaterialProperty<Real>("k_real")),
      53        1242 :     _k_imag(getADMaterialProperty<Real>("k_imag")),
      54        1242 :     _coef(getParam<Real>("coef")),
      55        1242 :     _prop_name_real(getParam<MaterialPropertyName>("prop_name_real")),
      56        1242 :     _prop_name_imag(getParam<MaterialPropertyName>("prop_name_imaginary")),
      57         621 :     _prop_real(declareADProperty<Real>(_prop_name_real)),
      58        1242 :     _prop_imag(declareADProperty<Real>(_prop_name_imag))
      59             : {
      60         621 : }
      61             : 
      62             : void
      63      601534 : WaveEquationCoefficient::computeQpProperties()
      64             : {
      65     1203068 :   ADReal k_sq_real = (_k_real[_qp] * _k_real[_qp]) - (_k_imag[_qp] * _k_imag[_qp]);
      66      601534 :   ADReal k_sq_imag = 2.0 * _k_real[_qp] * _k_imag[_qp];
      67             : 
      68     1203068 :   ADReal mu_eps_real = (_mu_r_real[_qp] * _eps_r_real[_qp]) - (_mu_r_imag[_qp] * _eps_r_imag[_qp]);
      69     1804602 :   ADReal mu_eps_imag = (_mu_r_real[_qp] * _eps_r_imag[_qp]) + (_mu_r_imag[_qp] * _eps_r_real[_qp]);
      70             : 
      71     1203068 :   _prop_real[_qp] = _coef * ((k_sq_real * mu_eps_real) - (k_sq_imag * mu_eps_imag));
      72      601534 :   _prop_imag[_qp] = _coef * ((k_sq_real * mu_eps_imag) + (k_sq_imag * mu_eps_real));
      73      601534 : }

Generated by: LCOV version 1.14