-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathTutorial07_2_PhaseFieldProblemHomogenized.m
More file actions
130 lines (107 loc) · 3.77 KB
/
Copy pathTutorial07_2_PhaseFieldProblemHomogenized.m
File metadata and controls
130 lines (107 loc) · 3.77 KB
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
classdef Tutorial07_2_PhaseFieldProblemHomogenized < handle
properties (Access = public)
initialGuess
output
end
properties (Access = private)
mesh
boundaryConditions
mat
dissipation
functional
end
methods (Access = public)
function obj = Tutorial07_2_PhaseFieldProblemHomogenized()
obj.init()
obj.defineCase();
obj.createInitialGuess();
obj.createMaterialPhaseField();
obj.createDissipationInterpolation();
obj.createPhaseFieldFunctional()
obj.solvePhaseFieldProblem()
end
end
methods (Access = private)
function init(obj)
close all;
end
function defineCase(obj)
s.mesh.type = '1Elem';
s.bc.type = 'DisplacementTractionY';
s.bc.values = [0:0.001:0.1];
[obj.mesh, obj.boundaryConditions] = BenchmarkManager.create(s);
end
function createInitialGuess(obj)
u = LagrangianFunction.create(obj.mesh,2,'P1');
phi = LagrangianFunction.create(obj.mesh,1,'P1');
%phi = obj.setInitialDamage(phi);
obj.initialGuess.phi = obj.createDamageVariable(phi);
obj.initialGuess.u = u;
end
function phi = setInitialDamage(obj,phi)
isInMiddle = obj.mesh.coord(:,1)>=0.5 & obj.mesh.coord(:,2)==0.5;
fValues = phi.fValues;
fValues(isInMiddle) = 0.01;
phi.setFValues(fValues);
end
function phi = createDamageVariable(obj,phi)
s.type = 'Damage';
s.mesh = phi.mesh;
s.fun = phi;
phi = DesignVariable.create(s);
end
function createPhaseFieldFunctional(obj)
s.energySplit = false;
s.C = obj.mat.C;
s.dC = obj.mat.dC;
s.d2C = obj.mat.d2C;
s.mesh = obj.mesh;
s.dissipation = obj.dissipation;
s.l0 = 0.1;
s.quadOrder = 2;
s.testSpace.u = obj.initialGuess.u;
s.testSpace.phi = obj.initialGuess.phi.fun;
obj.functional = PhaseFieldFunctional(s);
end
function createMaterialPhaseField(obj)
s.fileName = 'CirclePerimeter';
s.mesh = obj.mesh;
s.young = 210;
hm = HomogenizedMaterialsReader(s);
obj.mat.C = @(phi) hm.obtainTensor(phi);
obj.mat.dC = @(phi) hm.obtainTensorDerivative(phi);
obj.mat.d2C = @(phi) hm.obtainTensorSecondDerivative(phi);
end
function createDissipationInterpolation(obj)
s.mesh = obj.mesh;
s.pExp = 2;
Gc = 5e-3;
if s.pExp == 1
cw = 1/2;
elseif s.pExp == 2
cw = 2/3;
end
obj.dissipation.interpolation = PhaseFieldDissipationInterpolator(s);
obj.dissipation.constant = Gc/(4*cw);
end
function solvePhaseFieldProblem(obj)
s.mesh = obj.mesh;
s.initialGuess = obj.initialGuess;
s.boundaryConditions = obj.boundaryConditions;
s.functional = obj.functional;
s.monitoring.set = true;
s.monitoring.type = 'full';
s.monitoring.print = true;
s.tolerance.u = 1e-13;
s.tolerance.phi = 1e-6;
s.tolerance.stag = 1e-6;
s.maxIter.u = 100;
s.maxIter.phi = 300;
s.maxIter.stag = 300;
s.solver.type = 'Gradient';
s.solver.tau = 150;
PFComp = PhaseFieldComputer(s);
obj.output = PFComp.compute();
end
end
end