www.mooseframework.org
ProjectMaterialProperties.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "NonlinearSystem.h"
13 #include "Problem.h"
14 #include "FEProblem.h"
16 #include "MaterialData.h"
17 #include "Assembly.h"
18 #include "AuxKernel.h"
19 
20 #include "libmesh/threads.h"
21 #include "libmesh/elem.h"
22 
24  bool refine,
25  FEProblemBase & fe_problem,
26  NonlinearSystemBase & sys,
27  std::vector<std::shared_ptr<MaterialData>> & material_data,
28  std::vector<std::shared_ptr<MaterialData>> & bnd_material_data,
29  MaterialPropertyStorage & material_props,
30  MaterialPropertyStorage & bnd_material_props,
31  std::vector<std::unique_ptr<Assembly>> & assembly)
33  _refine(refine),
34  _fe_problem(fe_problem),
35  _sys(sys),
36  _material_data(material_data),
37  _bnd_material_data(bnd_material_data),
38  _material_props(material_props),
39  _bnd_material_props(bnd_material_props),
40  _assembly(assembly),
41  _need_internal_side_material(false)
42 {
43 }
44 
45 // Splitting Constructor
49  _refine(x._refine),
50  _fe_problem(x._fe_problem),
51  _sys(x._sys),
52  _material_data(x._material_data),
53  _bnd_material_data(x._bnd_material_data),
54  _material_props(x._material_props),
55  _bnd_material_props(x._bnd_material_props),
56  _assembly(x._assembly),
57  _need_internal_side_material(x._need_internal_side_material)
58 {
59 }
60 
62 
63 void
65 {
67 }
68 
69 void
71 {
72  _assembly[_tid]->reinit(elem);
73 
74  if (_refine)
75  {
76  const std::vector<std::vector<QpMap>> & refinement_map =
77  _mesh.getRefinementMap(*elem, -1, -1, -1);
78 
80  refinement_map,
81  *_assembly[_tid]->qRule(),
82  *_assembly[_tid]->qRuleFace(),
83  _material_props, // Passing in the same properties to do volume to volume projection
85  *elem,
86  -1,
87  -1,
88  -1); // Gets us volume projection
89  }
90  else
91  {
92  const std::vector<std::pair<unsigned int, QpMap>> & coarsening_map =
93  _mesh.getCoarseningMap(*elem, -1);
94 
97  *_assembly[_tid]->qRule(),
98  *_assembly[_tid]->qRuleFace(),
100  *elem,
101  -1);
102  }
103 }
104 
105 void
106 ProjectMaterialProperties::onBoundary(const Elem * elem, unsigned int side, BoundaryID bnd_id)
107 {
109  {
110  _assembly[_tid]->reinit(elem, side);
111 
112  if (_refine)
113  {
114  const std::vector<std::vector<QpMap>> & refinement_map =
115  _mesh.getRefinementMap(*elem, side, -1, side);
116 
118  refinement_map,
119  *_assembly[_tid]->qRule(),
120  *_assembly[_tid]->qRuleFace(),
121  _bnd_material_props, // Passing in the same properties to do side_to_side projection
123  *elem,
124  side,
125  -1,
126  side); // Gets us side to side projection
127  }
128  else
129  {
130  const std::vector<std::pair<unsigned int, QpMap>> & coarsening_map =
131  _mesh.getCoarseningMap(*elem, side);
132 
135  *_assembly[_tid]->qRule(),
136  *_assembly[_tid]->qRuleFace(),
138  *elem,
139  side);
140  }
141  }
142 }
143 
144 void
145 ProjectMaterialProperties::onInternalSide(const Elem * elem, unsigned int /*side*/)
146 {
148  _refine) // If we're refining then we need to also project "internal" child sides.
149  {
150  for (unsigned int child = 0; child < elem->n_children(); child++)
151  {
152  const Elem * child_elem = elem->child_ptr(child);
153 
154  for (unsigned int side = 0; side < child_elem->n_sides(); side++)
155  {
156  if (!elem->is_child_on_side(child, side)) // Otherwise we already projected it
157  {
158  const std::vector<std::vector<QpMap>> & refinement_map =
159  _mesh.getRefinementMap(*elem, -1, child, side);
160 
162  refinement_map,
163  *_assembly[_tid]->qRule(),
164  *_assembly[_tid]->qRuleFace(),
165  _material_props, // Passing in the same properties to do side_to_side projection
167  *elem,
168  -1,
169  child,
170  side); // Gets us volume to side projection
171  }
172  }
173  }
174  }
175 }
176 
177 void
179 {
180 }
Base class for assembly-like calculations.
std::vector< std::unique_ptr< Assembly > > & _assembly
void prolongStatefulProps(const std::vector< std::vector< QpMap >> &refinement_map, const QBase &qrule, const 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.
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:1731
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:1667
Stores the stateful material properties computed by materials.
bool needSubdomainMaterialOnSide(SubdomainID subdomain_id, THREAD_ID tid)
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< std::unique_ptr< Assembly >> &assembly)
MaterialPropertyStorage & _bnd_material_props
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)
Nonlinear system to be solved.
std::vector< std::string > split(const std::string &str, const std::string &delimiter)
Python like split function for strings.
Definition: MooseUtils.C:736
StoredRange< std::vector< const Elem * >::iterator, const Elem * > ConstElemPointerRange
Definition: MooseTypes.h:166
bool _refine
Whether or not you are projecting refinements. Set to false for coarsening.
MaterialPropertyStorage & _material_props
boundary_id_type BoundaryID
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id) override
Called when doing boundary assembling.
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:551
std::vector< std::shared_ptr< MaterialData > > & _material_data
void restrictStatefulProps(const std::vector< std::pair< unsigned int, QpMap >> &coarsening_map, const std::vector< const Elem *> &coarsened_element_children, const QBase &qrule, const QBase &qrule_face, MaterialData &material_data, const Elem &elem, int input_side=-1)
Creates storage for newly created elements from mesh Adaptivity.
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.
bool needBoundaryMaterialOnSide(BoundaryID bnd_id, THREAD_ID tid)
These methods are used to determine whether stateful material properties need to be stored on interna...