mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: eof errors in the STARCD, VTK file reader (#1059)
- previously simply read files until the input stream went bad and no
more lines could be read. With the more stringent checking of
values read (commit 0ce7e364a4) this approach causes problems.
Use the underlying tokenizer instead to decide about termination.
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -30,23 +30,27 @@ License
|
|||||||
#include "symmetryPolyPatch.H"
|
#include "symmetryPolyPatch.H"
|
||||||
#include "cellModel.H"
|
#include "cellModel.H"
|
||||||
#include "ListOps.H"
|
#include "ListOps.H"
|
||||||
|
#include "stringOps.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "IOMap.H"
|
#include "IOMap.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//! \cond fileScope
|
namespace Foam
|
||||||
//- Read and discard to newline
|
|
||||||
static void readToNewline(Foam::IFstream& is)
|
|
||||||
{
|
{
|
||||||
char ch = '\n';
|
|
||||||
do
|
// Read and discard to newline
|
||||||
|
static inline void readToNewline(ISstream& is)
|
||||||
{
|
{
|
||||||
(is).get(ch);
|
char ch = '\n';
|
||||||
|
do
|
||||||
|
{
|
||||||
|
is.get(ch);
|
||||||
|
}
|
||||||
|
while ((is) && ch != '\n');
|
||||||
}
|
}
|
||||||
while ((is) && ch != '\n');
|
|
||||||
}
|
} // End namespace Foam
|
||||||
//! \endcond
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -61,7 +65,7 @@ void Foam::fileFormats::STARCDMeshReader::readAux
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// read in the points from the .vrt file
|
// Read points from <.vrt> file
|
||||||
//
|
//
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Line 1:
|
Line 1:
|
||||||
@ -81,6 +85,7 @@ Foam::label Foam::fileFormats::STARCDMeshReader::readPoints
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
label nPoints = 0, maxId = 0;
|
label nPoints = 0, maxId = 0;
|
||||||
|
token tok;
|
||||||
|
|
||||||
// Pass 1:
|
// Pass 1:
|
||||||
// get # points and maximum vertex label
|
// get # points and maximum vertex label
|
||||||
@ -88,20 +93,22 @@ Foam::label Foam::fileFormats::STARCDMeshReader::readPoints
|
|||||||
IFstream is(inputName);
|
IFstream is(inputName);
|
||||||
readHeader(is, STARCDCore::HEADER_VRT);
|
readHeader(is, STARCDCore::HEADER_VRT);
|
||||||
|
|
||||||
label lineLabel;
|
|
||||||
scalar x, y, z;
|
scalar x, y, z;
|
||||||
|
|
||||||
while ((is >> lineLabel).good())
|
while (is.read(tok).good() && tok.isLabel())
|
||||||
{
|
{
|
||||||
nPoints++;
|
const label starVertexId = tok.labelToken();
|
||||||
maxId = max(maxId, lineLabel);
|
|
||||||
is >> x >> y >> z;
|
is >> x >> y >> z;
|
||||||
|
|
||||||
|
maxId = max(maxId, starVertexId);
|
||||||
|
++nPoints;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Number of points = " << nPoints << endl;
|
Info<< "Number of points = " << nPoints << endl;
|
||||||
|
|
||||||
// set sizes and reset to invalid values
|
// Set sizes and reset to invalid values
|
||||||
|
|
||||||
points_.setSize(nPoints);
|
points_.setSize(nPoints);
|
||||||
mapToFoamPointId_.setSize(maxId+1);
|
mapToFoamPointId_.setSize(maxId+1);
|
||||||
@ -116,24 +123,30 @@ Foam::label Foam::fileFormats::STARCDMeshReader::readPoints
|
|||||||
// Pass 2:
|
// Pass 2:
|
||||||
// construct pointList and conversion table
|
// construct pointList and conversion table
|
||||||
// from Star vertex numbers to Foam point labels
|
// from Star vertex numbers to Foam point labels
|
||||||
if (nPoints > 0)
|
if (!nPoints)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "no points in file " << inputName
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
IFstream is(inputName);
|
IFstream is(inputName);
|
||||||
readHeader(is, STARCDCore::HEADER_VRT);
|
readHeader(is, STARCDCore::HEADER_VRT);
|
||||||
|
|
||||||
label lineLabel;
|
|
||||||
|
|
||||||
label pointi = 0;
|
label pointi = 0;
|
||||||
while ((is >> lineLabel).good())
|
while (is.read(tok).good() && tok.isLabel())
|
||||||
{
|
{
|
||||||
|
const label starVertexId = tok.labelToken();
|
||||||
|
|
||||||
is >> points_[pointi].x()
|
is >> points_[pointi].x()
|
||||||
>> points_[pointi].y()
|
>> points_[pointi].y()
|
||||||
>> points_[pointi].z();
|
>> points_[pointi].z();
|
||||||
|
|
||||||
// might need again in the future
|
// might need again in the future
|
||||||
//// origPointId[pointi] = lineLabel;
|
//// origPointId[pointi] = starVertexId;
|
||||||
mapToFoamPointId_[lineLabel] = pointi;
|
mapToFoamPointId_[starVertexId] = pointi;
|
||||||
pointi++;
|
++pointi;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nPoints > pointi)
|
if (nPoints > pointi)
|
||||||
@ -144,23 +157,21 @@ Foam::label Foam::fileFormats::STARCDMeshReader::readPoints
|
|||||||
//// origPointId.setSize(nPoints);
|
//// origPointId.setSize(nPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scaleFactor > 1.0 + SMALL || scaleFactor < 1.0 - SMALL)
|
if
|
||||||
|
(
|
||||||
|
scaleFactor > 0
|
||||||
|
&& (scaleFactor > 1.0 + SMALL || scaleFactor < 1.0 - SMALL)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
points_ *= scaleFactor;
|
points_ *= scaleFactor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "no points in file " << inputName
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
return maxId;
|
return maxId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// read in the cells from the .cel file
|
// Read cells from <.cel> file
|
||||||
//
|
//
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Line 1:
|
Line 1:
|
||||||
@ -204,6 +215,7 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
|
|||||||
{
|
{
|
||||||
label nFluids = 0, nSolids = 0, nBaffles = 0, nShells = 0;
|
label nFluids = 0, nSolids = 0, nBaffles = 0, nShells = 0;
|
||||||
label maxId = 0;
|
label maxId = 0;
|
||||||
|
token tok;
|
||||||
|
|
||||||
bool unknownVertices = false;
|
bool unknownVertices = false;
|
||||||
|
|
||||||
@ -215,20 +227,21 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
|
|||||||
IFstream is(inputName);
|
IFstream is(inputName);
|
||||||
readHeader(is, STARCDCore::HEADER_CEL);
|
readHeader(is, STARCDCore::HEADER_CEL);
|
||||||
|
|
||||||
label lineLabel, shapeId, nLabels, cellTableId, typeId;
|
label shapeId, nLabels, cellTableId, typeId;
|
||||||
|
|
||||||
while ((is >> lineLabel).good())
|
while (is.read(tok).good() && tok.isLabel())
|
||||||
{
|
{
|
||||||
label starCellId = lineLabel;
|
const label starCellId = tok.labelToken();
|
||||||
|
|
||||||
is >> shapeId
|
is >> shapeId
|
||||||
>> nLabels
|
>> nLabels
|
||||||
>> cellTableId
|
>> cellTableId
|
||||||
>> typeId;
|
>> typeId;
|
||||||
|
|
||||||
// skip the rest of the line
|
// Skip the rest of the line
|
||||||
readToNewline(is);
|
readToNewline(is);
|
||||||
|
|
||||||
// max 8 indices per line
|
// Max 8 indices per line
|
||||||
while (nLabels > 0)
|
while (nLabels > 0)
|
||||||
{
|
{
|
||||||
readToNewline(is);
|
readToNewline(is);
|
||||||
@ -237,7 +250,7 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
|
|||||||
|
|
||||||
if (typeId == STARCDCore::starcdFluidType)
|
if (typeId == STARCDCore::starcdFluidType)
|
||||||
{
|
{
|
||||||
nFluids++;
|
++nFluids;
|
||||||
maxId = max(maxId, starCellId);
|
maxId = max(maxId, starCellId);
|
||||||
|
|
||||||
if (!cellTable_.found(cellTableId))
|
if (!cellTable_.found(cellTableId))
|
||||||
@ -248,7 +261,7 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
|
|||||||
}
|
}
|
||||||
else if (typeId == STARCDCore::starcdSolidType)
|
else if (typeId == STARCDCore::starcdSolidType)
|
||||||
{
|
{
|
||||||
nSolids++;
|
++nSolids;
|
||||||
if (keepSolids_)
|
if (keepSolids_)
|
||||||
{
|
{
|
||||||
maxId = max(maxId, starCellId);
|
maxId = max(maxId, starCellId);
|
||||||
@ -264,12 +277,12 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
|
|||||||
else if (typeId == STARCDCore::starcdBaffleType)
|
else if (typeId == STARCDCore::starcdBaffleType)
|
||||||
{
|
{
|
||||||
// baffles have no cellTable entry
|
// baffles have no cellTable entry
|
||||||
nBaffles++;
|
++nBaffles;
|
||||||
maxId = max(maxId, starCellId);
|
maxId = max(maxId, starCellId);
|
||||||
}
|
}
|
||||||
else if (typeId == STARCDCore::starcdShellType)
|
else if (typeId == STARCDCore::starcdShellType)
|
||||||
{
|
{
|
||||||
nShells++;
|
++nShells;
|
||||||
if (!cellTable_.found(cellTableId))
|
if (!cellTable_.found(cellTableId))
|
||||||
{
|
{
|
||||||
cellTable_.setName(cellTableId);
|
cellTable_.setName(cellTableId);
|
||||||
@ -336,14 +349,14 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
|
|||||||
readHeader(is, STARCDCore::HEADER_CEL);
|
readHeader(is, STARCDCore::HEADER_CEL);
|
||||||
|
|
||||||
labelList starLabels(64);
|
labelList starLabels(64);
|
||||||
label lineLabel, shapeId, nLabels, cellTableId, typeId;
|
label ignoredLabel, shapeId, nLabels, cellTableId, typeId;
|
||||||
|
|
||||||
label celli = 0;
|
label celli = 0, bafflei = 0;
|
||||||
label baffleI = 0;
|
|
||||||
|
|
||||||
while ((is >> lineLabel).good())
|
while (is.read(tok).good() && tok.isLabel())
|
||||||
{
|
{
|
||||||
label starCellId = lineLabel;
|
const label starCellId = tok.labelToken();
|
||||||
|
|
||||||
is >> shapeId
|
is >> shapeId
|
||||||
>> nLabels
|
>> nLabels
|
||||||
>> cellTableId
|
>> cellTableId
|
||||||
@ -355,17 +368,17 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
|
|||||||
}
|
}
|
||||||
starLabels = -1;
|
starLabels = -1;
|
||||||
|
|
||||||
// read indices - max 8 per line
|
// Read indices - max 8 per line
|
||||||
for (label i = 0; i < nLabels; ++i)
|
for (label i = 0; i < nLabels; ++i)
|
||||||
{
|
{
|
||||||
if ((i % 8) == 0)
|
if ((i % 8) == 0)
|
||||||
{
|
{
|
||||||
is >> lineLabel;
|
is >> ignoredLabel; // Skip cellId for continuation lines
|
||||||
}
|
}
|
||||||
is >> starLabels[i];
|
is >> starLabels[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip solid cells
|
// Skip solid cells
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
typeId == STARCDCore::starcdSolidType
|
typeId == STARCDCore::starcdSolidType
|
||||||
@ -375,7 +388,7 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine the OpenFOAM cell shape
|
// Determine the OpenFOAM cell shape
|
||||||
const cellModel* curModelPtr = nullptr;
|
const cellModel* curModelPtr = nullptr;
|
||||||
|
|
||||||
// fluid/solid cells
|
// fluid/solid cells
|
||||||
@ -432,7 +445,7 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
|
|||||||
);
|
);
|
||||||
|
|
||||||
cellFaces_[celli] = cellShapes_[celli].faces();
|
cellFaces_[celli] = cellShapes_[celli].faces();
|
||||||
celli++;
|
++celli;
|
||||||
}
|
}
|
||||||
else if (shapeId == STARCDCore::starcdPoly)
|
else if (shapeId == STARCDCore::starcdPoly)
|
||||||
{
|
{
|
||||||
@ -509,7 +522,7 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
|
|||||||
cellTableId_[celli] = cellTableId;
|
cellTableId_[celli] = cellTableId;
|
||||||
cellShapes_[celli] = genericShape;
|
cellShapes_[celli] = genericShape;
|
||||||
cellFaces_[celli] = faces;
|
cellFaces_[celli] = faces;
|
||||||
celli++;
|
++celli;
|
||||||
}
|
}
|
||||||
else if (typeId == STARCDCore::starcdBaffleType)
|
else if (typeId == STARCDCore::starcdBaffleType)
|
||||||
{
|
{
|
||||||
@ -547,16 +560,16 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
|
|||||||
// valid faces only
|
// valid faces only
|
||||||
if (f.size() >= 3)
|
if (f.size() >= 3)
|
||||||
{
|
{
|
||||||
baffleFaces_[baffleI] = f;
|
baffleFaces_[bafflei] = f;
|
||||||
// insert lookup addressing in normal list
|
// insert lookup addressing in normal list
|
||||||
mapToFoamCellId_[starCellId] = nCells + baffleI;
|
mapToFoamCellId_[starCellId] = nCells + bafflei;
|
||||||
origCellId_[nCells + baffleI] = starCellId;
|
origCellId_[nCells + bafflei] = starCellId;
|
||||||
baffleI++;
|
++bafflei;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
baffleFaces_.setSize(baffleI);
|
baffleFaces_.setSize(bafflei);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unknownVertices)
|
if (unknownVertices)
|
||||||
@ -577,7 +590,7 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// read in the boundaries from the .bnd file
|
// Read boundaries from <.bnd> file
|
||||||
//
|
//
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Line 1:
|
Line 1:
|
||||||
@ -603,7 +616,8 @@ void Foam::fileFormats::STARCDMeshReader::readBoundary
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
label nPatches = 0, nFaces = 0, nBafflePatches = 0, maxId = 0;
|
label nPatches = 0, nFaces = 0, nBafflePatches = 0, maxId = 0;
|
||||||
label lineLabel, starCellId, cellFaceId, starRegion, configNumber;
|
label starCellId, cellFaceId, starRegion, configNumber;
|
||||||
|
token tok;
|
||||||
word patchType;
|
word patchType;
|
||||||
|
|
||||||
labelList mapToFoamPatchId(1000, label(-1));
|
labelList mapToFoamPatchId(1000, label(-1));
|
||||||
@ -641,9 +655,12 @@ void Foam::fileFormats::STARCDMeshReader::readBoundary
|
|||||||
{
|
{
|
||||||
readHeader(is, STARCDCore::HEADER_BND);
|
readHeader(is, STARCDCore::HEADER_BND);
|
||||||
|
|
||||||
while ((is >> lineLabel).good())
|
while (is.read(tok).good() && tok.isLabel())
|
||||||
{
|
{
|
||||||
nFaces++;
|
// Ignore boundary id (not needed)
|
||||||
|
|
||||||
|
++nFaces;
|
||||||
|
|
||||||
is >> starCellId
|
is >> starCellId
|
||||||
>> cellFaceId
|
>> cellFaceId
|
||||||
>> starRegion
|
>> starRegion
|
||||||
@ -664,12 +681,12 @@ void Foam::fileFormats::STARCDMeshReader::readBoundary
|
|||||||
// should actually be case-insensitive
|
// should actually be case-insensitive
|
||||||
if (patchType == "BAFF")
|
if (patchType == "BAFF")
|
||||||
{
|
{
|
||||||
nBafflePatches++;
|
++nBafflePatches;
|
||||||
}
|
}
|
||||||
nPatches++;
|
++nPatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
nPatchFaces[patchLabel]++;
|
++nPatchFaces[patchLabel];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nPatches == 0)
|
if (nPatches == 0)
|
||||||
@ -684,7 +701,7 @@ void Foam::fileFormats::STARCDMeshReader::readBoundary
|
|||||||
}
|
}
|
||||||
|
|
||||||
// keep empty patch region in reserve
|
// keep empty patch region in reserve
|
||||||
nPatches++;
|
++nPatches;
|
||||||
Info<< "Number of patches = " << nPatches
|
Info<< "Number of patches = " << nPatches
|
||||||
<< " (including extra for missing)" << endl;
|
<< " (including extra for missing)" << endl;
|
||||||
|
|
||||||
@ -703,37 +720,22 @@ void Foam::fileFormats::STARCDMeshReader::readBoundary
|
|||||||
// - use 'Label' entry from "constant/boundaryRegion" dictionary
|
// - use 'Label' entry from "constant/boundaryRegion" dictionary
|
||||||
forAll(patchTypes_, patchi)
|
forAll(patchTypes_, patchi)
|
||||||
{
|
{
|
||||||
bool foundName = false, foundType = false;
|
bool fndName = false, fndType = false;
|
||||||
|
|
||||||
Map<dictionary>::const_iterator
|
auto iter = boundaryRegion_.cfind(origRegion[patchi]);
|
||||||
iter = boundaryRegion_.find(origRegion[patchi]);
|
|
||||||
|
|
||||||
if
|
if (iter.found())
|
||||||
(
|
|
||||||
iter != boundaryRegion_.end()
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
foundType = iter().readIfPresent
|
const dictionary& dict = *iter;
|
||||||
(
|
|
||||||
"BoundaryType",
|
|
||||||
patchTypes_[patchi]
|
|
||||||
);
|
|
||||||
|
|
||||||
foundName = iter().readIfPresent
|
fndType = dict.readIfPresent("BoundaryType", patchTypes_[patchi]);
|
||||||
(
|
fndName = dict.readIfPresent("Label", patchNames_[patchi]);
|
||||||
"Label",
|
|
||||||
patchNames_[patchi]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// consistent names, in long form and in lowercase
|
// Consistent names. Long form and in lowercase
|
||||||
if (!foundType)
|
if (!fndType)
|
||||||
{
|
{
|
||||||
// transform
|
stringOps::inplaceLower(patchTypes_[patchi]);
|
||||||
forAllIter(string, patchTypes_[patchi], i)
|
|
||||||
{
|
|
||||||
*i = tolower(*i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (patchTypes_[patchi] == "symp")
|
if (patchTypes_[patchi] == "symp")
|
||||||
{
|
{
|
||||||
@ -753,19 +755,19 @@ void Foam::fileFormats::STARCDMeshReader::readBoundary
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a name if needed
|
// Create a name if needed
|
||||||
if (!foundName)
|
if (!fndName)
|
||||||
{
|
{
|
||||||
patchNames_[patchi] =
|
patchNames_[patchi] =
|
||||||
patchTypes_[patchi] + "_" + name(origRegion[patchi]);
|
patchTypes_[patchi] + "_" + name(origRegion[patchi]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// enforce name "Default_Boundary_Region"
|
// Enforce name "Default_Boundary_Region"
|
||||||
patchNames_[nPatches-1] = defaultBoundaryName;
|
patchNames_[nPatches-1] = defaultBoundaryName;
|
||||||
|
|
||||||
// sort according to ascending region numbers, but leave
|
// Sort according to ascending region numbers, but leave
|
||||||
// Default_Boundary_Region as the final patch
|
// "Default_Boundary_Region" as the final patch
|
||||||
{
|
{
|
||||||
labelList sortedIndices;
|
labelList sortedIndices;
|
||||||
sortedOrder(SubList<label>(origRegion, nPatches-1), sortedIndices);
|
sortedOrder(SubList<label>(origRegion, nPatches-1), sortedIndices);
|
||||||
@ -829,8 +831,10 @@ void Foam::fileFormats::STARCDMeshReader::readBoundary
|
|||||||
IFstream is(inputName);
|
IFstream is(inputName);
|
||||||
readHeader(is, STARCDCore::HEADER_BND);
|
readHeader(is, STARCDCore::HEADER_BND);
|
||||||
|
|
||||||
while ((is >> lineLabel).good())
|
while (is.read(tok).good() && tok.isLabel())
|
||||||
{
|
{
|
||||||
|
// Ignore boundary id (not needed)
|
||||||
|
|
||||||
is
|
is
|
||||||
>> starCellId
|
>> starCellId
|
||||||
>> cellFaceId
|
>> cellFaceId
|
||||||
@ -885,8 +889,8 @@ void Foam::fileFormats::STARCDMeshReader::readBoundary
|
|||||||
#ifdef DEBUG_BOUNDARY
|
#ifdef DEBUG_BOUNDARY
|
||||||
Info<< "bnd " << cellId << " " << cellFaceId << endl;
|
Info<< "bnd " << cellId << " " << cellFaceId << endl;
|
||||||
#endif
|
#endif
|
||||||
// increment counter of faces in current patch
|
// Increment counter of faces in current patch
|
||||||
nPatchFaces[patchi]++;
|
++nPatchFaces[patchi];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -969,7 +973,7 @@ void Foam::fileFormats::STARCDMeshReader::cullPoints()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// the new ordering and the count of unused points
|
// The new ordering and the count of unused points
|
||||||
label pointi = 0;
|
label pointi = 0;
|
||||||
forAll(oldToNew, i)
|
forAll(oldToNew, i)
|
||||||
{
|
{
|
||||||
@ -979,30 +983,29 @@ void Foam::fileFormats::STARCDMeshReader::cullPoints()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// report unused points
|
// Report unused points
|
||||||
if (nPoints > pointi)
|
if (nPoints > pointi)
|
||||||
{
|
{
|
||||||
Info<< "Unused points = " << (nPoints - pointi) << endl;
|
Info<< "Unused points = " << (nPoints - pointi) << endl;
|
||||||
nPoints = pointi;
|
nPoints = pointi;
|
||||||
|
|
||||||
// adjust points and truncate
|
// Adjust points and truncate
|
||||||
inplaceReorder(oldToNew, points_);
|
inplaceReorder(oldToNew, points_);
|
||||||
points_.setSize(nPoints);
|
points_.setSize(nPoints);
|
||||||
|
|
||||||
// adjust cellFaces - with mesh shapes this might be faster
|
// Adjust cellFaces - with mesh shapes this might be faster
|
||||||
forAll(cellFaces_, celli)
|
for (faceList& faces : cellFaces_)
|
||||||
{
|
{
|
||||||
faceList& faces = cellFaces_[celli];
|
for (face& f : faces)
|
||||||
forAll(faces, i)
|
|
||||||
{
|
{
|
||||||
inplaceRenumber(oldToNew, faces[i]);
|
inplaceRenumber(oldToNew, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// adjust baffles
|
// Adjust baffles
|
||||||
forAll(baffleFaces_, facei)
|
for (face& f : baffleFaces_)
|
||||||
{
|
{
|
||||||
inplaceRenumber(oldToNew, baffleFaces_[facei]);
|
inplaceRenumber(oldToNew, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1051,10 +1054,4 @@ Foam::fileFormats::STARCDMeshReader::STARCDMeshReader
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::fileFormats::STARCDMeshReader::~STARCDMeshReader()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -71,15 +71,6 @@ class STARCDMeshReader
|
|||||||
bool keepSolids_;
|
bool keepSolids_;
|
||||||
|
|
||||||
|
|
||||||
// Private member functions
|
|
||||||
|
|
||||||
//- No copy construct
|
|
||||||
STARCDMeshReader(const STARCDMeshReader&) = delete;
|
|
||||||
|
|
||||||
//- No copy assignment
|
|
||||||
void operator=(const STARCDMeshReader&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Protected Data
|
// Protected Data
|
||||||
@ -126,15 +117,14 @@ public:
|
|||||||
STARCDMeshReader
|
STARCDMeshReader
|
||||||
(
|
(
|
||||||
const fileName& prefix,
|
const fileName& prefix,
|
||||||
const objectRegistry&,
|
const objectRegistry& registry,
|
||||||
const scalar scaleFactor = 1.0,
|
const scalar scaleFactor = 1.0,
|
||||||
const bool keepSolids = false
|
const bool keepSolids = false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~STARCDMeshReader();
|
virtual ~STARCDMeshReader() = default;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -24,9 +24,7 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "STARCDMeshWriter.H"
|
#include "STARCDMeshWriter.H"
|
||||||
|
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "SortableList.H"
|
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -35,7 +33,7 @@ Foam::label Foam::fileFormats::STARCDMeshWriter::findDefaultBoundary() const
|
|||||||
{
|
{
|
||||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
|
|
||||||
// find Default_Boundary_Region if it exists
|
// Find "Default_Boundary_Region" if it exists
|
||||||
forAll(patches, patchi)
|
forAll(patches, patchi)
|
||||||
{
|
{
|
||||||
if (defaultBoundaryName == patches[patchi].name())
|
if (defaultBoundaryName == patches[patchi].name())
|
||||||
@ -51,7 +49,7 @@ Foam::label Foam::fileFormats::STARCDMeshWriter::findDefaultBoundary() const
|
|||||||
|
|
||||||
void Foam::fileFormats::STARCDMeshWriter::getCellTable()
|
void Foam::fileFormats::STARCDMeshWriter::getCellTable()
|
||||||
{
|
{
|
||||||
// read constant/polyMesh/propertyName
|
// Read constant/polyMesh/propertyName
|
||||||
IOList<label> ioList
|
IOList<label> ioList
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
@ -112,9 +110,8 @@ void Foam::fileFormats::STARCDMeshWriter::getCellTable()
|
|||||||
// get the cellZone <-> cellTable correspondence
|
// get the cellZone <-> cellTable correspondence
|
||||||
Info<< "matching cellZones to cellTable" << endl;
|
Info<< "matching cellZones to cellTable" << endl;
|
||||||
|
|
||||||
forAll(mesh_.cellZones(), zoneI)
|
for (const cellZone& cZone : mesh_.cellZones())
|
||||||
{
|
{
|
||||||
const cellZone& cZone = mesh_.cellZones()[zoneI];
|
|
||||||
if (cZone.size())
|
if (cZone.size())
|
||||||
{
|
{
|
||||||
nUnzoned -= cZone.size();
|
nUnzoned -= cZone.size();
|
||||||
@ -129,9 +126,9 @@ void Foam::fileFormats::STARCDMeshWriter::getCellTable()
|
|||||||
tableId = cellTable_.append(dict);
|
tableId = cellTable_.append(dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(cZone, i)
|
for (const label celli : cZone)
|
||||||
{
|
{
|
||||||
cellTableId_[cZone[i]] = tableId;
|
cellTableId_[celli] = tableId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,7 +139,7 @@ void Foam::fileFormats::STARCDMeshWriter::getCellTable()
|
|||||||
|
|
||||||
dict.add("Label", "__unZonedCells__");
|
dict.add("Label", "__unZonedCells__");
|
||||||
dict.add("MaterialType", "fluid");
|
dict.add("MaterialType", "fluid");
|
||||||
label tableId = cellTable_.append(dict);
|
const label tableId = cellTable_.append(dict);
|
||||||
|
|
||||||
forAll(cellTableId_, i)
|
forAll(cellTableId_, i)
|
||||||
{
|
{
|
||||||
@ -205,36 +202,36 @@ void Foam::fileFormats::STARCDMeshWriter::writeCells
|
|||||||
const cellShape& shape = shapes[cellId];
|
const cellShape& shape = shapes[cellId];
|
||||||
const label mapIndex = shape.model().index();
|
const label mapIndex = shape.model().index();
|
||||||
|
|
||||||
// a registered primitive type
|
// A registered primitive type
|
||||||
if (shapeLookupIndex.found(mapIndex))
|
if (shapeLookupIndex.found(mapIndex))
|
||||||
{
|
{
|
||||||
const label shapeId = shapeLookupIndex[mapIndex];
|
const label shapeId = shapeLookupIndex[mapIndex];
|
||||||
const labelList& vrtList = shapes[cellId];
|
const labelList& vrtList = shapes[cellId];
|
||||||
|
|
||||||
os << cellId + 1
|
os << cellId + 1
|
||||||
<< " " << shapeId
|
<< ' ' << shapeId
|
||||||
<< " " << vrtList.size()
|
<< ' ' << vrtList.size()
|
||||||
<< " " << tableId
|
<< ' ' << tableId
|
||||||
<< " " << materialType;
|
<< ' ' << materialType;
|
||||||
|
|
||||||
// primitives have <= 8 vertices, but prevent overrun anyhow
|
// Primitives have <= 8 vertices, but prevent overrun anyhow
|
||||||
// indent following lines for ease of reading
|
// indent following lines for ease of reading
|
||||||
label count = 0;
|
label count = 0;
|
||||||
forAll(vrtList, i)
|
for (const label pointi : vrtList)
|
||||||
{
|
{
|
||||||
if ((count % 8) == 0)
|
if ((count % 8) == 0)
|
||||||
{
|
{
|
||||||
os << nl
|
os << nl
|
||||||
<< " " << cellId + 1;
|
<< " " << cellId + 1;
|
||||||
}
|
}
|
||||||
os << " " << vrtList[i] + 1;
|
os << ' ' << pointi + 1;
|
||||||
count++;
|
++count;
|
||||||
}
|
}
|
||||||
os << endl;
|
os << nl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// treat as general polyhedral
|
// Treat as general polyhedral
|
||||||
const label shapeId = STARCDCore::starcdPoly;
|
const label shapeId = STARCDCore::starcdPoly;
|
||||||
const labelList& cFaces = cells[cellId];
|
const labelList& cFaces = cells[cellId];
|
||||||
|
|
||||||
@ -251,29 +248,28 @@ void Foam::fileFormats::STARCDMeshWriter::writeCells
|
|||||||
}
|
}
|
||||||
|
|
||||||
os << cellId + 1
|
os << cellId + 1
|
||||||
<< " " << shapeId
|
<< ' ' << shapeId
|
||||||
<< " " << count
|
<< ' ' << count
|
||||||
<< " " << tableId
|
<< ' ' << tableId
|
||||||
<< " " << materialType;
|
<< ' ' << materialType;
|
||||||
|
|
||||||
// write indices - max 8 per line
|
// Write indices - max 8 per line
|
||||||
// indent following lines for ease of reading
|
// indent following lines for ease of reading
|
||||||
count = 0;
|
count = 0;
|
||||||
forAll(indices, i)
|
for (const label pointi : indices)
|
||||||
{
|
{
|
||||||
if ((count % 8) == 0)
|
if ((count % 8) == 0)
|
||||||
{
|
{
|
||||||
os << nl
|
os << nl
|
||||||
<< " " << cellId + 1;
|
<< " " << cellId + 1;
|
||||||
}
|
}
|
||||||
os << " " << indices[i];
|
os << ' ' << pointi;
|
||||||
count++;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write faces - max 8 per line
|
// write faces - max 8 per line
|
||||||
forAll(cFaces, facei)
|
for (const label meshFace : cFaces)
|
||||||
{
|
{
|
||||||
label meshFace = cFaces[facei];
|
|
||||||
face f;
|
face f;
|
||||||
|
|
||||||
if (owner[meshFace] == cellId)
|
if (owner[meshFace] == cellId)
|
||||||
@ -285,7 +281,7 @@ void Foam::fileFormats::STARCDMeshWriter::writeCells
|
|||||||
f = faces[meshFace].reverseFace();
|
f = faces[meshFace].reverseFace();
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(f, i)
|
for (const label pointi : f)
|
||||||
{
|
{
|
||||||
if ((count % 8) == 0)
|
if ((count % 8) == 0)
|
||||||
{
|
{
|
||||||
@ -293,8 +289,8 @@ void Foam::fileFormats::STARCDMeshWriter::writeCells
|
|||||||
<< " " << cellId + 1;
|
<< " " << cellId + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
os << " " << f[i] + 1;
|
os << ' ' << pointi + 1;
|
||||||
count++;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +345,7 @@ void Foam::fileFormats::STARCDMeshWriter::writeBoundary
|
|||||||
}
|
}
|
||||||
else if (defaultId == -1 || regionId < defaultId)
|
else if (defaultId == -1 || regionId < defaultId)
|
||||||
{
|
{
|
||||||
regionId++;
|
++regionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
label patchStart = patches[patchi].start();
|
label patchStart = patches[patchi].start();
|
||||||
@ -377,7 +373,7 @@ void Foam::fileFormats::STARCDMeshWriter::writeBoundary
|
|||||||
// as defined by primitiveMesh::cellShapes()
|
// as defined by primitiveMesh::cellShapes()
|
||||||
// Thus, for registered primitive types, do the lookup ourselves.
|
// Thus, for registered primitive types, do the lookup ourselves.
|
||||||
// Finally, the cellModel face number is re-mapped to the
|
// Finally, the cellModel face number is re-mapped to the
|
||||||
// STAR-CD local face number
|
// STARCD local face number
|
||||||
|
|
||||||
label mapIndex = shape.model().index();
|
label mapIndex = shape.model().index();
|
||||||
|
|
||||||
@ -400,15 +396,15 @@ void Foam::fileFormats::STARCDMeshWriter::writeBoundary
|
|||||||
}
|
}
|
||||||
// Info<< endl;
|
// Info<< endl;
|
||||||
|
|
||||||
boundId++;
|
++boundId;
|
||||||
|
|
||||||
os
|
os
|
||||||
<< boundId
|
<< boundId
|
||||||
<< " " << cellId + 1
|
<< ' ' << cellId + 1
|
||||||
<< " " << cellFaceId + 1
|
<< ' ' << cellFaceId + 1
|
||||||
<< " " << regionId
|
<< ' ' << regionId
|
||||||
<< " " << 0
|
<< ' ' << 0
|
||||||
<< " " << bndType.c_str()
|
<< ' ' << bndType.c_str()
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -433,12 +429,6 @@ Foam::fileFormats::STARCDMeshWriter::STARCDMeshWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::fileFormats::STARCDMeshWriter::~STARCDMeshWriter()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fileFormats::STARCDMeshWriter::write(const fileName& meshName) const
|
bool Foam::fileFormats::STARCDMeshWriter::write(const fileName& meshName) const
|
||||||
@ -461,7 +451,7 @@ bool Foam::fileFormats::STARCDMeshWriter::write(const fileName& meshName) const
|
|||||||
|
|
||||||
STARCDCore::removeFiles(baseName);
|
STARCDCore::removeFiles(baseName);
|
||||||
|
|
||||||
// points
|
// Points
|
||||||
{
|
{
|
||||||
OFstream os
|
OFstream os
|
||||||
(
|
(
|
||||||
@ -474,10 +464,10 @@ bool Foam::fileFormats::STARCDMeshWriter::write(const fileName& meshName) const
|
|||||||
writePoints(os, mesh_.points(), scaleFactor_);
|
writePoints(os, mesh_.points(), scaleFactor_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// cells
|
// Cells
|
||||||
writeCells(baseName);
|
writeCells(baseName);
|
||||||
|
|
||||||
// boundaries
|
// Boundaries
|
||||||
if (writeBoundary_)
|
if (writeBoundary_)
|
||||||
{
|
{
|
||||||
writeBoundary(baseName);
|
writeBoundary(baseName);
|
||||||
|
|||||||
@ -99,7 +99,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~STARCDMeshWriter();
|
virtual ~STARCDMeshWriter() = default;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -24,14 +24,9 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "STARCDCore.H"
|
#include "STARCDCore.H"
|
||||||
#include "ListOps.H"
|
|
||||||
#include "clock.H"
|
|
||||||
#include "bitSet.H"
|
|
||||||
#include "DynamicList.H"
|
#include "DynamicList.H"
|
||||||
#include "StringStream.H"
|
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const Foam::Enum
|
const Foam::Enum
|
||||||
@ -85,9 +80,41 @@ Foam::fileFormats::STARCDCore::starToFoamFaceAddr =
|
|||||||
{ starcdPyr, { 0, -1, 4, 2, 1, 3 } }
|
{ starcdPyr, { 0, -1, 4, 2, 1, 3 } }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Read and discard to newline
|
||||||
|
static inline void readToNewline(ISstream& is)
|
||||||
|
{
|
||||||
|
char ch = '\n';
|
||||||
|
do
|
||||||
|
{
|
||||||
|
is.get(ch);
|
||||||
|
}
|
||||||
|
while ((is) && ch != '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Read two-line header
|
||||||
|
//
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Line 1:
|
||||||
|
PROSTAR_(BOUNDARY|CELL|VERTEX) [newline]
|
||||||
|
|
||||||
|
Line 2:
|
||||||
|
<version> 0 0 0 0 0 0 0 [newline]
|
||||||
|
|
||||||
|
Body:
|
||||||
|
...
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
bool Foam::fileFormats::STARCDCore::readHeader
|
bool Foam::fileFormats::STARCDCore::readHeader
|
||||||
(
|
(
|
||||||
IFstream& is,
|
IFstream& is,
|
||||||
@ -100,23 +127,20 @@ bool Foam::fileFormats::STARCDCore::readHeader
|
|||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
word magic;
|
word magic;
|
||||||
|
is >> magic;
|
||||||
|
readToNewline(is);
|
||||||
|
|
||||||
label majorVersion;
|
label majorVersion;
|
||||||
|
is >> majorVersion;
|
||||||
|
readToNewline(is);
|
||||||
|
|
||||||
string line;
|
// Add other checks ...
|
||||||
|
|
||||||
is.getLine(line);
|
|
||||||
IStringStream(line)() >> magic;
|
|
||||||
|
|
||||||
is.getLine(line);
|
|
||||||
IStringStream(line)() >> majorVersion;
|
|
||||||
|
|
||||||
// add other checks ...
|
|
||||||
if (magic != fileHeaders_[header])
|
if (magic != fileHeaders_[header])
|
||||||
{
|
{
|
||||||
Info<< "header mismatch " << fileHeaders_[header]
|
Info<< "Header mismatch " << fileHeaders_[header]
|
||||||
<< " " << is.name()
|
<< " " << is.name()
|
||||||
<< endl;
|
<< nl;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -133,14 +157,14 @@ void Foam::fileFormats::STARCDCore::writeHeader
|
|||||||
{
|
{
|
||||||
os << fileHeaders_[header] << nl
|
os << fileHeaders_[header] << nl
|
||||||
<< 4000
|
<< 4000
|
||||||
<< " " << 0
|
<< ' ' << 0
|
||||||
<< " " << 0
|
<< ' ' << 0
|
||||||
<< " " << 0
|
<< ' ' << 0
|
||||||
<< " " << 0
|
<< ' ' << 0
|
||||||
<< " " << 0
|
<< ' ' << 0
|
||||||
<< " " << 0
|
<< ' ' << 0
|
||||||
<< " " << 0
|
<< ' ' << 0
|
||||||
<< endl;
|
<< nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -173,6 +197,7 @@ Foam::label Foam::fileFormats::STARCDCore::readPoints
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
label maxId = 0;
|
label maxId = 0;
|
||||||
|
token tok;
|
||||||
|
|
||||||
if (!is.good())
|
if (!is.good())
|
||||||
{
|
{
|
||||||
@ -183,24 +208,26 @@ Foam::label Foam::fileFormats::STARCDCore::readPoints
|
|||||||
|
|
||||||
readHeader(is, HEADER_VRT);
|
readHeader(is, HEADER_VRT);
|
||||||
|
|
||||||
// reuse memory if possible
|
// Reuse memory if possible
|
||||||
DynamicList<point> dynPoints(std::move(points));
|
DynamicList<point> dynPoints(std::move(points));
|
||||||
DynamicList<label> dynPointId(std::move(ids)); // STAR-CD index of points
|
DynamicList<label> dynPointId(std::move(ids)); // STARCD index of points
|
||||||
|
|
||||||
dynPoints.clear();
|
dynPoints.clear();
|
||||||
dynPointId.clear();
|
dynPointId.clear();
|
||||||
|
|
||||||
{
|
{
|
||||||
label lineLabel;
|
|
||||||
scalar x, y, z;
|
scalar x, y, z;
|
||||||
|
|
||||||
while ((is >> lineLabel).good())
|
while (is.read(tok).good() && tok.isLabel())
|
||||||
{
|
{
|
||||||
maxId = max(maxId, lineLabel);
|
const label starVertexId = tok.labelToken();
|
||||||
|
|
||||||
is >> x >> y >> z;
|
is >> x >> y >> z;
|
||||||
|
|
||||||
|
maxId = max(maxId, starVertexId);
|
||||||
|
|
||||||
dynPoints.append(point(x, y, z));
|
dynPoints.append(point(x, y, z));
|
||||||
dynPointId.append(lineLabel);
|
dynPointId.append(starVertexId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,18 +250,23 @@ void Foam::fileFormats::STARCDCore::writePoints
|
|||||||
// Set the precision of the points data to 10
|
// Set the precision of the points data to 10
|
||||||
os.precision(10);
|
os.precision(10);
|
||||||
|
|
||||||
// force decimal point for Fortran input
|
// Force decimal point for Fortran input
|
||||||
os.setf(std::ios::showpoint);
|
os.setf(std::ios::showpoint);
|
||||||
|
|
||||||
forAll(points, ptI)
|
label starVertId = 1; // 1-based vertex labels
|
||||||
|
|
||||||
|
for (const point& p : points)
|
||||||
{
|
{
|
||||||
// convert [m] -> [mm] etc
|
// Convert [m] -> [mm] etc
|
||||||
os
|
os
|
||||||
<< ptI + 1 << ' '
|
<< starVertId << ' '
|
||||||
<< scaleFactor * points[ptI].x() << ' '
|
<< scaleFactor * p.x() << ' '
|
||||||
<< scaleFactor * points[ptI].y() << ' '
|
<< scaleFactor * p.y() << ' '
|
||||||
<< scaleFactor * points[ptI].z() << '\n';
|
<< scaleFactor * p.z() << nl;
|
||||||
|
|
||||||
|
++starVertId;
|
||||||
}
|
}
|
||||||
|
|
||||||
os.flush();
|
os.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -93,7 +93,7 @@ void Foam::vtkUnstructuredReader::warnUnhandledType
|
|||||||
if (warningGiven.insert(type))
|
if (warningGiven.insert(type))
|
||||||
{
|
{
|
||||||
IOWarningInFunction(inFile)
|
IOWarningInFunction(inFile)
|
||||||
<< "Skipping unknown cell type " << type << endl;
|
<< "Skipping unknown cell type " << type << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,10 +344,9 @@ void Foam::vtkUnstructuredReader::extractCells
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Read " << celli << " cells;" << facei << " faces." << nl;
|
||||||
Info<< "Read " << celli << " cells;" << facei << " faces." << endl;
|
|
||||||
}
|
|
||||||
cells_.setSize(celli);
|
cells_.setSize(celli);
|
||||||
cellMap_.setSize(celli);
|
cellMap_.setSize(celli);
|
||||||
faces_.setSize(facei);
|
faces_.setSize(facei);
|
||||||
@ -401,10 +400,9 @@ void Foam::vtkUnstructuredReader::readField
|
|||||||
|
|
||||||
case VTK_STRING:
|
case VTK_STRING:
|
||||||
{
|
{
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Reading strings:" << size << nl;
|
||||||
Info<< "Reading strings:" << size << endl;
|
|
||||||
}
|
|
||||||
auto fieldVals = autoPtr<stringIOList>::New
|
auto fieldVals = autoPtr<stringIOList>::New
|
||||||
(
|
(
|
||||||
IOobject(arrayName, "", obj),
|
IOobject(arrayName, "", obj),
|
||||||
@ -425,9 +423,9 @@ void Foam::vtkUnstructuredReader::readField
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
IOWarningInFunction(inFile)
|
IOWarningInFunction(inFile)
|
||||||
<< "Unhandled type " << dataType << endl
|
<< "Unhandled type " << dataType << nl
|
||||||
<< "Skipping " << size
|
<< "Skipping " << size
|
||||||
<< " words." << endl;
|
<< " words." << nl;
|
||||||
scalarField fieldVals;
|
scalarField fieldVals;
|
||||||
readBlock(inFile, size, fieldVals);
|
readBlock(inFile, size, fieldVals);
|
||||||
}
|
}
|
||||||
@ -437,9 +435,9 @@ void Foam::vtkUnstructuredReader::readField
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
IOWarningInFunction(inFile)
|
IOWarningInFunction(inFile)
|
||||||
<< "Unhandled type " << dataType << endl
|
<< "Unhandled type " << dataType << nl
|
||||||
<< "Skipping " << size
|
<< "Skipping " << size
|
||||||
<< " words." << endl;
|
<< " words." << nl;
|
||||||
scalarField fieldVals;
|
scalarField fieldVals;
|
||||||
readBlock(inFile, size, fieldVals);
|
readBlock(inFile, size, fieldVals);
|
||||||
}
|
}
|
||||||
@ -456,14 +454,14 @@ Foam::wordList Foam::vtkUnstructuredReader::readFieldArray
|
|||||||
DynamicList<word> fields;
|
DynamicList<word> fields;
|
||||||
|
|
||||||
word dataName(inFile);
|
word dataName(inFile);
|
||||||
if (debug)
|
|
||||||
{
|
DebugInfo
|
||||||
Info<< "dataName:" << dataName << endl;
|
<< "dataName:" << dataName << nl;
|
||||||
}
|
|
||||||
label numArrays(readLabel(inFile));
|
label numArrays(readLabel(inFile));
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "numArrays:" << numArrays << endl;
|
Pout<< "numArrays:" << numArrays << nl;
|
||||||
}
|
}
|
||||||
for (label i = 0; i < numArrays; i++)
|
for (label i = 0; i < numArrays; i++)
|
||||||
{
|
{
|
||||||
@ -472,11 +470,9 @@ Foam::wordList Foam::vtkUnstructuredReader::readFieldArray
|
|||||||
label numTuples(readLabel(inFile));
|
label numTuples(readLabel(inFile));
|
||||||
word dataType(inFile);
|
word dataType(inFile);
|
||||||
|
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Reading field " << arrayName
|
||||||
Info<< "Reading field " << arrayName
|
<< " of " << numTuples << " tuples of rank " << numComp << nl;
|
||||||
<< " of " << numTuples << " tuples of rank " << numComp << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wantedSize != -1 && numTuples != wantedSize)
|
if (wantedSize != -1 && numTuples != wantedSize)
|
||||||
{
|
{
|
||||||
@ -536,20 +532,13 @@ Foam::vtkUnstructuredReader::vtkUnstructuredReader
|
|||||||
void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
||||||
{
|
{
|
||||||
inFile.getLine(header_);
|
inFile.getLine(header_);
|
||||||
if (debug)
|
DebugInfo<< "Header : " << header_ << nl;
|
||||||
{
|
|
||||||
Info<< "Header : " << header_ << endl;
|
|
||||||
}
|
|
||||||
inFile.getLine(title_);
|
inFile.getLine(title_);
|
||||||
if (debug)
|
DebugInfo<< "Title : " << title_ << nl;
|
||||||
{
|
|
||||||
Info<< "Title : " << title_ << endl;
|
|
||||||
}
|
|
||||||
inFile.getLine(dataType_);
|
inFile.getLine(dataType_);
|
||||||
if (debug)
|
DebugInfo<< "dataType : " << dataType_ << nl;
|
||||||
{
|
|
||||||
Info<< "dataType : " << dataType_ << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dataType_ == "BINARY")
|
if (dataType_ == "BINARY")
|
||||||
{
|
{
|
||||||
@ -564,28 +553,21 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
|||||||
// Temporary storage for vertices of cells.
|
// Temporary storage for vertices of cells.
|
||||||
labelList cellVerts;
|
labelList cellVerts;
|
||||||
|
|
||||||
while (inFile.good())
|
token tok;
|
||||||
|
|
||||||
|
while (inFile.read(tok).good() && tok.isWord())
|
||||||
{
|
{
|
||||||
word tag(inFile);
|
const word tag = tok.wordToken();
|
||||||
|
|
||||||
if (!inFile.good())
|
DebugInfo
|
||||||
{
|
<< "line:" << inFile.lineNumber()
|
||||||
break;
|
<< " tag:" << tag << nl;
|
||||||
}
|
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
Info<< "line:" << inFile.lineNumber()
|
|
||||||
<< " tag:" << tag << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tag == "DATASET")
|
if (tag == "DATASET")
|
||||||
{
|
{
|
||||||
word geomType(inFile);
|
word geomType(inFile);
|
||||||
if (debug)
|
DebugInfo<< "geomType : " << geomType << nl;
|
||||||
{
|
|
||||||
Info<< "geomType : " << geomType << endl;
|
|
||||||
}
|
|
||||||
readMode = parseModeNames[geomType];
|
readMode = parseModeNames[geomType];
|
||||||
wantedSize = -1;
|
wantedSize = -1;
|
||||||
}
|
}
|
||||||
@ -593,11 +575,10 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
|||||||
{
|
{
|
||||||
label nPoints(readLabel(inFile));
|
label nPoints(readLabel(inFile));
|
||||||
points_.setSize(nPoints); ///3);
|
points_.setSize(nPoints); ///3);
|
||||||
if (debug)
|
|
||||||
{
|
DebugInfo
|
||||||
Info<< "Reading " << nPoints << " numbers representing "
|
<< "Reading " << nPoints << " numbers representing "
|
||||||
<< points_.size() << " coordinates." << endl;
|
<< points_.size() << " coordinates." << nl;
|
||||||
}
|
|
||||||
|
|
||||||
word primitiveTag(inFile);
|
word primitiveTag(inFile);
|
||||||
if (primitiveTag != "float" && primitiveTag != "double")
|
if (primitiveTag != "float" && primitiveTag != "double")
|
||||||
@ -607,19 +588,18 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
|||||||
<< primitiveTag
|
<< primitiveTag
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
forAll(points_, i)
|
for (point& p : points_)
|
||||||
{
|
{
|
||||||
inFile >> points_[i].x() >> points_[i].y() >> points_[i].z();
|
inFile >> p.x() >> p.y() >> p.z();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tag == "CELLS")
|
else if (tag == "CELLS")
|
||||||
{
|
{
|
||||||
label nCells(readLabel(inFile));
|
label nCells(readLabel(inFile));
|
||||||
label nNumbers(readLabel(inFile));
|
label nNumbers(readLabel(inFile));
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Reading " << nCells << " cells or faces." << nl;
|
||||||
Info<< "Reading " << nCells << " cells or faces." << endl;
|
|
||||||
}
|
|
||||||
readBlock(inFile, nNumbers, cellVerts);
|
readBlock(inFile, nNumbers, cellVerts);
|
||||||
}
|
}
|
||||||
else if (tag == "CELL_TYPES")
|
else if (tag == "CELL_TYPES")
|
||||||
@ -644,10 +624,9 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
|||||||
{
|
{
|
||||||
label nLines(readLabel(inFile));
|
label nLines(readLabel(inFile));
|
||||||
label nNumbers(readLabel(inFile));
|
label nNumbers(readLabel(inFile));
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Reading " << nLines << " lines." << nl;
|
||||||
Info<< "Reading " << nLines << " lines." << endl;
|
|
||||||
}
|
|
||||||
labelList lineVerts;
|
labelList lineVerts;
|
||||||
readBlock(inFile, nNumbers, lineVerts);
|
readBlock(inFile, nNumbers, lineVerts);
|
||||||
|
|
||||||
@ -674,10 +653,9 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
|||||||
|
|
||||||
label nFaces(readLabel(inFile));
|
label nFaces(readLabel(inFile));
|
||||||
label nNumbers(readLabel(inFile));
|
label nNumbers(readLabel(inFile));
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Reading " << nFaces << " faces." << nl;
|
||||||
Info<< "Reading " << nFaces << " faces." << endl;
|
|
||||||
}
|
|
||||||
labelList faceVerts;
|
labelList faceVerts;
|
||||||
readBlock(inFile, nNumbers, faceVerts);
|
readBlock(inFile, nNumbers, faceVerts);
|
||||||
|
|
||||||
@ -740,12 +718,10 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
|||||||
word dataType(is);
|
word dataType(is);
|
||||||
//label numComp(readLabel(inFile));
|
//label numComp(readLabel(inFile));
|
||||||
|
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Reading scalar " << dataName
|
||||||
Info<< "Reading scalar " << dataName
|
<< " of type " << dataType
|
||||||
<< " of type " << dataType
|
<< " from lookup table" << nl;
|
||||||
<< " from lookup table" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
word lookupTableTag(inFile);
|
word lookupTableTag(inFile);
|
||||||
if (lookupTableTag != "LOOKUP_TABLE")
|
if (lookupTableTag != "LOOKUP_TABLE")
|
||||||
@ -775,11 +751,9 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
|||||||
IStringStream is(line);
|
IStringStream is(line);
|
||||||
word dataName(is);
|
word dataName(is);
|
||||||
word dataType(is);
|
word dataType(is);
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Reading vector " << dataName
|
||||||
Info<< "Reading vector " << dataName
|
<< " of type " << dataType << nl;
|
||||||
<< " of type " << dataType << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
objectRegistry& reg = selectRegistry(readMode);
|
objectRegistry& reg = selectRegistry(readMode);
|
||||||
|
|
||||||
@ -827,12 +801,10 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
|||||||
label dim(readLabel(is));
|
label dim(readLabel(is));
|
||||||
word dataType(is);
|
word dataType(is);
|
||||||
|
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Reading texture coords " << dataName
|
||||||
Info<< "Reading texture coords " << dataName
|
<< " dimension " << dim
|
||||||
<< " dimension " << dim
|
<< " of type " << dataType << nl;
|
||||||
<< " of type " << dataType << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
scalarField coords(dim*points_.size());
|
scalarField coords(dim*points_.size());
|
||||||
readBlock(inFile, coords.size(), coords);
|
readBlock(inFile, coords.size(), coords);
|
||||||
@ -841,10 +813,9 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
|||||||
{
|
{
|
||||||
label nStrips(readLabel(inFile));
|
label nStrips(readLabel(inFile));
|
||||||
label nNumbers(readLabel(inFile));
|
label nNumbers(readLabel(inFile));
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Reading " << nStrips << " triangle strips." << nl;
|
||||||
Info<< "Reading " << nStrips << " triangle strips." << endl;
|
|
||||||
}
|
|
||||||
labelList faceVerts;
|
labelList faceVerts;
|
||||||
readBlock(inFile, nNumbers, faceVerts);
|
readBlock(inFile, nNumbers, faceVerts);
|
||||||
|
|
||||||
@ -897,11 +868,9 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
|||||||
<< infoTag << exit(FatalIOError);
|
<< infoTag << exit(FatalIOError);
|
||||||
}
|
}
|
||||||
label nInfo(readLabel(inFile));
|
label nInfo(readLabel(inFile));
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Consuming " << nInfo << " metadata information." << nl;
|
||||||
Info<< "Consuming " << nInfo << " metadata information."
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
string line;
|
string line;
|
||||||
// Consume rest of line
|
// Consume rest of line
|
||||||
inFile.getLine(line);
|
inFile.getLine(line);
|
||||||
@ -926,9 +895,8 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
|||||||
|
|
||||||
label nSwapped = 0;
|
label nSwapped = 0;
|
||||||
|
|
||||||
forAll(cells_, celli)
|
for (cellShape& shape : cells_)
|
||||||
{
|
{
|
||||||
cellShape& shape = cells_[celli];
|
|
||||||
if (shape.model() == prism)
|
if (shape.model() == prism)
|
||||||
{
|
{
|
||||||
const triPointRef bottom
|
const triPointRef bottom
|
||||||
@ -961,7 +929,7 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
|||||||
if (nSwapped > 0)
|
if (nSwapped > 0)
|
||||||
{
|
{
|
||||||
WarningInFunction << "Swapped " << nSwapped << " prismatic cells"
|
WarningInFunction << "Swapped " << nSwapped << " prismatic cells"
|
||||||
<< endl;
|
<< nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -971,23 +939,23 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
|
|||||||
<< " cellShapes:" << cells_.size()
|
<< " cellShapes:" << cells_.size()
|
||||||
<< " faces:" << faces_.size()
|
<< " faces:" << faces_.size()
|
||||||
<< " lines:" << lines_.size()
|
<< " lines:" << lines_.size()
|
||||||
<< nl << endl;
|
<< nl << nl;
|
||||||
|
|
||||||
Info<< "Cell fields:" << endl;
|
Info<< "Cell fields:" << nl;
|
||||||
printFieldStats<vectorIOField>(cellData_);
|
printFieldStats<vectorIOField>(cellData_);
|
||||||
printFieldStats<scalarIOField>(cellData_);
|
printFieldStats<scalarIOField>(cellData_);
|
||||||
printFieldStats<labelIOField>(cellData_);
|
printFieldStats<labelIOField>(cellData_);
|
||||||
printFieldStats<stringIOList>(cellData_);
|
printFieldStats<stringIOList>(cellData_);
|
||||||
Info<< nl << endl;
|
Info<< nl << nl;
|
||||||
|
|
||||||
Info<< "Point fields:" << endl;
|
Info<< "Point fields:" << nl;
|
||||||
printFieldStats<vectorIOField>(pointData_);
|
printFieldStats<vectorIOField>(pointData_);
|
||||||
printFieldStats<scalarIOField>(pointData_);
|
printFieldStats<scalarIOField>(pointData_);
|
||||||
printFieldStats<labelIOField>(pointData_);
|
printFieldStats<labelIOField>(pointData_);
|
||||||
printFieldStats<stringIOList>(pointData_);
|
printFieldStats<stringIOList>(pointData_);
|
||||||
Info<< nl << endl;
|
Info<< nl << nl;
|
||||||
|
|
||||||
Info<< "Other fields:" << endl;
|
Info<< "Other fields:" << nl;
|
||||||
printFieldStats<vectorIOField>(otherData_);
|
printFieldStats<vectorIOField>(otherData_);
|
||||||
printFieldStats<scalarIOField>(otherData_);
|
printFieldStats<scalarIOField>(otherData_);
|
||||||
printFieldStats<labelIOField>(otherData_);
|
printFieldStats<labelIOField>(otherData_);
|
||||||
|
|||||||
@ -41,9 +41,9 @@ void Foam::vtkUnstructuredReader::readBlock
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
list.setSize(n);
|
list.setSize(n);
|
||||||
forAll(list, i)
|
for (T& val : list)
|
||||||
{
|
{
|
||||||
inFile >> list[i];
|
inFile >> val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,19 +39,21 @@ inline void Foam::fileFormats::STARCDedgeFormat::writeLines
|
|||||||
{
|
{
|
||||||
writeHeader(os, STARCDCore::HEADER_CEL);
|
writeHeader(os, STARCDCore::HEADER_CEL);
|
||||||
|
|
||||||
forAll(edges, edgeI)
|
label starCellId = 1; // 1-based cellId
|
||||||
{
|
|
||||||
const edge& e = edges[edgeI];
|
|
||||||
const label cellId = edgeI + 1;
|
|
||||||
|
|
||||||
os << cellId // includes 1 offset
|
for (const edge& e : edges)
|
||||||
|
{
|
||||||
|
os << starCellId
|
||||||
<< ' ' << starcdLine // 2(line) shape
|
<< ' ' << starcdLine // 2(line) shape
|
||||||
<< ' ' << e.size()
|
<< ' ' << e.size()
|
||||||
<< ' ' << 401 // arbitrary value
|
<< ' ' << 401 // arbitrary value
|
||||||
<< ' ' << starcdLineType; // 5(line)
|
<< ' ' << starcdLineType; // 5(line)
|
||||||
|
|
||||||
os << nl << " " << cellId << " "
|
os << nl
|
||||||
|
<< " " << starCellId << " "
|
||||||
<< (e[0]+1) << " " << (e[1]+1) << nl;
|
<< (e[0]+1) << " " << (e[1]+1) << nl;
|
||||||
|
|
||||||
|
++starCellId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +69,7 @@ void Foam::fileFormats::STARCDedgeFormat::writeCase
|
|||||||
{
|
{
|
||||||
const word caseName = os.name().nameLessExt();
|
const word caseName = os.name().nameLessExt();
|
||||||
|
|
||||||
os << "! STAR-CD file written " << clock::dateTime().c_str() << nl
|
os << "! STARCD file written " << clock::dateTime().c_str() << nl
|
||||||
<< "! " << pointLst.size() << " points, " << nEdges << " lines" << nl
|
<< "! " << pointLst.size() << " points, " << nEdges << " lines" << nl
|
||||||
<< "! case " << caseName << nl
|
<< "! case " << caseName << nl
|
||||||
<< "! ------------------------------" << nl;
|
<< "! ------------------------------" << nl;
|
||||||
@ -112,10 +114,10 @@ bool Foam::fileFormats::STARCDedgeFormat::read
|
|||||||
|
|
||||||
fileName baseName = filename.lessExt();
|
fileName baseName = filename.lessExt();
|
||||||
|
|
||||||
// STAR-CD index of points
|
// STARCD index of points
|
||||||
List<label> pointId;
|
List<label> pointId;
|
||||||
|
|
||||||
// read points from .vrt file
|
// Read points from .vrt file
|
||||||
readPoints
|
readPoints
|
||||||
(
|
(
|
||||||
IFstream(starFileName(baseName, STARCDCore::VRT_FILE))(),
|
IFstream(starFileName(baseName, STARCDCore::VRT_FILE))(),
|
||||||
@ -123,7 +125,7 @@ bool Foam::fileFormats::STARCDedgeFormat::read
|
|||||||
pointId
|
pointId
|
||||||
);
|
);
|
||||||
|
|
||||||
// Build inverse mapping (STAR-CD pointId -> index)
|
// Build inverse mapping (STARCD pointId -> index)
|
||||||
Map<label> mapPointId(2*pointId.size());
|
Map<label> mapPointId(2*pointId.size());
|
||||||
forAll(pointId, i)
|
forAll(pointId, i)
|
||||||
{
|
{
|
||||||
@ -131,11 +133,11 @@ bool Foam::fileFormats::STARCDedgeFormat::read
|
|||||||
}
|
}
|
||||||
pointId.clear();
|
pointId.clear();
|
||||||
|
|
||||||
// note which points were really used and which can be culled
|
// Note which points were really used and which can be culled
|
||||||
bitSet usedPoints(points().size());
|
bitSet usedPoints(points().size());
|
||||||
|
|
||||||
//
|
|
||||||
// read .cel file
|
// Read .cel file
|
||||||
// ~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~
|
||||||
IFstream is(starFileName(baseName, STARCDCore::CEL_FILE));
|
IFstream is(starFileName(baseName, STARCDCore::CEL_FILE));
|
||||||
if (!is.good())
|
if (!is.good())
|
||||||
@ -147,29 +149,35 @@ bool Foam::fileFormats::STARCDedgeFormat::read
|
|||||||
|
|
||||||
readHeader(is, STARCDCore::HEADER_CEL);
|
readHeader(is, STARCDCore::HEADER_CEL);
|
||||||
|
|
||||||
DynamicList<edge> dynEdges;
|
DynamicList<edge> dynEdges;
|
||||||
|
|
||||||
label lineLabel, shapeId, nLabels, cellTableId, typeId;
|
label ignoredLabel, shapeId, nLabels, cellTableId, typeId;
|
||||||
DynamicList<label> vertexLabels(64);
|
DynamicList<label> vertexLabels(64);
|
||||||
|
|
||||||
while ((is >> lineLabel).good())
|
token tok;
|
||||||
|
|
||||||
|
while (is.read(tok).good() && tok.isLabel())
|
||||||
{
|
{
|
||||||
is >> shapeId >> nLabels >> cellTableId >> typeId;
|
// const label starCellId = tok.labelToken();
|
||||||
|
is >> shapeId
|
||||||
|
>> nLabels
|
||||||
|
>> cellTableId
|
||||||
|
>> typeId;
|
||||||
|
|
||||||
vertexLabels.clear();
|
vertexLabels.clear();
|
||||||
vertexLabels.reserve(nLabels);
|
vertexLabels.reserve(nLabels);
|
||||||
|
|
||||||
// read indices - max 8 per line
|
// Read indices - max 8 per line
|
||||||
for (label i = 0; i < nLabels; ++i)
|
for (label i = 0; i < nLabels; ++i)
|
||||||
{
|
{
|
||||||
label vrtId;
|
label vrtId;
|
||||||
if ((i % 8) == 0)
|
if ((i % 8) == 0)
|
||||||
{
|
{
|
||||||
is >> lineLabel;
|
is >> ignoredLabel; // Skip cellId for continuation lines
|
||||||
}
|
}
|
||||||
is >> vrtId;
|
is >> vrtId;
|
||||||
|
|
||||||
// convert original vertex id to point label
|
// Convert original vertex id to point label
|
||||||
vertexLabels.append(mapPointId[vrtId]);
|
vertexLabels.append(mapPointId[vrtId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +208,7 @@ bool Foam::fileFormats::STARCDedgeFormat::read
|
|||||||
pts[nUsed] = pts[pointi];
|
pts[nUsed] = pts[pointi];
|
||||||
}
|
}
|
||||||
|
|
||||||
// map prev -> new id
|
// Map prev -> new id
|
||||||
mapPointId.set(pointi, nUsed);
|
mapPointId.set(pointi, nUsed);
|
||||||
|
|
||||||
++nUsed;
|
++nUsed;
|
||||||
@ -208,10 +216,8 @@ bool Foam::fileFormats::STARCDedgeFormat::read
|
|||||||
pts.resize(nUsed);
|
pts.resize(nUsed);
|
||||||
|
|
||||||
// Renumber edge vertices
|
// Renumber edge vertices
|
||||||
forAll(dynEdges, edgeI)
|
for (edge& e : dynEdges)
|
||||||
{
|
{
|
||||||
edge& e = dynEdges[edgeI];
|
|
||||||
|
|
||||||
e[0] = mapPointId[e[0]];
|
e[0] = mapPointId[e[0]];
|
||||||
e[1] = mapPointId[e[1]];
|
e[1] = mapPointId[e[1]];
|
||||||
}
|
}
|
||||||
@ -245,7 +251,7 @@ void Foam::fileFormats::STARCDedgeFormat::write
|
|||||||
edgeLst
|
edgeLst
|
||||||
);
|
);
|
||||||
|
|
||||||
// write a simple .inp file
|
// Write a simple .inp file
|
||||||
writeCase
|
writeCase
|
||||||
(
|
(
|
||||||
OFstream(starFileName(baseName, STARCDCore::INP_FILE))(),
|
OFstream(starFileName(baseName, STARCDCore::INP_FILE))(),
|
||||||
|
|||||||
@ -38,32 +38,30 @@ namespace Foam
|
|||||||
void Foam::ensightSurfaceReader::skip(const label n, Istream& is) const
|
void Foam::ensightSurfaceReader::skip(const label n, Istream& is) const
|
||||||
{
|
{
|
||||||
label i = 0;
|
label i = 0;
|
||||||
token t;
|
token tok;
|
||||||
while (is.good() && (i < n))
|
while (is.good() && (i < n))
|
||||||
{
|
{
|
||||||
is >> t;
|
is >> tok;
|
||||||
i++;
|
++i;
|
||||||
|
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Skipping token " << tok << nl;
|
||||||
Info<< "Skipping token " << t << endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != n)
|
if (i != n)
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Requested to skip " << n << "tokens, but stream exited after "
|
<< "Requested to skip " << n << "tokens, but stream exited after "
|
||||||
<< i << " tokens. Last token read: " << t
|
<< i << " tokens. Last token read: " << tok
|
||||||
<< endl;
|
<< nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::ensightSurfaceReader::readLine(IFstream& is, string& buffer) const
|
void Foam::ensightSurfaceReader::readLine(IFstream& is, string& buffer) const
|
||||||
{
|
{
|
||||||
buffer = "";
|
buffer.clear();
|
||||||
while (is.good() && buffer == "")
|
while (is.good() && buffer.empty())
|
||||||
{
|
{
|
||||||
is.getLine(buffer);
|
is.getLine(buffer);
|
||||||
}
|
}
|
||||||
@ -76,7 +74,7 @@ void Foam::ensightSurfaceReader::debugSection
|
|||||||
IFstream& is
|
IFstream& is
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
string actual = "";
|
string actual;
|
||||||
readLine(is, actual);
|
readLine(is, actual);
|
||||||
|
|
||||||
if (expected != actual)
|
if (expected != actual)
|
||||||
@ -87,10 +85,8 @@ void Foam::ensightSurfaceReader::debugSection
|
|||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Read section header: " << expected << nl;
|
||||||
Info<< "Read section header: " << expected << endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -103,45 +99,42 @@ void Foam::ensightSurfaceReader::readGeometryHeader(ensightReadFile& is) const
|
|||||||
|
|
||||||
// Ensight Geometry File
|
// Ensight Geometry File
|
||||||
is.read(buffer);
|
is.read(buffer);
|
||||||
if (debug) Info<< "buffer: " << buffer << endl;
|
DebugInfo<< "buffer: " << buffer << nl;
|
||||||
|
|
||||||
// Description - 1
|
// Description - 1
|
||||||
is.read(buffer);
|
is.read(buffer);
|
||||||
if (debug) Info<< "buffer: " << buffer << endl;
|
DebugInfo<< "buffer: " << buffer << nl;
|
||||||
|
|
||||||
// Node info
|
// Node info
|
||||||
is.read(buffer);
|
is.read(buffer);
|
||||||
if (debug) Info<< "buffer: " << buffer << endl;
|
DebugInfo<< "buffer: " << buffer << nl;
|
||||||
|
|
||||||
// Element info
|
// Element info
|
||||||
is.read(buffer);
|
is.read(buffer);
|
||||||
if (debug) Info<< "buffer: " << buffer << endl;
|
DebugInfo<< "buffer: " << buffer << nl;
|
||||||
|
|
||||||
// Part
|
// Part
|
||||||
is.read(buffer);
|
is.read(buffer);
|
||||||
if (debug) Info<< "buffer: " << buffer << endl;
|
DebugInfo<< "buffer: " << buffer << nl;
|
||||||
|
|
||||||
// Part number
|
// Part number
|
||||||
label ibuffer;
|
label ibuffer;
|
||||||
is.read(ibuffer);
|
is.read(ibuffer);
|
||||||
if (debug) Info<< "ibuffer: " << ibuffer << endl;
|
DebugInfo<< "ibuffer: " << ibuffer << nl;
|
||||||
|
|
||||||
// Description - 2
|
// Description - 2
|
||||||
is.read(buffer);
|
is.read(buffer);
|
||||||
if (debug) Info<< "buffer: " << buffer << endl;
|
DebugInfo<< "buffer: " << buffer << nl;
|
||||||
|
|
||||||
// Coordinates
|
// Coordinates
|
||||||
is.read(buffer);
|
is.read(buffer);
|
||||||
if (debug) Info<< "buffer: " << buffer << endl;
|
DebugInfo<< "buffer: " << buffer << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::ensightSurfaceReader::readCase(IFstream& is)
|
void Foam::ensightSurfaceReader::readCase(IFstream& is)
|
||||||
{
|
{
|
||||||
if (debug)
|
DebugInFunction<< nl;
|
||||||
{
|
|
||||||
InfoInFunction<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is.good())
|
if (!is.good())
|
||||||
{
|
{
|
||||||
@ -211,11 +204,9 @@ void Foam::ensightSurfaceReader::readCase(IFstream& is)
|
|||||||
fieldNames_.transfer(fieldNames);
|
fieldNames_.transfer(fieldNames);
|
||||||
fieldFileNames_.transfer(fieldFileNames);
|
fieldFileNames_.transfer(fieldFileNames);
|
||||||
|
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "fieldNames: " << fieldNames_ << nl
|
||||||
Info<< "fieldNames: " << fieldNames_ << nl
|
<< "fieldFileNames: " << fieldFileNames_ << nl;
|
||||||
<< "fieldFileNames: " << fieldFileNames_ << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start reading time information
|
// Start reading time information
|
||||||
readLine(is, buffer); // time set: <int>
|
readLine(is, buffer); // time set: <int>
|
||||||
@ -227,12 +218,10 @@ void Foam::ensightSurfaceReader::readCase(IFstream& is)
|
|||||||
readLine(is, buffer);
|
readLine(is, buffer);
|
||||||
readFromLine(2, buffer, timeIncrement_); // filename increment: <int>
|
readFromLine(2, buffer, timeIncrement_); // filename increment: <int>
|
||||||
|
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "nTimeSteps: " << nTimeSteps_ << nl
|
||||||
Info<< "nTimeSteps: " << nTimeSteps_ << nl
|
<< "timeStartIndex: " << timeStartIndex_ << nl
|
||||||
<< "timeStartIndex: " << timeStartIndex_ << nl
|
<< "timeIncrement: " << timeIncrement_ << nl;
|
||||||
<< "timeIncrement: " << timeIncrement_ << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read the time values
|
// Read the time values
|
||||||
readLine(is, buffer); // time values:
|
readLine(is, buffer); // time values:
|
||||||
@ -274,10 +263,7 @@ Foam::ensightSurfaceReader::ensightSurfaceReader(const fileName& fName)
|
|||||||
|
|
||||||
const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
|
const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
|
||||||
{
|
{
|
||||||
if (debug)
|
DebugInFunction<< nl;
|
||||||
{
|
|
||||||
InfoInFunction<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!surfPtr_.valid())
|
if (!surfPtr_.valid())
|
||||||
{
|
{
|
||||||
@ -337,20 +323,16 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
|
|||||||
|
|
||||||
ensightReadFile is(baseDir_/meshFileName_, streamFormat_);
|
ensightReadFile is(baseDir_/meshFileName_, streamFormat_);
|
||||||
|
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "File: " << is.name() << nl;
|
||||||
Info<< "File: " << is.name() << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
readGeometryHeader(is);
|
readGeometryHeader(is);
|
||||||
|
|
||||||
label nPoints;
|
label nPoints;
|
||||||
is.read(nPoints);
|
is.read(nPoints);
|
||||||
|
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "nPoints: " << nPoints << nl;
|
||||||
Info<< "nPoints: " << nPoints << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
pointField points(nPoints);
|
pointField points(nPoints);
|
||||||
{
|
{
|
||||||
@ -381,16 +363,14 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "faceType: " << faceType << endl;
|
||||||
Info<< "faceType: " << faceType << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (faceType == "tria3")
|
if (faceType == "tria3")
|
||||||
{
|
{
|
||||||
is.read(nFace);
|
is.read(nFace);
|
||||||
|
|
||||||
label np = 3;
|
const label np = 3;
|
||||||
for (label faceI = 0; faceI < nFace; ++faceI)
|
for (label faceI = 0; faceI < nFace; ++faceI)
|
||||||
{
|
{
|
||||||
face f(np);
|
face f(np);
|
||||||
@ -406,7 +386,7 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
|
|||||||
{
|
{
|
||||||
is.read(nFace);
|
is.read(nFace);
|
||||||
|
|
||||||
label np = 4;
|
const label np = 4;
|
||||||
for (label faceI = 0; faceI < nFace; ++faceI)
|
for (label faceI = 0; faceI < nFace; ++faceI)
|
||||||
{
|
{
|
||||||
face f(np);
|
face f(np);
|
||||||
@ -455,20 +435,16 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
|
|||||||
|
|
||||||
schema_.transfer(schema);
|
schema_.transfer(schema);
|
||||||
|
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "read nFaces: " << faces.size() << nl
|
||||||
Info<< "read nFaces: " << faces.size() << nl
|
<< "file schema: " << schema_ << nl;
|
||||||
<< "file schema: " << schema_ << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert from 1-based Ensight addressing to 0-based OF addressing
|
// Convert from 1-based Ensight addressing to 0-based OF addressing
|
||||||
forAll(faces, faceI)
|
for (face& f : faces)
|
||||||
{
|
{
|
||||||
face& f = faces[faceI];
|
for (label& pointi : f)
|
||||||
|
|
||||||
forAll(f, fpI)
|
|
||||||
{
|
{
|
||||||
f[fpI]--;
|
--pointi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -44,16 +44,16 @@ inline void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeShell
|
|||||||
<< ' ' << cellTableId
|
<< ' ' << cellTableId
|
||||||
<< ' ' << starcdShellType; // 4(shell)
|
<< ' ' << starcdShellType; // 4(shell)
|
||||||
|
|
||||||
// primitives have <= 8 vertices, but prevent overrun anyhow
|
// Primitives have <= 8 vertices, but prevent overrun anyhow
|
||||||
// indent following lines for ease of reading
|
// indent following lines for ease of reading
|
||||||
label count = 0;
|
label count = 0;
|
||||||
for (const label verti : f)
|
for (const label pointi : f)
|
||||||
{
|
{
|
||||||
if ((count % 8) == 0)
|
if ((count % 8) == 0)
|
||||||
{
|
{
|
||||||
os << nl << " " << cellId;
|
os << nl << " " << cellId;
|
||||||
}
|
}
|
||||||
os << ' ' << verti + 1;
|
os << ' ' << pointi + 1;
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
os << nl;
|
os << nl;
|
||||||
@ -91,7 +91,7 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// STAR-CD index of points
|
// STARCD index of points
|
||||||
List<label> pointId;
|
List<label> pointId;
|
||||||
|
|
||||||
// read points from .vrt file
|
// read points from .vrt file
|
||||||
@ -102,7 +102,7 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
|||||||
pointId
|
pointId
|
||||||
);
|
);
|
||||||
|
|
||||||
// Build inverse mapping (STAR-CD pointId -> index)
|
// Build inverse mapping (STARCD pointId -> index)
|
||||||
Map<label> mapPointId(2*pointId.size());
|
Map<label> mapPointId(2*pointId.size());
|
||||||
forAll(pointId, i)
|
forAll(pointId, i)
|
||||||
{
|
{
|
||||||
@ -133,27 +133,33 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
|||||||
bool sorted = true;
|
bool sorted = true;
|
||||||
label zoneId = 0;
|
label zoneId = 0;
|
||||||
|
|
||||||
label lineLabel, shapeId, nLabels, cellTableId, typeId;
|
label ignoredLabel, shapeId, nLabels, cellTableId, typeId;
|
||||||
DynamicList<label> vertexLabels(64);
|
DynamicList<label> vertexLabels(64);
|
||||||
|
|
||||||
while ((is >> lineLabel).good())
|
token tok;
|
||||||
|
|
||||||
|
while (is.read(tok).good() && tok.isLabel())
|
||||||
{
|
{
|
||||||
is >> shapeId >> nLabels >> cellTableId >> typeId;
|
// const label starCellId = tok.labelToken();
|
||||||
|
is >> shapeId
|
||||||
|
>> nLabels
|
||||||
|
>> cellTableId
|
||||||
|
>> typeId;
|
||||||
|
|
||||||
vertexLabels.clear();
|
vertexLabels.clear();
|
||||||
vertexLabels.reserve(nLabels);
|
vertexLabels.reserve(nLabels);
|
||||||
|
|
||||||
// read indices - max 8 per line
|
// Read indices - max 8 per line
|
||||||
for (label i = 0; i < nLabels; ++i)
|
for (label i = 0; i < nLabels; ++i)
|
||||||
{
|
{
|
||||||
label vrtId;
|
label vrtId;
|
||||||
if ((i % 8) == 0)
|
if ((i % 8) == 0)
|
||||||
{
|
{
|
||||||
is >> lineLabel;
|
is >> ignoredLabel; // Skip cellId for continuation lines
|
||||||
}
|
}
|
||||||
is >> vrtId;
|
is >> vrtId;
|
||||||
|
|
||||||
// convert original vertex id to point label
|
// Convert original vertex id to point label
|
||||||
vertexLabels.append(mapPointId[vrtId]);
|
vertexLabels.append(mapPointId[vrtId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,10 +189,7 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dynNames.append
|
dynNames.append("cellTable_" + ::Foam::name(cellTableId));
|
||||||
(
|
|
||||||
word("cellTable_") + ::Foam::name(cellTableId)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dynSizes.append(0);
|
dynSizes.append(0);
|
||||||
@ -204,7 +207,7 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
|||||||
|
|
||||||
for (const face& tri : trias)
|
for (const face& tri : trias)
|
||||||
{
|
{
|
||||||
// a triangular 'face', convert to 'triFace' etc
|
// A triangular 'face', convert to 'triFace' etc
|
||||||
dynFaces.append(Face(tri));
|
dynFaces.append(Face(tri));
|
||||||
dynZones.append(zoneId);
|
dynZones.append(zoneId);
|
||||||
dynSizes[zoneId]++;
|
dynSizes[zoneId]++;
|
||||||
|
|||||||
@ -86,7 +86,7 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
|
|||||||
{
|
{
|
||||||
const word caseName = os.name().nameLessExt();
|
const word caseName = os.name().nameLessExt();
|
||||||
|
|
||||||
os << "! STAR-CD file written " << clock::dateTime().c_str() << nl
|
os << "! STARCD file written " << clock::dateTime().c_str() << nl
|
||||||
<< "! " << pts.size() << " points, " << nFaces << " faces" << nl
|
<< "! " << pts.size() << " points, " << nFaces << " faces" << nl
|
||||||
<< "! case " << caseName << nl
|
<< "! case " << caseName << nl
|
||||||
<< "! ------------------------------" << nl;
|
<< "! ------------------------------" << nl;
|
||||||
|
|||||||
@ -46,9 +46,8 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
// Forward declarations
|
||||||
|
class ISstream;
|
||||||
class IFstream;
|
|
||||||
class Time;
|
class Time;
|
||||||
|
|
||||||
namespace fileFormats
|
namespace fileFormats
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -31,25 +31,6 @@ License
|
|||||||
#include "mergePoints.H"
|
#include "mergePoints.H"
|
||||||
#include "Map.H"
|
#include "Map.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
static Foam::string getLineNoComment
|
|
||||||
(
|
|
||||||
Foam::ISstream& is,
|
|
||||||
const char comment='#'
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Foam::string line;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
is.getLine(line);
|
|
||||||
}
|
|
||||||
while ((line.empty() || line[0] == comment) && is.good());
|
|
||||||
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fileFormats::TRIReader::readFile(const fileName& filename)
|
bool Foam::fileFormats::TRIReader::readFile(const fileName& filename)
|
||||||
@ -80,7 +61,7 @@ bool Foam::fileFormats::TRIReader::readFile(const fileName& filename)
|
|||||||
|
|
||||||
while (is.good())
|
while (is.good())
|
||||||
{
|
{
|
||||||
string line = getLineNoComment(is);
|
string line = this->getLineNoComment(is);
|
||||||
|
|
||||||
if (line.empty())
|
if (line.empty())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -43,6 +43,7 @@ SourceFiles
|
|||||||
|
|
||||||
#include "STLpoint.H"
|
#include "STLpoint.H"
|
||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
|
#include "surfaceFormatsCore.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -56,6 +57,8 @@ namespace fileFormats
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class TRIReader
|
class TRIReader
|
||||||
|
:
|
||||||
|
public surfaceFormatsCore
|
||||||
{
|
{
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user