LoopStructural 1.0.4__zip
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.
Potentially problematic release.
This version of LoopStructural might be problematic. Click here for more details.
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/__init__.py +33 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/__pycache__/__init__.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/__init__.py +12 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/__pycache__/__init__.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/__pycache__/_base.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/_base.py +65 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/claudius.csv +21049 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/claudiusbb.txt +2 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/duplex.csv +126 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/duplexbb.txt +2 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/intrusion.csv +1017 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/intrusionbb.txt +2 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/onefoldbb.txt +2 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/onefolddata.csv +2226 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/refolded_bb.txt +2 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/refolded_fold.csv +2126 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__init__.py +31 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/__init__.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/discrete_fold_interpolator.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/discrete_interpolator.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/finite_difference_interpolator.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/geological_interpolator.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/operator.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/piecewiselinear_interpolator.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/structured_grid.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/structured_tetra.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/surfe_wrapper.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/cython/__init__.py +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/cython/__pycache__/__init__.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/cython/dsi_helper.c +27782 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/cython/dsi_helper.cp37-win_amd64.pyd +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/discrete_fold_interpolator.py +171 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/discrete_interpolator.py +551 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/finite_difference_interpolator.py +342 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/geological_interpolator.py +190 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/operator.py +60 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/piecewiselinear_interpolator.py +348 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/structured_grid.py +466 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/structured_tetra.py +638 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/surfe_wrapper.py +117 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/__init__.py +46 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/__pycache__/__init__.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/core/__init__.py +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/core/__pycache__/__init__.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/core/__pycache__/geological_model.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/core/geological_model.py +1351 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/__init__.py +3 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/__pycache__/__init__.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/__pycache__/fault_function.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/__pycache__/fault_function_feature.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/__pycache__/fault_segment.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/fault_function.py +187 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/fault_function_feature.py +75 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/fault_segment.py +270 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__init__.py +7 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/__init__.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/cross_product_geological_feature.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/geological_feature.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/geological_feature_builder.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/region_feature.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/structural_frame.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/structural_frame_builder.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/unconformity_feature.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/cross_product_geological_feature.py +77 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/geological_feature.py +286 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/geological_feature_builder.py +329 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/region_feature.py +34 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/structural_frame.py +116 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/structural_frame_builder.py +179 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/unconformity_feature.py +69 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__init__.py +8 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__pycache__/__init__.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__pycache__/fold.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__pycache__/fold_rotation_angle.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__pycache__/fold_rotation_angle_feature.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__pycache__/foldframe.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__pycache__/svariogram.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/fold.py +135 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/fold_rotation_angle.py +132 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/fold_rotation_angle_feature.py +57 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/foldframe.py +192 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/svariogram.py +179 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/__init__.py +14 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/__pycache__/__init__.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/__pycache__/exceptions.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/__pycache__/helper.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/__pycache__/map2loop.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/__pycache__/utils.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/exceptions.py +9 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/helper.py +378 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/map2loop.py +314 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/utils.py +120 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__init__.py +19 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__pycache__/__init__.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__pycache__/map_viewer.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__pycache__/model_plotter.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__pycache__/model_visualisation.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__pycache__/rotation_angle_plotter.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__pycache__/sphinx_scraper.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/map_viewer.py +307 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/model_plotter.py +16 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/model_visualisation.py +1012 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/rotation_angle_plotter.py +82 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/sphinx_scraper.py +34 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.4-py3.7.egg-info/PKG-INFO +10 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.4-py3.7.egg-info/SOURCES.txt +60 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.4-py3.7.egg-info/dependency_links.txt +1 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.4-py3.7.egg-info/requires.txt +8 -0
- Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.4-py3.7.egg-info/top_level.txt +2 -0
- Miniconda/envs/loop/Lib/site-packages/tests/__init__.py +0 -0
- Miniconda/envs/loop/Lib/site-packages/tests/__pycache__/__init__.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/tests/__pycache__/test_faults.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/tests/__pycache__/test_fold.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/tests/__pycache__/test_interpolator.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/tests/__pycache__/test_refolded.cpython-37.pyc +0 -0
- Miniconda/envs/loop/Lib/site-packages/tests/test_faults.py +17 -0
- Miniconda/envs/loop/Lib/site-packages/tests/test_fold.py +57 -0
- Miniconda/envs/loop/Lib/site-packages/tests/test_interpolator.py +88 -0
- Miniconda/envs/loop/Lib/site-packages/tests/test_refolded.py +22 -0
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Cartesian grid for fold interpolator
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
import logging
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class StructuredGrid:
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
"""
|
|
16
|
+
def __init__(self,
|
|
17
|
+
origin=np.zeros(3),
|
|
18
|
+
nsteps=np.array([10, 10, 10]),
|
|
19
|
+
step_vector=np.ones(3),
|
|
20
|
+
maximum=None
|
|
21
|
+
):
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
origin - 3d list or numpy array
|
|
27
|
+
nsteps - 3d list or numpy array of ints
|
|
28
|
+
step_vector - 3d list or numpy array of int
|
|
29
|
+
maximum
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
self.nsteps = np.array(nsteps)
|
|
33
|
+
self.step_vector = np.array(step_vector)
|
|
34
|
+
self.origin = np.array(origin)
|
|
35
|
+
self.maximum = origin+self.nsteps*self.step_vector
|
|
36
|
+
|
|
37
|
+
# self.nsteps+=1
|
|
38
|
+
self.n_nodes = self.nsteps[0] * self.nsteps[1] * self.nsteps[2]
|
|
39
|
+
# self.nsteps-=1
|
|
40
|
+
self.dim = 3
|
|
41
|
+
self.nsteps_cells = self.nsteps - 1
|
|
42
|
+
self.n_cell_x = self.nsteps[0] - 1
|
|
43
|
+
self.n_cell_y = self.nsteps[1] - 1
|
|
44
|
+
self.n_cell_z = self.nsteps[2] - 1
|
|
45
|
+
self.properties = {}
|
|
46
|
+
self.n_elements = self.n_cell_x * self.n_cell_y * self.n_cell_z
|
|
47
|
+
|
|
48
|
+
# calculate the node positions using numpy (this should probably not
|
|
49
|
+
# be stored as it defeats
|
|
50
|
+
# the purpose of a structured grid
|
|
51
|
+
|
|
52
|
+
# self.barycentre = self.cell_centres(np.arange(self.n_elements))
|
|
53
|
+
|
|
54
|
+
self.regions = {}
|
|
55
|
+
self.regions['everywhere'] = np.ones(self.n_nodes).astype(bool)
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def nodes(self):
|
|
59
|
+
max = self.origin + self.nsteps_cells * self.step_vector
|
|
60
|
+
x = np.linspace(self.origin[0], max[0], self.nsteps[0])
|
|
61
|
+
y = np.linspace(self.origin[1], max[1], self.nsteps[1])
|
|
62
|
+
z = np.linspace(self.origin[2], max[2], self.nsteps[2])
|
|
63
|
+
xx, yy, zz = np.meshgrid(x, y, z, indexing='ij')
|
|
64
|
+
return np.array([xx.flatten(order='F'), yy.flatten(order='F'),
|
|
65
|
+
zz.flatten(order='F')]).T
|
|
66
|
+
|
|
67
|
+
def barycentre(self):
|
|
68
|
+
return self.cell_centres(np.arange(self.n_elements))
|
|
69
|
+
|
|
70
|
+
def print_geometry(self):
|
|
71
|
+
print('Origin: %f %f %f' % (
|
|
72
|
+
self.origin[0], self.origin[1], self.origin[2]))
|
|
73
|
+
print('Cell size: %f %f %f' % (
|
|
74
|
+
self.step_vector[0], self.step_vector[1], self.step_vector[2]))
|
|
75
|
+
max = self.origin + self.nsteps_cells * self.step_vector
|
|
76
|
+
print('Max extent: %f %f %f' % (max[0], max[1], max[2]))
|
|
77
|
+
|
|
78
|
+
def update_property(self, propertyname, values):
|
|
79
|
+
"""[summary]
|
|
80
|
+
|
|
81
|
+
[extended_summary]
|
|
82
|
+
|
|
83
|
+
Parameters
|
|
84
|
+
----------
|
|
85
|
+
propertyname : [type]
|
|
86
|
+
[description]
|
|
87
|
+
values : [type]
|
|
88
|
+
[description]
|
|
89
|
+
"""
|
|
90
|
+
if values.shape[0] == self.n_nodes:
|
|
91
|
+
self.properties[propertyname] = values
|
|
92
|
+
if values.shape[0] == self.n_elements:
|
|
93
|
+
self.cell_properties[propertyname] = values
|
|
94
|
+
|
|
95
|
+
def cell_centres(self, global_index):
|
|
96
|
+
"""[summary]
|
|
97
|
+
|
|
98
|
+
[extended_summary]
|
|
99
|
+
|
|
100
|
+
Parameters
|
|
101
|
+
----------
|
|
102
|
+
global_index : [type]
|
|
103
|
+
[description]
|
|
104
|
+
|
|
105
|
+
Returns
|
|
106
|
+
-------
|
|
107
|
+
[type]
|
|
108
|
+
[description]
|
|
109
|
+
"""
|
|
110
|
+
ix, iy, iz = self.global_index_to_cell_index(global_index)
|
|
111
|
+
x = self.origin[None, 0] + self.step_vector[None, 0] * .5 + \
|
|
112
|
+
self.step_vector[None, 0] * ix
|
|
113
|
+
y = self.origin[None, 1] + self.step_vector[None, 1] * .5 + \
|
|
114
|
+
self.step_vector[None, 1] * iy
|
|
115
|
+
z = self.origin[None, 2] + self.step_vector[None, 2] * .5 + \
|
|
116
|
+
self.step_vector[None, 2] * iz
|
|
117
|
+
return np.array([x, y, z]).T
|
|
118
|
+
|
|
119
|
+
def position_to_cell_index(self, pos):
|
|
120
|
+
"""[summary]
|
|
121
|
+
|
|
122
|
+
[extended_summary]
|
|
123
|
+
|
|
124
|
+
Parameters
|
|
125
|
+
----------
|
|
126
|
+
pos : [type]
|
|
127
|
+
[description]
|
|
128
|
+
|
|
129
|
+
Returns
|
|
130
|
+
-------
|
|
131
|
+
[type]
|
|
132
|
+
[description]
|
|
133
|
+
"""
|
|
134
|
+
|
|
135
|
+
pos = self.check_position(pos)
|
|
136
|
+
|
|
137
|
+
ix = pos[:, 0] - self.origin[None, 0]
|
|
138
|
+
iy = pos[:, 1] - self.origin[None, 1]
|
|
139
|
+
iz = pos[:, 2] - self.origin[None, 2]
|
|
140
|
+
ix = ix // self.step_vector[None, 0]
|
|
141
|
+
iy = iy // self.step_vector[None, 1]
|
|
142
|
+
iz = iz // self.step_vector[None, 2]
|
|
143
|
+
return ix.astype(int), iy.astype(int), iz.astype(int)
|
|
144
|
+
|
|
145
|
+
def inside(self, pos):
|
|
146
|
+
|
|
147
|
+
# check whether point is inside box
|
|
148
|
+
inside = np.ones(pos.shape[0]).astype(bool)
|
|
149
|
+
for i in range(3):
|
|
150
|
+
inside *= pos[:, i] > self.origin[None, i]
|
|
151
|
+
inside *= pos[:, i] < self.origin[None, i] + \
|
|
152
|
+
self.step_vector[None, i] * self.nsteps_cells[None, i]
|
|
153
|
+
return inside
|
|
154
|
+
|
|
155
|
+
def check_position(self, pos):
|
|
156
|
+
"""[summary]
|
|
157
|
+
|
|
158
|
+
[extended_summary]
|
|
159
|
+
|
|
160
|
+
Parameters
|
|
161
|
+
----------
|
|
162
|
+
pos : [type]
|
|
163
|
+
[description]
|
|
164
|
+
|
|
165
|
+
Returns
|
|
166
|
+
-------
|
|
167
|
+
[type]
|
|
168
|
+
[description]
|
|
169
|
+
"""
|
|
170
|
+
|
|
171
|
+
if len(pos.shape) == 1:
|
|
172
|
+
pos = np.array([pos])
|
|
173
|
+
if len(pos.shape) != 2:
|
|
174
|
+
print("Position array needs to be a list of points or a point")
|
|
175
|
+
return False
|
|
176
|
+
return pos
|
|
177
|
+
|
|
178
|
+
def trilinear(self, x, y, z):
|
|
179
|
+
"""
|
|
180
|
+
returns the trilinear interpolation for the local coordinates
|
|
181
|
+
Parameters
|
|
182
|
+
----------
|
|
183
|
+
x - double, array of doubles
|
|
184
|
+
y - double, array of doubles
|
|
185
|
+
z - double, array of doubles
|
|
186
|
+
|
|
187
|
+
Returns
|
|
188
|
+
-------
|
|
189
|
+
array of interpolation coefficients
|
|
190
|
+
|
|
191
|
+
"""
|
|
192
|
+
return np.array([(1 - x) * (1 - y) * (1 - z),
|
|
193
|
+
x * (1 - y) * (1 - z),
|
|
194
|
+
(1 - x) * y * (1 - z),
|
|
195
|
+
(1 - x) * (1 - y) * z,
|
|
196
|
+
x * (1 - y) * z,
|
|
197
|
+
(1 - x) * y * z,
|
|
198
|
+
x * y * (1 - z),
|
|
199
|
+
x * y * z])
|
|
200
|
+
|
|
201
|
+
def position_to_local_coordinates(self, pos):
|
|
202
|
+
"""
|
|
203
|
+
Convert from global to local coordinates within a cel
|
|
204
|
+
Parameters
|
|
205
|
+
----------
|
|
206
|
+
pos - array of positions inside
|
|
207
|
+
|
|
208
|
+
Returns
|
|
209
|
+
-------
|
|
210
|
+
localx, localy, localz
|
|
211
|
+
|
|
212
|
+
"""
|
|
213
|
+
# TODO check if inside mesh
|
|
214
|
+
|
|
215
|
+
# calculate local coordinates for positions
|
|
216
|
+
local_x = ((pos[:, 0] - self.origin[None, 0]) % self.step_vector[
|
|
217
|
+
None, 0]) / self.step_vector[None, 0]
|
|
218
|
+
local_y = ((pos[:, 1] - self.origin[None, 1]) % self.step_vector[
|
|
219
|
+
None, 1]) / self.step_vector[None, 1]
|
|
220
|
+
local_z = ((pos[:, 2] - self.origin[None, 2]) % self.step_vector[
|
|
221
|
+
None, 2]) / self.step_vector[None, 2]
|
|
222
|
+
|
|
223
|
+
return local_x, local_y, local_z
|
|
224
|
+
|
|
225
|
+
def position_to_dof_coefs(self, pos):
|
|
226
|
+
"""
|
|
227
|
+
global posotion to interpolation coefficients
|
|
228
|
+
Parameters
|
|
229
|
+
----------
|
|
230
|
+
pos
|
|
231
|
+
|
|
232
|
+
Returns
|
|
233
|
+
-------
|
|
234
|
+
|
|
235
|
+
"""
|
|
236
|
+
x_local, y_local, local_z = self.position_to_local_coordinates(pos)
|
|
237
|
+
weights = self.trilinear(x_local, y_local, local_z)
|
|
238
|
+
return weights
|
|
239
|
+
|
|
240
|
+
def global_indicies(self, indexes):
|
|
241
|
+
"""
|
|
242
|
+
xi, yi, zi to global index
|
|
243
|
+
|
|
244
|
+
Parameters
|
|
245
|
+
----------
|
|
246
|
+
indexes
|
|
247
|
+
|
|
248
|
+
Returns
|
|
249
|
+
-------
|
|
250
|
+
|
|
251
|
+
"""
|
|
252
|
+
indexes = np.array(indexes).swapaxes(0, 2)
|
|
253
|
+
return indexes[:, :, 0] + self.nsteps[None, None, 0] * indexes[:, :,
|
|
254
|
+
1] + \
|
|
255
|
+
self.nsteps[None, None, 0] * self.nsteps[
|
|
256
|
+
None, None, 1] * indexes[:, :, 2]
|
|
257
|
+
|
|
258
|
+
def neighbour_global_indexes(self, mask = None, **kwargs):
|
|
259
|
+
"""
|
|
260
|
+
Get neighbour indexes
|
|
261
|
+
|
|
262
|
+
Parameters
|
|
263
|
+
----------
|
|
264
|
+
kwargs - indexes array specifying the cells to return neighbours
|
|
265
|
+
|
|
266
|
+
Returns
|
|
267
|
+
-------
|
|
268
|
+
|
|
269
|
+
"""
|
|
270
|
+
indexes = None
|
|
271
|
+
if "indexes" in kwargs:
|
|
272
|
+
indexes = kwargs['indexes']
|
|
273
|
+
if "indexes" not in kwargs:
|
|
274
|
+
ii = []
|
|
275
|
+
jj = []
|
|
276
|
+
kk = []
|
|
277
|
+
for i in range(1, self.nsteps[0] - 1):
|
|
278
|
+
for j in range(1, self.nsteps[1] - 1):
|
|
279
|
+
for k in range(1, self.nsteps[2] - 1):
|
|
280
|
+
kk.append(k)
|
|
281
|
+
ii.append(i)
|
|
282
|
+
jj.append(j)
|
|
283
|
+
indexes = np.array([ii, jj, kk])
|
|
284
|
+
# indexes = np.array(indexes).T
|
|
285
|
+
if indexes.ndim != 2:
|
|
286
|
+
print(indexes.ndim)
|
|
287
|
+
return
|
|
288
|
+
# determine which neighbours to return default is diagonals included.
|
|
289
|
+
if mask is None:
|
|
290
|
+
mask = np.array([
|
|
291
|
+
[-1, 0, 1, -1, 0, 1, -1, 0, 1,
|
|
292
|
+
-1, 0, 1, -1, 0, 1, -1, 0, 1,
|
|
293
|
+
-1, 0, 1, -1, 0, 1, -1, 0, 1],
|
|
294
|
+
[-1, -1, -1, 0, 0, 0, 1, 1, 1,
|
|
295
|
+
-1, -1, -1, 0, 0, 0, 1, 1, 1,
|
|
296
|
+
-1, -1, -1, 0, 0, 0, 1, 1, 1],
|
|
297
|
+
[-1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
298
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
299
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1]
|
|
300
|
+
])
|
|
301
|
+
neighbours = indexes[:, None, :] + mask[:, :, None]
|
|
302
|
+
return(neighbours[0, :, :] + self.nsteps[0, None, None] * neighbours[1,
|
|
303
|
+
:, :] + \
|
|
304
|
+
self.nsteps[0, None, None] * self.nsteps[
|
|
305
|
+
1, None, None] * neighbours[2, :, :]).astype(np.int64)
|
|
306
|
+
|
|
307
|
+
def cell_corner_indexes(self, x_cell_index, y_cell_index, z_cell_index):
|
|
308
|
+
"""
|
|
309
|
+
Returns the indexes of the corners of a cell given its location xi,
|
|
310
|
+
yi, zi
|
|
311
|
+
|
|
312
|
+
Parameters
|
|
313
|
+
----------
|
|
314
|
+
x_cell_index
|
|
315
|
+
y_cell_index
|
|
316
|
+
z_cell_index
|
|
317
|
+
|
|
318
|
+
Returns
|
|
319
|
+
-------
|
|
320
|
+
|
|
321
|
+
"""
|
|
322
|
+
xcorner = np.array([0, 1, 0, 0, 1, 0, 1, 1])
|
|
323
|
+
ycorner = np.array([0, 0, 1, 0, 0, 1, 1, 1])
|
|
324
|
+
zcorner = np.array([0, 0, 0, 1, 1, 1, 0, 1])
|
|
325
|
+
xcorners = x_cell_index[:, None] + xcorner[None, :]
|
|
326
|
+
ycorners = y_cell_index[:, None] + ycorner[None, :]
|
|
327
|
+
zcorners = z_cell_index[:, None] + zcorner[None, :]
|
|
328
|
+
return xcorners, ycorners, zcorners
|
|
329
|
+
|
|
330
|
+
def global_index_to_cell_index(self, global_index):
|
|
331
|
+
"""
|
|
332
|
+
Convert from global indexes to xi,yi,zi
|
|
333
|
+
|
|
334
|
+
Parameters
|
|
335
|
+
----------
|
|
336
|
+
global_index
|
|
337
|
+
|
|
338
|
+
Returns
|
|
339
|
+
-------
|
|
340
|
+
|
|
341
|
+
"""
|
|
342
|
+
# determine the ijk indices for the global index.
|
|
343
|
+
# remainder when dividing by nx = i
|
|
344
|
+
# remained when dividing modulus of nx by ny is j
|
|
345
|
+
|
|
346
|
+
x_index = global_index % self.nsteps_cells[0, None]
|
|
347
|
+
y_index = global_index // self.nsteps_cells[0, None] % \
|
|
348
|
+
self.nsteps_cells[1, None]
|
|
349
|
+
z_index = global_index // self.nsteps_cells[0, None] // \
|
|
350
|
+
self.nsteps_cells[1, None]
|
|
351
|
+
return x_index, y_index, z_index
|
|
352
|
+
|
|
353
|
+
def node_indexes_to_position(self, xindex, yindex, zindex):
|
|
354
|
+
|
|
355
|
+
x = self.origin[0] + self.step_vector[0] * xindex
|
|
356
|
+
y = self.origin[1] + self.step_vector[1] * yindex
|
|
357
|
+
z = self.origin[2] + self.step_vector[2] * zindex
|
|
358
|
+
|
|
359
|
+
return x, y, z
|
|
360
|
+
|
|
361
|
+
def position_to_cell_corners(self, pos):
|
|
362
|
+
|
|
363
|
+
inside = self.inside(pos)
|
|
364
|
+
ix, iy, iz = self.position_to_cell_index(pos)
|
|
365
|
+
cornersx, cornersy, cornersz = self.cell_corner_indexes(ix, iy, iz)
|
|
366
|
+
globalidx = self.global_indicies(
|
|
367
|
+
np.dstack([cornersx, cornersy, cornersz]).T)
|
|
368
|
+
# if global index is not inside the support set to -1
|
|
369
|
+
globalidx[~inside] = -1
|
|
370
|
+
return globalidx, inside
|
|
371
|
+
|
|
372
|
+
def evaluate_value(self, evaluation_points, property_name):
|
|
373
|
+
"""
|
|
374
|
+
Evaluate the value of of the property at the locations.
|
|
375
|
+
Trilinear interpolation dot corner values
|
|
376
|
+
|
|
377
|
+
Parameters
|
|
378
|
+
----------
|
|
379
|
+
evaluation_points np array of locations
|
|
380
|
+
property_name string of property name
|
|
381
|
+
|
|
382
|
+
Returns
|
|
383
|
+
-------
|
|
384
|
+
|
|
385
|
+
"""
|
|
386
|
+
idc, inside = self.position_to_cell_corners(evaluation_points)
|
|
387
|
+
v = np.zeros(idc.shape)
|
|
388
|
+
v[:, :] = np.nan
|
|
389
|
+
|
|
390
|
+
v[inside, :] = self.position_to_dof_coefs(
|
|
391
|
+
evaluation_points[inside, :]).T
|
|
392
|
+
v[inside, :] *= self.properties[property_name][idc[inside, :]]
|
|
393
|
+
return np.sum(v, axis=1)
|
|
394
|
+
|
|
395
|
+
def evaluate_gradient(self, evaluation_points, property_name):
|
|
396
|
+
idc, inside = self.position_to_cell_corners(evaluation_points)
|
|
397
|
+
T = np.zeros((idc.shape[0], 3, 8))
|
|
398
|
+
T[inside, :, :] = self.calcul_T(evaluation_points[inside, :])
|
|
399
|
+
# indices = np.array([self.position_to_cell_index(evaluation_points)])
|
|
400
|
+
# idc = self.global_indicies(indices.swapaxes(0,1))
|
|
401
|
+
# print(idc)
|
|
402
|
+
T[inside, 0, :] *= self.properties[property_name][idc[inside, :]]
|
|
403
|
+
T[inside, 1, :] *= self.properties[property_name][idc[inside, :]]
|
|
404
|
+
T[inside, 2, :] *= self.properties[property_name][idc[inside, :]]
|
|
405
|
+
return np.array(
|
|
406
|
+
[np.sum(T[:, 0, :], axis=1) / 8, np.sum(T[:, 1, :], axis=1) / 8,
|
|
407
|
+
np.sum(T[:, 2, :], axis=1) / 8]).T
|
|
408
|
+
|
|
409
|
+
def calcul_T(self, pos):
|
|
410
|
+
"""
|
|
411
|
+
Calculates the gradient matrix at location pos
|
|
412
|
+
:param pos: numpy array of location Nx3
|
|
413
|
+
:return: Nx3x4 matrix
|
|
414
|
+
"""
|
|
415
|
+
# 6_ _ _ _ 8
|
|
416
|
+
# /| /|
|
|
417
|
+
# 4 /_| 5/ |
|
|
418
|
+
# | 2|_ _|_| 7
|
|
419
|
+
# | / | /
|
|
420
|
+
# |/_ _ _|/
|
|
421
|
+
# 0 1
|
|
422
|
+
#
|
|
423
|
+
# xindex, yindex, zindex = self.position_to_cell_index(pos)
|
|
424
|
+
# cellx, celly, cellz = self.cell_corner_indexes(xindex, yindex,zindex)
|
|
425
|
+
# x, y, z = self.node_indexes_to_position(cellx, celly, cellz)
|
|
426
|
+
T = np.zeros((pos.shape[0], 3, 8))
|
|
427
|
+
x, y, z = self.position_to_local_coordinates(pos)
|
|
428
|
+
# div = self.step_vector[0] * self.step_vector[1] * self.step_vector[2]
|
|
429
|
+
|
|
430
|
+
T[:, 0, 0] = -(1 - y) * (1 - z) # v000
|
|
431
|
+
T[:, 0, 1] = (1 - y) * (1 - z) # (y[:, 3] - pos[:, 1]) / div
|
|
432
|
+
T[:, 0, 2] = -y * (1 - z) # (pos[:, 1] - y[:, 0]) / div
|
|
433
|
+
T[:, 0, 3] = -(1 - y) * z # (pos[:, 1] - y[:, 1]) / div
|
|
434
|
+
T[:, 0, 4] = (1 - y) * z
|
|
435
|
+
T[:, 0, 5] = - y * z
|
|
436
|
+
T[:, 0, 6] = y * (1 - z)
|
|
437
|
+
T[:, 0, 7] = y * z
|
|
438
|
+
|
|
439
|
+
T[:, 1, 0] = - (1 - x) * (1 - z)
|
|
440
|
+
T[:, 1, 1] = - x * (1 - z)
|
|
441
|
+
T[:, 1, 2] = (1 - x) * (1 - z)
|
|
442
|
+
T[:, 1, 3] = -(1 - x) * z
|
|
443
|
+
T[:, 1, 4] = -x * z
|
|
444
|
+
T[:, 1, 5] = (1 - x) * z
|
|
445
|
+
T[:, 1, 6] = x * (1 - z)
|
|
446
|
+
T[:, 1, 7] = x * z
|
|
447
|
+
|
|
448
|
+
T[:, 2, 0] = -(1 - x) * (1 - y)
|
|
449
|
+
T[:, 2, 1] = - x * (1 - y)
|
|
450
|
+
T[:, 2, 2] = - (1 - x) * y
|
|
451
|
+
T[:, 2, 3] = (1 - x) * (1 - y)
|
|
452
|
+
T[:, 2, 4] = x * (1 - y)
|
|
453
|
+
T[:, 2, 5] = (1 - x) * y
|
|
454
|
+
T[:, 2, 6] = - x * y
|
|
455
|
+
T[:, 2, 7] = x * y
|
|
456
|
+
return T
|
|
457
|
+
|
|
458
|
+
def slice(self, propertyname, isovalue, region):
|
|
459
|
+
logger.error("function has been removed, please use the modelviewer class")
|
|
460
|
+
return
|
|
461
|
+
#
|
|
462
|
+
# verts, faces, normals, values = marching_cubes(
|
|
463
|
+
# self.properties[propertyname].reshape(self.nsteps, order='F'),
|
|
464
|
+
# isovalue,
|
|
465
|
+
# spacing=self.step_vector)
|
|
466
|
+
# return faces, verts + self.origin[None, :]
|