forked from stanfordhpccenter/HTR-solver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prometeo.rg
1679 lines (1421 loc) · 71 KB
/
prometeo.rg
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
-- Copyright (c) "2019, by Stanford University
-- Developer: Mario Di Renzo
-- Affiliation: Center for Turbulence Research, Stanford University
-- URL: https://ctr.stanford.edu
-- Citation: Di Renzo, M., Lin, F., and Urzay, J. (2020).
-- HTR solver: An open-source exascale-oriented task-based
-- multi-GPU high-order code for hypersonic aerothermodynamics.
-- Computer Physics Communications 255, 107262"
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import "regent"
-------------------------------------------------------------------------------
-- IMPORTS
-------------------------------------------------------------------------------
local C = regentlib.c
local SCHEMA = terralib.includec("config_schema.h")
local MAPPER = terralib.includec("prometeo_mapper.h")
local REGISTRAR = terralib.includec("prometeo_registrar.h")
local UTIL = require "util-desugared"
local VERSION = require "version"
-------------------------------------------------------------------------------
-- ACTIVATE TIMING
-------------------------------------------------------------------------------
local T
local TIMING = false
if os.getenv("TIMING") == "1" then
TIMING = true
T = regentlib.newsymbol()
print("######################################################################################")
print("WARNING: You are compiling with timing tools.")
print(" This might affect the performance of the solver.")
print("######################################################################################")
end
-------------------------------------------------------------------------------
-- ACTIVATE DEBUG_OUTPUT
-------------------------------------------------------------------------------
local DEBUG_OUTPUT = false
if os.getenv("DEBUG_OUTPUT") == "1" then
DEBUG_OUTPUT = true
print("#############################################################################")
print("WARNING: You are compiling with debug output.")
print(" This might affect the performance of the solver.")
print("#############################################################################")
end
-------------------------------------------------------------------------------
-- ACTIVATE ATOMIC COHERENCE MODE
-------------------------------------------------------------------------------
local ATOMIC = true
if os.getenv("NO_ATOMIC") == "1" then
ATOMIC = false
print("#############################################################################")
print("WARNING: You are compiling without atomic coherence mode.")
print(" This might affect the performance of the solver.")
print("#############################################################################")
end
-------------------------------------------------------------------------------
-- ACTIVATE AVERAGES
-------------------------------------------------------------------------------
local AVERAGES = true
if os.getenv("AVERAGES") == "0" then
AVERAGES = false
print("#############################################################################")
print("WARNING: You are compiling without averaging tools.")
print("#############################################################################")
end
-------------------------------------------------------------------------------
-- IMPORT MIXTURE
-------------------------------------------------------------------------------
local MIX
if (os.getenv("EOS") == "ConstPropMix") then
MIX = (require "ConstPropMix")(SCHEMA)
elseif (os.getenv("EOS") == "IsentropicMix") then
MIX = (require 'IsentropicMix')(SCHEMA)
elseif (os.getenv("EOS") == "AirMix") then
MIX = (require 'AirMix')(SCHEMA)
elseif (os.getenv("EOS") == "CH41StMix") then
MIX = (require 'CH41StMix')(SCHEMA)
elseif (os.getenv("EOS") == nil) then
error ("You must define EOS enviromnment variable")
else
error ("Unrecognized mixture: " .. os.getenv("EOS"))
end
-------------------------------------------------------------------------------
-- DATA STRUCTURES
-------------------------------------------------------------------------------
local Config = SCHEMA.Config
--local MultiConfig = SCHEMA.MultiConfig
-------------------------------------------------------------------------------
-- CONSTANTS
-------------------------------------------------------------------------------
local CONST = require "prometeo_const"
-- Runge-Kutta coefficients
local RK_C = CONST.RK_C
-- Variable indices
local nSpec = MIX.nSpec -- Number of species composing the mixture
local nEq = CONST.GetnEq(MIX) -- Total number of unknowns for the implicit solver
-------------------------------------------------------------------------------
-- DATA STRUCTURES
-------------------------------------------------------------------------------
local TYPES = terralib.includec("prometeo_types.h", {"-DEOS="..os.getenv("EOS")})
local Fluid_columns = TYPES.Fluid_columns
local IOVars = terralib.newlist({
'centerCoordinates',
'cellWidth',
'rho',
'pressure',
'temperature',
'MolarFracs',
'velocity',
'dudtBoundary',
'dTdtBoundary'
})
local DebugVars = terralib.newlist({
'centerCoordinates',
'cellWidth',
'rho',
'pressure',
'temperature',
'MolarFracs',
'velocity',
'Conserved',
'shockSensorX',
'shockSensorY',
'shockSensorZ'
})
-------------------------------------------------------------------------------
-- EXTERNAL MODULES IMPORTS
-------------------------------------------------------------------------------
local HDF = (require 'hdf_helper')(int3d, int3d, Fluid_columns,
IOVars,
{timeStep=int,simTime=double,channelForcing=double},
{SpeciesNames={nSpec, 20}, Versions={2, VERSION.Length}})
local HDF_DEBUG
if DEBUG_OUTPUT then
HDF_DEBUG = (require 'hdf_helper')(int3d, int3d, Fluid_columns,
DebugVars,
{timeStep=int,simTime=double,channelForcing=double},
{SpeciesNames={nSpec, 20}, Versions={2, VERSION.Length}})
end
-- Macro
local MACRO = require "prometeo_macro"
-- Metric routines
local METRIC = (require 'prometeo_metric')(SCHEMA, Fluid_columns)
-- Partitioning routines
local PART = (require 'prometeo_partitioner')(SCHEMA, METRIC, Fluid_columns)
-- Mesh routines
local GRID = (require 'prometeo_grid')(SCHEMA, Fluid_columns, PART.zones_partitions)
-- I/O routines
local IO = (require 'prometeo_IO')(SCHEMA)
-- Stability conditions routines
local CFL = (require 'prometeo_cfl')(MIX, Fluid_columns)
-- Chemistry routines
local CHEM = (require 'prometeo_chem')(SCHEMA, MIX, Fluid_columns, ATOMIC)
-- Initialization routines
local INIT = (require 'prometeo_init')(SCHEMA, MIX, CHEM, Fluid_columns)
-- Conserved->Primitives/Primitives->Conserved and properties routines
local VARS = (require 'prometeo_variables')(SCHEMA, MIX, METRIC, Fluid_columns, DEBUG_OUTPUT)
-- Fluxes routines
local SENSOR = (require 'prometeo_sensor')(SCHEMA, MIX, Fluid_columns, PART.zones_partitions, PART.ghost_partitions)
-- BCOND routines
local BCOND = (require 'prometeo_bc')(SCHEMA, MIX, CHEM, Fluid_columns, PART.zones_partitions, DEBUG_OUTPUT)
-- RK routines
local RK = (require 'prometeo_rk')(nEq, Fluid_columns)
-- RHS routines
local RHS = (require 'prometeo_rhs')(SCHEMA, MIX, METRIC, Fluid_columns,
PART.zones_partitions, PART.ghost_partitions, ATOMIC)
-- Volume averages routines
local STAT = (require 'prometeo_stat')(MIX, Fluid_columns)
-- Profiles routines
local PROFILES = (require 'prometeo_profiles')(SCHEMA, MIX, Fluid_columns)
-- Averages routines
local AVG
if AVERAGES then
AVG = (require 'prometeo_average')(SCHEMA, MIX, Fluid_columns)
end
-- Probes routines
local PROBES = (require 'prometeo_probe')(SCHEMA, MIX, IO, Fluid_columns)
-------------------------------------------------------------------------------
-- INITIALIZATION ROUTINES
-------------------------------------------------------------------------------
local function emitFill(p, t, f, val) return rquote
var v = [val]
__demand(__index_launch)
for c in t do fill(([p][c]).[f], v) end
end end
__demand(__inline)
task InitializeCell(Fluid : region(ispace(int3d), Fluid_columns),
tiles : ispace(int3d),
Fluid_Zones : PART.zones_partitions(Fluid, tiles))
where
writes(Fluid)
do
-- Unpack the partitions that we are going to need
var {p_All} = Fluid_Zones;
[emitFill(p_All, tiles, "centerCoordinates", rexpr array(0.0, 0.0, 0.0) end)];
[emitFill(p_All, tiles, "cellWidth", rexpr array(0.0, 0.0, 0.0) end)];
[emitFill(p_All, tiles, "nType_x", rexpr 0 end)];
[emitFill(p_All, tiles, "nType_y", rexpr 0 end)];
[emitFill(p_All, tiles, "nType_z", rexpr 0 end)];
[emitFill(p_All, tiles, "dcsi_e", rexpr 0.0 end)];
[emitFill(p_All, tiles, "deta_e", rexpr 0.0 end)];
[emitFill(p_All, tiles, "dzet_e", rexpr 0.0 end)];
[emitFill(p_All, tiles, "dcsi_d", rexpr 0.0 end)];
[emitFill(p_All, tiles, "deta_d", rexpr 0.0 end)];
[emitFill(p_All, tiles, "dzet_d", rexpr 0.0 end)];
[emitFill(p_All, tiles, "dcsi_s", rexpr 0.0 end)];
[emitFill(p_All, tiles, "deta_s", rexpr 0.0 end)];
[emitFill(p_All, tiles, "dzet_s", rexpr 0.0 end)];
[emitFill(p_All, tiles, "rho", rexpr 0.0 end)];
[emitFill(p_All, tiles, "mu" , rexpr 0.0 end)];
[emitFill(p_All, tiles, "lam", rexpr 0.0 end)];
[emitFill(p_All, tiles, "Di" , UTIL.mkArrayConstant(nSpec, rexpr 0.0 end))];
[emitFill(p_All, tiles, "SoS", rexpr 0.0 end)];
[emitFill(p_All, tiles, "pressure", rexpr 0.0 end)];
[emitFill(p_All, tiles, "temperature", rexpr 0.0 end)];
[emitFill(p_All, tiles, "MassFracs", UTIL.mkArrayConstant(nSpec, rexpr 0.0 end))];
[emitFill(p_All, tiles, "MolarFracs", UTIL.mkArrayConstant(nSpec, rexpr 0.0 end))];
[emitFill(p_All, tiles, "velocity", rexpr array(0.0, 0.0, 0.0) end)];
[emitFill(p_All, tiles, "velocityGradientX", rexpr array(0.0, 0.0, 0.0) end)];
[emitFill(p_All, tiles, "velocityGradientY", rexpr array(0.0, 0.0, 0.0) end)];
[emitFill(p_All, tiles, "velocityGradientZ", rexpr array(0.0, 0.0, 0.0) end)];
[emitFill(p_All, tiles, "temperatureGradient", rexpr array(0.0, 0.0, 0.0) end)];
[emitFill(p_All, tiles, "Conserved", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))];
[emitFill(p_All, tiles, "Conserved_old", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))];
-- [emitFill(p_All, tiles, "Conserved_hat", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))];
[emitFill(p_All, tiles, "Conserved_t", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))];
[emitFill(p_All, tiles, "Conserved_t_old", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))];
-- [emitFill(p_All, tiles, "FluxXCorr", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))];
-- [emitFill(p_All, tiles, "FluxYCorr", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))];
-- [emitFill(p_All, tiles, "FluxZCorr", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))];
[emitFill(p_All, tiles, "shockSensorX", rexpr true end)];
[emitFill(p_All, tiles, "shockSensorY", rexpr true end)];
[emitFill(p_All, tiles, "shockSensorZ", rexpr true end)];
-- [emitFill(p_All, tiles, "dissipation", rexpr 0.0 end)];
-- [emitFill(p_All, tiles, "dissipationFlux", rexpr 0.0 end)];
[emitFill(p_All, tiles, "dudtBoundary", rexpr array(0.0, 0.0, 0.0) end)];
[emitFill(p_All, tiles, "dTdtBoundary", rexpr 0.0 end)];
[emitFill(p_All, tiles, "velocity_old_NSCBC", rexpr array(0.0, 0.0, 0.0) end)];
[emitFill(p_All, tiles, "temperature_old_NSCBC", rexpr 0.0 end)];
[emitFill(p_All, tiles, "MolarFracs_profile", UTIL.mkArrayConstant(nSpec, rexpr 0.0 end))];
[emitFill(p_All, tiles, "velocity_profile", rexpr array(0.0, 0.0, 0.0) end)];
[emitFill(p_All, tiles, "temperature_profile", rexpr 0.0 end)];
[emitFill(p_All, tiles, "temperature_recycle", rexpr 0.0 end)];
[emitFill(p_All, tiles, "MolarFracs_recycle", UTIL.mkArrayConstant(nSpec, rexpr 0.0 end))];
[emitFill(p_All, tiles, "velocity_recycle", rexpr array(0.0, 0.0, 0.0) end)];
end
__demand(__cuda, __leaf) -- MANUALLY PARALLELIZED
task dummyAllocationTask(Fluid : region(ispace(int3d), Fluid_columns))
where reads(Fluid) do end
-------------------------------------------------------------------------------
-- DEBUG ROUTINES
-------------------------------------------------------------------------------
local DetectNaN
local CheckDebugOutput
if DEBUG_OUTPUT then
local isnan = regentlib.isnan(double)
__demand(__cuda, __leaf) -- MANUALLY PARALLELIZED
task DetectNaN(Fluid : region(ispace(int3d), Fluid_columns))
where
reads(Fluid.{pressure, temperature}),
reads(Fluid.Conserved)
do
var err = 0
__demand(__openmp)
for c in Fluid do
if ([bool](isnan(Fluid[c].pressure ))) then err += 1 end
if ([bool](isnan(Fluid[c].temperature))) then err += 1 end
for i=0, nEq do
if ([bool](isnan(Fluid[c].Conserved[i]))) then err += 1 end
end
end
return err
end
__demand(__inline)
task CheckDebugOutput(Fluid : region(ispace(int3d), Fluid_columns),
Fluid_copy : region(ispace(int3d), Fluid_columns),
tiles : ispace(int3d),
tiles_output : ispace(int3d),
Fluid_Zones : PART.zones_partitions(Fluid, tiles),
Fluid_Output : PART.output_partitions(Fluid, tiles_output),
Fluid_Output_copy : PART.output_partitions(Fluid_copy, tiles_output),
config : Config,
Mix : MIX.Mixture,
Integrator_timeStep : int,
Integrator_simTime : double)
where
reads(Fluid),
reads writes(Fluid_copy),
Fluid * Fluid_copy
do
-- Unpack the partitions that we are going to need
var {p_All} = Fluid_Zones
var {p_Output } = Fluid_Output
var {p_Output_copy=p_Output} = Fluid_Output_copy
var err = 0
__demand(__index_launch)
for c in tiles do
err += DetectNaN(p_All[c])
end
if err ~= 0 then
var SpeciesNames = MIX.GetSpeciesNames(Mix)
var dirname = [&int8](C.malloc(256))
C.snprintf(dirname, 256, '%s/debugOut', config.Mapping.outDir)
var _1 = IO.createDir(dirname)
_1 = HDF_DEBUG.dump( _1, tiles_output, dirname, Fluid, Fluid_copy, p_Output, p_Output_copy)
_1 = HDF_DEBUG.write.timeStep( _1, tiles_output, dirname, Fluid, p_Output, Integrator_timeStep)
_1 = HDF_DEBUG.write.simTime( _1, tiles_output, dirname, Fluid, p_Output, Integrator_simTime)
_1 = HDF_DEBUG.write.SpeciesNames( _1, tiles_output, dirname, Fluid, p_Output, SpeciesNames)
_1 = HDF_DEBUG.write.Versions( _1, tiles_output, dirname, Fluid, p_Output, array(regentlib.string([VERSION.SolverVersion]), regentlib.string([VERSION.LegionVersion])))
_1 = HDF_DEBUG.write.channelForcing( _1, tiles_output, dirname, Fluid, p_Output, config.Flow.turbForcing.u.CHANNEL.Forcing);
C.free(dirname)
__fence(__execution, __block)
regentlib.assert(false, "NaN detected! Debug fields dumped in debugOut")
end
end
end
-------------------------------------------------------------------------------
-- RK-LOOP ROUTINES
-------------------------------------------------------------------------------
__demand(__inline)
task UpdatePrimitivesAndBCsFromConserved(Fluid : region(ispace(int3d), Fluid_columns),
tiles : ispace(int3d),
Fluid_Zones : PART.zones_partitions(Fluid, tiles),
Fluid_Ghost : PART.ghost_partitions(Fluid, tiles),
BCParams : BCOND.BCParamsStruct(Fluid, tiles),
BCRecycleAverage : region(ispace(int1d), BCOND.RecycleAverageType),
BCRecycleAverageFI : region(ispace(int1d), BCOND.RecycleAverageFIType),
config : Config,
Mix : MIX.Mixture,
Integrator_simTime : double)
where
reads(BCRecycleAverageFI),
reads writes(Fluid),
reads writes(BCRecycleAverage)
do
-- Unpack the partitions that we are going to need
var {p_All, p_Interior, p_AllBCs} = Fluid_Zones;
var {p_GradientGhosts} = Fluid_Ghost;
@ESCAPE if TIMING then @EMIT
var [T] = IO.Console_WriteTiming(0, config.Mapping, "UpdatePrimitivesAndBCsFromConserved", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
-- Update all primitive variables...
__demand(__index_launch)
for c in tiles do
VARS.UpdatePrimitiveFromConserved(p_All[c], p_Interior[c], Mix)
end
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdatePrimitivesAndBCsFromConserved", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
-- ...also in the ghost cells
BCOND.UpdateGhostPrimitives(Fluid,
tiles,
Fluid_Zones,
BCParams,
BCRecycleAverage,
BCRecycleAverageFI,
config,
Mix,
Integrator_simTime);
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdatePrimitivesAndBCsFromConserved", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
-- Update the mixture properties everywhere
__demand(__index_launch)
for c in tiles do
VARS.UpdatePropertiesFromPrimitive(p_All[c], p_All[c], Mix)
end
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdatePrimitivesAndBCsFromConserved", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
-- update values of conserved variables in ghost cells
__demand(__index_launch)
for c in tiles do
VARS.UpdateConservedFromPrimitive(p_All[c], p_AllBCs[c], Mix)
end
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdatePrimitivesAndBCsFromConserved", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
-- Compute velocity gradients
__demand(__index_launch)
for c in tiles do
VARS.GetVelocityGradients(p_GradientGhosts[c], p_All[c], Fluid.bounds)
end
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdatePrimitivesAndBCsFromConserved", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
end
__demand(__inline)
task UpdateDerivatives(Fluid : region(ispace(int3d), Fluid_columns),
tiles : ispace(int3d),
Fluid_Zones : PART.zones_partitions(Fluid, tiles),
Fluid_Ghost : PART.ghost_partitions(Fluid, tiles),
config : Config,
Mix : MIX.Mixture,
UseOldDerivatives : bool)
where
reads writes(Fluid)
do
-- Unpack the partitions that we are going to need
var {p_All, p_Interior, p_solved,
p_xNeg, p_xPos, p_yNeg, p_yPos, p_zNeg, p_zPos,
xNeg_ispace, xPos_ispace,
yNeg_ispace, yPos_ispace,
zNeg_ispace, zPos_ispace} = Fluid_Zones;
@ESCAPE if TIMING then @EMIT
var [T] = IO.Console_WriteTiming(0, config.Mapping, "UpdateDerivatives", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
-- Initialize time derivatives to 0 or minus the old value
if UseOldDerivatives then
__demand(__index_launch)
for c in tiles do
[RK.mkInitializeTimeDerivatives(true)](p_All[c])
end
else
__demand(__index_launch)
for c in tiles do
[RK.mkInitializeTimeDerivatives(false)](p_All[c])
end
end
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivatives", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
if (not config.Integrator.implicitChemistry) then
-- Add chemistry source terms
__demand(__index_launch)
for c in tiles do
CHEM.AddChemistrySources(p_All[c], p_solved[c], Mix)
end
end
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivatives", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
-- Add body forces
__demand(__index_launch)
for c in tiles do
RHS.AddBodyForces(p_All[c], p_solved[c], config.Flow.bodyForce)
end
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivatives", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
-- Add turbulent forcing
if config.Flow.turbForcing.type == SCHEMA.TurbForcingModel_CHANNEL then
-- Add forcing
__demand(__index_launch)
for c in tiles do
RHS.AddBodyForces(p_All[c], p_solved[c],
array(config.Flow.turbForcing.u.CHANNEL.Forcing, 0.0, 0.0))
end
end
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivatives", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
-- Use Euler fluxes to update conserved value derivatives
RHS.UpdateUsingEulerFlux(Fluid, tiles, Fluid_Zones, Fluid_Ghost, Mix, config);
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivatives", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
-- Use diffusion fluxes to update conserved variables derivatives
RHS.UpdateUsingDiffusionFlux(Fluid, tiles, Fluid_Zones, Fluid_Ghost, Mix, config);
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivatives", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
-- Update using NSCBC_Outflow bcs
if (config.BC.xBCRight.type == SCHEMA.FlowBC_NSCBC_Outflow) then
var MaxMach = 0.0
__demand(__index_launch)
for c in tiles do
MaxMach max= STAT.CalculateMaxMachNumber(p_All[c], p_Interior[c], 0)
end
__demand(__index_launch)
for c in xPos_ispace do
[RHS.mkUpdateUsingFluxNSCBCOutflow("xPos")](p_All[c],
p_xPos[c],
Mix, MaxMach, config.Grid.xWidth, config.BC.xBCRight.u.NSCBC_Outflow.P)
end
end
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivatives", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
if (config.BC.yBCLeft.type == SCHEMA.FlowBC_NSCBC_Outflow or config.BC.yBCRight.type == SCHEMA.FlowBC_NSCBC_Outflow) then
var MaxMach = 0.0
__demand(__index_launch)
for c in tiles do
MaxMach max= STAT.CalculateMaxMachNumber(p_All[c], p_Interior[c], 1)
end
if (config.BC.yBCLeft.type == SCHEMA.FlowBC_NSCBC_Outflow) then
__demand(__index_launch)
for c in yNeg_ispace do
[RHS.mkUpdateUsingFluxNSCBCOutflow("yNeg")](p_All[c],
p_yNeg[c],
Mix, MaxMach, config.Grid.yWidth, config.BC.yBCLeft.u.NSCBC_Outflow.P)
end
end
if (config.BC.yBCRight.type == SCHEMA.FlowBC_NSCBC_Outflow) then
__demand(__index_launch)
for c in yPos_ispace do
[RHS.mkUpdateUsingFluxNSCBCOutflow("yPos")](p_All[c],
p_yPos[c],
Mix, MaxMach, config.Grid.yWidth, config.BC.yBCRight.u.NSCBC_Outflow.P)
end
end
end
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivatives", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
-- Update using IncomingShock bcs
if (config.BC.yBCRight.type == SCHEMA.FlowBC_IncomingShock) then
__demand(__index_launch)
for c in yPos_ispace do
[RHS.mkUpdateUsingFluxNSCBCInflow("yPos")](p_All[c], p_yPos[c], Mix)
end
end
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivatives", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
-- Update using NSCBC_Inflow bcs
if ((config.BC.xBCLeft.type == SCHEMA.FlowBC_NSCBC_Inflow) or
(config.BC.xBCLeft.type == SCHEMA.FlowBC_RecycleRescaling)) then
__demand(__index_launch)
for c in xNeg_ispace do
[RHS.mkUpdateUsingFluxNSCBCInflow("xNeg")](p_All[c], p_xNeg[c], Mix)
end
end
@ESCAPE if TIMING then @EMIT
[T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivatives", @LINE, C.legion_get_current_time_in_nanos())
@TIME end @EPACSE
end
--__demand(__inline)
--task CorrectDerivatives(Fluid : region(ispace(int3d), Fluid_columns),
-- tiles : ispace(int3d),
-- Fluid_Zones : PART.zones_partitions(Fluid, tiles),
-- Fluid_Ghost : PART.ghost_partitions(Fluid, tiles),
-- config : Config,
-- Mix : MIX.Mixture)
--where
-- reads writes(Fluid)
--do
-- -- Unpack the partitions that we are going to need
-- var {p_All, p_x_divg, p_y_divg, p_z_divg} = Fluid_Zones;
-- var {p_XDiffGhosts, p_YDiffGhosts, p_ZDiffGhosts} = Fluid_Ghost;
--
--@ESCAPE if TIMING then @EMIT
-- [T] = IO.Console_WriteTiming([T], config.Mapping, "CorrectDerivatives", @LINE, C.legion_get_current_time_in_nanos())
--@TIME end @EPACSE
--
-- __demand(__index_launch)
-- for c in tiles do
-- [RHS.mkCorrectUsingFlux("z")](p_ZDiffGhosts[c], p_All[c], p_z_divg[c], Fluid.bounds, Mix)
-- end
--
--@ESCAPE if TIMING then @EMIT
-- [T] = IO.Console_WriteTiming([T], config.Mapping, "CorrectDerivatives", @LINE, C.legion_get_current_time_in_nanos())
--@TIME end @EPACSE
--
-- __demand(__index_launch)
-- for c in tiles do
-- [RHS.mkCorrectUsingFlux("y")](p_YDiffGhosts[c], p_All[c], p_y_divg[c], Fluid.bounds, Mix);
-- end
--
--@ESCAPE if TIMING then @EMIT
-- [T] = IO.Console_WriteTiming([T], config.Mapping, "CorrectDerivatives", @LINE, C.legion_get_current_time_in_nanos())
--@TIME end @EPACSE
--
-- __demand(__index_launch)
-- for c in tiles do
-- [RHS.mkCorrectUsingFlux("x")](p_XDiffGhosts[c], p_All[c], p_x_divg[c], Fluid.bounds, Mix);
-- end
--
--@ESCAPE if TIMING then @EMIT
-- [T] = IO.Console_WriteTiming([T], config.Mapping, "CorrectDerivatives", @LINE, C.legion_get_current_time_in_nanos())
--@TIME end @EPACSE
--
--end
-------------------------------------------------------------------------------
-- MAIN SIMULATION
-------------------------------------------------------------------------------
local function mkInstance() local INSTANCE = {}
-----------------------------------------------------------------------------
-- Symbols shared between quotes
-----------------------------------------------------------------------------
local startTime = regentlib.newsymbol()
local Grid = {
xBnum = regentlib.newsymbol(),
yBnum = regentlib.newsymbol(),
zBnum = regentlib.newsymbol(),
NX = regentlib.newsymbol(),
NY = regentlib.newsymbol(),
NZ = regentlib.newsymbol(),
numTiles = regentlib.newsymbol(),
NXout = regentlib.newsymbol(),
NYout = regentlib.newsymbol(),
NZout = regentlib.newsymbol(),
numTilesOut = regentlib.newsymbol(),
}
local BC = BCOND.BCDataList
local Integrator_deltaTime = regentlib.newsymbol()
local Integrator_simTime = regentlib.newsymbol()
local Integrator_timeStep = regentlib.newsymbol()
local Integrator_exitCond = regentlib.newsymbol()
local Mix = regentlib.newsymbol()
local Fluid = regentlib.newsymbol("Fluid")
local Fluid_copy = regentlib.newsymbol("Fluid_copy")
local Fluid_bounds = regentlib.newsymbol("Fluid_bounds")
local tiles = regentlib.newsymbol()
local tiles_output = regentlib.newsymbol()
local Fluid_Zones = regentlib.newsymbol("Fluid_Zones")
local Fluid_Ghost = regentlib.newsymbol("Fluid_Ghost")
local Fluid_Output = regentlib.newsymbol("Fluid_Output")
local Fluid_Output_copy = regentlib.newsymbol("Fluid_Output_copy")
local interior_volume = regentlib.newsymbol(double)
local Averages
if AVERAGES then
Averages = AVG.AvgList
end
local Probes = PROBES.ProbesList
-----------------------------------------------------------------------------
-- Exported symbols
-----------------------------------------------------------------------------
INSTANCE.Grid = Grid
INSTANCE.Integrator_deltaTime = Integrator_deltaTime
INSTANCE.Integrator_simTime = Integrator_simTime
INSTANCE.Integrator_timeStep = Integrator_timeStep
INSTANCE.Integrator_exitCond = Integrator_exitCond
INSTANCE.Fluid = Fluid
INSTANCE.Fluid_copy = Fluid_copy
INSTANCE.tiles = tiles
INSTANCE.Fluid_Zones = Fluid_Zones
-----------------------------------------------------------------------------
-- Symbol declaration & initialization
-----------------------------------------------------------------------------
function INSTANCE.DeclSymbols(config) return rquote
---------------------------------------------------------------------------
-- Preparation
---------------------------------------------------------------------------
-- Start timer
var [startTime] = C.legion_get_current_time_in_micros() / 1000;
-- Write console header
IO.Console_WriteHeader(config.Mapping)
---------------------------------------------------------------------------
-- Initialize the mixture
---------------------------------------------------------------------------
var [Mix] = MIX.InitMixture(config)
---------------------------------------------------------------------------
-- Declare & initialize state variables
---------------------------------------------------------------------------
-- Determine number of ghost cells in each direction
-- 0 ghost cells if periodic and 1 otherwise
var [Grid.xBnum] = 1
var [Grid.yBnum] = 1
var [Grid.zBnum] = 1
if config.BC.xBCLeft.type == SCHEMA.FlowBC_Periodic then Grid.xBnum = 0 end
if config.BC.yBCLeft.type == SCHEMA.FlowBC_Periodic then Grid.yBnum = 0 end
if config.BC.zBCLeft.type == SCHEMA.FlowBC_Periodic then Grid.zBnum = 0 end
var [Grid.NX] = config.Mapping.tiles[0]
var [Grid.NY] = config.Mapping.tiles[1]
var [Grid.NZ] = config.Mapping.tiles[2]
var [Grid.numTiles] = Grid.NX * Grid.NY * Grid.NZ
var [Grid.NXout] = int(config.Mapping.tiles[0]/config.Mapping.tilesPerRank[0])
var [Grid.NYout] = int(config.Mapping.tiles[1]/config.Mapping.tilesPerRank[1])
var [Grid.NZout] = int(config.Mapping.tiles[2]/config.Mapping.tilesPerRank[2])
var [Grid.numTilesOut] = Grid.NXout * Grid.NYout * Grid.NZout
var [Integrator_exitCond] = true
var [Integrator_simTime] = config.Integrator.startTime
var [Integrator_timeStep] = config.Integrator.startIter
var [Integrator_deltaTime] = config.Integrator.fixedDeltaTime;
---------------------------------------------------------------------------
-- Declare BC symbols
---------------------------------------------------------------------------
[BCOND.CheckInput(BC, config)];
---------------------------------------------------------------------------
-- Initialize forcing values
---------------------------------------------------------------------------
if config.Flow.turbForcing.type == SCHEMA.TurbForcingModel_CHANNEL then
config.Flow.turbForcing.u.CHANNEL.Forcing max= 1.0
end
---------------------------------------------------------------------------
-- Create Regions and Partitions
---------------------------------------------------------------------------
var sampleId = config.Mapping.sampleId
-- Create Fluid Regions
var is_Fluid = ispace(int3d, {x = config.Grid.xNum + 2*Grid.xBnum,
y = config.Grid.yNum + 2*Grid.yBnum,
z = config.Grid.zNum + 2*Grid.zBnum})
var [Fluid] = region(is_Fluid, Fluid_columns);
[UTIL.emitRegionTagAttach(Fluid, MAPPER.SAMPLE_ID_TAG, sampleId, int)];
var [Fluid_bounds] = [Fluid].bounds
var [Fluid_copy] = region(is_Fluid, Fluid_columns);
[UTIL.emitRegionTagAttach(Fluid_copy, MAPPER.SAMPLE_ID_TAG, sampleId, int)];
-- Partitioning domain
var [tiles] = ispace(int3d, {Grid.NX, Grid.NY, Grid.NZ})
-- Fluid Partitioning
var [Fluid_Zones] = PART.PartitionZones(Fluid, tiles, config, Grid.xBnum, Grid.yBnum, Grid.zBnum)
-- Unpack the partitions that we are going to need
var {p_All} = Fluid_Zones;
-- Output partitionig
var [tiles_output] = ispace(int3d, {Grid.NXout, Grid.NYout, Grid.NZout})
var [Fluid_Output] = PART.PartitionOutput(Fluid, tiles_output, config,
Grid.xBnum, Grid.yBnum, Grid.zBnum)
var [Fluid_Output_copy] = PART.PartitionOutput(Fluid_copy, tiles_output, config,
Grid.xBnum, Grid.yBnum, Grid.zBnum);
---------------------------------------------------------------------------
-- Declare BC symbols
---------------------------------------------------------------------------
[BCOND.DeclSymbols(BC, Fluid, tiles, Fluid_Zones, Grid, config, Mix)];
---------------------------------------------------------------------------
-- Create one-dimensional averages
---------------------------------------------------------------------------
@ESCAPE if AVERAGES then @EMIT
[AVG.DeclSymbols(Averages, Grid, Fluid, p_All, config, MAPPER)];
@TIME end @EPACSE
---------------------------------------------------------------------------
-- Create probes
---------------------------------------------------------------------------
[PROBES.DeclSymbols(Probes, Grid, Fluid, p_All, config)];
---------------------------------------------------------------------------
-- Create directory for volume probes
---------------------------------------------------------------------------
for p=0, config.IO.volumeProbes.length do
var vProbe = config.IO.volumeProbes.values[p]
var dirname = [&int8](C.malloc(256))
C.snprintf(dirname, 256, '%s/%s', config.Mapping.outDir, vProbe.outDir)
var _1 = IO.createDir(dirname)
C.free(dirname)
end
end end -- DeclSymbols
-----------------------------------------------------------------------------
-- Region initialization
-----------------------------------------------------------------------------
function INSTANCE.InitRegions(config) return rquote
---------------------------------------------------------------------------
-- Initialize fluid region
---------------------------------------------------------------------------
InitializeCell(Fluid, tiles, Fluid_Zones);
-- Unpack the partitions that we are going to need
var {p_All, p_Interior, p_AllBCs,
xNeg, xPos, yNeg, yPos, zNeg, zPos,
p_xNeg, p_xPos, p_yNeg, p_yPos, p_zNeg, p_zPos} = Fluid_Zones
var {p_Output} = Fluid_Output
var {p_Output_copy=p_Output} = Fluid_Output_copy
---------------------------------------------------------------------------
-- Initialize grid operators
---------------------------------------------------------------------------
METRIC.InitializeOperators(Fluid, tiles, p_All)
-- Enforce BCs on the operators
__demand(__index_launch)
for c in tiles do [METRIC.mkCorrectGhostOperators("x")](p_All[c], Fluid_bounds, config.BC.xBCLeft.type, config.BC.xBCRight.type, Grid.xBnum, config.Grid.xNum) end
__demand(__index_launch)
for c in tiles do [METRIC.mkCorrectGhostOperators("y")](p_All[c], Fluid_bounds, config.BC.yBCLeft.type, config.BC.yBCRight.type, Grid.yBnum, config.Grid.yNum) end
__demand(__index_launch)
for c in tiles do [METRIC.mkCorrectGhostOperators("z")](p_All[c], Fluid_bounds, config.BC.zBCLeft.type, config.BC.zBCRight.type, Grid.zBnum, config.Grid.zNum) end
-- Create partitions to support stencils
var [Fluid_Ghost] = PART.PartitionGhost(Fluid, tiles, Fluid_Zones)
-- Unpack the ghost partitions that we are going to need
var {p_MetricGhostsX, p_MetricGhostsY, p_MetricGhostsZ, p_MetricGhosts} = Fluid_Ghost
-- Wait for the ghost partitions to be created
-- TODO: we could aviod this fence by changing the mapper such that
-- we ensure that all the recurring tasks are mapped on regions
-- collocated with the Ghosts
__fence(__execution, __block)
__demand(__index_launch)
for c in tiles do
dummyAllocationTask(p_MetricGhosts[c])
end
__fence(__mapping, __block)
-- If we read a restart file it will contain the geometry
if config.Flow.initCase.type ~= SCHEMA.FlowInitCase_Restart then
__demand(__index_launch)
for c in tiles do
GRID.InitializeGeometry(p_All[c],
config.Grid.xType, config.Grid.yType, config.Grid.zType,
config.Grid.xStretching, config.Grid.yStretching, config.Grid.zStretching,
Grid.xBnum, config.Grid.xNum, config.Grid.origin[0], config.Grid.xWidth,
Grid.yBnum, config.Grid.yNum, config.Grid.origin[1], config.Grid.yWidth,
Grid.zBnum, config.Grid.zNum, config.Grid.origin[2], config.Grid.zWidth)
end
-- Set ghost geometry based on BCs
GRID.InitializeGhostGeometry(Fluid, tiles, Fluid_Zones, config)
end
---------------------------------------------------------------------------
-- Initialize BC profiles
---------------------------------------------------------------------------
-- Read from file...
-- TODO: this will eventually become a separate call for each BC
if BC.readProfiles then
PROFILES.HDF.load(0, tiles_output, BC.ProfilesDir, Fluid, Fluid_copy, p_Output, p_Output_copy)
end
-- ... or use the config
[PROFILES.mkInitializeProfilesField("xBCRight")](xPos[0], config, Mix);
[PROFILES.mkInitializeProfilesField("xBCLeft" )](xNeg[0], config, Mix);
[PROFILES.mkInitializeProfilesField("yBCRight")](yPos[0], config, Mix);
[PROFILES.mkInitializeProfilesField("yBCLeft" )](yNeg[0], config, Mix);
[PROFILES.mkInitializeProfilesField("zBCRight")](zPos[0], config, Mix);
[PROFILES.mkInitializeProfilesField("zBCLeft" )](zNeg[0], config, Mix);
---------------------------------------------------------------------------
-- Initialize averages
---------------------------------------------------------------------------
@ESCAPE if AVERAGES then @EMIT
-- Initialize averages
[AVG.InitRakesAndPlanes(Averages)];
@TIME end @EPACSE
---------------------------------------------------------------------------
-- Initialize solution
---------------------------------------------------------------------------
if config.Flow.initCase.type == SCHEMA.FlowInitCase_Uniform then
var initMolarFracs = CHEM.ParseConfigMixture(config.Flow.initCase.u.Uniform.molarFracs, Mix)
__demand(__index_launch)
for c in tiles do
INIT.InitializeUniform(p_All[c],
config.Flow.initCase.u.Uniform.pressure,
config.Flow.initCase.u.Uniform.temperature,
config.Flow.initCase.u.Uniform.velocity,
initMolarFracs)
end
elseif config.Flow.initCase.type == SCHEMA.FlowInitCase_Random then
var initMolarFracs = CHEM.ParseConfigMixture(config.Flow.initCase.u.Random.molarFracs, Mix)
__demand(__index_launch)
for c in tiles do
INIT.InitializeRandom(p_All[c],
config.Flow.initCase.u.Random.pressure,
config.Flow.initCase.u.Random.temperature,
config.Flow.initCase.u.Random.magnitude,
initMolarFracs)
end
elseif config.Flow.initCase.type == SCHEMA.FlowInitCase_TaylorGreen2DVortex then
var initMolarFracs = CHEM.ParseConfigMixture(config.Flow.initCase.u.TaylorGreen2DVortex.molarFracs, Mix)
__demand(__index_launch)
for c in tiles do
INIT.InitializeTaylorGreen2D(p_All[c],
config.Flow.initCase.u.TaylorGreen2DVortex.pressure,
config.Flow.initCase.u.TaylorGreen2DVortex.temperature,
config.Flow.initCase.u.TaylorGreen2DVortex.velocity,
initMolarFracs,