Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TurTLE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TurTLE
TurTLE
Commits
b39b430f
Commit
b39b430f
authored
5 months ago
by
Cristian Lalescu
Browse files
Options
Downloads
Patches
Plain Diff
adds mechanism for control of initial condition behavior
parent
294a2437
No related branches found
No related tags found
1 merge request
!134
adds mechanism for control of initial condition behavior
Pipeline
#239606
passed
5 months ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
TurTLE/DNS.py
+46
-30
46 additions, 30 deletions
TurTLE/DNS.py
with
46 additions
and
30 deletions
TurTLE/DNS.py
+
46
−
30
View file @
b39b430f
...
@@ -929,40 +929,56 @@ class DNS(_code):
...
@@ -929,40 +929,56 @@ class DNS(_code):
return
None
return
None
def
generate_initial_condition
(
def
generate_initial_condition
(
self
,
self
,
opt
=
None
):
opt
=
None
,
need_field
=
None
,
checkpoint_field
=
None
):
"""
Creates the
"
checkpoint 0
"
file.
Keyword arguments:
opt --- options object, this method may access any of
* opt.src_simname,
* opt.src_work_dir,
* opt.src_iteration
need_field --- boolean: does the DNS need the
"
0
"
iteration field
to be present in the
"
checkpoint 0
"
file?
checkpoint_field --- string: name of field used for checkpoints, one of
'
velocity
'
or
'
vorticity
'
.
"""
# take care of fields' initial condition
# take care of fields' initial condition
if
type
(
checkpoint_field
)
==
type
(
None
):
if
self
.
dns_type
in
[
'
NSE
'
,
'
NSE_alt_dealias
'
]:
checkpoint_field
=
'
velocity
'
else
:
checkpoint_field
=
'
vorticity
'
# first, check if initial field exists
# first, check if initial field exists
need_field
=
False
if
type
(
need_field
)
==
type
(
None
):
if
self
.
check_current_vorticity_exists
:
need_field
=
False
need_field
=
True
if
self
.
check_current_vorticity_exists
:
if
self
.
dns_type
in
[
'
NSE
'
,
'
NSE_alt_dealias
'
]:
checkpoint_field
=
'
velocity
'
else
:
checkpoint_field
=
'
vorticity
'
if
self
.
dns_type
in
[
'
NSE
'
,
'
NSE_alt_dealias
'
,
'
NSVE
'
,
'
NSVE_no_output
'
,
'
static_field
'
,
'
NSVEparticles
'
,
'
NSVEcomplex_particles
'
,
'
NSVE_Stokes_particles
'
,
'
NSVEparticles_no_output
'
,
'
NSVEp_extra_sampling
'
]:
if
not
os
.
path
.
exists
(
self
.
get_checkpoint_0_fname
()):
need_field
=
True
need_field
=
True
else
:
if
self
.
dns_type
in
[
f
=
h5py
.
File
(
self
.
get_checkpoint_0_fname
(),
'
r
'
)
'
NSE
'
,
try
:
'
NSE_alt_dealias
'
,
dset
=
f
[
checkpoint_field
+
'
/complex/0
'
]
'
NSVE
'
,
need_field
=
(
dset
.
shape
!=
(
self
.
parameters
[
'
ny
'
],
'
NSVE_no_output
'
,
self
.
parameters
[
'
nz
'
],
'
static_field
'
,
self
.
parameters
[
'
nx
'
]
//
2
+
1
,
'
NSVEparticles
'
,
3
))
'
NSVEcomplex_particles
'
,
except
:
'
NSVE_Stokes_particles
'
,
'
NSVEparticles_no_output
'
,
'
NSVEp_extra_sampling
'
]:
if
not
os
.
path
.
exists
(
self
.
get_checkpoint_0_fname
()):
need_field
=
True
need_field
=
True
f
.
close
()
else
:
f
=
h5py
.
File
(
self
.
get_checkpoint_0_fname
(),
'
r
'
)
try
:
dset
=
f
[
checkpoint_field
+
'
/complex/0
'
]
need_field
=
(
dset
.
shape
!=
(
self
.
parameters
[
'
ny
'
],
self
.
parameters
[
'
nz
'
],
self
.
parameters
[
'
nx
'
]
//
2
+
1
,
3
))
except
:
need_field
=
True
f
.
close
()
if
need_field
:
if
need_field
:
# sanity check. User cannot demand a random initial condition and a source simulation at the same time.
# sanity check. User cannot demand a random initial condition and a source simulation at the same time.
assert
((
len
(
opt
.
src_simname
)
==
0
)
or
(
self
.
parameters
[
'
field_random_seed
'
]
==
0
)),
\
assert
((
len
(
opt
.
src_simname
)
==
0
)
or
(
self
.
parameters
[
'
field_random_seed
'
]
==
0
)),
\
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment