MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / save

Method save

SRC/element/PFEMElement/PFEMMesher2D.cpp:1174–1241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1172}
1173
1174int
1175PFEMMesher2D::save(const char* filename, Domain* theDomain, int maxelenodes)
1176{
1177 if(theDomain == 0) {
1178 opserr<<"WARNING: null domain";
1179 opserr<<" -- PFEMMesher2D::save\n";
1180 return -1;
1181 }
1182
1183 // get nodes
1184 std::map<int,int> fluidNodes;
1185 ID regions;
1186 theDomain->getRegionTags(regions);
1187 getNodes(regions,fluidNodes,theDomain);
1188
1189 std::ofstream outfile(std::string(filename).append(".node").c_str());
1190 outfile<<theDomain->getCurrentTime()<<" ";
1191 for(int i=0; i<8; i++) outfile<<0<<" ";
1192 outfile<<"\n";
1193
1194 // write nodes
1195 for(std::map<int,int>::iterator it=fluidNodes.begin(); it!=fluidNodes.end(); it++) {
1196 int tag = it->first;
1197 int type = it->second;
1198 Node* node = theDomain->getNode(tag);
1199 if(node == 0) {
1200 opserr<<"WARNING: node "<<tag<<" dose not exist -- ";
1201 opserr<<" -- PFEMMesher2D::save\n";
1202 return -1;
1203 }
1204 const Vector& coord = node->getCrds();
1205 const Vector& disp = node->getDisp();
1206 const Vector& vel = node->getVel();
1207 const Vector& accel = node->getAccel();
1208 outfile<<tag<<" "<<coord(0)+disp(0)<<" "<<coord(1)+disp(1)<<" ";
1209 outfile<<type<<" ";
1210 outfile<<vel(0)<<" "<<vel(1)<<" "<<accel(0)<<" "<<accel(1);
1211 Pressure_Constraint* thePC = theDomain->getPressure_Constraint(tag);
1212 if(thePC != 0) {
1213 outfile<<" "<<thePC->getPressure()<<"\n";
1214 } else {
1215 outfile<<" "<<0<<"\n";
1216 }
1217 }
1218 outfile.close();
1219
1220 // write elements
1221 outfile.open(std::string(filename).append(".ele").c_str());
1222 ElementIter& theEles = theDomain->getElements();
1223 Element* theEle = 0;
1224 while((theEle = theEles()) != 0) {
1225 const ID& ntags = theEle->getExternalNodes();
1226 int num = 0;
1227 for(int i=0; i<ntags.Size(); i++) {
1228 if(fluidNodes.find(ntags(i)) != fluidNodes.end()) {
1229 outfile<<ntags(i)<<" ";
1230 num++;
1231 }

Callers

nothing calls this directly

Calls 15

getCrdsMethod · 0.80
getRegionTagsMethod · 0.45
appendMethod · 0.45
getCurrentTimeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getNodeMethod · 0.45
getDispMethod · 0.45
getVelMethod · 0.45
getAccelMethod · 0.45
getPressureMethod · 0.45

Tested by

no test coverage detected