pyfedic_cython 23.9.0__tar.gz
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.
- pyfedic_cython-23.9.0/PKG-INFO +40 -0
- pyfedic_cython-23.9.0/README.md +17 -0
- pyfedic_cython-23.9.0/build.py +24 -0
- pyfedic_cython-23.9.0/pyfedic_cython/__init__.py +0 -0
- pyfedic_cython-23.9.0/pyfedic_cython/mesh.pyx +465 -0
- pyfedic_cython-23.9.0/pyfedic_cython/spfast.pyx +18 -0
- pyfedic_cython-23.9.0/pyproject.toml +28 -0
- pyfedic_cython-23.9.0/setup.py +31 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pyfedic_cython
|
|
3
|
+
Version: 23.9.0
|
|
4
|
+
Summary: Digital Image (2D/3D) Correlation Software - CYTHON module
|
|
5
|
+
Home-page: https://sourcesup.renater.fr/www/pyfedic/
|
|
6
|
+
License: CECILL-2.1
|
|
7
|
+
Author: Joël Lachambre
|
|
8
|
+
Author-email: joel.lachambre@cnrs.fr
|
|
9
|
+
Requires-Python: >=3.10,<3.12
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: License :: OSI Approved :: CEA CNRS Inria Logiciel Libre License, version 2.1 (CeCILL-2.1)
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Dist: pyfedic (>=23.9.0,<24.0.0)
|
|
20
|
+
Project-URL: Documentation, https://sourcesup.renater.fr/www/pyfedic/html
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# pyFEDIC : Digital Image (2D/3D) Correlation Software
|
|
24
|
+
|
|
25
|
+
pyFEDIC is a DIC software using global approach with finite element shape functions to describe the displacement field. It allows to perform 2D DIC and 3D DIC also called DVC (V stand for volume).
|
|
26
|
+
|
|
27
|
+
This software is a pure python library and offer a simple command line to run analysis with a few parameters as input.
|
|
28
|
+
|
|
29
|
+
It can be directly installed using pip:
|
|
30
|
+
|
|
31
|
+
```console
|
|
32
|
+
$ pip install pyfedic
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
For more information, visit https://sourcesup.renater.fr/www/pyfedic/html/index.html
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
[](https://doi.org/10.5281/zenodo.8298430)
|
|
39
|
+
|
|
40
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# pyFEDIC : Digital Image (2D/3D) Correlation Software
|
|
2
|
+
|
|
3
|
+
pyFEDIC is a DIC software using global approach with finite element shape functions to describe the displacement field. It allows to perform 2D DIC and 3D DIC also called DVC (V stand for volume).
|
|
4
|
+
|
|
5
|
+
This software is a pure python library and offer a simple command line to run analysis with a few parameters as input.
|
|
6
|
+
|
|
7
|
+
It can be directly installed using pip:
|
|
8
|
+
|
|
9
|
+
```console
|
|
10
|
+
$ pip install pyfedic
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
For more information, visit https://sourcesup.renater.fr/www/pyfedic/html/index.html
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
[](https://doi.org/10.5281/zenodo.8298430)
|
|
17
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
from Cython.Build import cythonize
|
|
4
|
+
from setuptools import Extension
|
|
5
|
+
|
|
6
|
+
def build(setup_kwargs):
|
|
7
|
+
extensions = [
|
|
8
|
+
Extension(
|
|
9
|
+
"*",
|
|
10
|
+
["pyfedic_cython/*.pyx"],
|
|
11
|
+
extra_compile_args=['-fopenmp'],
|
|
12
|
+
extra_link_args=['-fopenmp'],
|
|
13
|
+
libraries=["m"],
|
|
14
|
+
),
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
ext_modules = cythonize(
|
|
18
|
+
extensions,
|
|
19
|
+
#annotate=True,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
setup_kwargs.update({
|
|
23
|
+
'ext_modules': ext_modules,
|
|
24
|
+
})
|
|
File without changes
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# cython: boundscheck=False, cdivision=True, wraparound=False, initializedcheck=False
|
|
3
|
+
import numpy as np
|
|
4
|
+
from cython.parallel import prange, threadid
|
|
5
|
+
from libc.math cimport floor, ceil
|
|
6
|
+
from libc.stdio cimport printf, fflush, stdout
|
|
7
|
+
from libc.stdlib cimport malloc, free, realloc
|
|
8
|
+
|
|
9
|
+
from scipy import sparse
|
|
10
|
+
|
|
11
|
+
from openmp cimport omp_lock_t, omp_set_lock, omp_unset_lock, omp_init_lock, omp_destroy_lock
|
|
12
|
+
|
|
13
|
+
from multiprocessing import cpu_count
|
|
14
|
+
|
|
15
|
+
cdef int n_cpu = cpu_count()
|
|
16
|
+
|
|
17
|
+
def compute_N_by_type(points, nodes, cells, T, indp, indn, val, done, indni, iii, n_thread=-1):
|
|
18
|
+
indni = Compute_N(points, nodes, cells, T, indp, indn, val, done, indni, iii, n_thread).get_indni()
|
|
19
|
+
iii = iii+len(cells)
|
|
20
|
+
return iii, indni
|
|
21
|
+
|
|
22
|
+
cdef class Compute_N:
|
|
23
|
+
#
|
|
24
|
+
cdef bint is_linear
|
|
25
|
+
cdef double EPSILON
|
|
26
|
+
|
|
27
|
+
cdef double[:,:] N_data, dNdr_data, dNds_data, dNdt_data
|
|
28
|
+
|
|
29
|
+
cdef int ndim, n_thread, n_nodes
|
|
30
|
+
cdef long dimz, dimy, dimx, startz, starty, startx
|
|
31
|
+
cdef long n_points, n_cells, indni, iii
|
|
32
|
+
|
|
33
|
+
cdef double[:,:] nodes
|
|
34
|
+
cdef long[:,:] cells
|
|
35
|
+
cdef double[:,:] points
|
|
36
|
+
|
|
37
|
+
cdef int[:] indp, indn, done
|
|
38
|
+
cdef float[:] val
|
|
39
|
+
|
|
40
|
+
cdef omp_lock_t lock, lock_done
|
|
41
|
+
|
|
42
|
+
def get_indni(self):
|
|
43
|
+
return self.indni
|
|
44
|
+
|
|
45
|
+
def __init__(self, points, nodes, cells, cell_type, int[:] indp, int[:] indn, float[:] val, int[:] done, long indni, long iii, int n_thread=-1):
|
|
46
|
+
#
|
|
47
|
+
self.indp = indp
|
|
48
|
+
self.indn = indn
|
|
49
|
+
self.val = val
|
|
50
|
+
self.done = done
|
|
51
|
+
|
|
52
|
+
self.EPSILON = cell_type.EPSILON
|
|
53
|
+
self.ndim = cell_type.ndim
|
|
54
|
+
self.nodes = nodes
|
|
55
|
+
self.cells = cells
|
|
56
|
+
|
|
57
|
+
self.N_data = cell_type._N_data
|
|
58
|
+
self.dNdr_data = cell_type._dN_data[0]
|
|
59
|
+
self.dNds_data = cell_type._dN_data[1]
|
|
60
|
+
if self.ndim == 3:
|
|
61
|
+
self.dNdt_data = cell_type._dN_data[2]
|
|
62
|
+
|
|
63
|
+
self.n_nodes = cell_type.n_nodes
|
|
64
|
+
self.n_cells = len(cells)
|
|
65
|
+
|
|
66
|
+
self.is_linear = cell_type.is_linear
|
|
67
|
+
|
|
68
|
+
if n_thread < 0:
|
|
69
|
+
n_thread = n_cpu
|
|
70
|
+
|
|
71
|
+
if self.n_cells > 10:
|
|
72
|
+
self.n_thread = min(n_thread, self.n_cells)
|
|
73
|
+
else:
|
|
74
|
+
self.n_thread = 1
|
|
75
|
+
|
|
76
|
+
self.indni = indni
|
|
77
|
+
self.iii = iii
|
|
78
|
+
|
|
79
|
+
cdef long i_cell, i_point, zi, yi, xi
|
|
80
|
+
cdef bint grid = 0
|
|
81
|
+
|
|
82
|
+
if isinstance(points, np.ndarray):
|
|
83
|
+
self.n_points = len(points)
|
|
84
|
+
self.points = points
|
|
85
|
+
else:
|
|
86
|
+
grid = 1
|
|
87
|
+
if self.ndim == 2:
|
|
88
|
+
self.startz, self.starty, self.startx = (0,) + points.roi.offset
|
|
89
|
+
self.dimz, self.dimy, self.dimx = (1, ) + points.roi.shape
|
|
90
|
+
else:
|
|
91
|
+
self.startz, self.starty, self.startx = points.roi.offset
|
|
92
|
+
self.dimz, self.dimy, self.dimx = points.roi.shape
|
|
93
|
+
self.n_points = self.dimx*self.dimy*self.dimz
|
|
94
|
+
self.points = np.zeros((self.n_points, 3), dtype='f8')
|
|
95
|
+
i_point = 0
|
|
96
|
+
for zi in xrange(self.startz, self.startz+self.dimz):
|
|
97
|
+
for yi in xrange(self.starty, self.starty+self.dimy):
|
|
98
|
+
for xi in xrange(self.startx, self.startx+self.dimx):
|
|
99
|
+
self.points[i_point,0] = <double> xi
|
|
100
|
+
self.points[i_point,1] = <double> yi
|
|
101
|
+
self.points[i_point,2] = <double> zi
|
|
102
|
+
i_point += 1
|
|
103
|
+
|
|
104
|
+
omp_init_lock(&self.lock)
|
|
105
|
+
omp_init_lock(&self.lock_done)
|
|
106
|
+
|
|
107
|
+
for i_cell in prange(self.n_cells, nogil=True, num_threads=self.n_thread):
|
|
108
|
+
if grid:
|
|
109
|
+
self.compute_grid_thread(i_cell)
|
|
110
|
+
else:
|
|
111
|
+
self.compute_ugrid_thread(i_cell)
|
|
112
|
+
|
|
113
|
+
omp_destroy_lock(&self.lock)
|
|
114
|
+
omp_destroy_lock(&self.lock_done)
|
|
115
|
+
|
|
116
|
+
cdef void compute_grid_thread(self, long i_cell) noexcept nogil:
|
|
117
|
+
#
|
|
118
|
+
cdef long zzmin, zzmax, yymin, yymax, xxmin, xxmax
|
|
119
|
+
cdef long zi, xi, yi
|
|
120
|
+
cdef long i_node = 0
|
|
121
|
+
cdef long i_todo, n_todo
|
|
122
|
+
|
|
123
|
+
xxmin = <long> floor(self.nodes[self.cells[i_cell,i_node],0]+0.5)
|
|
124
|
+
xxmax = <long> ceil(self.nodes[self.cells[i_cell,i_node],0]+0.5)
|
|
125
|
+
yymin = <long> floor(self.nodes[self.cells[i_cell,i_node],1]+0.5)
|
|
126
|
+
yymax = <long> ceil(self.nodes[self.cells[i_cell,i_node],1]+0.5)
|
|
127
|
+
zzmin = <long> floor(self.nodes[self.cells[i_cell,i_node],2]+0.5)
|
|
128
|
+
zzmax = <long> ceil(self.nodes[self.cells[i_cell,i_node],2]+0.5)
|
|
129
|
+
|
|
130
|
+
for i_node in xrange(1, self.n_nodes):
|
|
131
|
+
if xxmin > self.nodes[self.cells[i_cell,i_node],0]:
|
|
132
|
+
xxmin = <long> floor(self.nodes[self.cells[i_cell,i_node],0]+0.5)
|
|
133
|
+
if xxmax < self.nodes[self.cells[i_cell,i_node],0]:
|
|
134
|
+
xxmax = <long> ceil(self.nodes[self.cells[i_cell,i_node],0]+0.5)
|
|
135
|
+
if yymin > self.nodes[self.cells[i_cell,i_node],1]:
|
|
136
|
+
yymin = <long> floor(self.nodes[self.cells[i_cell,i_node],1]+0.5)
|
|
137
|
+
if yymax < self.nodes[self.cells[i_cell,i_node],1]:
|
|
138
|
+
yymax = <long> ceil(self.nodes[self.cells[i_cell,i_node],1]+0.5)
|
|
139
|
+
if zzmin > self.nodes[self.cells[i_cell,i_node],2]:
|
|
140
|
+
zzmin = <long> floor(self.nodes[self.cells[i_cell,i_node],2]+0.5)
|
|
141
|
+
if zzmax < self.nodes[self.cells[i_cell,i_node],2]:
|
|
142
|
+
zzmax = <long> ceil(self.nodes[self.cells[i_cell,i_node],2]+0.5)
|
|
143
|
+
|
|
144
|
+
n_todo = (zzmax-zzmin) * (yymax-yymin) * (xxmax-xxmin)
|
|
145
|
+
to_do = <long*> malloc(n_todo * sizeof(long))
|
|
146
|
+
|
|
147
|
+
i_todo = 0
|
|
148
|
+
for zi in xrange(zzmin, zzmax):
|
|
149
|
+
for yi in xrange(yymin, yymax):
|
|
150
|
+
for xi in xrange(xxmin, xxmax):
|
|
151
|
+
to_do[i_todo] = (zi-self.startz)*self.dimx*self.dimy + (yi-self.starty)*self.dimx + (xi-self.startx)
|
|
152
|
+
i_todo += 1
|
|
153
|
+
|
|
154
|
+
if n_todo:
|
|
155
|
+
self.compute_thread(i_cell, to_do, n_todo)
|
|
156
|
+
|
|
157
|
+
free(to_do)
|
|
158
|
+
|
|
159
|
+
cdef void compute_ugrid_thread(self, long i_cell) noexcept nogil:
|
|
160
|
+
#
|
|
161
|
+
cdef double zzmin, zzmax, yymin, yymax, xxmin, xxmax
|
|
162
|
+
cdef long i_point
|
|
163
|
+
cdef long i_node = 0
|
|
164
|
+
cdef long n_todo, n_todo_max, i_todo
|
|
165
|
+
|
|
166
|
+
xxmin = self.nodes[self.cells[i_cell,i_node],0]
|
|
167
|
+
xxmax = self.nodes[self.cells[i_cell,i_node],0]
|
|
168
|
+
yymin = self.nodes[self.cells[i_cell,i_node],1]
|
|
169
|
+
yymax = self.nodes[self.cells[i_cell,i_node],1]
|
|
170
|
+
zzmin = self.nodes[self.cells[i_cell,i_node],2]
|
|
171
|
+
zzmax = self.nodes[self.cells[i_cell,i_node],2]
|
|
172
|
+
|
|
173
|
+
for i_node in xrange(1, self.n_nodes):
|
|
174
|
+
if xxmin > self.nodes[self.cells[i_cell,i_node],0]:
|
|
175
|
+
xxmin = self.nodes[self.cells[i_cell,i_node],0]
|
|
176
|
+
if xxmax < self.nodes[self.cells[i_cell,i_node],0]:
|
|
177
|
+
xxmax = self.nodes[self.cells[i_cell,i_node],0]
|
|
178
|
+
if yymin > self.nodes[self.cells[i_cell,i_node],1]:
|
|
179
|
+
yymin = self.nodes[self.cells[i_cell,i_node],1]
|
|
180
|
+
if yymax < self.nodes[self.cells[i_cell,i_node],1]:
|
|
181
|
+
yymax = self.nodes[self.cells[i_cell,i_node],1]
|
|
182
|
+
if zzmax < self.nodes[self.cells[i_cell,i_node],2]:
|
|
183
|
+
zzmax = self.nodes[self.cells[i_cell,i_node],2]
|
|
184
|
+
if zzmin > self.nodes[self.cells[i_cell,i_node],2]:
|
|
185
|
+
zzmin = self.nodes[self.cells[i_cell,i_node],2]
|
|
186
|
+
|
|
187
|
+
n_todo = 1000
|
|
188
|
+
to_do = <long*> malloc(n_todo * sizeof(long))
|
|
189
|
+
|
|
190
|
+
i_todo = 0
|
|
191
|
+
for i_point in xrange(self.n_points):
|
|
192
|
+
if ((self.points[i_point,0] >= xxmin) and (self.points[i_point,0] <= xxmax) and
|
|
193
|
+
(self.points[i_point,1] >= yymin) and (self.points[i_point,1] <= yymax) and
|
|
194
|
+
(self.points[i_point,2] >= zzmin) and (self.points[i_point,2] <= zzmax)):
|
|
195
|
+
to_do[i_todo] = i_point
|
|
196
|
+
i_todo += 1
|
|
197
|
+
if i_todo == n_todo:
|
|
198
|
+
n_todo += 1000
|
|
199
|
+
to_do = <long*> realloc(to_do, n_todo * sizeof(long))
|
|
200
|
+
|
|
201
|
+
n_todo = i_todo
|
|
202
|
+
to_do = <long*> realloc(to_do, n_todo * sizeof(long))
|
|
203
|
+
|
|
204
|
+
if n_todo:
|
|
205
|
+
self.compute_thread(i_cell, to_do, n_todo)
|
|
206
|
+
|
|
207
|
+
free(to_do)
|
|
208
|
+
|
|
209
|
+
cdef void compute_thread(self, long i_cell, long* to_do, long n_todo) noexcept nogil:
|
|
210
|
+
#
|
|
211
|
+
cdef long indni, i_node, i_point, i_todo
|
|
212
|
+
cdef double** g_points
|
|
213
|
+
|
|
214
|
+
if self.ndim == 2:
|
|
215
|
+
g_points = get_param_coordinate_2d(i_cell, to_do, n_todo, self.nodes, self.cells, self.n_nodes, self.N_data, self.dNdr_data, self.dNds_data, self.points, self.is_linear)
|
|
216
|
+
else:
|
|
217
|
+
g_points = get_param_coordinate_3d(i_cell, to_do, n_todo, self.nodes, self.cells, self.n_nodes, self.N_data, self.dNdr_data, self.dNds_data, self.dNdt_data, self.points, self.is_linear)
|
|
218
|
+
|
|
219
|
+
cdef double* N = <double*> malloc(self.n_nodes * sizeof(double))
|
|
220
|
+
|
|
221
|
+
for i_todo in xrange(n_todo):
|
|
222
|
+
if g_points[i_todo][0] != 2:
|
|
223
|
+
if self.ndim == 2:
|
|
224
|
+
N2D(N, g_points[i_todo], self.N_data, self.n_nodes)
|
|
225
|
+
else:
|
|
226
|
+
N3D(N, g_points[i_todo], self.N_data, self.n_nodes)
|
|
227
|
+
for i_node in xrange(self.n_nodes):
|
|
228
|
+
if N[i_node] < -self.EPSILON:
|
|
229
|
+
g_points[i_todo][0] = 2
|
|
230
|
+
break
|
|
231
|
+
if g_points[i_todo][0] == 2:
|
|
232
|
+
free(g_points[i_todo])
|
|
233
|
+
continue
|
|
234
|
+
i_point = to_do[i_todo]
|
|
235
|
+
omp_set_lock(&self.lock_done)
|
|
236
|
+
if self.done[i_point] > 0:
|
|
237
|
+
omp_unset_lock(&self.lock_done)
|
|
238
|
+
free(g_points[i_todo])
|
|
239
|
+
continue
|
|
240
|
+
else:
|
|
241
|
+
self.done[i_point] = 1+i_cell+self.iii
|
|
242
|
+
omp_unset_lock(&self.lock_done)
|
|
243
|
+
for i_node in xrange(self.n_nodes):
|
|
244
|
+
omp_set_lock(&self.lock)
|
|
245
|
+
indni = self.indni
|
|
246
|
+
self.indni += 1
|
|
247
|
+
omp_unset_lock(&self.lock)
|
|
248
|
+
self.indp[indni] = i_point
|
|
249
|
+
self.indn[indni] = self.cells[i_cell,i_node]
|
|
250
|
+
self.val[indni] = N[i_node]
|
|
251
|
+
free(g_points[i_todo])
|
|
252
|
+
free(g_points)
|
|
253
|
+
free(N)
|
|
254
|
+
|
|
255
|
+
cdef double** get_param_coordinate_2d(long i_cell, long* to_do, long n_todo, double[:,:] nodes, long[:,:] cells, int n_nodes, double[:,:] N_data, double[:,:] dNdr_data, double[:,:] dNds_data, double[:,:] points, bint is_linear) noexcept nogil:
|
|
256
|
+
#
|
|
257
|
+
cdef double res, dxg, dyg, detJ, dxdr, dydr, dxds, dyds, xpix_xp, ypix_yp, invJ0, invJ1, invJ2, invJ3, idetJ
|
|
258
|
+
|
|
259
|
+
cdef long niter, i_todo, i_node
|
|
260
|
+
|
|
261
|
+
cdef double* N = <double*> malloc(n_nodes * sizeof(double))
|
|
262
|
+
cdef double* dNdr = <double*> malloc(n_nodes * sizeof(double))
|
|
263
|
+
cdef double* dNds = <double*> malloc(n_nodes * sizeof(double))
|
|
264
|
+
cdef double** g_points = <double**> malloc(n_todo * sizeof(double*))
|
|
265
|
+
|
|
266
|
+
for i_todo in xrange(n_todo):
|
|
267
|
+
|
|
268
|
+
g_points[i_todo] = <double*> malloc(2 * sizeof(double))
|
|
269
|
+
|
|
270
|
+
res = 1
|
|
271
|
+
niter = 0
|
|
272
|
+
detJ = 1
|
|
273
|
+
|
|
274
|
+
g_points[i_todo][0] = 0
|
|
275
|
+
g_points[i_todo][1] = 0
|
|
276
|
+
|
|
277
|
+
while res > 1e-12 and detJ > 0 and niter < 1000:
|
|
278
|
+
|
|
279
|
+
niter += 1
|
|
280
|
+
|
|
281
|
+
N2D(N, g_points[i_todo], N_data, n_nodes)
|
|
282
|
+
N2D(dNdr, g_points[i_todo], dNdr_data, n_nodes)
|
|
283
|
+
N2D(dNds, g_points[i_todo], dNds_data, n_nodes)
|
|
284
|
+
|
|
285
|
+
dxdr = 0
|
|
286
|
+
dydr = 0
|
|
287
|
+
dxds = 0
|
|
288
|
+
dyds = 0
|
|
289
|
+
|
|
290
|
+
for i_node in xrange(n_nodes):
|
|
291
|
+
dxdr += dNdr[i_node]*nodes[cells[i_cell,i_node],0]
|
|
292
|
+
dydr += dNdr[i_node]*nodes[cells[i_cell,i_node],1]
|
|
293
|
+
dxds += dNds[i_node]*nodes[cells[i_cell,i_node],0]
|
|
294
|
+
dyds += dNds[i_node]*nodes[cells[i_cell,i_node],1]
|
|
295
|
+
|
|
296
|
+
detJ = dxdr*dyds - dydr*dxds
|
|
297
|
+
|
|
298
|
+
if detJ > 0:
|
|
299
|
+
|
|
300
|
+
idetJ = 1/detJ
|
|
301
|
+
|
|
302
|
+
invJ0 = dyds
|
|
303
|
+
invJ1 = -dxds
|
|
304
|
+
invJ2 = -dydr
|
|
305
|
+
invJ3 = dxdr
|
|
306
|
+
|
|
307
|
+
xpix_xp = points[to_do[i_todo],0]
|
|
308
|
+
ypix_yp = points[to_do[i_todo],1]
|
|
309
|
+
|
|
310
|
+
for i_node in xrange(n_nodes):
|
|
311
|
+
xpix_xp -= N[i_node]*nodes[cells[i_cell,i_node],0]
|
|
312
|
+
ypix_yp -= N[i_node]*nodes[cells[i_cell,i_node],1]
|
|
313
|
+
|
|
314
|
+
dxg = (invJ0*(xpix_xp)+invJ1*(ypix_yp))*idetJ
|
|
315
|
+
dyg = (invJ2*(xpix_xp)+invJ3*(ypix_yp))*idetJ
|
|
316
|
+
res = dxg*dxg + dyg*dyg
|
|
317
|
+
|
|
318
|
+
g_points[i_todo][0] += dxg
|
|
319
|
+
g_points[i_todo][1] += dyg
|
|
320
|
+
|
|
321
|
+
else:
|
|
322
|
+
g_points[i_todo][0] = 2
|
|
323
|
+
g_points[i_todo][1] = 2
|
|
324
|
+
|
|
325
|
+
if is_linear:
|
|
326
|
+
break
|
|
327
|
+
|
|
328
|
+
free(N)
|
|
329
|
+
free(dNdr)
|
|
330
|
+
free(dNds)
|
|
331
|
+
|
|
332
|
+
return g_points
|
|
333
|
+
|
|
334
|
+
cdef double** get_param_coordinate_3d(long i_cell, long* to_do, long n_todo, double[:,:] nodes, long[:,:] cells, int n_nodes, double[:,:] N_data, double[:,:] dNdr_data, double[:,:] dNds_data, double[:,:] dNdt_data, double[:,:] points, bint is_linear) noexcept nogil:
|
|
335
|
+
#
|
|
336
|
+
cdef double res, dxg, dyg, detJ, dxdr, dydr, dxds, dyds, xpix_xp, ypix_yp, invJ0, invJ1, invJ2, invJ3, idetJ
|
|
337
|
+
cdef double dzg, dzdr, dzds, dxdt, dydt, dzdt, zpix_zp, invJ4, invJ5, invJ6, invJ7, invJ8
|
|
338
|
+
|
|
339
|
+
cdef long niter, i_todo, i_node
|
|
340
|
+
|
|
341
|
+
cdef double* N = <double*> malloc(n_nodes * sizeof(double))
|
|
342
|
+
cdef double* dNdr = <double*> malloc(n_nodes * sizeof(double))
|
|
343
|
+
cdef double* dNds = <double*> malloc(n_nodes * sizeof(double))
|
|
344
|
+
cdef double* dNdt = <double*> malloc(n_nodes * sizeof(double))
|
|
345
|
+
cdef double** g_points = <double**> malloc(n_todo * sizeof(double*))
|
|
346
|
+
|
|
347
|
+
for i_todo in xrange(n_todo):
|
|
348
|
+
|
|
349
|
+
g_points[i_todo] = <double*> malloc(3 * sizeof(double))
|
|
350
|
+
|
|
351
|
+
res = 1
|
|
352
|
+
niter = 0
|
|
353
|
+
detJ = 1
|
|
354
|
+
|
|
355
|
+
g_points[i_todo][0] = 0
|
|
356
|
+
g_points[i_todo][1] = 0
|
|
357
|
+
g_points[i_todo][2] = 0
|
|
358
|
+
|
|
359
|
+
while res > 1e-12 and detJ > 0 and niter < 1000:
|
|
360
|
+
|
|
361
|
+
niter += 1
|
|
362
|
+
|
|
363
|
+
N3D(N, g_points[i_todo], N_data, n_nodes)
|
|
364
|
+
N3D(dNdr, g_points[i_todo], dNdr_data, n_nodes)
|
|
365
|
+
N3D(dNds, g_points[i_todo], dNds_data, n_nodes)
|
|
366
|
+
N3D(dNdt, g_points[i_todo], dNdt_data, n_nodes)
|
|
367
|
+
|
|
368
|
+
dxdr = 0
|
|
369
|
+
dydr = 0
|
|
370
|
+
dxds = 0
|
|
371
|
+
dyds = 0
|
|
372
|
+
dxdt = 0
|
|
373
|
+
dydt = 0
|
|
374
|
+
dzdr = 0
|
|
375
|
+
dzds = 0
|
|
376
|
+
dzdt = 0
|
|
377
|
+
|
|
378
|
+
for i_node in xrange(n_nodes):
|
|
379
|
+
dxdr += dNdr[i_node]*nodes[cells[i_cell,i_node],0]
|
|
380
|
+
dxds += dNds[i_node]*nodes[cells[i_cell,i_node],0]
|
|
381
|
+
dxdt += dNdt[i_node]*nodes[cells[i_cell,i_node],0]
|
|
382
|
+
dydr += dNdr[i_node]*nodes[cells[i_cell,i_node],1]
|
|
383
|
+
dyds += dNds[i_node]*nodes[cells[i_cell,i_node],1]
|
|
384
|
+
dydt += dNdt[i_node]*nodes[cells[i_cell,i_node],1]
|
|
385
|
+
dzdr += dNdr[i_node]*nodes[cells[i_cell,i_node],2]
|
|
386
|
+
dzds += dNds[i_node]*nodes[cells[i_cell,i_node],2]
|
|
387
|
+
dzdt += dNdt[i_node]*nodes[cells[i_cell,i_node],2]
|
|
388
|
+
|
|
389
|
+
detJ = (dxdr*dyds*dzdt +
|
|
390
|
+
dxdt*dydr*dzds +
|
|
391
|
+
dxds*dydt*dzdr -
|
|
392
|
+
dxdt*dyds*dzdr -
|
|
393
|
+
dxdr*dydt*dzds -
|
|
394
|
+
dxds*dydr*dzdt)
|
|
395
|
+
|
|
396
|
+
if detJ > 0:
|
|
397
|
+
idetJ = 1./detJ
|
|
398
|
+
|
|
399
|
+
invJ0 = (dyds*dzdt - dydt*dzds)
|
|
400
|
+
invJ1 = -(dxds*dzdt - dxdt*dzds)
|
|
401
|
+
invJ2 = (dxds*dydt - dxdt*dyds)
|
|
402
|
+
invJ3 = -(dydr*dzdt - dydt*dzdr)
|
|
403
|
+
invJ4 = (dxdr*dzdt - dxdt*dzdr)
|
|
404
|
+
invJ5 = -(dxdr*dydt - dxdt*dydr)
|
|
405
|
+
invJ6 = (dydr*dzds - dyds*dzdr)
|
|
406
|
+
invJ7 = -(dxdr*dzds - dxds*dzdr)
|
|
407
|
+
invJ8 = (dxdr*dyds - dxds*dydr)
|
|
408
|
+
|
|
409
|
+
xpix_xp = points[to_do[i_todo],0]
|
|
410
|
+
ypix_yp = points[to_do[i_todo],1]
|
|
411
|
+
zpix_zp = points[to_do[i_todo],2]
|
|
412
|
+
|
|
413
|
+
for i_node in xrange(n_nodes):
|
|
414
|
+
xpix_xp -= N[i_node]*nodes[cells[i_cell,i_node],0]
|
|
415
|
+
ypix_yp -= N[i_node]*nodes[cells[i_cell,i_node],1]
|
|
416
|
+
zpix_zp -= N[i_node]*nodes[cells[i_cell,i_node],2]
|
|
417
|
+
|
|
418
|
+
dxg = (invJ0*(xpix_xp)+invJ1*(ypix_yp)+invJ2*(zpix_zp))*idetJ
|
|
419
|
+
dyg = (invJ3*(xpix_xp)+invJ4*(ypix_yp)+invJ5*(zpix_zp))*idetJ
|
|
420
|
+
dzg = (invJ6*(xpix_xp)+invJ7*(ypix_yp)+invJ8*(zpix_zp))*idetJ
|
|
421
|
+
res = dxg*dxg + dyg*dyg + dzg*dzg
|
|
422
|
+
|
|
423
|
+
g_points[i_todo][0] += dxg
|
|
424
|
+
g_points[i_todo][1] += dyg
|
|
425
|
+
g_points[i_todo][2] += dzg
|
|
426
|
+
|
|
427
|
+
else:
|
|
428
|
+
g_points[i_todo][0] = 2
|
|
429
|
+
g_points[i_todo][1] = 2
|
|
430
|
+
g_points[i_todo][2] = 2
|
|
431
|
+
|
|
432
|
+
if is_linear:
|
|
433
|
+
break
|
|
434
|
+
|
|
435
|
+
free(N)
|
|
436
|
+
free(dNdr)
|
|
437
|
+
free(dNds)
|
|
438
|
+
free(dNdt)
|
|
439
|
+
|
|
440
|
+
return g_points
|
|
441
|
+
|
|
442
|
+
cdef void N2D(double* result, double* g_point, double[:,:] N_data, int n_nodes) noexcept nogil:
|
|
443
|
+
cdef int i_node
|
|
444
|
+
for i_node in xrange(n_nodes):
|
|
445
|
+
result[i_node] = (
|
|
446
|
+
N_data[i_node,0b00] +
|
|
447
|
+
N_data[i_node,0b01]*g_point[1] +
|
|
448
|
+
N_data[i_node,0b10]*g_point[0] +
|
|
449
|
+
N_data[i_node,0b11]*g_point[0]*g_point[1]
|
|
450
|
+
)
|
|
451
|
+
|
|
452
|
+
cdef void N3D(double* result, double* g_point, double[:,:] N_data, int n_nodes) noexcept nogil:
|
|
453
|
+
cdef int i_node
|
|
454
|
+
for i_node in xrange(n_nodes):
|
|
455
|
+
result[i_node] = (
|
|
456
|
+
N_data[i_node,0b000] +
|
|
457
|
+
N_data[i_node,0b001]*g_point[2] +
|
|
458
|
+
N_data[i_node,0b010]*g_point[1] +
|
|
459
|
+
N_data[i_node,0b011]*g_point[1]*g_point[2] +
|
|
460
|
+
N_data[i_node,0b100]*g_point[0] +
|
|
461
|
+
N_data[i_node,0b101]*g_point[0]*g_point[2] +
|
|
462
|
+
N_data[i_node,0b110]*g_point[0]*g_point[1] +
|
|
463
|
+
N_data[i_node,0b111]*g_point[0]*g_point[1]*g_point[2]
|
|
464
|
+
)
|
|
465
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# cython: boundscheck=False, cdivision=True, wraparound=False, initializedcheck=False
|
|
3
|
+
import numpy as np
|
|
4
|
+
from cython.parallel import prange
|
|
5
|
+
from scipy import sparse
|
|
6
|
+
from multiprocessing import cpu_count
|
|
7
|
+
|
|
8
|
+
cdef int ncpu = cpu_count()
|
|
9
|
+
|
|
10
|
+
def spmul(sp, d):
|
|
11
|
+
result = np.zeros(sp.data.shape[0], dtype='f4')
|
|
12
|
+
spmul_core(sp.indices, sp.data, d, result)
|
|
13
|
+
return sparse.csc_matrix((result, sp.indices, sp.indptr), shape=sp.shape)
|
|
14
|
+
|
|
15
|
+
def spmul_core(int[:] indices, float[:] data, float[:] vdata, float[:] result_view):
|
|
16
|
+
cdef int i
|
|
17
|
+
for i in prange(result_view.shape[0], nogil=True, num_threads=ncpu):
|
|
18
|
+
result_view[i] = data[i]*vdata[indices[i]]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["poetry-core", "setuptools", "Cython"]
|
|
3
|
+
build-backend = "poetry.core.masonry.api"
|
|
4
|
+
|
|
5
|
+
[tool.poetry]
|
|
6
|
+
name = "pyfedic_cython"
|
|
7
|
+
version = "23.9.0"
|
|
8
|
+
description = "Digital Image (2D/3D) Correlation Software - CYTHON module"
|
|
9
|
+
authors = ["Joël Lachambre <joel.lachambre@cnrs.fr>"]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license = "CECILL-2.1"
|
|
12
|
+
homepage = "https://sourcesup.renater.fr/www/pyfedic/"
|
|
13
|
+
documentation = "https://sourcesup.renater.fr/www/pyfedic/html"
|
|
14
|
+
classifiers = [
|
|
15
|
+
'Intended Audience :: Developers',
|
|
16
|
+
'Intended Audience :: Science/Research',
|
|
17
|
+
'Topic :: Scientific/Engineering',
|
|
18
|
+
'Topic :: Software Development :: Libraries :: Python Modules',
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[tool.poetry.build]
|
|
23
|
+
generate-setup-file = true
|
|
24
|
+
script = "build.py"
|
|
25
|
+
|
|
26
|
+
[tool.poetry.dependencies]
|
|
27
|
+
python = ">=3.10,<3.12"
|
|
28
|
+
pyfedic = "^23.9.0"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from setuptools import setup
|
|
3
|
+
|
|
4
|
+
packages = \
|
|
5
|
+
['pyfedic_cython']
|
|
6
|
+
|
|
7
|
+
package_data = \
|
|
8
|
+
{'': ['*']}
|
|
9
|
+
|
|
10
|
+
install_requires = \
|
|
11
|
+
['pyfedic>=23.9.0,<24.0.0']
|
|
12
|
+
|
|
13
|
+
setup_kwargs = {
|
|
14
|
+
'name': 'pyfedic_cython',
|
|
15
|
+
'version': '23.9.0',
|
|
16
|
+
'description': 'Digital Image (2D/3D) Correlation Software - CYTHON module',
|
|
17
|
+
'long_description': '# pyFEDIC : Digital Image (2D/3D) Correlation Software\n\npyFEDIC is a DIC software using global approach with finite element shape functions to describe the displacement field. It allows to perform 2D DIC and 3D DIC also called DVC (V stand for volume).\n\nThis software is a pure python library and offer a simple command line to run analysis with a few parameters as input.\n\nIt can be directly installed using pip:\n\n```console\n$ pip install pyfedic\n```\n\nFor more information, visit https://sourcesup.renater.fr/www/pyfedic/html/index.html\n\n\n[](https://doi.org/10.5281/zenodo.8298430)\n\n',
|
|
18
|
+
'author': 'Joël Lachambre',
|
|
19
|
+
'author_email': 'joel.lachambre@cnrs.fr',
|
|
20
|
+
'maintainer': 'None',
|
|
21
|
+
'maintainer_email': 'None',
|
|
22
|
+
'url': 'https://sourcesup.renater.fr/www/pyfedic/',
|
|
23
|
+
'packages': packages,
|
|
24
|
+
'package_data': package_data,
|
|
25
|
+
'install_requires': install_requires,
|
|
26
|
+
'python_requires': '>=3.10,<3.12',
|
|
27
|
+
}
|
|
28
|
+
from build import *
|
|
29
|
+
build(setup_kwargs)
|
|
30
|
+
|
|
31
|
+
setup(**setup_kwargs)
|