Skip to content

Commit 32026d3

Browse files
committed
(BUGFIX) changing tolerance for pyamg
1 parent 526fde6 commit 32026d3

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

LoopStructural/interpolators/discrete_interpolator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def _solve_cg(self, A, B, precon=None, **kwargs):
440440
cgargs['M'] = precon(A)
441441
return sla.cg(A, B, **cgargs)[0][:self.nx]
442442

443-
def _solve_pyamg(self, A, B):
443+
def _solve_pyamg(self, A, B, tol=1e-8,x0=None,**kwargs):
444444
"""
445445
Solve least squares system using pyamg algorithmic multigrid solver
446446
@@ -454,7 +454,8 @@ def _solve_pyamg(self, A, B):
454454
455455
"""
456456
import pyamg
457-
return pyamg.solve(A, B, verb=False)[:self.nx]
457+
logger.info("Solving using pyamg: tol {}".format(tol))
458+
return pyamg.solve(A, B, tol=tol, x0=x0, verb=False)[:self.nx]
458459

459460
def _solve(self, solver='cg', **kwargs):
460461
"""
@@ -500,7 +501,7 @@ def _solve(self, solver='cg', **kwargs):
500501
if solver == 'pyamg':
501502
try:
502503
logger.info("Solving with pyamg solve")
503-
self.c[self.region] = self._solve_pyamg(A, B)
504+
self.c[self.region] = self._solve_pyamg(A, B,**kwargs)
504505
except ImportError:
505506
logger.warn("Pyamg not installed using cg instead")
506507
self.c[self.region] = self._solve_cg(A, B)

LoopStructural/modelling/core/geological_model.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def __init__(self, origin, maximum, rescale=True, nsteps=(40, 40, 40),
151151
self.scale_factor = np.max(lengths)
152152
logger.info('Rescaling model using scale factor {}'.format(self.scale_factor))
153153
self._str+='Model rescale factor: {} \n'.format(self.scale_factor)
154-
self._str+='The model contains {} GeologicalFeatures'.format(len(self.features))
154+
self._str+='The model contains {} GeologicalFeatures \n'.format(len(self.features))
155155
self._str+=''
156156
self._str += '------------------------------------------ \n'
157157
self._str += ''
@@ -168,6 +168,9 @@ def __init__(self, origin, maximum, rescale=True, nsteps=(40, 40, 40),
168168
def __str__(self):
169169
return self._str
170170

171+
def _ipython_key_completions_(self):
172+
return self.feature_name_index.keys()
173+
171174
@classmethod
172175
def from_map2loop_directory(cls, m2l_directory,**kwargs):
173176
"""Alternate constructor for a geological model using m2l output
@@ -229,6 +232,12 @@ def __getitem__(self, feature_name):
229232
"""
230233
return self.get_feature_by_name(feature_name)
231234

235+
def feature_names(self):
236+
return self.feature_name_index.keys()
237+
238+
def fault_names(self):
239+
pass
240+
232241
def check_inialisation(self):
233242
if self.data is None:
234243
logger.error("Data not associated with GeologicalModel. Run set_data")
@@ -270,6 +279,7 @@ def _add_feature(self, feature):
270279
(feature.name, self.feature_name_index[feature.name]))
271280
self.features[self.feature_name_index[feature.name]] = feature
272281
else:
282+
self._str += 'GeologicalFeature: {} of type - {} \n'.format(feature.name,feature.type)
273283
self.features.append(feature)
274284
self.feature_name_index[feature.name] = len(self.features) - 1
275285
logger.info("Adding %s to model at location %i" % (

0 commit comments

Comments
 (0)