Line data Source code
1 : /********************************************************************/ 2 : /* SOFTWARE COPYRIGHT NOTIFICATION */ 3 : /* Cardinal */ 4 : /* */ 5 : /* (c) 2021 UChicago Argonne, LLC */ 6 : /* ALL RIGHTS RESERVED */ 7 : /* */ 8 : /* Prepared by UChicago Argonne, LLC */ 9 : /* Under Contract No. DE-AC02-06CH11357 */ 10 : /* With the U. S. Department of Energy */ 11 : /* */ 12 : /* Prepared by Battelle Energy Alliance, LLC */ 13 : /* Under Contract No. DE-AC07-05ID14517 */ 14 : /* With the U. S. Department of Energy */ 15 : /* */ 16 : /* See LICENSE for full restrictions */ 17 : /********************************************************************/ 18 : 19 : #ifdef ENABLE_NEK_COUPLING 20 : 21 : #include "NekRSProblem.h" 22 : #include "NekRSMesh.h" 23 : #include "NekTransferBase.h" 24 : 25 : InputParameters 26 2424 : NekTransferBase::validParams() 27 : { 28 2424 : auto params = MooseObject::validParams(); 29 4848 : MooseEnum direction("to_nek from_nek"); 30 4848 : params.addRequiredParam<MooseEnum>("direction", direction, "Direction in which to send data"); 31 2424 : params.addClassDescription("Base class for passing data between NekRS and MOOSE"); 32 2424 : params.addPrivateParam<NekRSProblem *>("_nek_problem"); 33 2424 : return params; 34 2424 : } 35 : 36 1218 : NekTransferBase::NekTransferBase(const InputParameters & parameters) 37 : : MooseObject(parameters), 38 : PostprocessorInterface(this), 39 1218 : _nek_problem(*getParam<NekRSProblem *>("_nek_problem")), 40 3654 : _direction(getParam<MooseEnum>("direction")) 41 : { 42 : // we do not need to check for other mesh types because we already enforce 43 : // the usage of NekRSMesh by requiring the use of a NekRS problem 44 : // in the AddNekTransferAction 45 1218 : _nek_mesh = dynamic_cast<NekRSMesh *>(&(getMooseApp().feProblem().mesh())); 46 1218 : } 47 : 48 : void 49 537 : NekTransferBase::checkAllocatedUsrwrkSlot(const unsigned int & u) const 50 : { 51 537 : if (u >= _nek_problem.nUsrWrkSlots()) 52 2 : paramError("usrwrk_slot", 53 4 : "Cannot write into usrwrk slot " + Moose::stringify(u) + " because only " + 54 2 : Moose::stringify(_nek_problem.nUsrWrkSlots()) + 55 : " have been allocated with 'n_usrwrk_slots'. Slots are zero-indexed, so the " 56 2 : "maximum acceptable value in 'usrwrk_slot' is " + 57 2 : Moose::stringify(_nek_problem.nUsrWrkSlots() - 1) + 58 : ". If you need more slots, increase 'n_usrwrk_slots' in the [Problem] block."); 59 535 : } 60 : 61 : void 62 324 : NekTransferBase::addExternalPostprocessor(const std::string name, const Real initial) 63 : { 64 324 : auto pp_params = _factory.getValidParams("Receiver"); 65 324 : pp_params.set<Real>("default") = initial; 66 : 67 : // we do not need to check for duplicate names, because MOOSE already handles 68 : // this error checking 69 324 : _nek_problem.addPostprocessor("Receiver", name, pp_params); 70 324 : } 71 : 72 : #endif