https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CentroidMultiApp.C
Go to the documentation of this file.
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
19
20// TODO: Deprecate and use Positions system
21
24{
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
40
41void
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}
registerMooseObject("MooseApp", CentroidMultiApp)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
An interface that restricts an object to subdomains via the 'blocks' input parameter.
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
static InputParameters validParams()
Automatically generates Sub-App positions from centroids of elements in the master mesh.
static InputParameters validParams()
virtual void fillPositions() override
fill in _positions with the positions of the sub-aps
CentroidMultiApp(const InputParameters &parameters)
virtual MooseMesh & mesh() override
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn't required or valid in the derived class...
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.
const std::string & _name
The name of this class.
Definition MooseBase.h:381
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3549
FEProblemBase & _fe_problem
The FEProblemBase this MultiApp is part of.
Definition MultiApp.h:495
std::vector< Point > _positions
The positions of all of the apps, using input constant vectors (to be deprecated)
Definition MultiApp.h:501
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
MultiApp Implementation for Transient Apps.
static InputParameters validParams()
const Parallel::Communicator & comm() const