| 224 | } |
| 225 | |
| 226 | int |
| 227 | PVDRecorder::pvd() |
| 228 | { |
| 229 | // open pvd file |
| 230 | theFile.close(); |
| 231 | std::string pvdname = pathname+basename+".pvd"; |
| 232 | |
| 233 | theFile.open(pvdname.c_str(), std::ios::trunc|std::ios::out); |
| 234 | if(theFile.fail()) { |
| 235 | opserr<<"WARNING: Failed to open file "<<pvdname.c_str()<<"\n"; |
| 236 | return -1; |
| 237 | } |
| 238 | theFile.precision(precision); |
| 239 | theFile << std::scientific; |
| 240 | |
| 241 | // header |
| 242 | theFile<<"<?xml version="<<quota<<"1.0"<<quota<<"?>\n"; |
| 243 | theFile<<"<VTKFile type="<<quota<<"Collection"<<quota; |
| 244 | theFile<<" compressor="<<quota<<"vtkZLibDataCompressor"<<quota; |
| 245 | theFile<<">\n"; |
| 246 | |
| 247 | // collection |
| 248 | this->incrLevel(); |
| 249 | this->indent(); |
| 250 | theFile<<"<Collection>\n"; |
| 251 | |
| 252 | // all data files |
| 253 | this->incrLevel(); |
| 254 | for(int i=0; i<(int)timestep.size(); i++) { |
| 255 | double t = timestep[i]; |
| 256 | const ID& partno = timeparts[i]; |
| 257 | for(int j=0; j<partno.Size(); j++) { |
| 258 | this->indent(); |
| 259 | theFile<<"<DataSet timestep="<<quota<<t<<quota; |
| 260 | theFile<<" group="<<quota<<quota; |
| 261 | theFile<<" part="<<quota<<partno(j)<<quota; |
| 262 | theFile<<" file="<<quota<<basename.c_str(); |
| 263 | theFile<<"/"<<basename.c_str()<<"_T"<<t<<"_P"; |
| 264 | theFile<<partno(j)<<".vtu"<<quota; |
| 265 | theFile<<"/>\n"; |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | // end colloection |
| 270 | this->decrLevel(); |
| 271 | this->indent(); |
| 272 | theFile<<"</Collection>\n"; |
| 273 | |
| 274 | // end VTKFile |
| 275 | this->decrLevel(); |
| 276 | this->indent(); |
| 277 | theFile<<"</VTKFile>\n"; |
| 278 | |
| 279 | theFile.close(); |
| 280 | |
| 281 | return 0; |
| 282 | } |
| 283 | |