mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: expand data mask for foamToEnsight (issue #231)
- Default is a width of 8 characters, but this can be extended up to 31
characters via the '-width' command-line option.
- Now use a similar structure as foamToEnsightParts for the masking.
This reduces the clutter within the directory, makes it easier to
selectively delete some time steps (using shell commands).
- Added in a "time" information data in each sub-directory to
make it possible to reconstruct the case file with an external
script.
- Conversion of cloud data should now also work in parallel
(may need more testing).
- Support binary output for cloud data.
- Better avoidance of illegal ensight variable names.
But still partially incomplete (due to patch fields).
==================================================
Example of NEW file structure:
EnSight/verticalChannel.case # case name
EnSight/geometry # for non-moving geometry
EnSight/data/ # time-varying data
EnSight/data/00000000/
EnSight/data/00000001/
...
Fields are stored by name within the data/********/ directories:
EnSight/data/00000001/time # human-readable time info
EnSight/data/00000001/U
EnSight/data/00000001/p
...
EnSight/data/00000001/geometry # for moving geometry
Clouds are stored at the next sub-directory level:
EnSight/data/00000001/lagrangian/<cloudName>/positions
EnSight/data/00000001/lagrangian/<cloudName>/U
...
==================================================
The old structure was significantly more cluttered:
EnSight/verticalChannel.case
EnSight/verticalChannel.0000.mesh
EnSight/verticalChannel.0001.p
EnSight/verticalChannel.0001.<cloudName>
EnSight/verticalChannel.0001.<cloudName>.U
==================================================
This commit is contained in:
@ -1,6 +1,5 @@
|
|||||||
itoa.C
|
|
||||||
ensightMesh.C
|
ensightMesh.C
|
||||||
ensightParticlePositions.C
|
ensightCloud.C
|
||||||
foamToEnsight.C
|
foamToEnsight.C
|
||||||
|
|
||||||
EXE = $(FOAM_APPBIN)/foamToEnsight
|
EXE = $(FOAM_APPBIN)/foamToEnsight
|
||||||
|
|||||||
@ -5,7 +5,8 @@ EXE_INC = \
|
|||||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
-I$(LIB_SRC)/fileFormats/lnInclude \
|
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||||
-I$(LIB_SRC)/sampling/lnInclude \
|
-I$(LIB_SRC)/sampling/lnInclude \
|
||||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude
|
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||||
|
-I$(LIB_SRC)/conversion/lnInclude
|
||||||
|
|
||||||
EXE_LIBS = \
|
EXE_LIBS = \
|
||||||
-lfiniteVolume \
|
-lfiniteVolume \
|
||||||
@ -13,5 +14,5 @@ EXE_LIBS = \
|
|||||||
-lfileFormats \
|
-lfileFormats \
|
||||||
-lsampling \
|
-lsampling \
|
||||||
-lgenericPatchFields \
|
-lgenericPatchFields \
|
||||||
-llagrangian
|
-llagrangian \
|
||||||
|
-lconversion
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// ignore special fields or fields that we don't handle
|
// ignore special fields or fields that we don't handle
|
||||||
//
|
//
|
||||||
bool variableGood = true;
|
bool variableGood = true;
|
||||||
for (label n1=0; n1<Times.size() && variableGood; ++n1)
|
for (label n1=0; n1<timeDirs.size() && variableGood; ++n1)
|
||||||
{
|
{
|
||||||
// ignore _0 fields
|
// ignore _0 fields
|
||||||
if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) == "_0")
|
if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) == "_0")
|
||||||
@ -13,7 +13,7 @@ for (label n1=0; n1<Times.size() && variableGood; ++n1)
|
|||||||
variableGood = IOobject
|
variableGood = IOobject
|
||||||
(
|
(
|
||||||
fieldName,
|
fieldName,
|
||||||
Times[n1].name(),
|
timeDirs[n1].name(),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::NO_READ
|
IOobject::NO_READ
|
||||||
).typeHeaderOk<volScalarField>(false);
|
).typeHeaderOk<volScalarField>(false);
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
// check for "points" in any of the result directories
|
// check for "points" in any of the result directories
|
||||||
|
|
||||||
bool meshMoving = false;
|
bool meshMoving = false;
|
||||||
if (Times.size() > 1)
|
if (timeDirs.size() > 1)
|
||||||
{
|
{
|
||||||
// We already loaded a mesh (usually from constant). See if any other
|
// We already loaded a mesh (usually from constant). See if any other
|
||||||
// points files
|
// points files
|
||||||
forAll(Times, timeI)
|
forAll(timeDirs, timeI)
|
||||||
{
|
{
|
||||||
if (Times[timeI].name() != mesh.pointsInstance())
|
if (timeDirs[timeI].name() != mesh.pointsInstance())
|
||||||
{
|
{
|
||||||
IOobject io
|
meshMoving = IOobject
|
||||||
(
|
(
|
||||||
"points",
|
"points",
|
||||||
Times[timeI].name(),
|
timeDirs[timeI].name(),
|
||||||
polyMesh::meshSubDir,
|
polyMesh::meshSubDir,
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::NO_READ
|
IOobject::NO_READ
|
||||||
);
|
).typeHeaderOk<pointIOField>(true);
|
||||||
if (io.typeHeaderOk<pointIOField>(true))
|
|
||||||
|
if (meshMoving)
|
||||||
{
|
{
|
||||||
meshMoving = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -52,17 +52,17 @@ class ensightAsciiStream
|
|||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Description of data_
|
//- Output file stream
|
||||||
OFstream str_;
|
OFstream str_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
ensightAsciiStream(const ensightAsciiStream&);
|
ensightAsciiStream(const ensightAsciiStream&) = delete;
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const ensightAsciiStream&);
|
void operator=(const ensightAsciiStream&) = delete;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -70,14 +70,14 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
ensightAsciiStream(const fileName& f, const Time& runTime)
|
ensightAsciiStream(const fileName& f)
|
||||||
:
|
:
|
||||||
ensightStream(f),
|
ensightStream(f),
|
||||||
str_
|
str_
|
||||||
(
|
(
|
||||||
f,
|
f,
|
||||||
runTime.writeFormat(),
|
IOstream::ASCII,
|
||||||
runTime.writeVersion(),
|
IOstream::currentVersion,
|
||||||
IOstream::UNCOMPRESSED
|
IOstream::UNCOMPRESSED
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -139,14 +139,6 @@ public:
|
|||||||
<< setw(10) << partI << nl;
|
<< setw(10) << partI << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Member Operators
|
|
||||||
|
|
||||||
// Friend Functions
|
|
||||||
|
|
||||||
// Friend Operators
|
|
||||||
|
|
||||||
// IOstream Operators
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -51,17 +51,17 @@ class ensightBinaryStream
|
|||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Description of data_
|
//- Output file stream
|
||||||
autoPtr<std::ofstream> str_;
|
autoPtr<std::ofstream> str_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
ensightBinaryStream(const ensightBinaryStream&);
|
ensightBinaryStream(const ensightBinaryStream&) = delete;
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const ensightBinaryStream&);
|
void operator=(const ensightBinaryStream&) = delete;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -69,7 +69,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
ensightBinaryStream(const fileName& f, const Time&)
|
ensightBinaryStream(const fileName& f)
|
||||||
:
|
:
|
||||||
ensightStream(f),
|
ensightStream(f),
|
||||||
str_
|
str_
|
||||||
@ -90,11 +90,6 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
virtual bool ascii() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void write(const char* val)
|
virtual void write(const char* val)
|
||||||
{
|
{
|
||||||
char buffer[80];
|
char buffer[80];
|
||||||
@ -141,14 +136,6 @@ public:
|
|||||||
write(partI);
|
write(partI);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Member Operators
|
|
||||||
|
|
||||||
// Friend Functions
|
|
||||||
|
|
||||||
// Friend Operators
|
|
||||||
|
|
||||||
// IOstream Operators
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
|
ensightCaseFile.setf(ios_base::scientific, ios_base::floatfield);
|
||||||
|
ensightCaseFile.precision(5);
|
||||||
|
|
||||||
ensightCaseFile << nl << "TIME" << nl
|
ensightCaseFile << nl << "TIME" << nl
|
||||||
<< "time set: " << 1 << nl
|
<< "time set: " << 1 << nl
|
||||||
<< "number of steps: " << nTimeSteps << nl
|
<< "number of steps: " << nTimeSteps << nl
|
||||||
@ -8,20 +11,17 @@ if (Pstream::master())
|
|||||||
|
|
||||||
ensightCaseFile << "time values:" << nl;
|
ensightCaseFile << "time values:" << nl;
|
||||||
|
|
||||||
ensightCaseFile.setf(ios_base::scientific, ios_base::floatfield);
|
|
||||||
ensightCaseFile.precision(5);
|
|
||||||
|
|
||||||
label count = 0;
|
label count = 0;
|
||||||
scalar Tcorr = 0.0;
|
scalar Tcorr = 0.0;
|
||||||
if (Times[0].value() < 0)
|
if (timeDirs[0].value() < 0)
|
||||||
{
|
{
|
||||||
Tcorr = - Times[0].value();
|
Tcorr = -timeDirs[0].value();
|
||||||
Info<< "Correcting time values. Adding " << Tcorr << endl;
|
Info<< "Correcting time values. Adding " << Tcorr << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(Times, n)
|
forAll(timeDirs, n)
|
||||||
{
|
{
|
||||||
ensightCaseFile << setw(12) << Times[n].value() + Tcorr << " ";
|
ensightCaseFile << setw(12) << timeDirs[n].value() + Tcorr << " ";
|
||||||
|
|
||||||
if (++count % 6 == 0)
|
if (++count % 6 == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -0,0 +1,180 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "ensightCloud.H"
|
||||||
|
#include "ensightFile.H"
|
||||||
|
#include "fvMesh.H"
|
||||||
|
#include "passiveParticle.H"
|
||||||
|
#include "Cloud.H"
|
||||||
|
#include "pointList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::ensightParticlePositions
|
||||||
|
(
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const fileName& dataDir,
|
||||||
|
const label timeIndex,
|
||||||
|
const word& cloudName,
|
||||||
|
const bool dataExists,
|
||||||
|
IOstream::streamFormat format
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (dataExists)
|
||||||
|
{
|
||||||
|
Info<< " positions";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< " positions{0}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Total number of parcels on all processes
|
||||||
|
label nTotParcels = 0;
|
||||||
|
autoPtr<Cloud<passiveParticle>> cloudPtr;
|
||||||
|
|
||||||
|
if (dataExists)
|
||||||
|
{
|
||||||
|
cloudPtr.reset(new Cloud<passiveParticle>(mesh, cloudName, false));
|
||||||
|
nTotParcels = cloudPtr().size();
|
||||||
|
}
|
||||||
|
reduce(nTotParcels, sumOp<label>());
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
const fileName postFileName =
|
||||||
|
ensightFile::subDir(timeIndex)/cloud::prefix/cloudName/"positions";
|
||||||
|
|
||||||
|
// the ITER/lagrangian subdirectory must exist
|
||||||
|
mkDir(dataDir/postFileName.path());
|
||||||
|
|
||||||
|
ensightFile os(dataDir, postFileName, format);
|
||||||
|
|
||||||
|
// tag binary format (just like geometry files)
|
||||||
|
os.writeBinaryHeader();
|
||||||
|
os.write(postFileName); // description
|
||||||
|
os.newline();
|
||||||
|
os.write("particle coordinates");
|
||||||
|
os.newline();
|
||||||
|
os.write(nTotParcels, 8); // unusual width
|
||||||
|
os.newline();
|
||||||
|
|
||||||
|
if (!nTotParcels)
|
||||||
|
{
|
||||||
|
return; // DONE
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format == IOstream::BINARY)
|
||||||
|
{
|
||||||
|
// binary write is Ensight6 - first ids, then positions
|
||||||
|
|
||||||
|
// 1-index
|
||||||
|
for (label parcelId = 0; parcelId < nTotParcels; ++parcelId)
|
||||||
|
{
|
||||||
|
os.write(parcelId+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Master
|
||||||
|
forAllConstIter(Cloud<passiveParticle>, cloudPtr(), elmnt)
|
||||||
|
{
|
||||||
|
const point& p = elmnt().position();
|
||||||
|
|
||||||
|
os.write(p.x());
|
||||||
|
os.write(p.y());
|
||||||
|
os.write(p.z());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slaves
|
||||||
|
for (int slave=1; slave<Pstream::nProcs(); ++slave)
|
||||||
|
{
|
||||||
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
|
pointList points(fromSlave);
|
||||||
|
|
||||||
|
forAll(points, pti)
|
||||||
|
{
|
||||||
|
const point& p = points[pti];
|
||||||
|
|
||||||
|
os.write(p.x());
|
||||||
|
os.write(p.y());
|
||||||
|
os.write(p.z());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ASCII id + position together
|
||||||
|
|
||||||
|
label parcelId = 0;
|
||||||
|
forAllConstIter(Cloud<passiveParticle>, cloudPtr(), elmnt)
|
||||||
|
{
|
||||||
|
const point& p = elmnt().position();
|
||||||
|
|
||||||
|
os.write(++parcelId, 8); // unusual width
|
||||||
|
os.write(p.x());
|
||||||
|
os.write(p.y());
|
||||||
|
os.write(p.z());
|
||||||
|
os.newline();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slaves
|
||||||
|
for (int slave=1; slave<Pstream::nProcs(); ++slave)
|
||||||
|
{
|
||||||
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
|
pointList points(fromSlave);
|
||||||
|
|
||||||
|
forAll(points, pti)
|
||||||
|
{
|
||||||
|
const point& p = points[pti];
|
||||||
|
|
||||||
|
os.write(++parcelId, 8); // unusual width
|
||||||
|
os.write(p.x());
|
||||||
|
os.write(p.y());
|
||||||
|
os.write(p.z());
|
||||||
|
os.newline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (nTotParcels)
|
||||||
|
{
|
||||||
|
// SLAVE, and data exist
|
||||||
|
pointList points(cloudPtr().size());
|
||||||
|
|
||||||
|
label pti = 0;
|
||||||
|
forAllConstIter(Cloud<passiveParticle>, cloudPtr(), elmnt)
|
||||||
|
{
|
||||||
|
const point& p = elmnt().position();
|
||||||
|
points[pti++] = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
|
toMaster<< points;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -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 |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -27,35 +27,62 @@ InApplication
|
|||||||
Description
|
Description
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
ensightCloudField.C
|
ensightCloud.C
|
||||||
|
ensightCloudTemplates.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef ensightCloudField_H
|
#ifndef ensightCloud_H
|
||||||
#define ensightCloudField_H
|
#define ensightCloud_H
|
||||||
|
|
||||||
|
#include "ensightFile.H"
|
||||||
|
#include "fvMesh.H"
|
||||||
#include "Cloud.H"
|
#include "Cloud.H"
|
||||||
#include "IOobject.H"
|
#include "IOobject.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
void ensightParticlePositions
|
||||||
|
(
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const fileName& dataDir,
|
||||||
|
const label timeIndex,
|
||||||
|
const word& cloudName,
|
||||||
|
const bool dataExists,
|
||||||
|
const IOstream::streamFormat format
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void ensightCloudField
|
void ensightCloudField
|
||||||
(
|
(
|
||||||
const IOobject& fieldObject,
|
const IOobject& fieldObject,
|
||||||
const fileName& postProcPath,
|
const fileName& dataDir,
|
||||||
const word& prepend,
|
|
||||||
const label timeIndex,
|
const label timeIndex,
|
||||||
const word& timeFile,
|
|
||||||
const word& cloudName,
|
const word& cloudName,
|
||||||
|
const label cloudNo,
|
||||||
Ostream& ensightCaseFile,
|
Ostream& ensightCaseFile,
|
||||||
const bool dataExists
|
const bool dataExists,
|
||||||
|
const IOstream::streamFormat format
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void writeCloudField
|
||||||
|
(
|
||||||
|
const IOField<Type>& field,
|
||||||
|
ensightFile& os
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "ensightCloudField.C"
|
#include "ensightCloudTemplates.C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -1,129 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "ensightCloudField.H"
|
|
||||||
#include "Time.H"
|
|
||||||
#include "IOField.H"
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "IOmanip.H"
|
|
||||||
#include "ensightPTraits.H"
|
|
||||||
|
|
||||||
using namespace Foam;
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void ensightCloudField
|
|
||||||
(
|
|
||||||
const IOobject& fieldObject,
|
|
||||||
const fileName& postProcPath,
|
|
||||||
const word& prepend,
|
|
||||||
const label timeIndex,
|
|
||||||
const word& cloudName,
|
|
||||||
Ostream& ensightCaseFile,
|
|
||||||
const bool dataExists
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (dataExists)
|
|
||||||
{
|
|
||||||
Info<< "Converting cloud " << cloudName
|
|
||||||
<< " field " << fieldObject.name() << endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Info<< "Creating empty cloud " << cloudName
|
|
||||||
<< " field " << fieldObject.name() << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
word timeFile = prepend + itoa(timeIndex);
|
|
||||||
|
|
||||||
const Time& runTime = fieldObject.time();
|
|
||||||
|
|
||||||
if (timeIndex == 0 && Pstream::master())
|
|
||||||
{
|
|
||||||
ensightCaseFile
|
|
||||||
<< pTraits<Type>::typeName << " per measured node: 1 ";
|
|
||||||
ensightCaseFile.width(15);
|
|
||||||
ensightCaseFile.setf(ios_base::left);
|
|
||||||
ensightCaseFile
|
|
||||||
<< ("c" + fieldObject.name()).c_str()
|
|
||||||
<< (' ' + prepend + "****." + cloudName
|
|
||||||
+ "." + fieldObject.name()).c_str()
|
|
||||||
<< nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
fileName ensightFileName
|
|
||||||
(
|
|
||||||
timeFile + "." + cloudName +"." + fieldObject.name()
|
|
||||||
);
|
|
||||||
|
|
||||||
OFstream ensightFile
|
|
||||||
(
|
|
||||||
postProcPath/ensightFileName,
|
|
||||||
runTime.writeFormat(),
|
|
||||||
runTime.writeVersion(),
|
|
||||||
runTime.writeCompression()
|
|
||||||
);
|
|
||||||
|
|
||||||
ensightFile<< pTraits<Type>::typeName << " values" << nl;
|
|
||||||
|
|
||||||
if (dataExists)
|
|
||||||
{
|
|
||||||
IOField<Type> vf(fieldObject);
|
|
||||||
|
|
||||||
ensightFile.setf(ios_base::scientific, ios_base::floatfield);
|
|
||||||
ensightFile.precision(5);
|
|
||||||
|
|
||||||
label count = 0;
|
|
||||||
forAll(vf, i)
|
|
||||||
{
|
|
||||||
Type v = vf[i];
|
|
||||||
|
|
||||||
if (mag(v) < 1.0e-90)
|
|
||||||
{
|
|
||||||
v = Zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (direction i=0; i < pTraits<Type>::nComponents; ++i)
|
|
||||||
{
|
|
||||||
label cmpt = ensightPTraits<Type>::componentOrder[i];
|
|
||||||
|
|
||||||
ensightFile << setw(12) << component(v, cmpt);
|
|
||||||
if (++count % 6 == 0)
|
|
||||||
{
|
|
||||||
ensightFile << nl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((count % 6 != 0) || (count==0))
|
|
||||||
{
|
|
||||||
ensightFile << nl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -0,0 +1,192 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "ensightCloud.H"
|
||||||
|
#include "ensightFile.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "IOField.H"
|
||||||
|
#include "OFstream.H"
|
||||||
|
#include "IOmanip.H"
|
||||||
|
#include "ensightPTraits.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::writeCloudField
|
||||||
|
(
|
||||||
|
const Foam::IOField<Type>& field,
|
||||||
|
Foam::ensightFile& os
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (returnReduce(field.size(), sumOp<label>()) > 0)
|
||||||
|
{
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
// 6 values per line
|
||||||
|
label count = 0;
|
||||||
|
|
||||||
|
// Master
|
||||||
|
forAll(field, i)
|
||||||
|
{
|
||||||
|
Type val = field[i];
|
||||||
|
|
||||||
|
if (mag(val) < 1e-90)
|
||||||
|
{
|
||||||
|
val = Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (direction i=0; i < pTraits<Type>::nComponents; ++i)
|
||||||
|
{
|
||||||
|
label cmpt = ensightPTraits<Type>::componentOrder[i];
|
||||||
|
os.write( component(val, cmpt) );
|
||||||
|
|
||||||
|
if (++count % 6 == 0)
|
||||||
|
{
|
||||||
|
os.newline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slaves
|
||||||
|
for (int slave=1; slave<Pstream::nProcs(); ++slave)
|
||||||
|
{
|
||||||
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
|
Field<Type> slaveData(fromSlave);
|
||||||
|
|
||||||
|
forAll(slaveData, i)
|
||||||
|
{
|
||||||
|
Type val = slaveData[i];
|
||||||
|
|
||||||
|
if (mag(val) < 1e-90)
|
||||||
|
{
|
||||||
|
val = Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (direction i=0; i < pTraits<Type>::nComponents; ++i)
|
||||||
|
{
|
||||||
|
label cmpt = ensightPTraits<Type>::componentOrder[i];
|
||||||
|
os.write( component(val, cmpt) );
|
||||||
|
|
||||||
|
if (++count % 6 == 0)
|
||||||
|
{
|
||||||
|
os.newline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add final newline if required
|
||||||
|
if (count % 6)
|
||||||
|
{
|
||||||
|
os.newline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
|
toMaster<< field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::ensightCloudField
|
||||||
|
(
|
||||||
|
const Foam::IOobject& fieldObject,
|
||||||
|
const Foam::fileName& dataDir,
|
||||||
|
const Foam::label timeIndex,
|
||||||
|
const Foam::word& cloudName,
|
||||||
|
const Foam::label cloudNo,
|
||||||
|
Foam::Ostream& ensightCaseFile,
|
||||||
|
const bool dataExists,
|
||||||
|
Foam::IOstream::streamFormat format
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const ensight::VarName varName(fieldObject.name());
|
||||||
|
|
||||||
|
if (dataExists)
|
||||||
|
{
|
||||||
|
Info<< ' ' << fieldObject.name();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< ' ' << fieldObject.name() << "{0}"; // ie, empty field
|
||||||
|
}
|
||||||
|
|
||||||
|
ensightFile* filePtr(nullptr);
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
const fileName postFileName =
|
||||||
|
ensightFile::subDir(timeIndex)/cloud::prefix/cloudName/varName;
|
||||||
|
|
||||||
|
// the ITER/lagrangian subdirectory must exist
|
||||||
|
// the ITER/lagrangian subdirectory was already created
|
||||||
|
// when writing positions
|
||||||
|
|
||||||
|
mkDir(dataDir/postFileName.path());
|
||||||
|
|
||||||
|
if (timeIndex == 0)
|
||||||
|
{
|
||||||
|
const fileName dirName =
|
||||||
|
dataDir.name()/ensightFile::mask()/cloud::prefix/cloudName;
|
||||||
|
|
||||||
|
ensightCaseFile.setf(ios_base::left);
|
||||||
|
|
||||||
|
// prefix variables with 'c' (cloud)
|
||||||
|
ensightCaseFile
|
||||||
|
<< ensightPTraits<Type>::typeName << " per "
|
||||||
|
<< setw(20)
|
||||||
|
<< "measured node:"
|
||||||
|
<< " 1 "
|
||||||
|
<< setw(15)
|
||||||
|
<< ("c" + Foam::name(cloudNo) + varName).c_str() << ' '
|
||||||
|
<< (dirName/varName).c_str()
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
filePtr = new ensightFile(dataDir, postFileName, format);
|
||||||
|
filePtr->write
|
||||||
|
(
|
||||||
|
// description
|
||||||
|
string(postFileName + " <" + pTraits<Type>::typeName + ">")
|
||||||
|
);
|
||||||
|
filePtr->newline();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataExists)
|
||||||
|
{
|
||||||
|
IOField<Type> field(fieldObject);
|
||||||
|
writeCloudField(field, *filePtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filePtr) // on master only
|
||||||
|
{
|
||||||
|
delete filePtr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -23,12 +23,12 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "ensightFile.H"
|
||||||
#include "ensightField.H"
|
#include "ensightField.H"
|
||||||
#include "fvMesh.H"
|
#include "fvMesh.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "IOmanip.H"
|
#include "IOmanip.H"
|
||||||
#include "itoa.H"
|
|
||||||
#include "volPointInterpolation.H"
|
#include "volPointInterpolation.H"
|
||||||
#include "ensightBinaryStream.H"
|
#include "ensightBinaryStream.H"
|
||||||
#include "ensightAsciiStream.H"
|
#include "ensightAsciiStream.H"
|
||||||
@ -121,10 +121,8 @@ volField
|
|||||||
// const IOobject& io,
|
// const IOobject& io,
|
||||||
// const fvMesh& mesh,
|
// const fvMesh& mesh,
|
||||||
// const ensightMesh& eMesh,
|
// const ensightMesh& eMesh,
|
||||||
// const fileName& postProcPath,
|
// const fileName& dataDir,
|
||||||
// const word& prepend,
|
|
||||||
// const label timeIndex,
|
// const label timeIndex,
|
||||||
// const bool binary,
|
|
||||||
// const bool nodeValues,
|
// const bool nodeValues,
|
||||||
// Ostream& ensightCaseFile
|
// Ostream& ensightCaseFile
|
||||||
//)
|
//)
|
||||||
@ -134,10 +132,8 @@ volField
|
|||||||
// (
|
// (
|
||||||
// volField<typename Container::value_type>(meshSubsetter, fld),
|
// volField<typename Container::value_type>(meshSubsetter, fld),
|
||||||
// eMesh,
|
// eMesh,
|
||||||
// postProcPath,
|
// dataDir,
|
||||||
// prepend,
|
|
||||||
// timeIndex,
|
// timeIndex,
|
||||||
// binary,
|
|
||||||
// nodeValues,
|
// nodeValues,
|
||||||
// ensightCaseFile
|
// ensightCaseFile
|
||||||
// );
|
// );
|
||||||
@ -175,26 +171,26 @@ void writeField
|
|||||||
(
|
(
|
||||||
const char* key,
|
const char* key,
|
||||||
const Field<Type>& vf,
|
const Field<Type>& vf,
|
||||||
ensightStream& ensightFile
|
ensightStream& os
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (returnReduce(vf.size(), sumOp<label>()) > 0)
|
if (returnReduce(vf.size(), sumOp<label>()) > 0)
|
||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightFile.write(key);
|
os.write(key);
|
||||||
|
|
||||||
for (direction i=0; i < pTraits<Type>::nComponents; ++i)
|
for (direction i=0; i < pTraits<Type>::nComponents; ++i)
|
||||||
{
|
{
|
||||||
label cmpt = ensightPTraits<Type>::componentOrder[i];
|
label cmpt = ensightPTraits<Type>::componentOrder[i];
|
||||||
|
|
||||||
ensightFile.write(vf.component(cmpt));
|
os.write(vf.component(cmpt));
|
||||||
|
|
||||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||||
{
|
{
|
||||||
IPstream fromSlave(Pstream::scheduled, slave);
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
scalarField slaveData(fromSlave);
|
scalarField slaveData(fromSlave);
|
||||||
ensightFile.write(slaveData);
|
os.write(slaveData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,35 +216,35 @@ bool writePatchField
|
|||||||
const label ensightPatchI,
|
const label ensightPatchI,
|
||||||
const faceSets& boundaryFaceSet,
|
const faceSets& boundaryFaceSet,
|
||||||
const ensightMesh::nFacePrimitives& nfp,
|
const ensightMesh::nFacePrimitives& nfp,
|
||||||
ensightStream& ensightFile
|
ensightStream& os
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
|
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
|
||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightFile.writePartHeader(ensightPatchI);
|
os.writePartHeader(ensightPatchI);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeField
|
writeField
|
||||||
(
|
(
|
||||||
"tria3",
|
"tria3",
|
||||||
Field<Type>(pf, boundaryFaceSet.tris),
|
Field<Type>(pf, boundaryFaceSet.tris),
|
||||||
ensightFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeField
|
writeField
|
||||||
(
|
(
|
||||||
"quad4",
|
"quad4",
|
||||||
Field<Type>(pf, boundaryFaceSet.quads),
|
Field<Type>(pf, boundaryFaceSet.quads),
|
||||||
ensightFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeField
|
writeField
|
||||||
(
|
(
|
||||||
"nsided",
|
"nsided",
|
||||||
Field<Type>(pf, boundaryFaceSet.polys),
|
Field<Type>(pf, boundaryFaceSet.polys),
|
||||||
ensightFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -267,15 +263,11 @@ void writePatchField
|
|||||||
const Field<Type>& pf,
|
const Field<Type>& pf,
|
||||||
const word& patchName,
|
const word& patchName,
|
||||||
const ensightMesh& eMesh,
|
const ensightMesh& eMesh,
|
||||||
const fileName& postProcPath,
|
const fileName& dataDir,
|
||||||
const word& prepend,
|
|
||||||
const label timeIndex,
|
const label timeIndex,
|
||||||
const bool binary,
|
|
||||||
Ostream& ensightCaseFile
|
Ostream& ensightCaseFile
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const Time& runTime = eMesh.mesh().time();
|
|
||||||
|
|
||||||
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
|
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
|
||||||
const wordList& allPatchNames = eMesh.allPatchNames();
|
const wordList& allPatchNames = eMesh.allPatchNames();
|
||||||
const HashTable<ensightMesh::nFacePrimitives>&
|
const HashTable<ensightMesh::nFacePrimitives>&
|
||||||
@ -295,53 +287,51 @@ void writePatchField
|
|||||||
ensightPatchI++;
|
ensightPatchI++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ensightStream* filePtr(nullptr);
|
||||||
word pfName = patchName + '.' + fieldName;
|
|
||||||
|
|
||||||
word timeFile = prepend + itoa(timeIndex);
|
|
||||||
|
|
||||||
ensightStream* ensightFilePtr = NULL;
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
|
// TODO: verify that these are indeed valid ensight variable names
|
||||||
|
const word varName = patchName + '.' + fieldName;
|
||||||
|
const fileName postFileName = ensightFile::subDir(timeIndex)/varName;
|
||||||
|
|
||||||
|
// the data/ITER subdirectory must exist
|
||||||
|
mkDir(dataDir/postFileName.path());
|
||||||
|
|
||||||
if (timeIndex == 0)
|
if (timeIndex == 0)
|
||||||
{
|
{
|
||||||
ensightCaseFile.setf(ios_base::left);
|
const fileName dirName = dataDir.name()/ensightFile::mask();
|
||||||
|
|
||||||
|
ensightCaseFile.setf(ios_base::left);
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
<< ensightPTraits<Type>::typeName
|
<< ensightPTraits<Type>::typeName << " per "
|
||||||
<< " per element: 1 "
|
<< setw(20)
|
||||||
<< setw(15) << pfName
|
<< "element:"
|
||||||
<< (' ' + prepend + "****." + pfName).c_str()
|
<< " 1 "
|
||||||
|
<< setw(15)
|
||||||
|
<< varName.c_str() << ' '
|
||||||
|
<< (dirName/varName).c_str()
|
||||||
<< nl;
|
<< nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the filename of the ensight file
|
if (eMesh.format() == IOstream::BINARY)
|
||||||
fileName ensightFileName(timeFile + "." + pfName);
|
|
||||||
|
|
||||||
if (binary)
|
|
||||||
{
|
{
|
||||||
ensightFilePtr = new ensightBinaryStream
|
filePtr = new ensightBinaryStream
|
||||||
(
|
(
|
||||||
postProcPath/ensightFileName,
|
dataDir/postFileName
|
||||||
runTime
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ensightFilePtr = new ensightAsciiStream
|
filePtr = new ensightAsciiStream
|
||||||
(
|
(
|
||||||
postProcPath/ensightFileName,
|
dataDir/postFileName
|
||||||
runTime
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filePtr->write(ensightPTraits<Type>::typeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
ensightStream& ensightFile = *ensightFilePtr;
|
ensightStream& os = *filePtr;
|
||||||
|
|
||||||
if (Pstream::master())
|
|
||||||
{
|
|
||||||
ensightFile.write(ensightPTraits<Type>::typeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (patchi >= 0)
|
if (patchi >= 0)
|
||||||
{
|
{
|
||||||
@ -352,7 +342,7 @@ void writePatchField
|
|||||||
ensightPatchI,
|
ensightPatchI,
|
||||||
boundaryFaceSets[patchi],
|
boundaryFaceSets[patchi],
|
||||||
nPatchPrims.find(patchName)(),
|
nPatchPrims.find(patchName)(),
|
||||||
ensightFile
|
os
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -366,13 +356,13 @@ void writePatchField
|
|||||||
ensightPatchI,
|
ensightPatchI,
|
||||||
nullFaceSets,
|
nullFaceSets,
|
||||||
nPatchPrims.find(patchName)(),
|
nPatchPrims.find(patchName)(),
|
||||||
ensightFile
|
os
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::master())
|
if (filePtr) // on master only
|
||||||
{
|
{
|
||||||
delete ensightFilePtr;
|
delete filePtr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,19 +372,14 @@ void ensightField
|
|||||||
(
|
(
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& vf,
|
const GeometricField<Type, fvPatchField, volMesh>& vf,
|
||||||
const ensightMesh& eMesh,
|
const ensightMesh& eMesh,
|
||||||
const fileName& postProcPath,
|
const fileName& dataDir,
|
||||||
const word& prepend,
|
|
||||||
const label timeIndex,
|
const label timeIndex,
|
||||||
const bool binary,
|
|
||||||
Ostream& ensightCaseFile
|
Ostream& ensightCaseFile
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< "Converting field " << vf.name() << endl;
|
Info<< ' ' << vf.name();
|
||||||
|
|
||||||
word timeFile = prepend + itoa(timeIndex);
|
|
||||||
|
|
||||||
const fvMesh& mesh = eMesh.mesh();
|
const fvMesh& mesh = eMesh.mesh();
|
||||||
const Time& runTime = mesh.time();
|
|
||||||
|
|
||||||
const cellSets& meshCellSets = eMesh.meshCellSets();
|
const cellSets& meshCellSets = eMesh.meshCellSets();
|
||||||
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
|
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
|
||||||
@ -414,48 +399,48 @@ void ensightField
|
|||||||
const labelList& hexes = meshCellSets.hexes;
|
const labelList& hexes = meshCellSets.hexes;
|
||||||
const labelList& polys = meshCellSets.polys;
|
const labelList& polys = meshCellSets.polys;
|
||||||
|
|
||||||
ensightStream* ensightFilePtr = NULL;
|
ensightStream* filePtr(nullptr);
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
// set the filename of the ensight file
|
const ensight::VarName varName(vf.name());
|
||||||
fileName ensightFileName(timeFile + "." + vf.name());
|
const fileName postFileName = ensightFile::subDir(timeIndex)/varName;
|
||||||
|
|
||||||
if (binary)
|
// the data/ITER subdirectory must exist
|
||||||
|
mkDir(dataDir/postFileName.path());
|
||||||
|
|
||||||
|
if (timeIndex == 0)
|
||||||
{
|
{
|
||||||
ensightFilePtr = new ensightBinaryStream
|
const fileName dirName = dataDir.name()/ensightFile::mask();
|
||||||
|
|
||||||
|
ensightCaseFile.setf(ios_base::left);
|
||||||
|
ensightCaseFile
|
||||||
|
<< ensightPTraits<Type>::typeName
|
||||||
|
<< " per element: 1 "
|
||||||
|
<< setw(15)
|
||||||
|
<< varName.c_str() << ' '
|
||||||
|
<< (dirName/varName).c_str()
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eMesh.format() == IOstream::BINARY)
|
||||||
|
{
|
||||||
|
filePtr = new ensightBinaryStream
|
||||||
(
|
(
|
||||||
postProcPath/ensightFileName,
|
dataDir/postFileName
|
||||||
runTime
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ensightFilePtr = new ensightAsciiStream
|
filePtr = new ensightAsciiStream
|
||||||
(
|
(
|
||||||
postProcPath/ensightFileName,
|
dataDir/postFileName
|
||||||
runTime
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filePtr->write(ensightPTraits<Type>::typeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
ensightStream& ensightFile = *ensightFilePtr;
|
ensightStream& os = *filePtr;
|
||||||
|
|
||||||
if (Pstream::master())
|
|
||||||
{
|
|
||||||
if (timeIndex == 0)
|
|
||||||
{
|
|
||||||
ensightCaseFile.setf(ios_base::left);
|
|
||||||
|
|
||||||
ensightCaseFile
|
|
||||||
<< ensightPTraits<Type>::typeName
|
|
||||||
<< " per element: 1 "
|
|
||||||
<< setw(15) << vf.name()
|
|
||||||
<< (' ' + prepend + "****." + vf.name()).c_str()
|
|
||||||
<< nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
ensightFile.write(ensightPTraits<Type>::typeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (patchNames.empty())
|
if (patchNames.empty())
|
||||||
{
|
{
|
||||||
@ -463,42 +448,42 @@ void ensightField
|
|||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightFile.writePartHeader(1);
|
os.writePartHeader(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeField
|
writeField
|
||||||
(
|
(
|
||||||
"hexa8",
|
"hexa8",
|
||||||
map(vf, hexes, wedges),
|
map(vf, hexes, wedges),
|
||||||
ensightFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeField
|
writeField
|
||||||
(
|
(
|
||||||
"penta6",
|
"penta6",
|
||||||
Field<Type>(vf, prisms),
|
Field<Type>(vf, prisms),
|
||||||
ensightFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeField
|
writeField
|
||||||
(
|
(
|
||||||
"pyramid5",
|
"pyramid5",
|
||||||
Field<Type>(vf, pyrs),
|
Field<Type>(vf, pyrs),
|
||||||
ensightFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeField
|
writeField
|
||||||
(
|
(
|
||||||
"tetra4",
|
"tetra4",
|
||||||
Field<Type>(vf, tets),
|
Field<Type>(vf, tets),
|
||||||
ensightFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeField
|
writeField
|
||||||
(
|
(
|
||||||
"nfaced",
|
"nfaced",
|
||||||
Field<Type>(vf, polys),
|
Field<Type>(vf, polys),
|
||||||
ensightFile
|
os
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,7 +506,7 @@ void ensightField
|
|||||||
ensightPatchI,
|
ensightPatchI,
|
||||||
boundaryFaceSets[patchi],
|
boundaryFaceSets[patchi],
|
||||||
nPatchPrims.find(patchName)(),
|
nPatchPrims.find(patchName)(),
|
||||||
ensightFile
|
os
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -546,8 +531,7 @@ void ensightField
|
|||||||
|
|
||||||
eMesh.barrier();
|
eMesh.barrier();
|
||||||
|
|
||||||
label zoneID = mesh.faceZones().findZoneID(faceZoneName);
|
const label zoneID = mesh.faceZones().findZoneID(faceZoneName);
|
||||||
|
|
||||||
const faceZone& fz = mesh.faceZones()[zoneID];
|
const faceZone& fz = mesh.faceZones()[zoneID];
|
||||||
|
|
||||||
// Prepare data to write
|
// Prepare data to write
|
||||||
@ -595,7 +579,7 @@ void ensightField
|
|||||||
ensightPatchI,
|
ensightPatchI,
|
||||||
faceZoneFaceSets[zoneID],
|
faceZoneFaceSets[zoneID],
|
||||||
nFaceZonePrims.find(faceZoneName)(),
|
nFaceZonePrims.find(faceZoneName)(),
|
||||||
ensightFile
|
os
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -603,9 +587,10 @@ void ensightField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Pstream::master())
|
|
||||||
|
if (filePtr) // on master only
|
||||||
{
|
{
|
||||||
delete ensightFilePtr;
|
delete filePtr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,65 +600,63 @@ void ensightPointField
|
|||||||
(
|
(
|
||||||
const GeometricField<Type, pointPatchField, pointMesh>& pf,
|
const GeometricField<Type, pointPatchField, pointMesh>& pf,
|
||||||
const ensightMesh& eMesh,
|
const ensightMesh& eMesh,
|
||||||
const fileName& postProcPath,
|
const fileName& dataDir,
|
||||||
const word& prepend,
|
|
||||||
const label timeIndex,
|
const label timeIndex,
|
||||||
const bool binary,
|
|
||||||
Ostream& ensightCaseFile
|
Ostream& ensightCaseFile
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< "Converting field " << pf.name() << endl;
|
Info<< ' ' << pf.name();
|
||||||
|
|
||||||
word timeFile = prepend + itoa(timeIndex);
|
|
||||||
|
|
||||||
const fvMesh& mesh = eMesh.mesh();
|
const fvMesh& mesh = eMesh.mesh();
|
||||||
const wordList& allPatchNames = eMesh.allPatchNames();
|
const wordList& allPatchNames = eMesh.allPatchNames();
|
||||||
const wordHashSet& patchNames = eMesh.patchNames();
|
const wordHashSet& patchNames = eMesh.patchNames();
|
||||||
const wordHashSet& faceZoneNames = eMesh.faceZoneNames();
|
const wordHashSet& faceZoneNames = eMesh.faceZoneNames();
|
||||||
|
|
||||||
|
ensightStream* filePtr(nullptr);
|
||||||
ensightStream* ensightFilePtr = NULL;
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
// set the filename of the ensight file
|
const ensight::VarName varName(pf.name());
|
||||||
fileName ensightFileName(timeFile + "." + pf.name());
|
const fileName postFileName = ensightFile::subDir(timeIndex)/varName;
|
||||||
|
|
||||||
if (binary)
|
// the data/ITER subdirectory must exist
|
||||||
|
mkDir(dataDir/postFileName.path());
|
||||||
|
|
||||||
|
if (timeIndex == 0)
|
||||||
{
|
{
|
||||||
ensightFilePtr = new ensightBinaryStream
|
const fileName dirName = dataDir.name()/ensightFile::mask();
|
||||||
|
|
||||||
|
ensightCaseFile.setf(ios_base::left);
|
||||||
|
ensightCaseFile
|
||||||
|
<< ensightPTraits<Type>::typeName
|
||||||
|
<< " per "
|
||||||
|
<< setw(20)
|
||||||
|
<< " node:"
|
||||||
|
<< " 1 "
|
||||||
|
<< setw(15)
|
||||||
|
<< varName.c_str() << ' '
|
||||||
|
<< (dirName/varName).c_str()
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eMesh.format() == IOstream::BINARY)
|
||||||
|
{
|
||||||
|
filePtr = new ensightBinaryStream
|
||||||
(
|
(
|
||||||
postProcPath/ensightFileName,
|
dataDir/postFileName
|
||||||
mesh.time()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ensightFilePtr = new ensightAsciiStream
|
filePtr = new ensightAsciiStream
|
||||||
(
|
(
|
||||||
postProcPath/ensightFileName,
|
dataDir/postFileName
|
||||||
mesh.time()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filePtr->write(ensightPTraits<Type>::typeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
ensightStream& ensightFile = *ensightFilePtr;
|
ensightStream& os = *filePtr;
|
||||||
|
|
||||||
if (Pstream::master())
|
|
||||||
{
|
|
||||||
if (timeIndex == 0)
|
|
||||||
{
|
|
||||||
ensightCaseFile.setf(ios_base::left);
|
|
||||||
|
|
||||||
ensightCaseFile
|
|
||||||
<< ensightPTraits<Type>::typeName
|
|
||||||
<< " per node: 1 "
|
|
||||||
<< setw(15) << pf.name()
|
|
||||||
<< (' ' + prepend + "****." + pf.name()).c_str()
|
|
||||||
<< nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
ensightFile.write(ensightPTraits<Type>::typeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eMesh.patchNames().empty())
|
if (eMesh.patchNames().empty())
|
||||||
{
|
{
|
||||||
@ -681,14 +664,14 @@ void ensightPointField
|
|||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightFile.writePartHeader(1);
|
os.writePartHeader(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeField
|
writeField
|
||||||
(
|
(
|
||||||
"coordinates",
|
"coordinates",
|
||||||
Field<Type>(pf.internalField(), eMesh.uniquePointMap()),
|
Field<Type>(pf.internalField(), eMesh.uniquePointMap()),
|
||||||
ensightFile
|
os
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,11 +687,8 @@ void ensightPointField
|
|||||||
if (patchNames.empty() || patchNames.found(patchName))
|
if (patchNames.empty() || patchNames.found(patchName))
|
||||||
{
|
{
|
||||||
const fvPatch& p = mesh.boundary()[patchi];
|
const fvPatch& p = mesh.boundary()[patchi];
|
||||||
if
|
|
||||||
(
|
if (returnReduce(p.size(), sumOp<label>()) > 0)
|
||||||
returnReduce(p.size(), sumOp<label>())
|
|
||||||
> 0
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// Renumber the patch points/faces into unique points
|
// Renumber the patch points/faces into unique points
|
||||||
labelList pointToGlobal;
|
labelList pointToGlobal;
|
||||||
@ -724,14 +704,14 @@ void ensightPointField
|
|||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightFile.writePartHeader(ensightPatchI);
|
os.writePartHeader(ensightPatchI);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeField
|
writeField
|
||||||
(
|
(
|
||||||
"coordinates",
|
"coordinates",
|
||||||
Field<Type>(pf.internalField(), uniqueMeshPointLabels),
|
Field<Type>(pf.internalField(), uniqueMeshPointLabels),
|
||||||
ensightFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
ensightPatchI++;
|
ensightPatchI++;
|
||||||
@ -748,8 +728,7 @@ void ensightPointField
|
|||||||
|
|
||||||
eMesh.barrier();
|
eMesh.barrier();
|
||||||
|
|
||||||
label zoneID = mesh.faceZones().findZoneID(faceZoneName);
|
const label zoneID = mesh.faceZones().findZoneID(faceZoneName);
|
||||||
|
|
||||||
const faceZone& fz = mesh.faceZones()[zoneID];
|
const faceZone& fz = mesh.faceZones()[zoneID];
|
||||||
|
|
||||||
if (returnReduce(fz().nPoints(), sumOp<label>()) > 0)
|
if (returnReduce(fz().nPoints(), sumOp<label>()) > 0)
|
||||||
@ -768,7 +747,7 @@ void ensightPointField
|
|||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightFile.writePartHeader(ensightPatchI);
|
os.writePartHeader(ensightPatchI);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeField
|
writeField
|
||||||
@ -779,7 +758,7 @@ void ensightPointField
|
|||||||
pf.internalField(),
|
pf.internalField(),
|
||||||
uniqueMeshPointLabels
|
uniqueMeshPointLabels
|
||||||
),
|
),
|
||||||
ensightFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
ensightPatchI++;
|
ensightPatchI++;
|
||||||
@ -787,9 +766,9 @@ void ensightPointField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::master())
|
if (filePtr) // on master only
|
||||||
{
|
{
|
||||||
delete ensightFilePtr;
|
delete filePtr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -799,10 +778,8 @@ void ensightField
|
|||||||
(
|
(
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& vf,
|
const GeometricField<Type, fvPatchField, volMesh>& vf,
|
||||||
const ensightMesh& eMesh,
|
const ensightMesh& eMesh,
|
||||||
const fileName& postProcPath,
|
const fileName& dataDir,
|
||||||
const word& prepend,
|
|
||||||
const label timeIndex,
|
const label timeIndex,
|
||||||
const bool binary,
|
|
||||||
const bool nodeValues,
|
const bool nodeValues,
|
||||||
Ostream& ensightCaseFile
|
Ostream& ensightCaseFile
|
||||||
)
|
)
|
||||||
@ -819,10 +796,8 @@ void ensightField
|
|||||||
(
|
(
|
||||||
pfld,
|
pfld,
|
||||||
eMesh,
|
eMesh,
|
||||||
postProcPath,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -832,10 +807,8 @@ void ensightField
|
|||||||
(
|
(
|
||||||
vf,
|
vf,
|
||||||
eMesh,
|
eMesh,
|
||||||
postProcPath,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -69,10 +69,8 @@ void ensightField
|
|||||||
(
|
(
|
||||||
const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>& vf,
|
const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>& vf,
|
||||||
const Foam::ensightMesh& eMesh,
|
const Foam::ensightMesh& eMesh,
|
||||||
const Foam::fileName& postProcPath,
|
const Foam::fileName& dataDir,
|
||||||
const Foam::word& prepend,
|
|
||||||
const Foam::label timeIndex,
|
const Foam::label timeIndex,
|
||||||
const bool binary,
|
|
||||||
const bool nodeValues,
|
const bool nodeValues,
|
||||||
Foam::Ostream& ensightCaseFile
|
Foam::Ostream& ensightCaseFile
|
||||||
);
|
);
|
||||||
@ -85,8 +83,7 @@ void writePatchField
|
|||||||
const Foam::Field<Type>& pf,
|
const Foam::Field<Type>& pf,
|
||||||
const Foam::word& patchName,
|
const Foam::word& patchName,
|
||||||
const Foam::ensightMesh& eMesh,
|
const Foam::ensightMesh& eMesh,
|
||||||
const Foam::fileName& postProcPath,
|
const Foam::fileName& dataDir,
|
||||||
const Foam::word& prepend,
|
|
||||||
const Foam::label timeIndex,
|
const Foam::label timeIndex,
|
||||||
Foam::Ostream& ensightCaseFile
|
Foam::Ostream& ensightCaseFile
|
||||||
);
|
);
|
||||||
|
|||||||
@ -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 |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -32,16 +32,21 @@ License
|
|||||||
#include "processorPolyPatch.H"
|
#include "processorPolyPatch.H"
|
||||||
#include "cellModeller.H"
|
#include "cellModeller.H"
|
||||||
#include "IOmanip.H"
|
#include "IOmanip.H"
|
||||||
#include "itoa.H"
|
|
||||||
#include "globalIndex.H"
|
#include "globalIndex.H"
|
||||||
#include "mapDistribute.H"
|
#include "mapDistribute.H"
|
||||||
#include "stringListOps.H"
|
#include "stringListOps.H"
|
||||||
|
|
||||||
|
#include "ensightFile.H"
|
||||||
#include "ensightBinaryStream.H"
|
#include "ensightBinaryStream.H"
|
||||||
#include "ensightAsciiStream.H"
|
#include "ensightAsciiStream.H"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* Foam::ensightMesh::geometryName = "geometry";
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::ensightMesh::correct()
|
void Foam::ensightMesh::correct()
|
||||||
@ -403,7 +408,7 @@ Foam::ensightMesh::ensightMesh
|
|||||||
const bool faceZones,
|
const bool faceZones,
|
||||||
const wordReList& faceZonePatterns,
|
const wordReList& faceZonePatterns,
|
||||||
|
|
||||||
const bool binary
|
const IOstream::streamFormat format
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
@ -412,7 +417,7 @@ Foam::ensightMesh::ensightMesh
|
|||||||
patchPatterns_(patchPatterns),
|
patchPatterns_(patchPatterns),
|
||||||
faceZones_(faceZones),
|
faceZones_(faceZones),
|
||||||
faceZonePatterns_(faceZonePatterns),
|
faceZonePatterns_(faceZonePatterns),
|
||||||
binary_(binary),
|
format_(format),
|
||||||
meshCellSets_(mesh.nCells())
|
meshCellSets_(mesh.nCells())
|
||||||
{
|
{
|
||||||
correct();
|
correct();
|
||||||
@ -521,7 +526,7 @@ void Foam::ensightMesh::writePrims
|
|||||||
// Create a temp int array
|
// Create a temp int array
|
||||||
if (cellShapes.size())
|
if (cellShapes.size())
|
||||||
{
|
{
|
||||||
if (ensightGeometryFile.ascii())
|
if (format_ == IOstream::ASCII)
|
||||||
{
|
{
|
||||||
// Workaround for paraview issue : write one cell per line
|
// Workaround for paraview issue : write one cell per line
|
||||||
|
|
||||||
@ -1018,63 +1023,55 @@ void Foam::ensightMesh::writeAllPoints
|
|||||||
|
|
||||||
void Foam::ensightMesh::write
|
void Foam::ensightMesh::write
|
||||||
(
|
(
|
||||||
const fileName& postProcPath,
|
const fileName& dataDir,
|
||||||
const word& prepend,
|
|
||||||
const label timeIndex,
|
const label timeIndex,
|
||||||
const bool meshMoving,
|
const bool meshMoving,
|
||||||
Ostream& ensightCaseFile
|
Ostream& ensightCaseFile
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const Time& runTime = mesh_.time();
|
|
||||||
const cellShapeList& cellShapes = mesh_.cellShapes();
|
const cellShapeList& cellShapes = mesh_.cellShapes();
|
||||||
|
|
||||||
|
ensightStream* filePtr(nullptr);
|
||||||
word timeFile = prepend;
|
|
||||||
|
|
||||||
if (timeIndex == 0)
|
|
||||||
{
|
|
||||||
timeFile += "0000.";
|
|
||||||
}
|
|
||||||
else if (meshMoving)
|
|
||||||
{
|
|
||||||
timeFile += itoa(timeIndex) + '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the filename of the ensight file
|
|
||||||
fileName ensightGeometryFileName = timeFile + "mesh";
|
|
||||||
|
|
||||||
ensightStream* ensightGeometryFilePtr = NULL;
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
if (binary_)
|
// set the filename of the ensight file
|
||||||
|
fileName geoFileName = dataDir.path()/ensightMesh::geometryName;
|
||||||
|
|
||||||
|
if (meshMoving)
|
||||||
{
|
{
|
||||||
ensightGeometryFilePtr = new ensightBinaryStream
|
geoFileName =
|
||||||
|
dataDir/ensightFile::subDir(timeIndex)/ensightMesh::geometryName;
|
||||||
|
|
||||||
|
mkDir(geoFileName.path());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format_ == IOstream::BINARY)
|
||||||
|
{
|
||||||
|
filePtr = new ensightBinaryStream
|
||||||
(
|
(
|
||||||
postProcPath/ensightGeometryFileName,
|
geoFileName
|
||||||
runTime
|
|
||||||
);
|
);
|
||||||
ensightGeometryFilePtr->write("C binary");
|
filePtr->write("C binary");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ensightGeometryFilePtr = new ensightAsciiStream
|
filePtr = new ensightAsciiStream
|
||||||
(
|
(
|
||||||
postProcPath/ensightGeometryFileName,
|
geoFileName
|
||||||
runTime
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ensightStream& ensightGeometryFile = *ensightGeometryFilePtr;
|
ensightStream& os = *filePtr;
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
string desc = string("written by OpenFOAM-") + Foam::FOAMversion;
|
string desc = string("written by OpenFOAM-") + Foam::FOAMversion;
|
||||||
|
|
||||||
ensightGeometryFile.write("EnSight Geometry File");
|
os.write("EnSight Geometry File");
|
||||||
ensightGeometryFile.write(desc.c_str());
|
os.write(desc.c_str());
|
||||||
ensightGeometryFile.write("node id assign");
|
os.write("node id assign");
|
||||||
ensightGeometryFile.write("element id assign");
|
os.write("element id assign");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (patchNames_.empty())
|
if (patchNames_.empty())
|
||||||
@ -1089,7 +1086,7 @@ void Foam::ensightMesh::write
|
|||||||
"internalMesh",
|
"internalMesh",
|
||||||
uniquePoints,
|
uniquePoints,
|
||||||
nPoints,
|
nPoints,
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeAllPrims
|
writeAllPrims
|
||||||
@ -1103,7 +1100,7 @@ void Foam::ensightMesh::write
|
|||||||
meshCellSets_.wedges,
|
meshCellSets_.wedges,
|
||||||
pointToGlobal_
|
pointToGlobal_
|
||||||
),
|
),
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeAllPrims
|
writeAllPrims
|
||||||
@ -1111,7 +1108,7 @@ void Foam::ensightMesh::write
|
|||||||
"penta6",
|
"penta6",
|
||||||
meshCellSets_.nPrisms,
|
meshCellSets_.nPrisms,
|
||||||
map(cellShapes, meshCellSets_.prisms, pointToGlobal_),
|
map(cellShapes, meshCellSets_.prisms, pointToGlobal_),
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeAllPrims
|
writeAllPrims
|
||||||
@ -1119,7 +1116,7 @@ void Foam::ensightMesh::write
|
|||||||
"pyramid5",
|
"pyramid5",
|
||||||
meshCellSets_.nPyrs,
|
meshCellSets_.nPyrs,
|
||||||
map(cellShapes, meshCellSets_.pyrs, pointToGlobal_),
|
map(cellShapes, meshCellSets_.pyrs, pointToGlobal_),
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeAllPrims
|
writeAllPrims
|
||||||
@ -1127,13 +1124,13 @@ void Foam::ensightMesh::write
|
|||||||
"tetra4",
|
"tetra4",
|
||||||
meshCellSets_.nTets,
|
meshCellSets_.nTets,
|
||||||
map(cellShapes, meshCellSets_.tets, pointToGlobal_),
|
map(cellShapes, meshCellSets_.tets, pointToGlobal_),
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeAllPolys
|
writeAllPolys
|
||||||
(
|
(
|
||||||
pointToGlobal_,
|
pointToGlobal_,
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1182,7 +1179,7 @@ void Foam::ensightMesh::write
|
|||||||
patchName,
|
patchName,
|
||||||
uniquePoints,
|
uniquePoints,
|
||||||
globalPointsPtr().size(),
|
globalPointsPtr().size(),
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeAllFacePrims
|
writeAllFacePrims
|
||||||
@ -1191,7 +1188,7 @@ void Foam::ensightMesh::write
|
|||||||
tris,
|
tris,
|
||||||
nfp.nTris,
|
nfp.nTris,
|
||||||
patchFaces,
|
patchFaces,
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeAllFacePrims
|
writeAllFacePrims
|
||||||
@ -1200,7 +1197,7 @@ void Foam::ensightMesh::write
|
|||||||
quads,
|
quads,
|
||||||
nfp.nQuads,
|
nfp.nQuads,
|
||||||
patchFaces,
|
patchFaces,
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeAllNSided
|
writeAllNSided
|
||||||
@ -1208,7 +1205,7 @@ void Foam::ensightMesh::write
|
|||||||
polys,
|
polys,
|
||||||
nfp.nPolys,
|
nfp.nPolys,
|
||||||
patchFaces,
|
patchFaces,
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1287,7 +1284,7 @@ void Foam::ensightMesh::write
|
|||||||
faceZoneName,
|
faceZoneName,
|
||||||
uniquePoints,
|
uniquePoints,
|
||||||
globalPointsPtr().size(),
|
globalPointsPtr().size(),
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeAllFacePrims
|
writeAllFacePrims
|
||||||
@ -1296,7 +1293,7 @@ void Foam::ensightMesh::write
|
|||||||
tris,
|
tris,
|
||||||
nfp.nTris,
|
nfp.nTris,
|
||||||
faceZoneMasterFaces,
|
faceZoneMasterFaces,
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeAllFacePrims
|
writeAllFacePrims
|
||||||
@ -1305,7 +1302,7 @@ void Foam::ensightMesh::write
|
|||||||
quads,
|
quads,
|
||||||
nfp.nQuads,
|
nfp.nQuads,
|
||||||
faceZoneMasterFaces,
|
faceZoneMasterFaces,
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
|
|
||||||
writeAllNSided
|
writeAllNSided
|
||||||
@ -1313,14 +1310,14 @@ void Foam::ensightMesh::write
|
|||||||
polys,
|
polys,
|
||||||
nfp.nPolys,
|
nfp.nPolys,
|
||||||
faceZoneMasterFaces,
|
faceZoneMasterFaces,
|
||||||
ensightGeometryFile
|
os
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::master())
|
if (filePtr) // only on master
|
||||||
{
|
{
|
||||||
delete ensightGeometryFilePtr;
|
delete filePtr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -63,6 +63,11 @@ class ensightStream;
|
|||||||
class ensightMesh
|
class ensightMesh
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
//- The name for geometry files
|
||||||
|
static const char* geometryName;
|
||||||
|
|
||||||
|
//- Helper class for managing face primitives
|
||||||
class nFacePrimitives
|
class nFacePrimitives
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -97,8 +102,8 @@ private:
|
|||||||
const bool faceZones_;
|
const bool faceZones_;
|
||||||
const wordReList faceZonePatterns_;
|
const wordReList faceZonePatterns_;
|
||||||
|
|
||||||
//- Set binary file output
|
//- Ascii/Binary file output
|
||||||
const bool binary_;
|
const IOstream::streamFormat format_;
|
||||||
|
|
||||||
//- The ensight part id for the first patch
|
//- The ensight part id for the first patch
|
||||||
label patchPartOffset_;
|
label patchPartOffset_;
|
||||||
@ -140,10 +145,10 @@ private:
|
|||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
ensightMesh(const ensightMesh&);
|
ensightMesh(const ensightMesh&) = delete;
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const ensightMesh&);
|
void operator=(const ensightMesh&) = delete;
|
||||||
|
|
||||||
void writePoints
|
void writePoints
|
||||||
(
|
(
|
||||||
@ -267,7 +272,7 @@ public:
|
|||||||
const wordReList& patchPatterns,
|
const wordReList& patchPatterns,
|
||||||
const bool faceZones,
|
const bool faceZones,
|
||||||
const wordReList& faceZonePatterns,
|
const wordReList& faceZonePatterns,
|
||||||
const bool binary
|
const IOstream::streamFormat format = IOstream::BINARY
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -284,6 +289,11 @@ public:
|
|||||||
return mesh_;
|
return mesh_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IOstream::streamFormat format() const
|
||||||
|
{
|
||||||
|
return format_;
|
||||||
|
}
|
||||||
|
|
||||||
const cellSets& meshCellSets() const
|
const cellSets& meshCellSets() const
|
||||||
{
|
{
|
||||||
return meshCellSets_;
|
return meshCellSets_;
|
||||||
@ -352,8 +362,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
|
||||||
//- Update for new mesh
|
//- Update for new mesh
|
||||||
@ -371,8 +379,7 @@ public:
|
|||||||
|
|
||||||
void write
|
void write
|
||||||
(
|
(
|
||||||
const fileName& postProcPath,
|
const fileName& ensightDir,
|
||||||
const word& prepend,
|
|
||||||
const label timeIndex,
|
const label timeIndex,
|
||||||
const bool meshMoving,
|
const bool meshMoving,
|
||||||
Ostream& ensightCaseFile
|
Ostream& ensightCaseFile
|
||||||
|
|||||||
@ -1,103 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
|
||||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "ensightParticlePositions.H"
|
|
||||||
#include "fvMesh.H"
|
|
||||||
#include "passiveParticle.H"
|
|
||||||
#include "Cloud.H"
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "IOmanip.H"
|
|
||||||
#include "itoa.H"
|
|
||||||
|
|
||||||
using namespace Foam;
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void ensightParticlePositions
|
|
||||||
(
|
|
||||||
const fvMesh& mesh,
|
|
||||||
const fileName& postProcPath,
|
|
||||||
const word& timeFile,
|
|
||||||
const word& cloudName,
|
|
||||||
const bool dataExists
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (dataExists)
|
|
||||||
{
|
|
||||||
Info<< "Converting cloud " << cloudName << " positions" << endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Info<< "Creating empty cloud " << cloudName << " positions" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Time& runTime = mesh.time();
|
|
||||||
|
|
||||||
fileName ensightFileName(timeFile + "." + cloudName);
|
|
||||||
OFstream ensightFile
|
|
||||||
(
|
|
||||||
postProcPath/ensightFileName,
|
|
||||||
runTime.writeFormat(),
|
|
||||||
runTime.writeVersion(),
|
|
||||||
runTime.writeCompression()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Output header
|
|
||||||
ensightFile
|
|
||||||
<< cloudName.c_str() << nl
|
|
||||||
<< "particle coordinates" << nl;
|
|
||||||
|
|
||||||
if (dataExists)
|
|
||||||
{
|
|
||||||
Cloud<passiveParticle> parcels(mesh, cloudName, false);
|
|
||||||
|
|
||||||
// Set Format
|
|
||||||
ensightFile.setf(ios_base::scientific, ios_base::floatfield);
|
|
||||||
ensightFile.precision(5);
|
|
||||||
|
|
||||||
ensightFile<< setw(8) << parcels.size() << nl;
|
|
||||||
|
|
||||||
label nParcels = 0;
|
|
||||||
|
|
||||||
// Output positions
|
|
||||||
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
|
|
||||||
{
|
|
||||||
const vector& p = elmnt().position();
|
|
||||||
|
|
||||||
ensightFile
|
|
||||||
<< setw(8) << ++nParcels
|
|
||||||
<< setw(12) << p.x() << setw(12) << p.y() << setw(12) << p.z()
|
|
||||||
<< nl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
label nParcels = 0;
|
|
||||||
ensightFile<< setw(8) << nParcels << nl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
|
||||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
InApplication
|
|
||||||
foamToEnsight
|
|
||||||
|
|
||||||
Description
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
ensightParticlePositions.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef ensightParticlePositions_H
|
|
||||||
#define ensightParticlePositions_H
|
|
||||||
|
|
||||||
#include "fvMesh.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void ensightParticlePositions
|
|
||||||
(
|
|
||||||
const Foam::fvMesh& mesh,
|
|
||||||
const Foam::fileName& postProcPath,
|
|
||||||
const Foam::word& timeFile,
|
|
||||||
const Foam::word& CloudName,
|
|
||||||
const bool dataExists
|
|
||||||
);
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -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 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -57,10 +57,10 @@ class ensightStream
|
|||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
ensightStream(const ensightStream&);
|
ensightStream(const ensightStream&) = delete;
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const ensightStream&);
|
void operator=(const ensightStream&) = delete;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -86,8 +86,6 @@ public:
|
|||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool ascii() const = 0;
|
|
||||||
|
|
||||||
virtual void write(const char*) = 0;
|
virtual void write(const char*) = 0;
|
||||||
|
|
||||||
virtual void write(const int) = 0;
|
virtual void write(const int) = 0;
|
||||||
@ -98,8 +96,6 @@ public:
|
|||||||
|
|
||||||
virtual void writePartHeader(const label) = 0;
|
virtual void writePartHeader(const label) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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 |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -34,11 +34,14 @@ Description
|
|||||||
|
|
||||||
Usage
|
Usage
|
||||||
- foamToEnsight [OPTION] \n
|
- foamToEnsight [OPTION] \n
|
||||||
Translates OpenFOAM data to Ensight format
|
Translates OpenFOAM data to EnSight format
|
||||||
|
|
||||||
\param -ascii \n
|
\param -ascii \n
|
||||||
Write Ensight data in ASCII format instead of "C Binary"
|
Write Ensight data in ASCII format instead of "C Binary"
|
||||||
|
|
||||||
|
\param -noZero \n
|
||||||
|
Exclude the often incomplete initial conditions.
|
||||||
|
|
||||||
\param -patches patchList \n
|
\param -patches patchList \n
|
||||||
Specify particular patches to write.
|
Specify particular patches to write.
|
||||||
Specifying an empty list suppresses writing the internalMesh.
|
Specifying an empty list suppresses writing the internalMesh.
|
||||||
@ -52,6 +55,9 @@ Usage
|
|||||||
\param -cellZone zoneName \n
|
\param -cellZone zoneName \n
|
||||||
Specify single cellZone to write (not lagrangian)
|
Specify single cellZone to write (not lagrangian)
|
||||||
|
|
||||||
|
\param -width \<n\>\n
|
||||||
|
Width of EnSight data subdir (default: 8)
|
||||||
|
|
||||||
Note
|
Note
|
||||||
Parallel support for cloud data is not supported
|
Parallel support for cloud data is not supported
|
||||||
- writes to \a EnSight directory to avoid collisions with foamToEnsightParts
|
- writes to \a EnSight directory to avoid collisions with foamToEnsightParts
|
||||||
@ -70,14 +76,12 @@ Note
|
|||||||
#include "scalarIOField.H"
|
#include "scalarIOField.H"
|
||||||
#include "tensorIOField.H"
|
#include "tensorIOField.H"
|
||||||
|
|
||||||
|
#include "ensightFile.H"
|
||||||
#include "ensightMesh.H"
|
#include "ensightMesh.H"
|
||||||
#include "ensightField.H"
|
#include "ensightField.H"
|
||||||
|
#include "ensightCloud.H"
|
||||||
#include "ensightParticlePositions.H"
|
|
||||||
#include "ensightCloudField.H"
|
|
||||||
|
|
||||||
#include "fvc.H"
|
#include "fvc.H"
|
||||||
|
|
||||||
#include "cellSet.H"
|
#include "cellSet.H"
|
||||||
#include "fvMeshSubset.H"
|
#include "fvMeshSubset.H"
|
||||||
|
|
||||||
@ -151,32 +155,21 @@ int main(int argc, char *argv[])
|
|||||||
"word",
|
"word",
|
||||||
"specify cellZone to write"
|
"specify cellZone to write"
|
||||||
);
|
);
|
||||||
|
argList::addOption
|
||||||
|
(
|
||||||
|
"name",
|
||||||
|
"subdir",
|
||||||
|
"define sub-directory name to use for ensight data "
|
||||||
|
"(default: 'EnSight')"
|
||||||
|
);
|
||||||
|
argList::addOption
|
||||||
|
(
|
||||||
|
"width",
|
||||||
|
"n",
|
||||||
|
"width of ensight data subdir"
|
||||||
|
);
|
||||||
|
|
||||||
#include "setRootCase.H"
|
// the volume field types that we handle
|
||||||
|
|
||||||
// Check options
|
|
||||||
const bool binary = !args.optionFound("ascii");
|
|
||||||
const bool nodeValues = args.optionFound("nodeValues");
|
|
||||||
|
|
||||||
cpuTime timer;
|
|
||||||
memInfo mem;
|
|
||||||
Info<< "Initial memory "
|
|
||||||
<< mem.update().size() << " kB" << endl;
|
|
||||||
|
|
||||||
#include "createTime.H"
|
|
||||||
|
|
||||||
instantList Times = timeSelector::select0(runTime, args);
|
|
||||||
|
|
||||||
#include "createNamedMesh.H"
|
|
||||||
|
|
||||||
// Mesh instance (region0 gets filtered out)
|
|
||||||
fileName regionPrefix = "";
|
|
||||||
|
|
||||||
if (regionName != polyMesh::defaultRegion)
|
|
||||||
{
|
|
||||||
regionPrefix = regionName;
|
|
||||||
}
|
|
||||||
|
|
||||||
const label nVolFieldTypes = 10;
|
const label nVolFieldTypes = 10;
|
||||||
const word volFieldTypes[] =
|
const word volFieldTypes[] =
|
||||||
{
|
{
|
||||||
@ -193,38 +186,88 @@ int main(int argc, char *argv[])
|
|||||||
volTensorField::DimensionedInternalField::typeName
|
volTensorField::DimensionedInternalField::typeName
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
// default to binary output, unless otherwise specified
|
||||||
|
const enum IOstream::streamFormat format =
|
||||||
|
(
|
||||||
|
args.optionFound("ascii")
|
||||||
|
? IOstream::ASCII
|
||||||
|
: IOstream::BINARY
|
||||||
|
);
|
||||||
|
|
||||||
|
const bool nodeValues = args.optionFound("nodeValues");
|
||||||
|
|
||||||
|
cpuTime timer;
|
||||||
|
memInfo mem;
|
||||||
|
Info<< "Initial memory "
|
||||||
|
<< mem.update().size() << " kB" << endl;
|
||||||
|
|
||||||
|
#include "createTime.H"
|
||||||
|
|
||||||
|
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||||
|
|
||||||
|
// adjust output width
|
||||||
|
if (args.optionFound("width"))
|
||||||
|
{
|
||||||
|
ensightFile::subDirWidth(args.optionRead<label>("width"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// define sub-directory name to use for EnSight data
|
||||||
|
fileName ensightDir = "EnSight";
|
||||||
|
args.optionReadIfPresent("name", ensightDir);
|
||||||
|
|
||||||
// Path to EnSight directory at case level only
|
// Path to EnSight directory at case level only
|
||||||
// - For parallel cases, data only written from master
|
// - For parallel cases, data only written from master
|
||||||
fileName ensightDir = args.rootPath()/args.globalCaseName()/"EnSight";
|
if (!ensightDir.isAbsolute())
|
||||||
|
{
|
||||||
|
ensightDir = args.rootPath()/args.globalCaseName()/ensightDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileName dataDir = ensightDir/"data";
|
||||||
|
const fileName dataMask = dataDir.name()/ensightFile::mask();
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
|
// EnSight and EnSight/data directories must exist
|
||||||
|
// - remove old data for a clean conversion of everything
|
||||||
if (isDir(ensightDir))
|
if (isDir(ensightDir))
|
||||||
{
|
{
|
||||||
rmDir(ensightDir);
|
rmDir(ensightDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
mkDir(ensightDir);
|
mkDir(dataDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "createNamedMesh.H"
|
||||||
|
|
||||||
|
// Mesh instance (region0 gets filtered out)
|
||||||
|
fileName regionPrefix;
|
||||||
|
if (regionName != polyMesh::defaultRegion)
|
||||||
|
{
|
||||||
|
regionPrefix = regionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start of case file header output
|
// Start of case file header output
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
const word prepend = args.globalCaseName() + '.';
|
OFstream *ensightCaseFilePtr(nullptr);
|
||||||
|
|
||||||
OFstream *ensightCaseFilePtr = NULL;
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
fileName caseFileName = prepend + "case";
|
fileName caseFileName = args.globalCaseName() + ".case";
|
||||||
Info<< nl << "write case: " << caseFileName.c_str() << endl;
|
Info<< nl << "write case: " << caseFileName.c_str() << endl;
|
||||||
|
|
||||||
// the case file is always ASCII
|
// The case file is always ASCII
|
||||||
ensightCaseFilePtr = new OFstream
|
ensightCaseFilePtr = new OFstream
|
||||||
(
|
(
|
||||||
ensightDir/caseFileName,
|
ensightDir/caseFileName,
|
||||||
IOstream::ASCII
|
IOstream::ASCII
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ensightCaseFilePtr->setf(ios_base::left);
|
||||||
|
ensightCaseFilePtr->setf(ios_base::scientific, ios_base::floatfield);
|
||||||
|
ensightCaseFilePtr->precision(5);
|
||||||
|
|
||||||
*ensightCaseFilePtr
|
*ensightCaseFilePtr
|
||||||
<< "FORMAT" << nl
|
<< "FORMAT" << nl
|
||||||
<< "type: ensight gold" << nl << nl;
|
<< "type: ensight gold" << nl << nl;
|
||||||
@ -280,11 +323,11 @@ int main(int argc, char *argv[])
|
|||||||
patchPatterns,
|
patchPatterns,
|
||||||
selectedZones,
|
selectedZones,
|
||||||
zonePatterns,
|
zonePatterns,
|
||||||
binary
|
format
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set Time to the last time before looking for the lagrangian objects
|
// Set Time to the last time before looking for the lagrangian objects
|
||||||
runTime.setTime(Times.last(), Times.size()-1);
|
runTime.setTime(timeDirs.last(), timeDirs.size()-1);
|
||||||
|
|
||||||
IOobjectList objects(mesh, runTime.timeName());
|
IOobjectList objects(mesh, runTime.timeName());
|
||||||
|
|
||||||
@ -296,29 +339,38 @@ int main(int argc, char *argv[])
|
|||||||
<< " Writing meshes for every timestep." << endl;
|
<< " Writing meshes for every timestep." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wordHashSet allCloudNames;
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
word geomFileName = prepend + "0000";
|
// test the pre-check variable if there is a moving mesh
|
||||||
|
// time-set for geometries
|
||||||
|
// TODO: split off into separate time-set,
|
||||||
|
// but need to verify ensight spec
|
||||||
|
|
||||||
// test pre check variable if there is a moving mesh
|
|
||||||
if (meshMoving)
|
if (meshMoving)
|
||||||
{
|
{
|
||||||
geomFileName = prepend + "****";
|
|
||||||
}
|
|
||||||
|
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
<< "GEOMETRY" << nl
|
<< "GEOMETRY" << nl
|
||||||
<< "model: 1 "
|
<< setw(16) << "model: 1"
|
||||||
<< (geomFileName + ".mesh").c_str() << nl;
|
<< (dataMask/ensightMesh::geometryName).c_str() << nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ensightCaseFile
|
||||||
|
<< "GEOMETRY" << nl
|
||||||
|
<< setw(16) << "model:"
|
||||||
|
<< ensightMesh::geometryName << nl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Identify if lagrangian data exists at each time, and add clouds
|
// Identify if lagrangian data exists any time step, and add clouds
|
||||||
// to the 'allCloudNames' hash set
|
// to the 'cloudNames' (sorted list)
|
||||||
forAll(Times, timeI)
|
wordList cloudNames;
|
||||||
{
|
{
|
||||||
runTime.setTime(Times[timeI], timeI);
|
wordHashSet allCloudNames;
|
||||||
|
|
||||||
|
forAll(timeDirs, timeI)
|
||||||
|
{
|
||||||
|
runTime.setTime(timeDirs[timeI], timeI);
|
||||||
|
|
||||||
fileNameList cloudDirs = readDir
|
fileNameList cloudDirs = readDir
|
||||||
(
|
(
|
||||||
@ -344,40 +396,42 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sorted for consistency
|
||||||
|
cloudNames = allCloudNames.sortedToc();
|
||||||
|
}
|
||||||
|
|
||||||
HashTable<HashTable<word>> allCloudFields;
|
HashTable<HashTable<word>> allCloudFields;
|
||||||
forAllConstIter(wordHashSet, allCloudNames, cloudIter)
|
forAll(cloudNames, cloudNo)
|
||||||
{
|
{
|
||||||
|
const word& cloudName = cloudNames[cloudNo];
|
||||||
|
|
||||||
// Add the name of the cloud(s) to the case file header
|
// Add the name of the cloud(s) to the case file header
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
<< (
|
<< setw(16) << "measured: 1"
|
||||||
"measured: 1 "
|
<< fileName(dataMask/cloud::prefix/cloudName/"positions").c_str()
|
||||||
+ prepend
|
|
||||||
+ "****."
|
|
||||||
+ cloudIter.key()
|
|
||||||
).c_str()
|
|
||||||
<< nl;
|
<< nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new hash table for each cloud
|
// Create a new hash table for each cloud
|
||||||
allCloudFields.insert(cloudIter.key(), HashTable<word>());
|
allCloudFields.insert(cloudName, HashTable<word>());
|
||||||
|
|
||||||
// Identify the new cloud in the hash table
|
// Identify the new cloud in the hash table
|
||||||
HashTable<HashTable<word>>::iterator newCloudIter =
|
HashTable<HashTable<word>>::iterator newCloudIter =
|
||||||
allCloudFields.find(cloudIter.key());
|
allCloudFields.find(cloudName);
|
||||||
|
|
||||||
// Loop over all times to build list of fields and field types
|
// Loop over all times to build list of fields and field types
|
||||||
// for each cloud
|
// for each cloud
|
||||||
forAll(Times, timeI)
|
forAll(timeDirs, timeI)
|
||||||
{
|
{
|
||||||
runTime.setTime(Times[timeI], timeI);
|
runTime.setTime(timeDirs[timeI], timeI);
|
||||||
|
|
||||||
IOobjectList cloudObjs
|
IOobjectList cloudObjs
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
runTime.timeName(),
|
runTime.timeName(),
|
||||||
cloud::prefix/cloudIter.key()
|
cloud::prefix/cloudName
|
||||||
);
|
);
|
||||||
|
|
||||||
forAllConstIter(IOobjectList, cloudObjs, fieldIter)
|
forAllConstIter(IOobjectList, cloudObjs, fieldIter)
|
||||||
@ -398,15 +452,26 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
label nTimeSteps = 0;
|
label nTimeSteps = 0;
|
||||||
forAll(Times, timeIndex)
|
forAll(timeDirs, timeIndex)
|
||||||
{
|
{
|
||||||
nTimeSteps++;
|
++nTimeSteps;
|
||||||
runTime.setTime(Times[timeIndex], timeIndex);
|
runTime.setTime(timeDirs[timeIndex], timeIndex);
|
||||||
|
|
||||||
word timeName = itoa(timeIndex);
|
Info<< "Time [" << timeIndex << "] = " << runTime.timeName() << nl;
|
||||||
word timeFile = prepend + timeName;
|
|
||||||
|
|
||||||
Info<< "Translating time = " << runTime.timeName() << nl;
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
// the data/ITER subdirectory must exist
|
||||||
|
// Note that data/ITER is indeed a valid ensight::FileName
|
||||||
|
const fileName subDir = ensightFile::subDir(timeIndex);
|
||||||
|
mkDir(dataDir/subDir);
|
||||||
|
|
||||||
|
// place a timestamp in the directory for future reference
|
||||||
|
OFstream timeStamp(dataDir/subDir/"time");
|
||||||
|
timeStamp
|
||||||
|
<< "# timestep time" << nl
|
||||||
|
<< subDir.c_str() << " " << runTime.timeName() << nl;
|
||||||
|
}
|
||||||
|
|
||||||
polyMesh::readUpdateState meshState = mesh.readUpdate();
|
polyMesh::readUpdateState meshState = mesh.readUpdate();
|
||||||
if (timeIndex != 0 && meshSubsetter.hasSubMesh())
|
if (timeIndex != 0 && meshSubsetter.hasSubMesh())
|
||||||
@ -420,7 +485,6 @@ int main(int argc, char *argv[])
|
|||||||
meshSubsetter.setLargeCellSubset(c0, 0);
|
meshSubsetter.setLargeCellSubset(c0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (meshState != polyMesh::UNCHANGED)
|
if (meshState != polyMesh::UNCHANGED)
|
||||||
{
|
{
|
||||||
eMesh.correct();
|
eMesh.correct();
|
||||||
@ -430,8 +494,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
eMesh.write
|
eMesh.write
|
||||||
(
|
(
|
||||||
ensightDir,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
meshMoving,
|
meshMoving,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
@ -450,6 +513,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Cell field data output
|
// Cell field data output
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
Info<< "Write volume field (";
|
||||||
|
|
||||||
for (label i=0; i<nVolFieldTypes; i++)
|
for (label i=0; i<nVolFieldTypes; i++)
|
||||||
{
|
{
|
||||||
@ -491,10 +555,8 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
volField(meshSubsetter, vf),
|
volField(meshSubsetter, vf),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
|
||||||
nodeValues,
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
@ -506,10 +568,8 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
volField(meshSubsetter, vf),
|
volField(meshSubsetter, vf),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
|
||||||
nodeValues,
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
@ -521,10 +581,8 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
volField(meshSubsetter, vf),
|
volField(meshSubsetter, vf),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
|
||||||
nodeValues,
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
@ -536,10 +594,8 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
volField(meshSubsetter, vf),
|
volField(meshSubsetter, vf),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
|
||||||
nodeValues,
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
@ -551,10 +607,8 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
volField(meshSubsetter, vf),
|
volField(meshSubsetter, vf),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
|
||||||
nodeValues,
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
@ -575,10 +629,8 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
volField<scalar>(meshSubsetter, df),
|
volField<scalar>(meshSubsetter, df),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
|
||||||
nodeValues,
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
@ -598,10 +650,8 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
volField<vector>(meshSubsetter, df),
|
volField<vector>(meshSubsetter, df),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
|
||||||
nodeValues,
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
@ -621,10 +671,8 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
volField<sphericalTensor>(meshSubsetter, df),
|
volField<sphericalTensor>(meshSubsetter, df),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
|
||||||
nodeValues,
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
@ -644,10 +692,8 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
volField<symmTensor>(meshSubsetter, df),
|
volField<symmTensor>(meshSubsetter, df),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
|
||||||
nodeValues,
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
@ -667,24 +713,30 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
volField<tensor>(meshSubsetter, df),
|
volField<tensor>(meshSubsetter, df),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
|
||||||
nodeValues,
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Info<< " )" << endl;
|
||||||
|
|
||||||
|
|
||||||
// Cloud field data output
|
// Cloud field data output
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
forAllConstIter(HashTable<HashTable<word>>, allCloudFields, cloudIter)
|
forAll(cloudNames, cloudNo)
|
||||||
{
|
{
|
||||||
const word& cloudName = cloudIter.key();
|
const word& cloudName = cloudNames[cloudNo];
|
||||||
|
if (!allCloudFields.found(cloudName))
|
||||||
|
{
|
||||||
|
// extra safety
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HashTable<word>& cloudFields = allCloudFields[cloudName];
|
||||||
|
|
||||||
fileNameList currentCloudDirs = readDir
|
fileNameList currentCloudDirs = readDir
|
||||||
(
|
(
|
||||||
@ -692,17 +744,22 @@ int main(int argc, char *argv[])
|
|||||||
fileName::DIRECTORY
|
fileName::DIRECTORY
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Info<< "Write " << cloudName << " (";
|
||||||
|
|
||||||
bool cloudExists = inFileNameList(currentCloudDirs, cloudName);
|
bool cloudExists = inFileNameList(currentCloudDirs, cloudName);
|
||||||
|
reduce(cloudExists, orOp<bool>());
|
||||||
|
|
||||||
ensightParticlePositions
|
ensightParticlePositions
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
ensightDir,
|
dataDir,
|
||||||
timeFile,
|
timeIndex,
|
||||||
cloudName,
|
cloudName,
|
||||||
cloudExists
|
cloudExists,
|
||||||
|
format
|
||||||
);
|
);
|
||||||
|
|
||||||
forAllConstIter(HashTable<word>, cloudIter(), fieldIter)
|
forAllConstIter(HashTable<word>, cloudFields, fieldIter)
|
||||||
{
|
{
|
||||||
const word& fieldName = fieldIter.key();
|
const word& fieldName = fieldIter.key();
|
||||||
const word& fieldType = fieldIter();
|
const word& fieldType = fieldIter();
|
||||||
@ -720,17 +777,20 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
reduce(fieldExists, orOp<bool>());
|
||||||
|
|
||||||
if (fieldType == scalarIOField::typeName)
|
if (fieldType == scalarIOField::typeName)
|
||||||
{
|
{
|
||||||
ensightCloudField<scalar>
|
ensightCloudField<scalar>
|
||||||
(
|
(
|
||||||
fieldObject,
|
fieldObject,
|
||||||
ensightDir,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
cloudName,
|
cloudName,
|
||||||
|
cloudNo,
|
||||||
ensightCaseFile,
|
ensightCaseFile,
|
||||||
fieldExists
|
fieldExists,
|
||||||
|
format
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (fieldType == vectorIOField::typeName)
|
else if (fieldType == vectorIOField::typeName)
|
||||||
@ -738,37 +798,34 @@ int main(int argc, char *argv[])
|
|||||||
ensightCloudField<vector>
|
ensightCloudField<vector>
|
||||||
(
|
(
|
||||||
fieldObject,
|
fieldObject,
|
||||||
ensightDir,
|
dataDir,
|
||||||
prepend,
|
|
||||||
timeIndex,
|
timeIndex,
|
||||||
cloudName,
|
cloudName,
|
||||||
|
cloudNo,
|
||||||
ensightCaseFile,
|
ensightCaseFile,
|
||||||
fieldExists
|
fieldExists,
|
||||||
|
format
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Info<< "Unable to convert field type " << fieldType
|
|
||||||
<< " for field " << fieldName << endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Info<< " )" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Wrote in "
|
Info<< "Wrote in "
|
||||||
<< timer.cpuTimeIncrement() << " s, "
|
<< timer.cpuTimeIncrement() << " s, "
|
||||||
<< mem.update().size() << " kB" << endl;
|
<< mem.update().size() << " kB" << nl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "ensightCaseTail.H"
|
#include "ensightCaseTail.H"
|
||||||
|
|
||||||
if (Pstream::master())
|
if (ensightCaseFilePtr) // on master only
|
||||||
{
|
{
|
||||||
delete ensightCaseFilePtr;
|
delete ensightCaseFilePtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "\nEnd: "
|
Info<< "End: "
|
||||||
<< timer.elapsedCpuTime() << " s, "
|
<< timer.elapsedCpuTime() << " s, "
|
||||||
<< mem.update().peak() << " kB (peak)\n" << endl;
|
<< mem.update().peak() << " kB (peak)" << nl << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,61 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
|
||||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "itoa.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
word itoa(const label n)
|
|
||||||
{
|
|
||||||
const label offset = '0';
|
|
||||||
const label length = 4;
|
|
||||||
|
|
||||||
char val[length + 1];
|
|
||||||
|
|
||||||
label leftOfN = n;
|
|
||||||
|
|
||||||
for (label i=0; i<length; i++)
|
|
||||||
{
|
|
||||||
label j = label(leftOfN/pow(10, length - i - 1));
|
|
||||||
leftOfN -= j*pow(10, length - i - 1);
|
|
||||||
val[i] = offset + j;
|
|
||||||
}
|
|
||||||
|
|
||||||
val[length] = 0;
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
|
||||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
InApplication
|
|
||||||
foamToEnsight
|
|
||||||
|
|
||||||
Description
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "word.H"
|
|
||||||
#include "label.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
word itoa(const label n);
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
Reference in New Issue
Block a user