Commit 15723204 authored by Philippe Delandmeter's avatar Philippe Delandmeter

slim3d benchmark: tilted thermocline under a constant wind stress

parent 4db36d6f
Pipeline #2402 failed with stage
in 1 minute and 34 seconds
L = 10e3;
l = 125;
Point(1) = {-L, -l, 0,500};
Point(2) = {L, -l, 0,500};
Point(3) = {L, l, 0,500};
Point(4) = {-L, l, 0,500};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line Loop(1) = {3, 4, 1, 2};
Plane Surface(1) = {1};
Transfinite Line{2} = 2;
Transfinite Line{4} = 2;
Transfinite Line{1} = 81;
Transfinite Line{3} = 81;
Mesh.Algorithm=8;
Recombine Surface{1};
Physical Surface("sea")={1};
Physical Line("coast") = {2,4};
Physical Line("cut") = {3};
Physical Line("paste") = {1};
$MeshFormat
2.2 0 8
$EndMeshFormat
$PhysicalNames
4
1 2 "coast"
1 3 "cut"
1 4 "paste"
2 1 "sea"
$EndPhysicalNames
$Nodes
162
1 -10000 -125 0
2 10000 -125 0
3 10000 125 0
4 -10000 125 0
5 -9750.00000000099 -125 0
6 -9500.000000001981 -125 0
7 -9250.00000000297 -125 0
8 -9000.00000000396 -125 0
9 -8750.000000004949 -125 0
10 -8500.000000005939 -125 0
11 -8250.000000006858 -125 0
12 -8000.000000006996 -125 0
13 -7750.000000006848 -125 0
14 -7500.000000006879 -125 0
15 -7250.000000007693 -125 0
16 -7000.000000008682 -125 0
17 -6750.000000009673 -125 0
18 -6500.000000010663 -125 0
19 -6250.000000011654 -125 0
20 -6000.000000012645 -125 0
21 -5750.000000013138 -125 0
22 -5500.000000012991 -125 0
23 -5250.000000012845 -125 0
24 -5000.000000012697 -125 0
25 -4750.000000012551 -125 0
26 -4500.000000012406 -125 0
27 -4250.000000012257 -125 0
28 -4000.000000012111 -125 0
29 -3750.000000011965 -125 0
30 -3500.000000011818 -125 0
31 -3250.000000011672 -125 0
32 -3000.000000011524 -125 0
33 -2750.000000011379 -125 0
34 -2500.000000011232 -125 0
35 -2250.000000011087 -125 0
36 -2000.000000010939 -125 0
37 -1750.000000011076 -125 0
38 -1500.000000011996 -125 0
39 -1250.000000012986 -125 0
40 -1000.000000013977 -125 0
41 -750.0000000149685 -125 0
42 -500.000000015958 -125 0
43 -250.0000000169475 -125 0
44 -1.758417056407779e-08 -125 0
45 249.9999999833453 -125 0
46 499.9999999846277 -125 0
47 749.9999999859137 -125 0
48 999.9999999871925 -125 0
49 1249.999999988479 -125 0
50 1499.999999989763 -125 0
51 1749.999999991045 -125 0
52 1999.999999992329 -125 0
53 2249.99999999361 -125 0
54 2499.999999994896 -125 0
55 2749.99999999618 -125 0
56 2999.999999997463 -125 0
57 3249.999999998745 -125 0
58 3500.000000000027 -125 0
59 3750.000000001311 -125 0
60 4000.000000002598 -125 0
61 4250.00000000388 -125 0
62 4500.000000005162 -125 0
63 4750.000000006445 -125 0
64 5000.000000007729 -125 0
65 5250.000000009015 -125 0
66 5500.000000010294 -125 0
67 5750.00000001158 -125 0
68 6000.000000012862 -125 0
69 6250.000000014146 -125 0
70 6500.000000013868 -125 0
71 6750.000000012875 -125 0
72 7000.000000011885 -125 0
73 7250.000000010896 -125 0
74 7500.000000009906 -125 0
75 7750.000000008913 -125 0
76 8000.000000007924 -125 0
77 8250.000000006934 -125 0
78 8500.000000005944 -125 0
79 8750.000000004955 -125 0
80 9000.000000003962 -125 0
81 9250.000000002972 -125 0
82 9500.000000001983 -125 0
83 9750.00000000099 -125 0
84 9750.00000000099 125 0
85 9500.000000001981 125 0
86 9250.00000000297 125 0
87 9000.00000000396 125 0
88 8750.000000004949 125 0
89 8500.000000005939 125 0
90 8250.000000006858 125 0
91 8000.000000006996 125 0
92 7750.000000006848 125 0
93 7500.000000006879 125 0
94 7250.000000007693 125 0
95 7000.000000008682 125 0
96 6750.000000009673 125 0
97 6500.000000010663 125 0
98 6250.000000011654 125 0
99 6000.000000012645 125 0
100 5750.000000013138 125 0
101 5500.000000012991 125 0
102 5250.000000012845 125 0
103 5000.000000012697 125 0
104 4750.000000012551 125 0
105 4500.000000012406 125 0
106 4250.000000012257 125 0
107 4000.000000012111 125 0
108 3750.000000011965 125 0
109 3500.000000011818 125 0
110 3250.000000011672 125 0
111 3000.000000011524 125 0
112 2750.000000011379 125 0
113 2500.000000011232 125 0
114 2250.000000011087 125 0
115 2000.000000010939 125 0
116 1750.000000011076 125 0
117 1500.000000011996 125 0
118 1250.000000012986 125 0
119 1000.000000013977 125 0
120 750.0000000149685 125 0
121 500.000000015958 125 0
122 250.0000000169475 125 0
123 1.758417056407779e-08 125 0
124 -249.9999999833453 125 0
125 -499.9999999846277 125 0
126 -749.9999999859137 125 0
127 -999.9999999871925 125 0
128 -1249.999999988479 125 0
129 -1499.999999989763 125 0
130 -1749.999999991045 125 0
131 -1999.999999992329 125 0
132 -2249.99999999361 125 0
133 -2499.999999994896 125 0
134 -2749.99999999618 125 0
135 -2999.999999997463 125 0
136 -3249.999999998745 125 0
137 -3500.000000000027 125 0
138 -3750.000000001311 125 0
139 -4000.000000002598 125 0
140 -4250.00000000388 125 0
141 -4500.000000005162 125 0
142 -4750.000000006445 125 0
143 -5000.000000007729 125 0
144 -5250.000000009015 125 0
145 -5500.000000010294 125 0
146 -5750.00000001158 125 0
147 -6000.000000012862 125 0
148 -6250.000000014146 125 0
149 -6500.000000013868 125 0
150 -6750.000000012875 125 0
151 -7000.000000011885 125 0
152 -7250.000000010896 125 0
153 -7500.000000009906 125 0
154 -7750.000000008913 125 0
155 -8000.000000007924 125 0
156 -8250.000000006934 125 0
157 -8500.000000005944 125 0
158 -8750.000000004955 125 0
159 -9000.000000003962 125 0
160 -9250.000000002972 125 0
161 -9500.000000001983 125 0
162 -9750.00000000099 125 0
$EndNodes
$Elements
242
1 1 2 4 1 1 5
2 1 2 4 1 5 6
3 1 2 4 1 6 7
4 1 2 4 1 7 8
5 1 2 4 1 8 9
6 1 2 4 1 9 10
7 1 2 4 1 10 11
8 1 2 4 1 11 12
9 1 2 4 1 12 13
10 1 2 4 1 13 14
11 1 2 4 1 14 15
12 1 2 4 1 15 16
13 1 2 4 1 16 17
14 1 2 4 1 17 18
15 1 2 4 1 18 19
16 1 2 4 1 19 20
17 1 2 4 1 20 21
18 1 2 4 1 21 22
19 1 2 4 1 22 23
20 1 2 4 1 23 24
21 1 2 4 1 24 25
22 1 2 4 1 25 26
23 1 2 4 1 26 27
24 1 2 4 1 27 28
25 1 2 4 1 28 29
26 1 2 4 1 29 30
27 1 2 4 1 30 31
28 1 2 4 1 31 32
29 1 2 4 1 32 33
30 1 2 4 1 33 34
31 1 2 4 1 34 35
32 1 2 4 1 35 36
33 1 2 4 1 36 37
34 1 2 4 1 37 38
35 1 2 4 1 38 39
36 1 2 4 1 39 40
37 1 2 4 1 40 41
38 1 2 4 1 41 42
39 1 2 4 1 42 43
40 1 2 4 1 43 44
41 1 2 4 1 44 45
42 1 2 4 1 45 46
43 1 2 4 1 46 47
44 1 2 4 1 47 48
45 1 2 4 1 48 49
46 1 2 4 1 49 50
47 1 2 4 1 50 51
48 1 2 4 1 51 52
49 1 2 4 1 52 53
50 1 2 4 1 53 54
51 1 2 4 1 54 55
52 1 2 4 1 55 56
53 1 2 4 1 56 57
54 1 2 4 1 57 58
55 1 2 4 1 58 59
56 1 2 4 1 59 60
57 1 2 4 1 60 61
58 1 2 4 1 61 62
59 1 2 4 1 62 63
60 1 2 4 1 63 64
61 1 2 4 1 64 65
62 1 2 4 1 65 66
63 1 2 4 1 66 67
64 1 2 4 1 67 68
65 1 2 4 1 68 69
66 1 2 4 1 69 70
67 1 2 4 1 70 71
68 1 2 4 1 71 72
69 1 2 4 1 72 73
70 1 2 4 1 73 74
71 1 2 4 1 74 75
72 1 2 4 1 75 76
73 1 2 4 1 76 77
74 1 2 4 1 77 78
75 1 2 4 1 78 79
76 1 2 4 1 79 80
77 1 2 4 1 80 81
78 1 2 4 1 81 82
79 1 2 4 1 82 83
80 1 2 4 1 83 2
81 1 2 2 2 2 3
82 1 2 3 3 3 84
83 1 2 3 3 84 85
84 1 2 3 3 85 86
85 1 2 3 3 86 87
86 1 2 3 3 87 88
87 1 2 3 3 88 89
88 1 2 3 3 89 90
89 1 2 3 3 90 91
90 1 2 3 3 91 92
91 1 2 3 3 92 93
92 1 2 3 3 93 94
93 1 2 3 3 94 95
94 1 2 3 3 95 96
95 1 2 3 3 96 97
96 1 2 3 3 97 98
97 1 2 3 3 98 99
98 1 2 3 3 99 100
99 1 2 3 3 100 101
100 1 2 3 3 101 102
101 1 2 3 3 102 103
102 1 2 3 3 103 104
103 1 2 3 3 104 105
104 1 2 3 3 105 106
105 1 2 3 3 106 107
106 1 2 3 3 107 108
107 1 2 3 3 108 109
108 1 2 3 3 109 110
109 1 2 3 3 110 111
110 1 2 3 3 111 112
111 1 2 3 3 112 113
112 1 2 3 3 113 114
113 1 2 3 3 114 115
114 1 2 3 3 115 116
115 1 2 3 3 116 117
116 1 2 3 3 117 118
117 1 2 3 3 118 119
118 1 2 3 3 119 120
119 1 2 3 3 120 121
120 1 2 3 3 121 122
121 1 2 3 3 122 123
122 1 2 3 3 123 124
123 1 2 3 3 124 125
124 1 2 3 3 125 126
125 1 2 3 3 126 127
126 1 2 3 3 127 128
127 1 2 3 3 128 129
128 1 2 3 3 129 130
129 1 2 3 3 130 131
130 1 2 3 3 131 132
131 1 2 3 3 132 133
132 1 2 3 3 133 134
133 1 2 3 3 134 135
134 1 2 3 3 135 136
135 1 2 3 3 136 137
136 1 2 3 3 137 138
137 1 2 3 3 138 139
138 1 2 3 3 139 140
139 1 2 3 3 140 141
140 1 2 3 3 141 142
141 1 2 3 3 142 143
142 1 2 3 3 143 144
143 1 2 3 3 144 145
144 1 2 3 3 145 146
145 1 2 3 3 146 147
146 1 2 3 3 147 148
147 1 2 3 3 148 149
148 1 2 3 3 149 150
149 1 2 3 3 150 151
150 1 2 3 3 151 152
151 1 2 3 3 152 153
152 1 2 3 3 153 154
153 1 2 3 3 154 155
154 1 2 3 3 155 156
155 1 2 3 3 156 157
156 1 2 3 3 157 158
157 1 2 3 3 158 159
158 1 2 3 3 159 160
159 1 2 3 3 160 161
160 1 2 3 3 161 162
161 1 2 3 3 162 4
162 1 2 2 4 4 1
163 3 2 1 1 162 5 6 161
164 3 2 1 1 150 17 18 149
165 3 2 1 1 71 96 97 70
166 3 2 1 1 83 84 85 82
167 3 2 1 1 17 150 151 16
168 3 2 1 1 96 71 72 95
169 3 2 1 1 5 162 4 1
170 3 2 1 1 159 8 9 158
171 3 2 1 1 9 10 157 158
172 3 2 1 1 80 87 88 79
173 3 2 1 1 78 79 88 89
174 3 2 1 1 85 86 81 82
175 3 2 1 1 83 2 3 84
176 3 2 1 1 161 6 7 160
177 3 2 1 1 159 160 7 8
178 3 2 1 1 16 151 152 15
179 3 2 1 1 95 72 73 94
180 3 2 1 1 80 81 86 87
181 3 2 1 1 157 10 11 156
182 3 2 1 1 78 89 90 77
183 3 2 1 1 153 14 15 152
184 3 2 1 1 74 93 94 73
185 3 2 1 1 149 18 19 148
186 3 2 1 1 70 97 98 69
187 3 2 1 1 156 11 12 155
188 3 2 1 1 77 90 91 76
189 3 2 1 1 127 128 39 40
190 3 2 1 1 126 127 40 41
191 3 2 1 1 47 48 119 120
192 3 2 1 1 48 49 118 119
193 3 2 1 1 148 19 20 147
194 3 2 1 1 69 98 99 68
195 3 2 1 1 128 129 38 39
196 3 2 1 1 125 126 41 42
197 3 2 1 1 46 47 120 121
198 3 2 1 1 49 50 117 118
199 3 2 1 1 124 125 42 43
200 3 2 1 1 45 46 121 122
201 3 2 1 1 129 130 37 38
202 3 2 1 1 50 51 116 117
203 3 2 1 1 154 13 14 153
204 3 2 1 1 75 92 93 74
205 3 2 1 1 123 124 43 44
206 3 2 1 1 44 45 122 123
207 3 2 1 1 155 12 13 154
208 3 2 1 1 76 91 92 75
209 3 2 1 1 146 147 20 21
210 3 2 1 1 67 68 99 100
211 3 2 1 1 130 131 36 37
212 3 2 1 1 51 52 115 116
213 3 2 1 1 145 146 21 22
214 3 2 1 1 66 67 100 101
215 3 2 1 1 131 132 35 36
216 3 2 1 1 52 53 114 115
217 3 2 1 1 140 141 26 27
218 3 2 1 1 135 136 31 32
219 3 2 1 1 56 57 110 111
220 3 2 1 1 61 62 105 106
221 3 2 1 1 143 144 23 24
222 3 2 1 1 137 138 29 30
223 3 2 1 1 58 59 108 109
224 3 2 1 1 64 65 102 103
225 3 2 1 1 144 145 22 23
226 3 2 1 1 142 143 24 25
227 3 2 1 1 139 140 27 28
228 3 2 1 1 133 134 33 34
229 3 2 1 1 54 55 112 113
230 3 2 1 1 60 61 106 107
231 3 2 1 1 63 64 103 104
232 3 2 1 1 65 66 101 102
233 3 2 1 1 141 142 25 26
234 3 2 1 1 138 139 28 29
235 3 2 1 1 136 137 30 31
236 3 2 1 1 134 135 32 33
237 3 2 1 1 132 133 34 35
238 3 2 1 1 53 54 113 114
239 3 2 1 1 55 56 111 112
240 3 2 1 1 57 58 109 110
241 3 2 1 1 59 60 107 108
242 3 2 1 1 62 63 104 105
$EndElements
fslim = open('thermocline_slim.txt', 'r')
ftheo = open('thermocline_theo.txt', 'r')
emax = 0
emean = 0
n = 0
ffact = 1/30.
h0 = 50*ffact
ls = fslim.readline()
lt = ftheo.readline()
while True:
if not ls: break
if not lt: break
(xs, ts) = (float(s) for s in ls.split(' '))
(xt, tt) = (float(s) for s in lt.split(' '))
if abs(xs-xt) > 1e-6: print("BUG here")
e = abs(ts-tt)/h0
emax = max(e, emax)
emean = emean + e
n = n+1
ls = fslim.readline()
lt = ftheo.readline()
emean = emean / n
print('emax : %g\n' % emax )
print('emean: %g\n' % emean)
from dgpy import *
import slim3d
output_dir = 'output_3D/'
lastExport = 200
mesh3d_file = output_dir+'mesh2dxz.msh'
domain = slim3d.Domain(mesh3d_file)
slimSolver = domain._slimSolver
groups3d = slimSolver.groups3d
groups2d = slimSolver.groups2d
extrusion = slimSolver.extrusion()
TDof = dgDofContainer(groups3d, 1)
zDof = dgDofContainer(groups3d, 1)
thermoclineDof = dgDofContainer(groups2d, 1)
exporter = dgIdxExporter(thermoclineDof, output_dir + '/thermocline');
feval = dgFunctionEvaluator(groups2d, thermoclineDof.getFunction())
val = fullMatrixDouble(1,1)
nPoints = 50
L = 550e3
xfact = 1e-5
ffact = -1/30.
for iExport in range(lastExport+1):
print('Computing thermocline export %003d ' % iExport)
TDof.importIdx( (output_dir+"temperature/temperature-%06d.idx" % iExport) )
zDof.importIdx( (output_dir+"z/z-%06d.idx" % iExport) )
computeThermocline(extrusion, TDof, zDof, thermoclineDof, 24.8)
exporter.exportIdx(iExport, 0)
if iExport == 70:#lastExport:
f = open('thermocline_slim.txt', 'w')
for i in range(nPoints):
x = i * L / (nPoints-1)
feval.compute(x, 0, 0, val)
f.write('%g %g\n' % (x*xfact, val.get(0,0)*ffact) )
f.close()
Msg.Exit(0)
import slimPre
import numpy as np
data_dir = 'data3d/'
slimPre.make_directory(data_dir)
mesh_file = slimPre.fetch_ftp('slim_data/tanganyika/tanga1dx.msh')
print('Extruding mesh')
def shiftOperation(node, iPerBound) :
n = [node[0], node[1] - 1e4, node[2]]
return n
cutTags = ["cut"]
pasteTags = ["paste"]
mapFilename = data_dir+"periodicMesh.txt"
periodicity = (shiftOperation, cutTags, pasteTags, mapFilename)
#mesh2d = slimPre.Mesh(mesh_file)
#region_global = slimPre.Region(mesh2d)
#xyz = region_global.coordinates
#
#bath_file_name = slimPre.fetch_ftp('slim_data/tanganyika/1d_bath.txt')
#f = open(bath_file_name, 'r');
#l = f.readline()
#data = []
#while l != '':
# (x1d, x, y, h) = [float(d) for d in l.split(',')]
# data.append([x1d, x, y, h])
# l = f.readline()
#f.close()
#data = np.array(data)
#
#bath = np.zeros((xyz.shape[0]))
#for i in range(bath.shape[0]):
# x = xyz[i,0]
# ind = np.where(x < data[:,0])[0][0]
# if ind == 0:
# print('bug')
# exit(-1)
# xsi = (x-data[ind-1,0]) / (data[ind,0]-data[ind-1,0])
# bath[i] = (1-xsi) * data[ind-1,3] + xsi * data[ind,3]
#
#slimPre.write_file(data_dir+'bath_2d.nc', region=region_global, time=None, data=[('bath',bath)])
#slimPre.netcdf_to_msh(mesh_file, data_dir+'bath_2d.nc','bath',data_dir+'bath')
h = 700
slimPre.write_file(data_dir+'bath_2d.nc', region=None, time=None, data=[('bath',h)])
zLayers = [0, 2, 5]
zLayers += [10 * h for h in range(1, 11)]
zLayers += [150, 200, 300, 500, 700, 950, 1200, 1400, 1500]
mesh3d_file = data_dir+'tanga2dxz.msh'
slimPre.extrude(mesh_file, (data_dir+'bath_2d.nc','bath'), z_layers=zLayers, mesh_file_name_out=mesh3d_file, factor_show=200, periodicity=periodicity)
print('Loading 3D mesh')
mesh = slimPre.Mesh(mesh3d_file)
region_global = slimPre.Region(mesh)
#print('Preprocessing Coriolis')
#Tday = 0.99726968*24*60*60; # sidereal time of Earth revolution
#OmegaEarth = 2*np.pi/Tday
#latDeg = -6.2
#phi = (np.pi/180)*latDeg # latitude in radians
#corio = 2*OmegaEarth*np.sin(phi) # // [rad/s] Coriolis parameter
#slimPre.write_file(data_dir+'coriolis.nc',None,None,[('coriolis',corio)])
#print('Fixed viscosity')
#import dgpy
#shear = np.array([5, 5, 5, 1])/1e3
#groups = mesh._groups
#data = dgpy.fullMatrixDouble()
#dof = dgpy.dgDofContainer(groups, 1)
#dof_copy = dgpy.dgDofContainer(groups, 1)
#dof.setAll(0)
#for iFaceGroup in range(groups.getNbFaceGroups()):
# faceGroup = groups.getFaceGroup(iFaceGroup)
# if faceGroup.physicalTag() == 'vertical_bottom' or faceGroup.physicalTag() == 'bottom_sea':
# iGroup = groups.getElementGroupId(faceGroup.elementGroup(0))
# for iFace in range(faceGroup.size()):
# iElem = faceGroup.elementId(iFace, 0)
# dof.getElementProxy(iGroup, iElem, data)
# data.setAll(shear[0])
#data0 = dgpy.fullMatrixDouble()
#data1 = dgpy.fullMatrixDouble()
#for i in range(len(shear)-1):
# dof_copy.copy(dof)
# for iFaceGroup in range(groups.getNbFaceGroups()):
# faceGroup = groups.getFaceGroup(iFaceGroup)
# if faceGroup.nConnection() == 2:
# iGroup0 = groups.getElementGroupId(faceGroup.elementGroup(0))
# iGroup1 = groups.getElementGroupId(faceGroup.elementGroup(1))
# for iFace in range(faceGroup.size()):
# iElem0 = faceGroup.elementId(iFace, 0)
# iElem1 = faceGroup.elementId(iFace, 1)
# dof_copy.getElementProxy(iGroup0, iElem0, data0)
# dof.getElementProxy(iGroup1, iElem1, data1)
# if data0.get(0,0) > 1e-10 and data1.get(0,0) < 1e-10:
# data1.setAll(shear[i+1])