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 : // MOOSE includes 11 : #include "CentroidMultiApp.h" 12 : #include "MooseMesh.h" 13 : #include "FEProblem.h" 14 : 15 : // libMesh includes 16 : #include "libmesh/parallel_algebra.h" 17 : 18 : registerMooseObject("MooseApp", CentroidMultiApp); 19 : 20 : // TODO: Deprecate and use Positions system 21 : 22 : InputParameters 23 14461 : CentroidMultiApp::validParams() 24 : { 25 14461 : InputParameters params = TransientMultiApp::validParams(); 26 14461 : params += BlockRestrictable::validParams(); 27 14461 : params.addClassDescription( 28 : "Automatically generates Sub-App positions from centroids of elements in the parent app " 29 : " mesh."); 30 14461 : params.suppressParameter<std::vector<Point>>("positions"); 31 14461 : params.suppressParameter<std::vector<FileName>>("positions_file"); 32 14461 : params.suppressParameter<std::vector<PositionsName>>("positions_objects"); 33 14461 : return params; 34 0 : } 35 : 36 98 : CentroidMultiApp::CentroidMultiApp(const InputParameters & parameters) 37 98 : : TransientMultiApp(parameters), BlockRestrictable(this) 38 : { 39 98 : } 40 : 41 : void 42 98 : CentroidMultiApp::fillPositions() 43 : { 44 98 : MooseMesh & parent_app_mesh = _fe_problem.mesh(); 45 : 46 2342 : for (const auto & elem_ptr : parent_app_mesh.getMesh().active_local_element_ptr_range()) 47 1122 : if (hasBlocks(elem_ptr->subdomain_id())) 48 1044 : _positions.push_back(elem_ptr->vertex_average()); 49 : 50 : // Use the comm from the problem this MultiApp is part of 51 98 : libMesh::ParallelObject::comm().allgather(_positions); 52 : 53 98 : if (_positions.empty()) 54 0 : mooseError("No positions found for CentroidMultiapp ", _name); 55 : 56 : // An attempt to try to make this parallel stable 57 98 : std::sort(_positions.begin(), _positions.end()); 58 98 : }