Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
21febf0
docs(spec): add spec 003, faster evaluation of faulted models
lachlangrose Nov 1, 2026
546bb43
docs(spec): record the answers to the clarifications of spec 003
lachlangrose Nov 1, 2026
eb7a780
docs(spec): add the plugin model as it is as a golden model of spec 003
lachlangrose Nov 1, 2026
d22db4f
docs(spec): prepare fault evaluation implementation
lachlangrose Nov 1, 2026
c577541
test(fault-evaluation): define golden model fixture contracts
lachlangrose Nov 1, 2026
667ca33
test(fault-evaluation): check actual fold frame dependencies
lachlangrose Nov 1, 2026
9aaaed4
docs(spec): add faulted gradient prerequisite
lachlangrose Nov 1, 2026
b22517f
test(fault-evaluation): reproduce gradient output shape failure
lachlangrose Nov 1, 2026
e9b7229
fix(features): preserve gradient output during fault refinement
lachlangrose Nov 1, 2026
21a3490
test(fault-evaluation): require meaningful fixture classifications
lachlangrose Nov 1, 2026
0a7930e
test(fault-evaluation): freeze solved model fixtures
lachlangrose Nov 1, 2026
9d0c066
test(fault-evaluation): define golden reference tool contracts
lachlangrose Nov 1, 2026
caaba54
test(fault-evaluation): add immutable golden capture tools
lachlangrose Nov 1, 2026
cac2a49
fix(fault-evaluation): sample boundaries without gradient refinement
lachlangrose Nov 1, 2026
09be87b
fix(fault-evaluation): capture legacy plugin groups and boundaries
lachlangrose Nov 1, 2026
ddc333e
test(fault-evaluation): record readable reference statistics
lachlangrose Nov 1, 2026
2697c1d
test(fault-evaluation): freeze 21 golden model references
lachlangrose Nov 2, 2026
7a8c0ab
test(fault-evaluation): cover missing surface list diagnostics
lachlangrose Nov 2, 2026
c66109c
test(fault-evaluation): verify complete legacy golden replay
lachlangrose Nov 2, 2026
b4b8562
docs(fault-evaluation): clarify golden harness validation
lachlangrose Nov 2, 2026
75c0684
test(fault-evaluation): define benchmark runner contracts
lachlangrose Nov 2, 2026
7393279
chore(dev-tools): install shared skills and agents
lachlangrose Nov 2, 2026
a188e03
feat(fault-evaluation): add benchmark runner and comparison contract …
lachlangrose Nov 2, 2026
9f72830
feat(fault-evaluation): add benchmark result comparison
lachlangrose Nov 2, 2026
bfd22f3
fix(fault-evaluation): correct review findings of wave 11
lachlangrose Nov 2, 2026
88aa2ff
test(fault-evaluation): define acceptance reporting contract
lachlangrose Nov 2, 2026
9610f6a
fix(fault-evaluation): add progress output and resume to the benchmar…
lachlangrose Nov 2, 2026
290edf3
fix(fault-evaluation): correct review findings of the runner resume
lachlangrose Nov 2, 2026
2b9e143
docs(spec): add standard benchmark suite to 003-fault-evaluation-perf…
lachlangrose Nov 2, 2026
bc14daa
test(fault-evaluation): define standard suite selection contract
lachlangrose Nov 2, 2026
77bc045
feat(fault-evaluation): add standard benchmark suite and suite option
lachlangrose Nov 2, 2026
4d83d86
fix(fault-evaluation): correct review findings of wave 13
lachlangrose Nov 2, 2026
c9577a9
feat(fault-evaluation): add acceptance check and short-case repeat tests
lachlangrose Nov 2, 2026
88cb819
fix(fault-evaluation): correct review findings of wave 14
lachlangrose Nov 2, 2026
617cfea
feat(fault-evaluation): repeat short timing cases with more rounds
lachlangrose Nov 2, 2026
23f6bb7
docs(fault-evaluation): record the baseline of the standard benchmark…
lachlangrose Nov 2, 2026
cd27038
docs(fault-evaluation): correct the rounds and count statements in th…
lachlangrose Nov 2, 2026
ca403b0
test(fault-evaluation): define cache storage and grid lookup contracts
lachlangrose Nov 2, 2026
3ee1cfa
fix(fault-evaluation): correct review findings of wave 17
lachlangrose Nov 2, 2026
61588e4
fix(fault-evaluation): accept any exception in the failed-put cache t…
lachlangrose Nov 2, 2026
39e7122
feat(fault-evaluation): add restoration cache storage and single-look…
lachlangrose Nov 2, 2026
3828957
test(fault-evaluation): define one-call restoration sharing contract
lachlangrose Nov 2, 2026
612fc87
fix(fault-evaluation): correct review findings of wave 19
lachlangrose Nov 2, 2026
259b871
fix(fault-evaluation): remove an assertion that cannot hold in the re…
lachlangrose Nov 2, 2026
f695823
feat(modelling): share fault restorations inside one evaluation call
lachlangrose Nov 2, 2026
e3f4ef7
test(fault-evaluation): define cache invalidation and fingerprint con…
lachlangrose Nov 2, 2026
69bc399
test(fault-evaluation): do not require a stable revision for same-val…
lachlangrose Nov 3, 2026
b0ba48e
feat(modelling): add evaluation revision hooks and dependency fingerp…
lachlangrose Nov 3, 2026
d8759ba
fix(fault-evaluation): hash a root feature in full when a cycle retur…
lachlangrose Nov 3, 2026
ec0283e
test(fault-evaluation): define cross-call restoration reuse and cache…
lachlangrose Nov 3, 2026
9e8c703
fix(fault-evaluation): compute references before warming the cache in…
lachlangrose Nov 3, 2026
823a1d6
feat(modelling): reuse fault restorations between evaluation calls
lachlangrose Nov 3, 2026
625149b
test(fault-evaluation): define gradient sharing, concurrency, memory …
lachlangrose Nov 3, 2026
ba420cb
fix(fault-evaluation): relax two wave 25 tests that exceeded the plan
lachlangrose Nov 3, 2026
646c158
feat(modelling): share equal gradient batches and fault frame grid lo…
lachlangrose Nov 3, 2026
c8e3f9f
feat(modelling): serialise outer evaluations per model and bound the …
lachlangrose Nov 3, 2026
30a7c8e
docs(spec): mark T030 as failed after the first acceptance measurement
lachlangrose Nov 3, 2026
2b4b281
docs(spec): record the T030 acceptance failure and the cache design d…
lachlangrose Nov 3, 2026
f656c38
lachlangrose Nov 3, 2026
21616db
docs(spec): add D4a tasks for 003-fault-evaluation-performance
lachlangrose Nov 3, 2026
89f797d
docs(spec): add the cache pickle defect to T040 and T041
lachlangrose Nov 3, 2026
8e2a0f1
docs(spec): split the failed T030 results by cause (T043)
lachlangrose Nov 3, 2026
a1989c4
docs(spec): apply the spec 005 cascade to 003-fault-evaluation-perfor…
lachlangrose Nov 3, 2026
a02a413
test(fault-evaluation): add the fault-set cache key tests (T040)
lachlangrose Nov 3, 2026
7d865f7
perf(features): key stored restorations on the ordered fault set (T041)
lachlangrose Nov 3, 2026
598ef21
docs(spec): record the wave 29 review of 003
lachlangrose Nov 3, 2026
3ef8cb1
docs(spec): record the D4a profile of 003 and the failed key-time gat…
lachlangrose Nov 3, 2026
c4ea58e
docs(spec): record the T042 commit in the run state of 003
lachlangrose Nov 3, 2026
465688e
docs(spec): add the D4b frame digest tasks to 003
lachlangrose Nov 3, 2026
c1250ab
test(fault-evaluation): add the D4b frame digest tests (T044)
lachlangrose Nov 4, 2026
e492ac7
perf(features): read a small DataFrame with one call in the frame dig…
lachlangrose Nov 4, 2026
45980ad
docs(spec): record the wave 31 review of 003
lachlangrose Nov 4, 2026
31e056f
docs(spec): record the second D4a profile of 003; all gates pass (T042)
lachlangrose Nov 4, 2026
b59cf1e
docs(spec): record the T042 commit in the run state of 003
lachlangrose Nov 4, 2026
d4157a3
docs(spec): add plan and S1 tasks for 005-coordinate-frame-correctness
lachlangrose Nov 4, 2026
91e07a6
chore: remove the dev-toolkit files from the PR branch of 003
lachlangrose Nov 4, 2026
894042c
docs(spec): remove the cache between calls from 003 and change SC-006…
lachlangrose Nov 18, 2026
a90f7cb
docs(spec): carry 003-fault-evaluation-performance changes into spec 005
lachlangrose Nov 18, 2026
fe2ee9f
docs(spec): add the reduced-scope tasks T046-T051 to 003
lachlangrose Nov 18, 2026
12a7385
merge: merge master into the 003 branch and move the value lookup (T046)
lachlangrose Nov 18, 2026
8caf50d
test(fault-evaluation): change the tests for no cache and the shorter…
lachlangrose Nov 18, 2026
cf7af16
fix(fault-evaluation): correct review findings of wave 33
lachlangrose Nov 18, 2026
28d88a7
perf(features): remove the restoration cache between calls and the mo…
lachlangrose Nov 18, 2026
54d106f
test(fault-evaluation): correct the SC-006 allowance test of T049
lachlangrose Nov 18, 2026
15d095f
perf(benchmarks): make the standard suite shorter and apply the new a…
lachlangrose Nov 18, 2026
1991682
fix(benchmarks): correct review findings of wave 35
lachlangrose Nov 18, 2026
3865c80
docs(spec): record the wave 35 review of 003
lachlangrose Nov 18, 2026
808b491
docs(spec): measure the SC-003 count and SC-004 on one evaluate_model…
lachlangrose Nov 18, 2026
f446cbf
docs(spec): record the third D4a profile of 003 on the merged tree (T…
lachlangrose Nov 18, 2026
d0ffb09
test(fault-evaluation): test SC-003 and SC-004 on one evaluate_model …
lachlangrose Nov 18, 2026
c692fbc
perf(benchmarks): measure the SC-003 count and SC-004 on one evaluate…
lachlangrose Nov 18, 2026
b6ff1a8
docs(spec): record the wave 37 review of 003
lachlangrose Nov 18, 2026
dd71315
docs(spec): park the T030 acceptance run of 003 until a quiet compute…
lachlangrose Nov 18, 2026
b64c1e4
merge: bring the spec branch of 003 into the PR branch
lachlangrose Nov 18, 2026
3d4bf9d
merge: bring master into feat/003-fault-evaluation-performance
lachlangrose Nov 22, 2026
299b7be
test: update fault-evaluation tests for the spec 005 changes from master
lachlangrose Nov 22, 2026
6c2a385
feat: add fault snapshot exporter, reference data and agent brief
lachlangrose Nov 23, 2026
6c01d7e
perf(fault): remove repeated work in one fault frame step
lachlangrose Nov 25, 2026
c606586
fix(fault): keep the regions and the frame check on the shared frame …
lachlangrose Nov 25, 2026
eea3c69
revert: remove the fault snapshot exporter from the spec 003 branch
lachlangrose Nov 25, 2026
198388b
fix(benchmarks): fail SC-006 when a memory-pass case has no candidate…
lachlangrose Nov 26, 2026
24122b7
fix(evaluation): keep one restoration per fault set and batch shape i…
lachlangrose Nov 26, 2026
8d40be4
fix(benchmarks): measure peak memory with tracemalloc, not process RSS
lachlangrose Nov 26, 2026
30e7241
fix(loop_common): keep a subclass's own corner weights off the fast l…
lachlangrose Nov 26, 2026
20ae0a1
test(fault-evaluation): check reordered ids, saved models and the thr…
lachlangrose Nov 26, 2026
3c3bf8f
docs(spec): record the review of 003, C-018 to C-020 and the Linux ba…
lachlangrose Nov 26, 2026
3b73be7
merge: bring origin/master into feat/003-fault-evaluation-performance
lachlangrose Nov 26, 2026
c75267d
fix(evaluation): accept object points and array displacements in the …
lachlangrose Nov 26, 2026
3aa3609
fix(evaluation): keep the batches of the caller for the whole call (F…
lachlangrose Nov 26, 2026
81039df
fix(benchmarks): review round 2 minor fixes of the acceptance check a…
lachlangrose Nov 26, 2026
edac803
docs(spec): record review round 2, the master baseline and the caller…
lachlangrose Nov 26, 2026
6dec737
fix(features): fillnan='nearest' leaves points with a NaN coordinate NaN
lachlangrose Nov 26, 2026
9262da8
merge: bring origin/master (#421) into feat/003-fault-evaluation-perf…
lachlangrose Nov 26, 2026
e1a8289
merge: bring the fix of #424 into feat/003-fault-evaluation-performance
lachlangrose Nov 26, 2026
51d8e2b
test(fault-evaluation): re-record the golden outputs that master #421…
lachlangrose Nov 26, 2026
246ce4f
docs(spec): record C-021, the master #421 merge and the master + #424…
lachlangrose Nov 26, 2026
6c2bbb0
refactor(fault): remove the use_threads switch of the fault frame
lachlangrose Nov 26, 2026
c85ed40
fix(benchmarks): drop the gradient_decision row of the acceptance check
lachlangrose Nov 26, 2026
9e62b97
docs(spec): record T062 and T030: all success criteria pass on Linux
lachlangrose Nov 26, 2026
f188b17
fix(fault): keep a step direction where a cutting fault leaves no fra…
lachlangrose Nov 26, 2026
9e3c14c
merge: bring the fix of #425 into feat/003-fault-evaluation-performance
lachlangrose Nov 26, 2026
b6ac72c
test(fault-evaluation): capture the cutting_faults references again a…
lachlangrose Nov 26, 2026
4536bff
fix(fault): restore a cutting fault before the fault it cuts
lachlangrose Nov 26, 2026
f27251e
merge: bring the fix of #427 into feat/003-fault-evaluation-performance
lachlangrose Nov 26, 2026
eb8396d
fix(fault): read the frame members from StructuralFrame.features
lachlangrose Nov 26, 2026
bc35d76
merge: bring the fix of #427 (read frame members from features) into …
lachlangrose Nov 26, 2026
5469886
test(fault-evaluation): capture the cutting_faults references again a…
lachlangrose Nov 26, 2026
79f66bf
fix(fault): restore the whole chain of cutting faults in one pass
lachlangrose Nov 26, 2026
6e8f6b5
merge: bring the chain fix of #427 (whole chain of cutting faults) in…
lachlangrose Nov 26, 2026
362d3f1
fix(builder): rotate data vectors through the faults in restore order
lachlangrose Nov 26, 2026
b64bb23
merge: bring the fix of #428 (rotate data vectors in restore order) i…
lachlangrose Nov 26, 2026
452ae46
fix(builder): check each builder once per up_to_date call
lachlangrose Nov 26, 2026
f460a3b
merge: bring the fix of fix/up-to-date-visit-once (check each builder…
lachlangrose Nov 26, 2026
a558a1b
merge: bring origin/master (#425, #427, #428, #429 squash-merged) int…
lachlangrose Nov 26, 2026
e88269b
fix(benchmarks): time 1-5 s cases with the median of 3 rounds (C-022)
lachlangrose Nov 26, 2026
9136925
docs(spec): record the final T030 run: all success criteria pass
lachlangrose Nov 27, 2026
7a37729
merge: bring origin/master (#430, spec 007 docs) into feat/003-fault-…
lachlangrose Nov 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 47 additions & 36 deletions LoopStructural/modelling/core/geological_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Main entry point for creating a geological model
"""

from __future__ import annotations

import warnings
Expand All @@ -26,6 +27,7 @@
all_heading,
gradient_vec_names,
)
from ..features._evaluation import evaluation_scope
from ..features._feature_converters import (
add_fold_to_feature as _add_fold_to_feature,
)
Expand Down Expand Up @@ -325,13 +327,17 @@ def from_processor(cls, processor):
logger.warning(f"Cannot add splay {edge[1]} or {edge[0]} are not in the model")
continue
splay = False
if "angle" in properties and float(properties["angle"]) < 30 and (
"dip_dir" not in processor.stratigraphic_column["faults"][edge[0]]
or np.abs(
processor.stratigraphic_column["faults"][edge[0]]["dip_dir"]
- processor.stratigraphic_column["faults"][edge[1]]["dip_dir"]
if (
"angle" in properties
and float(properties["angle"]) < 30
and (
"dip_dir" not in processor.stratigraphic_column["faults"][edge[0]]
or np.abs(
processor.stratigraphic_column["faults"][edge[0]]["dip_dir"]
- processor.stratigraphic_column["faults"][edge[1]]["dip_dir"]
)
< 90
)
< 90
):
# splay
region = model[edge[1]].builder.add_splay(model[edge[0]])
Expand Down Expand Up @@ -678,12 +684,10 @@ def set_stratigraphic_column(self, stratigraphic_column, cmap="tab20"):
min_val = stratigraphic_column[g][u]["min"]
max_val = stratigraphic_column[g][u].get("max", None)
thickness = max_val - min_val if max_val is not None else None
logger.info(
f"""
logger.info(f"""
model.stratigraphic_column.add_unit({u},
colour={stratigraphic_column[g][u].get("colour", None)},
thickness={thickness})"""
)
thickness={thickness})""")
self.stratigraphic_column.add_unit(
u,
colour=stratigraphic_column[g][u].get("colour", None),
Expand Down Expand Up @@ -1290,14 +1294,16 @@ def evaluate_model(self, xyz: np.ndarray, *, scale: bool = True) -> np.ndarray:
logger.warning("No stratigraphic column defined")
return strat_id

for g in reversed(self.stratigraphic_column.get_groups()):
feature_id = self.feature_name_index.get(g.name, -1)
if feature_id >= 0:
vals = self.features[feature_id].evaluate_value(xyz)
for u in g.units:
strat_id[np.logical_and(vals < u.max(), vals > u.min())] = u.id
if feature_id == -1:
logger.error(f"Model does not contain {g.name}")
# one scope for all groups: they share the restorations of equal fault sets
with evaluation_scope(self):
for g in reversed(self.stratigraphic_column.get_groups()):
feature_id = self.feature_name_index.get(g.name, -1)
if feature_id >= 0:
vals = self.features[feature_id].evaluate_value(xyz)
for u in g.units:
strat_id[np.logical_and(vals < u.max(), vals > u.min())] = u.id
if feature_id == -1:
logger.error(f"Model does not contain {g.name}")

return strat_id

Expand All @@ -1321,13 +1327,15 @@ def evaluate_model_gradient(self, points: np.ndarray, *, scale: bool = True) ->
# evaluate_model.
xyz = np.array(points)
grad = np.zeros(xyz.shape)
for g in reversed(self.stratigraphic_column.get_groups()):
feature_id = self.feature_name_index.get(g.name, -1)
if feature_id >= 0:
gradt = self.features[feature_id].evaluate_gradient(xyz)
grad[~np.isnan(gradt).any(axis=1)] = gradt[~np.isnan(gradt).any(axis=1)]
if feature_id == -1:
logger.error(f"Model does not contain {g.name}")
# one scope for all groups: they share the restorations of equal fault sets
with evaluation_scope(self):
for g in reversed(self.stratigraphic_column.get_groups()):
feature_id = self.feature_name_index.get(g.name, -1)
if feature_id >= 0:
gradt = self.features[feature_id].evaluate_gradient(xyz)
grad[~np.isnan(gradt).any(axis=1)] = gradt[~np.isnan(gradt).any(axis=1)]
if feature_id == -1:
logger.error(f"Model does not contain {g.name}")

return grad

Expand All @@ -1351,10 +1359,11 @@ def evaluate_fault_displacements(self, points, scale=True):
# `scale` is retained for API-signature compatibility only -- see
# evaluate_model.
vals = np.zeros(points.shape[0])
for f in self.features:
if f.type == FeatureType.FAULT:
disp = f.displacementfeature.evaluate_value(points)
vals[~np.isnan(disp)] += disp[~np.isnan(disp)]
with evaluation_scope(self):
for f in self.features:
if f.type == FeatureType.FAULT:
disp = f.displacementfeature.evaluate_value(points)
vals[~np.isnan(disp)] += disp[~np.isnan(disp)]
return vals # convert from restoration magnutude to displacement

@public_api(tier="stable")
Expand Down Expand Up @@ -1423,7 +1432,8 @@ def evaluate_feature_value(self, feature_name, xyz, scale=True):
# evaluate_model.
feature = self.get_feature_by_name(feature_name)
if feature:
return feature.evaluate_value(xyz)
with evaluation_scope(self):
return feature.evaluate_value(xyz)
else:
return np.zeros(xyz.shape[0])

Expand Down Expand Up @@ -1577,10 +1587,8 @@ def update(self, verbose=False, progressbar=True):
total_dof += f.interpolator.dof
continue
if verbose:
logger.info(
f"Updating geological model. There are: \n {nfeatures} \
geological features that need to be interpolated\n"
)
logger.info(f"Updating geological model. There are: \n {nfeatures} \
geological features that need to be interpolated\n")

with timed_stage(logger, "update", nfeatures=nfeatures, total_dof=total_dof):
if progressbar:
Expand Down Expand Up @@ -1648,7 +1656,8 @@ def save(
# ModelFeatureFactory.build_* staticmethod; new feature types register here
# without modifying GeologicalModel's source.
FeatureBuilderRegistry.register(
"foliation", lambda model, name, **params: ModelFeatureFactory.build_foliation(model, name, **params)
"foliation",
lambda model, name, **params: ModelFeatureFactory.build_foliation(model, name, **params),
)
FeatureBuilderRegistry.register(
"fold_frame",
Expand All @@ -1660,7 +1669,9 @@ def save(
)
FeatureBuilderRegistry.register(
"folded_fold_frame",
lambda model, name, **params: ModelFeatureFactory.build_folded_fold_frame(model, name, **params),
lambda model, name, **params: ModelFeatureFactory.build_folded_fold_frame(
model, name, **params
),
)
FeatureBuilderRegistry.register(
"intrusion",
Expand Down
12 changes: 8 additions & 4 deletions LoopStructural/modelling/features/_base_geological_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from LoopStructural.utils.regions import BaseRegion
from LoopStructural.utils.typing import NumericInput

from ._evaluation import evaluation_scope

logger = getLogger(__name__)


Expand Down Expand Up @@ -227,8 +229,9 @@ def evaluate_normalised_value(self, pos: NumericInput):
pos : NumericInput
An array or arraylike object with locations
"""
value = self.evaluate_value(pos)
return (value - self.min()) / (self.max() - self.min())
with evaluation_scope(self.model):
value = self.evaluate_value(pos)
return (value - self.min()) / (self.max() - self.min())

def _calculate_mask(
self, evaluation_points: np.ndarray, ignore_regions=False, block=None,
Expand Down Expand Up @@ -308,7 +311,7 @@ def evaluate_gradient(self, pos, ignore_regions=False):
"""
Evaluate the gradient of the feature at a given position.
"""

raise NotImplementedError

def min(self):
Expand Down Expand Up @@ -372,7 +375,7 @@ def surfaces(
raise ValueError("Must specify bounding box")
bounding_box = self.model.bounding_box
regions = self.regions

try:
# A region can also be a plain callable (e.g. the lambdas
# add_domain_fault_below/above attach for a domain-fault crop),
Expand Down Expand Up @@ -456,6 +459,7 @@ def gradient_norm_scalar_field(self, bounding_box=None):
)
grid.cell_properties[self.name] = value
return grid

def vector_field(self, bounding_box=None, tolerance=0.05, scale=1.0):
"""Create a vector field for the feature

Expand Down
Loading
Loading