forked from tjhei/cracks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cracks.cc
4389 lines (3491 loc) · 139 KB
/
cracks.cc
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
This code is licensed under the "GNU GPL version 2 or later". See
LICENSE file or https://www.gnu.org/licenses/gpl-2.0.html
Copyright 2013-2015: Thomas Wick and Timo Heister
*/
// Geomechanics: Crack with phase-field
// monolithic approach and a primal dual active set strategy
// Predictor-corrector mesh adaptivity
// 2d code version
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/logstream.h>
#include <deal.II/base/function.h>
#include <deal.II/base/utilities.h>
#include <deal.II/base/timer.h>
#include <deal.II/base/table_handler.h>
#include <deal.II/base/parameter_handler.h>
#include <deal.II/base/function_parser.h>
#include <deal.II/lac/block_vector.h>
#include <deal.II/lac/full_matrix.h>
#include <deal.II/lac/block_sparse_matrix.h>
#include <deal.II/lac/sparse_direct.h>
#include <deal.II/lac/constraint_matrix.h>
#include <deal.II/lac/solver_gmres.h>
#include <deal.II/grid/tria.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/grid/tria_boundary_lib.h>
#include <deal.II/grid/grid_tools.h>
#include <deal.II/grid/grid_in.h>
#include <deal.II/dofs/dof_handler.h>
#include <deal.II/dofs/dof_renumbering.h>
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/dofs/dof_tools.h>
#include <deal.II/fe/fe_q.h>
#include <deal.II/fe/fe_dgq.h>
#include <deal.II/fe/fe_dgp.h>
#include <deal.II/fe/fe_system.h>
#include <deal.II/fe/fe_values.h>
#include <deal.II/fe/mapping_q1.h>
#include <deal.II/numerics/error_estimator.h>
#include <deal.II/numerics/vector_tools.h>
#include <deal.II/numerics/matrix_tools.h>
#include <deal.II/numerics/data_out.h>
#include <deal.II/numerics/solution_transfer.h>
#include <deal.II/lac/generic_linear_algebra.h>
namespace LA
{
using namespace dealii::LinearAlgebraTrilinos;
}
#include <deal.II/distributed/tria.h>
#include <deal.II/distributed/grid_refinement.h>
#include <deal.II/distributed/solution_transfer.h>
#include <fstream>
#include <sstream>
#include <sys/stat.h> // for mkdir
#define CATCH_CONFIG_RUNNER
#include "contrib/catch.hpp"
using namespace dealii;
// For Example 3 (multiple cracks in a heterogenous medium)
// reads .pgm file and returns it as floating point values
// taken from step-42
class BitmapFile
{
public:
BitmapFile(const std::string &name);
double
get_value(const double x, const double y) const;
private:
std::vector<double> image_data;
double hx, hy;
int nx, ny;
double
get_pixel_value(const int i, const int j) const;
};
// The constructor of this class reads in the data that describes
// the obstacle from the given file name.
BitmapFile::BitmapFile(const std::string &name)
:
image_data(0),
hx(0),
hy(0),
nx(0),
ny(0)
{
std::ifstream f(name.c_str());
AssertThrow (f, ExcMessage (std::string("Can't read from file <") +
name + ">!"));
std::string temp;
getline(f, temp);
f >> temp;
if (temp[0]=='#')
getline(f, temp);
f >> nx >> ny;
AssertThrow(nx > 0 && ny > 0, ExcMessage("Invalid file format."));
for (int k = 0; k < nx * ny; k++)
{
unsigned int val;
f >> val;
image_data.push_back(val / 255.0);
}
hx = 1.0 / (nx - 1);
hy = 1.0 / (ny - 1);
}
// The following two functions return the value of a given pixel with
// coordinates $i,j$, which we identify with the values of a function
// defined at positions <code>i*hx, j*hy</code>, and at arbitrary
// coordinates $x,y$ where we do a bilinear interpolation between
// point values returned by the first of the two functions. In the
// second function, for each $x,y$, we first compute the (integer)
// location of the nearest pixel coordinate to the bottom left of
// $x,y$, and then compute the coordinates $\xi,\eta$ within this
// pixel. We truncate both kinds of variables from both below
// and above to avoid problems when evaluating the function outside
// of its defined range as may happen due to roundoff errors.
double
BitmapFile::get_pixel_value(const int i,
const int j) const
{
assert(i >= 0 && i < nx);
assert(j >= 0 && j < ny);
return image_data[nx * (ny - 1 - j) + i];
}
double
BitmapFile::get_value(const double x,
const double y) const
{
const int ix = std::min(std::max((int) (x / hx), 0), nx - 2);
const int iy = std::min(std::max((int) (y / hy), 0), ny - 2);
const double xi = std::min(std::max((x-ix*hx)/hx, 1.), 0.);
const double eta = std::min(std::max((y-iy*hy)/hy, 1.), 0.);
return ((1-xi)*(1-eta)*get_pixel_value(ix,iy)
+
xi*(1-eta)*get_pixel_value(ix+1,iy)
+
(1-xi)*eta*get_pixel_value(ix,iy+1)
+
xi*eta*get_pixel_value(ix+1,iy+1));
}
template <int dim>
class BitmapFunction : public Function<dim>
{
public:
BitmapFunction(const std::string &filename,
double x1_, double x2_, double y1_, double y2_, double minvalue_, double maxvalue_)
: Function<dim>(1),
f(filename), x1(x1_), x2(x2_), y1(y1_), y2(y2_), minvalue(minvalue_), maxvalue(maxvalue_)
{}
virtual
double value (const Point<dim> &p,
const unsigned int /*component*/) const
{
Assert(dim==2, ExcNotImplemented());
double x = (p(0)-x1)/(x2-x1);
double y = (p(1)-y1)/(y2-y1);
return minvalue + f.get_value(x,y)*(maxvalue-minvalue);
}
private:
BitmapFile f;
double x1,x2,y1,y2;
double minvalue, maxvalue;
};
// Define some tensors for cleaner notation later.
namespace Tensors
{
template <int dim>
inline Tensor<1, dim>
get_grad_pf (
unsigned int q,
const std::vector<std::vector<Tensor<1, dim> > > &old_solution_grads)
{
Tensor<1, dim> grad_pf;
grad_pf[0] = old_solution_grads[q][dim][0];
grad_pf[1] = old_solution_grads[q][dim][1];
return grad_pf;
}
template <int dim>
inline Tensor<2, dim>
get_grad_u (
unsigned int q,
const std::vector<std::vector<Tensor<1, dim> > > &old_solution_grads)
{
Tensor<2, dim> structure_continuation;
structure_continuation[0][0] = old_solution_grads[q][0][0];
structure_continuation[0][1] = old_solution_grads[q][0][1];
structure_continuation[1][0] = old_solution_grads[q][1][0];
structure_continuation[1][1] = old_solution_grads[q][1][1];
return structure_continuation;
}
template <int dim>
inline Tensor<2, dim>
get_Identity ()
{
Tensor<2, dim> identity;
identity[0][0] = 1.0;
identity[0][1] = 0.0;
identity[1][0] = 0.0;
identity[1][1] = 1.0;
return identity;
}
template <int dim>
inline Tensor<1, dim>
get_u (
unsigned int q,
const std::vector<Vector<double> > &old_solution_values)
{
Tensor<1, dim> u;
u[0] = old_solution_values[q](0);
u[1] = old_solution_values[q](1);
return u;
}
template <int dim>
inline Tensor<1, dim>
get_u_LinU (
const Tensor<1, dim> &phi_i_u)
{
Tensor<1, dim> tmp;
tmp[0] = phi_i_u[0];
tmp[1] = phi_i_u[1];
return tmp;
}
}
// Several classes for initial (phase-field) values
// Here, we prescribe initial (multiple) cracks
template <int dim>
class InitialValuesSneddon : public Function<dim>
{
public:
InitialValuesSneddon (
const double min_cell_diameter)
:
Function<dim>(dim+1)
{
_min_cell_diameter = min_cell_diameter;
}
virtual double
value (
const Point<dim> &p, const unsigned int component = 0) const;
virtual void
vector_value (
const Point<dim> &p, Vector<double> &value) const;
private:
double _min_cell_diameter;
};
template <int dim>
double
InitialValuesSneddon<dim>::value (
const Point<dim> &p, const unsigned int component) const
{
double width = _min_cell_diameter;
double height = _min_cell_diameter;///2.0;
double top = 2.0 + height;
double bottom = 2.0 - height;
// Defining the initial crack(s)
// 0 = crack
// 1 = no crack
if (component == dim)
{
if (((p(0) >= 1.8 - width) && (p(0) <= 2.2 + width))
&& ((p(1) >= bottom) && (p(1) <= top)))
return 0.0;
else
return 1.0;
}
return 0.0;
}
template <int dim>
void
InitialValuesSneddon<dim>::vector_value (
const Point<dim> &p, Vector<double> &values) const
{
for (unsigned int comp = 0; comp < this->n_components; ++comp)
values(comp) = InitialValuesSneddon<dim>::value(p, comp);
}
template <int dim>
class ExactPhiSneddon : public Function<dim>
{
public:
ExactPhiSneddon (const double eps_)
:
Function<dim>(dim+1),
eps(eps_)
{
}
virtual double
value (
const Point<dim> &p, const unsigned int component = 0) const
{
(void)component;
double dist = 0.0;
Point<dim> left(1.8, 2.0);
Point<dim> right(2.2, 2.0);
if (p(0)<1.8)
dist = left.distance(p);
else if (p(0)>2.2)
dist = right.distance(p);
else
dist=std::abs(p(1)-2.0);
return 1.0 - exp(-dist/eps);
}
private:
double eps;
};
template <int dim>
class SneddonExactPostProc : public DataPostprocessorScalar<dim>
{
public:
SneddonExactPostProc (const double eps)
:
DataPostprocessorScalar<dim> ("exact_phi", update_q_points),
exact(eps)
{}
void evaluate_vector_field (const DataPostprocessorInputs::Vector<dim> &input_data,
std::vector<Vector<double> > &computed_quantities) const
{
for (unsigned int i=0; i<computed_quantities.size(); ++i)
computed_quantities[i][0] = exact.value(input_data.evaluation_points[i]);
}
private:
ExactPhiSneddon<dim> exact;
};
// Class for initial values multiple fractures in a homogeneous material
template <int dim>
class InitialValuesMultipleHomo : public Function<dim>
{
public:
InitialValuesMultipleHomo (
const double min_cell_diameter)
:
Function<dim>(dim+1)
{
_min_cell_diameter = min_cell_diameter;
}
virtual double
value (
const Point<dim> &p, const unsigned int component = 0) const;
virtual void
vector_value (
const Point<dim> &p, Vector<double> &value) const;
private:
double _min_cell_diameter;
};
template <int dim>
double
InitialValuesMultipleHomo<dim>::value (
const Point<dim> &p, const unsigned int component) const
{
double width = _min_cell_diameter;
double height = _min_cell_diameter;
// Defining the initial crack(s)
// 0 = crack
// 1 = no crack
bool example_3 = true;
if (component == dim)
{
if (example_3)
{
// Example 3 of our paper
if (((p(0) >= 2.5 - width/2.0) && (p(0) <= 2.5 + width/2.0))
&& ((p(1) >= 0.8) && (p(1) <= 1.5)))
return 0.0;
else if (((p(0) >= 0.5) && (p(0) <= 1.5))
&& ((p(1) >= 3.0 - height/2.0) && (p(1) <= 3.0 + height/2.0)))
return 0.0;
else
return 1.0;
}
else
{
// Two parallel fractures
if (((p(0) >= 1.6 - width) && (p(0) <= 2.4 + width))
&& ((p(1) >= 2.75 - height) && (p(1) <= 2.75 + height)))
return 0.0;
else if (((p(0) >= 1.6 - width) && (p(0) <= 2.4 + width))
&& ((p(1) >= 1.25 - height) && (p(1) <= 1.25 + height)))
return 0.0;
else
return 1.0;
}
}
return 0.0;
}
template <int dim>
void
InitialValuesMultipleHomo<dim>::vector_value (
const Point<dim> &p, Vector<double> &values) const
{
for (unsigned int comp = 0; comp < this->n_components; ++comp)
values(comp) = InitialValuesMultipleHomo<dim>::value(p, comp);
}
// Class for initial values multiple fractures in a heterogeneous material
template <int dim>
class InitialValuesMultipleHet : public Function<dim>
{
public:
InitialValuesMultipleHet (
const double min_cell_diameter)
:
Function<dim>(dim+1)
{
_min_cell_diameter = min_cell_diameter;
}
virtual double
value (
const Point<dim> &p, const unsigned int component = 0) const;
virtual void
vector_value (
const Point<dim> &p, Vector<double> &value) const;
private:
double _min_cell_diameter;
};
template <int dim>
double
InitialValuesMultipleHet<dim>::value (
const Point<dim> &p, const unsigned int component) const
{
double width = _min_cell_diameter;
double height = _min_cell_diameter;
// Defining the initial crack(s)
// 0 = crack
// 1 = no crack
bool example_3 = true;
if (component == dim)
{
if (example_3)
{
// Example 3 of our paper
if (((p(0) >= 2.5 - width/2.0) && (p(0) <= 2.5 + width/2.0))
&& ((p(1) >= 0.8) && (p(1) <= 1.5)))
return 0.0;
else if (((p(0) >= 0.5) && (p(0) <= 1.5))
&& ((p(1) >= 3.0 - height/2.0) && (p(1) <= 3.0 + height/2.0)))
return 0.0;
else
return 1.0;
}
else
{
// Two parallel fractures
if (((p(0) >= 1.6 - width) && (p(0) <= 2.4 + width))
&& ((p(1) >= 2.75 - height) && (p(1) <= 2.75 + height)))
return 0.0;
else if (((p(0) >= 1.6 - width) && (p(0) <= 2.4 + width))
&& ((p(1) >= 1.25 - height) && (p(1) <= 1.25 + height)))
return 0.0;
else
return 1.0;
}
}
return 0.0;
}
template <int dim>
void
InitialValuesMultipleHet<dim>::vector_value (
const Point<dim> &p, Vector<double> &values) const
{
for (unsigned int comp = 0; comp < this->n_components; ++comp)
values(comp) = InitialValuesMultipleHet<dim>::value(p, comp);
}
template <int dim>
class InitialValuesMiehe : public Function<dim>
{
public:
InitialValuesMiehe (
const double min_cell_diameter)
:
Function<dim>(dim+1)
{
_min_cell_diameter = min_cell_diameter;
}
virtual double
value (
const Point<dim> &p, const unsigned int component = 0) const;
virtual void
vector_value (
const Point<dim> &p, Vector<double> &value) const;
private:
double _min_cell_diameter;
};
template <int dim>
double
InitialValuesMiehe<dim>::value (
const Point<dim> & /*p*/, const unsigned int component) const
{
// Defining the initial crack(s)
// 0 = crack
// 1 = no crack
if (component == dim)
{
return 1.0;
}
return 0.0;
}
template <int dim>
void
InitialValuesMiehe<dim>::vector_value (
const Point<dim> &p, Vector<double> &values) const
{
for (unsigned int comp = 0; comp < this->n_components; ++comp)
values(comp) = InitialValuesMiehe<dim>::value(p, comp);
}
// Several classes for Dirichlet boundary conditions
// for displacements for the single-edge notched test (Miehe 2010)
// Example 2a (Miehe tension)
template <int dim>
class BoundaryParabelTension : public Function<dim>
{
public:
BoundaryParabelTension (const double time)
: Function<dim>(dim+1)
{
_time = time;
}
virtual double value (const Point<dim> &p,
const unsigned int component = 0) const;
virtual void vector_value (const Point<dim> &p,
Vector<double> &value) const;
private:
double _time;
};
// The boundary values are given to component
// with number 0.
template <int dim>
double
BoundaryParabelTension<dim>::value (const Point<dim> &p,
const unsigned int component) const
{
Assert (component < this->n_components,
ExcIndexRange (component, 0, this->n_components));
double dis_step_per_timestep = 1.0;
if (component == 1)
{
return ( ((p(1) == 1.0) && (p(0) <= 1.0) && (p(0) >= 0.0))
?
(1.0) * _time *dis_step_per_timestep : 0 );
}
return 0;
}
template <int dim>
void
BoundaryParabelTension<dim>::vector_value (const Point<dim> &p,
Vector<double> &values) const
{
for (unsigned int c=0; c<this->n_components; ++c)
values (c) = BoundaryParabelTension<dim>::value (p, c);
}
// Dirichlet boundary conditions for
// Miehe's et al. shear test
// Example 2b
template <int dim>
class BoundaryParabelShear : public Function<dim>
{
public:
BoundaryParabelShear (const double time)
: Function<dim>(dim+1)
{
_time = time;
}
virtual double value (const Point<dim> &p,
const unsigned int component = 0) const;
virtual void vector_value (const Point<dim> &p,
Vector<double> &value) const;
private:
double _time;
};
// The boundary values are given to component
// with number 0.
template <int dim>
double
BoundaryParabelShear<dim>::value (const Point<dim> &p,
const unsigned int component) const
{
Assert (component < this->n_components,
ExcIndexRange (component, 0, this->n_components));
double dis_step_per_timestep = -1.0;
if (component == 0)
{
return ( ((p(1) == 1.0) )
?
(1.0) * _time *dis_step_per_timestep : 0 );
}
return 0;
}
template <int dim>
void
BoundaryParabelShear<dim>::vector_value (const Point<dim> &p,
Vector<double> &values) const
{
for (unsigned int c=0; c<this->n_components; ++c)
values (c) = BoundaryParabelShear<dim>::value (p, c);
}
template <int dim>
class BoundaryThreePoint : public Function<dim>
{
public:
BoundaryThreePoint (const double time)
: Function<dim>(dim+1)
{
_time = time;
}
virtual double value (const Point<dim> &p,
const unsigned int component = 0) const;
virtual void vector_value (const Point<dim> &p,
Vector<double> &value) const;
private:
double _time;
};
// The boundary values are given to component
// with number 0.
template <int dim>
double
BoundaryThreePoint<dim>::value (const Point<dim> &p,
const unsigned int component) const
{
Assert (component < this->n_components,
ExcIndexRange (component, 0, this->n_components));
double dis_step_per_timestep = -1.0;
if (component == 1)
{
return 1.0 * _time *dis_step_per_timestep;
}
return 0;
}
template <int dim>
void
BoundaryThreePoint<dim>::vector_value (const Point<dim> &p,
Vector<double> &values) const
{
for (unsigned int c=0; c<this->n_components; ++c)
values (c) = BoundaryThreePoint<dim>::value (p, c);
}
// Main program
template <int dim>
class FracturePhaseFieldProblem
{
public:
FracturePhaseFieldProblem (
const unsigned int degree, ParameterHandler &);
void
run ();
static void
declare_parameters (ParameterHandler &prm);
private:
void
set_runtime_parameters ();
void
determine_mesh_dependent_parameters();
void
setup_system ();
void
assemble_system (bool residual_only=false);
void
assemble_nl_residual ();
void assemble_diag_mass_matrix();
void
set_initial_bc (
const double time);
void
set_newton_bc ();
unsigned int
solve ();
double newton_active_set();
double
newton_iteration (
const double time);
double
compute_point_value (
const DoFHandler<dim> &dofh, const LA::MPI::BlockVector &vector,
const Point<dim> &p, const unsigned int component) const;
void
compute_point_stress ();
void
output_results () const;
void
compute_functional_values ();
void
compute_load();
void compute_cod_array ();
double
compute_cod (
const double eval_line);
double compute_energy();
bool
refine_mesh ();
void
project_back_phase_field ();
MPI_Comm mpi_com;
const unsigned int degree;
ParameterHandler &prm;
parallel::distributed::Triangulation<dim> triangulation;
FESystem<dim> fe;
DoFHandler<dim> dof_handler;
ConstraintMatrix constraints_update;
ConstraintMatrix constraints_hanging_nodes;
LA::MPI::BlockSparseMatrix system_pde_matrix;
LA::MPI::BlockVector solution, newton_update,
old_solution, old_old_solution, system_pde_residual;
LA::MPI::BlockVector system_total_residual;
LA::MPI::BlockVector diag_mass, diag_mass_relevant;
ConditionalOStream pcout;
TimerOutput timer;
IndexSet active_set;
Function<dim> *func_emodulus;
std::vector<IndexSet> partition;
std::vector<IndexSet> partition_relevant;
std::vector<std::vector<bool> > constant_modes;
LA::MPI::PreconditionAMG preconditioner_solid;
LA::MPI::PreconditionAMG preconditioner_phase_field;
// Global variables for timestepping scheme
unsigned int timestep_number;
unsigned int max_no_timesteps;
double timestep, timestep_size_2, time;
unsigned int switch_timestep;
struct OuterSolverType
{
enum Enum {active_set, simple_monolithic};
};
typename OuterSolverType::Enum outer_solver;
struct TestCase
{
enum Enum {sneddon_2d, miehe_tension, miehe_shear, multiple_homo, multiple_het, three_point_bending};
};
typename TestCase::Enum test_case;
struct RefinementStrategy
{
enum Enum {phase_field_ref, fixed_preref_sneddon, fixed_preref_miehe_tension,
fixed_preref_miehe_shear, fixed_preref_multiple_homo, fixed_preref_multiple_het,
global, mix, phase_field_ref_three_point_top
};
};
typename RefinementStrategy::Enum refinement_strategy;
bool direct_solver;
double force_structure_x_biot, force_structure_y_biot;
double force_structure_x, force_structure_y;
// Biot parameters
double c_biot, alpha_biot, lame_coefficient_biot, K_biot, density_biot;
double gravity_x, gravity_y, volume_source, traction_x, traction_y,
traction_x_biot, traction_y_biot;
// Structure parameters
double density_structure;
double lame_coefficient_mu, lame_coefficient_lambda, poisson_ratio_nu;
// Other parameters to control the fluid mesh motion
double cell_diameter;
FunctionParser<1> func_pressure;
double constant_k, alpha_eps,
G_c, viscosity_biot, gamma_penal;
double E_modulus, E_prime;
double min_cell_diameter, norm_part_iterations, value_phase_field_for_refinement;
unsigned int n_global_pre_refine, n_local_pre_refine, n_refinement_cycles;
double lower_bound_newton_residuum;
unsigned int max_no_newton_steps;
double upper_newton_rho;
unsigned int max_no_line_search_steps;
double line_search_damping;
double decompose_stress_rhs, decompose_stress_matrix;
std::string output_folder;
std::string filename_basis;
double old_timestep, old_old_timestep;
bool use_old_timestep_pf;
TableHandler statistics;
};
// The constructor of this class is comparable
// to other tutorials steps, e.g., step-22, and step-31.
template <int dim>
FracturePhaseFieldProblem<dim>::FracturePhaseFieldProblem (
const unsigned int degree, ParameterHandler ¶m)
:
mpi_com(MPI_COMM_WORLD),
degree(degree),
prm(param),
triangulation(mpi_com),
fe(FE_Q<dim>(degree), dim, FE_Q<dim>(degree), 1),
dof_handler(triangulation),
pcout(std::cout, (Utilities::MPI::this_mpi_process(mpi_com) == 0)),
timer(mpi_com, pcout, TimerOutput::every_call_and_summary,
TimerOutput::cpu_and_wall_times)
{
statistics.set_auto_fill_mode(true);
}
template <int dim>
void
FracturePhaseFieldProblem<dim>::declare_parameters (ParameterHandler &prm)
{
prm.enter_subsection("Global parameters");
{
prm.declare_entry("Global pre-refinement steps", "1",
Patterns::Integer(0));
prm.declare_entry("Local pre-refinement steps", "0",
Patterns::Integer(0));
prm.declare_entry("Adaptive refinement cycles", "0",
Patterns::Integer(0));
prm.declare_entry("Max No of timesteps", "1", Patterns::Integer(0));
prm.declare_entry("Timestep size", "1.0", Patterns::Double(0));
prm.declare_entry("Timestep size to switch to", "1.0", Patterns::Double(0));
prm.declare_entry("Switch timestep after steps", "0", Patterns::Integer(0));
prm.declare_entry("outer solver", "active set",
Patterns::Selection("active set|simple monolithic"));