diff --git a/program2D/source/extemp/interpolateFrom3D.h b/program2D/source/extemp/interpolateFrom3D.h index ad74ad895b849b9f2dad8084a0a033b28e6011ea..84e4bb54221a1a589d32fb15e4c2df13d18aeea1 100644 --- a/program2D/source/extemp/interpolateFrom3D.h +++ b/program2D/source/extemp/interpolateFrom3D.h @@ -341,6 +341,7 @@ void Variable<DTyp>::interpolateSlizeZ(const Expr2D<A>& a_, IteratorZDirection* ///////////////////////////////////////////////////////// // 3. Interpolation 3D->2D +// 3.1. mit double z ///////////////////////////////////////////////////////// @@ -935,202 +936,141 @@ void Variable2D<DTyp>::interpolateSlizeZ(const Exp_Function4<A, B, C, D, DTyp1,D assert(false); } } -#ifdef CPP11 + + +///////////////////////////////////////////////////////// +// 3. Interpolation 3D->2D +// 3.2. mit Iterator +///////////////////////////////////////////////////////// + + + template <class DTyp> -template <class DTyp_Result, class DTyp1, class Func, typename ... A> -void Variable2D<DTyp>::interpolateSlizeZ(const Exp_Functor<DTyp_Result, DTyp1, Func, A...>& U, double z) { - Blockgrid* blockgrid3D = U.Give_blockgrid(); - Unstructured_grid* ug3Dp = blockgrid3D->Give_unstructured_grid(); - TypeOfUG typeUg = ug3Dp->getUgTyp(); +template <class DTyp1> +void Variable2D<DTyp>::interpolateSlizeZ(const Variable<DTyp1>* U, IteratorZDirection* iterZ) { + Blockgrid* blockgrid3D = U->Give_blockgrid(); + Unstructured_grid* ug3D = blockgrid3D->Give_unstructured_grid(); + TypeOfUG typeUg = ug3D->getUgTyp(); assert(typeUg!=noWithZTyp); - UG_WithZdirection* ug3DZ = static_cast<UG_WithZdirection*>(ug3Dp); - + UG_WithZdirection* ug3DZ = static_cast<UG_WithZdirection*>(ug3D); + int numberCorners2D = ug->Give_number_points(); +// U->UpdateHexahedra(); - // Hexaeder -> Rectangle + // Rectangle -> Hexaeder if(typeUg==hexahedronUgTyp) { assert(numberCorners2D==4); - int id = ug3DZ->getNummerBlockZ(z); - int Nx = blockgrid->Give_Nx_rectangle(0); int Ny = blockgrid->Give_Ny_rectangle(0); - int Nz = blockgrid3D->Give_Nz_hexahedron(id); - - double zLeft = ug3DZ->zLeft(id); //ug3Dp->Give_point(0)->Give_coordinate().z; - double zRight = ug3DZ->zRight(id); //ug3Dp->Give_point(4)->Give_coordinate().z; - int kf = find_k(zLeft,zRight,z,Nz); - - if(kf==0 || kf==Nz) { //links und rechts - int k=kf; - U.Update<hexahedronEl>(id); - for(int j = 0;j <= Ny;++j) - for(int i = 0;i <= Nx;++i) { - data_rectangles[0][i+(Nx+1)*j] = U.Give_data<hexahedronEl> ( params_out ); - } - Update_back(0); - } - else { //mitte - int k; - double zl = zLeft + (zRight-zLeft)/Nz * (kf-1); - double zr = zLeft + (zRight-zLeft)/Nz * (kf ); - - U.Update<hexahedronEl>(id); - for(int j = 0;j <= Ny;++j) - for(int i = 0;i <= Nx;++i) { - k=kf-1; - DTyp Ul = U.Give_data<hexahedronEl> ( params_out ); - k=kf; - DTyp Ur = U.Give_data<hexahedronEl> ( params_out ); +// U->template Update<rectangleEl>(0); + + int k = iterZ->get_k_intern(); + int id = iterZ->get_nummerBlock(); - data_rectangles[0][i+(Nx+1)*j] = Ul + (Ur-Ul) * (z-zl)/(zr-zl); - } - Update_back(0); - } + U->template Update<hexahedronEl>(id); + for(int j = 0;j <= Ny;++j) + for(int i = 0;i <= Nx;++i) { + data_rectangles[0][i+(Nx+1)*j] = U->template Give_data<hexahedronEl> ( params_out ); +// data_hexahedra[id][(i)+(Nx+1)*((j)+(Ny+1)*(k))] = U->template Give_data<rectangleEl>(0, i, j, Nx); + } + Update_back(0); } - else if(typeUg==cylinderUgTyp || typeUg==hexahedronAdaptiveUgTyp || typeUg==cylinderListUgTyp) { // Cylinder -> disc oder adaptiveHex -> adaptiveRec + else if(typeUg==cylinderUgTyp || typeUg == hexahedronAdaptiveUgTyp) { // Cylinder -> disc oder adaptiveHex -> adaptiveRec assert(numberCorners2D==8); - int id_block = ug3DZ->getNummerBlockZ(z); - int Nz = blockgrid3D->Give_Nz_hexahedron(id_block); + int id_block = iterZ->get_nummerBlock(); int num_blocks = ug3DZ->getNummernBloecke(); - - double zLeft = ug3DZ->zLeft(id_block); - double zRight = ug3DZ->zRight(id_block); - + int k = iterZ->get_k_intern(); + for(int id_rec = 0;id_rec<5;++id_rec) { int Nx = blockgrid->Give_Nx_rectangle(id_rec); int Ny = blockgrid->Give_Ny_rectangle(id_rec); int id = id_rec*num_blocks + id_block; - int kf = find_k(zLeft,zRight,z,Nz); - - if(kf==0 || kf==Nz) { //links und rechts - int k=kf; - U.Update<hexahedronEl>(id); - for(int j = 0;j <= Ny;++j) - for(int i = 0;i <= Nx;++i) { - data_rectangles[id_rec][i+(Nx+1)*j] = U.Give_data<hexahedronEl> ( params_out ); - } - Update_back(id_rec); - } - else { //mitte - int k; - double zl = zLeft + (zRight-zLeft)/Nz * (kf-1); - double zr = zLeft + (zRight-zLeft)/Nz * (kf ); - - U.Update<hexahedronEl>(id); - for(int j = 0;j <= Ny;++j) - for(int i = 0;i <= Nx;++i) { - k=kf-1; - DTyp Ul = U.Give_data<hexahedronEl> ( params_out ); - k=kf; - DTyp Ur = U.Give_data<hexahedronEl> ( params_out ); - - data_rectangles[id_rec][i+(Nx+1)*j] = Ul + (Ur-Ul) * (z-zl)/(zr-zl); - } - Update_back(id_rec); - } + U->template Update<hexahedronEl>(id); + for(int j = 0;j <= Ny;++j) + for(int i = 0;i <= Nx;++i) { + data_rectangles[id_rec][i+(Nx+1)*j] = U->template Give_data<hexahedronEl> ( params_out ); +// data_hexahedra[id][(i)+(Nx+1)*((j)+(Ny+1)*(k))] = U->template Give_data<rectangleEl>(id_rec, i, j, Nx); + } + Update_back(id_rec); } } - else if(typeUg==hexahedronListUgTyp) { //adaptiveHex -> adaptiveRec - HexahedronXYList* hexahedron = (HexahedronXYList*)(ug3Dp); - int n_x = hexahedron->n_x; - int n_y = hexahedron->n_y; - - int id_block = ug3DZ->getNummerBlockZ(z); - int Nz = blockgrid3D->Give_Nz_hexahedron(id_block); + else if(typeUg==cylinderListUgTyp) { // List Cylinder -> disc // neu Christoph: 29.10.14 + int id_block = iterZ->get_nummerBlock(); int num_blocks = ug3DZ->getNummernBloecke(); - - double zLeft = ug3DZ->zLeft(id_block); - double zRight = ug3DZ->zRight(id_block); - - for(int id_rec = 0;id_rec< n_x*n_y;++id_rec) { + int k = iterZ->get_k_intern(); + + for(int id_rec = 0;id_rec<5;++id_rec) { int Nx = blockgrid->Give_Nx_rectangle(id_rec); int Ny = blockgrid->Give_Ny_rectangle(id_rec); int id = id_rec*num_blocks + id_block; - int kf = find_k(zLeft,zRight,z,Nz); - - if(kf==0 || kf==Nz) { //links und rechts - int k=kf; - U.Update<hexahedronEl>(id); - for(int j = 0;j <= Ny;++j) - for(int i = 0;i <= Nx;++i) { - data_rectangles[id_rec][i+(Nx+1)*j] = U.Give_data<hexahedronEl> ( params_out ); - } - Update_back(id_rec); - } - else { //mitte - int k; - double zl = zLeft + (zRight-zLeft)/Nz * (kf-1); - double zr = zLeft + (zRight-zLeft)/Nz * (kf ); - - U.Update<hexahedronEl>(id); - for(int j = 0;j <= Ny;++j) - for(int i = 0;i <= Nx;++i) { - k=kf-1; - DTyp Ul = U.Give_data<hexahedronEl> ( params_out ); - k=kf; - DTyp Ur = U.Give_data<hexahedronEl> ( params_out ); - - data_rectangles[id_rec][i+(Nx+1)*j] = Ul + (Ur-Ul) * (z-zl)/(zr-zl); - } - Update_back(id_rec); - } + U->template Update<hexahedronEl>(id); + for(int j = 0;j <= Ny;++j) + for(int i = 0;i <= Nx;++i) { + data_rectangles[id_rec][i+(Nx+1)*j] = U->template Give_data<hexahedronEl> ( params_out ); +// data_hexahedra[id][(i)+(Nx+1)*((j)+(Ny+1)*(k))] = U->template Give_data<rectangleEl>(id_rec, i, j, Nx); + } + Update_back(id_rec); } - } - else if(typeUg==hexahedronListTestUgTyp) { //adaptiveHex -> adaptiveRec - HexahedronXYListTest* hexahedron = (HexahedronXYListTest*)(ug3Dp); - int n_x = hexahedron->n_x; - int n_y = hexahedron->n_y; - - int id_block = ug3DZ->getNummerBlockZ(z); - int Nz = blockgrid3D->Give_Nz_hexahedron(id_block); - int num_blocks = ug3DZ->getNummernBloecke(); + } + else if(typeUg == hexahedronListUgTyp) { + HexahedronXYList* hexahedron = (HexahedronXYList*)ug; + int n_x = numberCorners2D==hexahedron->n_x; + int n_y = numberCorners2D==hexahedron->n_y; + assert((n_x+1) * (n_y+1)); - double zLeft = ug3DZ->zLeft(id_block); - double zRight = ug3DZ->zRight(id_block); + int id_block = iterZ->get_nummerBlock(); + int num_blocks = ug3DZ->getNummernBloecke(); + int k = iterZ->get_k_intern(); - for(int id_rec = 0;id_rec< n_x*n_y;++id_rec) { - int Nx = blockgrid->Give_Nx_rectangle(id_rec); - int Ny = blockgrid->Give_Ny_rectangle(id_rec); - int id = id_rec*num_blocks + id_block; + for(int id_rec = 0;id_rec< n_x*n_y;++id_rec) { + int Nx = blockgrid->Give_Nx_rectangle(id_rec); + int Ny = blockgrid->Give_Ny_rectangle(id_rec); + int id = id_rec*num_blocks + id_block; - int kf = find_k(zLeft,zRight,z,Nz); + U->template Update<hexahedronEl>(id); + for(int j = 0;j <= Ny;++j) + for(int i = 0;i <= Nx;++i) { + data_rectangles[id_rec][i+(Nx+1)*j] = U->template Give_data<hexahedronEl> ( params_out ); +// data_hexahedra[id][(i)+(Nx+1)*((j)+(Ny+1)*(k))] = U->template Give_data<rectangleEl>(id_rec, i, j, Nx); + } + Update_back(id_rec); + } + } + else if(typeUg == hexahedronListTestUgTyp) { + HexahedronXYListTest* hexahedron = (HexahedronXYListTest*)ug; + int n_x = numberCorners2D==hexahedron->n_x; + int n_y = numberCorners2D==hexahedron->n_y; + assert((n_x+1) * (n_y+1)); - if(kf==0 || kf==Nz) { //links und rechts - int k=kf; - U.Update<hexahedronEl>(id); - for(int j = 0;j <= Ny;++j) - for(int i = 0;i <= Nx;++i) { - data_rectangles[id_rec][i+(Nx+1)*j] = U.Give_data<hexahedronEl> ( params_out ); - } - Update_back(id_rec); - } - else { //mitte - int k; - double zl = zLeft + (zRight-zLeft)/Nz * (kf-1); - double zr = zLeft + (zRight-zLeft)/Nz * (kf ); + int id_block = iterZ->get_nummerBlock(); + int num_blocks = ug3DZ->getNummernBloecke(); + int k = iterZ->get_k_intern(); - U.Update<hexahedronEl>(id); - for(int j = 0;j <= Ny;++j) - for(int i = 0;i <= Nx;++i) { - k=kf-1; - DTyp Ul = U.Give_data<hexahedronEl> ( params_out ); - k=kf; - DTyp Ur = U.Give_data<hexahedronEl> ( params_out ); + for(int id_rec = 0;id_rec< n_x*n_y;++id_rec) { + int Nx = blockgrid->Give_Nx_rectangle(id_rec); + int Ny = blockgrid->Give_Ny_rectangle(id_rec); + int id = id_rec*num_blocks + id_block; - data_rectangles[id_rec][i+(Nx+1)*j] = Ul + (Ur-Ul) * (z-zl)/(zr-zl); - } - Update_back(id_rec); - } - } + U->template Update<hexahedronEl>(id); + for(int j = 0;j <= Ny;++j) + for(int i = 0;i <= Nx;++i) { + data_rectangles[id_rec][i+(Nx+1)*j] = U->template Give_data<hexahedronEl> ( params_out ); +// data_hexahedra[id][(i)+(Nx+1)*((j)+(Ny+1)*(k))] = U->template Give_data<rectangleEl>(id_rec, i, j, Nx); + } + Update_back(id_rec); + } } else { - assert(false); + std::cout << " noch nicht implementiert!! " << std::endl; + assert(false); } } -#endif + + + ///////////////////////////////////////////////////////// // 4. Intergrate 3D->2D diff --git a/program2D/source/extemp/variable2D.h b/program2D/source/extemp/variable2D.h index 611980d3d9435ddfdd648927ee651fd86cfb8a74..c83f6d141e392007b4c16daf969aea9e7b9a8d66 100644 --- a/program2D/source/extemp/variable2D.h +++ b/program2D/source/extemp/variable2D.h @@ -38,6 +38,8 @@ template <typename TYPE> class ExpressionProlongation2D; template <class A, class DTyp> class Expr2D_Equation_of_Array; +class IteratorZDirection; + class QString; class Iteration_description2D { @@ -189,6 +191,9 @@ class Variable2D : public Expr2D<Variable2D< DTyp > > { template <class DTyp1> void interpolateSlizeZ(const Variable<DTyp1>* U, double z); + template <class DTyp1> + void interpolateSlizeZ(const Variable<DTyp1>* U, IteratorZDirection* iterZ); + template <class DTyp1, class A> void interpolateSlizeZ(const Exp_Function1<A, DTyp1, DTyp>& U, double z);