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 template <>
23 {
25 
27 
28  params.suppressParameter<std::vector<Point>>("positions");
29  params.suppressParameter<std::vector<FileName>>("positions_file");
30 
31  return params;
32 }
33 
35  : TransientMultiApp(parameters), BlockRestrictable(this)
36 {
37 }
38 
39 void
41 {
42  MooseMesh & master_mesh = _fe_problem.mesh();
43 
44  for (const auto & elem_ptr : master_mesh.getMesh().active_local_element_ptr_range())
45  if (hasBlocks(elem_ptr->subdomain_id()))
46  _positions.push_back(elem_ptr->centroid());
47 
48  // Use the comm from the problem this MultiApp is part of
50 
51  if (_positions.empty())
52  mooseError("No positions found for CentroidMultiapp ", _name);
53 
54  // An attempt to try to make this parallel stable
55  std::sort(_positions.begin(), _positions.end());
56 }
InputParameters validParams< BlockRestrictable >()
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...
MultiApp Implementation for Transient Apps.
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
FEProblemBase & _fe_problem
The FEProblemBase this MultiApp is part of.
Definition: MultiApp.h:325
CentroidMultiApp(const InputParameters &parameters)
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:2567
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
InputParameters validParams< CentroidMultiApp >()
const std::string & _name
The name of this object, reference to value stored in InputParameters.
Definition: MooseObject.h:183
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
MPI_Comm comm
virtual MooseMesh & mesh() override
registerMooseObject("MooseApp", CentroidMultiApp)
std::vector< Point > _positions
The positions of all of the apps.
Definition: MultiApp.h:331
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
InputParameters validParams< TransientMultiApp >()