Skip to content

Commit

Permalink
Transition to elk::REAL in if statement comparisons and correct error…
Browse files Browse the repository at this point in the history
…s in MooseEnum declarations causing test failures with the new comparisons.

Refs idaholab#10
  • Loading branch information
cticenhour committed Nov 8, 2021
1 parent 04d0ffb commit 9641c21
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 23 deletions.
5 changes: 3 additions & 2 deletions modules/electromagnetics/src/bcs/AbsorbingBC.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "AbsorbingBC.h"
#include "ElkEnums.h"
#include "Function.h"
#include <complex>

Expand All @@ -12,7 +13,7 @@ validParams<AbsorbingBC>()

params.addRequiredCoupledVar("field_real", "Real component of field.");
params.addRequiredCoupledVar("field_imaginary", "Imaginary component of field.");
MooseEnum component("imaginary real", "real");
MooseEnum component("real imaginary");
params.addParam<MooseEnum>("component", component, "Real or Imaginary wave component.");
params.addParam<FunctionName>("func_real", 1.0, "Function coefficient, real component.");
params.addParam<FunctionName>("func_imag", 0.0, "Function coefficient, imaginary component.");
Expand Down Expand Up @@ -48,7 +49,7 @@ AbsorbingBC::computeQpResidual()

std::complex<double> _val = -_j * _coeff * _func * _field;

if (_component == "real")
if (_component == elk::REAL)
{
return _sign * _test[_i][_qp] * _val.real();
}
Expand Down
5 changes: 3 additions & 2 deletions modules/electromagnetics/src/bcs/PortBC.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "PortBC.h"
#include "ElkEnums.h"
#include "Function.h"
#include <complex>

Expand All @@ -12,7 +13,7 @@ validParams<PortBC>()

params.addRequiredCoupledVar("field_real", "Real component of field.");
params.addRequiredCoupledVar("field_imaginary", "Imaginary component of field.");
MooseEnum component("imaginary real", "real");
MooseEnum component("real imaginary");
params.addParam<MooseEnum>("component", component, "Real or Imaginary wave component.");
params.addParam<FunctionName>("func_real", 1.0, "Function coefficient, real component.");
params.addParam<FunctionName>("func_imag", 0.0, "Function coefficient, imaginary component.");
Expand Down Expand Up @@ -58,7 +59,7 @@ PortBC::computeQpResidual()
std::complex<double> _LHS = _common * _field;
std::complex<double> _diff = _RHS - _LHS;

if (_component == "real")
if (_component == elk::REAL)
{
return _sign * _test[_i][_qp] * _diff.real();
}
Expand Down
5 changes: 3 additions & 2 deletions modules/electromagnetics/src/bcs/ReflectionBC.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "ReflectionBC.h"
#include "ElkEnums.h"
#include "Function.h"
#include <complex>

Expand All @@ -12,7 +13,7 @@ validParams<ReflectionBC>()

params.addRequiredCoupledVar("field_real", "Real component of field.");
params.addRequiredCoupledVar("field_imaginary", "Imaginary component of field.");
MooseEnum component("imaginary real", "real");
MooseEnum component("real imaginary");
params.addParam<MooseEnum>("component", component, "Real or Imaginary wave component.");
params.addParam<FunctionName>("func_real", 1.0, "Function coefficient, real component.");
params.addParam<FunctionName>("func_imag", 0.0, "Function coefficient, imaginary component.");
Expand Down Expand Up @@ -54,7 +55,7 @@ ReflectionBC::computeQpResidual()
std::complex<double> _LHS = _common * _field;
std::complex<double> _diff = _RHS - _LHS;

if (_component == "real")
if (_component == elk::REAL)
{
return _sign * _test[_i][_qp] * _diff.real();
}
Expand Down
9 changes: 5 additions & 4 deletions modules/electromagnetics/src/bcs/VectorPortBC.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "VectorPortBC.h"
#include "ElkEnums.h"
#include <complex>

registerMooseObject("ElkApp", VectorPortBC);
Expand Down Expand Up @@ -49,7 +50,7 @@ VectorPortBC::computeQpResidual()
std::complex<double> E2(0, 0);

// Create E and ncrossE for residual based on component parameter
if (_component == "real")
if (_component == elk::REAL)
{
E0.real(_u[_qp](0));
E0.imag(_coupled_val[_qp](0));
Expand Down Expand Up @@ -102,7 +103,7 @@ VectorPortBC::computeQpResidual()

std::complex<double> res = U_inc_dot_test - P_dot_test;

if (_component == "real")
if (_component == elk::REAL)
{
return res.real();
}
Expand All @@ -124,11 +125,11 @@ VectorPortBC::computeQpOffDiagJacobian(unsigned int jvar)
Real off_diag_jac = _beta.value(_t, _q_point[_qp]) * _test[_i][_qp].cross(_normals[_qp]) *
_normals[_qp].cross(_phi[_j][_qp]);

if (_component == "real" && jvar == _coupled_id)
if (_component == elk::REAL && jvar == _coupled_id)
{
return off_diag_jac;
}
else if (_component == "imaginary" && jvar == _coupled_id)
else if (_component == elk::IMAGINARY && jvar == _coupled_id)
{
return -off_diag_jac;
}
Expand Down
5 changes: 3 additions & 2 deletions modules/electromagnetics/src/functions/HelmholtzTestFunc.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "HelmholtzTestFunc.h"
#include "ElkEnums.h"
#include <complex>

registerMooseObject("ElkApp", HelmholtzTestFunc);
Expand All @@ -21,7 +22,7 @@ validParams<HelmholtzTestFunc>()
params.addRequiredParam<Real>("g0_imag", "Imaginary component of DirichletBC where x = 0.");
params.addRequiredParam<Real>("gL_real", "Real component of DirichletBC where x = L.");
params.addRequiredParam<Real>("gL_imag", "Imaginary component of DirichletBC where x = L.");
MooseEnum component("imaginary real", "real");
MooseEnum component("real imaginary");
params.addParam<MooseEnum>("component", component, "Real or Imaginary wave component.");
return params;
}
Expand Down Expand Up @@ -66,7 +67,7 @@ HelmholtzTestFunc::value(Real t, const Point & p)

val = _C1 * std::cos(_lambda * p(0)) + _C2 * std::sin(_lambda * p(0));

if (_component == "real")
if (_component == elk::REAL)
{
return val.real();
}
Expand Down
5 changes: 3 additions & 2 deletions modules/electromagnetics/src/functions/JinSlabCoeffFunc.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "JinSlabCoeffFunc.h"
#include "ElkEnums.h"
#include <complex>

registerMooseObject("ElkApp", JinSlabCoeffFunc);
Expand All @@ -14,7 +15,7 @@ validParams<JinSlabCoeffFunc>()
params.addParam<Real>("muR_imag", 0.0, "Relative permeability, imaginary component");
params.addRequiredParam<Real>("k", "Wave Number");
params.addRequiredParam<Real>("theta", "Wave Incidence angle, in degrees");
MooseEnum component("imaginary real", "real");
MooseEnum component("real imaginary");
params.addParam<MooseEnum>("component", component, "Real or Imaginary wave component");
return params;
}
Expand Down Expand Up @@ -46,7 +47,7 @@ JinSlabCoeffFunc::value(Real t, const Point & p)
std::complex<double> _val =
_k * std::sqrt(_epsR * _muR - std::pow(std::sin(_theta * libMesh::pi / 180.), 2));

if (_component == "real")
if (_component == elk::REAL)
{
return _val.real();
}
Expand Down
5 changes: 3 additions & 2 deletions modules/electromagnetics/src/functions/RobinTestFunc.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "RobinTestFunc.h"
#include "ElkEnums.h"
#include <complex>

registerMooseObject("ElkApp", RobinTestFunc);
Expand All @@ -18,7 +19,7 @@ validParams<RobinTestFunc>()
params.addRequiredParam<Real>("g0_real", "Real component of DirichletBC where x = 0.");
params.addRequiredParam<Real>("g0_imag", "Imaginary component of DirichletBC where x = 0.");
params.addParam<FunctionName>("func", "Function coefficient.");
MooseEnum component("imaginary real", "real");
MooseEnum component("real imaginary");
params.addParam<MooseEnum>("component", component, "Real or Imaginary wave component.");
return params;
}
Expand Down Expand Up @@ -59,7 +60,7 @@ RobinTestFunc::value(Real t, const Point & p)

val = _C1 * std::cos(_c * _x) + _C2 * std::sin(_c * _x);

if (_component == "real")
if (_component == elk::REAL)
{
return val.real();
}
Expand Down
5 changes: 3 additions & 2 deletions modules/electromagnetics/src/functions/WaveCoeff.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "WaveCoeff.h"
#include "ElkEnums.h"
#include <complex>

registerMooseObject("ElkApp", WaveCoeff);
Expand All @@ -17,7 +18,7 @@ validParams<WaveCoeff>()
params.addRequiredParam<FunctionName>("mu_rel_imag",
"Relative permeability, imaginary component.");
params.addRequiredParam<Real>("k", "Wave number.");
MooseEnum component("imaginary real", "real");
MooseEnum component("real imaginary");
params.addParam<MooseEnum>("component", component, "Real or Imaginary wave component.");
return params;
}
Expand All @@ -43,7 +44,7 @@ WaveCoeff::value(Real t, const Point & p)

std::complex<double> val = std::pow(_k, 2) * mu_r * eps_r;

if (_component == "real")
if (_component == elk::REAL)
{
return val.real();
}
Expand Down
5 changes: 3 additions & 2 deletions modules/electromagnetics/src/functions/ZPolarizedWave.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "ZPolarizedWave.h"
#include "ElkEnums.h"

registerMooseObject("ElkApp", ZPolarizedWave);

Expand All @@ -11,7 +12,7 @@ validParams<ZPolarizedWave>()
"relative to the x-axis, on a plane parallel to the y-axis.");
params.addRequiredParam<Real>("theta", "Angle of incidence, in degrees");
params.addRequiredParam<Real>("k", "Wave Number");
MooseEnum component("imaginary real", "real");
MooseEnum component("real imaginary");
params.addParam<MooseEnum>("component", component, "Real or Imaginary wave component.");
params.addParam<bool>(
"sign_flip",
Expand Down Expand Up @@ -44,7 +45,7 @@ ZPolarizedWave::ZPolarizedWave(const InputParameters & parameters)
Real
ZPolarizedWave::value(Real t, const Point & p)
{
if (_component == "real")
if (_component == elk::REAL)
{
return std::cos(_sign * _k * p(0) * std::cos(2 * libMesh::pi * _theta / 360));
}
Expand Down
3 changes: 2 additions & 1 deletion modules/electromagnetics/src/kernels/VectorCurrentSource.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "VectorCurrentSource.h"
#include "ElkEnums.h"
#include <complex>

registerMooseObject("ElkApp", VectorCurrentSource);
Expand Down Expand Up @@ -40,7 +41,7 @@ VectorCurrentSource::computeQpResidual()

std::complex<double> res = jay * _func.value(_t, _q_point[_qp]) * source * _test[_i][_qp];

if (_component == "real")
if (_component == elk::REAL)
{
return res.real();
}
Expand Down
5 changes: 3 additions & 2 deletions modules/electromagnetics/test/src/functions/MMSTestFunc.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "MMSTestFunc.h"
#include "ElkEnums.h"
#include <complex>

registerMooseObject("ElkApp", MMSTestFunc);
Expand All @@ -22,7 +23,7 @@ validParams<MMSTestFunc>()
params.addRequiredParam<Real>("g0_imag", "Imaginary component of DirichletBC where x = 0.");
params.addRequiredParam<Real>("gL_real", "Real component of DirichletBC where x = L.");
params.addRequiredParam<Real>("gL_imag", "Imaginary component of DirichletBC where x = L.");
MooseEnum component("imaginary real", "real");
MooseEnum component("real imaginary");
params.addParam<MooseEnum>("component", component, "Real or Imaginary wave component.");
return params;
}
Expand Down Expand Up @@ -75,7 +76,7 @@ MMSTestFunc::value(Real t, const Point & p)
_C2 * ((_c_second * p(0) + 2.0 * _c_grad) * std::cos(_c * p(0)) -
(std::pow(_c_grad * p(0), 2) + 2.0 * _c_grad * _c * p(0)) * std::sin(_c * p(0)));

if (_component == "real")
if (_component == elk::REAL)
{
_val = _F.real();
}
Expand Down

0 comments on commit 9641c21

Please sign in to comment.