| 836 | } |
| 837 | |
| 838 | int |
| 839 | PVDRecorder::savePartParticle(int pno, int bgtag, int nodendf) |
| 840 | { |
| 841 | if (theDomain == 0) { |
| 842 | opserr<<"WARNING: setDomain has not been called -- PVDRecorder\n"; |
| 843 | return -1; |
| 844 | } |
| 845 | |
| 846 | // get time and part |
| 847 | std::stringstream ss; |
| 848 | ss.precision(precision); |
| 849 | ss << std::scientific; |
| 850 | ss << pno << ' ' << timestep.back(); |
| 851 | std::string stime, spart; |
| 852 | ss >> spart >> stime; |
| 853 | |
| 854 | // open file |
| 855 | theFile.close(); |
| 856 | std::string vtuname = pathname+basename+"/"+basename+"_T"+stime+"_P"+spart+".vtu"; |
| 857 | theFile.open(vtuname.c_str(), std::ios::trunc|std::ios::out); |
| 858 | if(theFile.fail()) { |
| 859 | opserr<<"WARNING: Failed to open file "<<vtuname.c_str()<<"\n"; |
| 860 | return -1; |
| 861 | } |
| 862 | theFile.precision(precision); |
| 863 | theFile << std::scientific; |
| 864 | |
| 865 | // header |
| 866 | theFile<<"<?xml version="<<quota<<"1.0"<<quota<<"?>\n"; |
| 867 | theFile<<"<VTKFile type="<<quota<<"UnstructuredGrid"<<quota; |
| 868 | theFile<<" version="<<quota<<"1.0"<<quota; |
| 869 | theFile<<" byte_order="<<quota<<"LittleEndian"<<quota; |
| 870 | theFile<<" compressor="<<quota<<"vtkZLibDataCompressor"<<quota; |
| 871 | theFile<<">\n"; |
| 872 | this->incrLevel(); |
| 873 | this->indent(); |
| 874 | theFile<<"<UnstructuredGrid>\n"; |
| 875 | |
| 876 | // get particles in group |
| 877 | VParticle particles; |
| 878 | ParticleGroup* group = dynamic_cast<ParticleGroup*>(OPS_getMesh(bgtag)); |
| 879 | if (group == 0) { |
| 880 | opserr << "WARNING: particle group "<<bgtag<<"doesn't exist\n"; |
| 881 | return -1; |
| 882 | } |
| 883 | for(int j=0; j<group->numParticles(); j++) { |
| 884 | Particle* p = group->getParticle(j); |
| 885 | if(p == 0) continue; |
| 886 | particles.push_back(p); |
| 887 | } |
| 888 | |
| 889 | // Piece |
| 890 | this->incrLevel(); |
| 891 | this->indent(); |
| 892 | theFile<<"<Piece NumberOfPoints="<<quota<<(int)particles.size()<<quota; |
| 893 | theFile<<" NumberOfCells="<<quota<<1<<quota<<">\n"; |
| 894 | |
| 895 | // points |
no test coverage detected