https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ProjectMaterialProperties.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 "Problem.h"
13#include "FEProblem.h"
15#include "MaterialData.h"
16#include "Assembly.h"
17#include "AuxKernel.h"
18
19#include "libmesh/threads.h"
20#include "libmesh/elem.h"
21
23 bool refine,
24 FEProblemBase & fe_problem,
25 MaterialPropertyStorage & material_props,
26 MaterialPropertyStorage & bnd_material_props,
27 std::vector<std::vector<std::unique_ptr<Assembly>>> & assembly)
29 _refine(refine),
30 _fe_problem(fe_problem),
31 _material_props(material_props),
32 _bnd_material_props(bnd_material_props),
33 _assembly(assembly),
34 _need_internal_side_material(false),
35 _materials(_fe_problem.getRegularMaterialsWarehouse()),
36 _discrete_materials(_fe_problem.getDiscreteMaterialWarehouse())
37{
38}
39
40// Splitting Constructor
42 Threads::split split)
44 _refine(x._refine),
45 _fe_problem(x._fe_problem),
46 _material_props(x._material_props),
47 _bnd_material_props(x._bnd_material_props),
48 _assembly(x._assembly),
49 _need_internal_side_material(x._need_internal_side_material),
50 _materials(x._materials),
51 _discrete_materials(x._discrete_materials)
52{
53}
54
56
57void
62
63void
65{
66 // This check mirrors the check in ComputeMaterialsObjectThread::onElement as it must because it
67 // is possible that there are no materials on this element's subdomain, e.g. if we are doing
68 // mortar, in which case the properties will not have been resized in
69 // ComputeMaterialsObjectThread::onElement, and consequently if we were to proceed we would get
70 // bad access errors
71 if (!_materials.hasActiveBlockObjects(elem->subdomain_id(), _tid) &&
72 !_discrete_materials.hasActiveBlockObjects(elem->subdomain_id(), _tid))
73 return;
74
75 _assembly[_tid][0]->reinit(elem);
76
77 if (_refine)
78 {
80 {
81 const auto & p_refinement_map = _mesh.getPRefinementMap(*elem);
83 p_refinement_map,
84 *_assembly[_tid][0]->qRule(),
85 *_assembly[_tid][0]->qRuleFace(),
86 _tid,
87 *elem,
88 -1);
89 }
90 else
91 {
92 const std::vector<std::vector<QpMap>> & refinement_map =
93 _mesh.getRefinementMap(*elem, -1, -1, -1);
94
97 refinement_map,
98 *_assembly[_tid][0]->qRule(),
99 *_assembly[_tid][0]->qRuleFace(),
100 _material_props, // Passing in the same properties to do volume to volume projection
101 _tid,
102 *elem,
103 -1,
104 -1,
105 -1); // Gets us volume projection
106 }
107 }
108 else
109 {
111 {
112 const auto & p_coarsening_map = _mesh.getPCoarseningMap(*elem);
114 p_coarsening_map,
115 *_assembly[_tid][0]->qRule(),
116 *_assembly[_tid][0]->qRuleFace(),
117 _tid,
118 *elem,
119 -1);
120 }
121 else
122 {
123 const std::vector<std::pair<unsigned int, QpMap>> & coarsening_map =
124 _mesh.getCoarseningMap(*elem, -1);
125
128 *_assembly[_tid][0]->qRule(),
129 *_assembly[_tid][0]->qRuleFace(),
130 _tid,
131 *elem,
132 -1);
133 }
134 }
135}
136
137void
139 unsigned int side,
140 BoundaryID bnd_id,
141 const Elem * /*lower_d_elem = nullptr*/)
142{
145 {
146 _assembly[_tid][0]->reinit(elem, side);
147
148 if (_refine)
149 {
151 {
152 const auto & p_refinement_map = _mesh.getPRefinementSideMap(*elem);
154 p_refinement_map,
155 *_assembly[_tid][0]->qRule(),
156 *_assembly[_tid][0]->qRuleFace(),
157 _tid,
158 *elem,
159 side);
160 }
161 else
162 {
163 const std::vector<std::vector<QpMap>> & refinement_map =
164 _mesh.getRefinementMap(*elem, side, -1, side);
165
168 refinement_map,
169 *_assembly[_tid][0]->qRule(),
170 *_assembly[_tid][0]->qRuleFace(),
171 _bnd_material_props, // Passing in the same properties to do side_to_side projection
172 _tid,
173 *elem,
174 side,
175 -1,
176 side); // Gets us side to side projection
177 }
178 }
179 else
180 {
182 {
183 const auto & p_coarsening_map = _mesh.getPCoarseningSideMap(*elem);
185 p_coarsening_map,
186 *_assembly[_tid][0]->qRule(),
187 *_assembly[_tid][0]->qRuleFace(),
188 _tid,
189 *elem,
190 side);
191 }
192 else
193 {
194 const std::vector<std::pair<unsigned int, QpMap>> & coarsening_map =
195 _mesh.getCoarseningMap(*elem, side);
196
199 *_assembly[_tid][0]->qRule(),
200 *_assembly[_tid][0]->qRuleFace(),
201 _tid,
202 *elem,
203 side);
204 }
205 }
206 }
207}
208
209void
210ProjectMaterialProperties::onInternalSide(const Elem * elem, unsigned int /*side*/)
211{
213 _refine) // If we're refining then we need to also project "internal" child sides.
214 {
215 mooseError("I'm pretty sure we're not handling stateful material property prolongation or "
216 "restriction correctly on internal sides");
217 for (unsigned int child = 0; child < elem->n_children(); child++)
218 {
219 const Elem * child_elem = elem->child_ptr(child);
220
221 for (unsigned int side = 0; side < child_elem->n_sides(); side++)
222 {
223 if (!elem->is_child_on_side(child, side)) // Otherwise we already projected it
224 {
225 const std::vector<std::vector<QpMap>> & refinement_map =
226 _mesh.getRefinementMap(*elem, -1, child, side);
227
230 refinement_map,
231 *_assembly[_tid][0]->qRule(),
232 *_assembly[_tid][0]->qRuleFace(),
233 _material_props, // Passing in the same properties to do side_to_side projection
234 _tid,
235 *elem,
236 -1,
237 child,
238 side); // Gets us volume to side projection
239 }
240 }
241 }
242 }
243}
244
245void
boundary_id_type BoundaryID
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
bool needInternalNeighborSideMaterial(SubdomainID subdomain_id, const THREAD_ID tid)
bool needBoundaryMaterialOnSide(BoundaryID bnd_id, const THREAD_ID tid)
These methods are used to determine whether stateful material properties need to be stored on interna...
Stores the stateful material properties computed by materials.
void updateStatefulPropsForPRefinement(const processor_id_type pid, const std::vector< QpMap > &p_refinement_map, const libMesh::QBase &qrule, const libMesh::QBase &qrule_face, const THREAD_ID tid, const Elem &elem, const int input_side)
Based on the p-refinement flag of elem, either prolong (for refinement) or restrict (for coarsening) ...
void restrictStatefulProps(const std::vector< std::pair< unsigned int, QpMap > > &coarsening_map, const std::vector< const Elem * > &coarsened_element_children, const libMesh::QBase &qrule, const libMesh::QBase &qrule_face, const THREAD_ID tid, const Elem &elem, int input_side=-1)
Creates storage for newly created elements from mesh Adaptivity.
void prolongStatefulProps(processor_id_type pid, const std::vector< std::vector< QpMap > > &refinement_map, const libMesh::QBase &qrule, const libMesh::QBase &qrule_face, MaterialPropertyStorage &parent_material_props, const THREAD_ID tid, const Elem &elem, const int input_parent_side, const int input_child, const int input_child_side)
Creates storage for newly created elements from mesh Adaptivity.
const std::vector< QpMap > & getPRefinementMap(const Elem &elem) const
Get the map describing for each volumetric quadrature point (qp) on the refined level which qp on the...
Definition MooseMesh.C:4499
const std::vector< const Elem * > & coarsenedElementChildren(const Elem *elem) const
Get the newly removed children element ids for an element that was just coarsened.
Definition MooseMesh.C:949
const std::vector< std::pair< unsigned int, QpMap > > & getCoarseningMap(const Elem &elem, int input_side)
Get the coarsening map for a given element type.
Definition MooseMesh.C:2630
const std::vector< QpMap > & getPCoarseningMap(const Elem &elem) const
Get the map describing for each volumetric quadrature point (qp) on the coarse level which qp on the ...
Definition MooseMesh.C:4511
const std::vector< QpMap > & getPCoarseningSideMap(const Elem &elem) const
Get the map describing for each side quadrature point (qp) on the coarse level which qp on the previo...
Definition MooseMesh.C:4517
const std::vector< QpMap > & getPRefinementSideMap(const Elem &elem) const
Get the map describing for each side quadrature point (qp) on the refined level which qp on the previ...
Definition MooseMesh.C:4505
const std::vector< std::vector< QpMap > > & getRefinementMap(const Elem &elem, int parent_side, int child, int child_side)
Get the refinement map for a given element type.
Definition MooseMesh.C:2566
void doingPRefinement(bool doing_p_refinement)
Indicate whether the kind of adaptivity we're doing includes p-refinement.
Definition MooseMesh.h:1504
bool hasActiveBlockObjects(THREAD_ID tid=0) const
std::vector< std::vector< std::unique_ptr< Assembly > > > & _assembly
bool _refine
Whether or not you are projecting refinements. Set to false for coarsening.
MaterialPropertyStorage & _bnd_material_props
const MaterialWarehouse & _materials
Materials warehouse.
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr) override
Called when doing boundary assembling.
MaterialPropertyStorage & _material_props
ProjectMaterialProperties(bool refine, FEProblemBase &fe_problem, MaterialPropertyStorage &material_props, MaterialPropertyStorage &bnd_material_props, std::vector< std::vector< std::unique_ptr< Assembly > > > &assembly)
void join(const ProjectMaterialProperties &)
virtual void onElement(const Elem *elem) override
Assembly of the element (not including surface assembly)
const MaterialWarehouse & _discrete_materials
Discrete materials warehouse.
virtual void subdomainChanged() override
Called every time the current subdomain changes (i.e.
virtual void onInternalSide(const Elem *elem, unsigned int side) override
Called when doing internal edge assembling.
SubdomainID _subdomain
The subdomain for the current element.
Base class for assembly-like calculations.
processor_id_type processor_id() const