Skip to content

Commit

Permalink
fix: adding check to see if a feature is valid.
Browse files Browse the repository at this point in the history
If something doesn't interpolate it will break further steps where
it is needed.
  • Loading branch information
Lachlan Grose committed Sep 21, 2021
1 parent 6ec77bb commit c9bd3b0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion LoopStructural/interpolators/discrete_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,15 @@ def _solve(self, solver='cg', **kwargs):
# check solution is not nan
# self.support.properties[self.propertyname] = self.c
if np.all(self.c == np.nan):
self.valid = False
logger.warning("Solver not run, no scalar field")
return
# if solution is all 0, probably didn't work
if np.all(self.c[self.region] == 0):
self.valid = False
logger.warning("No solution, {} scalar field 0. Add more data.".format(self.propertyname))

return
self.valid = True
def update(self):
"""
Check if the solver is up to date, if not rerun interpolation using
Expand Down
3 changes: 2 additions & 1 deletion LoopStructural/interpolators/geological_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def __init__(self):
self.constraints = []
self.propertyname = 'defaultproperty'
self.__str = 'Base Geological Interpolator'

self.valid = False

def __str__(self):

return self.__str
Expand Down
3 changes: 3 additions & 0 deletions LoopStructural/modelling/features/geological_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def __init__(self, name, interpolator, builder=None, data=None, region=None, typ
self.region = 'everywhere'
self.model = None

def is_valid(self):
return self.interpolator.valid

def __str__(self):
return self.name

Expand Down
1 change: 1 addition & 0 deletions docs/source/_static/loopstructural_design.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LoopStructural design

0 comments on commit c9bd3b0

Please sign in to comment.