Line data Source code
1 : #ifdef ENABLE_NEK_COUPLING 2 : 3 : #include "NekFieldInterface.h" 4 : #include "NekInterface.h" 5 : #include "UserErrorChecking.h" 6 : #include "GeometryUtils.h" 7 : 8 : InputParameters 9 9199 : NekFieldInterface::validParams() 10 : { 11 9199 : InputParameters params = emptyInputParameters(); 12 9199 : params += FunctionInterface::validParams(); 13 18398 : params.addRequiredParam<MooseEnum>("field", getNekFieldEnum(), "Field to apply this object to"); 14 18398 : params.addParam<FunctionName>( 15 : "function", 16 : "Function to shift the field by, when applying this object. For example, if 'field = " 17 : "temperature', using this parameter will apply this object to the new combined quantity " 18 : "'temperature - f', where 'f' is this shifting function."); 19 18398 : params.addParam<Point>("velocity_direction", 20 : "Unit vector to dot with velocity, for 'field = velocity_component'. For " 21 : "example, velocity_direction = '1 1 0' will get the velocity dotted with " 22 : "(1/sqrt(2), 1/sqrt(2), 0)."); 23 18398 : params.addParam<MooseEnum>( 24 : "velocity_component", 25 18398 : getBinnedVelocityComponentEnum(), 26 : "Direction in which to evaluate velocity when 'field = velocity_component.' " 27 : "Options: user (you then need to specify a direction with 'velocity_direction'); normal"); 28 9199 : return params; 29 0 : } 30 : 31 3045 : NekFieldInterface::NekFieldInterface(const MooseObject * moose_object, 32 : const InputParameters & parameters, 33 3045 : const bool allow_normal_velocity) 34 : : FunctionInterface(moose_object), 35 6090 : _field(moose_object->getParam<MooseEnum>("field").getEnum<field::NekFieldEnum>()), 36 6105 : _function(moose_object->isParamValid("function") ? &this->getFunction("function") : nullptr), 37 6090 : _velocity_component(moose_object->getParam<MooseEnum>("velocity_component") 38 3045 : .getEnum<component::BinnedVelocityComponentEnum>()) 39 : { 40 : // check that this field can be used given the problem parameters 41 3045 : nekrs::checkFieldValidity(_field); 42 : 43 3037 : if (_field == field::velocity_component) 44 : { 45 109 : switch (_velocity_component) 46 : { 47 : case component::user: 48 200 : checkRequiredParam(parameters, "velocity_direction", "using 'velocity_component = user'"); 49 : 50 300 : _velocity_direction = geom_utils::unitVector( 51 : moose_object->getParam<Point>("velocity_direction"), "velocity_direction"); 52 : 53 100 : break; 54 9 : case component::normal: 55 9 : if (!allow_normal_velocity) 56 0 : mooseError("This object does not support 'velocity_component = normal'! Please contact " 57 : "the Cardinal development team if this is hindering your use case."); 58 : 59 18 : checkUnusedParam(parameters, "velocity_direction", "using 'velocity_component = normal'"); 60 9 : break; 61 0 : default: 62 0 : mooseError("Unhandled BinnedVelocityComponentEnum!"); 63 : } 64 : } 65 : else 66 : { 67 5856 : checkUnusedParam(parameters, "velocity_direction", "not using 'field = velocity_component'"); 68 5856 : checkUnusedParam(parameters, "velocity_component", "not using 'field = velocity_component'"); 69 : } 70 3037 : } 71 : #endif