------------------------------------------------------------------------------ Build the turbine towers Parse a blade file to set the number of cells and points in blades ------------------------------------------------------------------------------
| 385 | // Parse a blade file to set the number of cells and points in blades |
| 386 | //------------------------------------------------------------------------------ |
| 387 | void vtkPWindBladeReader::SetupBladeData() |
| 388 | { |
| 389 | if (!vtkMPIController::GetGlobalController()->IsA("vtkMPIController")) |
| 390 | { |
| 391 | this->Superclass::SetupBladeData(); |
| 392 | return; |
| 393 | } |
| 394 | |
| 395 | // Load the tower information |
| 396 | std::ostringstream fileName; |
| 397 | fileName << this->RootDirectory << "/" << this->TurbineDirectory << "/" << this->TurbineTowerName; |
| 398 | std::vector<char> inBuf(vtkWindBladeReader::LINE_SIZE); |
| 399 | |
| 400 | MPI_File tempFile; |
| 401 | char native[7] = "native"; |
| 402 | MPICall(MPI_File_open( |
| 403 | MPI_COMM_WORLD, fileName.str().c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &tempFile)); |
| 404 | |
| 405 | std::stringstream inStr; |
| 406 | MPI_Offset i, tempSize; |
| 407 | MPI_Status status; |
| 408 | |
| 409 | MPICall(MPI_File_get_size(tempFile, &tempSize)); |
| 410 | MPICall(MPI_File_set_view(tempFile, 0, MPI_BYTE, MPI_BYTE, native, MPI_INFO_NULL)); |
| 411 | |
| 412 | for (i = 0; i < tempSize; i = i + vtkWindBladeReader::LINE_SIZE) |
| 413 | { |
| 414 | if (i + vtkWindBladeReader::LINE_SIZE > tempSize) |
| 415 | { |
| 416 | MPICall(MPI_File_read_all(tempFile, inBuf.data(), tempSize - i, MPI_BYTE, &status)); |
| 417 | inStr.write(inBuf.data(), tempSize - i); |
| 418 | } |
| 419 | else |
| 420 | { |
| 421 | MPICall(MPI_File_read_all( |
| 422 | tempFile, inBuf.data(), vtkWindBladeReader::LINE_SIZE, MPI_BYTE, &status)); |
| 423 | inStr.write(inBuf.data(), vtkWindBladeReader::LINE_SIZE); |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | MPICall(MPI_File_close(&tempFile)); |
| 428 | |
| 429 | if (!inStr) |
| 430 | { |
| 431 | vtkWarningMacro("Could not open " << fileName.str() << endl); |
| 432 | } |
| 433 | |
| 434 | int numColumns = 0; |
| 435 | this->ReadBladeHeader(fileName.str(), inStr, numColumns); |
| 436 | |
| 437 | // Calculate the number of cells in unstructured turbine blades |
| 438 | std::ostringstream fileName2; |
| 439 | fileName2 << this->RootDirectory << "/" << this->TurbineDirectory << "/" << this->TurbineBladeName |
| 440 | << this->TimeStepFirst; |
| 441 | |
| 442 | MPICall(MPI_File_open( |
| 443 | MPI_COMM_WORLD, fileName2.str().c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &tempFile)); |
| 444 |