Skip to content
Snippets Groups Projects
Commit 9ae89761 authored by Max Jaeschke's avatar Max Jaeschke Committed by Dmitri Naumov
Browse files

Add test for reading curve from binary file

parent f38743fb
No related branches found
No related tags found
No related merge requests found
...@@ -96,6 +96,20 @@ AddTest( ...@@ -96,6 +96,20 @@ AddTest(
beier_sandbox_ts_10_t_600.000000.vtu beier_sandbox_newton_ts_10_t_600.000000.vtu temperature_soil temperature_soil 0 1e-13 beier_sandbox_ts_10_t_600.000000.vtu beier_sandbox_newton_ts_10_t_600.000000.vtu temperature_soil temperature_soil 0 1e-13
) )
AddTest(
NAME HeatTransportBHE_1U_3D_beier_sandbox_binary_curve
PATH Parabolic/T/3D_Beier_sandbox
EXECUTABLE ogs
EXECUTABLE_ARGS beier_sandbox_binary_curve.xml
WRAPPER time
TESTER vtkdiff
REQUIREMENTS NOT OGS_USE_MPI
RUNTIME 20
DIFF_DATA
beier_sandbox_ts_10_t_600.000000.vtu beier_sandbox_binary_curve_ts_10_t_600.000000.vtu temperature_BHE1 temperature_BHE1 0 1e-14
beier_sandbox_ts_10_t_600.000000.vtu beier_sandbox_binary_curve_ts_10_t_600.000000.vtu temperature_soil temperature_soil 0 1e-12
)
AddTest( AddTest(
NAME HeatTransportBHE_1U_3D_beier_sandbox_algebraicBC NAME HeatTransportBHE_1U_3D_beier_sandbox_algebraicBC
PATH Parabolic/T/3D_Beier_sandbox PATH Parabolic/T/3D_Beier_sandbox
......
<?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>
File added
File added
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment