ContinuousFieldLevel.hpp

00001 
00002 //
00003 // $Id: ContinuousFieldLevel.hpp,v 1.1 2008/01/14 19:20:43 werner Exp $
00004 //
00006 #ifndef __GRIDOP_CONTINUOUSFIELDLEVEL_HPP
00007 #define __GRIDOP_CONTINUOUSFIELDLEVEL_HPP
00008 
00009 #include "gridopDllApi.h"
00010 
00011 #include <field/MemArray.hpp>
00012 #include <field/DirectProductArray.hpp>
00013 
00014 #include <vector/CubicIpol.hpp>
00015 #include <vector/LinearIpol.hpp>
00016 #include <vector/Interpolate.hpp>
00017 
00018 #include <ocean/eagle/PhysicalSpace.hpp>
00019 
00020 namespace Fiber
00021 {
00022 
00023 template <int Dims, typename real=double>
00024 struct  ContinuousFieldLevel
00025 {
00026         enum { N = Dims };
00027 
00028         typedef FixedArray<real, N>                     Point_t;
00029         typedef DirectProductMemArray<Eagle::point3>    ProcArray_t; 
00030 
00031         typedef std::pair<Point_t, ContinuousFieldLevel*> Location_t;
00032 
00033         RefPtr<LinearArray<double> > Coordinates[N];
00034 
00035         ContinuousFieldLevel*Neighbours[N][2];
00036 
00037         ContinuousFieldLevel(const ProcArray_t&Crds)
00038         {
00039                 for(int k=0; k<N; k++)
00040                 {
00041                         Coordinates[k] = Crds.Components[k]; 
00042                         if (!Coordinates[k] )
00043                                 throw "ContinuousFieldLevel(): Nonlinear coordinates found, not good.";
00044                 }
00045         }
00046 
00047         Location_t locate(const Point_t&P)
00048         {
00049         Point_t point;
00050 
00051                 // Compute 
00052                 for(int k=0; k<N; k++)
00053                 {
00054                         point[k] = (Coordinates[k])->reverse( P[k] ); 
00055 
00056                         if (point[k] < 0.0)
00057                         {
00058                                 if (!Neighbours[k][0])
00059                                         throw P; 
00060 
00061                                 return Neighbours[k][0]->locate(P);
00062                         }
00063 
00064                         if (point[k] > Coordinates[k]->Length() )
00065                         {
00066                                 if (!Neighbours[k][1])
00067                                         throw P; 
00068 
00069                                 return Neighbours[k][1]->locate(P);
00070                         }
00071 
00072                 } 
00073 
00074                 return Location_t(point, this);
00075         }
00076 
00077 /*
00078                 {
00079         const MultiArray_t&M;
00080 
00081         Interpolate_t Ipol(M, point); 
00082 
00083                 return Ipol.eval();
00084         }
00085 */
00086 };
00087 
00088 template <int Dims, typename real=double>
00089 struct  ContinuousField
00090 {
00091         typedef ContinuousFieldLevel<Dims, real> ContinuousFieldLevel_t;
00092 
00093         typedef typename ContinuousFieldLevel_t::Location_t     Location_t;
00094         typedef typename ContinuousFieldLevel_t::Point_t        Point_t;
00095 
00096         typedef set< ContinuousFieldLevel_t*>   FragmentsPerLevel_t;
00097 
00098         typedef map<int, FragmentsPerLevel_t>   AllLevels_t;
00099 
00100         AllLevels_t AllLevels;
00101 
00102         Location_t locate(const Point_t&P, ContinuousFieldLevel_t*hint)
00103         {
00104                 
00105         }
00106 };
00107 
00108 
00109 } /* namespace Fiber */ 
00110 
00111 #endif /* __GRIDOP_CONTINUOUSFIELDLEVEL_HPP */
00112