XMLElasticityParser Class Reference

#include <xml_parser_elast.h>

Inheritance diagram for XMLElasticityParser:

Inheritance graph
[legend]
Collaboration diagram for XMLElasticityParser:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual int ParseFile (char *name)
 XMLElasticityParser (DOFLibMesh &d, GhostedNumericVector< Number > &a)

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 manageMassMatrixX (char *s)
void manageMassMatrixY (char *s)
void manageMassMatrixZ (char *s)
void manageNodeIDs (char *s)
void manageP0 (char *s)
void manageU (char *s)
void manageV (char *s)

Private Attributes

GhostedNumericVector< Number > & A
unsigned int cpt
int current_field
unsigned int Dim
DOFLibMeshdofs
unsigned int nbNodes
int * tab_indexes

Detailed Description

Definition at line 52 of file xml_parser_elast.h.


Constructor & Destructor Documentation

XMLElasticityParser::XMLElasticityParser ( DOFLibMesh d,
GhostedNumericVector< Number > &  a 
) [inline]

Definition at line 56 of file xml_parser_elast.h.

00056 :dofs(d),A(a){};


Member Function Documentation

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

Implements XMLParser.

Definition at line 75 of file xml_parser_elast.h.

References ACC, XMLParser::buf, current_field, DEP, IDS, manageA(), manageNodeIDs(), manageP0(), manageU(), manageV(), P0S, and VEL.

00075                                                 {
00076     char buf[512];
00077     
00078    
00079     if (len == 0)
00080       return;
00081 
00082     strncpy(buf,str,len);
00083     buf[len]='\0';
00084 
00085     if (buf[0] == '\n')
00086       return;
00087 
00088     //    DUMP("len = " << len);
00089     //DUMP("buf = " << buf);
00090 
00091     switch (current_field){
00092     case IDS: manageNodeIDs(buf);break;
00093     case P0S: manageP0(buf);break;
00094     case DEP: manageU(buf);break;
00095     case VEL: manageV(buf);break;
00096     case ACC: manageA(buf);break;
00097     }
00098   };

Here is the call graph for this function:

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

Implements XMLParser.

Definition at line 135 of file xml_parser_elast.h.

References ACC, cpt, current_field, DEP, FATAL, IDS, nbNodes, P0S, and VEL.

00135                                     {
00136 
00137     char message[256];
00138     
00139     switch (current_field){
00140     case IDS: sprintf(message,"%s : in vector IDs ",name);break;
00141     case P0S: sprintf(message,"%s : in vector P0s ",name);break;
00142     case DEP: sprintf(message,"%s : in vector Us ",name);break;
00143     case VEL: sprintf(message,"%s : in vector Vs ",name);break;
00144     case ACC: sprintf(message,"%s : in vector As ",name);break;
00145     }
00146     current_field = NOONE;
00147 
00148     if (cpt != 0 && cpt != nbNodes)
00149       FATAL(message << ": values number do not concord (read " << cpt << " should be " << nbNodes << ")");
00150   };

void XMLElasticityParser::manageA ( char *  s  )  [inline, private]

Definition at line 279 of file xml_parser_elast.h.

References A, cpt, DBG_ALL, Dim, DUMP, and tab_indexes.

Referenced by charHandler().

00279                         {
00280     double ax=0,ay=0,az=0;
00281     double tmp;
00282 
00283     std::istringstream str(s);
00284 
00285     int start = A.first_local_index();
00286     int last = A.last_local_index();
00287 
00288     while (str >> tmp){
00289       
00290       int index = tab_indexes[cpt]*Dim;
00291 
00292       ++cpt;
00293 
00294       //      DUMP("index = " << index);
00295       ax = tmp;
00296       if (Dim > 1 && str >> tmp) ay = tmp;
00297       if (Dim == 3 && str >> tmp) az = tmp;
00298 
00299       if (index < start ||  index >= last)
00300         continue;
00301 
00302       A.set(index,ax);
00303       if (Dim > 1 )
00304         A.set(index+1,ay);
00305       if (Dim == 3)
00306         A.set(index+2,az);
00307 
00308       DUMP(ax << " " << ay << " " << az,DBG_ALL);
00309 
00310     }
00311 
00312     A.close();
00313   };

void XMLElasticityParser::manageMassMatrixX ( char *  s  )  [inline, private]

Definition at line 314 of file xml_parser_elast.h.

00314                                   {
00315     *s = 0;
00316   };

void XMLElasticityParser::manageMassMatrixY ( char *  s  )  [inline, private]

Definition at line 317 of file xml_parser_elast.h.

00317                                   {
00318     *s = 0;
00319   };

void XMLElasticityParser::manageMassMatrixZ ( char *  s  )  [inline, private]

Definition at line 320 of file xml_parser_elast.h.

00320                                   {
00321     *s = 0;
00322   };

void XMLElasticityParser::manageNodeIDs ( char *  s  )  [inline, private]

Definition at line 155 of file xml_parser_elast.h.

References cpt, and tab_indexes.

Referenced by charHandler().

00155                               {
00156     int id;
00157     
00158 
00159     std::istringstream str(s);
00160 
00161     while (str >> id){
00162       tab_indexes[cpt] = id;
00163       ++cpt;
00164       //      DUMP(id);
00165     }
00166 
00167   };

void XMLElasticityParser::manageP0 ( char *  s  )  [inline, private]

Definition at line 168 of file xml_parser_elast.h.

References cpt, DBG_ALL, Dim, dofs, DUMP, DOFLibMesh::P0(), and tab_indexes.

Referenced by charHandler().

00168                          {
00169     double x=0,y=0,z=0;
00170     double xold=0,yold=0,zold=0;
00171     char tmp[256];
00172 
00173     std::istringstream str(s);
00174 
00175     GhostedNumericVector<Number> & P0 = dofs.P0();
00176     int start = P0.first_local_index();
00177     int last = P0.last_local_index();
00178 
00179     while (str >> tmp){
00180       
00181       int index = tab_indexes[cpt]*Dim;
00182       ++cpt;
00183 
00184       //      DUMP("index = " << index);
00185       xold = atof(tmp);
00186       if (Dim > 1 && str >> tmp) yold = atof(tmp);
00187       if (Dim == 3 && str >> tmp) zold = atof(tmp);
00188 
00189       if (index < start ||  index >= last) continue;
00190 
00191       x = P0[index];
00192       if (Dim > 1)
00193         y = P0[index+1];
00194       if (Dim == 3)
00195         z = P0[index+2];
00196 
00197       DUMP(x << " " << y << " " << z << " " << xold << " " << yold << " " << zold,DBG_ALL);
00198 
00199 /*       if (ipow(x - xold,2) + ipow(y - yold,2) + ipow(z - zold,2) > ) */
00200 /*      FATAL("there seems to have a trouble beetween restart file and loaded simulation (are they equivalent ?)"); */
00201 
00202     }
00203     
00204   };

Here is the call graph for this function:

void XMLElasticityParser::manageU ( char *  s  )  [inline, private]

Definition at line 205 of file xml_parser_elast.h.

References cpt, DBG_ALL, Dim, dofs, DUMP, tab_indexes, and DOFLibMesh::U().

Referenced by charHandler().

00205                         {
00206     double ux=0,uy=0,uz=0;
00207     double tmp;
00208 
00209     std::istringstream str(s);
00210 
00211     GhostedNumericVector<Number> & U = dofs.U();
00212     int start = U.first_local_index();
00213     int last = U.last_local_index();
00214 
00215     while (str >> tmp){
00216       
00217       int index = tab_indexes[cpt]*Dim;
00218 
00219       ++cpt;
00220 
00221       //      DUMP("index = " << index);
00222       ux = tmp;
00223       if (Dim > 1 && str >> tmp) uy = tmp;
00224       if (Dim == 3 && str >> tmp) uz = tmp;
00225 
00226       if (index < start ||  index >= last)
00227         continue;
00228 
00229       U.set(index,ux);
00230       if (Dim > 1)
00231         U.set(index+1,uy);
00232       if (Dim == 3)
00233         U.set(index+2,uz);
00234 
00235 
00236       DUMP(ux << " " << uy << " " << uz,DBG_ALL);
00237 
00238     }
00239 
00240     U.close();
00241   };

Here is the call graph for this function:

void XMLElasticityParser::manageV ( char *  s  )  [inline, private]

Definition at line 242 of file xml_parser_elast.h.

References cpt, DBG_ALL, Dim, dofs, DUMP, tab_indexes, and DOFLibMesh::V().

Referenced by charHandler().

00242                         {
00243     double vx=0,vy=0,vz=0;
00244     double tmp;
00245 
00246     std::istringstream str(s);
00247 
00248     GhostedNumericVector<Number> & V = dofs.V();
00249     int start = V.first_local_index();
00250     int last = V.last_local_index();
00251 
00252     while (str >> tmp){
00253       
00254       int index = tab_indexes[cpt]*Dim;
00255 
00256       DUMP("index = " << index,DBG_ALL);
00257 
00258       ++cpt;
00259 
00260       vx = tmp;
00261       if (Dim > 1 && str >> tmp) vy = tmp;
00262       if (Dim == 3 && str >> tmp) vz = tmp;
00263 
00264       if (index < start ||  index >= last)
00265         continue;
00266 
00267       V.set(index,vx);
00268       if (Dim > 1 )
00269         V.set(index+1,vy);
00270       if (Dim == 3) 
00271         V.set(index+2,vz);
00272 
00273       DUMP("setting v[" << index/Dim << "]" << vx << " " << vy << " " << vz,DBG_ALL);
00274 
00275     }
00276 
00277     V.close();
00278   };

Here is the call graph for this function:

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

Definition at line 59 of file xml_parser_elast.h.

References DBG_INFO, Dim, DUMP, nbNodes, and XMLParser::ParseFile().

00059                                     {
00060     XMLParser::ParseFile(name);
00061 
00062     DUMP("dimension read : " << Dim,DBG_INFO);
00063     DUMP("nbNodes read : " << nbNodes,DBG_INFO);
00064 
00065 /*     for (unsigned int i = 0 ; i < nbNodes ; ++i){ */
00066 /*       std::cout << tab_indexes[i] << " ";       */
00067 /*     } */
00068 /*     std::cout << std::endl; */
00069     return 0;
00070   }

Here is the call graph for this function:

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

Implements XMLParser.

Definition at line 100 of file xml_parser_elast.h.

References ACC, cpt, current_field, Dim, IDS, nbNodes, P0S, tab_indexes, and VEL.

00100                                                        {
00101     int j;
00102     cpt=0;
00103 
00104     if (strcmp("meshData",name)==0){
00105       for (j=0; (j < 10  && atts[j] != NULL);++j){
00106         if (strcmp("dim",atts[j])==0){
00107           Dim = atoi(atts[j+1]);
00108           //    printf("Dim = %d\n",data.Dim);
00109           ++j;
00110         }
00111         if (strcmp("nbNodes",atts[j])==0){
00112           nbNodes = atoi(atts[j+1]);
00113           //printf("nbNodes = %d\n",data.nbNodes);
00114           ++j;
00115           tab_indexes = new int[nbNodes]; 
00116         }
00117       }
00118     }
00119     if (strcmp("nodeIDs",name)==0){
00120       current_field = IDS;
00121     }
00122     if (strcmp("P0",name)==0){
00123       current_field = P0S;
00124     }
00125     if (strcmp("V",name)==0){
00126       current_field = VEL;
00127     }
00128     if (strcmp("A",name)==0){
00129       current_field = ACC;
00130     }
00131 
00132     
00133   };


Member Data Documentation

GhostedNumericVector<Number>& XMLElasticityParser::A [private]

Definition at line 332 of file xml_parser_elast.h.

Referenced by manageA().

unsigned int XMLElasticityParser::cpt [private]

Definition at line 329 of file xml_parser_elast.h.

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

int XMLElasticityParser::current_field [private]

Definition at line 328 of file xml_parser_elast.h.

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

unsigned int XMLElasticityParser::Dim [private]

Definition at line 322 of file xml_parser_elast.h.

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

DOFLibMesh& XMLElasticityParser::dofs [private]

Definition at line 331 of file xml_parser_elast.h.

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

unsigned int XMLElasticityParser::nbNodes [private]

Definition at line 325 of file xml_parser_elast.h.

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

int* XMLElasticityParser::tab_indexes [private]

Definition at line 326 of file xml_parser_elast.h.

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


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