Skip to content

Commit 82ae708

Browse files
javohaLeguark
authored andcommitted
Fixed MC code to assign correct scalar field values to elements.
1 parent 44f98f3 commit 82ae708

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

gempy/modules/mesh_extranction/marching_cubes.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,33 @@ def set_meshes_with_marching_cubes(model: GeoModel) -> None:
2828

2929
regular_grid: RegularGrid = model.grid.regular_grid
3030
structural_groups: list[StructuralGroup] = model.structural_frame.structural_groups
31-
31+
32+
print(model.solutions.scalar_field_at_surface_points)
33+
3234
if not model.solutions.octrees_output or not model.solutions.octrees_output[0].outputs_centers:
3335
raise ValueError("No interpolation outputs available for mesh extraction.")
3436

3537
output_lvl0: list[InterpOutput] = model.solutions.octrees_output[0].outputs_centers
3638

39+
# TODO: Attribute of element.scalar_field was None, changed it to scalar field value of that element
40+
# This should probably be done somewhere else and maybe renamed to scalar_field_value?
41+
# This is just the most basic solution to be clear what I did
42+
counter = 0
43+
for e, structural_group in enumerate(structural_groups):
44+
if e >= len(output_lvl0):
45+
continue
46+
47+
for element in structural_group.elements:
48+
element.scalar_field = model.solutions.scalar_field_at_surface_points[counter]
49+
counter += 1
50+
3751
for e, structural_group in enumerate(structural_groups):
3852
if e >= len(output_lvl0):
3953
continue
4054

4155
output_group: InterpOutput = output_lvl0[e]
4256
scalar_field_matrix = output_group.exported_fields_dense_grid.scalar_field
43-
57+
4458
for element in structural_group.elements:
4559
extract_mesh_for_element(
4660
structural_element=element,
@@ -71,8 +85,9 @@ def extract_mesh_for_element(structural_element: StructuralElement,
7185
if mask is not None:
7286
volume = volume * mask
7387

74-
# TODO: We need to pass the mask arrays to the marching cubes to account for discontinuities. The mask array are in InterpOutput too if I remember correctly.
75-
88+
# TODO: We need to pass the mask arrays to the marching cubes to account for discontinuities. The mask array are
89+
# in InterpOutput too if I remember correctly.
90+
7691
# Extract mesh using marching cubes
7792
verts, faces, _, _ = measure.marching_cubes(
7893
volume=volume,

0 commit comments

Comments
 (0)