LoopStructural 1.0.9__cp39-cp39-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. LoopStructural/__init__.py +36 -0
  2. LoopStructural/analysis/__init__.py +2 -0
  3. LoopStructural/analysis/_fault_displacement.py +67 -0
  4. LoopStructural/analysis/_fault_intersection.py +36 -0
  5. LoopStructural/analysis/_plane_fit.py +43 -0
  6. LoopStructural/datasets/__init__.py +12 -0
  7. LoopStructural/datasets/_base.py +65 -0
  8. LoopStructural/datasets/data/claudius.csv +21049 -0
  9. LoopStructural/datasets/data/claudiusbb.txt +2 -0
  10. LoopStructural/datasets/data/duplex.csv +126 -0
  11. LoopStructural/datasets/data/duplexbb.txt +2 -0
  12. LoopStructural/datasets/data/intrusion.csv +1017 -0
  13. LoopStructural/datasets/data/intrusionbb.txt +2 -0
  14. LoopStructural/datasets/data/onefoldbb.txt +2 -0
  15. LoopStructural/datasets/data/onefolddata.csv +2226 -0
  16. LoopStructural/datasets/data/refolded_bb.txt +2 -0
  17. LoopStructural/datasets/data/refolded_fold.csv +2126 -0
  18. LoopStructural/interpolators/__init__.py +34 -0
  19. LoopStructural/interpolators/base_structured_3d_support.py +101 -0
  20. LoopStructural/interpolators/cython/__init__.py +0 -0
  21. LoopStructural/interpolators/cython/dsi_helper.c +31046 -0
  22. LoopStructural/interpolators/cython/dsi_helper.cp39-win_amd64.pyd +0 -0
  23. LoopStructural/interpolators/discrete_fold_interpolator.py +202 -0
  24. LoopStructural/interpolators/discrete_interpolator.py +584 -0
  25. LoopStructural/interpolators/finite_difference_interpolator.py +399 -0
  26. LoopStructural/interpolators/geological_interpolator.py +197 -0
  27. LoopStructural/interpolators/operator.py +61 -0
  28. LoopStructural/interpolators/piecewiselinear_interpolator.py +437 -0
  29. LoopStructural/interpolators/structured_grid.py +421 -0
  30. LoopStructural/interpolators/structured_tetra.py +681 -0
  31. LoopStructural/interpolators/surfe_wrapper.py +118 -0
  32. LoopStructural/modelling/__init__.py +46 -0
  33. LoopStructural/modelling/core/__init__.py +0 -0
  34. LoopStructural/modelling/core/geological_model.py +1513 -0
  35. LoopStructural/modelling/core/geological_model_graph.py +880 -0
  36. LoopStructural/modelling/core/stratigraphic_column.py +5 -0
  37. LoopStructural/modelling/fault/__init__.py +4 -0
  38. LoopStructural/modelling/fault/fault_builder.py +143 -0
  39. LoopStructural/modelling/fault/fault_function.py +188 -0
  40. LoopStructural/modelling/fault/fault_function_feature.py +76 -0
  41. LoopStructural/modelling/fault/fault_segment.py +298 -0
  42. LoopStructural/modelling/features/__init__.py +8 -0
  43. LoopStructural/modelling/features/cross_product_geological_feature.py +90 -0
  44. LoopStructural/modelling/features/geological_feature.py +252 -0
  45. LoopStructural/modelling/features/geological_feature_builder.py +414 -0
  46. LoopStructural/modelling/features/lambda_geological_feature.py +36 -0
  47. LoopStructural/modelling/features/region_feature.py +34 -0
  48. LoopStructural/modelling/features/structural_frame.py +133 -0
  49. LoopStructural/modelling/features/structural_frame_builder.py +206 -0
  50. LoopStructural/modelling/features/unconformity_feature.py +74 -0
  51. LoopStructural/modelling/fold/__init__.py +8 -0
  52. LoopStructural/modelling/fold/fold.py +143 -0
  53. LoopStructural/modelling/fold/fold_rotation_angle.py +133 -0
  54. LoopStructural/modelling/fold/fold_rotation_angle_feature.py +58 -0
  55. LoopStructural/modelling/fold/foldframe.py +193 -0
  56. LoopStructural/modelling/fold/svariogram.py +180 -0
  57. LoopStructural/utils/__init__.py +18 -0
  58. LoopStructural/utils/bounding_box.py +21 -0
  59. LoopStructural/utils/exceptions.py +10 -0
  60. LoopStructural/utils/helper.py +382 -0
  61. LoopStructural/utils/logging.py +60 -0
  62. LoopStructural/utils/map2loop.py +353 -0
  63. LoopStructural/utils/regions.py +11 -0
  64. LoopStructural/utils/utils.py +69 -0
  65. LoopStructural/visualisation/__init__.py +31 -0
  66. LoopStructural/visualisation/map_viewer.py +322 -0
  67. LoopStructural/visualisation/model_plotter.py +17 -0
  68. LoopStructural/visualisation/model_visualisation.py +1113 -0
  69. LoopStructural/visualisation/rotation_angle_plotter.py +83 -0
  70. LoopStructural/visualisation/sphinx_scraper.py +34 -0
  71. LoopStructural/visualisation/stratigraphic_column.py +60 -0
  72. LoopStructural-1.0.9.dist-info/LICENSE +21 -0
  73. LoopStructural-1.0.9.dist-info/METADATA +19 -0
  74. LoopStructural-1.0.9.dist-info/RECORD +77 -0
  75. LoopStructural-1.0.9.dist-info/WHEEL +5 -0
  76. LoopStructural-1.0.9.dist-info/top_level.txt +2 -0
  77. tests/__init__.py +0 -0
@@ -0,0 +1,399 @@
1
+ """
2
+ FiniteDifference interpolator
3
+ """
4
+ import logging
5
+
6
+ import numpy as np
7
+
8
+ from LoopStructural.utils.helper import get_vectors
9
+ from .discrete_interpolator import DiscreteInterpolator
10
+ from .operator import Operator
11
+
12
+ from LoopStructural.utils import getLogger
13
+ logger = getLogger(__name__)
14
+
15
+
16
+ class FiniteDifferenceInterpolator(DiscreteInterpolator):
17
+ """
18
+
19
+ """
20
+
21
+ def __init__(self, grid):
22
+ """
23
+ Finite difference interpolation on a regular cartesian grid
24
+
25
+ Parameters
26
+ ----------
27
+ grid : StructuredGrid
28
+ """
29
+ self.shape = 'rectangular'
30
+ DiscreteInterpolator.__init__(self, grid)
31
+ # default weights for the interpolation matrix are 1 in x,y,z and
32
+ # 1/
33
+ self.set_interpolation_weights({'dxy': .7,
34
+ 'dyz': .7,
35
+ 'dxz': .7,
36
+ 'dxx': 1.,
37
+ 'dyy': 1.,
38
+ 'dzz': 1.,
39
+ 'dx': 1.,
40
+ 'dy': 1.,
41
+ 'dz': 1.,
42
+ 'cpw': 1.,
43
+ 'gpw': 1.,
44
+ 'npw': 1.,
45
+ 'tpw': 1.,
46
+ 'ipw': 1.
47
+ })
48
+
49
+ self.vol = grid.step_vector[0] * grid.step_vector[1] * \
50
+ grid.step_vector[2]
51
+
52
+ def _setup_interpolator(self, **kwargs):
53
+ """
54
+
55
+ Parameters
56
+ ----------
57
+ kwargs
58
+ possible kwargs are weights for the different masks and masks.
59
+
60
+ Notes
61
+ -----
62
+ Default masks are the second derivative in x,y,z direction and the second derivative of x wrt
63
+ y and y wrt z and z wrt x. Custom masks can be used by specifying the operator as a 3d numpy array
64
+ e.g. [ [ [ 0 0 0 ]
65
+ [ 0 1 0 ]
66
+ [ 0 0 0 ] ]
67
+ [ [ 1 1 1 ]
68
+ [ 1 1 1 ]
69
+ [ 1 1 1 ] ]
70
+ [ [ 0 0 0 ]
71
+ [ 0 1 0 ]
72
+ [ 0 0 0 ] ]
73
+
74
+ Returns
75
+ -------
76
+
77
+ """
78
+ for key in kwargs:
79
+ self.up_to_date = False
80
+ if 'regularisation' in kwargs:
81
+ self.interpolation_weights['dxy'] = kwargs[
82
+ 'regularisation'] * 0.7
83
+ self.interpolation_weights['dyz'] = kwargs[
84
+ 'regularisation'] * 0.7
85
+ self.interpolation_weights['dxz'] = kwargs[
86
+ 'regularisation'] * 0.7
87
+ self.interpolation_weights['dxx'] = kwargs[
88
+ 'regularisation'] * 1.
89
+ self.interpolation_weights['dyy'] = kwargs[
90
+ 'regularisation'] * 1.
91
+ self.interpolation_weights['dzz'] = kwargs[
92
+ 'regularisation'] * 1.
93
+ self.interpolation_weights[key] = kwargs[key]
94
+ # if we want to define the operators manually
95
+ if 'operators' in kwargs:
96
+ for n, o in kwargs['operators'].items():
97
+ self.assemble_inner(o[0], o[1])
98
+ # otherwise just use defaults
99
+ if 'operators' not in kwargs:
100
+ operator = Operator.Dxy_mask
101
+
102
+ self.assemble_inner(operator, np.sqrt(2 * self.vol) *
103
+ self.interpolation_weights['dxy'])
104
+ operator = Operator.Dyz_mask
105
+ self.assemble_inner(operator, np.sqrt(2 * self.vol) *
106
+ self.interpolation_weights['dyz'])
107
+ operator = Operator.Dxz_mask
108
+ self.assemble_inner(operator, np.sqrt(2 * self.vol) *
109
+ self.interpolation_weights['dxz'])
110
+ operator = Operator.Dxx_mask
111
+ self.assemble_inner(operator,
112
+ np.sqrt(self.vol) * self.interpolation_weights[
113
+ 'dxx'])
114
+ operator = Operator.Dyy_mask
115
+ self.assemble_inner(operator,
116
+ np.sqrt(self.vol) * self.interpolation_weights[
117
+ 'dyy'])
118
+ operator = Operator.Dzz_mask
119
+ self.assemble_inner(operator,
120
+ np.sqrt(self.vol) * self.interpolation_weights[
121
+ 'dzz'])
122
+ self.add_norm_constraint(
123
+ np.sqrt(self.vol) * self.interpolation_weights['npw'])
124
+ self.add_gradient_constraint(
125
+ np.sqrt(self.vol) * self.interpolation_weights['gpw'])
126
+ self.add_vaue_constraint(
127
+ np.sqrt(self.vol) * self.interpolation_weights['cpw'])
128
+ self.add_tangent_ctr_pts(
129
+ np.sqrt(self.vol) * self.interpolation_weights['tpw']
130
+ )
131
+ self.add_interface_ctr_pts(
132
+ np.sqrt(self.vol)*self.interpolation_weights['ipw']
133
+ )
134
+
135
+ def copy(self):
136
+ """
137
+ Create a new identical interpolator
138
+
139
+ Returns
140
+ -------
141
+ returns a new empy interpolator from the same support
142
+ """
143
+ return FiniteDifferenceInterpolator(self.support)
144
+
145
+ def add_vaue_constraint(self, w=1.):
146
+ """
147
+
148
+ Parameters
149
+ ----------
150
+ w : double or numpy array
151
+
152
+ Returns
153
+ -------
154
+
155
+ """
156
+
157
+ points = self.get_value_constraints()
158
+ # check that we have added some points
159
+ if points.shape[0] > 0:
160
+ node_idx, inside = self.support.position_to_cell_corners(
161
+ points[:, :3])
162
+ # print(points[inside,:].shape)
163
+
164
+ gi = np.zeros(self.support.n_nodes)
165
+ gi[:] = -1
166
+ gi[self.region] = np.arange(0, self.nx)
167
+ idc = np.zeros(node_idx.shape)
168
+ idc[:] = -1
169
+
170
+ idc[inside, :] = gi[node_idx[inside, :]]
171
+ inside = np.logical_and(~np.any(idc == -1, axis=1), inside)
172
+ a = self.support.position_to_dof_coefs(points[inside, :3])
173
+ # a*=w
174
+
175
+ self.add_constraints_to_least_squares(a.T * w,
176
+ points[inside, 3] * w,
177
+ idc[inside, :],
178
+ name='value')
179
+ def add_interface_ctr_pts(self, w=1.0): # for now weight all value points the same
180
+ """
181
+ Adds a constraint that defines all points with the same 'id' to be the same value
182
+ Sets all P1-P2 = 0 for all pairs of points
183
+
184
+ Parameters
185
+ ----------
186
+ w : double
187
+ weight
188
+
189
+ Returns
190
+ -------
191
+
192
+ """
193
+ # get elements for points
194
+ points = self.get_interface_constraints()
195
+ if points.shape[0] > 1:
196
+ node_idx, inside = self.support.position_to_cell_corners(
197
+ points[:, :3])
198
+ # print(points[inside,:].shape)
199
+
200
+ gi = np.zeros(self.support.n_nodes)
201
+ gi[:] = -1
202
+ gi[self.region] = np.arange(0, self.nx)
203
+ idc = np.zeros(node_idx.shape)
204
+ idc[:] = -1
205
+
206
+ idc[inside, :] = gi[node_idx[inside, :]]
207
+ inside = np.logical_and(~np.any(idc == -1, axis=1), inside)
208
+ a = self.support.position_to_dof_coefs(points[inside, :3]).T
209
+ # create oversided array for storing constraints
210
+ A = np.zeros((a.shape[0]*a.shape[0],a.shape[1]*2))
211
+ interface_idc = np.zeros((a.shape[0]*a.shape[0],a.shape[1]*2),dtype=int)
212
+ interface_idc[:] = -1
213
+ c_i = 0
214
+
215
+ for i in np.unique(points[np.logical_and(~np.isnan(points[:,3]),inside),3]):
216
+ mask = points[inside,3] == i
217
+ for p1 in range(points[inside][mask].shape[0]):
218
+ for p2 in range(p1+1,points[inside][mask].shape[0]):
219
+ A[c_i,:8] = a[mask][p1,:]
220
+ A[c_i,8:] -= a[mask][p2,:]
221
+ interface_idc[c_i,:8] = idc[inside,:][mask,:][p1,:]
222
+ interface_idc[c_i,8:] = idc[inside,:][mask,:][p2,:]
223
+ c_i+=1
224
+ outside = ~np.any(interface_idc == -1, axis=1)
225
+
226
+ self.add_constraints_to_least_squares(A[outside,:] * w,
227
+ np.zeros(A[outside,:].shape[0]),
228
+ interface_idc[outside, :], name='interface')
229
+
230
+ def add_gradient_constraint(self, w=1.):
231
+ """
232
+
233
+ Parameters
234
+ ----------
235
+ w : double / numpy array
236
+
237
+ Returns
238
+ -------
239
+
240
+ """
241
+
242
+ points = self.get_gradient_constraints()
243
+ if points.shape[0] > 0:
244
+ # calculate unit vector for orientation data
245
+ # points[:,3:]/=np.linalg.norm(points[:,3:],axis=1)[:,None]
246
+
247
+ node_idx, inside = self.support.position_to_cell_corners(
248
+ points[:, :3])
249
+ # calculate unit vector for node gradients
250
+ # this means we are only constraining direction of grad not the
251
+ # magnitude
252
+ gi = np.zeros(self.support.n_nodes)
253
+ gi[:] = -1
254
+ gi[self.region] = np.arange(0, self.nx)
255
+ idc = np.zeros(node_idx.shape)
256
+ idc[:] = -1
257
+ idc[inside, :] = gi[node_idx[inside, :]]
258
+ inside = np.logical_and(~np.any(idc == -1, axis=1), inside)
259
+
260
+ T = self.support.calcul_T(points[inside, :3])
261
+ strike_vector, dip_vector = get_vectors(points[inside, 3:6])
262
+ A = np.einsum('ij,ijk->ik', strike_vector.T, T)
263
+
264
+ B = np.zeros(points[inside, :].shape[0])
265
+ self.add_constraints_to_least_squares(A * w, B, idc[inside, :], name='gradient')
266
+ A = np.einsum('ij,ijk->ik', dip_vector.T, T)
267
+ self.add_constraints_to_least_squares(A * w, B, idc[inside, :], name='gradient')
268
+
269
+ def add_norm_constraint(self, w=1.):
270
+ """
271
+ Add constraints to control the norm of the gradient of the scalar field
272
+
273
+ Parameters
274
+ ----------
275
+ w : double
276
+ weighting of this constraint (double)
277
+
278
+ Returns
279
+ -------
280
+
281
+ """
282
+ points = self.get_norm_constraints()
283
+ if points.shape[0] > 0:
284
+ # calculate unit vector for orientation data
285
+ # points[:,3:]/=np.linalg.norm(points[:,3:],axis=1)[:,None]
286
+
287
+ node_idx, inside = self.support.position_to_cell_corners(
288
+ points[:, :3])
289
+ gi = np.zeros(self.support.n_nodes)
290
+ gi[:] = -1
291
+ gi[self.region] = np.arange(0, self.nx)
292
+ idc = np.zeros(node_idx.shape)
293
+ idc[:] = -1
294
+ idc[inside, :] = gi[node_idx[inside, :]]
295
+ inside = np.logical_and(~np.any(idc == -1, axis=1), inside)
296
+
297
+ # calculate unit vector for node gradients
298
+ # this means we are only constraining direction of grad not the
299
+ # magnitude
300
+ T = self.support.calcul_T(points[inside, :3])
301
+
302
+ w /= 3
303
+ self.add_constraints_to_least_squares(T[:, 0, :] * w,
304
+ points[inside, 3] * w,
305
+ idc[inside, :], name='norm')
306
+ self.add_constraints_to_least_squares(T[:, 1, :] * w,
307
+ points[inside, 4] * w,
308
+ idc[inside, :], name='norm')
309
+ self.add_constraints_to_least_squares(T[:, 2, :] * w,
310
+ points[inside, 5] * w,
311
+ idc[inside, :], name='norm')
312
+
313
+ def add_gradient_orthogonal_constraint(self, points, vector, w=1.0,
314
+ B=0):
315
+ """
316
+ constraints scalar field to be orthogonal to a given vector
317
+
318
+ Parameters
319
+ ----------
320
+ elements : np.array
321
+ normals : np.array
322
+ w : double
323
+ B : np.array
324
+
325
+ Returns
326
+ -------
327
+
328
+ """
329
+ if points.shape[0] > 0:
330
+ # calculate unit vector for orientation data
331
+ # points[:,3:]/=np.linalg.norm(points[:,3:],axis=1)[:,None]
332
+
333
+ node_idx, inside = self.support.position_to_cell_corners(
334
+ points[:, :3])
335
+ # calculate unit vector for node gradients
336
+ # this means we are only constraining direction of grad not the
337
+ # magnitude
338
+ gi = np.zeros(self.support.n_nodes)
339
+ gi[:] = -1
340
+ gi[self.region] = np.arange(0, self.nx)
341
+ idc = np.zeros(node_idx.shape)
342
+ idc[:] = -1
343
+
344
+ idc[inside, :] = gi[node_idx[inside, :]]
345
+ inside = np.logical_and(~np.any(idc == -1, axis=1), inside)
346
+
347
+ T = self.support.calcul_T(points[inside, :3])
348
+ A = np.einsum('ij,ijk->ik', vector[inside, :3], T)
349
+
350
+ B = np.zeros(points[inside, :].shape[0])
351
+ self.add_constraints_to_least_squares(A * w, B, idc[inside, :], name='gradient orthogonal')
352
+
353
+ def add_regularisation(self, operator, w=0.1):
354
+ """
355
+
356
+ Parameters
357
+ ----------
358
+ operator
359
+ w
360
+
361
+ Returns
362
+ -------
363
+
364
+ """
365
+ self.assemble_inner(operator)
366
+ # self.assemble_borders()
367
+
368
+ def assemble_inner(self, operator, w):
369
+ """
370
+
371
+ Parameters
372
+ ----------
373
+ operator : Operator
374
+ w : double
375
+
376
+ Returns
377
+ -------
378
+
379
+ """
380
+ # First get the global indicies of the pairs of neighbours this should be an
381
+ # Nx27 array for 3d and an Nx9 array for 2d
382
+
383
+ global_indexes = self.support.neighbour_global_indexes() # np.array([ii,jj]))
384
+
385
+ a = np.tile(operator.flatten(), (global_indexes.shape[1], 1))
386
+ idc = global_indexes.T
387
+
388
+ gi = np.zeros(self.support.n_nodes)
389
+ gi[:] = -1
390
+ gi[self.region] = np.arange(0, self.nx)
391
+ idc = gi[idc]
392
+ inside = ~np.any(idc == -1, axis=1)
393
+ B = np.zeros(global_indexes.shape[1])
394
+ self.add_constraints_to_least_squares(a[inside, :] * w,
395
+ B[inside],
396
+ idc[inside, :],
397
+ name='regularisation'
398
+ )
399
+ return
@@ -0,0 +1,197 @@
1
+ """
2
+ Base geological interpolator
3
+ """
4
+ import logging
5
+
6
+ import numpy as np
7
+
8
+ from LoopStructural.utils import getLogger
9
+ logger = getLogger(__name__)
10
+
11
+
12
+ class GeologicalInterpolator:
13
+ """
14
+ Attributes
15
+ ----------
16
+ data : dict
17
+ a dictionary with np.arrays for gradient, value, normal, tangent data
18
+ """
19
+ def __init__(self):
20
+ """
21
+ This class is the base class for a geological interpolator and contains all of the
22
+ main interface functions. Any class that is inheriting from this should be callable
23
+ by using any of these functions. This will enable interpolators to be interchanged.
24
+ """
25
+
26
+ self.data = {'gradient': np.zeros((0,7)),
27
+ 'value' : np.zeros((0,5)),
28
+ 'normal': np.zeros((0,7)),
29
+ 'tangent': np.zeros((0,7)),
30
+ 'interface' : np.zeros((0,5))
31
+ }
32
+ self.n_g = 0
33
+ self.n_i = 0
34
+ self.n_n = 0
35
+ self.n_t = 0
36
+
37
+ self.type = 'undefined'
38
+ self.up_to_date = False
39
+ self.constraints = []
40
+ self.propertyname = 'defaultproperty'
41
+ self.__str = 'Base Geological Interpolator'
42
+
43
+ def __str__(self):
44
+
45
+ return self.__str
46
+
47
+ def set_region(self,**kwargs):
48
+ pass
49
+
50
+ def set_property_name(self, name):
51
+ """
52
+ Set the name of the interpolated property
53
+ Parameters
54
+ ----------
55
+ name : string
56
+ name of the property to be saved on a mesh
57
+
58
+ Returns
59
+ -------
60
+
61
+ """
62
+ self.propertyname = name
63
+
64
+ def set_value_constraints(self, points):
65
+ """
66
+
67
+ Parameters
68
+ ----------
69
+ points
70
+
71
+ Returns
72
+ -------
73
+
74
+ """
75
+
76
+ self.data['value'] = points
77
+ self.n_i = points.shape[0]
78
+
79
+ def set_gradient_constraints(self, points):
80
+ """
81
+
82
+ Parameters
83
+ ----------
84
+ points
85
+
86
+ Returns
87
+ -------
88
+
89
+ """
90
+ self.n_g = points.shape[0]
91
+ self.data['gradient'] = points
92
+
93
+ def set_normal_constraints(self, points):
94
+ """
95
+
96
+ Parameters
97
+ ----------
98
+ points
99
+
100
+ Returns
101
+ -------
102
+
103
+ """
104
+ self.n_n = points.shape[0]
105
+ self.data['normal'] = points
106
+
107
+ def set_tangent_constraints(self, points):
108
+ """
109
+
110
+ Parameters
111
+ ----------
112
+ points
113
+
114
+ Returns
115
+ -------
116
+
117
+ """
118
+ self.data['tangent'] = points
119
+
120
+ def set_interface_constraints(self, points):
121
+ self.data['interface'] = points
122
+
123
+ def get_value_constraints(self):
124
+ """
125
+
126
+ Returns
127
+ -------
128
+ numpy array
129
+ """
130
+ return self.data['value']
131
+
132
+ def get_gradient_constraints(self):
133
+ """
134
+
135
+ Returns
136
+ -------
137
+ numpy array
138
+ """
139
+ return self.data['gradient']
140
+
141
+
142
+ def get_tangent_constraints(self):
143
+ """
144
+
145
+ Returns
146
+ -------
147
+ numpy array
148
+ """
149
+
150
+ return self.data['tangent']
151
+
152
+ def get_norm_constraints(self):
153
+ """
154
+
155
+ Returns
156
+ -------
157
+ numpy array
158
+ """
159
+ return self.data['normal']
160
+
161
+ def get_data_locations(self):
162
+ norm = self.get_norm_constraints()
163
+ grad = self.get_gradient_constraints()
164
+ val = self.get_value_constraints()
165
+ return np.vstack([norm[:,:3],grad[:,:3],val[:,:3]])
166
+
167
+ def get_interface_constraints(self):
168
+ return self.data['interface']
169
+ def setup_interpolator(self, **kwargs):
170
+ """
171
+ Runs all of the required setting up stuff
172
+ """
173
+ self._setup_interpolator(**kwargs)
174
+
175
+ def solve_system(self, **kwargs):
176
+ """
177
+ Solves the interpolation equations
178
+ """
179
+ self._solve(**kwargs)
180
+ self.up_to_date = True
181
+
182
+ def update(self):
183
+ return False
184
+
185
+ def reset(self):
186
+ """
187
+ Removes all of the data from an interpolator
188
+
189
+ Returns
190
+ -------
191
+
192
+ """
193
+ self.n_g = 0
194
+ self.n_i = 0
195
+ self.n_n = 0
196
+ self.n_t = 0
197
+
@@ -0,0 +1,61 @@
1
+ """
2
+ Finite difference masks
3
+ """
4
+ import logging
5
+
6
+ import numpy as np
7
+
8
+ from LoopStructural.utils import getLogger
9
+ logger = getLogger(__name__)
10
+
11
+
12
+ class Operator(object):
13
+ """
14
+
15
+ """
16
+ z = np.zeros((3, 3))
17
+ Dx_mask = np.array([z, [
18
+ [0.0, 0.0, 0.0],
19
+ [-0.5, 0.0, 0.5],
20
+ [0.0, 0.0, 0.0]], z
21
+ ])
22
+ Dy_mask = Dx_mask.swapaxes(1, 2)
23
+ Dz_mask = Dx_mask.swapaxes(0, 2)
24
+
25
+ Dxx_mask = np.array([z, [
26
+ [0, 0, 0],
27
+ [1, -2, 1],
28
+ [0, 0, 0]], z])
29
+ Dyy_mask = Dxx_mask.swapaxes(1, 2)
30
+ Dzz_mask = Dxx_mask.swapaxes(0, 2)
31
+
32
+ Dxy_mask = np.array([z, [
33
+ [-0.25, 0, 0.25],
34
+ [0, 0, 0],
35
+ [0.25, 0, -0.25]
36
+ ], z])
37
+ Dxz_mask = Dxy_mask.swapaxes(0, 1)
38
+ Dyz_mask = Dxy_mask.swapaxes(0, 2)
39
+
40
+ # from https://en.wikipedia.org/wiki/Discrete_Laplace_operator
41
+ Lapacian = np.array([[[0, 0, 0],
42
+ [0, 1, 0], # first plane
43
+ [0, 0, 0]]
44
+ , [[0, 1, 0],
45
+ [1, -6, 1], # second plane
46
+ [0, 1, 0]],
47
+ [[0, 0, 0],
48
+ [0, 1, 0], # third plane
49
+ [0, 0, 0]]]
50
+ )
51
+
52
+ #Hessian is
53
+ # Dxx Dxy Dxz
54
+ # Dxy Dyy Dzy
55
+ # Dzx Dzy Dzz
56
+
57
+ #det of hessian
58
+ # Det_Hessian_operator =
59
+ # Dxx_mask.dot(Dyy_mask.dot(Dzz_mask)) - Dxx_mask.dot(Dyz_mask.dot(Dyz_mask) -
60
+ # Dxy_mask.dot(Dxy_mask.dot(Dzz_mask)) - Dxy_mask.dot(Dxz_mask.dot(Dyz_mask)) +
61
+ # Dxz_mask.dot(Dxy_mask.dot(Dyz_mask)) - Dxz_mask.dot(Dyy_mask.dot(Dxz_mask))