www.mooseframework.org
ProjectMaterialProperties.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 // MOOSE includes
17 #include "NonlinearSystem.h"
18 #include "Problem.h"
19 #include "FEProblem.h"
21 #include "MaterialData.h"
22 #include "Assembly.h"
23 #include "AuxKernel.h"
24 
25 #include "libmesh/threads.h"
26 #include "libmesh/elem.h"
27 
29  bool refine,
30  FEProblemBase & fe_problem,
31  NonlinearSystemBase & sys,
32  std::vector<std::shared_ptr<MaterialData>> & material_data,
33  std::vector<std::shared_ptr<MaterialData>> & bnd_material_data,
34  MaterialPropertyStorage & material_props,
35  MaterialPropertyStorage & bnd_material_props,
36  std::vector<Assembly *> & assembly)
38  _refine(refine),
39  _fe_problem(fe_problem),
40  _sys(sys),
41  _material_data(material_data),
42  _bnd_material_data(bnd_material_data),
43  _material_props(material_props),
44  _bnd_material_props(bnd_material_props),
45  _assembly(assembly),
46  _need_internal_side_material(false)
47 {
48 }
49 
50 // Splitting Constructor
52  Threads::split split)
54  _refine(x._refine),
56  _sys(x._sys),
63 {
64 }
65 
67 
68 void
70 {
72 }
73 
74 void
76 {
77  _assembly[_tid]->reinit(elem);
78 
79  if (_refine)
80  {
81  const std::vector<std::vector<QpMap>> & refinement_map =
82  _mesh.getRefinementMap(*elem, -1, -1, -1);
83 
85  refinement_map,
86  *_assembly[_tid]->qRule(),
87  *_assembly[_tid]->qRuleFace(),
88  _material_props, // Passing in the same properties to do volume to volume projection
90  *elem,
91  -1,
92  -1,
93  -1); // Gets us volume projection
94  }
95  else
96  {
97  const std::vector<std::pair<unsigned int, QpMap>> & coarsening_map =
98  _mesh.getCoarseningMap(*elem, -1);
99 
100  _material_props.restrictStatefulProps(coarsening_map,
102  *_assembly[_tid]->qRule(),
103  *_assembly[_tid]->qRuleFace(),
105  *elem,
106  -1);
107  }
108 }
109 
110 void
111 ProjectMaterialProperties::onBoundary(const Elem * elem, unsigned int side, BoundaryID bnd_id)
112 {
113  if (_fe_problem.needMaterialOnSide(bnd_id, _tid))
114  {
115  _assembly[_tid]->reinit(elem, side);
116 
117  if (_refine)
118  {
119  const std::vector<std::vector<QpMap>> & refinement_map =
120  _mesh.getRefinementMap(*elem, side, -1, side);
121 
123  refinement_map,
124  *_assembly[_tid]->qRule(),
125  *_assembly[_tid]->qRuleFace(),
126  _bnd_material_props, // Passing in the same properties to do side_to_side projection
128  *elem,
129  side,
130  -1,
131  side); // Gets us side to side projection
132  }
133  else
134  {
135  const std::vector<std::pair<unsigned int, QpMap>> & coarsening_map =
136  _mesh.getCoarseningMap(*elem, side);
137 
140  *_assembly[_tid]->qRule(),
141  *_assembly[_tid]->qRuleFace(),
143  *elem,
144  side);
145  }
146  }
147 }
148 
149 void
150 ProjectMaterialProperties::onInternalSide(const Elem * elem, unsigned int /*side*/)
151 {
153  _refine) // If we're refining then we need to also project "internal" child sides.
154  {
155  for (unsigned int child = 0; child < elem->n_children(); child++)
156  {
157  Elem * child_elem = elem->child(child);
158 
159  for (unsigned int side = 0; side < child_elem->n_sides(); side++)
160  {
161  if (!elem->is_child_on_side(child, side)) // Otherwise we already projected it
162  {
163  const std::vector<std::vector<QpMap>> & refinement_map =
164  _mesh.getRefinementMap(*elem, -1, child, side);
165 
167  refinement_map,
168  *_assembly[_tid]->qRule(),
169  *_assembly[_tid]->qRuleFace(),
170  _material_props, // Passing in the same properties to do side_to_side projection
172  *elem,
173  -1,
174  child,
175  side); // Gets us volume to side projection
176  }
177  }
178  }
179  }
180 }
181 
182 void
184 {
185 }
Base class for assembly-like calculations.
std::vector< std::shared_ptr< MaterialData > > & _bnd_material_data
virtual void subdomainChanged() override
Called every time the current subdomain changes (i.e.
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:1630
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:1568
Stores the stateful material properties computed by materials.
MaterialPropertyStorage & _bnd_material_props
bool needMaterialOnSide(BoundaryID bnd_id, THREAD_ID tid)
These methods are used to determine whether stateful material properties need to be stored on interna...
static PetscErrorCode Vec x
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual void onElement(const Elem *elem) override
Assembly of the element (not including surface assembly)
void restrictStatefulProps(const std::vector< std::pair< unsigned int, QpMap >> &coarsening_map, const std::vector< const Elem * > &coarsened_element_children, QBase &qrule, QBase &qrule_face, MaterialData &material_data, const Elem &elem, int input_side=-1)
Creates storage for newly created elements from mesh Adaptivity.
Nonlinear system to be solved.
StoredRange< std::vector< const Elem * >::iterator, const Elem * > ConstElemPointerRange
Definition: MooseTypes.h:82
bool _refine
Whether or not you are projecting refinements. Set to false for coarsening.
MaterialPropertyStorage & _material_props
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id) override
Called when doing boundary assembling.
std::vector< std::shared_ptr< MaterialData > > & _material_data
ProjectMaterialProperties(bool refine, FEProblemBase &fe_problem, NonlinearSystemBase &sys, std::vector< std::shared_ptr< MaterialData >> &material_data, std::vector< std::shared_ptr< MaterialData >> &bnd_material_data, MaterialPropertyStorage &material_props, MaterialPropertyStorage &bnd_material_props, std::vector< Assembly * > &assembly)
std::vector< Assembly * > & _assembly
void prolongStatefulProps(const std::vector< std::vector< QpMap >> &refinement_map, QBase &qrule, QBase &qrule_face, MaterialPropertyStorage &parent_material_props, MaterialData &child_material_data, 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< const Elem * > & coarsenedElementChildren(const Elem *elem) const
Get the newly removed children element ids for an element that was just coarsened.
Definition: MooseMesh.C:509
SubdomainID _subdomain
The subdomain for the current element.
void join(const ProjectMaterialProperties &)
virtual void onInternalSide(const Elem *elem, unsigned int side) override
Called when doing internal edge assembling.
boundary_id_type BoundaryID
Definition: MooseTypes.h:75