Hi Max,
After working out howto setup a mesh (in docker + macosx) i found that this code somewhat works.
root ➜ /workspace/cxc/adjusted/test $ cat mesh8.py
import pyvista as pv
import pathlib
from typing import List
import os
import ogstools as ot
from ogstools.meshlib import Mesh
from ogstools.meshlib.gmsh_BHE import BHE, gen_bhe_mesh
Debug: Check Gmsh and environment
print(“Gmsh version:”)
os.system(“gmsh --version”)
print(“Temporary files before meshing:”)
os.system(“ls -l /tmp/*.msh || echo ‘No .msh files found’”)
Scaling factor for mesh sizes (based on depth increase: 16300 / 70 ≈ 232.857)
scaling_factor = 16300.0 / 70.0
inner_mesh_size = 6.0 * (scaling_factor ** 0.5) # Square root scaling for balance
outer_mesh_size = 12.0 * (scaling_factor ** 0.5)
dist_box_x = 3.0 * (scaling_factor ** 0.5)
dist_box_y = 3.0 * (scaling_factor ** 0.5)
target_z_size_coarse = 100.0 # Reduced for stability
target_z_size_fine = 50.0 # Reduced for stability
Generate the 3D mesh
print(“Input parameters:”, {
“length”: 70.0,
“width”: 20.0,
“layer”: [16300.0],
“groundwater”: ,
“BHE”: [{“x”: 1.0, “y”: 10.0, “z_begin”: -10.0, “z_end”: -16210.0, “borehole_radius”: 0.108}],
“meshing_type”: “structured”,
“refinement”: {“dist_box_x”: dist_box_x, “dist_box_y”: dist_box_y,
“inner_mesh_size”: inner_mesh_size, “outer_mesh_size”: outer_mesh_size}
})
try:
bhe_meshes = gen_bhe_mesh(
length=70.0,
width=20.0,
layer=[16300.0],
groundwater=,
BHE_Array=[
BHE(
x=1.0,
y=10.0,
z_begin=-10.0,
z_end=-16210.0,
borehole_radius=0.108
),
],
target_z_size_coarse=target_z_size_coarse,
target_z_size_fine=target_z_size_fine,
n_refinement_layers=3, # Increased for smoother transitions
meshing_type=“structured”, # Changed to supported type
dist_box_x=dist_box_x,
dist_box_y=dist_box_y,
inner_mesh_size=inner_mesh_size,
outer_mesh_size=outer_mesh_size,
propagation=1.2,
order=1,
out_name=pathlib.Path(“domain.vtu”)
)
except Exception as e:
print(“Mesh generation failed:”, str(e))
print(“Fallback files are inappropriate for 16300m domain. Please check meshing parameters.”)
raise
print(“Temporary files after meshing:”)
os.system(“ls -l /tmp/*.msh || echo ‘No .msh files found’”)
def load_and_plot(mesh_filenames: List[str]):
pv.set_plot_theme(“document”)
plotter = pv.Plotter(off_screen=True)
domain_mesh_pv = pv.read(mesh_filenames[0])
print(“Domain mesh arrays:”, domain_mesh_pv.array_names)
bhe_line = domain_mesh_pv.extract_cells_by_type(pv.CellType.LINE)
if “MaterialIDs” in domain_mesh_pv.array_names:
plotter.add_mesh(
domain_mesh_pv,
scalars=“MaterialIDs”,
cmap=“viridis”,
show_scalar_bar=True,
scalar_bar_args={“title”: “Material IDs”},
opacity=0.8,
)
else:
print(“MaterialIDs not found. Available arrays:”, domain_mesh_pv.array_names)
plotter.add_mesh(domain_mesh_pv, style=“surface”, color=“grey”, opacity=0.8)
plotter.add_mesh(domain_mesh_pv, style=“wireframe”, color=“black”, opacity=0.3)
plotter.add_mesh(bhe_line, color=“red”, line_width=3)
offsets = [(0, 0, 100), (0, 0, -100), (2, 0, 0)]
for submesh_file, offset in zip(mesh_filenames[1:], offsets, strict=False):
submesh_pv = pv.read(submesh_file)
print(f"Submesh {submesh_file}:", submesh_pv)
plotter.add_mesh(
submesh_pv.translate(offset), show_edges=True, color=“lightgrey”, opacity=0.7
)
plotter.camera_position = “iso”
plotter.screenshot(“deep_bhe_plot.png”)
print(“Mesh generated! Plot saved as ‘deep_bhe_plot.png’.”)
print(“Filenames:”, mesh_filenames)
load_and_plot(bhe_meshes)
But if i load this one with https://gitlab.opengeosys.org/ogs/ogs/-/raw/master/Tests/Data/Parabolic/T/3D_deep_BHE/3D_deep_BHE_CXA.prj (adjusted for the depth ofcourse)
It seems to give me output temperatures of 25 degrees Celsius but Im expecting more like 300 degrees Celsius.
The simulation does run and it does produce the vtu files but the result in temperature isn’t correct. I am suspecting it is not applying a geothermal gradient (i looking at 3 deg.C per 100mtrs)
Kind regards,
Jan