https://mooseframework.inl.gov
QuadraturePointMultiApp.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
12 #include "MooseMesh.h"
13 #include "FEProblem.h"
14 
15 // libMesh includes
16 #include "libmesh/parallel_algebra.h"
17 #include "libmesh/mesh.h"
18 #include "libmesh/elem.h"
19 #include "libmesh/fe.h"
20 
21 using namespace libMesh;
22 
24 // TODO: Deprecate and use Positions system
25 
28 {
31  params.addClassDescription(
32  "Automatically generates sub-App positions from the elemental quadrature points, with the "
33  "default quadrature, in the parent mesh.");
34  params.suppressParameter<std::vector<Point>>("positions");
35  params.suppressParameter<std::vector<FileName>>("positions_file");
36  params.suppressParameter<std::vector<PositionsName>>("positions_objects");
37  return params;
38 }
39 
41  : TransientMultiApp(parameters), BlockRestrictable(this)
42 {
43 }
44 
45 void
47 {
48  MooseMesh & main_mesh = _fe_problem.mesh();
49  auto & mesh = main_mesh.getMesh();
50  for (auto & elem : mesh.active_local_element_ptr_range())
51  {
52  // FEType is local to the element, supporting mixed order meshes
53  const FEFamily mapping_family = FEMap::map_fe_type(*elem);
54  FEType fe_type(elem->default_order(), mapping_family);
55  const auto qrule = fe_type.default_quadrature_rule(elem->dim());
56 
57  // Build a Finite Element object of the specified type
58  std::unique_ptr<FEBase> fe(FEBase::build(elem->dim(), fe_type));
59 
60  // Tell the finite element object to use our quadrature rule.
61  fe->attach_quadrature_rule(qrule.get());
62 
63  // The physical XY locations of the quadrature points on the element.
64  // These might be useful for evaluating spatially varying material
65  // properties at the quadrature points.
66  const std::vector<Point> & q_points = fe->get_xyz();
67  fe->reinit(elem);
68 
69  if (hasBlocks(elem->subdomain_id()))
70  for (const auto & q : q_points)
71  _positions.push_back(q);
72  }
73 
74  // Remove local duplicates from the vector of positions as transfers will not handle them
75  std::sort(_positions.begin(), _positions.end());
76  _positions.erase(std::unique(_positions.begin(), _positions.end()), _positions.end());
77 
78  // Use the comm from the problem this MultiApp is part of
80 
81  // Remove duplicates occurring at process boundaries
82  std::sort(_positions.begin(), _positions.end());
83  _positions.erase(std::unique(_positions.begin(), _positions.end()), _positions.end());
84 
85  if (_positions.empty())
86  mooseError("No positions found for QuadraturePointMultiApp ", _name);
87 }
std::unique_ptr< FEGenericBase< Real > > build(const unsigned int dim, const FEType &fet)
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
static InputParameters validParams()
const std::string & _name
The name of this class.
Definition: MooseBase.h:359
static InputParameters validParams()
MeshBase & 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.
registerMooseObject("MooseApp", QuadraturePointMultiApp)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
FEProblemBase & _fe_problem
The FEProblemBase this MultiApp is part of.
Definition: MultiApp.h:482
QuadraturePointMultiApp(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...
std::unique_ptr< QBase > default_quadrature_rule(const unsigned int dim, const int extraorder=0) const
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3448
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
virtual MooseMesh & mesh() override
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
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:488
void fillPositions() override
must fill in _positions with the positions of the sub-aps
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
FEFamily
Automatically generates sub-App positions with elemental quadrature points of the parent mesh...