xml_parser_restart.h

Go to the documentation of this file.
00001 /* ./parser/xml_parser_restart.h 
00002 **********************************
00003 Copyright INRIA and CEA 
00004 
00005 author : Guillaume ANCIAUX (anciaux@labri.fr, g.anciaux@laposte.net)
00006 
00007 The LibMultiScale is a C++ parallel framework for the multiscale
00008 coupling methods dedicated to material simulations. This framework
00009 provides an API which makes it possible to program coupled simulations
00010 and integration of already existing codes.
00011 
00012 This Project is done in a collaboration between INRIA Futurs Bordeaux
00013 within ScAlApplix team and CEA/DPTA Ile de France. 
00014 
00015 This software is governed by the CeCILL-C license under French law and
00016 abiding by the rules of distribution of free software.  You can  use, 
00017 modify and/ or redistribute the software under the terms of the CeCILL-C
00018 license as circulated by CEA, CNRS and INRIA at the following URL
00019 "http://www.cecill.info". 
00020 
00021 As a counterpart to the access to the source code and  rights to copy,
00022 modify and redistribute granted by the license, users are provided only
00023 with a limited warranty  and the software's author,  the holder of the
00024 economic rights,  and the successive licensors  have only  limited
00025 liability. 
00026 
00027 In this respect, the user's attention is drawn to the risks associated
00028 with loading,  using,  modifying and/or developing or reproducing the
00029 software by the user in light of its specific status of free software,
00030 that may mean  that it is complicated to manipulate,  and  that  also
00031 therefore means  that it is reserved for developers  and  experienced
00032 professionals having in-depth computer knowledge. Users are therefore
00033 encouraged to load and test the software's suitability as regards their
00034 requirements in conditions enabling the security of their systems and/or 
00035 data to be ensured and,  more generally, to use and operate it in the 
00036 same conditions as regards security. 
00037 
00038 The fact that you are presently reading this means that you have had
00039 knowledge of the CeCILL-C license and that you accept its terms.
00040 ***********************************/
00041 
00042 #ifndef XML_PARSER_RESTART_H
00043 #define XML_PARSER_RESTART_H
00044 
00045 #include "../dumper/base64_reader.h"
00046 #include "../geometry/geometry_manager.h"
00047 #include "xml_parser.h"
00048 
00049 #define NONE 0
00050 #define P0S 1
00051 #define DEP 2
00052 #define VEL 3
00053 #define ACC 4
00054 #define TEXT 0
00055 #define BINARY 1
00056 
00057 
00058 
00059 class Triplet {
00060  public:
00061 
00062   Triplet(double x0=0, double y0=0 ,double z0=0){
00063     x = x0; y = y0; z = z0;
00064     read = 0;
00065 
00066     epsilon = .4e-10;
00067     epsilon2 = epsilon * epsilon;
00068   };
00069 
00070   void Truncate();
00071   static void SetDomainSize(Geometrie & geom);
00072   
00073   double & operator()(int i){
00074     switch (i) {
00075     case 0 : return x;
00076     case 1 : return y;
00077     case 2 : return z;      
00078     default: FATAL("value requested for coordinates out of range");
00079     }
00080   }
00081 
00082   int & getRead(){return read;};
00083 
00084   static double tx,ty,tz;
00085 
00086  private:
00087 
00088   double x,y,z;
00089 
00090   int read;
00091 
00092   static Cube geom;
00093   static bool domainSizeIsSet;
00094 
00095   double epsilon;
00096   double epsilon2;
00097 };
00098 
00099 
00100 class close_enough{
00101 
00102 
00103  public:
00104   
00105   close_enough(Triplet t){
00106     search = t;
00107     epsilon2 = 1e-10*1e-10;
00108   }
00109 
00110   bool operator()(pair<Triplet,Triplet> elem){
00111     double dx = elem.first(0) - search(0);
00112     double dy = elem.first(1) - search(1);
00113     double dz = elem.first(2) - search(2);
00114 
00115     double d = dx*dx + dy*dy + dz*dz;
00116     //    DUMP("d " << dx << " " << dy << " " << dz << " " << d << " " << epsilon2);
00117     
00118     if (d < epsilon2)
00119       return true;
00120     else return false;
00121   }
00122 
00123  private:
00124   double epsilon2;
00125   Triplet search;
00126 };
00127 
00128 class ComparateurTriplet{
00129  public:
00130 
00131   bool operator()(Triplet t1,Triplet t2) const{
00132 
00133     if (t1(0) != t2(0))
00134     return (t1(0) < t2(0));
00135     if (t1(1) != t2(1))
00136       return (t1(1) < t2(1));
00137     if (t1(2) != t2(2))
00138       return (t1(2) < t2(2));
00139 
00140     return false;
00141   }
00142 };
00143 
00144 
00145 
00146 class XMLRestartParser : public XMLParser {
00147 
00148  public:
00149 
00150   XMLRestartParser(){
00151     nbDofs = 0;
00152     Dim = 3;
00153     savedTime = 0;
00154     cpt = 0;
00155   };
00156 
00157 
00158   virtual int ParseFile(const char * name){
00159     XMLParser::ParseFile(name);
00160 
00161     return 0;
00162   }
00163 
00164   bool IsDofRegistered(double x,double y, double z);
00165   void AssignDispField(double x,double y, double z,double & ux, double & uy,double & uz);
00166   void AssignVelField(double x,double y, double z,double & ux, double & uy,double & uz);
00167   void AssignForceField(double x,double y, double z,double & ux, double & uy,double & uz);
00168   
00169  protected:
00170 
00171   void charHandler(const XML_Char * str,int len);
00172   void startElement(const char *name,const char **atts);
00173   void endElement(const char * name);
00174 
00175  private:
00176 
00177   void manageP0(char * s);
00178   void manageU(char * s);
00179   void manageV(char * s);
00180   void manageA(char * s);
00181   int readTriplet(Triplet & C,char * s);
00182 
00184   Triplet triplet;
00185 
00186   unsigned int Dim;
00187   unsigned int nbDofs;
00188   double savedTime;
00189   int * tab_indexes;
00190 
00191   int current_field;
00192   unsigned int cpt;
00193   int type;
00194 
00196   Base64Reader b64;
00197 
00198 
00199   std::map<Triplet,Triplet,ComparateurTriplet> mapU;
00200   std::map<Triplet,Triplet,ComparateurTriplet> mapV;
00201   std::map<Triplet,Triplet,ComparateurTriplet> mapA;
00202   std::map<int,Triplet> mapP0;
00203 };
00204 
00205 
00206 inline ostream& operator << (ostream& os,Triplet &t){
00207   os << "Triplet : " << t(0) << " " << t(1) << " " << t(2) << std::endl;
00208   return os;
00209 };
00210 
00211 
00212 #endif

Generated on Fri Sep 7 13:12:35 2007 for LibMultiScale by  doxygen 1.5.2