mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Begin code refactoring of third-party file formats.
This commit is contained in:
@ -18,6 +18,7 @@ EXE_LIBS = \
|
|||||||
-lengine \
|
-lengine \
|
||||||
-lerrorEstimation \
|
-lerrorEstimation \
|
||||||
-lfieldFunctionObjects \
|
-lfieldFunctionObjects \
|
||||||
|
-lfileFormats \
|
||||||
-lfiniteVolume \
|
-lfiniteVolume \
|
||||||
-lforces \
|
-lforces \
|
||||||
-lfvMotionSolvers \
|
-lfvMotionSolvers \
|
||||||
|
|||||||
@ -100,10 +100,8 @@ int main(int argc, char *argv[])
|
|||||||
meshSubsetDict.lookup("addFaceNeighbours")
|
meshSubsetDict.lookup("addFaceNeighbours")
|
||||||
);
|
);
|
||||||
|
|
||||||
Switch invertSelection
|
const bool invertSelection =
|
||||||
(
|
meshSubsetDict.lookupOrDefault<bool>("invertSelection", false);
|
||||||
meshSubsetDict.lookup("invertSelection")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Mark the cells for the subset
|
// Mark the cells for the subset
|
||||||
|
|
||||||
@ -246,7 +244,7 @@ int main(int argc, char *argv[])
|
|||||||
// bb of surface
|
// bb of surface
|
||||||
treeBoundBox bb(selectSurf.localPoints());
|
treeBoundBox bb(selectSurf.localPoints());
|
||||||
|
|
||||||
// Radnom number generator
|
// Random number generator
|
||||||
Random rndGen(354543);
|
Random rndGen(354543);
|
||||||
|
|
||||||
// search engine
|
// search engine
|
||||||
@ -269,14 +267,11 @@ int main(int argc, char *argv[])
|
|||||||
indexedOctree<treeDataTriSurface>::volumeType t =
|
indexedOctree<treeDataTriSurface>::volumeType t =
|
||||||
selectTree.getVolumeType(fc);
|
selectTree.getVolumeType(fc);
|
||||||
|
|
||||||
if (t == indexedOctree<treeDataTriSurface>::INSIDE && !outside)
|
if
|
||||||
{
|
|
||||||
facesToSubset[faceI] = true;
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
(
|
||||||
t == indexedOctree<treeDataTriSurface>::OUTSIDE
|
outside
|
||||||
&& outside
|
? (t == indexedOctree<treeDataTriSurface>::OUTSIDE)
|
||||||
|
: (t == indexedOctree<treeDataTriSurface>::INSIDE)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
facesToSubset[faceI] = true;
|
facesToSubset[faceI] = true;
|
||||||
@ -346,20 +341,11 @@ int main(int argc, char *argv[])
|
|||||||
if (invertSelection)
|
if (invertSelection)
|
||||||
{
|
{
|
||||||
Info<< "Inverting selection." << endl;
|
Info<< "Inverting selection." << endl;
|
||||||
boolList newFacesToSubset(facesToSubset.size());
|
|
||||||
|
|
||||||
forAll(facesToSubset, i)
|
forAll(facesToSubset, i)
|
||||||
{
|
{
|
||||||
if (facesToSubset[i])
|
facesToSubset[i] = facesToSubset[i] ? false : true;
|
||||||
{
|
|
||||||
newFacesToSubset[i] = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newFacesToSubset[i] = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
facesToSubset.transfer(newFacesToSubset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ zone
|
|||||||
surface
|
surface
|
||||||
{
|
{
|
||||||
name "sphere.stl";
|
name "sphere.stl";
|
||||||
outside yes;
|
outside yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extend selection with edge neighbours
|
// Extend selection with edge neighbours
|
||||||
|
|||||||
@ -22,6 +22,7 @@ wmake libso OpenFOAM
|
|||||||
|
|
||||||
wmake libso lagrangian/basic
|
wmake libso lagrangian/basic
|
||||||
|
|
||||||
|
wmake libso fileFormats
|
||||||
wmake libso edgeMesh
|
wmake libso edgeMesh
|
||||||
wmake libso surfMesh
|
wmake libso surfMesh
|
||||||
wmake libso triSurface
|
wmake libso triSurface
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/fileFormats/lnInclude
|
||||||
|
|
||||||
|
LIB_LIBS = \
|
||||||
|
-lfileFormats
|
||||||
|
|||||||
@ -29,34 +29,6 @@ License
|
|||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
#include "PackedBoolList.H"
|
#include "PackedBoolList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
// Do weird things to extract a floating point number
|
|
||||||
Foam::scalar Foam::fileFormats::NASedgeFormat::parseNASCoord
|
|
||||||
(
|
|
||||||
const string& s
|
|
||||||
)
|
|
||||||
{
|
|
||||||
size_t expSign = s.find_last_of("+-");
|
|
||||||
|
|
||||||
if (expSign != string::npos && expSign > 0 && !isspace(s[expSign-1]))
|
|
||||||
{
|
|
||||||
scalar mantissa = readScalar(IStringStream(s.substr(0, expSign))());
|
|
||||||
scalar exponent = readScalar(IStringStream(s.substr(expSign+1))());
|
|
||||||
|
|
||||||
if (s[expSign] == '-')
|
|
||||||
{
|
|
||||||
exponent = -exponent;
|
|
||||||
}
|
|
||||||
return mantissa * pow(10, exponent);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return readScalar(IStringStream(s)());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fileFormats::NASedgeFormat::NASedgeFormat
|
Foam::fileFormats::NASedgeFormat::NASedgeFormat
|
||||||
|
|||||||
@ -37,6 +37,7 @@ SourceFiles
|
|||||||
#define NASedgeFormat_H
|
#define NASedgeFormat_H
|
||||||
|
|
||||||
#include "edgeMesh.H"
|
#include "edgeMesh.H"
|
||||||
|
#include "NASCore.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -51,7 +52,8 @@ namespace fileFormats
|
|||||||
|
|
||||||
class NASedgeFormat
|
class NASedgeFormat
|
||||||
:
|
:
|
||||||
public edgeMesh
|
public edgeMesh,
|
||||||
|
public NASCore
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
@ -61,13 +63,6 @@ class NASedgeFormat
|
|||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const NASedgeFormat&);
|
void operator=(const NASedgeFormat&);
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// Protected Member Functions
|
|
||||||
|
|
||||||
//- Do weird things to extract number
|
|
||||||
static scalar parseNASCoord(const string&);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|||||||
@ -59,134 +59,6 @@ inline void Foam::fileFormats::STARCDedgeFormat::writeLines
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fileFormats::STARCDedgeFormat::readHeader
|
|
||||||
(
|
|
||||||
IFstream& is,
|
|
||||||
const word& signature
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (!is.good())
|
|
||||||
{
|
|
||||||
FatalErrorIn
|
|
||||||
(
|
|
||||||
"fileFormats::STARCDedgeFormat::readHeader(...)"
|
|
||||||
)
|
|
||||||
<< "cannot read " << signature << " " << is.name()
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
word header;
|
|
||||||
label majorVersion;
|
|
||||||
|
|
||||||
string line;
|
|
||||||
|
|
||||||
is.getLine(line);
|
|
||||||
IStringStream(line)() >> header;
|
|
||||||
|
|
||||||
is.getLine(line);
|
|
||||||
IStringStream(line)() >> majorVersion;
|
|
||||||
|
|
||||||
// add other checks ...
|
|
||||||
if (header != signature)
|
|
||||||
{
|
|
||||||
Info<< "header mismatch " << signature << " " << is.name()
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::STARCDedgeFormat::writeHeader
|
|
||||||
(
|
|
||||||
Ostream& os,
|
|
||||||
const char* filetype
|
|
||||||
)
|
|
||||||
{
|
|
||||||
os << "PROSTAR_" << filetype << nl
|
|
||||||
<< 4000
|
|
||||||
<< " " << 0
|
|
||||||
<< " " << 0
|
|
||||||
<< " " << 0
|
|
||||||
<< " " << 0
|
|
||||||
<< " " << 0
|
|
||||||
<< " " << 0
|
|
||||||
<< " " << 0
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::fileFormats::STARCDedgeFormat::readPoints
|
|
||||||
(
|
|
||||||
IFstream& is,
|
|
||||||
pointField& points,
|
|
||||||
labelList& ids
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// read .vrt file
|
|
||||||
// ~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
if (!is.good())
|
|
||||||
{
|
|
||||||
FatalErrorIn
|
|
||||||
(
|
|
||||||
"fileFormats::STARCDedgeFormat::readPoints(...)"
|
|
||||||
)
|
|
||||||
<< "Cannot read file " << is.name()
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
readHeader(is, "PROSTAR_VERTEX");
|
|
||||||
|
|
||||||
DynamicList<point> dynPoints;
|
|
||||||
DynamicList<label> dynPointId; // STAR-CD index of points
|
|
||||||
|
|
||||||
label lineLabel;
|
|
||||||
while ((is >> lineLabel).good())
|
|
||||||
{
|
|
||||||
scalar x, y, z;
|
|
||||||
|
|
||||||
is >> x >> y >> z;
|
|
||||||
|
|
||||||
dynPoints.append(point(x, y, z));
|
|
||||||
dynPointId.append(lineLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
points.transfer(dynPoints);
|
|
||||||
ids.transfer(dynPointId);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::STARCDedgeFormat::writePoints
|
|
||||||
(
|
|
||||||
Ostream& os,
|
|
||||||
const pointField& pointLst
|
|
||||||
)
|
|
||||||
{
|
|
||||||
writeHeader(os, "VERTEX");
|
|
||||||
|
|
||||||
// Set the precision of the points data to 10
|
|
||||||
os.precision(10);
|
|
||||||
|
|
||||||
// force decimal point for Fortran input
|
|
||||||
os.setf(std::ios::showpoint);
|
|
||||||
|
|
||||||
forAll(pointLst, ptI)
|
|
||||||
{
|
|
||||||
os
|
|
||||||
<< ptI + 1 << " "
|
|
||||||
<< pointLst[ptI].x() << " "
|
|
||||||
<< pointLst[ptI].y() << " "
|
|
||||||
<< pointLst[ptI].z() << nl;
|
|
||||||
}
|
|
||||||
os.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::STARCDedgeFormat::writeCase
|
void Foam::fileFormats::STARCDedgeFormat::writeCase
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
|
|||||||
@ -43,6 +43,8 @@ SourceFiles
|
|||||||
#define STARCDedgeFormat_H
|
#define STARCDedgeFormat_H
|
||||||
|
|
||||||
#include "edgeMesh.H"
|
#include "edgeMesh.H"
|
||||||
|
#include "STARCDCore.H"
|
||||||
|
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
@ -60,7 +62,8 @@ namespace fileFormats
|
|||||||
|
|
||||||
class STARCDedgeFormat
|
class STARCDedgeFormat
|
||||||
:
|
:
|
||||||
public edgeMesh
|
public edgeMesh,
|
||||||
|
public STARCDCore
|
||||||
{
|
{
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
@ -90,14 +93,6 @@ protected:
|
|||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
static bool readHeader(IFstream&, const word&);
|
|
||||||
|
|
||||||
static void writeHeader(Ostream&, const char* filetype);
|
|
||||||
|
|
||||||
static bool readPoints(IFstream&, pointField&, labelList& ids);
|
|
||||||
|
|
||||||
static void writePoints(Ostream&, const pointField&);
|
|
||||||
|
|
||||||
static void writeCase
|
static void writeCase
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
|
|||||||
4
src/fileFormats/Make/files
Normal file
4
src/fileFormats/Make/files
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
nas/NASCore.C
|
||||||
|
starcd/STARCDCore.C
|
||||||
|
|
||||||
|
LIB = $(FOAM_LIBBIN)/libfileFormats
|
||||||
0
src/fileFormats/Make/options
Normal file
0
src/fileFormats/Make/options
Normal file
@ -24,13 +24,18 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "NASsurfaceFormatCore.H"
|
#include "NASCore.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Do weird things to extract a floating point number
|
Foam::fileFormats::NASCore::NASCore()
|
||||||
Foam::scalar Foam::fileFormats::NASsurfaceFormatCore::parseNASCoord
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::scalar Foam::fileFormats::NASCore::parseNASCoord
|
||||||
(
|
(
|
||||||
const string& s
|
const string& s
|
||||||
)
|
)
|
||||||
@ -2,7 +2,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) 1991-2009 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,21 +23,21 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fileFormats::NASsurfaceFormatCore
|
Foam::fileFormats::NASCore
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Internal class used by the NASsurfaceFormat
|
Core routines used when reading/writing NASTRAN files.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
NASsurfaceFormatCore.C
|
NASCore.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef NASsurfaceFormatCore_H
|
#ifndef NASCore_H
|
||||||
#define NASsurfaceFormatCore_H
|
#define NASCore_H
|
||||||
|
|
||||||
#include "Ostream.H"
|
#include "scalar.H"
|
||||||
#include "OFstream.H"
|
#include "string.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -47,17 +47,25 @@ namespace fileFormats
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class NASsurfaceFormatCore Declaration
|
Class fileFormats::NASCore Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class NASsurfaceFormatCore
|
class NASCore
|
||||||
{
|
{
|
||||||
protected:
|
public:
|
||||||
|
|
||||||
// Protected Member Functions
|
// Public Member Functions
|
||||||
|
|
||||||
//- Do weird things to extract number
|
//- Do weird things to extract number
|
||||||
static scalar parseNASCoord(const string&);
|
static scalar parseNASCoord(const string&);
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
NASCore();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
173
src/fileFormats/starcd/STARCDCore.C
Normal file
173
src/fileFormats/starcd/STARCDCore.C
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2006-2010 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "STARCDCore.H"
|
||||||
|
#include "ListOps.H"
|
||||||
|
#include "clock.H"
|
||||||
|
#include "PackedBoolList.H"
|
||||||
|
#include "IStringStream.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fileFormats::STARCDCore::STARCDCore()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::fileFormats::STARCDCore::readHeader
|
||||||
|
(
|
||||||
|
IFstream& is,
|
||||||
|
const word& signature
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!is.good())
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"fileFormats::STARCDCore::readHeader(...)"
|
||||||
|
)
|
||||||
|
<< "cannot read " << signature << " " << is.name()
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
word header;
|
||||||
|
label majorVersion;
|
||||||
|
|
||||||
|
string line;
|
||||||
|
|
||||||
|
is.getLine(line);
|
||||||
|
IStringStream(line)() >> header;
|
||||||
|
|
||||||
|
is.getLine(line);
|
||||||
|
IStringStream(line)() >> majorVersion;
|
||||||
|
|
||||||
|
// add other checks ...
|
||||||
|
if (header != signature)
|
||||||
|
{
|
||||||
|
Info<< "header mismatch " << signature << " " << is.name()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fileFormats::STARCDCore::writeHeader
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const word& filetype
|
||||||
|
)
|
||||||
|
{
|
||||||
|
os << "PROSTAR_" << filetype << nl
|
||||||
|
<< 4000
|
||||||
|
<< " " << 0
|
||||||
|
<< " " << 0
|
||||||
|
<< " " << 0
|
||||||
|
<< " " << 0
|
||||||
|
<< " " << 0
|
||||||
|
<< " " << 0
|
||||||
|
<< " " << 0
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::fileFormats::STARCDCore::readPoints
|
||||||
|
(
|
||||||
|
IFstream& is,
|
||||||
|
pointField& points,
|
||||||
|
labelList& ids
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!is.good())
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"fileFormats::STARCDedgeFormat::readPoints(...)"
|
||||||
|
)
|
||||||
|
<< "Cannot read file " << is.name()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
readHeader(is, "PROSTAR_VERTEX");
|
||||||
|
|
||||||
|
|
||||||
|
// reuse memory if possible
|
||||||
|
DynamicList<point> dynPoints(points.xfer());
|
||||||
|
DynamicList<label> dynPointId(ids.xfer()); // STAR-CD index of points
|
||||||
|
|
||||||
|
dynPoints.clear();
|
||||||
|
dynPointId.clear();
|
||||||
|
|
||||||
|
label lineLabel;
|
||||||
|
while ((is >> lineLabel).good())
|
||||||
|
{
|
||||||
|
scalar x, y, z;
|
||||||
|
|
||||||
|
is >> x >> y >> z;
|
||||||
|
|
||||||
|
dynPoints.append(point(x, y, z));
|
||||||
|
dynPointId.append(lineLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
points.transfer(dynPoints);
|
||||||
|
ids.transfer(dynPointId);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fileFormats::STARCDCore::writePoints
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const pointField& pointLst
|
||||||
|
)
|
||||||
|
{
|
||||||
|
writeHeader(os, "VERTEX");
|
||||||
|
|
||||||
|
// Set the precision of the points data to 10
|
||||||
|
os.precision(10);
|
||||||
|
|
||||||
|
// force decimal point for Fortran input
|
||||||
|
os.setf(std::ios::showpoint);
|
||||||
|
|
||||||
|
forAll(pointLst, ptI)
|
||||||
|
{
|
||||||
|
os
|
||||||
|
<< ptI + 1 << " "
|
||||||
|
<< pointLst[ptI].x() << " "
|
||||||
|
<< pointLst[ptI].y() << " "
|
||||||
|
<< pointLst[ptI].z() << nl;
|
||||||
|
}
|
||||||
|
os.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
131
src/fileFormats/starcd/STARCDCore.H
Normal file
131
src/fileFormats/starcd/STARCDCore.H
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2006-2010 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::fileFormats::STARCDCore
|
||||||
|
|
||||||
|
Description
|
||||||
|
Core routines used when reading/writing pro-STAR vrt/cel/bnd files.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
STARCDCore.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef STARCDCore_H
|
||||||
|
#define STARCDCore_H
|
||||||
|
|
||||||
|
#include "IFstream.H"
|
||||||
|
#include "pointField.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace fileFormats
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class fileFormats::STARCDCore Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class STARCDCore
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Read header
|
||||||
|
static bool readHeader(IFstream&, const word& fileSignature);
|
||||||
|
|
||||||
|
//- Write header for fileType (CELL|VERTEX|BOUNDARY)
|
||||||
|
static void writeHeader(Ostream&, const word& fileType);
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
enum cellType
|
||||||
|
{
|
||||||
|
starcdFluidType = 1,
|
||||||
|
starcdSolidType = 2,
|
||||||
|
starcdBaffleType = 3,
|
||||||
|
starcdShellType = 4,
|
||||||
|
starcdLineType = 5,
|
||||||
|
starcdPointType = 6
|
||||||
|
};
|
||||||
|
|
||||||
|
enum shapeType
|
||||||
|
{
|
||||||
|
starcdPoint = 1,
|
||||||
|
starcdLine = 2,
|
||||||
|
starcdShell = 3,
|
||||||
|
starcdHex = 11,
|
||||||
|
starcdPrism = 12,
|
||||||
|
starcdTet = 13,
|
||||||
|
starcdPyr = 14,
|
||||||
|
starcdPoly = 255
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Public Member Functions
|
||||||
|
|
||||||
|
//- Read points from a (.vrt) file
|
||||||
|
// The file format is as follows:
|
||||||
|
// @verbatim
|
||||||
|
// Line 1:
|
||||||
|
// PROSTAR_VERTEX newline
|
||||||
|
//
|
||||||
|
// Line 2:
|
||||||
|
// {version} 0 0 0 0 0 0 0 newline
|
||||||
|
//
|
||||||
|
// Body:
|
||||||
|
// {vertexId} {x} {y} {z} newline
|
||||||
|
// @endverbatim
|
||||||
|
static bool readPoints(IFstream&, pointField&, labelList& ids);
|
||||||
|
|
||||||
|
//- Write header and points to (.vrt) file
|
||||||
|
static void writePoints(Ostream&, const pointField&);
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
STARCDCore();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace fileFormats
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -24,7 +24,6 @@ $(surfaceFormats)/ac3d/AC3DsurfaceFormatCore.C
|
|||||||
$(surfaceFormats)/ac3d/AC3DsurfaceFormatRunTime.C
|
$(surfaceFormats)/ac3d/AC3DsurfaceFormatRunTime.C
|
||||||
$(surfaceFormats)/ftr/FTRsurfaceFormatRunTime.C
|
$(surfaceFormats)/ftr/FTRsurfaceFormatRunTime.C
|
||||||
$(surfaceFormats)/gts/GTSsurfaceFormatRunTime.C
|
$(surfaceFormats)/gts/GTSsurfaceFormatRunTime.C
|
||||||
$(surfaceFormats)/nas/NASsurfaceFormatCore.C
|
|
||||||
$(surfaceFormats)/nas/NASsurfaceFormatRunTime.C
|
$(surfaceFormats)/nas/NASsurfaceFormatRunTime.C
|
||||||
$(surfaceFormats)/obj/OBJsurfaceFormatRunTime.C
|
$(surfaceFormats)/obj/OBJsurfaceFormatRunTime.C
|
||||||
$(surfaceFormats)/off/OFFsurfaceFormatRunTime.C
|
$(surfaceFormats)/off/OFFsurfaceFormatRunTime.C
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/fileFormats/lnInclude
|
||||||
|
|
||||||
|
LIB_LIBS = \
|
||||||
|
-lfileFormats
|
||||||
|
|||||||
@ -47,7 +47,7 @@ SourceFiles
|
|||||||
#include "MeshedSurface.H"
|
#include "MeshedSurface.H"
|
||||||
#include "MeshedSurfaceProxy.H"
|
#include "MeshedSurfaceProxy.H"
|
||||||
#include "UnsortedMeshedSurface.H"
|
#include "UnsortedMeshedSurface.H"
|
||||||
#include "NASsurfaceFormatCore.H"
|
#include "NASCore.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ template<class Face>
|
|||||||
class NASsurfaceFormat
|
class NASsurfaceFormat
|
||||||
:
|
:
|
||||||
public MeshedSurface<Face>,
|
public MeshedSurface<Face>,
|
||||||
public NASsurfaceFormatCore
|
public NASCore
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
|||||||
@ -31,63 +31,6 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fileFormats::STARCDsurfaceFormatCore::readHeader
|
|
||||||
(
|
|
||||||
IFstream& is,
|
|
||||||
const word& signature
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (!is.good())
|
|
||||||
{
|
|
||||||
FatalErrorIn
|
|
||||||
(
|
|
||||||
"fileFormats::STARCDsurfaceFormatCore::readHeader(...)"
|
|
||||||
)
|
|
||||||
<< "cannot read " << signature << " " << is.name()
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
word header;
|
|
||||||
label majorVersion;
|
|
||||||
|
|
||||||
string line;
|
|
||||||
|
|
||||||
is.getLine(line);
|
|
||||||
IStringStream(line)() >> header;
|
|
||||||
|
|
||||||
is.getLine(line);
|
|
||||||
IStringStream(line)() >> majorVersion;
|
|
||||||
|
|
||||||
// add other checks ...
|
|
||||||
if (header != signature)
|
|
||||||
{
|
|
||||||
Info<< "header mismatch " << signature << " " << is.name()
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::STARCDsurfaceFormatCore::writeHeader
|
|
||||||
(
|
|
||||||
Ostream& os,
|
|
||||||
const char* filetype
|
|
||||||
)
|
|
||||||
{
|
|
||||||
os << "PROSTAR_" << filetype << nl
|
|
||||||
<< 4000
|
|
||||||
<< " " << 0
|
|
||||||
<< " " << 0
|
|
||||||
<< " " << 0
|
|
||||||
<< " " << 0
|
|
||||||
<< " " << 0
|
|
||||||
<< " " << 0
|
|
||||||
<< " " << 0
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// parse things like this:
|
// parse things like this:
|
||||||
// CTNAME 1 someName
|
// CTNAME 1 someName
|
||||||
// don't bother with the older comma-delimited format
|
// don't bother with the older comma-delimited format
|
||||||
@ -102,12 +45,12 @@ Foam::fileFormats::STARCDsurfaceFormatCore::readInpCellTable
|
|||||||
|
|
||||||
regExp ctnameRE
|
regExp ctnameRE
|
||||||
(
|
(
|
||||||
" *CTNA[^ ]*" // keyword - min 4 chars
|
" *CTNA[^ ]*" // keyword - min 4 chars
|
||||||
"[[:space:]]+" // space delimited
|
"[[:space:]]+" // space delimited
|
||||||
"([0-9]+)" // 1: <digits>
|
"([0-9]+)" // 1: <digits>
|
||||||
"[[:space:]]+" // space delimited
|
"[[:space:]]+" // space delimited
|
||||||
"([^,[:space:]].*)", // 2: <name>
|
"([^,[:space:]].*)", // 2: <name>
|
||||||
true // ignore case
|
true // ignore case
|
||||||
);
|
);
|
||||||
|
|
||||||
string line;
|
string line;
|
||||||
@ -132,78 +75,6 @@ Foam::fileFormats::STARCDsurfaceFormatCore::readInpCellTable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::fileFormats::STARCDsurfaceFormatCore::readPoints
|
|
||||||
(
|
|
||||||
IFstream& is,
|
|
||||||
pointField& points,
|
|
||||||
labelList& ids
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// read .vrt file
|
|
||||||
// ~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
if (!is.good())
|
|
||||||
{
|
|
||||||
FatalErrorIn
|
|
||||||
(
|
|
||||||
"fileFormats::STARCDsurfaceFormatCore::readPoints(...)"
|
|
||||||
)
|
|
||||||
<< "Cannot read file " << is.name()
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
readHeader(is, "PROSTAR_VERTEX");
|
|
||||||
|
|
||||||
DynamicList<point> dynPoints;
|
|
||||||
// STAR-CD index of points
|
|
||||||
DynamicList<label> dynPointId;
|
|
||||||
|
|
||||||
label lineLabel;
|
|
||||||
while ((is >> lineLabel).good())
|
|
||||||
{
|
|
||||||
scalar x, y, z;
|
|
||||||
|
|
||||||
is >> x >> y >> z;
|
|
||||||
|
|
||||||
dynPoints.append(point(x, y, z));
|
|
||||||
dynPointId.append(lineLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
points.transfer(dynPoints);
|
|
||||||
ids.transfer(dynPointId);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::STARCDsurfaceFormatCore::writePoints
|
|
||||||
(
|
|
||||||
Ostream& os,
|
|
||||||
const pointField& pointLst
|
|
||||||
)
|
|
||||||
{
|
|
||||||
writeHeader(os, "VERTEX");
|
|
||||||
|
|
||||||
// Set the precision of the points data to 10
|
|
||||||
os.precision(10);
|
|
||||||
|
|
||||||
// force decimal point for Fortran input
|
|
||||||
os.setf(std::ios::showpoint);
|
|
||||||
|
|
||||||
forAll(pointLst, ptI)
|
|
||||||
{
|
|
||||||
os
|
|
||||||
<< ptI + 1 << " "
|
|
||||||
<< pointLst[ptI].x() << " "
|
|
||||||
<< pointLst[ptI].y() << " "
|
|
||||||
<< pointLst[ptI].z() << nl;
|
|
||||||
}
|
|
||||||
os.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
|
void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
@ -238,4 +109,3 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
|
|||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,7 @@ SourceFiles
|
|||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "MeshedSurface.H"
|
#include "MeshedSurface.H"
|
||||||
|
#include "STARCDCore.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -53,21 +54,15 @@ namespace fileFormats
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class STARCDsurfaceFormatCore
|
class STARCDsurfaceFormatCore
|
||||||
|
:
|
||||||
|
public STARCDCore
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
static bool readHeader(IFstream&, const word&);
|
|
||||||
|
|
||||||
static void writeHeader(Ostream&, const char* filetype);
|
|
||||||
|
|
||||||
static Map<word> readInpCellTable(IFstream&);
|
static Map<word> readInpCellTable(IFstream&);
|
||||||
|
|
||||||
static bool readPoints(IFstream&, pointField&, labelList& ids);
|
|
||||||
|
|
||||||
static void writePoints(Ostream&, const pointField&);
|
|
||||||
|
|
||||||
static void writeCase
|
static void writeCase
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
|
|||||||
@ -1 +1,5 @@
|
|||||||
EXE_INC =
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/fileFormats/lnInclude
|
||||||
|
|
||||||
|
LIB_LIBS = \
|
||||||
|
-lfileFormats
|
||||||
|
|||||||
Reference in New Issue
Block a user