-
Notifications
You must be signed in to change notification settings - Fork 3
/
Miyauchi_shear.h
executable file
·328 lines (279 loc) · 11.6 KB
/
Miyauchi_shear.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#include <deal.II/grid/tria.h>
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/manifold_lib.h>
#include <iostream>
#include <fstream>
#include <cmath>
#include "../MA-Code/enumerator_list.h"
using namespace dealii;
namespace Miyauchi_shear
/*
* A Miyauchi specimen for shearing
*
* CERTIFIED TO STANDARD numExS07 (200724)
*/
{
// Name of the numerical example
std::string numEx_name = "Miyauchi_shear";
// The loading direction: \n
// In which coordinate direction the load shall be applied, so x/y/z.
const unsigned int loading_direction = enums::x;
// Evaluation point
Point<3> eval_point;
// The loaded faces:
const enums::enum_boundary_ids id_boundary_load = enums::id_boundary_xPlus2;
const enums::enum_boundary_ids id_boundary_secondaryLoad = enums::id_boundary_none;
// Characteristic body dimensions
std::vector<double> body_dimensions (5);
// Some internal parameters
struct parameterCollection
{
const types::manifold_id manifold_id_left_radius = 10;
const types::manifold_id manifold_id_right_radius = 11;
const double search_tolerance = 1e-12;
};
template<int dim>
void make_constraints ( AffineConstraints<double> &constraints, const FESystem<dim> &fe, DoFHandler<dim> &dof_handler_ref,
const bool &apply_dirichlet_bc, double ¤t_load_increment,
const Parameter::GeneralParameters ¶meter )
{
// on yPlus plane constrain y dofs (symmetry BC)
numEx::BC_apply( enums::id_boundary_yPlus, enums::y, 0, apply_dirichlet_bc, dof_handler_ref, fe, constraints );
// on xPlus1 plane constrain x dofs
numEx::BC_apply( enums::id_boundary_xPlus1, enums::x, 0, apply_dirichlet_bc, dof_handler_ref, fe, constraints );
// on xMinus1 plane constrain x dofs
if ( false ) //guide_left_end
numEx::BC_apply( enums::id_boundary_xMinus1, enums::x, 0, apply_dirichlet_bc, dof_handler_ref, fe, constraints );
// BC for the load ...
if ( parameter.driver == enums::Dirichlet ) // ... as Dirichlet only for Dirichlet as driver
numEx::BC_apply( id_boundary_load, loading_direction, current_load_increment, apply_dirichlet_bc, dof_handler_ref, fe, constraints );
}
template <int dim>
void make_half_grid( Triangulation<dim> &triangulation )
{
const double widthX = 81.25;
const double heightY_half = 65./2.;
const double widthX_notch = 15.;
const double radius_notch = 3./2.;
const double width_innerPlate = (widthX_notch/2. + radius_notch);
// The points that span the left lower brick
Point<dim> p1 (-widthX/2.,-heightY_half/2.);
Point<dim> p2 (-width_innerPlate, -radius_notch*2.);
Triangulation<2> tria_brick_leftlow;
GridGenerator::subdivided_hyper_rectangle ( tria_brick_leftlow,
{8,4},
p1,
p2
);
// The points that span the left lower match brick
Point<dim> p11 (p1[enums::x], p2[enums::y]);
Point<dim> p21 (p2[enums::x], -radius_notch);
Triangulation<2> tria_brickMatch_leftlow;
GridGenerator::subdivided_hyper_rectangle ( tria_brickMatch_leftlow,
{8,1},
p11,
p21
);
// The points that span the left upper brick
Point<dim> p3 (p1[enums::x],-p1[enums::y]);
Point<dim> p4 (p2[enums::x],-p2[enums::y]);
Triangulation<2> tria_brick_leftup;
GridGenerator::subdivided_hyper_rectangle ( tria_brick_leftup,
{8,4},
p3,
p4
);
// The points that span the left lower match brick
Point<dim> p31 (p11[enums::x], -p11[enums::y]);
Point<dim> p41 (p21[enums::x], -p21[enums::y]);
Triangulation<2> tria_brickMatch_leftup;
GridGenerator::subdivided_hyper_rectangle ( tria_brickMatch_leftup,
{8,1},
p31,
p41
);
// Left half plate with hole
Point<dim> centre_left ( -width_innerPlate, 0 );
const types::manifold_id polar_manifold_id = 0;
const types::manifold_id tfi_manifold_id = 1;
Triangulation<2> tria_plateWithHole_left;
// Create the full plate with hole
GridGenerator::plate_with_a_hole ( tria_plateWithHole_left,
/*inner radius*/radius_notch,
/*outer radius*/2*radius_notch, //width_innerPlate,
/*pad bottom */(heightY_half-4.*radius_notch)/2.,
/*pad top */(heightY_half-4.*radius_notch)/2.,
/*pad left */0.,
/*pad right */width_innerPlate-2.*radius_notch,
centre_left,
polar_manifold_id,
tfi_manifold_id
);
// Remove the left part of the plate for the left half plate
Triangulation<2> tria_HalfPlateWithHole_left;
std::set<typename Triangulation<dim>::active_cell_iterator > cells_to_remove;
for (typename Triangulation<2>::active_cell_iterator
cell = tria_plateWithHole_left.begin_active();
cell != tria_plateWithHole_left.end(); ++cell)
{
// Remove all cells that are not in the first quadrant
if (cell->center()[enums::x] < centre_left[enums::x] )
cells_to_remove.insert(cell);
}
Assert(cells_to_remove.size() > 0, ExcInternalError());
Assert(cells_to_remove.size() != tria_plateWithHole_left.n_active_cells(), ExcInternalError());
GridGenerator::create_triangulation_with_removed_cells(tria_plateWithHole_left,cells_to_remove,tria_HalfPlateWithHole_left);
// Merge the left parts
GridGenerator::merge_triangulations( {&tria_brick_leftup, &tria_brickMatch_leftup, &tria_HalfPlateWithHole_left, &tria_brickMatch_leftlow, &tria_brick_leftlow},
triangulation,
1.0e-10,
true );
}
// 2D grid
template <int dim>
void make_grid( Triangulation<2> &triangulation, const Parameter::GeneralParameters ¶meter )
{
// ToDo-assure: the use the values from the parameter file
const double widthX = 81.25;
const double heightY_half = 65./2.;
const double widthX_notch = 15.;
const double radius_notch = 3./2.;
const double width_innerPlate = (widthX_notch/2. + radius_notch);
body_dimensions[enums::x] = widthX;
body_dimensions[enums::y] = heightY_half;
// // Set the evaluation point
// if ( loading_direction == enums::y )
// {
// eval_point[enums::x] = body_dimensions[enums::x];
// eval_point[enums::y] = body_dimensions[enums::y];
// }
// else if ( loading_direction == enums::x )
// {
// eval_point[enums::x] = body_dimensions[enums::x];
// eval_point[enums::y] = body_dimensions[enums::y]/2.;
// }
parameterCollection parameters_internal;
const double search_tolerance = parameters_internal.search_tolerance;
Triangulation<dim> tria_left, tria_right;
make_half_grid( tria_left );
make_half_grid( tria_right );
// @todo-optimize Better use function transform instead of rotate
GridTools::rotate(std::atan(1) * 4./*180 degrees*/, tria_right);
// Merge the left and right part
GridGenerator::merge_triangulations( {&tria_left, &tria_right},
triangulation,
1.0e-10,
true );
if ( true ) // remove the left inner part
{
std::set<typename Triangulation<dim>::active_cell_iterator > cells_to_remove;
for (typename Triangulation<2>::active_cell_iterator
cell = triangulation.begin_active();
cell != triangulation.end(); ++cell)
{
// Remove all cells that are not in the first quadrant
if ( cell->center()[enums::x] < -width_innerPlate && cell->center()[enums::y] > 0 )
cells_to_remove.insert(cell);
}
Assert(cells_to_remove.size() > 0, ExcInternalError());
Assert(cells_to_remove.size() != triangulation.n_active_cells(), ExcInternalError());
GridGenerator::create_triangulation_with_removed_cells(triangulation,cells_to_remove,triangulation);
}
// Clear all existing boundary ID's
numEx::clear_boundary_IDs( triangulation );
//Set boundary IDs and and manifolds
for (typename Triangulation<dim>::active_cell_iterator
cell = triangulation.begin_active();
cell != triangulation.end(); ++cell)
{
for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
if (cell->face(face)->at_boundary())
{
// Set boundary IDs
if ( std::abs(cell->face(face)->center()[enums::x] - body_dimensions[enums::x]/2.) < search_tolerance )
{
if ( cell->face(face)->center()[enums::y] > 0 )
{
cell->face(face)->set_boundary_id(enums::id_boundary_xPlus2);
}
else
{
cell->face(face)->set_boundary_id(enums::id_boundary_xPlus1);
}
}
else if (std::abs(cell->face(face)->center()[enums::y] - body_dimensions[enums::y]/2.) < search_tolerance )
{
cell->face(face)->set_boundary_id(enums::id_boundary_yPlus);
}
else if ( std::abs(cell->face(face)->center()[enums::x] + body_dimensions[enums::x]/2.) < search_tolerance )
{
if ( cell->face(face)->center()[enums::y] > 0 )
{
cell->face(face)->set_boundary_id(enums::id_boundary_xMinus2);
}
else
{
cell->face(face)->set_boundary_id(enums::id_boundary_xMinus1);
}
}
}
}
// Attach the notch radius manifolds
{
Point<dim> centre_left ( -width_innerPlate, 0 );
Point<dim> centre_right ( width_innerPlate, 0 );
for (typename Triangulation<dim>::active_cell_iterator
cell = triangulation.begin_active();
cell != triangulation.end(); ++cell)
{
for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
if ( cell->face(face)->at_boundary() && std::abs( cell->face(face)->center()[enums::x] ) < width_innerPlate )
for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_face; ++vertex)
{
if ( std::abs( (cell->face(face)->vertex(vertex)).distance(centre_left) - radius_notch ) < search_tolerance )
{
cell->face(face)->set_all_manifold_ids(parameters_internal.manifold_id_left_radius);
}
else if ( std::abs( (cell->face(face)->vertex(vertex)).distance(centre_right) - radius_notch ) < search_tolerance )
{
cell->face(face)->set_all_manifold_ids(parameters_internal.manifold_id_right_radius);
}
}
}
// For the upper radius
static SphericalManifold<dim> spherical_manifold_left (centre_left);
triangulation.set_manifold(parameters_internal.manifold_id_left_radius,spherical_manifold_left);
// For the lower radius
static SphericalManifold<dim> spherical_manifold_right (centre_right);
triangulation.set_manifold(parameters_internal.manifold_id_right_radius,spherical_manifold_right);
}
triangulation.refine_global(parameter.nbr_global_refinements); // ... Parameter.prm file
// local refinements
{
for ( unsigned int nbr_local_ref=0; nbr_local_ref<parameter.nbr_holeEdge_refinements; nbr_local_ref++ )
{
for (typename Triangulation<dim>::active_cell_iterator
cell = triangulation.begin_active();
cell != triangulation.end(); ++cell)
{
// Find all cells that lay in an exemplary damage band with size 1.5 mm from the y=0 face
if ( std::abs( cell->center()[enums::x] ) < width_innerPlate && std::abs( cell->center()[enums::y] ) < 2*radius_notch )
cell->set_refine_flag();
}
triangulation.execute_coarsening_and_refinement();
}
}
// numEx::output_triangulation(triangulation,enums::output_eps,numEx_name);
}
// 3d grid
template <int dim>
void make_grid( Triangulation<3> &triangulation, const Parameter::GeneralParameters ¶meter )
{
std::cout << "number of active cells: " << triangulation.n_active_cells() << std::endl;
std::cout << "Chosen numerical example: " << parameter.numExample << std::endl;
AssertThrow(false, ExcMessage("Miyauchi_shear<< not yet implemented for 3D."));
}
}