diff --git a/Cassiopee/Transform/Transform/Fortran/HomothetyF.for b/Cassiopee/Transform/Transform/Fortran/HomothetyF.for deleted file mode 100755 index e35fa0648..000000000 --- a/Cassiopee/Transform/Transform/Fortran/HomothetyF.for +++ /dev/null @@ -1,53 +0,0 @@ -C -C Copyright 2013-2024 Onera. -C -C This file is part of Cassiopee. -C -C Cassiopee is free software: you can redistribute it and/or modify -C it under the terms of the GNU General Public License as published by -C the Free Software Foundation, either version 3 of the License, or -C (at your option) any later version. -C -C Cassiopee is distributed in the hope that it will be useful, -C but WITHOUT ANY WARRANTY; without even the implied warranty of -C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -C GNU General Public License for more details. -C -C You should have received a copy of the GNU General Public License -C along with Cassiopee. If not, see . -C ============================================================================ - SUBROUTINE k6homothety( npts, x, y, z, - & xc, yc, zc, - & alpha, - & xo, yo, zo) -C - IMPLICIT NONE -C============================================================================== -C_IN - INTEGER_E npts ! mesh size - REAL_E x(1:npts) ! mesh coordinates - REAL_E y(1:npts) - REAL_E z(1:npts) - REAL_E xc,yc,zc ! center of homothety - REAL_E alpha ! factor -C_OUT - REAL_E xo(1:npts) ! rotated mesh - REAL_E yo(1:npts) - REAL_E zo(1:npts) -C_LOCAL - INTEGER_E ind - REAL_E rx, ry, rz -C============================================================================== -!$OMP PARALLEL PRIVATE(ind, rx, ry, rz) -!$OMP DO - DO ind = 1, npts - rx = x(ind)-xc - ry = y(ind)-yc - rz = z(ind)-zc - xo(ind) = xc + alpha*rx - yo(ind) = yc + alpha*ry - zo(ind) = zc + alpha*rz - ENDDO -!$OMP END DO -!$OMP END PARALLEL - END diff --git a/Cassiopee/Transform/Transform/Fortran/RotateF.for b/Cassiopee/Transform/Transform/Fortran/RotateF.for deleted file mode 100755 index dc11bfcce..000000000 --- a/Cassiopee/Transform/Transform/Fortran/RotateF.for +++ /dev/null @@ -1,84 +0,0 @@ -C -C Copyright 2013-2024 Onera. -C -C This file is part of Cassiopee. -C -C Cassiopee is free software: you can redistribute it and/or modify -C it under the terms of the GNU General Public License as published by -C the Free Software Foundation, either version 3 of the License, or -C (at your option) any later version. -C -C Cassiopee is distributed in the hope that it will be useful, -C but WITHOUT ANY WARRANTY; without even the implied warranty of -C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -C GNU General Public License for more details. -C -C You should have received a copy of the GNU General Public License -C along with Cassiopee. If not, see . -C ============================================================================ - SUBROUTINE k6rotate(npts, x, y, z, - & xc, yc, zc, nx, ny, nz, - & teta, - & xo, yo, zo) -C - IMPLICIT NONE -C============================================================================== -C_IN - INTEGER_E npts ! mesh size - REAL_E x(1:npts) ! mesh coordinates - REAL_E y(1:npts) - REAL_E z(1:npts) - REAL_E xc,yc,zc ! center of rotation - REAL_E nx,ny,nz ! rotation vector - REAL_E teta ! angle -C_OUT - REAL_E xo(1:npts) ! rotated mesh - REAL_E yo(1:npts) - REAL_E zo(1:npts) -C_LOCAL - INTEGER_E ind - REAL_E unx, uny, unz - REAL_E norm - REAL_E px, py, pz - REAL_E rx, ry, rz - REAL_E e0, e1, e2, e3 - REAL_E a1, a2, sinteta, sinteta5 -C============================================================================== -C nx,ny,nz must be unit vector - norm = nx*nx+ny*ny+nz*nz - IF (norm.LE.1.e-12) THEN - WRITE(*,*) 'Error: rotate: nx,ny,nz has null norm.' - RETURN - ENDIF - - norm = 1.D0/SQRT(norm) - unx = nx*norm - uny = ny*norm - unz = nz*norm - - sinteta = sin(teta) - sinteta5 = sin(teta*0.5D0) -C quaternion - e0 = cos(teta*0.5D0) - e1 = -unx*sinteta5 - e2 = -uny*sinteta5 - e3 = -unz*sinteta5 - a1 = e0*e0-e1*e1-e2*e2-e3*e3 - -!$OMP PARALLEL PRIVATE(ind, rx, ry, rz, a2, px, py, pz) -!$OMP DO - DO ind = 1, npts - rx = x(ind)-xc - ry = y(ind)-yc - rz = z(ind)-zc - a2 = e1*rx+e2*ry+e3*rz - px = a1*rx+2*e1*a2-(ry*unz-rz*uny)*sinteta - py = a1*ry+2*e2*a2-(rz*unx-rx*unz)*sinteta - pz = a1*rz+2*e3*a2-(rx*uny-ry*unx)*sinteta - xo(ind) = xc+px - yo(ind) = yc+py - zo(ind) = zc+pz - ENDDO -!$OMP END DO -!$OMP END PARALLEL - END diff --git a/Cassiopee/Transform/Transform/Fortran/TranslateF.for b/Cassiopee/Transform/Transform/Fortran/TranslateF.for deleted file mode 100755 index 68e5b34e1..000000000 --- a/Cassiopee/Transform/Transform/Fortran/TranslateF.for +++ /dev/null @@ -1,54 +0,0 @@ -C -C Copyright 2013-2024 Onera. -C -C This file is part of Cassiopee. -C -C Cassiopee is free software: you can redistribute it and/or modify -C it under the terms of the GNU General Public License as published by -C the Free Software Foundation, either version 3 of the License, or -C (at your option) any later version. -C -C Cassiopee is distributed in the hope that it will be useful, -C but WITHOUT ANY WARRANTY; without even the implied warranty of -C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -C GNU General Public License for more details. -C -C You should have received a copy of the GNU General Public License -C along with Cassiopee. If not, see . -C ============================================================================ - SUBROUTINE k6translate(npts, x, y, z, - & v1,v2,v3, - & xo, yo, zo) -C - IMPLICIT NONE -C============================================================================== -C_IN - INTEGER_E npts ! mesh size - REAL_E x(1:npts) ! mesh coordinates - REAL_E y(1:npts) - REAL_E z(1:npts) - REAL_E v1,v2,v3 ! translation vector -C_OUT - REAL_E xo(1:npts) ! translated mesh - REAL_E yo(1:npts) - REAL_E zo(1:npts) -C_LOCAL - INTEGER_E ind -C============================================================================== -!$OMP PARALLEL PRIVATE(ind) -!$OMP DO - DO ind = 1, npts - xo(ind) = x(ind)+v1 - yo(ind) = y(ind)+v2 - zo(ind) = z(ind)+v3 - ENDDO -!$OMP END DO -!$OMP END PARALLEL - END - - - - - - - diff --git a/Cassiopee/Transform/Transform/coordTransform.cpp b/Cassiopee/Transform/Transform/coordTransform.cpp index 020deb89b..c4c3d22dc 100644 --- a/Cassiopee/Transform/Transform/coordTransform.cpp +++ b/Cassiopee/Transform/Transform/coordTransform.cpp @@ -39,56 +39,6 @@ extern "C" const E_Int& ni, const E_Int& nj, const E_Int& nk, E_Float* x, E_Float* y, E_Float* z); } -// ============================================================================ -/* Homothety from an array describing a mesh */ -// ============================================================================ -PyObject* K_TRANSFORM::homothety(PyObject* self, PyObject* args) -{ - E_Float xc, yc, zc; - E_Float alpha; - PyObject* array; - if (!PYPARSETUPLE_(args, O_ TRRR_ R_, - &array, &xc, &yc, &zc, &alpha)) - { - return NULL; - } - - // Check array - E_Int nil, njl, nkl; - FldArrayF* f; FldArrayI* cn; - char* varString; char* eltType; - E_Int res = - K_ARRAY::getFromArray3(array, varString, f, nil, njl, nkl, cn, eltType); - - if (res != 1 && res != 2) - { - PyErr_SetString(PyExc_TypeError, - "homothety: not a valid array."); - return NULL; - } - - E_Int posx = K_ARRAY::isCoordinateXPresent(varString); - E_Int posy = K_ARRAY::isCoordinateYPresent(varString); - E_Int posz = K_ARRAY::isCoordinateZPresent(varString); - if (posx == -1 || posy == -1 || posz == -1) - { - RELEASESHAREDB(res, array, f, cn); - PyErr_SetString(PyExc_TypeError, - "homothety: can't find coordinates in array."); - return NULL; - } - posx++; posy++; posz++; - - E_Int npts = f->getSize(); - // Homothety - k6homothety_(npts, - f->begin(posx), f->begin(posy), f->begin(posz), - xc, yc, zc, alpha, - f->begin(posx), f->begin(posy), f->begin(posz)); - RELEASESHAREDB(res, array, f, cn); - Py_INCREF(Py_None); - return Py_None; -} // ============================================================================ /* Contract python array describing a mesh */ diff --git a/Cassiopee/Transform/Transform/homothety.cpp b/Cassiopee/Transform/Transform/homothety.cpp new file mode 100644 index 000000000..3c10a780a --- /dev/null +++ b/Cassiopee/Transform/Transform/homothety.cpp @@ -0,0 +1,85 @@ +/* + Copyright 2013-2024 Onera. + + This file is part of Cassiopee. + + Cassiopee is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Cassiopee is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Cassiopee. If not, see . +*/ + +# include "transform.h" + +using namespace std; +using namespace K_FUNC; +using namespace K_FLD; + +// ============================================================================ +// Homothety array2/3 - in place +//============================================================================= +PyObject* K_TRANSFORM::homothety(PyObject* self, PyObject* args) +{ + E_Float xc, yc, zc, alpha; + PyObject* array; + if (!PYPARSETUPLE_(args, O_ TRRR_ R_, + &array, &xc, &yc, &zc, &alpha)) + return NULL; + + // Check array + E_Int nil, njl, nkl; + FldArrayF* f; FldArrayI* cn; + char* varString; char* eltType; + E_Int res = K_ARRAY::getFromArray3(array, varString, f, nil, njl, nkl, + cn, eltType); + + if (res != 1 && res != 2) + { + PyErr_SetString(PyExc_TypeError, + "homothety: invalid array."); + return NULL; + } + E_Int posx = K_ARRAY::isCoordinateXPresent(varString); + E_Int posy = K_ARRAY::isCoordinateYPresent(varString); + E_Int posz = K_ARRAY::isCoordinateZPresent(varString); + + if (posx == -1 || posy == -1 || posz == -1) + { + RELEASESHAREDB(res, array, f, cn); + PyErr_SetString(PyExc_TypeError, + "homothety: can't find coordinates in array."); + return NULL; + } + posx++; posy++; posz++; + E_Int npts = f->getSize(); + E_Float* xt = f->begin(posx); + E_Float* yt = f->begin(posy); + E_Float* zt = f->begin(posz); + + #pragma omp parallel default(shared) + { + E_Float rx, ry, rz; +#pragma omp for + for (E_Int ind = 0; ind < npts; ind++) + { + rx = xt[ind]-xc; + ry = yt[ind]-yc; + rz = zt[ind]-zc; + xt[ind] = xc + alpha*rx; + yt[ind] = yc + alpha*ry; + zt[ind] = zc + alpha*rz; + } + } + + RELEASESHAREDB(res, array, f, cn); + Py_INCREF(Py_None); + return Py_None; +} diff --git a/Cassiopee/Transform/Transform/rotate.cpp b/Cassiopee/Transform/Transform/rotate.cpp deleted file mode 100644 index 7824a9269..000000000 --- a/Cassiopee/Transform/Transform/rotate.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/* - Copyright 2013-2024 Onera. - - This file is part of Cassiopee. - - Cassiopee is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Cassiopee is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Cassiopee. If not, see . -*/ - -// Rotate functions - code obsolete -> voir rotate2 -# include "transform.h" - -using namespace std; -using namespace K_FUNC; -using namespace K_FLD; - -extern "C" -{ - void k6rotate_(const E_Int& npts, - const E_Float* x, const E_Float* y, const E_Float* z, - const E_Float& xc, const E_Float& yc, const E_Float& zc, - const E_Float& nx, const E_Float& ny, const E_Float& nz, - const E_Float& teta, - E_Float* xo, E_Float* yo, E_Float* zo); -} - -// ============================================================================ -/* Rotate an array describing a mesh */ -// ============================================================================ -PyObject* K_TRANSFORM::rotateA1(PyObject* self, PyObject* args) -{ - PyObject* array; - PyObject* listOfFieldVectors; - E_Float xc, yc, zc; - E_Float nx, ny, nz, teta; - if (!PYPARSETUPLE_(args, O_ TRRR_ TRRR_ R_ O_, - &array, &xc, &yc, &zc, &nx, &ny, &nz, &teta, &listOfFieldVectors)) - { - return NULL; - } - - // Check array - E_Int nil, njl, nkl; - FldArrayF* f; FldArrayI* cn; - char* varString; char* eltType; - E_Int res; - - // Preliminary check - if (K_FUNC::fEqualZero(nx) == true && - K_FUNC::fEqualZero(ny) == true && - K_FUNC::fEqualZero(nz) == true) - { - PyErr_SetString(PyExc_ValueError, - "rotate: vector has null norm."); - return NULL; - } - - res = K_ARRAY::getFromArray(array, varString, f, nil, njl, nkl, - cn, eltType, true); - - if (res != 1 && res != 2) - { - PyErr_SetString(PyExc_TypeError, - "rotate: invalid array."); - return NULL; - } - - E_Int posx = K_ARRAY::isCoordinateXPresent(varString); - E_Int posy = K_ARRAY::isCoordinateYPresent(varString); - E_Int posz = K_ARRAY::isCoordinateZPresent(varString); - posx++; posy++; posz++; - vector posvx; vector posvy; vector posvz; - E_Int ok = extractVectorComponents(varString, listOfFieldVectors, posvx, posvy, posvz); - if (ok == -1) - { - RELEASESHAREDB(res, array, f, cn); - return NULL; - } - - // Transformation en radians - E_Float pi = 4*atan(1.); - teta = teta*pi/180.; - - E_Int npts = f->getSize(); - E_Int nfld = f->getNfld(); - - // Construit l'array resultat et l'initialise par copie - PyObject* tpl; - if (res == 1) //structured - { - tpl = K_ARRAY::buildArray(nfld, varString, - nil, njl, nkl); - } - else //unstructured - { - E_Int csize = cn->getSize()*cn->getNfld(); - tpl = K_ARRAY::buildArray(nfld, varString, - npts, cn->getSize(), - -1, eltType, false, csize); - } - E_Float* fnp = K_ARRAY::getFieldPtr(tpl); - FldArrayF fn(npts, nfld, fnp, true); - fn.setAllValuesAt(*f); - - if (res == 2) - { - E_Int* cnnp = K_ARRAY::getConnectPtr(tpl); - K_KCORE::memcpy__(cnnp, cn->begin(), cn->getSize()*cn->getNfld()); - } - - // rotate - E_Int nvect = posvx.size(); - if (posx>0 && posy>0 && posz>0) //coord + champs - { - k6rotate_(npts, f->begin(posx), f->begin(posy), f->begin(posz), - xc, yc, zc, nx, ny, nz, teta, - fn.begin(posx), fn.begin(posy), fn.begin(posz)); - } - for (E_Int nov = 0; nov < nvect; nov++) - { - posx = posvx[nov]; posy = posvy[nov]; posz = posvz[nov]; - k6rotate_(npts, f->begin(posx), f->begin(posy), f->begin(posz), - 0., 0., 0., nx, ny, nz, teta, - fn.begin(posx), fn.begin(posy), fn.begin(posz)); - } - - RELEASESHAREDB(res, array, f, cn); - return tpl; -} - -// ============================================================================ -/* Rotate an array describing a mesh, input is two frames */ -// ============================================================================ -PyObject* K_TRANSFORM::rotateA2(PyObject* self, PyObject* args) -{ - PyObject* array; - E_Float xc, yc, zc; - E_Float e1x, e1y, e1z, e2x, e2y, e2z, e3x, e3y, e3z; - E_Float f1x, f1y, f1z, f2x, f2y, f2z, f3x, f3y, f3z; - PyObject* listOfFieldVectors; - - if (!PYPARSETUPLE_(args, O_ TRRR_ "(" TRRR_ TRRR_ TRRR_ ")" "(" TRRR_ TRRR_ TRRR_ ")" O_, - &array, - &xc, &yc, &zc, - &e1x, &e1y, &e1z, - &e2x, &e2y, &e2z, - &e3x, &e3y, &e3z, - &f1x, &f1y, &f1z, - &f2x, &f2y, &f2z, - &f3x, &f3y, &f3z, - &listOfFieldVectors)) - { - return NULL; - } - - // Check array - E_Int nil, njl, nkl; - FldArrayF* f; FldArrayI* cn; - char* varString; char* eltType; - E_Int res; - - // Make unity - E_Float e1 = sqrt(e1x*e1x+e1y*e1y+e1z*e1z); - E_Float e2 = sqrt(e2x*e2x+e2y*e2y+e2z*e2z); - E_Float e3 = sqrt(e3x*e3x+e3y*e3y+e3z*e3z); - E_Float f1 = sqrt(f1x*f1x+f1y*f1y+f1z*f1z); - E_Float f2 = sqrt(f2x*f2x+f2y*f2y+f2z*f2z); - E_Float f3 = sqrt(f3x*f3x+f3y*f3y+f3z*f3z); - - if (K_FUNC::fEqualZero(e1) == true || - K_FUNC::fEqualZero(e2) == true || - K_FUNC::fEqualZero(e3) == true || - K_FUNC::fEqualZero(f1) == true || - K_FUNC::fEqualZero(f2) == true || - K_FUNC::fEqualZero(f3) == true) - { - PyErr_SetString(PyExc_ValueError, - "rotate: frame vectors must have non null norm."); - return NULL; - } - - e1 = 1./e1; e2 = 1./e2; e3 = 1./e3; - f1 = 1./f1; f2 = 1./f2; f3 = 1./f3; - e1x = e1x * e1; e1y = e1y * e1; e1z = e1z * e1; - e2x = e2x * e2; e2y = e2y * e2; e2z = e2z * e2; - e3x = e3x * e3; e3y = e3y * e3; e3z = e3z * e3; - f1x = f1x * f1; f1y = f1y * f1; f1z = f1z * f1; - f2x = f2x * f2; f2y = f2y * f2; f2z = f2z * f2; - f3x = f3x * f3; f3y = f3y * f3; f3z = f3z * f3; - - res = K_ARRAY::getFromArray(array, varString, f, nil, njl, nkl, - cn, eltType, true); - - if (res != 1 && res != 2) - { - PyErr_SetString(PyExc_TypeError, - "rotate: invalid array."); - return NULL; - } - E_Int posx = K_ARRAY::isCoordinateXPresent(varString); - E_Int posy = K_ARRAY::isCoordinateYPresent(varString); - E_Int posz = K_ARRAY::isCoordinateZPresent(varString); - posx++; posy++; posz++; - vector posvx; vector posvy; vector posvz; - E_Int ok = extractVectorComponents(varString, listOfFieldVectors, posvx, posvy, posvz); - if (ok == -1) - { - RELEASESHAREDB(res, array, f, cn); - return NULL; - } - - E_Int npts = f->getSize(); - E_Int nfld = f->getNfld(); - - // Construit l'array resultat et l'initialise par copie - PyObject* tpl; - if (res == 1) //structured - { - tpl = K_ARRAY::buildArray(nfld, varString, - nil, njl, nkl); - } - else //unstructured - { - E_Int csize = cn->getSize()*cn->getNfld(); - tpl = K_ARRAY::buildArray(nfld, varString, - npts, cn->getSize(), - -1, eltType, false, csize); - } - E_Float* fnp = K_ARRAY::getFieldPtr(tpl); - FldArrayF fn(npts, nfld, fnp, true); - fn.setAllValuesAt(*f); - if (res == 2) - { - E_Int* cnnp = K_ARRAY::getConnectPtr(tpl); - K_KCORE::memcpy__(cnnp, cn->begin(), cn->getSize()*cn->getNfld()); - } - - // rotate - E_Float m11 = f1x*e1x+f2x*e2x+f3x*e3x; - E_Float m21 = f1y*e1x+f2y*e2x+f3y*e3x; - E_Float m31 = f1z*e1x+f2z*e2x+f3z*e3x; - E_Float m12 = f1x*e1y+f2x*e2y+f3x*e3y; - E_Float m22 = f1y*e1y+f2y*e2y+f3y*e3y; - E_Float m32 = f1z*e1y+f2z*e2y+f3z*e3y; - E_Float m13 = f1x*e1z+f2x*e2z+f3x*e3z; - E_Float m23 = f1y*e1z+f2y*e2z+f3y*e3z; - E_Float m33 = f1z*e1z+f2z*e2z+f3z*e3z; - - if (posx>0 && posy>0 && posz>0) //coord + champs - { - E_Float* xt = f->begin(posx); - E_Float* yt = f->begin(posy); - E_Float* zt = f->begin(posz); - E_Float* xp = fn.begin(posx); - E_Float* yp = fn.begin(posy); - E_Float* zp = fn.begin(posz); - -#pragma omp parallel shared (npts, xt, yt, zt, xp, yp, zp, xc, yc, zc, m11, m12, m13, m21, m22, m23, m31, m32, m33) if (npts > 100) - { - E_Float x, y, z; -#pragma omp for nowait - for (E_Int i = 0; i < npts; i++) - { - x = (xt[i]-xc); - y = (yt[i]-yc); - z = (zt[i]-zc); - xp[i] = xc + m11*x + m12*y + m13*z; - yp[i] = yc + m21*x + m22*y + m23*z; - zp[i] = zc + m31*x + m32*y + m33*z; - } - } - } - E_Int nvect = posvx.size(); - for (E_Int nov = 0; nov < nvect; nov++) - { - E_Int posx = posvx[nov]; - E_Int posy = posvy[nov]; - E_Int posz = posvz[nov]; - E_Float* fxt = f->begin(posx); - E_Float* fyt = f->begin(posy); - E_Float* fzt = f->begin(posz); - E_Float* fxp = fn.begin(posx); - E_Float* fyp = fn.begin(posy); - E_Float* fzp = fn.begin(posz); -#pragma omp parallel shared (npts, fxt, fyt, fzt, fxp, fyp, fzp, m11, m12, m13, m21, m22, m23, m31, m32, m33) if (npts > 100) - { -#pragma omp for nowait - for (E_Int i = 0; i < npts; i++) - { - fxp[i] = m11*fxt[i] + m12*fyt[i] + m13*fzt[i]; - fyp[i] = m21*fxt[i] + m22*fyt[i] + m23*fzt[i]; - fzp[i] = m31*fxt[i] + m32*fyt[i] + m33*fzt[i]; - } - } - } - RELEASESHAREDB(res, array, f, cn); - return tpl; -} - -// ============================================================================ -/* Rotate an array describing a mesh */ -// ============================================================================ -PyObject* K_TRANSFORM::rotateA3(PyObject* self, PyObject* args) -{ - PyObject* array; - E_Float xc, yc, zc; - E_Float alpha, beta, gamma; - PyObject* listOfFieldVectors; - - if (!PYPARSETUPLE_(args, O_ TRRR_ TRRR_ O_, - &array, &xc, &yc, &zc, &alpha, &beta, &gamma, &listOfFieldVectors)) - { - return NULL; - } - - // Check array - E_Int nil, njl, nkl; - FldArrayF* f; FldArrayI* cn; - char* varString; char* eltType; - E_Int res; - res = K_ARRAY::getFromArray(array, varString, f, nil, njl, nkl, - cn, eltType, true); - - if (res != 1 && res != 2) - { - PyErr_SetString(PyExc_TypeError, - "rotate: invalid array."); - return NULL; - } - - E_Int posx = K_ARRAY::isCoordinateXPresent(varString); - E_Int posy = K_ARRAY::isCoordinateYPresent(varString); - E_Int posz = K_ARRAY::isCoordinateZPresent(varString); - posx++; posy++; posz++; - vector posvx; vector posvy; vector posvz; - E_Int ok = extractVectorComponents(varString, listOfFieldVectors, posvx, posvy, posvz); - if (ok == -1) - { - RELEASESHAREDB(res, array, f, cn); - return NULL; - } - // Transformation en radians - E_Float pi = 4*atan(1.); - alpha = alpha*pi/180.; - beta = beta*pi/180.; - gamma = gamma*pi/180.; - - E_Int npts = f->getSize(); - E_Int nfld = f->getNfld(); - - // Construit l'array resultat et l'initialise par copie - PyObject* tpl; - if (res == 1) //structured - { - tpl = K_ARRAY::buildArray(nfld, varString, - nil, njl, nkl); - } - else //unstructured - { - E_Int csize = cn->getSize()*cn->getNfld(); - tpl = K_ARRAY::buildArray(nfld, varString, - npts, cn->getSize(), - -1, eltType, false, csize); - } - E_Float* fnp = K_ARRAY::getFieldPtr(tpl); - FldArrayF fn(npts, nfld, fnp, true); - fn.setAllValuesAt(*f); - - if (res == 2) - { - E_Int* cnnp = K_ARRAY::getConnectPtr(tpl); - K_KCORE::memcpy__(cnnp, cn->begin(), cn->getSize()*cn->getNfld()); - } - - // rotate - E_Float calpha = cos(alpha); - E_Float salpha = sin(alpha); - E_Float cbeta = cos(beta); - E_Float sbeta = sin(beta); - E_Float cgamma = cos(gamma); - E_Float sgamma = sin(gamma); - if (posx>0 && posy>0 && posz>0) //coord + champs - { - E_Float* xp = fn.begin(posx); - E_Float* yp = fn.begin(posy); - E_Float* zp = fn.begin(posz); - E_Float* x = f->begin(posx); - E_Float* y = f->begin(posy); - E_Float* z = f->begin(posz); - -#pragma omp parallel default(shared) - { - E_Float dx, dy, dz; - E_Float x1, y1, z1, x2, y2, z2; -#pragma omp for - for (E_Int i = 0; i < npts; i++) - { - // Rotation autour de Oz (Ox->Ox1, Oy->Oy1, Oz->Oz) - dx = x[i]-xc; dy = y[i]-yc; dz = z[i]-zc; - x1 = xc + cgamma*dx - sgamma*dy; - y1 = yc + sgamma*dx + cgamma*dy; - z1 = zc + dz; - - // Rotation autour de Oy1 (Ox1->Ox2, Oy1->Oy1, Oz1->Oz2) - dx = x1-xc; dy = y1-yc; dz = z1-zc; - x2 = xc + cbeta*dx - sbeta*dz; - y2 = yc + dy; - z2 = zc + sbeta*dx + cbeta*dz; - - // Rotation autour de Oz2 (Ox2->Ox3, Oy2->Oy3, Oz2->Oz2) - dx = x2-xc; dy = y2-yc; dz = z2-zc; - xp[i] = xc + dx; - yp[i] = yc + calpha*dy - salpha*dz; - zp[i] = zc + salpha*dy + calpha*dz; - } - } - } - - E_Int nvect = posvx.size(); - for (E_Int nov = 0; nov < nvect; nov++) - { - E_Int posx = posvx[nov]; - E_Int posy = posvy[nov]; - E_Int posz = posvz[nov]; - E_Float* fxt = f->begin(posx); - E_Float* fyt = f->begin(posy); - E_Float* fzt = f->begin(posz); - E_Float* fxp = fn.begin(posx); - E_Float* fyp = fn.begin(posy); - E_Float* fzp = fn.begin(posz); -//#pragma omp parallel default(shared) - { - E_Float dx, dy, dz; - E_Float x1, y1, z1, x2, y2, z2; -//#pragma omp for - for (E_Int i = 0; i < npts; i++) - { - // Rotation autour de Oz (Ox->Ox1, Oy->Oy1, Oz->Oz) - dx = fxt[i]; dy = fyt[i]; dz = fzt[i]; - x1 = cgamma*dx - sgamma*dy; - y1 = sgamma*dx + cgamma*dy; - z1 = dz; - - // Rotation autour de Oy1 (Ox1->Ox2, Oy1->Oy1, Oz1->Oz2) - dx = x1; dy = y1; dz = z1; - x2 = cbeta*dx - sbeta*dz; - y2 = dy; - z2 = sbeta*dx + cbeta*dz; - - // Rotation autour de Oz2 (Ox2->Ox3, Oy2->Oy3, Oz2->Oz2) - dx = x2; dy = y2; dz = z2; - fxp[i] = dx; - fyp[i] = calpha*dy - salpha*dz; - fzp[i] = salpha*dy + calpha*dz; - } - } - } - - RELEASESHAREDB(res, array, f, cn); - return tpl; -} diff --git a/Cassiopee/Transform/srcs.py b/Cassiopee/Transform/srcs.py index 21d307731..bb85c81a9 100644 --- a/Cassiopee/Transform/srcs.py +++ b/Cassiopee/Transform/srcs.py @@ -6,9 +6,9 @@ "Transform/deform.cpp", "Transform/deform2.cpp", "Transform/deformMeshStruct.cpp", - #"Transform/rotate.cpp", "Transform/rotate2.cpp", "Transform/translate.cpp", + "Transform/homothety.cpp", "Transform/perturbate.cpp", "Transform/patch.cpp", "Transform/oneovern.cpp", @@ -58,6 +58,4 @@ #============================================================================== # Fichiers fortran #============================================================================== -for_srcs = ['Transform/Fortran/RotateF.for', - 'Transform/Fortran/HomothetyF.for', - 'Transform/Fortran/DeformF.for' ] +for_srcs = [ 'Transform/Fortran/DeformF.for' ]