vtf-logo

Geom.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2002 Ralf Deiterding
00004 // Brandenburgische Universitaet Cottbus
00005 //
00006 // Copyright (C) 2003-2007 California Institute of Technology
00007 // Ralf Deiterding, ralf@amroc.net
00008 
00009 #ifndef AMROC_GEOM_H
00010 #define AMROC_GEOM_H
00011 
00024 template <class DataType, int dim>
00025 class Geom {
00026 public:
00027   typedef GridData<DataType,dim> grid_data_type;   
00028   typedef Vector<DataType,dim> point_type;
00029 
00030   Geom() {}
00031 
00032   int LocalList(GridHierarchy& GH, const BBox& bb, const int& nc, 
00033                 const point_type* xc, bool* lused) {
00034     DCoords lbc = GH.worldCoords(bb.lower(), bb.stepsize());
00035     DCoords ubc = GH.worldCoords(bb.upper()+bb.stepsize(), bb.stepsize());
00036     int nl = nc;
00037     for (register int n=0; n<nc; n++) {
00038       lused[n] = true;
00039       for (register int d=0; d<dim; d++) 
00040         if (lbc(d)>xc[n](d) || ubc(d)<xc[n](d)) {
00041           lused[n] = false;
00042           nl--;
00043           break;
00044         }
00045     }
00046     return nl;
00047   }
00048 
00049   void CellCoords(GridHierarchy& GH, const Coords& ss, const int& nc, 
00050                   const int* idx, point_type* xc) {
00051     point_type dxh2;
00052     GH.worldStep(ss, dxh2.data());
00053     dxh2 *= static_cast<DataType>(0.5);
00054 
00055     for (register int n=0; n<nc; n++) {
00056       GH.worldCoords(&(idx[dim*n]), ss(), (DataType*)(xc[n].data()));
00057       xc[n] += dxh2;
00058     }
00059   }
00060 
00061   void CellIndices(GridHierarchy& GH, const Coords& ss, const int& nc, 
00062                    const point_type* xc, int* idx) {
00063     for (register int n=0; n<nc; n++) {      
00064       GH.localCoords(xc[n].data(), &(idx[dim*n]));
00065       for (register int d=0; d<dim; d++) {
00066         if (idx[n*dim+d]<0) idx[n*dim+d] -= ss(d)-1;
00067         idx[n*dim+d] = (idx[n*dim+d]/ss(d))*ss(d);
00068       }
00069     }
00070   }
00071 };
00072 
00073 #endif

Generated on Fri Aug 24 13:00:50 2007 for AMROC Fluid-solver Framework - by  doxygen 1.4.7