-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'CurveFromFile' into 'master'
Read curve definitions from binary file See merge request ogs/ogs!5127
- Loading branch information
Showing
14 changed files
with
193 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The default is false. If this option is true, the coordinates and values of the curve are read from a binary file. The precision of the values is double and the byte ordering must be little endian. This option is recommended for large curve definitions, which may fail to directly read from the project file. |
1 change: 1 addition & 0 deletions
1
Documentation/ProjectFile/prj/time_loop/output/t_fixed_output_times_from_file.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Read **\<fixed_output_times\>** from binary file (double precision, little endian). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Tests/Data/Parabolic/T/3D_Beier_sandbox/beier_sandbox_binary_curve.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<OpenGeoSysProjectDiff base_file="beier_sandbox.prj"> | ||
<add sel="/*/curves/curve"> | ||
<read_from_file>true</read_from_file> | ||
</add> | ||
<replace sel="/*/time_loop/output/prefix/text()">beier_sandbox_binary_curve</replace> | ||
<replace sel="/*/curves/curve/coords/text()">inflow_temperature_coords.bin</replace> | ||
<replace sel="/*/curves/curve/values/text()">inflow_temperature_values.bin</replace> | ||
</OpenGeoSysProjectDiff> |
Binary file added
BIN
+22.1 KB
Tests/Data/Parabolic/T/3D_Beier_sandbox/inflow_temperature_coords.bin
Binary file not shown.
Binary file added
BIN
+22.1 KB
Tests/Data/Parabolic/T/3D_Beier_sandbox/inflow_temperature_values.bin
Binary file not shown.
33 changes: 33 additions & 0 deletions
33
Tests/Data/Parabolic/T/3D_Beier_sandbox/read_values_from_prj_curve.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import inspect | ||
import os | ||
import xml.etree.ElementTree as ET | ||
|
||
import numpy as np | ||
|
||
file = inspect.getfile(inspect.currentframe()) | ||
prj_path = os.path.split(os.path.realpath(file))[0] | ||
|
||
# read prj-data | ||
tree = ET.parse(prj_path + "/beier_sandbox.prj") | ||
root = tree.getroot() | ||
|
||
curve_elements = root.findall(".//curve") | ||
for curve in curve_elements: | ||
curve_name = curve.find("name").text | ||
|
||
# read coordinates | ||
coords_element = curve.find("coords") | ||
coords_text = coords_element.text # replace("\n", " ") | ||
coords_array = np.fromstring(coords_text, dtype=float, sep=" ") | ||
# Store array in binary format | ||
coords_array.astype("<f8").tofile( | ||
prj_path + f"/{curve_name}_coords.bin" | ||
) # < - little Endian | f - float | 8 - Bytes equal to 64bit(double) | ||
|
||
# read values | ||
values_element = curve.find("values") | ||
values_text = values_element.text # replace("\n", " ") | ||
values_array = np.fromstring(values_text, dtype=float, sep=" ") | ||
values_array.astype("<f8").tofile( | ||
prj_path + f"/{curve_name}_values.bin" | ||
) # < - little Endian | f - float | 8 - Bytes equal to 64bit(double) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters