-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathREADME.html
1247 lines (998 loc) · 65.4 KB
/
README.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>README_AV</title>
<style type="text/css">
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
margin-top: 0 !important; }
body > *:last-child {
margin-bottom: 0 !important; }
a {
color: #4183C4; }
a.absent {
color: #cc0000; }
a.anchor {
display: block;
padding-left: 30px;
margin-left: -30px;
cursor: pointer;
position: absolute;
top: 0;
left: 0;
bottom: 0; }
h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
padding: 0;
font-weight: bold;
-webkit-font-smoothing: antialiased;
cursor: text;
position: relative; }
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA09pVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoMTMuMCAyMDEyMDMwNS5tLjQxNSAyMDEyLzAzLzA1OjIxOjAwOjAwKSAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OUM2NjlDQjI4ODBGMTFFMTg1ODlEODNERDJBRjUwQTQiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OUM2NjlDQjM4ODBGMTFFMTg1ODlEODNERDJBRjUwQTQiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5QzY2OUNCMDg4MEYxMUUxODU4OUQ4M0REMkFGNTBBNCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo5QzY2OUNCMTg4MEYxMUUxODU4OUQ4M0REMkFGNTBBNCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PsQhXeAAAABfSURBVHjaYvz//z8DJYCRUgMYQAbAMBQIAvEqkBQWXI6sHqwHiwG70TTBxGaiWwjCTGgOUgJiF1J8wMRAIUA34B4Q76HUBelAfJYSA0CuMIEaRP8wGIkGMA54bgQIMACAmkXJi0hKJQAAAABJRU5ErkJggg==) no-repeat 10px center;
text-decoration: none; }
h1 tt, h1 code {
font-size: inherit; }
h2 tt, h2 code {
font-size: inherit; }
h3 tt, h3 code {
font-size: inherit; }
h4 tt, h4 code {
font-size: inherit; }
h5 tt, h5 code {
font-size: inherit; }
h6 tt, h6 code {
font-size: inherit; }
h1 {
font-size: 28px;
color: black; }
h2 {
font-size: 24px;
border-bottom: 1px solid #cccccc;
color: black; }
h3 {
font-size: 18px; }
h4 {
font-size: 16px; }
h5 {
font-size: 14px; }
h6 {
color: #777777;
font-size: 14px; }
p, blockquote, ul, ol, dl, li, table, pre {
margin: 15px 0; }
hr {
background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAECAYAAACtBE5DAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OENDRjNBN0E2NTZBMTFFMEI3QjRBODM4NzJDMjlGNDgiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OENDRjNBN0I2NTZBMTFFMEI3QjRBODM4NzJDMjlGNDgiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo4Q0NGM0E3ODY1NkExMUUwQjdCNEE4Mzg3MkMyOUY0OCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4Q0NGM0E3OTY1NkExMUUwQjdCNEE4Mzg3MkMyOUY0OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PqqezsUAAAAfSURBVHjaYmRABcYwBiM2QSA4y4hNEKYDQxAEAAIMAHNGAzhkPOlYAAAAAElFTkSuQmCC) repeat-x 0 0;
border: 0 none;
color: #cccccc;
height: 4px;
padding: 0;
}
body > h2:first-child {
margin-top: 0;
padding-top: 0; }
body > h1:first-child {
margin-top: 0;
padding-top: 0; }
body > h1:first-child + h2 {
margin-top: 0;
padding-top: 0; }
body > h3:first-child, body > h4:first-child, body > h5:first-child, body > h6:first-child {
margin-top: 0;
padding-top: 0; }
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
margin-top: 0;
padding-top: 0; }
h1 p, h2 p, h3 p, h4 p, h5 p, h6 p {
margin-top: 0; }
li p.first {
display: inline-block; }
li {
margin: 0; }
ul, ol {
padding-left: 30px; }
ul :first-child, ol :first-child {
margin-top: 0; }
dl {
padding: 0; }
dl dt {
font-size: 14px;
font-weight: bold;
font-style: italic;
padding: 0;
margin: 15px 0 5px; }
dl dt:first-child {
padding: 0; }
dl dt > :first-child {
margin-top: 0; }
dl dt > :last-child {
margin-bottom: 0; }
dl dd {
margin: 0 0 15px;
padding: 0 15px; }
dl dd > :first-child {
margin-top: 0; }
dl dd > :last-child {
margin-bottom: 0; }
blockquote {
border-left: 4px solid #dddddd;
padding: 0 15px;
color: #777777; }
blockquote > :first-child {
margin-top: 0; }
blockquote > :last-child {
margin-bottom: 0; }
table {
padding: 0;border-collapse: collapse; }
table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
table tr:nth-child(2n) {
background-color: #f8f8f8; }
table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
table tr th :first-child, table tr td :first-child {
margin-top: 0; }
table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }
img {
max-width: 100%; }
span.frame {
display: block;
overflow: hidden; }
span.frame > span {
border: 1px solid #dddddd;
display: block;
float: left;
overflow: hidden;
margin: 13px 0 0;
padding: 7px;
width: auto; }
span.frame span img {
display: block;
float: left; }
span.frame span span {
clear: both;
color: #333333;
display: block;
padding: 5px 0 0; }
span.align-center {
display: block;
overflow: hidden;
clear: both; }
span.align-center > span {
display: block;
overflow: hidden;
margin: 13px auto 0;
text-align: center; }
span.align-center span img {
margin: 0 auto;
text-align: center; }
span.align-right {
display: block;
overflow: hidden;
clear: both; }
span.align-right > span {
display: block;
overflow: hidden;
margin: 13px 0 0;
text-align: right; }
span.align-right span img {
margin: 0;
text-align: right; }
span.float-left {
display: block;
margin-right: 13px;
overflow: hidden;
float: left; }
span.float-left span {
margin: 13px 0 0; }
span.float-right {
display: block;
margin-left: 13px;
overflow: hidden;
float: right; }
span.float-right > span {
display: block;
overflow: hidden;
margin: 13px auto 0;
text-align: right; }
code, tt {
margin: 0 2px;
padding: 0 5px;
white-space: nowrap;
border: 1px solid #eaeaea;
background-color: #f8f8f8;
border-radius: 3px; }
pre code {
margin: 0;
padding: 0;
white-space: pre;
border: none;
background: transparent; }
.highlight pre {
background-color: #f8f8f8;
border: 1px solid #cccccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px; }
pre {
background-color: #f8f8f8;
border: 1px solid #cccccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px; }
pre code, pre tt {
background-color: transparent;
border: none; }
sup {
font-size: 0.83em;
vertical-align: super;
line-height: 0;
}
kbd {
display: inline-block;
padding: 3px 5px;
font-size: 11px;
line-height: 10px;
color: #555;
vertical-align: middle;
background-color: #fcfcfc;
border: solid 1px #ccc;
border-bottom-color: #bbb;
border-radius: 3px;
box-shadow: inset 0 -1px 0 #bbb
}
* {
-webkit-print-color-adjust: exact;
}
@media screen and (min-width: 914px) {
body {
width: 854px;
margin:0 auto;
}
}
@media print {
table, pre {
page-break-inside: avoid;
}
pre {
word-wrap: break-word;
}
}
</style>
<style type="text/css">
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/
code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
text-shadow: 0 1px white;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}
@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}
.token.punctuation {
color: #999;
}
.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #905;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #690;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #a67f59;
background: hsla(0, 0%, 100%, .5);
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}
.token.function {
color: #DD4A68;
}
.token.regex,
.token.important,
.token.variable {
color: #e90;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
</style>
</head>
<body>
<h1 id="toc_0">DGANN solver</h1>
<h3 id="toc_1">Created by: Deep Ray (Rice University, Houston), Niccolò Discacciati (EPFL, Lausanne)</h3>
<h3 id="toc_2">Code available at:</h3>
<p><code>https://github.com/nickdisca/DGANN_AV/</code>
<code>https://bitbucket.org/deepray/dgann/src/master/</code> </p>
<h3 id="toc_3">Date: 26 August, 2019</h3>
<p><strong>DGANN</strong> is a RKDG-solver written in MATLAB, which is also capable of using artificial neural networks trained to serve as a troubled-cell detector and/or artificial viscosity estimator. The main source code for the RKDG solver is based on the solvers available with the following texts:</p>
<ol>
<li>Nodal Disontinuous Galerkin methods, by Jan S. Hesthaven and Tim Warburton. </li>
<li>Numerical Methods for Conservation Laws: From Analysis to Algorithms, by Jan S. Hesthaven.</li>
</ol>
<p>Details about the design of the Multilayer Perceptron (MLP) troubled-cell indicator for 1D problems have been published in the paper <a href="https://www.sciencedirect.com/science/article/pii/S0021999118302547">"An artificial neural network as a troubled-cell indicator"</a>, while the extension to 2D problems is described <a href="https://infoscience.epfl.ch/record/258044/files/2D_troubled_cell_indicator.pdf">here</a>. Details about the MLP viscosity estimator can be found <a href="https://infoscience.epfl.ch/record/263616/files/Artificial_viscosity_nn.pdf">here</a>.</p>
<p><strong>NOTE:</strong> If the math symbols do not display properly in README_AV.md, have a look at README_AV.html or README_AV.pdf instead.</p>
<p><strong>NOTE:</strong> As of today, the two MLPs have not been tested together. We used either limiting or artificial viscosity. Even though no issues should arise when combining the models, we advice the interested user to take particular care in case (s)he whants to do so.</p>
<h2 id="toc_4">Table of contents</h2>
<ul>
<li><a href="#markdown-header-running-the-code">Running the code</a>
<ul>
<li><a href="#markdown-header-scripts-for-1d-problems">Scripts for 1D</a>
<ul>
<li><a href="#markdown-header-scalar-1d">Scalar 1D</a></li>
<li><a href="#markdown-header-euler-1d">Euler equations 1D</a></li>
</ul></li>
<li><a href="#markdown-header-scripts-for-2d-problems">Scripts for 2D</a>
<ul>
<li><a href="#markdown-header-scalar-2d">Scalar 2D</a></li>
<li><a href="#markdown-header-euler-2d">Euler equations 2D</a> </li>
</ul></li>
</ul></li>
<li><a href="#markdown-header-using-the-mlp-indicator">Using the MLP troubled-cell indicator</a>
<ul>
<li><a href="#markdown-header-network-for-1d-problems-ind">Network for 1D</a> </li>
<li><a href="#markdown-header-network-for-2d-problems-ind">Network for 2D</a> </li>
</ul></li>
<li><a href="#markdown-header-using-the-mlp-predictor">Using the MLP artificial viscosity estimator</a>
<ul>
<li><a href="#markdown-header-network-for-1d-problems-visc">Network for 1D</a> </li>
<li><a href="#markdown-header-network-for-2d-problems-visc">Network for 2D</a> </li>
<li><a href="#markdown-header-remarks">Remarks</a> </li>
</ul></li>
</ul>
<h2 id="toc_5">Running the code</h2>
<p>After cloning the git repository, execute <strong>mypath.m</strong> from the parent directory in MATLAB. This will set all the neccesary paths to use the solver. The various test cases need to be run from the <strong>Examples</strong> directory or its sub-directories.</p>
<h3 id="toc_6">Scripts for 1D problems</h3>
<p>Currently, the 1D solver supports linear advection, Burgers' equation, the shallow water equations and the compressible Euler equations.</p>
<h4 id="toc_7">Scalar 1D</h4>
<p>The basic structure of the example script is as follows.</p>
<div><pre><code class="language-matlab">CleanUp1D;
clc
clear all
close all
model = 'Advection';
test_name = 'Sine';
u_IC =@(x) sin(10*pi*x);
bnd_l = 0.0;
bnd_r = 1.0;
mesh_pert = 0.0;
bc_cond = {'P',0.0,'P',0.0};
FinalTime = 0.2;
CFL = 0.2;
K = 100;
N = 4;
RK = 'LS54';
Indicator = 'MINMOD';
nn_model = 'MLP_v1';
Limiter = 'MINMOD';
Visc_model = 'NONE';
nn_visc_model = 'MLP_visc';
plot_iter = 200;
save_iter = 1;
save_soln = true;
save_ind = true;
save_visc = true;
save_plot = true;
ref_avail = true;
ref_fname = 'ref_soln.dat';
rk_comb = false;
var_ran = [-1.2,1.5];
% Call code driver
ScalarDriver1D; </code></pre></div>
<ul>
<li><code>CleanUp1D</code> removes temporary file paths added, which is especially important if the previous run of the script terminated prematurely. This must be the first line of every script. DO NOT REMOVE IT!</li>
<li>The <code>model</code> flag sets the type of scalar model which is being solved. The following scalar models are currently available:
<ul>
<li><code>'Advection'</code>: Linear advection equation with the advection speed set to 1.</li>
<li><code>'Burgers'</code> : Burgers equation with the flux \(u^2/2\).</li>
<li><code>'BuckLev'</code>: Buckley-Leverett equation with flux contant set to \(0.5\).</li>
</ul></li>
<li><code>test_name</code> is used to declare the name of the test. This is used for creating various save files.</li>
<li><code>u_IC</code> is used to set the initial condition for the problem.</li>
<li><code>bnd_l</code> and <code>bnd_r</code> define the left and right domain boundaries, which is descritized using <code>K</code> number of elements. The degree of the polynomial in each element/cell is set using <code>N</code>. </li>
<li><p><code>mesh_pert</code> is used to randomly perturb the interior cell-interfaces using the following algorithm.<br>
\[x_{i+\frac{1}{2}} \rightarrow x_{i+\frac{1}{2}} + \text{mesh_pert} \ h \ \omega_{i+\frac{1}{2}}, \qquad \omega_{i+\frac{1}{2}} \in \mathcal{U}[-0.5,0.5], \qquad i=1,...,K-1\]</p>
<p>where \(h\) is the mesh size of the initial uniform grid.</p></li>
<li><p><code>bc_cond</code> is used to set the left and right boundary conditions. It is a cell of the form
<code>{LEFT_BC_TYPE, LEFT_BC_VAL, RIGHT_BC_TYPE,RIGHT_BC_VAL}</code>. The <code>BC_TYPES</code> can be set as:</p>
<ul>
<li><code>'P'</code>: Periodic boundary conditions. In this case, both boundary type must be set to <code>'P'</code>.</li>
<li><code>'N'</code>: Neumann boundary condition.</li>
<li><code>'D'</code>: Dirichlet boundary condition, with the imposed Dirichlet value given by <code>BC_VAL</code>. Note that <code>BC_VAL</code> is ignored if <code>BC_TYPE</code> is not set to <code>'D'</code>. </li>
</ul></li>
<li><p>The final simulation time is set using <code>FinalTime</code>, while the time step is chosen using <code>CFL</code>.</p></li>
<li><p><code>K</code> is the number of elements/cells in the mesh.</p></li>
<li><p><code>N</code> sets the order of the basis.</p></li>
<li><p><code>RK</code> sets the time integration scheme. The current implementation supports the five-stage fourth-order low-storage Runge-Kutta scheme <code>'LS54'</code> and the third order strong stability preserving Runge-Kutta <code>'SSP3'</code>.</p></li>
<li><p>The troubled-cell indicator is set using <code>Indicator</code>. The following options are currently available:</p>
<ul>
<li><code>'NONE'</code>: No cells are flagged.</li>
<li><code>'ALL'</code>: All cells are flagged.</li>
<li><code>'MINMOD'</code>: Uses the basic minmod limiter.</li>
<li><code>'TVB'</code>: Uses the modified minmod-type TVB limiter. If this is chosen, then one also needs to set the variable <code>TVBM</code> to a positive number. Note that if this constant is set to 0, then the limiter reduces to the usual minmod limiter.</li>
<li><code>'NN'</code>: Uses the trained neural network. The network name is set using the variable <code>nn_model</code>. The available networks are described below in the section <strong>Using the MLP troubled-cell indicator</strong>.</li>
</ul></li>
<li><p>The limiter usd to reconstruct the solution in each troubled-cell,is set using <code>Limiter</code>. The following options are currently available:</p>
<ul>
<li><code>'NONE'</code>: No limiting is applied.</li>
<li><code>'MINMOD'</code>: MUSCL reconstruction using minmod limiter.</li>
</ul></li>
<li><p>The artificial viscosity model is set using <code>Visc_model</code>. The following options are currently available:</p>
<ul>
<li><code>'NONE'</code>: No artificial viscosity is added.</li>
<li><code>'EV'</code>: Uses the entropy viscosity model. If this is chosen, two nonnegative parameters <code>c_E</code> and <code>c_max</code> have to be specified.</li>
<li><code>'MDH'</code>: Uses the highest modal decay model. If this is chosen, three nonnegative parameters <code>c_A</code>,<code>c_k</code>, and <code>c_max</code> have to be specified.</li>
<li><code>'MDA'</code>: Uses the averaged modal decay model. If this is chosen, a nonnegative parameter <code>c_max</code> has to be specified.</li>
<li><code>'NN'</code>: Uses the trained neural network. The network name is set using the variable <code>nn_visc_model</code>. The available networks are described below in the section <strong>Using the MLP artificial viscosity estimator</strong>. </li>
</ul></li>
<li><p>The flag <code>plot_iter</code> is used for visualization purposes. The solution plots are shown after every <code>plot_iter</code> number of iterations during the simulation. </p></li>
<li><p>The flag <code>save_iter</code> controls the frequency with which data are saved to files. This applies to both the troubled cells and the artificial viscosity.</p></li>
<li><p>If solution at the final time needs to be saved, the flag <code>save_soln</code> must be set to <code>true</code>. If this is not the case, set this flag to <code>false</code>. The solution files are save in the directory <strong>OUTPUT</strong>. The filename has the format: <code><model>1D_<test_name>_P<N>_N<K>_IND_<Indicator>_LIM_<Limiter>_VISC_<Visc_model>.dat</code>. If mesh perturbation is used, then the filename will contain the tag <code>pert</code>. The data in the file has the following format: </p>
<ul>
<li>Column 1: x-coordinates.<br></li>
<li>Column 2: solution value at corresponding x-coordinate<br></li>
</ul></li>
<li><p>If the time-history of the troubled-cells needs to be viewed/saved, the flag <code>save_ind</code> must be set to <code>true</code>. If this is not the case, set this flag to <code>false</code>. The time-history files are also save in the directory <strong>OUTPUT</strong>. The filename has the format: <code><model>1D_<test_name>_P<N>_N<K>_IND_<Indicator>_LIM_<Limiter>_VISC_<Visc_model>_tcells.dat</code>. If mesh perturbation is used, then the filename includes the tag <code>pert</code>. The data in the file has the following format:</p>
<ul>
<li>Each row of the file contains the time, followed by the mid-points of the cells flagged as troubled-cells at that time.</li>
<li>The first row corresponds to the cell flagged at time \(t=0\). This is essentially done for the initial condition.</li>
<li>Following the first row, the rows can be grouped in sets of size \(r\), to list the cells flagged after each sub-stage of the r-stage time-integration scheme. Depending on the selected Runge-Kutta scheme, \(r\) will be equal to 3 or 5.</li>
</ul></li>
<li><p>If the time-history of the artificial viscosity needs to be viewed/saved, the flag <code>save_visc</code> must be set to <code>true</code>. If this is not the case, set this flag to <code>false</code>. The time-history files are also save in the directory <strong>OUTPUT</strong>. The filename has the format: <code><model>1D_<test_name>_P<N>_N<K>_IND_<Indicator>_LIM_<Limiter>_VISC_<Visc_model>_visc.dat</code>. If mesh perturbation is used, then the filename will include the tag <code>pert</code>. The data in the file has the following format:</p>
<ul>
<li>Each row of the file contains the time, followed by the value of the artificial viscosity in each x coordinate at the current time. Unlike the troubled-cell indicator, the viscosity is updated at the beginning of the RK sub-loop. Thus, the number of rows is equal to the number of timesteps.</li>
</ul></li>
<li><p>If <code>save_plot</code> is set to <code>true</code>, then the solution plots are generated and saved in <strong>OUTPUT</strong>. <strong>NOTE</strong>: This needs <code>save_soln</code>, <code>save_ind</code> and <code>save_visc</code> to be set as <code>true</code>. </p></li>
<li><p>If a reference/exact solution data file is available, then set <code>ref_avail</code> to <code>true</code> and the (relative) file name of the referene solution in <code>ref_fname</code>. </p></li>
<li><p><code>var_ran</code> is used to set the ylim for the solution plot. This should be a array of size (1,2).</p></li>
<li><p>The main driver script <code>ScalarDriver1D</code> is called once all the flags have been set.</p></li>
</ul>
<p><a href="#markdown-header-table-of-contents">back to table of contents</a></p>
<h4 id="toc_8">Euler 1D</h4>
<p>The basic structure of the example script is as follows.</p>
<div><pre><code class="language-matlab">CleanUp1D;
clc
clear all
close all
Globals1D_DG;
Globals1D_MLP;
model = 'Euler';
gas_const = 1.0;
gas_gamma = 1.4;
test_name = 'ShockEntropy';
rho_IC =@(x) (x<-4)*3.857143 + (x>=-4).*(1 + 0.2*sin(5*x));
vel_IC =@(x) (x<-4)*2.629369;
pre_IC =@(x) (x<-4)*10.33333 + (x>=-4)*1.0;
bnd_l = -5.0;
bnd_r = 5.0;
mesh_pert = 0.0;
bc_cond = {'D',3.857143,'N',0.0;
'D',10.141852,'D',0.0;
'D',39.166661,'N',0.0}; % For conserved variables
FinalTime = 1.8;
CFL = 0.1;
K = 200;
N = 4;
RK = 'LS54';
Indicator = 'NN';
ind_var = 'prim';
nn_model = 'MLP_v1';
Limiter = 'MINMOD';
lim_var = 'con';
nn_visc_model = 'MLP_visc';
Visc_model='NN';
visc_var='density';
plot_iter = 100;
save_soln = true;
save_ind = true;
save_visc = true;
save_plot = true;
ref_avail = true;
ref_fname = 'ref_soln.dat';
rk_comb = true;
var_ran = [0,1.2; -0.2,1.5; 0,1.2];
% Call code driver
EulerDriver1D; </code></pre></div>
<p>Most of the structure is similar to the Scalar 1D script. The differences are described below. </p>
<ul>
<li>The <code>model</code> needs to be set as <code>'Euler'</code>. This should not be changed.</li>
<li>The gas constant and ratio of specific heats is set using <code>gas_const</code> and <code>gas_gamma</code>.</li>
<li>The initial density, velocity and pressure are set using <code>rho_IC</code>, <code>vel_IC</code> and <code>pre_IC</code>.</li>
<li>The <code>bc_cond</code> has the same format as earlier, although now it has three rows of parameters. The first row corresponds to density, the second corresponds to the momentum, and the third to energy. Note that the boundary condition are set for the conserved variables.</li>
<li>For systems of conservation laws, there are various choices for the variables to be used for troubled-cell detection. For the Euler equations, <code>ind_var</code> can be set as (the troubled-cells flagged for each variable is pooled together):
<ul>
<li><code>'density'</code>: Only the density is used</li>
<li><code>'velocity'</code>: Only the velocity is used</li>
<li><code>'pressure'</code>: Only the pressure is used</li>
<li><code>'prim'</code>: The primitive variables i.e., density, velocity and pressure, are used.</li>
<li><code>'con'</code>: The conserved variables i.e., density, momentum and energy, are used. </li>
</ul></li>
<li>As was the case with detection, there are several options for the variables which can be reconstructed. This is set using the flag <code>lim_var</code>, with the following options:
<ul>
<li><code>'prim'</code>: The primitive variables i.e., density, velocity and pressure, are recontructed.</li>
<li><code>'con'</code>: The conserved variables i.e., density, momentum and energy, are recontructed.</li>
<li><code>'char_cell'</code>: The local characterictic variables are reconstructed. These are obtained cell-by-cell using the linearized transformation operators. More precisely, the transformation matrix in each cell is evaluated using the cell-average value, following which the conserved variables are transformed to the characteristic variables in that cell. The same transformation is used to retrieve the conserved variables after limiting the characteristic variables. </li>
<li><code>'char_stencil'</code>: The local characterictic variables obtained cell-by-cell can introduce spurious oscillations in the solution. One can also obtain the local characteristic variables, stencil-by stencil. More precisely, for a given reconstruction stencil of 3-cells, the transformation matrix is evaluated using the cell-average value of the central cell, following which the conserved variables are transformed to the characteristic variables in every cell of that stencil. The transformed variables are used to obtain the reconstructed characteristic variables in the central cell. Note that this approach can be 3 times more expensive than the <code>'char_cell'</code> approach.</li>
</ul></li>
<li>For systems of conservation laws, there are various choices to estimate the artificial viscosity. The current implementation of Euler equations estimates the dissipation using the representative variable set in <code>visc_var</code>. Only <code>'density'</code> is currently supported. After the viscosity estimation, the same value is applied to all equations.</li>
<li>The solution filename has the format: <code><model>1D_<test_name>_P<N>_N<K>_IND_<Indicator>_IVAR_<ind_var>_LIM_<Limiter>_LVAR_<lim_var>_VISC_<Visc_model>_VVAR_<visc_var>.dat</code>. The data in the file has the following format:
<ul>
<li>Column 1: x-coordinates</li>
<li>Column 2: the value of density, velocity and pressure (in that order) at corresponding x-coordinate.</li>
</ul></li>
<li>The troubled-cell time-history filename has the format: <code><model>1D_<test_name>_P<N>_N<K>_IND_<Indicator>_IVAR_<ind_var>_LIM_<Limiter>_LVAR_<lim_var>_VISC_<Visc_model>_VVAR_<visc_var>_tcells.dat</code>.</li>
<li>The artificial viscosity time-history filename has the format: <code><model>1D_<test_name>_P<N>_N<K>_IND_<Indicator>_IVAR_<ind_var>_LIM_<Limiter>_LVAR_<lim_var>_VISC_<Visc_model>_VVAR_<visc_var>_visc.dat</code>. As the same viscosity is injected in all equations, it is saved only for the first one.</li>
<li><code>var_ran</code> is used to set the ylim for the solution plots, with the format <code>[rho_min,rho_max ; velocity_min, velocity_max ; pressure_min, pressure_max]</code>.</li>
<li>The main driver script <code>EulerDriver1D</code> is called once all the flags have been set. The troubled-cells flagged for each variable is pooled together.</li>
</ul>
<p><a href="#markdown-header-table-of-contents">back to table of contents</a></p>
<h3 id="toc_9">Scripts for 2D problems</h3>
<p>Currently, the 2D solver supports linear advection, Burgers' equation, the KPP equation, and the compressible Euler equations. For each problem, we need the following files:</p>
<ul>
<li>A main script (with the default name <code>Main.m</code>) to set the various problem parameters. </li>
<li>The initial condition is defined using the script/function (with the default name <code>IC.m</code>).</li>
<li>When physical boundary conditions are used, an additional script/function (<strong>must</strong> be named <code>BC.m</code>) needs to be created. This file is not needed when all boundary conditions are periodic.</li>
<li>Finally, a mesh file is needed, which is currently generated using <a href="http://gmsh.info/">Gmsh</a>. Each example is already provided with the Gmsh geometry file (with the extension <code>.geo</code>). To generate the mesh file (with the extension <code>.msh</code>), you could either use the Gmsh GUI or create the file non-interactively from the terminal as <code>$ gmsh -2 mymeshfile.geo</code></li>
</ul>
<h4 id="toc_10">Scalar 2D</h4>
<p>The basic structure of the various scripts are as follows:</p>
<h5 id="toc_11">Main.m</h5>
<div><pre><code class="language-matlab">% Remove NN diretory paths if they still exist
CleanUp2D;
close all
clear all
clc
model = 'Advection';
AdvectionVelocity = [1,1]; % Used for linear advection only
test_name = 'Smooth';
InitialCond = @IC;
BC_cond = {100001,'P'; 100002,'P'; 100003,'P'; 100004,'P'};
FinalTime = 0.5;
CFL = 0.3;
tstamps = 2;
N = 1;
RK = 'LS54';
% Set type of indicator
Indicator = 'NONE';
Filter_const = true;
nn_model = 'MLP_v1';
Limiter = 'NONE';
%Set viscosity model
nn_visc_model = 'MLP_visc';
Visc_model='EV'; c_E=1; c_max=0.25;
% Mesh file
msh_file = 'square_trans.msh';
% Output flags
plot_iter = 50;
show_plot = true;
xran = [0,1];
yran = [0,1];
clines = linspace(0,2,30);
save_soln = true;
% Call main driver
ScalarDriver2D;</code></pre></div>
<ul>
<li><code>CleanUp2D</code> removes temporary file paths added, which is especially important if the previous run of the script terminated prematurely. This must be the first line of every script. DO NOT REMOVE IT!</li>
<li>The <code>model</code> flag sets the type of scalar model which is being solved. The following scalar models are currently available:
<ul>
<li><code>'Advection'</code>: Linear advection equation with the advection speed set set using <code>AdvectionVelocity</code>.</li>
<li><code>'Burgers'</code> : Simple extension of the Burgers' equation to 2D, with the flux \(u^2/2\) in each coordinate direction. </li>
<li><code>'KPP'</code>: KPP problem in 2D with flux \((\sin(u),\cos(u))\).</li>
</ul></li>
<li><code>test_name</code> is used to declare the name of the test. This is used for creating various save files.</li>
<li><code>InitialCond</code> is used to set the initial condition for the problem (see the description of IC.m below).</li>
<li><p><code>BC_cond</code> is used to specify the boundary conditions for each face of the domain. This must be a MATLAB cell array of size \(NBfaces \times 2\), where \(NBfaces\) is the number of boundary curves specified in the mesh geometry file (with file-extension <code>.geo</code>). The first element of each row must be the physical face tag of a boundary curve in the geometry file, while the second element must be one of the following flags </p>
<ul>
<li><code>'P'</code>: Periodic boundary conditions. Note there must be an even number of periodic boundary faces.</li>
<li><code>'D'</code>: Dirichlet boundary condition. The actual Dirichlet conditions are specified in BC.m</li>
<li><code>'Sym'</code>: Symmteric boundary conditions.<br>
Boundary conditions require the creation of ghost cells, with the value of the solution in these cells depending on the type of boundary condition. </li>
</ul></li>
<li><p>The final simulation time is set using <code>FinalTime</code>, while the time step is chosen using a constant <code>CFL</code> or a setting a step <code>fixed_dt</code>. NOTE: Either <code>CFL</code> can be mentioned or the fixed time-step <code>fixed_dt</code>, but not both at the same time.</p></li>
<li><p><code>tstamps</code> is used to specify the number of uniform time-instances (exluding the initial time) at which the solution files are saved. This must be a positive integer. For instance if <code>tstamps=2</code> and <code>FinalTime = 2</code>, then the solution evaluated at times closest (less than half the local time-step) to \(t=0,1,2\) are saved. NOTE: It might happen that pen-ultimate time instance in the simulation is very close to <code>FinalTime</code>, with the difference being much smaller than the pen-ultimate time-step. In this case, the solver saves the solution at this pen-ultimate as the solution representing the final solution. Thus, we also save the solution at the actual <code>FinalTime</code>, leading to a total of <code>tstamps</code>+2 save points in time. This becomes crucial when comparing the troubled-cells flagged at the final time-step, since the number of cell flagged is sensitive to the size of the time-step taken.</p></li>
<li><p><code>N</code> sets the order of the basis.</p></li>
<li><p><code>RK</code> sets the time integration scheme. The current implementation supports the five-stage fourth-order low-storage Runge-Kutta scheme <code>'LS54'</code> and the third order strong stability preserving Runge-Kutta <code>'SSP3'</code>.</p></li>
<li><p>The troubled-cell indicator is set using <code>Indicator</code>. The following options are currently available:</p>
<ul>
<li><code>'NONE'</code>: No cells are flagged.</li>
<li><code>'ALL'</code>: All cells are flagged.</li>
<li><code>'TVB'</code>: Uses the 2D minmod-type TVB limiter. If this is chosen, then one also needs to set the variables <code>TVBM</code> and <code>TVBnu</code> as positive numbers. See the <a href="https://infoscience.epfl.ch/record/258044/files/2D_troubled_cell_indicator.pdf">paper</a> for details. </li>
<li><code>'NN'</code>: Uses the trained neural network. The network name is set using the variable <code>nn_model</code>. The available networks are described below in the section <strong>Using the MLP troubled-cell indicator</strong>.</li>
</ul></li>
<li><p>Set <code>Filter_const</code> to <code>true</code>, if you want to avoid flagging almost constant cells. This is especially important for speeding up the performance with the network. See the <a href="https://infoscience.epfl.ch/record/258044/files/2D_troubled_cell_indicator.pdf">paper</a> for details. </p></li>
<li><p>The limiter usd to reconstruct the solution in each troubled-cell,is set using <code>Limiter</code>. The following options are currently available:</p>
<ul>
<li><code>'NONE'</code>: No limiting is applied.</li>
<li><code>'BJES'</code>: Barth-Jespersen limiter.</li>
</ul></li>
<li><p>The artificial viscosity model is set using <code>Visc_model</code>. The following options are currently available:</p>
<ul>
<li><code>'NONE'</code>: No artificial viscosity is added.</li>
<li><code>'EV'</code>: Uses the entropy viscosity model. If this is chosen, two nonnegative parameters <code>c_E</code> and <code>c_max</code> have to be specified.</li>
<li><code>'MDH'</code>: Uses the highest modal decay model. If this is chosen, three nonnegative parameters <code>c_A</code>,<code>c_k</code>, and <code>c_max</code> have to be specified.</li>
<li><code>'MDA'</code>: Uses the averaged modal decay model. If this is chosen, a nonnegative parameter <code>c_max</code> has to be specified.</li>
<li><code>'NN'</code>: Uses the trained neural network. The network name is set using the variable <code>nn_visc_model</code>. The available networks are described below in the section <strong>Using the MLP artificial viscosity estimator</strong>.</li>
</ul></li>
<li><p>The flag <code>plot_iter</code> is used for visualization/verbose purposes. The solution plots are shown after every <code>plot_iter</code> number of iterations during the simulation.</p></li>
<li><p>Set <code>show_plot</code> to <code>true</code> if you want solution plots to be generated during the simulation.</p></li>
<li><p><code>xran</code> and <code>yran</code> are used to crop the x and y axes of the solution plots (if <code>show_plot</code> is set to <code>true</code>). This is particulalry helpful when an extended domain is used to impose artificial boundary conditions, for instance when solving 2D Riemann problem.</p></li>
<li><p><code>clines</code> is used to set the contour lines for the solution contour plots (if <code>show_plot</code> is set to <code>true</code>). </p></li>
<li><p>The solution variables are saved in the <strong>OUTPUT</strong> directory if <code>save_soln</code> is set to <code>true</code>. The filename has the format: <code><model>2D_<test_name>_P<N>_IND_<Indicator>_LIM_<Limiter>_VISC_<Visc_model>_DATA.mat</code>. If <code>Filter_const</code> is set to <code>true</code>, then <code>ConstFilt</code> also appears in the filename. The following MATLAB variables are saved:</p>
<ul>
<li>The <code>x</code> and <code>y</code> coordinates of all degrees of freedom in the mesh.</li>
<li>Inverse of the Vandermonde matrix <code>invV</code>, the Jacobian of the geometric mapping <code>J</code>, the mass matrix <code>Mass</code> in the reference element.</li>
<li><code>Save_times</code> is the array of exact time-instances at which the solution is saved. This is of length <code>tstamps</code>+2.</li>
<li>The solutions evaluated at the time-instances listed in <code>Save_times</code> is stored in the MATLAB-cell <code>Q_save</code>.</li>
<li>The troubled-cells flagged in the mesh at each time-instance listed in <code>Save_times</code> is stored in the MATLAB-cell <code>ind_save</code>.</li>
<li>The artificial viscosity at each time-instance listed in <code>Save_times</code> is stored in the MATLAB-cell <code>visc_save</code>.</li>
<li><code>ptc_hist</code> stores the time-history of the percentage of the total number mesh cells flaged as troubled-cells. </li>
<li><code>maxvisc_hist</code> stores the time-history of the maximum value of the artificial viscosity.</li>
<li><code>t_hist</code> stores all the time-instances attained during the simulation. </li>
<li><code>sim_time</code> stores the full simulation time (excludes time taken to generate mesh data structures).</li>
</ul></li>
<li><p>The main driver script <code>ScalarDriver2D</code> is called once all the flags have been set.</p></li>
</ul>
<h4 id="toc_12">IC.m</h4>
<p>The initial condition function must take as input the arrays x and y, where each of these is of the shape \(m \times n\). The output should be a array of dimension \(m \times n \times 1\). Almost always, \(m\) will denote the number of DOFs per cell in the mesh, while \(n\) will be the number of cells. We give an example of this function below:</p>
<div><pre><code class="language-matlab">function Q = IC(x, y)
Q(:,:,1) = sin(4*pi*x).*cos(4*pi*y);
return;</code></pre></div>
<h4 id="toc_13">BC.m</h4>
<p>When using non-periodic boundary conditions, a function script called BC.m is also needed. An example function is as follows:</p>
<div><pre><code class="language-matlab">function uG = BC(ckey,time)
u1 = 1.0; u2 = -1.0, c=3.0;
if(ckey == 101 || ckey == 103)
uG =@(x,y) u1*ones(size(x));
elseif(ckey == 102)
uG =@(x,y) u2*ones(size(x));
elseif(ckey == 104)
rhoG =@(x,y) u1*(y > x+c*time) + u1*(y < x+c*time);
end
return;</code></pre></div>
<p>where the function takes in as input a boundary physical tag <code>ckey</code> and the curent simulation-time. The output is a function of x and y (and perhaps implicitly of time).</p>
<p><a href="#markdown-header-table-of-contents">back to table of contents</a></p>
<h4 id="toc_14">Euler 2D</h4>
<p>The basic structure of the various scripts are as follows:</p>
<h5 id="toc_15">Main.m</h5>
<div><pre><code class="language-matlab">% Remove NN diretory paths if they still exist
CleanUp2D;
close all
clear all
clc
%Model
model = 'Euler';
gas_const = 1.0;
gas_gamma = 1.4;
test_name = 'SV';
InitialCond = @IC;
BC_cond = {100001,'P'; 100002,'P'; 100003,'P'; 100004,'P'};
FinalTime = 0.8;
CFL = 0.8;
tstamps = 1;
N = 4;
RK = 'LS54';
% Mesh file
msh_file = 'nonuniform_m1p3_H002.msh';
% Set type of indicator
Indicator = 'NONE';
ind_var = 'con';
nn_model = 'MLP_v1';
Limiter = 'NONE';
lim_var = 'con';
Filter_const = true;
%Set viscosity model
nn_visc_model = 'MLP_visc';
Visc_model='EV'; c_E=1; c_max=0.25;
visc_var='density';
plot_iter = 50;
show_plot = true;
xran = [0,2];
yran = [0,1];
plot_var = {'density'};
clines = {linspace(0.85,1.35,30)};
save_soln = true;
% Call main driver
EulerDriver2D;</code></pre></div>
<p>Most of the structure is similar to the Scalar 2D script. The differences are described below. Note that most of the differences coincide with the 1D case.</p>
<ul>
<li>The <code>model</code> flag must be set to <code>Euler</code>.</li>
<li>The gas constant and ratio of specific heats is set using <code>gas_const</code> and <code>gas_gamma</code>.</li>
<li>The following flags
<ul>
<li><code>'P'</code>: Periodic boundary conditions. </li>
<li><code>'D'</code>: Dirichlet boundary condition. </li>
<li><code>'S'</code>: Slip boundary conditions.<br></li>
<li><code>'I'</code>: Inflow boundary.</li>
<li><code>'O'</code>: Outflow boundary</li>
</ul></li>
<li>The troubled-cells are detected using the variables mentioned in <code>ind_var</code>. The following options are available :
<ul>
<li><code>'density'</code></li>
<li><code>'pressure'</code></li>
<li><code>'velocity'</code>: Both components of velocity are use.</li>
<li><code>'prim'</code>: The primitive variables are used. </li>
<li><code>'con'</code>: The conserved variables are used.</li>
</ul></li>
<li>The limiting variables are set using the flag <code>lim_var</code>, with the following options being avaialable:
<ul>