XMLRestartParser Class Reference

#include <xml_parser_restart.h>

Inheritance diagram for XMLRestartParser:

Inheritance graph
[legend]
Collaboration diagram for XMLRestartParser:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void AssignDispField (double x, double y, double z, double &ux, double &uy, double &uz)
void AssignForceField (double x, double y, double z, double &ux, double &uy, double &uz)
void AssignVelField (double x, double y, double z, double &ux, double &uy, double &uz)
bool IsDofRegistered (double x, double y, double z)
virtual int ParseFile (const char *name)
 XMLRestartParser ()

Protected Member Functions

void charHandler (const XML_Char *str, int len)
void endElement (const char *name)
void startElement (const char *name, const char **atts)

Private Member Functions

void manageA (char *s)
void manageP0 (char *s)
void manageU (char *s)
void manageV (char *s)
int readTriplet (Triplet &C, char *s)

Private Attributes

Base64Reader b64
 helper for base64
unsigned int cpt
int current_field
unsigned int Dim
std::map< Triplet, Triplet,
ComparateurTriplet
mapA
std::map< int, TripletmapP0
std::map< Triplet, Triplet,
ComparateurTriplet
mapU
std::map< Triplet, Triplet,
ComparateurTriplet
mapV
unsigned int nbDofs
double savedTime
int * tab_indexes
Triplet triplet
 temporary triplet (for incomlete lines)
int type

Detailed Description

Definition at line 146 of file xml_parser_restart.h.


Constructor & Destructor Documentation

XMLRestartParser::XMLRestartParser (  )  [inline]

Definition at line 150 of file xml_parser_restart.h.

References cpt, Dim, nbDofs, and savedTime.

00150                     {
00151     nbDofs = 0;
00152     Dim = 3;
00153     savedTime = 0;
00154     cpt = 0;
00155   };


Member Function Documentation

void XMLRestartParser::AssignDispField ( double  x,
double  y,
double  z,
double &  ux,
double &  uy,
double &  uz 
)

Definition at line 310 of file xml_parser_restart.cpp.

References Dim, mapU, and Triplet::Truncate().

Referenced by DomainAtomic< C >::ReadXMLFile(), and DomainContinuum< ContenerElems, ContenerNodes, Dim >::ReadXMLFile().

00310                                                                                                        {
00311   if (Dim < 3) z = 0;
00312   if (Dim == 1) y = 0;
00313   Triplet a(x,y,z);
00314   a.Truncate();
00315   Triplet &b = mapU[a];
00316   ux = b(0);
00317   uy = b(1);
00318   uz = b(2);
00319 };

Here is the call graph for this function:

void XMLRestartParser::AssignForceField ( double  x,
double  y,
double  z,
double &  ux,
double &  uy,
double &  uz 
)

Definition at line 332 of file xml_parser_restart.cpp.

References Dim, mapA, and Triplet::Truncate().

Referenced by DomainAtomic< C >::ReadXMLFile(), and DomainContinuum< ContenerElems, ContenerNodes, Dim >::ReadXMLFile().

00332                                                                                                         {
00333   if (Dim < 3) z = 0;
00334   if (Dim == 1) y = 0;
00335   Triplet a(x,y,z);
00336   a.Truncate();
00337   Triplet &b = mapA[a];
00338   ux = b(0);
00339   uy = b(1);
00340   uz = b(2);
00341 };

Here is the call graph for this function:

void XMLRestartParser::AssignVelField ( double  x,
double  y,
double  z,
double &  ux,
double &  uy,
double &  uz 
)

Definition at line 321 of file xml_parser_restart.cpp.

References Dim, mapV, and Triplet::Truncate().

Referenced by DomainAtomic< C >::ReadXMLFile(), and DomainContinuum< ContenerElems, ContenerNodes, Dim >::ReadXMLFile().

00321                                                                                                       {
00322   if (Dim < 3) z = 0;
00323   if (Dim == 1) y = 0;
00324   Triplet a(x,y,z);
00325   a.Truncate();
00326   Triplet &b = mapV[a];
00327   ux = b(0);
00328   uy = b(1);
00329   uz = b(2);
00330 };

Here is the call graph for this function:

void XMLRestartParser::charHandler ( const XML_Char *  str,
int  len 
) [protected, virtual]

Implements XMLParser.

Definition at line 91 of file xml_parser_restart.cpp.

References ACC, b64, XMLParser::buf, current_field, DBG_ALL, DEP, DUMP, manageA(), manageP0(), manageU(), manageV(), P0S, Base64Reader::SetStream(), TEXT, type, and VEL.

00091                                                               {
00092   char * buf;
00093     
00094   DUMP("read a line of size " << len,DBG_ALL);
00095   if (len == 0)
00096     return;
00097 
00098   buf = new char[len+1];
00099   
00100   strncpy(buf,str,len);
00101   
00102   if (type == TEXT)
00103     buf[len]='\0';
00104   else
00105     b64.SetStream(buf,len);
00106   
00107   if (buf[0] == '\n')
00108     return;
00109   
00110   //    DUMP("len = " << len);
00111   //DUMP("buf = " << buf);
00112   
00113   switch (current_field){
00114   case P0S: manageP0(buf);break;
00115   case DEP: manageU(buf);break;
00116   case VEL: manageV(buf);break;
00117   case ACC: manageA(buf);break;
00118   }
00119 
00120   delete [] buf;
00121 };

Here is the call graph for this function:

void XMLRestartParser::endElement ( const char *  name  )  [protected, virtual]

Implements XMLParser.

Definition at line 185 of file xml_parser_restart.cpp.

References ACC, cpt, current_field, DEP, FATAL, nbDofs, NONE, P0S, and VEL.

00185                                                   {
00186   
00187   char message[256];
00188   
00189   switch (current_field){
00190   case P0S: sprintf(message,"%s : in vector P0s ",name);break;
00191   case DEP: sprintf(message,"%s : in vector Us ",name);break;
00192   case VEL: sprintf(message,"%s : in vector Vs ",name);break;
00193   case ACC: sprintf(message,"%s : in vector As ",name);break;
00194   }
00195   current_field = NONE;
00196   
00197   if (cpt != 0 && cpt != nbDofs)
00198     FATAL(message << ": values number do not concord (read " << cpt << " should be " << nbDofs << ")");
00199 };

bool XMLRestartParser::IsDofRegistered ( double  x,
double  y,
double  z 
)

Definition at line 277 of file xml_parser_restart.cpp.

References DBG_ALL, Dim, DUMP, FORMATREAL, mapU, Triplet::Truncate(), Triplet::tx, Triplet::ty, and Triplet::tz.

Referenced by DomainAtomic< C >::ReadXMLFile(), and DomainContinuum< ContenerElems, ContenerNodes, Dim >::ReadXMLFile().

00277                                                                  {
00278   double epsilon2 = .8e-10*.8e-10;
00279 
00280   if (Dim < 3) z = 0;
00281   if (Dim == 1) y = 0;
00282   Triplet a(x,y,z);
00283   a.Truncate();
00284   if (mapU.count(a) == 0) {
00285     std::map<Triplet,Triplet>::iterator pos;
00286     DUMP("testing if already registered with the position " << a,DBG_ALL);  
00287     pos = find_if(mapU.begin(),mapU.end(),close_enough(a));
00288   
00289     if(pos != mapU.end()){
00290       Triplet found = pos->first; 
00291       double dx = a(0) - found(0);
00292       double dy = a(1) - found(1);
00293       double dz = a(2) - found(2);
00294 
00295       double rmin = dx*dx + dy*dy +dz*dz;
00296       DUMP("minimal distance = " << FORMATREAL(rmin) << " " << found(0) << " " << found(1) << " " << found(2),DBG_ALL);
00297       if ( rmin > epsilon2 ) return false;
00298       Triplet::tx = found(0) - x;Triplet::ty=found(1) - y;Triplet::tz=found(2) -z;
00299       DUMP("translation  " << FORMATREAL(Triplet::tx) << " " << Triplet::ty << " " << Triplet::tz,DBG_ALL);
00300       
00301       return true;
00302     }
00303     DUMP("Triplet not found :  " << a,DBG_ALL);      
00304     return false;
00305   }
00306   return true;
00307 };

Here is the call graph for this function:

void XMLRestartParser::manageA ( char *  s  )  [private]

Definition at line 267 of file xml_parser_restart.cpp.

References cpt, DBG_ALL, DUMP, mapA, mapP0, nbDofs, and readTriplet().

Referenced by charHandler().

00267                                       {
00268   Triplet a;
00269   while (readTriplet(a,s) && cpt < nbDofs){
00270     mapA[mapP0[cpt]] = a;
00271     DUMP(a(0) << " + " << a(1) << " + " << a(2) << " + " << cpt,DBG_ALL);
00272     ++cpt;    
00273   }
00274 };

Here is the call graph for this function:

void XMLRestartParser::manageP0 ( char *  s  )  [private]

Definition at line 238 of file xml_parser_restart.cpp.

References cpt, DBG_ALL, DUMP, mapP0, nbDofs, readTriplet(), and Triplet::Truncate().

Referenced by charHandler().

00238                                        {
00239   Triplet C;
00240   while (readTriplet(C,s) && cpt < nbDofs){
00241     C.Truncate();
00242     mapP0[cpt] = C;
00243     DUMP(C(0) << " " << C(1) << " " << C(2) << " " << cpt,DBG_ALL);
00244     ++cpt;    
00245   }
00246 };

Here is the call graph for this function:

void XMLRestartParser::manageU ( char *  s  )  [private]

Definition at line 249 of file xml_parser_restart.cpp.

References cpt, DBG_ALL, DUMP, mapP0, mapU, nbDofs, and readTriplet().

Referenced by charHandler().

00249                                       {
00250   Triplet u;
00251   while (readTriplet(u,s) && cpt < nbDofs){
00252     mapU[mapP0[cpt]] = u;
00253     DUMP(u(0) << " + " << u(1) << " + " << u(2) << " + " << cpt,DBG_ALL);
00254     ++cpt;    
00255   }
00256 };

Here is the call graph for this function:

void XMLRestartParser::manageV ( char *  s  )  [private]

Definition at line 258 of file xml_parser_restart.cpp.

References cpt, DBG_ALL, DUMP, mapP0, mapV, nbDofs, and readTriplet().

Referenced by charHandler().

00258                                       {
00259   Triplet v;
00260   while (readTriplet(v,s) && cpt < nbDofs){
00261     mapV[mapP0[cpt]] = v;
00262     DUMP(v(0) << " + " << v(1) << " + " << v(2) << " + " << cpt,DBG_ALL);
00263     ++cpt;    
00264   }
00265 };

Here is the call graph for this function:

virtual int XMLRestartParser::ParseFile ( const char *  name  )  [inline, virtual]

Reimplemented from XMLParser.

Definition at line 158 of file xml_parser_restart.h.

References XMLParser::ParseFile().

Referenced by DomainAtomic< C >::ReadXMLFile(), and DomainContinuum< ContenerElems, ContenerNodes, Dim >::ReadXMLFile().

00158                                           {
00159     XMLParser::ParseFile(name);
00160 
00161     return 0;
00162   }

Here is the call graph for this function:

int XMLRestartParser::readTriplet ( Triplet C,
char *  s 
) [private]

Definition at line 201 of file xml_parser_restart.cpp.

References b64, BINARY, DBG_ALL, DUMP, Triplet::getRead(), Base64Reader::PopDoubleInBase64(), TEXT, triplet, and type.

Referenced by manageA(), manageP0(), manageU(), and manageV().

00201                                                      {
00202   if (type == TEXT){
00203     std::istringstream str(s);
00204     char tmp[256];
00205     if (triplet.getRead() == 0 && str >> tmp) {
00206       triplet(0) = atof(tmp);
00207       triplet.getRead()++;
00208     }
00209     else return 0;
00210     if (triplet.getRead() == 1 && str >> tmp) {
00211       triplet(1) = atof(tmp); 
00212       triplet.getRead()++;
00213     }
00214     else return 0;
00215     if (triplet.getRead() == 2 && str >> tmp) {
00216       triplet(2) = atof(tmp);
00217       triplet.getRead()++;
00218     }
00219     else return 0;
00220   }
00221 
00222   if (type == BINARY){
00223     for (int i = triplet.getRead() ; i < 3 ; ++i){
00224       DUMP("read " << triplet.getRead() << " " << i,DBG_ALL);
00225       triplet.getRead() += b64.PopDoubleInBase64(triplet(i)); 
00226       DUMP("read " << triplet.getRead() << " " << i,DBG_ALL);
00227       if (i+1 != triplet.getRead()) {DUMP("already red " << triplet.getRead() << " components of the triplet",DBG_ALL);return 0;}
00228     } 
00229   }
00230    
00231   C = triplet;
00232   triplet.getRead() = 0;
00233 
00234   return 1;
00235 }

Here is the call graph for this function:

void XMLRestartParser::startElement ( const char *  name,
const char **  atts 
) [protected, virtual]

Implements XMLParser.

Definition at line 124 of file xml_parser_restart.cpp.

References ACC, BINARY, cpt, current_field, DBG_INFO, DEP, Dim, DUMP, nbDofs, P0S, savedTime, tab_indexes, TEXT, type, and VEL.

00124                                                                      {
00125   int j;
00126   cpt=0;
00127   
00128   if (strcmp("SimulationData",name)==0){
00129     for (j=0; (j < 10  && atts[j] != NULL);++j){
00130       if (strcmp("dim",atts[j])==0){
00131         Dim = atoi(atts[j+1]);
00132         //printf("Dim = %d\n",data.Dim);
00133         ++j;
00134       }
00135       /*       if (strcmp("Unity",atts[j])==0){ */
00136       /*        if (strcmp("Real",atts[j+1])==0){ */
00137       /*          unit.SetReadUnits(UnitsConverter::AtomsUnits); */
00138       /*        } */
00139       /*        else if (strcmp("Atoms",atts[j+1])==0){ */
00140       
00141       /*        } */
00142       /*        ++j; */
00143       /*       } */
00144       if (strcmp("dataType",atts[j])==0){
00145         if (strcmp("TEXT",atts[j+1])==0){
00146           type = TEXT;
00147         }
00148         else type = BINARY;
00149         ++j;
00150       }
00151       if (strcmp("nbDofs",atts[j])==0){
00152         nbDofs = atoi(atts[j+1]);
00153         //printf("nbNodes = %d\n",data.nbNodes);
00154         ++j;
00155         tab_indexes = new int[nbDofs]; 
00156       }
00157       if (strcmp("savedTime",atts[j])==0){
00158         savedTime = atoi(atts[j+1]);
00159         //printf("nbNodes = %d\n",data.nbNodes);
00160         ++j;
00161       }
00162     }
00163   }
00164   if (strcmp("P0",name)==0){
00165     current_field = P0S;
00166     DUMP("reading intial positions",DBG_INFO);
00167   }
00168   if (strcmp("U",name)==0){
00169     current_field = DEP;
00170     DUMP("reading displacements",DBG_INFO);
00171   }
00172   if (strcmp("V",name)==0){
00173     current_field = VEL;
00174     DUMP("reading velocities",DBG_INFO);
00175   }
00176   if (strcmp("A",name)==0){
00177     current_field = ACC;
00178     DUMP("reading accelerations",DBG_INFO);
00179   }
00180   
00181   
00182 };


Member Data Documentation

Base64Reader XMLRestartParser::b64 [private]

helper for base64

Definition at line 196 of file xml_parser_restart.h.

Referenced by charHandler(), and readTriplet().

unsigned int XMLRestartParser::cpt [private]

Definition at line 192 of file xml_parser_restart.h.

Referenced by endElement(), manageA(), manageP0(), manageU(), manageV(), startElement(), and XMLRestartParser().

int XMLRestartParser::current_field [private]

Definition at line 191 of file xml_parser_restart.h.

Referenced by charHandler(), endElement(), and startElement().

unsigned int XMLRestartParser::Dim [private]

Definition at line 186 of file xml_parser_restart.h.

Referenced by AssignDispField(), AssignForceField(), AssignVelField(), IsDofRegistered(), startElement(), and XMLRestartParser().

std::map<Triplet,Triplet,ComparateurTriplet> XMLRestartParser::mapA [private]

Definition at line 201 of file xml_parser_restart.h.

Referenced by AssignForceField(), and manageA().

std::map<int,Triplet> XMLRestartParser::mapP0 [private]

Definition at line 202 of file xml_parser_restart.h.

Referenced by manageA(), manageP0(), manageU(), and manageV().

std::map<Triplet,Triplet,ComparateurTriplet> XMLRestartParser::mapU [private]

Definition at line 199 of file xml_parser_restart.h.

Referenced by AssignDispField(), IsDofRegistered(), and manageU().

std::map<Triplet,Triplet,ComparateurTriplet> XMLRestartParser::mapV [private]

Definition at line 200 of file xml_parser_restart.h.

Referenced by AssignVelField(), and manageV().

unsigned int XMLRestartParser::nbDofs [private]

Definition at line 187 of file xml_parser_restart.h.

Referenced by endElement(), manageA(), manageP0(), manageU(), manageV(), startElement(), and XMLRestartParser().

double XMLRestartParser::savedTime [private]

Definition at line 188 of file xml_parser_restart.h.

Referenced by startElement(), and XMLRestartParser().

int* XMLRestartParser::tab_indexes [private]

Definition at line 189 of file xml_parser_restart.h.

Referenced by startElement().

Triplet XMLRestartParser::triplet [private]

temporary triplet (for incomlete lines)

Definition at line 184 of file xml_parser_restart.h.

Referenced by readTriplet().

int XMLRestartParser::type [private]

Definition at line 193 of file xml_parser_restart.h.

Referenced by charHandler(), readTriplet(), and startElement().


The documentation for this class was generated from the following files:
Generated on Fri Sep 7 13:13:30 2007 for LibMultiScale by  doxygen 1.5.2