www.mooseframework.org
CentroidMultiApp.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
19 
20 // TODO: Deprecate and use Positions system
21 
24 {
27  params.addClassDescription(
28  "Automatically generates Sub-App positions from centroids of elements in the parent app "
29  " mesh.");
30  params.suppressParameter<std::vector<Point>>("positions");
31  params.suppressParameter<std::vector<FileName>>("positions_file");
32  params.suppressParameter<std::vector<PositionsName>>("positions_objects");
33  return params;
34 }
35 
37  : TransientMultiApp(parameters), BlockRestrictable(this)
38 {
39 }
40 
41 void
43 {
44  MooseMesh & parent_app_mesh = _fe_problem.mesh();
45 
46  for (const auto & elem_ptr : parent_app_mesh.getMesh().active_local_element_ptr_range())
47  if (hasBlocks(elem_ptr->subdomain_id()))
48  _positions.push_back(elem_ptr->vertex_average());
49 
50  // Use the comm from the problem this MultiApp is part of
52 
53  if (_positions.empty())
54  mooseError("No positions found for CentroidMultiapp ", _name);
55 
56  // An attempt to try to make this parallel stable
57  std::sort(_positions.begin(), _positions.end());
58 }
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
const std::string & _name
The name of this class, reference to value stored in InputParameters.
Definition: MooseBase.h:75
static InputParameters validParams()
Automatically generates Sub-App positions from centroids of elements in the master mesh...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Parallel::Communicator & comm() const
MultiApp Implementation for Transient Apps.
FEProblemBase & _fe_problem
The FEProblemBase this MultiApp is part of.
Definition: MultiApp.h:479
CentroidMultiApp(const InputParameters &parameters)
static InputParameters validParams()
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn&#39;t required or valid in the derived class...
virtual void fillPositions() override
fill in _positions with the positions of the sub-aps
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3198
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
static InputParameters validParams()
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
virtual MooseMesh & mesh() override
registerMooseObject("MooseApp", CentroidMultiApp)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
std::vector< Point > _positions
The positions of all of the apps, using input constant vectors (to be deprecated) ...
Definition: MultiApp.h:485
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.