66
67
else if((rec=="clumpids") || (rec=="clumpId")) recActive[REC_CLUMPID]=true;
67
68
else if(rec=="materialId") recActive[REC_MATERIALID]=true;
68
69
else if(rec=="stress") recActive[REC_STRESS]=true;
69
else LOG_ERROR("Unknown recorder named `"<<rec<<"' (supported are: all, spheres, velocity, facets, boxes, color, stress, cpm, rpm, wpm, intr, id, clumpId, materialId). Ignored.");
70
else if(rec=="jcfpm") recActive[REC_JCFPM]=true;
71
else if(rec=="cracks") recActive[REC_CRACKS]=true;
72
else if(rec=="pericell" && scene->isPeriodic) recActive[REC_PERICELL]=true;
73
else LOG_ERROR("Unknown recorder named `"<<rec<<"' (supported are: all, spheres, velocity, facets, boxes, color, stress, cpm, wpm, intr, id, clumpId, materialId, jcfpm, cracks, pericell). Ignored.");
71
75
// cpm needs interactions
72
76
if(recActive[REC_CPM]) recActive[REC_INTR]=true;
78
// jcfpm needs interactions
79
if(recActive[REC_JCFPM]) recActive[REC_INTR]=true;
74
81
// wpm needs interactions
75
82
if(recActive[REC_WPM]) recActive[REC_INTR]=true;
200
211
cpmStress->SetNumberOfComponents(9);
201
212
cpmStress->SetName("cpmStress");
204
vtkSmartPointer<vtkFloatArray> rpmSpecNum = vtkSmartPointer<vtkFloatArray>::New();
205
rpmSpecNum->SetNumberOfComponents(1);
206
rpmSpecNum->SetName("rpmSpecNum");
207
vtkSmartPointer<vtkFloatArray> rpmSpecMass = vtkSmartPointer<vtkFloatArray>::New();
208
rpmSpecMass->SetNumberOfComponents(1);
209
rpmSpecMass->SetName("rpmSpecMass");
210
vtkSmartPointer<vtkFloatArray> rpmSpecDiam = vtkSmartPointer<vtkFloatArray>::New();
211
rpmSpecDiam->SetNumberOfComponents(1);
212
rpmSpecDiam->SetName("rpmSpecDiam");
215
vtkSmartPointer<vtkFloatArray> damage = vtkSmartPointer<vtkFloatArray>::New();
216
damage->SetNumberOfComponents(1);;
217
damage->SetName("damage");
218
vtkSmartPointer<vtkFloatArray> damageRel = vtkSmartPointer<vtkFloatArray>::New();
219
damageRel->SetNumberOfComponents(1);;
220
damageRel->SetName("damageRel");
221
vtkSmartPointer<vtkFloatArray> intrIsCohesive = vtkSmartPointer<vtkFloatArray>::New();
222
intrIsCohesive->SetNumberOfComponents(1);
223
intrIsCohesive->SetName("isCohesive");
224
vtkSmartPointer<vtkFloatArray> intrIsOnJoint = vtkSmartPointer<vtkFloatArray>::New();
225
intrIsOnJoint->SetNumberOfComponents(1);
226
intrIsOnJoint->SetName("isOnJoint");
229
vtkSmartPointer<vtkPoints> crackPos = vtkSmartPointer<vtkPoints>::New();
230
vtkSmartPointer<vtkCellArray> crackCells = vtkSmartPointer<vtkCellArray>::New();
231
vtkSmartPointer<vtkFloatArray> iter = vtkSmartPointer<vtkFloatArray>::New();
232
iter->SetNumberOfComponents(1);
233
iter->SetName("iter");
234
vtkSmartPointer<vtkFloatArray> crackType = vtkSmartPointer<vtkFloatArray>::New();
235
crackType->SetNumberOfComponents(1);
236
crackType->SetName("crackType");
237
vtkSmartPointer<vtkFloatArray> crackSize = vtkSmartPointer<vtkFloatArray>::New();
238
crackSize->SetNumberOfComponents(1);
239
crackSize->SetName("crackSize");
240
vtkSmartPointer<vtkFloatArray> crackNorm = vtkSmartPointer<vtkFloatArray>::New();
241
crackNorm->SetNumberOfComponents(3);
242
crackNorm->SetName("crackNorm");
244
// // the same for newly created cracks
245
// vtkSmartPointer<vtkPoints> crackPosNew = vtkSmartPointer<vtkPoints>::New();
246
// vtkSmartPointer<vtkCellArray> crackCellsNew = vtkSmartPointer<vtkCellArray>::New();
247
// vtkSmartPointer<vtkFloatArray> iterNew = vtkSmartPointer<vtkFloatArray>::New();
248
// iterNew->SetNumberOfComponents(1);
249
// iterNew->SetName("iter");
250
// vtkSmartPointer<vtkFloatArray> crackTypeNew = vtkSmartPointer<vtkFloatArray>::New();
251
// crackTypeNew->SetNumberOfComponents(1);
252
// crackTypeNew->SetName("crackType");
253
// vtkSmartPointer<vtkFloatArray> crackSizeNew = vtkSmartPointer<vtkFloatArray>::New();
254
// crackSizeNew->SetNumberOfComponents(1);
255
// crackSizeNew->SetName("crackSize");
256
// vtkSmartPointer<vtkFloatArray> crackNormNew = vtkSmartPointer<vtkFloatArray>::New();
257
// crackNormNew->SetNumberOfComponents(3);
258
// crackNormNew->SetName("crackNorm");
214
260
// extras for WireMatPM
215
261
vtkSmartPointer<vtkFloatArray> wpmNormalForce = vtkSmartPointer<vtkFloatArray>::New();
216
262
wpmNormalForce->SetNumberOfComponents(1);
356
409
float s[9]={ (float) ss(0,0), (float) ss(0,1), (float) ss(0,2), (float) ss(1,0), (float) ss(1,1), (float) ss(1,2), (float) ss(2,0), (float) ss(2,1), (float) ss(2,2)};
357
410
cpmStress->InsertNextTupleValue(s);
359
if (recActive[REC_RPM]){
360
rpmSpecNum->InsertNextValue(YADE_PTR_CAST<RpmState>(b->state)->specimenNumber);
361
rpmSpecMass->InsertNextValue(YADE_PTR_CAST<RpmState>(b->state)->specimenMass);
362
rpmSpecDiam->InsertNextValue(YADE_PTR_CAST<RpmState>(b->state)->specimenMaxDiam);
413
if (recActive[REC_JCFPM]){
414
damage->InsertNextValue(YADE_PTR_CAST<JCFpmState>(b->state)->tensBreak + YADE_PTR_CAST<JCFpmState>(b->state)->shearBreak);
415
// damageRel->InsertNextValue(YADE_PTR_CAST<JCFpmState>(b->state)->tensBreakRel + YADE_PTR_CAST<JCFpmState>(b->state)->shearBreakRel);
365
418
if (recActive[REC_MATERIALID]) spheresMaterialId->InsertNextValue(b->material->id);
507
if (recActive[REC_PERICELL]) {
508
const Matrix3r& hSize = scene->cell->hSize;
509
Vector3r v0 = hSize*Vector3r(0,0,1);
510
Vector3r v1 = hSize*Vector3r(0,1,1);
511
Vector3r v2 = hSize*Vector3r(1,1,1);
512
Vector3r v3 = hSize*Vector3r(1,0,1);
513
Vector3r v4 = hSize*Vector3r(0,0,0);
514
Vector3r v5 = hSize*Vector3r(0,1,0);
515
Vector3r v6 = hSize*Vector3r(1,1,0);
516
Vector3r v7 = hSize*Vector3r(1,0,0);
517
pericellPoints->InsertNextPoint(v0[0],v0[1],v0[2]);
518
pericellPoints->InsertNextPoint(v1[0],v1[1],v1[2]);
519
pericellPoints->InsertNextPoint(v2[0],v2[1],v2[2]);
520
pericellPoints->InsertNextPoint(v3[0],v3[1],v3[2]);
521
pericellPoints->InsertNextPoint(v4[0],v4[1],v4[2]);
522
pericellPoints->InsertNextPoint(v5[0],v5[1],v5[2]);
523
pericellPoints->InsertNextPoint(v6[0],v6[1],v6[2]);
524
pericellPoints->InsertNextPoint(v7[0],v7[1],v7[2]);
525
vtkSmartPointer<vtkHexahedron> h = vtkSmartPointer<vtkHexahedron>::New();
526
vtkIdList* l = h->GetPointIds();
527
for (int i=0; i<8; i++) {
530
pericellHexa->InsertNextCell(h);
455
534
vtkSmartPointer<vtkDataCompressor> compressor;
456
535
if(compress) compressor=vtkSmartPointer<vtkZLibDataCompressor>::New();
656
vtkSmartPointer<vtkUnstructuredGrid> pericellUg = vtkSmartPointer<vtkUnstructuredGrid>::New();
657
if (recActive[REC_PERICELL]){
658
pericellUg->SetPoints(pericellPoints);
659
pericellUg->SetCells(12,pericellHexa);
660
#ifdef YADE_VTK_MULTIBLOCK
664
vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer = vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New();
665
if(compress) writer->SetCompressor(compressor);
666
if(ascii) writer->SetDataModeToAscii();
667
string fn=fileName+"pericell."+lexical_cast<string>(scene->iter)+".vtu";
668
writer->SetFileName(fn.c_str());
669
writer->SetInput(pericellUg);
674
if (recActive[REC_CRACKS]) {
675
std::ifstream file ("cracks.txt",std::ios::in);
676
vtkSmartPointer<vtkUnstructuredGrid> crackUg = vtkSmartPointer<vtkUnstructuredGrid>::New();
677
vtkSmartPointer<vtkUnstructuredGrid> crackUgNew = vtkSmartPointer<vtkUnstructuredGrid>::New();
680
while ( !file.eof() ){
682
Real i,p0,p1,p2,t,s,n0,n1,n2;
683
while ( std::getline(file, line)/* writes into string "line", a line of file "file". To go along diff. lines*/ )
685
file >> i >> p0 >> p1 >> p2 >> t >> s >> n0 >> n1 >> n2;
687
pid[0] = crackPos->InsertNextPoint(p0, p1, p2);
688
crackCells->InsertNextCell(1,pid);
689
crackType->InsertNextValue(t);
690
crackSize->InsertNextValue(s);
691
iter->InsertNextValue(i);
692
float n[3] = { n0, n1, n2 };
693
crackNorm->InsertNextTupleValue(n);
694
// if (i > scene->iter - iterPeriod)
696
// pid[0] = crackPosNew->InsertNextPoint(p0, p1, p2);
697
// crackCellsNew->InsertNextCell(1,pid);
698
// crackTypeNew->InsertNextValue(t);
699
// crackSizeNew->InsertNextValue(s);
700
// iterNew->InsertNextValue(i);
701
// crackNormNew->InsertNextTupleValue(n);
709
crackUg->SetPoints(crackPos);
710
crackUg->SetCells(VTK_VERTEX, crackCells);
711
crackUg->GetPointData()->AddArray(iter);
712
crackUg->GetPointData()->AddArray(crackType);
713
crackUg->GetPointData()->AddArray(crackSize);
714
crackUg->GetPointData()->AddArray(crackNorm); //orientation of 2D glyphs does not match this direction (some work to do in order to have the good orientation)
716
/*crackUgNew->SetPoints(crackPosNew);
717
crackUgNew->SetCells(VTK_VERTEX, crackCellsNew);
718
crackUgNew->GetPointData()->AddArray(iterNew);
719
crackUgNew->GetPointData()->AddArray(crackTypeNew);
720
crackUgNew->GetPointData()->AddArray(crackSizeNew);
721
crackUgNew->GetPointData()->AddArray(crackNormNew); //same remark...*/
723
vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer = vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New();
724
if(compress) writer->SetCompressor(compressor);
725
if(ascii) writer->SetDataModeToAscii();
726
string fn=fileName+"cracks."+lexical_cast<string>(scene->iter)+".vtu";
727
writer->SetFileName(fn.c_str());
728
writer->SetInput(crackUg);
731
// fn=fileName+"newcracks."+lexical_cast<string>(scene->iter)+".vtu";
732
// writer->SetFileName(fn.c_str());
733
// writer->SetInput(crackUgNew);
575
737
#ifdef YADE_VTK_MULTIBLOCK
577
739
vtkSmartPointer<vtkMultiBlockDataSet> multiblockDataset = vtkSmartPointer<vtkMultiBlockDataSet>::New();