-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
525 lines (424 loc) · 18.4 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
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="plotly-latest.min.js"></script>
<link href="./UI/jquery-ui.css" rel="stylesheet">
<style>
body{
font: 62.5% "Trebuchet MS", sans-serif;
margin: 50px;
}
.demoHeaders {
margin-top: 2em;
}
#column1 {
}
#column2 {
}
#column3 {
}
.h2 {
border:0; color:#f6931f; font-weight:bold;
}
.column {
background-color: #ffffff;
float:left;
width: 300px
}
#dialog-link {
padding: .4em 1em .4em 20px;
text-decoration: none;
position: relative;
}
#dialog-link span.ui-icon {
margin: 0 5px 0 0;
position: absolute;
left: .2em;
top: 50%;
margin-top: -8px;
}
#icons {
margin: 0;
padding: 0;
}
#icons li {
margin: 2px;
position: relative;
padding: 4px 0;
cursor: pointer;
float: left;
list-style: none;
}
#icons span.ui-icon {
float: left;
margin: 0 4px;
}
#displayTypeSet label { width: 200px }
#versionSet label { width: 200px }
#brushTypeSet label { width: 200px }
.brush_button {
padding: 3px 2px 0px 2px;
color: black;
}
.selected_button {
background-color: #007fff;
}
.standardSlider {
margin: auto;
width: 280px;
}
.ui-slider-range { background: #007fff; }
.ui-button .ui-icon.brush-circle {
background-image: url(brushbutton_circle.png);
width: 32px;
height: 32px;
} }
.ui-button .ui-icon.brush-square {
background-image: url(brushbutton_square.png);
width: 32px;
height: 32px;
} }
.fakewindowcontain .ui-widget-overlay {
position: absolute;
}
select {
width: 200px;
}
</style>
<!------------------------------------------------------------->
<!-- TOP -- >
<!------------------------------------------------------------->
<title>CFD Toy Box</title>
<meta charset="utf-8">
<meta name="viewport" content="width=620">
<style>
body {background-color:#ffffff; font-family:Arial, sans-serif; font-size:14px;
text-align:center;} /* gray background, center everything */
p {margin-left:auto; margin-right:auto; width:600px;} /* keep paragraphs narrow and centered */
input {font-size:115%;} /* make buttons bigger */
li {text-align:left;}
</style>
<style type="text/css"></style></head>
<body>
<h2 id="mainTitle">Fluid Dynamics Toy Box</h2>
<!-- Info label-->
<div>
Force <span id="dragLabel">...</span>
<br />
FPS: <span id="fpsLabel">...</span>
</div>
<canvas id="theCanvas" width="600" height="240">This application runs only in modern
browsers. For best results, use Google Chrome.</canvas>
<!-- Reset / Play -->
<div>
<input id="clearButton" type="button" onclick="fds.clear()" value="Clear">
<input id="resetFluidButton" type="button" onclick="fds.resetFluid()" value="Reset">
<input id="startButton" type="button" onclick="fds.startStop()" value="Start">
<!--
not quite implemented yet...
<input id="loadButton" type="button" onclick="openLoadDialogue()" value="Load">
-->
</div>
<!------------------------------------------------------------->
<!-- MIDDLE: Display / Draw / Experiment Settings -- >
<!------------------------------------------------------------->
<div style="align-content:center; margin:auto; width: 900px;">
<div id="column1" class="column">
<!-- Display -->
<h2 class="h2">Display</h2>
<!-- Display type -->
<form id="myform" style="margin-top: 1em;">
<div id="displayTypeSet">
<input type="radio" id="radio1" value="0" name="radio"><label for="radio1">Density</label><br>
<input type="radio" id="radio2" value="1" name="radio"><label for="radio2">XVel</label><br>
<input type="radio" id="radio3" value="2" name="radio"><label for="radio3">YVel</label><br>
<input type="radio" id="radio4" value="3" name="radio"><label for="radio4">Speed</label><br>
<input type="radio" id="radio5" value="4" name="radio" checked="checked"><label for="radio5">Curl</label><br>
<input type="radio" id="radio7" value="6" name="radio"><label for="radio7">None</label><br>
</div>
</form>
<!-- Contrast Slider -->
</br>
<div>
<label for="contrastValue">Contrast:</label>
<input type="text" id="contrastLabel" readonly style="border:0; color:#f6931f; font-weight:bold;">
<div id="contrastSlider" class="standardSlider"></div>
</div>
<!-- Display toggles -->
</br>
<div id="format">
<input type="checkbox" id="tracers" onclick="fds.showTracers = this.checked; fds.resetTracers()"><label for="tracers">Tracers</label>
<input type="checkbox" id="flowlines" onclick="fds.showFlowlines = this.checked; "><label for="flowlines">Flowlines</label>
<input type="checkbox" id="sensor" onclick="fds.showSensor = this.checked; "><label for="sensor">Sensor</label>
</div>
</div>
<div id="column2" class="column">
<!-- Draw -->
<h2 class="h2">Draw</h2>
<!-- Brushe Shape -->
<div id="brushShapeSet">
<button class="brush_button" id="brushbutton_circle" onclick="setBrushType(this)" value="circle"><img src="brushbutton_circle.png" height=24 width=24 /></button>
<button class="brush_button" id="brushbutton_square" onclick="setBrushType(this)" value="square"><img src="brushbutton_square.png" height=24 width=24 /></button>
<button class="brush_button" id="brushbutton_hline" onclick="setBrushType(this)" value="hline"><img src="brushbutton_hline.png" height=24 width=24 /></button>
<button class="brush_button" id="brushbutton_vline" onclick="setBrushType(this)" value="vline"><img src="brushbutton_vline.png" height=24 width=24 /></button>
<button class="brush_button selected_button" id="brushbutton_hand" onclick="setBrushType(this)" value="push"><img src="brushbutton_hand.png" height=24 width=24 /></button>
</div>
<!-- Brush Type -->
<br />
<form>
<div id="brushValueSet">
<input type="radio" id="brushValue1" value="1" name="radio" checked="checked"><label for="brushValue1">Barrier</label>
<input type="radio" id="brushValue2" value="2" name="radio"><label for="brushValue2">Outlet</label>
<input type="radio" id="brushValue3" value="3" name="radio"><label for="brushValue3">Inlet</label>
<input type="radio" id="brushValue4" value="0" name="radio"><label for="brushValue4">Clear</label>
</div>
</form>
<br />
<div>
<label for="brushSizeLabel">Brush size:</label>
<input type="text" id="brushSizeLabel" readonly style="border:0; color:#f6931f; font-weight:bold;">
<div id="brushSizeSlider" class="standardSlider"></div>
</div>
</div>
<div id="column3" class="column">
<!-- Experiment -->
<h2 class="h2">Experiment</h2>
<!-- Versions List -->
<form id="versionList" style="margin-top: 1em;">
<select id="versionSet">
</select>
</form>
<br />
<!-- Fluid Speed Slider -->
<div>
<label for="fluidSpeedValue">Fluid speed:</label>
<input type="text" id="fluidSpeedLabel" readonly style="border:0; color:#f6931f; font-weight:bold;">
<div id="fluidSpeedSlider" class="standardSlider"></div>
</div>
<!-- Gravity tick box -->
<br />
<div>
<label for="gravityCheckbox">Gravity:</label>
<input name="gravityCheckbox" value="False" type="checkbox" onclick="toggleGravity();">
</div>
<br />
<!-- Summary -->
<div>
<p id="summary" style ="width:280px; text-align: left "></p>
</div>
</div>
</div>
<br>
<br />
<!-- Load dialogue -->
<div id="load-dialog-form" title="Select Experiment">
</br>
</br>
</br>
<form>
<select name="experimentList" id="experimentList">
<option selected="selected" value="0">Sandbox</option>
<option value="1">Experiment1 - Lift</option>
<option value="2">Experiment2 - Continuity Equation</option>
<option value="3">Experiment3 - Drag</option>
<option value="4">Experiment4 - Bernoulli Equation</option>
<option value="5">Experiment5 - Sound Waves</option>
</select>
<input type="Load" tabindex="-1" style="position:absolute; top:-1000px">
</form>
</div>
<div id="tester" style="width:600px;height:250px;"></div>
<script src="./Fluid Dynamics Simulation_files/barrierdata.js"></script>
<script src="helper.js"></script>
<script src="LBESolver_JS.js"></script>
<script src="fluidDynamics.js"></script>
<script src="./UI/external/jquery/jquery.js"></script>
<script src="./UI/jquery-ui.js"></script>
<script src="./UI/jquery-ui.js"></script>
<script src="./presets.js"></script>
<script src='js/XMLWriter-1.0.0.js'></script>
<!-- Just an interface to the lattice_boltzmann settings -->
<script>
// Updates the list of versions this experiment has.
function updateVersionList() {
list = document.getElementById('versionSet');
var newOptions = "";
// is this really the way to do this?
for (var i = 0; i < fds.versionName.length; i++) {
var checked = "";
if (i == fds.defaultVersion)
checked = ' selected="selected"';
newOptions += '<option id="ver{0}" value="{0}" name="radio"{2}><label for="ver{0}">{1}</label><br>'.format(i.toString(), fds.versionName[Number(i)],checked);
}
list.innerHTML = newOptions;
$("#versionSet").selectmenu();
}
// Select version number for experiments with multiple verisons.
function selectVersion(versionIndex) {
}
// Loads given experiment clearing the current context.
function loadExperiment(experimentNumber) {
var preset = fds.load(presets[experimentNumber]);
document.getElementById("mainTitle").innerHTML = preset.name;
document.getElementById("summary").innerHTML = preset.description;
updateVersionList();
}
// Loads experiment selected in the experiments modal form.
function loadSelectedExperiment() {
var value = $("select[name=experimentList]").val();
loadExperiment(parseInt(value));
dialog.dialog( "close" );
return true;
}
function openLoadDialogue() {
dialog.dialog("open");
}
// initialization
fds = new FluidDynamics();
fds.clear();
loadExperiment(1);
$(function () {
$("#fluidSpeedSlider").slider({
range: "min",
value: 0.10,
min: 0.00,
step: 0.0125,
max: 0.18,
slide: function (event, ui) {
$("#fluidSpeedLabel").val(ui.value);
fds.speed = ui.value;
}
});
$("#fluidSpeedLabel").val($("#fluidSpeedSlider").slider("value"));
});
$(function () {
$("#contrastSlider").slider({
range: "min",
value: 0,
min: -10,
step: 0.01,
max: 10,
slide: function (event, ui) {
$("#contrastLabel").val(ui.value);
fds.contrast = ui.value;
}
});
$("#contrastLabel").val($("#contrastSlider").slider("value"));
});
$(function () {
$("#brushSizeSlider").slider({
range: "min",
value: 1,
min: 1,
step: 1,
max: 16,
slide: function (event, ui) {
$("#brushSizeLabel").val(ui.value);
fds.brushSize = ui.value;
}
});
$("#brushSizeLabel").val($("#brushSizeSlider").slider("value"));
});
dialog = $("#load-dialog-form").dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Load": loadSelectedExperiment,
Cancel: function () {
dialog.dialog("close");
}
},
close: function () {
form[0].reset();
}
});
form = dialog.find("form").on("submit", function (event) {
event.preventDefault();
loadSelectedExperiment();
});
// globals to our UI controls
var speedLabel = document.getElementById('fluidSpeedLabel');
var speedSlider = document.getElementById('fluidSpeedSlider');
// get jquery up and running
$("#displayTypeSet").buttonset();
$("#brushShapeSet").buttonset();
$("#brushValueSet").buttonset();
$("#resetFluidButton").button();
$("#startButton").button();
$("#clearButton").button();
$("#loadButton").button();
$("#brushbutton_circle").button();
$("#brushbutton_square").button();
$("#brushbutton_hline").button();
$("#brushbutton_vline").button();
$("#brushbutton_hand").button();
$("#attribute_button_barrier").button();
$("#attribute_button_inlet").button();
$("#attribute_button_outlet").button();
$("#attribute_button_clear").button();
$("#tracers").button();
$("#flowlines").button();
$("#sensor").button();
$("#savebutton").button();
$("#experimentList").selectmenu();
$("#versionSet").selectmenu();
// hooks
$("#displayTypeSet").click(function () {
_setPlot()
});
$("#brushValueSet").click(function () {
_setBrushValue()
});
$("#versionSet").selectmenu({
change: function( event, data ) {
_setVersion(data.item.value);
}
});
fds.ui.dragLabel = document.getElementById('dragLabel');
fds.ui.fpsLabel = document.getElementById('fpsLabel');
// start the simulation on page load
fds.startStop();
var results = []
var sample_number
var sample_count
var sample_step
var sample_start
var sample_time = 1000
function currentDragForceMagnitude() {
var Fx = barrierFx;
var Fy = barrierFy;
return Math.sqrt(Fx * Fx + Fy * Fy).toFixed(3);
}
function _setPlot() {
value = $('input[name=radio]:checked', '#myform').val();
fds.plotSelect = value;
}
function _setVersion(value) {
fds.setVersion(Number(value));
console.log("setting version to {0}".format(value));
}
function _setBrushValue() {
value = $('input[name=radio]:checked', '#brushValueSet').val();
fds.brushValue = Number(value);
console.log("setting brush value to {0}".format(value));
}
function setBrushType(button) {
fds.brushType = button.value;
$("#brushbutton_circle").removeClass('selected_button');
$("#brushbutton_square").removeClass('selected_button');
$("#brushbutton_hline").removeClass('selected_button');
$("#brushbutton_vline").removeClass('selected_button');
$("#brushbutton_hand").removeClass('selected_button');
$(button).addClass('selected_button');
}
function toggleGravity() {
if (fds.solver.gravity == 0)
fds.solver.gravity = -0.00005
else
fds.solver.gravity = 0;
}
</script>
</body>
</html>