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 "VectorCurrentSource.h" 11 : #include "ElectromagneticEnums.h" 12 : #include "ElectromagneticConstants.h" 13 : #include "Function.h" 14 : #include <complex> 15 : 16 : registerMooseObject("ElectromagneticsApp", VectorCurrentSource); 17 : 18 : InputParameters 19 504 : VectorCurrentSource::validParams() 20 : { 21 504 : InputParameters params = VectorKernel::validParams(); 22 504 : params.addClassDescription( 23 : "Kernel to calculate the current source term in the Helmholtz wave equation."); 24 1008 : params.addParam<FunctionName>("function_coefficient", 25 1008 : 1.0, 26 : "Function coefficient multiplier for current source (normally " 27 : "$\\omega$ or $\\omega \\cdot \\mu$)."); 28 1008 : params.addRequiredParam<FunctionName>("source_real", "Current Source vector, real component"); 29 1008 : params.addRequiredParam<FunctionName>("source_imag", 30 : "Current Source vector, imaginary component"); 31 1008 : MooseEnum component("real imaginary"); 32 1008 : params.addParam<MooseEnum>("component", component, "Component of field (real or imaginary)."); 33 504 : return params; 34 504 : } 35 : 36 264 : VectorCurrentSource::VectorCurrentSource(const InputParameters & parameters) 37 : : VectorKernel(parameters), 38 264 : _func(getFunction("function_coefficient")), 39 264 : _source_real(getFunction("source_real")), 40 264 : _source_imag(getFunction("source_imag")), 41 792 : _component(getParam<MooseEnum>("component")) 42 : { 43 264 : } 44 : 45 : Real 46 621504 : VectorCurrentSource::computeQpResidual() 47 : { 48 1243008 : std::complex<double> source_0(_source_real.vectorValue(_t, _q_point[_qp])(0), 49 621504 : _source_imag.vectorValue(_t, _q_point[_qp])(0)); 50 1243008 : std::complex<double> source_1(_source_real.vectorValue(_t, _q_point[_qp])(1), 51 621504 : _source_imag.vectorValue(_t, _q_point[_qp])(1)); 52 1243008 : std::complex<double> source_2(_source_real.vectorValue(_t, _q_point[_qp])(2), 53 621504 : _source_imag.vectorValue(_t, _q_point[_qp])(2)); 54 : VectorValue<std::complex<double>> source(source_0, source_1, source_2); 55 : 56 621504 : std::complex<double> res = EM::j * _func.value(_t, _q_point[_qp]) * source * _test[_i][_qp]; 57 : 58 621504 : if (_component == EM::REAL) 59 310752 : return res.real(); 60 : else 61 310752 : return res.imag(); 62 : } 63 : 64 : Real 65 1018656 : VectorCurrentSource::computeQpJacobian() 66 : { 67 1018656 : return 0.0; 68 : }