/********************************************************************************** * Copyright 2010 Christoph Pflaum * Department Informatik Lehrstuhl 10 - Systemsimulation * Friedrich-Alexander Universität Erlangen-Nürnberg * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **********************************************************************************/ #ifndef BLOCKGRID2D_H #define BLOCKGRID2D_H #include /* Ny * * * * * * Ny-1 * + + + + * 3 * + + + + * 2 * + + + + * 1 * + + + + * 0 * * * * * * 0 1 2 3 Nx-1 Nx */ template class Variable2D; class Blockgrid2D { public: Blockgrid2D(Unstructured2DGrid *ug); Blockgrid2D(Unstructured2DGrid *ug, int N); Blockgrid2D(Unstructured2DGrid *ug, int Nx, int Ny); /** Constructor for disc *** @param Nx: Number of grid points in x-direction *** @param Ny: Number of grid points in y-direction *** @param Nr: Number of grid points in radial direction **/ Blockgrid2D(Unstructured2DGrid *ug, int Nx, int Ny, int Nr); Blockgrid2D(Unstructured2DGrid *ug, const std::vector& N); Blockgrid2D(Unstructured2DGrid *ug, const std::vector& Nx, const std::vector&Ny); Blockgrid2D(const Blockgrid2D& copy, const std::vector& number_points); Blockgrid2D(const Blockgrid2D& copy); ~Blockgrid2D(); bool hasSameStructure(const Blockgrid2D& otherBg) { return true; } /** * @param strechDomainX streched die Geometrie um Faktor strechDomainX in x-Richtung * @param strechDomainY streched die Geometrie um Faktor strechDomainY in y-Richtung */ void SetDomainStrech(double strechDomainX_,double strechDomainY_) { strechDomainX = strechDomainX_; strechDomainY = strechDomainY_; } double getStrechX() const { return strechDomainX; } double getStrechY() const { return strechDomainY; } inline bool inStrechedDomain(const D2vector& point_coord); double MinimumStrechedX() { return ug->MinimumX()*strechDomainX; }; double MinimumStrechedY() { return ug->MinimumY()*strechDomainY; }; double MaximumStrechedX() { return ug->MaximumX()*strechDomainX; }; double MaximumStrechedY() { return ug->MaximumY()*strechDomainY; }; void Set_grid_points(int d, int Nd); Unstructured2DGrid* Give_unstructured_grid() const { return ug; }; D2vector Give_coord_rectangle(int id, int i, int j) const; D2vector Give_coord_edge(int id, int i) const; D2vector Give_coord_point(int id) const; int Give_Nx_rectangle(int id) const; int Give_Ny_rectangle(int id) const; int Give_N_total_rectangle(int id) const; const std::vector& Give_N() const; int Give_Nx_edge(int id) const; int Give_N_color(int color) const; int Total_number_of_points(); Blockgrid2D CopyRefinement(std::vector& N) const; void Refine(std::vector& N); /** * Verschiebung der Indizes in einer Richtung * Diese Funktion verwNEdiret man oft nacheinder in x und y Richtung * und addiert Nconst auf. * Indizes bezüglich Zellen * */ inline static int Give_Nconst_cell ( dir2D dir, int Nxrec, int Nyrec); /** * Index der Zelle an der Ecke son * Indizes bezüglich Zellen * */ inline static int Give_Nconst_cell (dir2D_sons son, int Nxrec, int Nyrec); /** * Indizes des inneren Punktes im Quadrangle an der Ecke son * Indizes bezüglich Punkte * */ inline static int Give_Nconst(dir2D_sons son, int Nxrec, int Nyrec); int getId() { return id_of_grid; } protected: std::vector number_points; // number_points[i] // Anzahl der Punkte in Richtung i // i=0, ..., degree_of_freedom()-1 bool variable_set; // set true falls eine Variable konstruiert private: Unstructured2DGrid *ug; int id_of_grid; static int id_count_grid; double strechDomainX; double strechDomainY; }; // inline Funtionen //------------------------------------- bool Blockgrid2D::inStrechedDomain(const D2vector& point_coord) { D2vector point_streched(point_coord.x/strechDomainX,point_coord.y/strechDomainY); return ug->inDomain(point_streched); } inline int Blockgrid2D::Give_Nconst_cell ( dir2D dir, int Nxrec, int Nyrec) { /* old if ( dir == Wdir2D ) return Nxrec; if ( dir == Sdir2D ) return ( Nxrec + 1 ) *Nyrec; return 0; */ if ( dir == Wdir2D ) return Nxrec-1; if ( dir == Ndir2D ) return Nxrec * (Nyrec-1); return 0; //Index Zelle: (j*Nx+i) // i=0,...,Nx-1, j=0,...,Ny-1 } // Index der Zelle an der Ecke son inline int Blockgrid2D::Give_Nconst_cell (dir2D_sons son, int Nxrec, int Nyrec) { if(son == SWdir2D) return 0; if(son == SEdir2D) return Nxrec-1; if(son == NWdir2D) return Nxrec*(Nyrec-1); // son == NEdir2D return Nxrec*(Nyrec-1)+Nxrec-1; //Index Zelle: (j*Nx+i) // i=0,...,Nx-1, j=0,...,Ny-1 } // dir2D_sons { SWdir2D, SEdir2D, NWdir2D, NEdir2D }; inline int Blockgrid2D::Give_Nconst(dir2D_sons son, int Nxrec, int Nyrec) { if(son == SWdir2D) return Nxrec + 2; if(son == SEdir2D) return 2*Nxrec; if(son == NWdir2D) return (Nxrec+1) * Nyrec - Nxrec; // son == NEdir2D return (Nxrec+1) * Nyrec - 2; //Bsp Nx=3, Ny=4 // // ++++ // +--+ // +--+ // +--+ // ++++ // WS: 3 + 2 = 5 // 4 5 // 0 1 2 3 // ES: 2*3 = 6 // 4 5 6 // 0 1 2 3 // WN: 4*4 - 3 = 13 // 12 13 // 8 9 10 11 // 4 5 6 7 // 0 1 2 3 // EN: 4*4 - 2 = 14 // 12 13 14 // 8 9 10 11 // 4 5 6 7 // 0 1 2 3 } #endif // BLOCKGRID_H