neko
neko copied to clipboard
Initial condition from fld or chkp
Adds some functionalities outlined in #1283 for using fields as an initial condition.
Basically allows to initialize the simulation from fld
or chkp
files with the keyword case.<fluid/scalar>.initial_condition.type = field
.
- For chkp the already existing interpolations (mesh to mesh and from one polynomial order to another) are usable.
- For fld we basically do the exact same interpolation workflow as chkp, but we wrap the findpts part in
fld_data_file
instead of having it in the reader. Chkp should perhaps be modified to do that as well if we decide to go that way. - I am opening this as draft for others to add the missing functionalities if they so want, see the list below for the missing functionalities :)
Todo
So far this needs to be tested with:
- [x] AMD GPUs
- [x] Nvidia GPUs
- [x] CPUs
Functionalities
- [x] Read from chkp with or without interpolation
- [x] Read from fld without interpolation
- [x] Read from fld with interpolation (different polynomial order)
- [x] Read from fld with interpolation (mesh to mesh)
- [ ] ~~Read from fld with 2D extrusion~~ (I think this is already quite a lot so probably we can skip this for now?)
Usage
chkp
We read the entire chkp file but only apply u,v,w,p
and/or s
.
"initial_condition": {
"type": "field",
"file_name": "fluid00001.chkp",
}
Any interpolation that chkp
does when reading the file can also be done here, so essentially one can use a chkp file with mesh to mesh interpolation or just interpolation from different polynomial order (the latter doesn't need any additional keywords):
"initial_condition": {
"type": "field",
"file_name": "fluid00001.chkp",
"previous_mesh": "mesh.nmsh",
"tolerance": 1e-6
}
fld
Without interpolation
Here I see a two different use cases:
The first one would be where one has a series of field0.fld
files and we select the index of the file we want to sample.
"initial_condition": {
"type": "field",
"file_name": "field0.fld" or "field0.nek5000",
"sample_index": 5 <--- this will read field0.f00005
}
Without specifying sample_index
we read the last fld file in the series by default, provided that a field0.nek5000
file exists, if not it will default to reading field0.f00000
.
The second use case is if one only has a single field file for example myfield0.f00100
, then one can directly use that file name and the sample_index will be retrieved from the extension f00100
:
"initial_condition": {
"type": "field",
"file_name": "myfield0.f00100"
}
With interpolation
The interpolation between two different polynomial orders is done automatically without having to specify anything (same as for chkp).
In order to use the mesh to mesh interpolation, we use the interpolate
keyword:
"initial_condition": {
"type": "field",
"file_name": "field0.fld" or "field0.nek5000",
"sample_index": 5, <--- this will read field0.f00005
"interpolate": true
}
When a fld
series is given as file_name
, we will by default read the x,y,z
coordinates in the first fld
file of the series. If we give a single .f*****
file, it will try to look for the first file in the series (if it can find a .nek5000
file, otherwise it will read the f00000
file) for coordinates. If the coordinates are in a specific file we can also provide the index of the file with sample_mesh_index
:
"initial_condition": {
"type": "field",
"file_name": "myfield0.f00100",
"interpolate": true,
"sample_mesh_index": 99 <--- means that the coordinates are in myfield0.f00099
}
Other changes
I added some logging for the initial condition so it becomes cleaner when using the fld
reader that outputs some messages, that gives something like:
---Fluid initial condition----
Type: field
File name: results/field0.fld
Reading meta file for fld series
Name: field0
Start counter : 0
Number of samples: 17
Reading fld file results/field0.f00000
Reading fld file results/field0.f00016
---Scalar initial condition---
Type: field
File name: results/field0.fld
Sample index: 00005
Reading meta file for fld series
Name: field0
Start counter : 0
Number of samples: 17
Reading fld file results/field0.f00005
But it will also output all the values provided if one uses the other initial condition types like blasius
, uniform
, point_zone
etc.
---Fluid initial condition----
Type: blasius
delta : 0.001000
Approximation: sin
Value: [ 1.000000, 0.000000, 0.000000]