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 : #pragma once 11 : 12 : #include "MultiAppTransfer.h" 13 : #include "MeshChangedInterface.h" 14 : 15 : /** 16 : * Samples a variable's value in the parent application domain at the point where 17 : * the MultiApp (for each child app) is. Copies that value into a postprocessor in the MultiApp. 18 : */ 19 : class MultiAppVariableValueSamplePostprocessorTransfer : public MultiAppTransfer, 20 : public MeshChangedInterface 21 : { 22 : public: 23 : static InputParameters validParams(); 24 : 25 : MultiAppVariableValueSamplePostprocessorTransfer(const InputParameters & parameters); 26 : 27 : virtual void initialSetup() override; 28 : 29 : virtual void execute() override; 30 : 31 : void meshChanged() override; 32 : 33 : protected: 34 : /** 35 : * Sets up the postprocessor to processor ID communication pattern data member \p 36 : * _postprocessor_to_processor_id 37 : */ 38 : void setupPostprocessorCommunication(); 39 : 40 : /** 41 : * Method that caches data regarding the element to postprocess relationship. This is an expensive 42 : * method, so we only do it during initial setup or if the mesh changes 43 : */ 44 : void cacheElemToPostprocessorData(); 45 : 46 : /** 47 : * Maps the child application index to the parent application variable component 48 : * 49 : * @param index Child application index 50 : * @return unsigned int Parent application variable component 51 : */ 52 4128 : unsigned int getVariableComponent(unsigned int index) const 53 : { 54 4128 : return _map_comp_to_child ? index / _apps_per_component : _comp; 55 : } 56 : 57 : /// the name of the postprocessor on the sub-applications 58 : PostprocessorName _postprocessor_name; 59 : /// the name of the variable on the main-application 60 : AuxVariableName _var_name; 61 : /// the component number of the variable for transferring 62 : unsigned int _comp; 63 : /// the moose variable 64 : MooseVariableFieldBase & _var; 65 : /// Whether or not to map groups of child applications to each component of an array variable 66 : const bool _map_comp_to_child; 67 : /// The number of applications associated with a component of the variable when doing array variable sampling 68 : unsigned int _apps_per_component; 69 : /// Sub-application ids of all local active elements in the main-application 70 : /// When _map_comp_to_child == true, this vector has an entry for each component of the array variable: 71 : /// sub_app_index = _cached_multiapp_pos_ids[elem_id * n_comp + comp] 72 : std::vector<unsigned int> _cached_multiapp_pos_ids; 73 : 74 : /// Entries in this vector correspond to the processor ID that owns the application/postprocessor 75 : /// corresponding to the index 76 : std::vector<processor_id_type> _postprocessor_to_processor_id; 77 : 78 : /// The postprocessors that this process needs for its active local elements 79 : std::unordered_set<unsigned int> _needed_postprocessors; 80 : };