-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
650 lines (592 loc) · 24.6 KB
/
index.html
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
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="static/css/bootstrap.min.css">
<link rel="stylesheet" href="static/css/app.css">
<link rel="stylesheet" href="static/css/dashboard.css">
<script src="static/js/jquery.min.js"></script>
<script src="static/js/popper.min.js"></script>
<!-- <script src="js/Chart.bundle.min.js"></script> -->
<script src="static/js/bootstrap.min.js"></script>
<script src="static/js/svg.min.js"></script>
<script src="static/js/three.min.js"></script>
<script src="static/js/OrbitControls.js"></script>
<script src="static/js/data2blob.js"></script>
<script src="static/js/pdfkit.standalone.js"></script>
<script src="static/js/svg-to-pdfkit.js"></script>
<link rel="icon" type="image/png" sizes="32x32" href="static/img/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="static/img/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="static/img/favicon-16x16.png">
<!-- <script src="js/CSS3DRenderer.js"></script> -->
<!-- <script async src="mathjax/MathJax.js"></script> -->
<title>FreeFEM</title>
</head>
<body>
<nav class="navbar navbar-dark fixed-top bg-dark flex-md-nowrap p-0 shadow">
<button class="btn btn-outline-dark btn-sm" type="button" id="mytoggle">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand col-md-12 mr-0" href="/">
FreeFEM
</a>
</nav>
<div class="container-fluid">
<div class="row">
<nav class="col-md-2 d-none d-md-block bg-light sidebar">
<div class="sidebar-sticky">
<div class="dropdown">
</div>
<form id="control" class="controlbox nav flex-column" onsubmit="event.preventDefault()">
<div id="2d_control">
<h6>Preference</h6>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="mesh" checked>
<label class="form-check-label" for="mesh">mesh</label>
</div>
<div class="form-group form-check subcheck">
<input type="checkbox" class="form-check-input" id="tri_index">
<label class="form-check-label" for="tri_index">index of triangles</label>
</div>
<div class="form-group form-check subcheck">
<input type="checkbox" class="form-check-input" id="ver_index">
<label class="form-check-label" for="ver_index">index of vertices</label>
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="edg_label">
<label class="form-check-label" for="edg_label">label of edges</label>
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="level" checked>
<label class="form-check-label" for="level">isoline</label>
</div>
<div class="form-group form-check">
<label for="nbiso">Number of isovalues</label>
<input type="number" class="form-control" id="nbiso" value="15">
</div>
<div class="form-group form-check subcheck">
<input type="checkbox" class="form-check-input" id="colorbar" checked>
<label class="form-check-label" for="colorbar">colorbar</label>
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="svg">
<label class="form-check-label" for="svg">Preview in SVG</label>
</div>
<h6>Download</h6>
<div class="btn-group" role="group" aria-label="Basic example" id="2d_download_btn">
<a href="#" class="btn btn-outline-primary" id="2dsvg">SVG</a>
<a href="#" class="btn btn-outline-primary" id="2dpng">PNG</a>
<a href="#" class="btn btn-outline-primary" id="2dpdf">PDF</a>
</div>
</div>
<div id="3d_control" style="display: none;">
<h6>Preference</h6>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="mesh3d">
<label class="form-check-label" for="mesh3d">mesh</label>
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="wireframe">
<label class="form-check-label" for="wireframe">wireframe</label>
</div>
<div class="form-group form-check mesh3">
<input type="checkbox" class="form-check-input" id="intersec_check">
<label for="intersection">intersection</label><br>
<label for="intersection_x">x</label>
<input type="range" class="custom-range" min="-1" max="1" step="0.01" value="1"
id="intersection_x">
<label for="intersection_y">y</label>
<input type="range" class="custom-range" min="-1" max="1" step="0.01" value="1"
id="intersection_y">
<label for="intersection_z">z</label>
<input type="range" class="custom-range" min="-1" max="1" step="0.01" value="1"
id="intersection_z">
</div>
<h6>Set View</h6>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="axes3d">
<label class="form-check-label" for="axes3d">axes</label>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-outline-secondary"
onclick="view(0,0,frustumSize)">XY</button>
<button type="button" class="btn btn-outline-secondary"
onclick="view(frustumSize,0,0)">YZ</button>
<button type="button" class="btn btn-outline-secondary"
onclick="view(0,frustumSize,0)">XZ</button>
</div>
<br>
<br>
<h6>Download</h6>
<div class="btn-group" role="group" id="3d_download_btn">
<a href="#" class="btn btn-outline-primary" id="3dpng">PNG</a>
</div>
</div>
</form>
</div>
</nav>
<main role="main" class="col-md-10 ml-sm-auto px-4 dashboard">
<div id="dashboard_new" class="">
<div class="row plot_title">
<div class="d-flex flex-column flex-fill align-items-left">
<h6>Output</h6>
<h6 class="text-muted" id="comment"></h6>
</div>
<div class="d-flex justify-content-end align-items-center">
<nav aria-label="Page navigation example">
<ul class="pagination" id="img-select">
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li class="page-item">
<a class="page-link" href="#" onclick="previous()">Previous</a>
</li>
<li class="page-item">
<a class="page-link" href="#" onclick="goto()" id="nowpage">1/1</a>
</li>
<li class="page-item">
<a class="page-link" href="#" onclick="next()">Next</a>
</li>
<li class="page-item">
<a class="page-link" href="#" onclick="play()" id="play">Play</a>
</li>
</ul>
</nav>
<button type="button" class="btn btn-outline-secondary" id="3dstart"
style="margin-left: 10px;">2D</button>
</ul>
</nav>
</div>
</div>
<div id="new_plot" style="text-align: center"></div>
</div>
<div class="d-flex justify-content-center mypage">
</div>
</main>
</div>
</div>
</body>
<script>
var mesh_data = [];
var vertex_data = [];
var edge_data = [];
var minmax_data = 0;
var basic_data = 0;
var cmm_data;
var pause = 1;
var preview = 1;
var cprofile1 = ["#0000ff", "#00ffff", "#00ff00", "#ffff00", "#ff0000"];
var cprofile2 = ["#112F41", "#0894A1", "#47AB6C", "#F2B134", "#ED553B"];
var cprofile3 = ["#955BA5", "#2D95BF", "#4EBA6F", "#F0C419", "#F15A5A"];
var cprofile = cprofile3;
var now_file = 1;
var total_file = 0;
var is_now_MPI = 0;
var refresh = 0;
var url = new URL(window.location.href);
function play() {
if (pause) {
pause = 0;
$("#play").text('Pause');
} else {
pause = 1;
$("#play").text('Play');
}
}
function reload() {
$.when(mesh_ajax(), vertex_ajax(), edge_ajax()).done(function () {
if ($("#3dstart").text() == '2D') {
mydraw2d();
} else {
if (basic_data['type'] == 'Mesh3') {
mydraw3dmesh();
}else if (basic_data['type'] == 'MeshS') {
mydraw3dmeshS();
} else {
mydraw3d();
}
}
$("#nowpage").text(now_file + '/' + total_file);
})
}
function mpi_reload() {
mesh_data = [];
vertex_data = [];
edge_data = [];
minmax_data = 0;
var promiseArr = [];
for (var i = 0; i < mpisize; i++) {
var promise = new Promise(function (resolve, reject) {
(function (index) {
$.when(mpi_mesh_ajax(index), mpi_vertex_ajax(index), mpi_edge_ajax(index)).done(function () {
resolve('outputIfany');
})
})(i + 1);
});
promiseArr.push(promise);
}
Promise.all(promiseArr).then(function (values) {
if ($("#3dstart").text() == '2D') {
mydraw2d();
} else {
if (basic_data['type'] == 'Mesh3') {
mydraw3dmesh();
} else {
mydraw3d();
}
}
$("#nowpage").text(now_file + '/' + total_file);
});
}
function mesh_ajax() {
return $.ajax({
url: './static/cache/mesh' + now_file + '.json.gz',
cache: false,
type: 'GET',
}).done((m) => {
// console.log(m);
mesh_data = m.mesh;
}).fail((xhr, status, error) => {
console.log("Status: " + status + " Error: " + error);
console.log(xhr);
})
}
function vertex_ajax() {
return $.ajax({
url: './static/cache/vertex' + now_file + '.json.gz',
cache: false,
type: 'GET'
}).done((m) => {
// console.log(m);
vertex_data = m.position;
minmax_data = m.minmax;
cmm_data = m.cmm;
if (cmm_data) {
$("#comment").text(cmm_data);
}
}).fail((xhr, status, error) => {
console.log("Status: " + status + " Error: " + error);
console.log(xhr);
})
}
function edge_ajax() {
return $.ajax({
url: './static/cache/edge' + now_file + '.json.gz',
cache: false,
type: 'GET'
}).done((m) => {
// console.log(m);
edge_data = m.edge;
}).fail((xhr, status, error) => {
console.log("Status: " + status + " Error: " + error);
console.log(xhr);
})
}
function mpi_mesh_ajax(mpirank) {
return $.ajax({
url: './static/cache/mesh' + now_file + '_' + mpirank + '.json.gz',
cache: false,
type: 'GET'
}).done((m) => {
var meshori = mesh_data.length;
mesh_data.length = meshori + m.mesh.length;
for (let index = 0; index < m.mesh.length; index++) {
mesh_data[meshori + index] = m.mesh[index];
}
}).fail((xhr, status, error) => {
console.log("Status: " + status + " Error: " + error);
console.log(xhr);
})
}
function mpi_vertex_ajax(mpirank) {
return $.ajax({
url: './static/cache/vertex' + now_file + '_' + mpirank + '.json.gz',
cache: false,
type: 'GET'
}).done((m) => {
var vertexori = vertex_data.length;
vertex_data.length = vertexori + m.position.length;
for (let index = 0; index < m.position.length; index++) {
vertex_data[vertexori + index] = m.position[index];
}
if (minmax_data == 0) {
minmax_data = m.minmax;
} else {
if (m.minmax[0]['u'] <= minmax_data[0]['u']) {
minmax_data[0] = m.minmax[0];
}
if (m.minmax[1]['u'] >= minmax_data[1]['u']) {
minmax_data[1] = m.minmax[1];
}
}
if (mpirank == 1) {
cmm_data = m.cmm;
if (cmm_data) {
$("#comment").text(cmm_data);
}
}
}).fail((xhr, status, error) => {
console.log("Status: " + status + " Error: " + error);
console.log(xhr);
})
}
function mpi_edge_ajax(mpirank) {
return $.ajax({
url: './static/cache/edge' + now_file + '_' + mpirank + '.json.gz',
cache: false,
type: 'GET'
}).done((m) => {
var edgeori = edge_data.length;
edge_data.length = edgeori + m.edge.length;
for (let index = 0; index < m.edge.length; index++) {
edge_data[edgeori + index] = m.edge[index];
}
}).fail((xhr, status, error) => {
console.log("Status: " + status + " Error: " + error);
console.log(xhr);
})
}
function mpi_basic_ajax(mpirank) {
return $.ajax({
url: './static/cache/basic' + now_file + '_' + mpirank + '.json.gz',
cache: false,
type: 'GET'
}).done((m) => {
// console.log(m);
if (basic_data == 0) {
basic_data = m;
} else {
for (let i = 0; i < m.bounds[0].length; i++) {
if (m.bounds[0][i] <= basic_data.bounds[0][i]) {
basic_data.bounds[0][i] = m.bounds[0][i];
}
if (m.bounds[1][i] >= basic_data.bounds[1][i]) {
basic_data.bounds[1][i] = m.bounds[1][i];
}
}
}
}).fail((xhr, status, error) => {
console.log("Status: " + status + " Error: " + error);
console.log(xhr);
})
}
function basic_ajax() {
return $.ajax({
url: './static/cache/basic' + now_file + '.json.gz',
cache: false,
type: 'GET'
}).done((m) => {
console.log(m);
refresh = 1;
if (m["mpi"] == "True") {
mpisize = m.size;
is_now_MPI = 1;
var promiseArr = [];
for (var i = 0; i < mpisize; i++) {
var promise = new Promise(function (resolve, reject) {
(function (index) {
$.when(mpi_basic_ajax(index)).done(function () {
resolve('outputIfany');
})
})(i + 1);
});
promiseArr.push(promise);
}
Promise.all(promiseArr).then(function (values) {
if (m["type"] == "Mesh") {
$("#canvas_3d").remove();
init();
animate();
mpi_reload();
if ($('#3dstart').text() == '2D') {
$("#canvas_3d").hide();
}
var query_view = url.searchParams.get("v");
if (query_view !== null) {
if (query_view == "3d") {
switch3d();
}
}
} else if (m["type"] == "Mesh3") {
$("#canvas_3d").remove();
init();
animate();
mpi_reload();
if ($('#3dstart').text() == '2D') {
$("#canvas_3d").hide();
}
switch3d();
}
});
} else {
is_now_MPI = 0;
basic_data = m;
if (m["type"] == "Mesh") {
$("#canvas_3d").remove();
init();
animate();
reload();
if ($('#3dstart').text() == '2D') {
$("#canvas_3d").hide();
}
var query_view = url.searchParams.get("v");
if (query_view !== null) {
if (query_view == "3d") {
switch3d();
}
}
} else if (m["type"] == "Mesh3" ) {
$("#canvas_3d").remove();
init();
animate();
reload();
if ($('#3dstart').text() == '2D') {
$("#canvas_3d").hide();
}
switch3d();
} else if (m["type"] == "MeshS") {
$("#canvas_3d").remove();
init();
animate();
reload();
if ($('#3dstart').text() == '2D') {
$("#canvas_3d").hide();
}
switch3d();
}
}
}).fail((xhr, status, error) => {
console.log("Status: " + status + " Error: " + error);
console.log(xhr);
})
}
function get_picnum_ajax() {
return $.ajax({
url: './total_temp',
cache: false,
type: 'GET'
}).done((m) => {
total_file = m.total;
$("#nowpage").text(now_file + '/' + total_file);
}).fail((xhr, status, error) => {
console.log("Status: " + status + " Error: " + error);
console.log(xhr);
})
}
function setnowpage(page) {
if (now_file !== page) {
refresh = 1;
now_file = page;
url.searchParams.set('p', page);
window.history.replaceState(null, null, url);
if (is_now_MPI == 1) {
mpi_reload();
} else {
reload();
}
}
}
function next() {
var temp_now_file = now_file + 1;
if (temp_now_file >= total_file) {
temp_now_file = total_file;
}
setnowpage(temp_now_file);
}
function previous() {
var temp_now_file = now_file - 1;
if (temp_now_file <= 0) {
temp_now_file = 1;
}
setnowpage(temp_now_file);
}
function goto() {
var page = Number(prompt('Go to figure', now_file));
setnowpage(page);
}
function switch3d() {
if ($("#3dstart").text() == '3D') {
//2D mode
$("#3dstart").text('2D');
$("#canvas_3d").hide();
$("#new_plot").children("svg").show();
$('#2d_control').show();
$('#3d_control').hide();
// mydraw2d();
// disenable camera orbit control
controls.enabled = false;
url.searchParams.set('v', "2d");
} else {
// init();
// animate();
//3D mode
$("#3dstart").text('3D');
$("#new_plot").children('svg').hide();
$("#canvas_2d").hide();
$("#canvas_3d").show();
$('#2d_control').hide();
$('#3d_control').show();
if (basic_data['type'] != 'Mesh3') {
$('.mesh3').hide();
}
// mydraw3d();
// enable camera orbit control
controls.enabled = true;
url.searchParams.set('v', "3d");
}
window.history.replaceState(null, null, url)
}
$(document).ready(function () {
var params = new URLSearchParams(url.search.slice(1));
var query_page = params.get("p");
if (query_page !== null){
setnowpage(parseInt(query_page,10));
}
basic_ajax();
get_picnum_ajax();
//update draw
$("#control").find('input').change(function () {
if ($("#3dstart").text() == '2D') {
mydraw2d()
} else {
if (basic_data['type'] == 'Mesh3') {
mydraw3dmesh();
}else if (basic_data['type'] == 'MeshS') {
mydraw3dmeshS();
} else {
mydraw3d();
}
}
});
//3d switch
$('#3dstart').click(function () {
switch3d();
// basic_ajax();
if (is_now_MPI == 1) {
mpi_reload();
} else {
reload();
}
// reload();
});
$("#mytoggle").click(function () {
if ($("#control").is(":visible")) {
if ($(".sidebar").hasClass('d-none')) {
$(".sidebar").removeClass('d-md-block')
$(".dashboard").removeClass("col-md-10").addClass("col-md-12")
} else {
$(".sidebar").addClass('d-none')
}
} else {
if (!$(".sidebar").hasClass('d-md-block')) {
$(".sidebar").addClass('d-md-block')
$(".dashboard").removeClass("col-md-12").addClass("col-md-10")
}
if ($(".sidebar").hasClass('d-none')) {
$(".sidebar").removeClass('d-none')
}
}
})
});
</script>
<script src="static/js/freefem2d.js"></script>
<script src="static/js/freefem3d.js"></script>
</html>