| 1223 | } |
| 1224 | |
| 1225 | int |
| 1226 | PVDRecorder::savePart(int partno, int ctag, int nodendf) |
| 1227 | { |
| 1228 | if (theDomain == 0) { |
| 1229 | opserr<<"WARNING: setDomain has not been called -- PVDRecorder\n"; |
| 1230 | return -1; |
| 1231 | } |
| 1232 | |
| 1233 | // get time and part |
| 1234 | std::stringstream ss; |
| 1235 | ss.precision(precision); |
| 1236 | ss << std::scientific; |
| 1237 | ss << partno << ' ' << timestep.back(); |
| 1238 | std::string stime, spart; |
| 1239 | ss >> spart >> stime; |
| 1240 | |
| 1241 | // open file |
| 1242 | theFile.close(); |
| 1243 | std::string vtuname = pathname+basename+"/"+basename+"_T"+stime+"_P"+spart+".vtu"; |
| 1244 | theFile.open(vtuname.c_str(), std::ios::trunc|std::ios::out); |
| 1245 | if(theFile.fail()) { |
| 1246 | opserr<<"WARNING: Failed to open file "<<vtuname.c_str()<<"\n"; |
| 1247 | return -1; |
| 1248 | } |
| 1249 | theFile.precision(precision); |
| 1250 | theFile << std::scientific; |
| 1251 | |
| 1252 | // header |
| 1253 | theFile<<"<?xml version="<<quota<<"1.0"<<quota<<"?>\n"; |
| 1254 | theFile<<"<VTKFile type="<<quota<<"UnstructuredGrid"<<quota; |
| 1255 | theFile<<" version="<<quota<<"1.0"<<quota; |
| 1256 | theFile<<" byte_order="<<quota<<"LittleEndian"<<quota; |
| 1257 | theFile<<" compressor="<<quota<<"vtkZLibDataCompressor"<<quota; |
| 1258 | theFile<<">\n"; |
| 1259 | this->incrLevel(); |
| 1260 | this->indent(); |
| 1261 | theFile<<"<UnstructuredGrid>\n"; |
| 1262 | |
| 1263 | // get nodes |
| 1264 | const ID& eletags = parts[ctag]; |
| 1265 | ID ndtags(0,eletags.Size()*3); |
| 1266 | std::vector<Element*> eles(eletags.Size()); |
| 1267 | int numelenodes = 0; |
| 1268 | int increlenodes = 1; |
| 1269 | for(int i=0; i<eletags.Size(); i++) { |
| 1270 | eles[i] = theDomain->getElement(eletags(i)); |
| 1271 | if (eles[i] == 0) { |
| 1272 | opserr<<"WARNING: element "<<eletags(i)<<" is not defined--pvdRecorder\n"; |
| 1273 | return -1; |
| 1274 | } |
| 1275 | const ID& elenodes = eles[i]->getExternalNodes(); |
| 1276 | if(numelenodes == 0) { |
| 1277 | numelenodes = elenodes.Size(); |
| 1278 | if(ctag==ELE_TAG_PFEMElement2D|| |
| 1279 | ctag==ELE_TAG_PFEMElement2DCompressible|| |
| 1280 | ctag==ELE_TAG_PFEMElement2DBubble|| |
| 1281 | ctag==ELE_TAG_PFEMElement2Dmini || |
| 1282 | ctag==ELE_TAG_MINI || |
no test coverage detected