~esys-p-dev/esys-particle/trunk

« back to all changes in this revision

Viewing changes to Parallel/ParserLmInitialiser.cpp

  • Committer: slatham
  • Date: 2005-01-15 05:09:37 UTC
  • Revision ID: svn-v4:1ddc92f8-1f06-0410-a909-b11019f1b28a:lsmtrunk:573
Moved OpValue dependencies in CLatticeMaster to ParserLmInitialiser.cpp classes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
#include "Parallel/ParserLmInitialiser.h"
18
18
#include "Parallel/LatticeMaster.h"
19
 
#include "console.h"
 
19
#include "Foundation/console.h"
 
20
 
 
21
#include <fstream>
 
22
#include <stdexcept>
20
23
 
21
24
// -- Parser Functions ----
22
25
 
31
34
      m_pLatticeMaster(&latticeMaster)
32
35
  {
33
36
  }
34
 
  
 
37
 
35
38
  LatticeMastererPredefFn(
36
39
    int argc,
37
40
    OpValue::OType itype,
134
137
      args->Next() ;
135
138
    }
136
139
    ISVALID_PTR(m_pLatticeMaster) ;
137
 
    getLatticeMaster().addBondedTriMeshIG(name,meshname,k,break_dist,build,buildparams);
 
140
    addBondedTriMeshIG(name,meshname,k,break_dist,build,buildparams);
138
141
    SParserAccess::Interface()->SetAllValues() ;
139
142
    return OpValue(1L) ;
140
143
  } ;
141
 
} ;
 
144
 
 
145
  /*!
 
146
    add a group of bonded triangle mesh (surface) to particle interactions
 
147
  
 
148
      \param name the name of the itneraction group
 
149
      \param meshname the name of the mesh
 
150
      \param k spring constant
 
151
      \param r_break (relative) breaking distance
 
152
      \param buildtype the way to initially build the IG
 
153
      \param buildparam the parameters for building the IG
 
154
  */
 
155
  void addBondedTriMeshIG(const std::string& name,
 
156
                          const std::string& meshname,
 
157
                          double k,
 
158
                          double r_break,
 
159
                          const std::string& buildtype,
 
160
                          const std::list<OpValue> &buildparams)
 
161
  {
 
162
    console.XDebug() << "PF_AddBondedTriMeshIG::addBondedTriMeshIG\n";
 
163
  
 
164
    BTriMeshIP triMeshPrms;
 
165
 
 
166
    triMeshPrms.setName(name);
 
167
    triMeshPrms.setMeshName(meshname.c_str());
 
168
    triMeshPrms.k = k;
 
169
    triMeshPrms.brk = r_break;
 
170
 
 
171
    if (buildtype == TriMeshTagBuildPrms().getTypeString()) {
 
172
      console.XDebug() << "BuildByTag\n";
 
173
      // extract build parameters
 
174
      TriMeshTagBuildPrms buildPrms;
 
175
      list<OpValue>::const_iterator iter=buildparams.begin();
 
176
      buildPrms.m_tag = int(iter->Content.l); iter++; // tag
 
177
      buildPrms.m_mask = int(iter->Content.l); // mask
 
178
      getLatticeMaster().addBondedTriMeshIG(triMeshPrms, buildPrms);
 
179
    } else if (buildtype == TriMeshGapBuildPrms().getTypeString()) {
 
180
      list<OpValue>::const_iterator iter=buildparams.begin();
 
181
      TriMeshGapBuildPrms buildPrms;
 
182
      buildPrms.m_maxGap = iter->Content.d; // max. gap
 
183
      getLatticeMaster().addBondedTriMeshIG(triMeshPrms, buildPrms);
 
184
    } else {
 
185
      throw std::runtime_error(std::string("Unknown BTriMeshInteraction build type: ")+buildtype);
 
186
    }
 
187
    console.XDebug() << "end PF_AddBondedTriMeshIG::addBondedTriMeshIG\n";
 
188
  }
 
189
};
142
190
 
143
191
//---------
144
192
 
205
253
      params.push_back(OV);
206
254
      args->Next() ;
207
255
    }
208
 
    getLatticeMaster().addPairIG(type,name,params);     
 
256
    addPairIG(type, name, params);
209
257
    SParserAccess::Interface()->SetAllValues() ;
210
258
    return OpValue(1L) ;
211
259
  }
 
260
 
 
261
  void addPairIG(const std::string &type, const std::string &name, const list<OpValue> &params)
 
262
  {
 
263
    console.XDebug() << "PF_AddPIG::addPairIG\n";
 
264
 
 
265
    list<OpValue>::const_iterator iter=params.begin();     
 
266
    if (type == "Elastic") {
 
267
      CElasticIGP prms;
 
268
      prms.setName(name);
 
269
      prms.m_k    = iter->Content.d;
 
270
      getLatticeMaster().addPairIG(prms);
 
271
    } else if (type == "Friction") {
 
272
      CFrictionIGP prms;
 
273
      prms.setName(name);
 
274
      prms.k      = iter->Content.d; iter++; // k
 
275
      prms.mu     = iter->Content.d; iter++; // mu
 
276
      prms.k_s    = iter->Content.d; iter++; // k_s
 
277
      prms.dt     = iter->Content.d;         // dt
 
278
      getLatticeMaster().addPairIG(prms);
 
279
    } else if(type=="AdhesiveFriction"){
 
280
      CAdhesiveFrictionIGP prms;
 
281
      prms.setName(name);
 
282
      prms.k      = iter->Content.d; iter++; // k
 
283
      prms.mu     = iter->Content.d; iter++; // mu
 
284
      prms.k_s    = iter->Content.d; iter++; // k_s
 
285
      prms.dt     = iter->Content.d; iter++; // dt
 
286
      prms.r_cut  = iter->Content.d;         // r_cut
 
287
      getLatticeMaster().addPairIG(prms);
 
288
    } else if (type=="FractalFriction") {
 
289
      FractalFrictionIGP prms;
 
290
      prms.setName(name);
 
291
      prms.k      = iter->Content.d; iter++; // k
 
292
      prms.mu_0   = iter->Content.d; iter++; // mu_0
 
293
      prms.k_s    = iter->Content.d; iter++; // k_s
 
294
      prms.dt     = iter->Content.d; iter++; // dt
 
295
      prms.x0     = iter->Content.d; iter++; // x0
 
296
      prms.y0     = iter->Content.d; iter++; // y0
 
297
      prms.dx     = iter->Content.d; iter++; // dx
 
298
      prms.dy     = iter->Content.d; iter++; // dy
 
299
      prms.nx     = iter->Content.l; iter++;
 
300
      prms.ny     = iter->Content.l;
 
301
      prms.mu     = boost::shared_ptr<double>(new double[prms.nx*prms.ny]);
 
302
      // read coeff file and put it into buffer
 
303
      string ffname=string("Data/test1.frac"); //iter++;
 
304
      console.XDebug() << "frac file: " << ffname << "\n";
 
305
      std::ifstream infile(ffname.c_str());
 
306
      for(int i = 0; i < (prms.nx*prms.ny); i++) {
 
307
        double mu;
 
308
        infile >> mu;
 
309
        console.XDebug() << i << " : " << mu << "\n";
 
310
        (prms.mu.get())[i] = mu;
 
311
      }
 
312
      infile.close();
 
313
      getLatticeMaster().addPairIG(prms);
 
314
    } else {
 
315
      console.Error()<<"trying to add PIG of unknown type\n";
 
316
    }
 
317
    console.XDebug()<<"end PF_AddPIG::addPairIG\n";
 
318
  }
212
319
};
213
320
 
214
321
//---------
243
350
      params.push_back(OV);
244
351
      args->Next() ;
245
352
    }
246
 
    getLatticeMaster().addTriMeshIG(type,name,meshname,params); 
 
353
    addTriMeshIG(type,name,meshname,params);    
247
354
    SParserAccess::Interface()->SetAllValues() ;
248
355
    return OpValue(1L) ;
249
356
  }
 
357
 
 
358
  void addTriMeshIG(const std::string &type, const std::string &name, const std::string &meshname, const list<OpValue> &params)
 
359
  {
 
360
    console.XDebug() << "begin PF_AddTMIG::addTriMeshIG\n";
 
361
 
 
362
    if (type ==" Elastic") {
 
363
      console.XDebug() << "TriMeshIG is elastic\n";
 
364
      ETriMeshIP prms;
 
365
      list<OpValue>::const_iterator iter=params.begin();
 
366
      prms.setName(name);
 
367
      prms.k = iter->Content.d; // k
 
368
      getLatticeMaster().addTriMeshIG(prms);
 
369
    } else {
 
370
      throw std::runtime_error(std::string("Unknown TriMesh interaction type: ")+type);
 
371
    }
 
372
 
 
373
    console.XDebug() << "end CLatticeMaster::addTriMeshIG\n";
 
374
  }
250
375
};
251
376
 
252
377
//---------
322
447
      params.push_back(OV);
323
448
      args->Next() ;
324
449
    }
325
 
    getLatticeMaster().addSingleIG(type,name,params);   
 
450
    addSingleIG(type,name,params);      
326
451
    SParserAccess::Interface()->SetAllValues() ;
327
452
    return OpValue(1L) ;
328
453
  }
 
454
 
 
455
  void addSingleIG(const string& type, const string& name, list<OpValue> params)
 
456
  {
 
457
    console.XDebug()<<"PF_AddSIG::addSingleIG\n";
 
458
  
 
459
    if(type == "Gravity"){
 
460
  
 
461
      list<OpValue>::iterator iter=params.begin();
 
462
      const double x = iter->Content.d;
 
463
      iter++;
 
464
      const double y = iter->Content.d;
 
465
      iter++;
 
466
      const double z = iter->Content.d;
 
467
      
 
468
      getLatticeMaster().addSingleIG(esys::lsm::GravityIGP(name, Vec3(x, y, z)));
 
469
    } else {
 
470
      throw std::runtime_error(
 
471
        std::string("Unknown body force type: ")
 
472
        +
 
473
        type
 
474
      );
 
475
    }
 
476
    console.XDebug()<<"end PF_AddSIG::addSingleIG\n";
 
477
  }
329
478
};
330
479
 
331
480
//---------
760
909
      params.push_back(OV);
761
910
      args->Next() ;
762
911
    }
763
 
    getLatticeMaster().addDamping(type,params); 
 
912
    addDamping(type, params);   
764
913
    SParserAccess::Interface()->SetAllValues() ;
765
914
    return OpValue(1L) ;
766
915
  }
 
916
 
 
917
  /*!
 
918
    Add damping to a lattice. Send parameters to slaves
 
919
  */
 
920
  void addDamping(const string& type, const list<OpValue> &params)
 
921
  {
 
922
    console.XDebug() << "PF_AddDamping::addDamping\n";
 
923
 
 
924
    if (type == "Damping") {
 
925
      CDampingIGP igp;
 
926
      list<OpValue>::const_iterator iter=params.begin();
 
927
      igp.setName("damp");
 
928
      igp.setVRef(Vec3(0.0,0.0,0.0));
 
929
      igp.setVisc(iter->Content.d);
 
930
      console.XDebug()<< "visc : " << iter->Content.d;
 
931
      iter++;
 
932
      igp.setTimeStep(iter->Content.d);
 
933
      console.XDebug()<< "dt : " << iter->Content.d;
 
934
      iter++;
 
935
      igp.setMaxIter(iter->Content.l);
 
936
      getLatticeMaster().addDamping(igp);
 
937
    }else{
 
938
      console.Error()<<"trying to add Damping of unknown type\n";
 
939
    }
 
940
    console.XDebug()<<"end PF_AddDamping::addDamping\n";
 
941
  }
767
942
};
768
943
 
769
944
 
1293
1468
  PF_AddRotPIG(CLatticeMaster &latticeMaster) : LatticeMastererPredefFn(UNLIMITED_ARGS, OpValue::NONE, latticeMaster)
1294
1469
  {
1295
1470
  };
 
1471
  
1296
1472
  OpValue fn(ExpressionNode *args) {
1297
1473
    string type;
1298
1474
    string name;
1322
1498
      params.push_back(OV);
1323
1499
      args->Next() ;
1324
1500
    }
1325
 
    getLatticeMaster().addRotPairIG(type,name,params);
 
1501
    addRotPairIG(type,name,params);
1326
1502
    console.XDebug() << "after TheLatticeMaster->addRotPairIG\n";
1327
1503
    SParserAccess::Interface()->SetAllValues() ;
1328
1504
    console.XDebug() << "##\n";
1329
1505
    return OpValue(1L) ;
1330
1506
  }
 
1507
  
 
1508
  void addRotPairIG(const string& type, const string& name, const list<OpValue> &params)
 
1509
  {
 
1510
    console.XDebug() << "PF_AddRotPIG::addRotPairIG\n";
 
1511
 
 
1512
    if (type == "RotElastic") {
 
1513
      console.Debug()<<"adding Rotelastic PIG\n";
 
1514
      console.XDebug()<< "name of the PIG is : " << name.c_str() << "\n";
 
1515
 
 
1516
      CRotElasticIGP prms;      
 
1517
      list<OpValue>::const_iterator iter=params.begin();
 
1518
      prms.setName(name);
 
1519
      prms.m_kr = iter->Content.d; // k
 
1520
      getLatticeMaster().addPairIG(prms);
 
1521
    } else if (type == "RotFriction") {
 
1522
      console.Debug()<<"adding friction PIG\n";
 
1523
      console.XDebug()<< "name of the PIG is : " << name.c_str() << "\n";
 
1524
      CRotFrictionIGP prms;
 
1525
      list<OpValue>::const_iterator iter=params.begin();
 
1526
      prms.setName(name);
 
1527
      prms.k    = iter->Content.d; iter++; // k
 
1528
      prms.mu_s = iter->Content.d; iter++; // mu_s
 
1529
      prms.mu_d = iter->Content.d; iter++; // mu_d
 
1530
      prms.k_s  = iter->Content.d; iter++; // k_s
 
1531
      prms.dt   = iter->Content.d; // dt
 
1532
      getLatticeMaster().addPairIG(prms);
 
1533
    } else {
 
1534
      console.Error()<<"trying to add PIG of unknown type\n";
 
1535
    }
 
1536
    console.XDebug()<<"end PF_AddRotPIG::addRotPairIG\n";
 
1537
  }
1331
1538
};
1332
1539
 
1333
1540
/*