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

Method write

SRC/runtime/commands/utilities/BinaryFileStream.cpp:245–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245int
246BinaryFileStream::write(Vector& data)
247{
248 if (fileOpen == 0)
249 this->open();
250
251 //
252 // if not parallel, just write the data
253 //
254
255 if (sendSelfCount == 0) {
256 (*this) << data;
257 return 0;
258 }
259
260 //
261 // otherwise parallel, send the data if not p0
262 //
263
264 if (sendSelfCount < 0) {
265 if (data.Size() != 0) {
266 return theChannels[0]->sendVector(0, 0, data);
267 } else
268 return 0;
269 }
270
271 //
272 // if p0 recv the data & write it out sorted
273 //
274
275 // recv data
276 for (int i = 0; i <= sendSelfCount; ++i) {
277 int numColumns = (*sizeColumns)(i);
278 double* dataI = theData[i];
279 if (i == 0) {
280 for (int j = 0; j < numColumns; j++) {
281 dataI[j] = data(j);
282 }
283 } else {
284 if (numColumns != 0) {
285 theChannels[i - 1]->recvVector(0, 0, *(theRemoteData[i]));
286 }
287 }
288 }
289
290 Matrix& printMapping = *mapping;
291
292 // write data
293 for (int i = 0; i < maxCount + 1; ++i) {
294 int fileID = (int)printMapping(0, i);
295 int startLoc = (int)printMapping(1, i);
296 int numData = (int)printMapping(2, i);
297 double* data = theData[fileID];
298 // for (int j=0; j<numData; j++)
299 theFile.write((char*)(&data[startLoc]), 8 * numData);
300 }
301 theFile << "\n";
302

Callers 3

textToBinaryFunction · 0.45
textToBinaryFunction · 0.45

Calls 4

openMethod · 0.95
SizeMethod · 0.45
sendVectorMethod · 0.45
recvVectorMethod · 0.45

Tested by

no test coverage detected