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 : #include "NearestPointReceiverTransfer.h" 20 : 21 : #include "NearestPointReceiver.h" 22 : 23 : // MOOSE includes 24 : #include "MooseTypes.h" 25 : #include "FEProblem.h" 26 : #include "MultiApp.h" 27 : 28 : // libMesh 29 : #include "libmesh/meshfree_interpolation.h" 30 : #include "libmesh/system.h" 31 : 32 : registerMooseObject("MooseApp", NearestPointReceiverTransfer); 33 : 34 : InputParameters 35 60 : NearestPointReceiverTransfer::validParams() 36 : { 37 60 : InputParameters params = MultiAppTransfer::validParams(); 38 : 39 120 : params.addRequiredParam<UserObjectName>("from_uo", 40 : "The name of the UserObject to transfer the value from."); 41 : 42 120 : params.addRequiredParam<UserObjectName>( 43 : "to_uo", "The name of the NearestPointReceiver to transfer the value to. "); 44 : 45 60 : return params; 46 0 : } 47 : 48 30 : NearestPointReceiverTransfer::NearestPointReceiverTransfer(const InputParameters & parameters) 49 : : MultiAppTransfer(parameters), 50 60 : _from_uo_name(getParam<UserObjectName>("from_uo")), 51 60 : _to_uo_name(getParam<UserObjectName>("to_uo")) 52 : { 53 30 : } 54 : 55 : void 56 90 : NearestPointReceiverTransfer::execute() 57 : { 58 : std::vector<Real> values; 59 : 60 90 : switch (_direction) 61 : { 62 45 : case TO_MULTIAPP: 63 : { 64 45 : FEProblemBase & from_problem = getToMultiApp()->problemBase(); 65 45 : auto & from_uo = from_problem.getUserObjectBase(_from_uo_name); 66 : 67 180 : for (unsigned int i = 0; i < getToMultiApp()->numGlobalApps(); i++) 68 : { 69 90 : if (getToMultiApp()->hasLocalApp(i)) 70 : { 71 : values.clear(); 72 : 73 90 : auto & receiver = getToMultiApp()->appProblemBase(i).getUserObject<NearestPointReceiver>(_to_uo_name); 74 : const auto & points = receiver.positions(); 75 : 76 45 : values.reserve(points.size()); 77 : 78 180 : for (const auto & point : points) 79 135 : values.emplace_back(from_uo.spatialValue(point)); 80 : 81 45 : receiver.setValues(values); 82 : } 83 : } 84 : 85 : break; 86 : } 87 45 : case FROM_MULTIAPP: 88 : { 89 45 : FEProblemBase & to_problem = getFromMultiApp()->problemBase(); 90 45 : auto & receiver = to_problem.getUserObject<NearestPointReceiver>(_to_uo_name); 91 : 92 180 : for (unsigned int i = 0; i < getFromMultiApp()->numGlobalApps(); ++i) 93 : { 94 90 : if (getFromMultiApp()->hasLocalApp(i)) 95 : { 96 : values.clear(); 97 : 98 90 : auto & from_uo = getFromMultiApp()->appProblemBase(i).getUserObjectBase(_from_uo_name); 99 : const auto & points = receiver.positions(); 100 : 101 45 : values.reserve(points.size()); 102 : 103 180 : for (const auto & point : points) 104 135 : values.emplace_back(from_uo.spatialValue(point)); 105 : 106 45 : receiver.setValues(values); 107 : } 108 : } 109 : } 110 : } 111 : 112 90 : _console << "Finished NearestPointReceiverTransfer " << name() << std::endl; 113 90 : }