https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
21using namespace libMesh;
22
24// TODO: Deprecate and use Positions system
25
28{
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
44
45void
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}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObject("MooseApp", QuadraturePointMultiApp)
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()
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
Automatically generates sub-App positions with elemental quadrature points of the parent mesh.
static InputParameters validParams()
QuadraturePointMultiApp(const InputParameters &parameters)
void fillPositions() override
must fill in _positions with the positions of the sub-aps
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
MultiApp Implementation for Transient Apps.
static InputParameters validParams()
std::unique_ptr< FEGenericBase< Real > > build(const unsigned int dim, const FEType &fet)
static FEFamily map_fe_type(const Elem &elem)
std::unique_ptr< QBase > default_quadrature_rule(const unsigned int dim, const int extraorder=0) const
const Parallel::Communicator & comm() const
MeshBase & mesh
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...