ExaDG
Loading...
Searching...
No Matches
material_handler.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef EXADG_STRUCTURE_MATERIAL_MATERIAL_HANDLER_H_
23#define EXADG_STRUCTURE_MATERIAL_MATERIAL_HANDLER_H_
24
25// deal.II
26#include <deal.II/matrix_free/matrix_free.h>
27
28// ExaDG
29#include <exadg/structure/material/library/incompressible_neo_hookean.h>
30#include <exadg/structure/material/library/st_venant_kirchhoff.h>
31#include <exadg/structure/material/material.h>
32#include <exadg/structure/user_interface/material_descriptor.h>
33
34namespace ExaDG
35{
36namespace Structure
37{
38template<int dim, typename Number>
39class MaterialHandler
40{
41public:
42 typedef std::pair<dealii::types::material_id, std::shared_ptr<Material<dim, Number>>> Pair;
43 typedef std::map<dealii::types::material_id, std::shared_ptr<Material<dim, Number>>> Materials;
44
45 MaterialHandler() : dof_index(0)
46 {
47 }
48
49 void
50 initialize(dealii::MatrixFree<dim, Number> const & matrix_free,
51 unsigned int const dof_index,
52 unsigned int const quad_index,
53 std::shared_ptr<MaterialDescriptor const> material_descriptor,
54 bool const large_deformation)
55 {
56 this->dof_index = dof_index;
57 this->material_descriptor = material_descriptor;
58
59 for(auto iter = material_descriptor->begin(); iter != material_descriptor->end(); ++iter)
60 {
61 dealii::types::material_id id = iter->first;
62 std::shared_ptr<MaterialData> data = iter->second;
63 MaterialType type = data->type;
64
65 switch(type)
66 {
67 case MaterialType::Undefined:
68 {
69 AssertThrow(false, dealii::ExcMessage("Material type is undefined."));
70 break;
71 }
72 case MaterialType::StVenantKirchhoff:
73 {
74 std::shared_ptr<StVenantKirchhoffData<dim>> data_StVenantKirchhoff =
75 std::static_pointer_cast<StVenantKirchhoffData<dim>>(data);
76 material_map.insert(Pair(id,
77 new StVenantKirchhoff<dim, Number>(matrix_free,
78 dof_index,
79 quad_index,
80 *data_StVenantKirchhoff,
81 large_deformation)));
82 break;
83 }
84 case MaterialType::IncompressibleNeoHookean:
85 {
86 AssertThrow(
87 large_deformation == true,
88 dealii::ExcMessage(
89 "Incompressible Neo-Hookean material model defined for finite strain theory."));
90
91 std::shared_ptr<IncompressibleNeoHookeanData<dim>> data_IncompressibleNeoHookean =
92 std::static_pointer_cast<IncompressibleNeoHookeanData<dim>>(data);
93 material_map.insert(
94 Pair(id,
96 matrix_free, dof_index, quad_index, *data_IncompressibleNeoHookean)));
97 break;
98 }
99 default:
100 {
101 AssertThrow(false, dealii::ExcMessage("Specified material type is not implemented."));
102 break;
103 }
104 }
105 }
106 }
107
108 void
109 reinit(dealii::MatrixFree<dim, Number> const & matrix_free, unsigned int const cell)
110 {
111 auto mid = matrix_free.get_cell_iterator(cell, 0, dof_index)->material_id();
112
113#ifdef DEBUG
114 for(unsigned int v = 1; v < matrix_free.n_active_entries_per_cell_batch(cell); v++)
115 AssertThrow(mid == matrix_free.get_cell_iterator(cell, v)->material_id(),
116 dealii::ExcMessage("You have to categorize cells according to their materials!"));
117#endif
118
119 material = material_map[mid];
120 }
121
122 std::shared_ptr<Material<dim, Number>>
123 get_material() const
124 {
125 return material;
126 }
127
128private:
129 unsigned int dof_index;
130
131 std::shared_ptr<MaterialDescriptor const> material_descriptor;
132 Materials material_map;
133
134 // pointer to material of current cell
135 std::shared_ptr<Material<dim, Number>> material;
136};
137
138} // namespace Structure
139} // namespace ExaDG
140
141#endif /* EXADG_STRUCTURE_MATERIAL_MATERIAL_HANDLER_H_ */
Definition incompressible_neo_hookean.h:65
Definition st_venant_kirchhoff.h:65
Definition driver.cpp:33