Skip to content

Commit 114bdac

Browse files
committed
Update Celeris for current forces, fixes, etc.
1 parent bf5e1a2 commit 114bdac

File tree

5 files changed

+316
-189
lines changed

5 files changed

+316
-189
lines changed

modules/createEVENT/Celeris/Celeris.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -375,26 +375,7 @@ def main():
375375
# Read the number of floors
376376
floorsCount = GetFloorsCount(arguments.filenameAIM) # noqa: N816
377377
filenameEVENT = arguments.filenameEVENT # noqa: N816
378-
379-
# result = subprocess.run( # noqa: S603
380-
# [ # noqa: S607
381-
# sys.executable,
382-
# scriptName,
383-
# '-d',
384-
# caseDirectory,
385-
# '-f',
386-
# configFilename,
387-
# '-b',
388-
# bathymetryFilename,
389-
# '-w',
390-
# waveFilename,
391-
# # f'{os.path.realpath(os.path.dirname(__file__))}'
392-
# # + '/taichi_script.py',
393-
# ],
394-
# stdout=subprocess.PIPE,
395-
# check=False,
396-
# )
397-
378+
398379
forces = []
399380
for i in range(floorsCount):
400381
forces.append(FloorForces(recorderID=(i + 1))) # noqa: PERF401
@@ -427,8 +408,6 @@ def main():
427408
bathymetryFilename,
428409
'-w',
429410
waveFilename,
430-
# f'{os.path.realpath(os.path.dirname(__file__))}'
431-
# + '/taichi_script.py',
432411
],
433412
stdout=subprocess.PIPE,
434413
check=False,

modules/createEVENT/Celeris/celeris/domain.py

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,24 @@ def __init__(self, filename=None, datatype=None, path=None):
3333
self.datatype = datatype
3434
self.path = path
3535

36-
def z(self): # noqa: D102
36+
def z(self, seaLevel=0.0): # noqa: D102
3737
if self.datatype == 'xyz':
3838
if self.path != None: # noqa: E711
3939
if self.filename == None: # noqa: E711
4040
self.filename = 'test_curve.xyz'
4141
return np.loadtxt(os.path.join(self.path, self.filename)) # noqa: PTH118
4242
return np.loadtxt(self.filename)
43+
if self.datatype == 'xz':
44+
if self.path!=None:
45+
return np.loadtxt(os.path.join(self.path, self.filename))
46+
else:
47+
return np.loadtxt(self.filename)
4348
if self.datatype == 'celeris' or self.datatype == 'txt': # noqa: PLR1714
4449
if self.path != None: # noqa: E711
4550
if self.filename == None: # noqa: E711
4651
self.filename = 'bathy.txt'
4752
bathy = np.loadtxt(os.path.join(self.path, self.filename)) # noqa: PTH118
53+
bathy = bathy - seaLevel
4854
return bathy * -1
4955
return 'No supported format'
5056

@@ -58,10 +64,10 @@ def __init__( # noqa: C901
5864
self,
5965
celeris=True, # noqa: FBT002
6066
precision=ti.f32,
61-
North=None, # noqa: N803
62-
South=None, # noqa: N803
63-
East=None, # noqa: N803
64-
West=None, # noqa: N803
67+
North=10, # noqa: N803
68+
South=10, # noqa: N803
69+
East=10, # noqa: N803
70+
West=10, # noqa: N803
6571
WaveType=-1, # noqa: N803
6672
Amplitude=0.5, # noqa: N803
6773
Period=10.0, # noqa: N803
@@ -256,6 +262,8 @@ def __init__( # noqa: C901, PLR0913
256262
self.seaLevel = float(self.configfile['seaLevel'])
257263
elif checjson('sea_level', self.configfile) == 1:
258264
self.seaLevel = float(self.configfile['sea_level'])
265+
elif checjson('swl', self.configfile) == 1:
266+
self.seaLevel = float(self.configfile['swl'])
259267
else:
260268
self.seaLevel = 0.0
261269

@@ -303,6 +311,15 @@ def __init__( # noqa: C901, PLR0913
303311
self.Courant = Courant
304312
self.base_depth_ = base_depth
305313

314+
if self.topodata.datatype=='xz':
315+
self.Ny = 1
316+
self.dy = 1.0
317+
self.dx = (self.x2 - self.x1)/self.Nx
318+
self.isManning = isManning
319+
self.friction = friction
320+
self.Courant = Courant
321+
self.base_depth_ = base_depth
322+
306323
self.pixels = ti.field(float, shape=(self.Nx, self.Ny))
307324

308325
def topofield(self): # noqa: D102
@@ -311,7 +328,7 @@ def topofield(self): # noqa: D102
311328
np.arange(0.0, self.Nx * self.dx, self.dx),
312329
np.arange(0, self.Ny * self.dy, self.dy),
313330
)
314-
foo = self.topodata.z()
331+
foo = self.topodata.z(seaLevel=self.seaLevel)
315332
return x_out, y_out, foo.T
316333
if self.topodata.datatype == 'xyz': # noqa: RET503
317334
dum = self.topodata.z()
@@ -321,10 +338,19 @@ def topofield(self): # noqa: D102
321338
)
322339
dem = griddata(dum[:, :2], dum[:, 2], (x_out, y_out), method='nearest')
323340
return x_out.T, y_out.T, dem.T
341+
if self.topodata.datatype=='xz':
342+
dum = self.topodata.z()
343+
x_out = np.arange( self.x1, self.x2, self.dx)
344+
dem = np.interp(x_out,dum[:,0],dum[:,1])
345+
return x_out, dem
324346

325347
def bottom(self): # noqa: D102
326348
nbottom = np.zeros((4, self.Nx, self.Ny), dtype=ti2np(self.precision))
327-
nbottom[2] = -1.0 * self.topofield()[2]
349+
if self.topodata.datatype=='xz':
350+
# VERSION 1D
351+
nbottom[2,:,0] =-1.0* self.topofield()[1]
352+
else:
353+
nbottom[2] =-1.0* self.topofield()[2]
328354
nbottom[3] = 99.0 # To be used in neardry
329355

330356
bottom = ti.field(self.precision, shape=(4, self.Nx, self.Ny))
@@ -339,11 +365,20 @@ def grid(self): # noqa: D102
339365

340366
def maxdepth(self): # noqa: D102
341367
if self.base_depth_ == None: # noqa: E711
342-
return np.max(self.topofield()[2])
343-
return self.base_depth_
368+
# VERSION 1D
369+
if self.topodata.datatype=='xz':
370+
return np.max(self.topofield()[1])
371+
else:
372+
return np.max(self.topofield()[2])
373+
else:
374+
return self.base_depth_
344375

345376
def maxtopo(self): # noqa: D102
346-
return np.min(self.topofield()[2])
377+
# VERSION 1D
378+
if self.topodata.datatype=='xz':
379+
return np.min(self.topofield()[1])
380+
else:
381+
return np.min(self.topofield()[2])
347382

348383
def dt(self): # noqa: D102
349384
maxdepth = self.maxdepth() # noqa: F841

modules/createEVENT/Celeris/celeris/runner.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def Evolve_0(self): # noqa: N802, D102
7272
def Evolve_Steps(self, step=0): # noqa: C901, N802, D102
7373
i = step
7474
self.solver.update_step()
75-
self.solver.Pass1(int(i))
75+
self.solver.Pass1(step=int(i))
7676

7777
if self.solver.useSedTransModel:
7878
self.solver.Pass1_SedTrans()
@@ -124,7 +124,7 @@ def Evolve_Steps(self, step=0): # noqa: C901, N802, D102
124124
src=self.solver.NewState_Sed, dst=self.solver.State_Sed
125125
)
126126

127-
self.solver.Pass1(int(i))
127+
self.solver.Pass1(step=int(i))
128128

129129
if self.solver.useSedTransModel:
130130
self.solver.Pass1_SedTrans()
@@ -484,7 +484,7 @@ def Evolve_Display( # noqa: C901, N802, D102
484484
plotpath = './plots'
485485
if not os.path.exists(plotpath): # noqa: PTH110
486486
os.makedirs(plotpath) # noqa: PTH103
487-
i = 0.0
487+
i = 0
488488
show_gui = None
489489
use_ggui = None
490490
window = None
@@ -640,7 +640,7 @@ def Evolve_Display( # noqa: C901, N802, D102
640640

641641
self.output_forces = True
642642
if (self.output_forces):
643-
self.solver.write_hydrostatic_force()
643+
self.solver.write_force()
644644

645645
if i > self.maxsteps:
646646
if self.saveimg:

0 commit comments

Comments
 (0)