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
22// TODO: Deprecate and use Positions system
23
26{
30 "Automatically generates sub-App positions from the elemental quadrature points, with the "
31 "default quadrature, in the parent mesh.");
32 params.suppressParameter<std::vector<Point>>("positions");
33 params.suppressParameter<std::vector<FileName>>("positions_file");
34 params.suppressParameter<std::vector<PositionsName>>("positions_objects");
35 return params;
36}
37
42
43void
45{
46 MooseMesh & main_mesh = _fe_problem.mesh();
47 auto & mesh = main_mesh.getMesh();
48 for (auto & elem : mesh.active_local_element_ptr_range())
49 {
50 // FEType is local to the element, supporting mixed order meshes
51 const FEFamily mapping_family = FEMap::map_fe_type(*elem);
52 FEType fe_type(elem->default_order(), mapping_family);
53 const auto qrule = fe_type.default_quadrature_rule(elem->dim());
54
55 // Build a Finite Element object of the specified type
56 std::unique_ptr<FEBase> fe(FEBase::build(elem->dim(), fe_type));
57
58 // Tell the finite element object to use our quadrature rule.
59 fe->attach_quadrature_rule(qrule.get());
60
61 // The physical XY locations of the quadrature points on the element.
62 // These might be useful for evaluating spatially varying material
63 // properties at the quadrature points.
64 const std::vector<Point> & q_points = fe->get_xyz();
65 fe->reinit(elem);
66
67 if (hasBlocks(elem->subdomain_id()))
68 for (const auto & q : q_points)
69 _positions.push_back(q);
70 }
71
72 // Remove local duplicates from the vector of positions as transfers will not handle them
73 std::sort(_positions.begin(), _positions.end());
74 _positions.erase(std::unique(_positions.begin(), _positions.end()), _positions.end());
75
76 // Use the comm from the problem this MultiApp is part of
78
79 // Remove duplicates occurring at process boundaries
80 std::sort(_positions.begin(), _positions.end());
81 _positions.erase(std::unique(_positions.begin(), _positions.end()), _positions.end());
82
83 if (_positions.empty())
84 mooseError("No positions found for QuadraturePointMultiApp ", _name);
85}
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:3557
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()
const Parallel::Communicator & comm() const
MeshBase & mesh