ENH: getting foamToTecplot working again

- updated code to use current API level 142.

- ThirdParty build of tecio now uses CMake.
This commit is contained in:
Mark Olesen
2016-11-11 09:42:28 +01:00
parent a3fd21b306
commit 7aeaf61cda
6 changed files with 567 additions and 559 deletions

View File

@ -4,11 +4,13 @@ cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for application compilation (at least for error control) # Parse arguments for application compilation (at least for error control)
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
if [ ! -d ${WM_THIRD_PARTY_DIR}/tecio ] export TECIO_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/tecio
if [ -f $TECIO_ARCH_PATH/TECIO.h -a -r $TECIO_ARCH_PATH/libtecio.a ]
then then
echo "Did not find tecio in ${WM_THIRD_PARTY_DIR}. Not building foamToTecplot360." echo "Building optional tecplot conversion component."
else
wmake $targetType wmake $targetType
else
echo "Skipping optional tecplot conversion components (no tecio detected)."
fi fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -1,14 +1,14 @@
/* Tecio doesn't have many files, so they are just in a single directory */
EXE_INC = \ EXE_INC = \
-I$(WM_THIRD_PARTY_DIR)/tecio/tecsrc/lnInclude \ -I$(TECIO_ARCH_PATH) \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude -I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-L$(TECIO_ARCH_PATH) -ltecio \
-llagrangian \ -llagrangian \
-ldynamicMesh \ -ldynamicMesh \
-ldynamicMesh \ -lgenericPatchFields
-lgenericPatchFields \
-L$(FOAM_EXT_LIBBIN) -ltecio

View File

@ -43,7 +43,6 @@ Usage
information as a single argument. information as a single argument.
- \par -cellSet \<name\> - \par -cellSet \<name\>
- \par -faceSet \<name\> - \par -faceSet \<name\>
Restrict conversion to the cellSet, faceSet. Restrict conversion to the cellSet, faceSet.
@ -81,16 +80,11 @@ Usage
#include "passiveParticleCloud.H" #include "passiveParticleCloud.H"
#include "faceSet.H" #include "faceSet.H"
#include "stringListOps.H" #include "stringListOps.H"
#include "wordRe.H" #include "wordReList.H"
#include "meshSubsetHelper.H" #include "meshSubsetHelper.H"
#include "readFields.H" #include "readFields.H"
#include "tecplotWriter.H" #include "tecplotWriter.H"
#include "TECIO.h"
// Note: needs to be after TECIO to prevent Foam::Time conflicting with
// Xlib Time.
#include "fvCFD.H" #include "fvCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -243,22 +237,22 @@ int main(int argc, char *argv[])
word cellSetName; word cellSetName;
word faceSetName; word faceSetName;
string vtkName = runTime.caseName(); string pltName = runTime.caseName();
if (args.optionReadIfPresent("cellSet", cellSetName)) if (args.optionReadIfPresent("cellSet", cellSetName))
{ {
vtkName = cellSetName; pltName = cellSetName;
} }
else if (Pstream::parRun()) else if (Pstream::parRun())
{ {
// Strip off leading casename, leaving just processor_DDD ending. // Strip off leading casename, leaving just processor_DDD ending.
vtkName = runTime.caseName(); pltName = runTime.caseName();
string::size_type i = vtkName.rfind("processor"); string::size_type i = pltName.rfind("processor");
if (i != string::npos) if (i != string::npos)
{ {
vtkName = vtkName.substr(i); pltName = pltName.substr(i);
} }
} }
args.optionReadIfPresent("faceSet", faceSetName); args.optionReadIfPresent("faceSet", faceSetName);
@ -269,9 +263,9 @@ int main(int argc, char *argv[])
// TecplotData/ directory in the case // TecplotData/ directory in the case
fileName fvPath(runTime.path()/"Tecplot360"); fileName fvPath(runTime.path()/"Tecplot360");
// Directory of mesh (region0 gets filtered out)
fileName regionPrefix = "";
// Directory of mesh (region0 gets filtered out)
fileName regionPrefix;
if (regionName != polyMesh::defaultRegion) if (regionName != polyMesh::defaultRegion)
{ {
fvPath = fvPath/regionName; fvPath = fvPath/regionName;
@ -293,7 +287,7 @@ int main(int argc, char *argv[])
} }
else else
{ {
Info<< "Deleting old VTK files in " << fvPath << nl << endl; Info<< "Deleting old tecplot files in " << fvPath << nl << endl;
rmDir(fvPath); rmDir(fvPath);
} }
@ -317,13 +311,13 @@ int main(int argc, char *argv[])
polyMesh::readUpdateState meshState = myMesh.readUpdate(); polyMesh::readUpdateState meshState = myMesh.readUpdate();
const fvMesh& mesh = myMesh.mesh(); const fvMesh& mesh = myMesh.mesh();
INTEGER4 nFaceNodes = 0; // TotalNumFaceNodes
int32_t nFaceNodes = 0;
forAll(mesh.faces(), facei) forAll(mesh.faces(), facei)
{ {
nFaceNodes += mesh.faces()[facei].size(); nFaceNodes += mesh.faces()[facei].size();
} }
// Read all fields on the new mesh // Read all fields on the new mesh
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -463,23 +457,23 @@ int main(int argc, char *argv[])
// ~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~
string varNames; string varNames;
DynamicList<INTEGER4> varLocation; DynamicList<int32_t> varLocation;
string cellVarNames; string cellVarNames;
DynamicList<INTEGER4> cellVarLocation; DynamicList<int32_t> cellVarLocation;
// volFields // volFields
tecplotWriter::getTecplotNames tecplotWriter::getTecplotNames
( (
vsf, vsf,
ValueLocation_CellCentered, tecplotWriter::CELL_CENTERED,
varNames, varNames,
varLocation varLocation
); );
tecplotWriter::getTecplotNames tecplotWriter::getTecplotNames
( (
vsf, vsf,
ValueLocation_CellCentered, tecplotWriter::CELL_CENTERED,
cellVarNames, cellVarNames,
cellVarLocation cellVarLocation
); );
@ -487,14 +481,14 @@ int main(int argc, char *argv[])
tecplotWriter::getTecplotNames tecplotWriter::getTecplotNames
( (
vvf, vvf,
ValueLocation_CellCentered, tecplotWriter::CELL_CENTERED,
varNames, varNames,
varLocation varLocation
); );
tecplotWriter::getTecplotNames tecplotWriter::getTecplotNames
( (
vvf, vvf,
ValueLocation_CellCentered, tecplotWriter::CELL_CENTERED,
cellVarNames, cellVarNames,
cellVarLocation cellVarLocation
); );
@ -502,14 +496,14 @@ int main(int argc, char *argv[])
tecplotWriter::getTecplotNames tecplotWriter::getTecplotNames
( (
vSpheretf, vSpheretf,
ValueLocation_CellCentered, tecplotWriter::CELL_CENTERED,
varNames, varNames,
varLocation varLocation
); );
tecplotWriter::getTecplotNames tecplotWriter::getTecplotNames
( (
vSpheretf, vSpheretf,
ValueLocation_CellCentered, tecplotWriter::CELL_CENTERED,
cellVarNames, cellVarNames,
cellVarLocation cellVarLocation
); );
@ -517,14 +511,14 @@ int main(int argc, char *argv[])
tecplotWriter::getTecplotNames tecplotWriter::getTecplotNames
( (
vSymmtf, vSymmtf,
ValueLocation_CellCentered, tecplotWriter::CELL_CENTERED,
varNames, varNames,
varLocation varLocation
); );
tecplotWriter::getTecplotNames tecplotWriter::getTecplotNames
( (
vSymmtf, vSymmtf,
ValueLocation_CellCentered, tecplotWriter::CELL_CENTERED,
cellVarNames, cellVarNames,
cellVarLocation cellVarLocation
); );
@ -532,25 +526,24 @@ int main(int argc, char *argv[])
tecplotWriter::getTecplotNames tecplotWriter::getTecplotNames
( (
vtf, vtf,
ValueLocation_CellCentered, tecplotWriter::CELL_CENTERED,
varNames, varNames,
varLocation varLocation
); );
tecplotWriter::getTecplotNames tecplotWriter::getTecplotNames
( (
vtf, vtf,
ValueLocation_CellCentered, tecplotWriter::CELL_CENTERED,
cellVarNames, cellVarNames,
cellVarLocation cellVarLocation
); );
// pointFields // pointFields
tecplotWriter::getTecplotNames tecplotWriter::getTecplotNames
( (
psf, psf,
ValueLocation_Nodal, tecplotWriter::NODE_CENTERED,
varNames, varNames,
varLocation varLocation
); );
@ -558,44 +551,45 @@ int main(int argc, char *argv[])
tecplotWriter::getTecplotNames tecplotWriter::getTecplotNames
( (
pvf, pvf,
ValueLocation_Nodal, tecplotWriter::NODE_CENTERED,
varNames, varNames,
varLocation varLocation
); );
// strandID (= piece id. Gets incremented for every piece of geometry // strandID (= piece id).
// that is output) // Gets incremented for every piece of geometry that is output.
INTEGER4 strandID = 1; int32_t strandID = 1;
if (meshState != polyMesh::UNCHANGED) if (meshState != polyMesh::UNCHANGED)
{ {
if (doWriteInternal) if (doWriteInternal)
{ {
// Output mesh and fields // Output mesh and fields
fileName vtkFileName fileName pltFileName
( (
fvPath/vtkName fvPath/pltName
+ "_" + "_"
+ timeDesc + timeDesc
+ ".plt" + ".plt"
); );
tecplotWriter writer(runTime); const string allVarNames = tecplotWriter::XYZ + " " + varNames;
DynamicList<int32_t> allVarLocation
string allVarNames = string("X Y Z ") + varNames; {
DynamicList<INTEGER4> allVarLocation; tecplotWriter::NODE_CENTERED,
allVarLocation.append(ValueLocation_Nodal); tecplotWriter::NODE_CENTERED,
allVarLocation.append(ValueLocation_Nodal); tecplotWriter::NODE_CENTERED
allVarLocation.append(ValueLocation_Nodal); };
allVarLocation.append(varLocation); allVarLocation.append(varLocation);
tecplotWriter writer(runTime);
writer.writeInit writer.writeInit
( (
runTime.caseName(), runTime.caseName(),
allVarNames, allVarNames,
vtkFileName, pltFileName,
DataFileType_Full tecplotWriter::FILETYPE_FULL
); );
writer.writePolyhedralZone writer.writePolyhedralZone
@ -607,41 +601,18 @@ int main(int argc, char *argv[])
nFaceNodes nFaceNodes
); );
// Write coordinates // Coordinates
writer.writeField(mesh.points().component(0)()); writer.writeField(mesh.points());
writer.writeField(mesh.points().component(1)());
writer.writeField(mesh.points().component(2)());
// Write all fields // Write all fields
forAll(vsf, i) writer.writeFields(vsf);
{ writer.writeFields(vvf);
writer.writeField(vsf[i]); writer.writeFields(vSpheretf);
} writer.writeFields(vSymmtf);
forAll(vvf, i) writer.writeFields(vtf);
{
writer.writeField(vvf[i]);
}
forAll(vSpheretf, i)
{
writer.writeField(vSpheretf[i]);
}
forAll(vSymmtf, i)
{
writer.writeField(vSymmtf[i]);
}
forAll(vtf, i)
{
writer.writeField(vtf[i]);
}
forAll(psf, i) writer.writeFields(psf);
{ writer.writeFields(pvf);
writer.writeField(psf[i]);
}
forAll(pvf, i)
{
writer.writeField(pvf[i]);
}
writer.writeConnectivity(mesh); writer.writeConnectivity(mesh);
writer.writeEnd(); writer.writeEnd();
@ -654,22 +625,22 @@ int main(int argc, char *argv[])
if (timeI == 0) if (timeI == 0)
{ {
// Output static mesh only // Output static mesh only
fileName vtkFileName fileName pltFileName
( (
fvPath/vtkName fvPath/pltName
+ "_grid_" + "_grid_"
+ timeDesc + timeDesc
+ ".plt" + ".plt"
); );
tecplotWriter writer(runTime);
tecplotWriter writer(runTime);
writer.writeInit writer.writeInit
( (
runTime.caseName(), runTime.caseName(),
"X Y Z", tecplotWriter::XYZ,
vtkFileName, pltFileName,
DataFileType_Grid tecplotWriter::FILETYPE_GRID
); );
writer.writePolyhedralZone writer.writePolyhedralZone
@ -677,36 +648,33 @@ int main(int argc, char *argv[])
mesh.name(), // regionName mesh.name(), // regionName
strandID, // strandID strandID, // strandID
mesh, mesh,
List<INTEGER4>(3, ValueLocation_Nodal), List<int32_t>(3, tecplotWriter::NODE_CENTERED),
nFaceNodes nFaceNodes
); );
// Write coordinates // Coordinates
writer.writeField(mesh.points().component(0)()); writer.writeField(mesh.points());
writer.writeField(mesh.points().component(1)());
writer.writeField(mesh.points().component(2)());
writer.writeConnectivity(mesh); writer.writeConnectivity(mesh);
writer.writeEnd(); writer.writeEnd();
} }
// Output solution file // Output solution file
fileName vtkFileName fileName pltFileName
( (
fvPath/vtkName fvPath/pltName
+ "_" + "_"
+ timeDesc + timeDesc
+ ".plt" + ".plt"
); );
tecplotWriter writer(runTime);
tecplotWriter writer(runTime);
writer.writeInit writer.writeInit
( (
runTime.caseName(), runTime.caseName(),
varNames, varNames,
vtkFileName, pltFileName,
DataFileType_Solution tecplotWriter::FILETYPE_SOLUTION
); );
writer.writePolyhedralZone writer.writePolyhedralZone
@ -719,35 +687,15 @@ int main(int argc, char *argv[])
); );
// Write all fields // Write all fields
forAll(vsf, i) writer.writeFields(vsf);
{ writer.writeFields(vvf);
writer.writeField(vsf[i]); writer.writeFields(vSpheretf);
} writer.writeFields(vSymmtf);
forAll(vvf, i) writer.writeFields(vtf);
{
writer.writeField(vvf[i]); writer.writeFields(psf);
} writer.writeFields(pvf);
forAll(vSpheretf, i)
{
writer.writeField(vSpheretf[i]);
}
forAll(vSymmtf, i)
{
writer.writeField(vSymmtf[i]);
}
forAll(vtf, i)
{
writer.writeField(vtf[i]);
}
forAll(psf, i)
{
writer.writeField(psf[i]);
}
forAll(pvf, i)
{
writer.writeField(pvf[i]);
}
writer.writeEnd(); writer.writeEnd();
} }
} }
@ -765,11 +713,11 @@ int main(int argc, char *argv[])
labelList faceLabels(faceSet(mesh, faceSetName).toc()); labelList faceLabels(faceSet(mesh, faceSetName).toc());
// Filename as if patch with same name. // Filename as if patch with same name.
mkDir(fvPath/setName); mkDir(fvPath/faceSetName);
fileName patchFileName fileName patchFileName
( (
fvPath/setName/setName fvPath/faceSetName/faceSetName
+ "_" + "_"
+ timeDesc + timeDesc
+ ".plt" + ".plt"
@ -777,21 +725,23 @@ int main(int argc, char *argv[])
Info<< " FaceSet : " << patchFileName << endl; Info<< " FaceSet : " << patchFileName << endl;
tecplotWriter writer(runTime); const string allVarNames = tecplotWriter::XYZ + " " + cellVarNames;
DynamicList<int32_t> allVarLocation
string allVarNames = string("X Y Z ") + cellVarNames; {
DynamicList<INTEGER4> allVarLocation; tecplotWriter::NODE_CENTERED,
allVarLocation.append(ValueLocation_Nodal); tecplotWriter::NODE_CENTERED,
allVarLocation.append(ValueLocation_Nodal); tecplotWriter::NODE_CENTERED
allVarLocation.append(ValueLocation_Nodal); };
allVarLocation.append(cellVarLocation); allVarLocation.append(cellVarLocation);
tecplotWriter writer(runTime);
writer.writeInit writer.writeInit
( (
runTime.caseName(), runTime.caseName(),
cellVarNames, cellVarNames,
patchFileName, patchFileName,
DataFileType_Full tecplotWriter::FILETYPE_FULL
); );
const indirectPrimitivePatch ipp const indirectPrimitivePatch ipp
@ -802,16 +752,14 @@ int main(int argc, char *argv[])
writer.writePolygonalZone writer.writePolygonalZone
( (
setName, faceSetName,
strandID++, strandID++,
ipp, ipp,
allVarLocation allVarLocation
); );
// Write coordinates // Coordinates
writer.writeField(ipp.localPoints().component(0)()); writer.writeField(ipp.localPoints());
writer.writeField(ipp.localPoints().component(1)());
writer.writeField(ipp.localPoints().component(2)());
// Write all volfields // Write all volfields
forAll(vsf, i) forAll(vsf, i)
@ -822,7 +770,7 @@ int main(int argc, char *argv[])
( (
linearInterpolate(vsf[i])(), linearInterpolate(vsf[i])(),
faceLabels faceLabels
)() )
); );
} }
forAll(vvf, i) forAll(vvf, i)
@ -833,7 +781,7 @@ int main(int argc, char *argv[])
( (
linearInterpolate(vvf[i])(), linearInterpolate(vvf[i])(),
faceLabels faceLabels
)() )
); );
} }
forAll(vSpheretf, i) forAll(vSpheretf, i)
@ -844,7 +792,7 @@ int main(int argc, char *argv[])
( (
linearInterpolate(vSpheretf[i])(), linearInterpolate(vSpheretf[i])(),
faceLabels faceLabels
)() )
); );
} }
forAll(vSymmtf, i) forAll(vSymmtf, i)
@ -855,7 +803,7 @@ int main(int argc, char *argv[])
( (
linearInterpolate(vSymmtf[i])(), linearInterpolate(vSymmtf[i])(),
faceLabels faceLabels
)() )
); );
} }
forAll(vtf, i) forAll(vtf, i)
@ -866,7 +814,7 @@ int main(int argc, char *argv[])
( (
linearInterpolate(vtf[i])(), linearInterpolate(vtf[i])(),
faceLabels faceLabels
)() )
); );
} }
writer.writeConnectivity(ipp); writer.writeConnectivity(ipp);
@ -908,33 +856,37 @@ int main(int argc, char *argv[])
Info<< " Combined patches : " << patchFileName << endl; Info<< " Combined patches : " << patchFileName << endl;
tecplotWriter writer(runTime); const string allVarNames = tecplotWriter::XYZ + " " + varNames;
DynamicList<int32_t> allVarLocation
string allVarNames = string("X Y Z ") + varNames; {
DynamicList<INTEGER4> allVarLocation; tecplotWriter::NODE_CENTERED,
allVarLocation.append(ValueLocation_Nodal); tecplotWriter::NODE_CENTERED,
allVarLocation.append(ValueLocation_Nodal); tecplotWriter::NODE_CENTERED
allVarLocation.append(ValueLocation_Nodal); };
allVarLocation.append(varLocation); allVarLocation.append(varLocation);
tecplotWriter writer(runTime);
writer.writeInit writer.writeInit
( (
runTime.caseName(), runTime.caseName(),
allVarNames, allVarNames,
patchFileName, patchFileName,
DataFileType_Full tecplotWriter::FILETYPE_FULL
); );
forAll(patchIDs, i) forAll(patchIDs, i)
{ {
label patchID = patchIDs[i]; label patchID = patchIDs[i];
const polyPatch& pp = patches[patchID]; const polyPatch& pp = patches[patchID];
//INTEGER4 strandID = 1 + i; // int32_t strandID = 1 + i;
if (pp.size() > 0) if (pp.size() > 0)
{ {
Info<< " Writing patch " << patchID << "\t" << pp.name() Info<< " Writing patch " << patchID
<< "\tstrand:" << strandID << nl << endl; << tab << pp.name()
<< tab << "strand:" << strandID
<< nl << endl;
const indirectPrimitivePatch ipp const indirectPrimitivePatch ipp
( (
@ -950,10 +902,8 @@ int main(int argc, char *argv[])
allVarLocation allVarLocation
); );
// Write coordinates // Coordinates
writer.writeField(ipp.localPoints().component(0)()); writer.writeField(ipp.localPoints());
writer.writeField(ipp.localPoints().component(1)());
writer.writeField(ipp.localPoints().component(2)());
// Write all fields // Write all fields
forAll(vsf, i) forAll(vsf, i)
@ -965,7 +915,7 @@ int main(int argc, char *argv[])
nearCellValue, nearCellValue,
vsf[i], vsf[i],
patchID patchID
)() )
); );
} }
forAll(vvf, i) forAll(vvf, i)
@ -977,7 +927,7 @@ int main(int argc, char *argv[])
nearCellValue, nearCellValue,
vvf[i], vvf[i],
patchID patchID
)() )
); );
} }
forAll(vSpheretf, i) forAll(vSpheretf, i)
@ -989,7 +939,7 @@ int main(int argc, char *argv[])
nearCellValue, nearCellValue,
vSpheretf[i], vSpheretf[i],
patchID patchID
)() )
); );
} }
forAll(vSymmtf, i) forAll(vSymmtf, i)
@ -1001,7 +951,7 @@ int main(int argc, char *argv[])
nearCellValue, nearCellValue,
vSymmtf[i], vSymmtf[i],
patchID patchID
)() )
); );
} }
forAll(vtf, i) forAll(vtf, i)
@ -1013,7 +963,7 @@ int main(int argc, char *argv[])
nearCellValue, nearCellValue,
vtf[i], vtf[i],
patchID patchID
)() )
); );
} }
@ -1021,14 +971,14 @@ int main(int argc, char *argv[])
{ {
writer.writeField writer.writeField
( (
psf[i].boundaryField()[patchID].patchInternalField()() psf[i].boundaryField()[patchID].patchInternalField()
); );
} }
forAll(pvf, i) forAll(pvf, i)
{ {
writer.writeField writer.writeField
( (
pvf[i].boundaryField()[patchID].patchInternalField()() pvf[i].boundaryField()[patchID].patchInternalField()
); );
} }
@ -1037,7 +987,7 @@ int main(int argc, char *argv[])
else else
{ {
Info<< " Skipping zero sized patch " << patchID Info<< " Skipping zero sized patch " << patchID
<< "\t" << pp.name() << tab << pp.name()
<< nl << endl; << nl << endl;
} }
} }
@ -1054,7 +1004,7 @@ int main(int argc, char *argv[])
const faceZoneMesh& zones = mesh.faceZones(); const faceZoneMesh& zones = mesh.faceZones();
if (doFaceZones && zones.size() > 0) if (doFaceZones && !zones.empty())
{ {
mkDir(fvPath/"faceZoneMesh"); mkDir(fvPath/"faceZoneMesh");
@ -1079,21 +1029,23 @@ int main(int argc, char *argv[])
Info<< " FaceZone : " << patchFileName << endl; Info<< " FaceZone : " << patchFileName << endl;
tecplotWriter writer(runTime); const string allVarNames = tecplotWriter::XYZ + " " + cellVarNames;
DynamicList<int32_t> allVarLocation
string allVarNames = string("X Y Z ") + cellVarNames; {
DynamicList<INTEGER4> allVarLocation; tecplotWriter::NODE_CENTERED,
allVarLocation.append(ValueLocation_Nodal); tecplotWriter::NODE_CENTERED,
allVarLocation.append(ValueLocation_Nodal); tecplotWriter::NODE_CENTERED
allVarLocation.append(ValueLocation_Nodal); };
allVarLocation.append(cellVarLocation); allVarLocation.append(cellVarLocation);
tecplotWriter writer(runTime);
writer.writeInit writer.writeInit
( (
runTime.caseName(), runTime.caseName(),
allVarNames, allVarNames,
patchFileName, patchFileName,
DataFileType_Full tecplotWriter::FILETYPE_FULL
); );
forAll(zones, zoneI) forAll(zones, zoneI)
@ -1116,10 +1068,8 @@ int main(int argc, char *argv[])
allVarLocation allVarLocation
); );
// Write coordinates // Coordinates
writer.writeField(ipp.localPoints().component(0)()); writer.writeField(ipp.localPoints());
writer.writeField(ipp.localPoints().component(1)());
writer.writeField(ipp.localPoints().component(2)());
// Write all volfields // Write all volfields
forAll(vsf, i) forAll(vsf, i)
@ -1130,7 +1080,7 @@ int main(int argc, char *argv[])
( (
linearInterpolate(vsf[i])(), linearInterpolate(vsf[i])(),
pp pp
)() )
); );
} }
forAll(vvf, i) forAll(vvf, i)
@ -1141,7 +1091,7 @@ int main(int argc, char *argv[])
( (
linearInterpolate(vvf[i])(), linearInterpolate(vvf[i])(),
pp pp
)() )
); );
} }
forAll(vSpheretf, i) forAll(vSpheretf, i)
@ -1152,7 +1102,7 @@ int main(int argc, char *argv[])
( (
linearInterpolate(vSpheretf[i])(), linearInterpolate(vSpheretf[i])(),
pp pp
)() )
); );
} }
forAll(vSymmtf, i) forAll(vSymmtf, i)
@ -1163,7 +1113,7 @@ int main(int argc, char *argv[])
( (
linearInterpolate(vSymmtf[i])(), linearInterpolate(vSymmtf[i])(),
pp pp
)() )
); );
} }
forAll(vtf, i) forAll(vtf, i)
@ -1174,7 +1124,7 @@ int main(int argc, char *argv[])
( (
linearInterpolate(vtf[i])(), linearInterpolate(vtf[i])(),
pp pp
)() )
); );
} }
@ -1183,16 +1133,16 @@ int main(int argc, char *argv[])
else else
{ {
Info<< " Skipping zero sized faceZone " << zoneI Info<< " Skipping zero sized faceZone " << zoneI
<< "\t" << pp.name() << tab << pp.name()
<< nl << endl; << nl << endl;
} }
} }
writer.writeEnd(); writer.writeEnd();
Info<< endl; Info<< endl;
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// //
// Write lagrangian data // Write lagrangian data
@ -1283,16 +1233,18 @@ int main(int argc, char *argv[])
} }
string allVarNames = string("X Y Z"); string allVarNames = tecplotWriter::XYZ;
DynamicList<INTEGER4> allVarLocation; DynamicList<int32_t> allVarLocation
allVarLocation.append(ValueLocation_Nodal); {
allVarLocation.append(ValueLocation_Nodal); tecplotWriter::NODE_CENTERED,
allVarLocation.append(ValueLocation_Nodal); tecplotWriter::NODE_CENTERED,
tecplotWriter::NODE_CENTERED
};
tecplotWriter::getTecplotNames<label> tecplotWriter::getTecplotNames<label>
( (
labelNames, labelNames,
ValueLocation_Nodal, tecplotWriter::NODE_CENTERED,
allVarNames, allVarNames,
allVarLocation allVarLocation
); );
@ -1300,7 +1252,7 @@ int main(int argc, char *argv[])
tecplotWriter::getTecplotNames<scalar> tecplotWriter::getTecplotNames<scalar>
( (
scalarNames, scalarNames,
ValueLocation_Nodal, tecplotWriter::NODE_CENTERED,
allVarNames, allVarNames,
allVarLocation allVarLocation
); );
@ -1308,20 +1260,19 @@ int main(int argc, char *argv[])
tecplotWriter::getTecplotNames<vector> tecplotWriter::getTecplotNames<vector>
( (
vectorNames, vectorNames,
ValueLocation_Nodal, tecplotWriter::NODE_CENTERED,
allVarNames, allVarNames,
allVarLocation allVarLocation
); );
tecplotWriter writer(runTime); tecplotWriter writer(runTime);
writer.writeInit writer.writeInit
( (
runTime.caseName(), runTime.caseName(),
allVarNames, allVarNames,
lagrFileName, lagrFileName,
DataFileType_Full tecplotWriter::FILETYPE_FULL
); );
writer.writeOrderedZone writer.writeOrderedZone
@ -1332,19 +1283,19 @@ int main(int argc, char *argv[])
allVarLocation allVarLocation
); );
// Write coordinates // Coordinates
writer.writeField(positions.component(0)()); writer.writeField(positions);
writer.writeField(positions.component(1)());
writer.writeField(positions.component(2)());
// labelFields // labelFields
forAll(labelNames, i) forAll(labelNames, i)
{ {
const word& fieldName = labelNames[i];
IOField<label> fld IOField<label> fld
( (
IOobject IOobject
( (
labelNames[i], fieldName,
mesh.time().timeName(), mesh.time().timeName(),
cloud::prefix/cloudDirs[cloudI], cloud::prefix/cloudDirs[cloudI],
mesh, mesh,
@ -1354,21 +1305,19 @@ int main(int argc, char *argv[])
) )
); );
scalarField sfld(fld.size()); writer.writeField(fld);
forAll(fld, j)
{
sfld[j] = scalar(fld[j]);
}
writer.writeField(sfld);
} }
// scalarFields // scalarFields
forAll(scalarNames, i) forAll(scalarNames, i)
{ {
const word& fieldName = scalarNames[i];
IOField<scalar> fld IOField<scalar> fld
( (
IOobject IOobject
( (
scalarNames[i], fieldName,
mesh.time().timeName(), mesh.time().timeName(),
cloud::prefix/cloudDirs[cloudI], cloud::prefix/cloudDirs[cloudI],
mesh, mesh,
@ -1377,16 +1326,20 @@ int main(int argc, char *argv[])
false false
) )
); );
writer.writeField(fld); writer.writeField(fld);
} }
// vectorFields // vectorFields
forAll(vectorNames, i) forAll(vectorNames, i)
{ {
const word& fieldName = vectorNames[i];
IOField<vector> fld IOField<vector> fld
( (
IOobject IOobject
( (
vectorNames[i], fieldName,
mesh.time().timeName(), mesh.time().timeName(),
cloud::prefix/cloudDirs[cloudI], cloud::prefix/cloudDirs[cloudI],
mesh, mesh,
@ -1395,6 +1348,7 @@ int main(int argc, char *argv[])
false false
) )
); );
writer.writeField(fld); writer.writeField(fld);
} }

View File

@ -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.
@ -25,13 +25,23 @@ License
#include "tecplotWriter.H" #include "tecplotWriter.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "TECIO.h"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const int32_t Foam::tecplotWriter::tecConst_0 = 0;
const int32_t Foam::tecplotWriter::tecConst_1 = 1;
const int32_t Foam::tecplotWriter::tecConst_False = 0;
const int32_t Foam::tecplotWriter::tecConst_True = 1;
const Foam::string Foam::tecplotWriter::XYZ = "X Y Z";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::tecplotWriter::tecplotWriter(const Time& runTime) Foam::tecplotWriter::tecplotWriter(const Time& runTime)
: :
runTime_(runTime) time_(runTime)
{} {}
@ -42,35 +52,37 @@ void Foam::tecplotWriter::writeInit
const word& name, const word& name,
const string& varNames, const string& varNames,
const fileName& fName, const fileName& fName,
INTEGER4 tecplotFileType const dataFileType fileType
) const ) const
{ {
Pout<< endl const int32_t FileType = fileType;
<< endl const int32_t FileFormat = 0; // 0 = binary (plt), 1 = subzone (.szplt)
Pout<< nl << nl
<< "Name:" << name << "Name:" << name
<< " varNames:" << varNames << " varNames:" << varNames
<< " to file:" << fName << " to file:" << fName
<< " of type:" << tecplotFileType << " of type:" << int(fileType)
<< endl; << endl;
INTEGER4 IsDouble = 0; //float
INTEGER4 Debug = 0; //nodebug
if if
( (
!TECINI112 tecini142
( (
const_cast<char*>(name.c_str()), /* Data Set Title */ name.c_str(), //< DataSet Title
const_cast<char*>(varNames.c_str()), /* Variable List */ varNames.c_str(), //< Variables List
const_cast<char*>(fName.c_str()), /* File Name */ fName.c_str(), //< FileName
const_cast<char*>(runTime_.path().c_str()), /* Scratch Directory */ time_.path().c_str(), //< ScratchDir
&tecplotFileType, &FileFormat, //< FileFormat
&Debug, &FileType, //< FileType
&IsDouble &tecConst_False, //< Debug (0: no debug, 1: debug)
&tecConst_False //< VIsDouble (0: single, 1: double)
) )
) )
{ {
// FatalErrorInFunction FatalErrorInFunction
// << "Error in TECINI112." << exit(FatalError); << "Error in tecini142."
<< exit(FatalError);
} }
} }
@ -78,78 +90,60 @@ Pout<< endl
void Foam::tecplotWriter::writePolyhedralZone void Foam::tecplotWriter::writePolyhedralZone
( (
const word& zoneName, const word& zoneName,
INTEGER4 strandID, const int32_t strandID,
const fvMesh& mesh, const fvMesh& mesh,
const List<INTEGER4>& varLocArray, const UList<int32_t>& varLocArray,
INTEGER4 nFaceNodes const int32_t NumFaceNodes
) const ) const
{ {
/* Call TECZNE112 */ const int32_t NumNodes = mesh.nPoints(); // Number of unique nodes
INTEGER4 NumNodes = mesh.nPoints(); /* number of unique nodes */ const int32_t NumElems = mesh.nCells(); // Number of elements
INTEGER4 NumElems = mesh.nCells(); /* number of elements */ const int32_t NumFaces = mesh.nFaces(); // Number of unique faces
INTEGER4 NumFaces = mesh.nFaces(); /* number of unique faces */ const double SolTime = time_.value(); // Solution time
INTEGER4 ICellMax = 0; /* Not Used, set to zero */ const int32_t ParentZone = 0; // Bool: 0 = no parent zone
INTEGER4 JCellMax = 0; /* Not Used, set to zero */ const int32_t ShrConn = 0;
INTEGER4 KCellMax = 0; /* Not Used, set to zero */ const int32_t NumBConns = 0; // No Boundary Connections
const int32_t NumBItems = 0; // No Boundary Items
double SolTime = runTime_.value(); /* solution time */
INTEGER4 ParentZone = 0; /* no parent zone */
INTEGER4 IsBlock = 1; /* block format */
INTEGER4 NFConns = 0; /* not used for FEPolyhedron
* zones
*/
INTEGER4 FNMode = 0; /* not used for FEPolyhedron
* zones
*/
Pout<< "zoneName:" << zoneName Pout<< "zoneName:" << zoneName
//<< " varLocArray:" << varLocArray //<< " varLocArray:" << varLocArray
<< " solTime:" << SolTime << " solTime:" << SolTime
<< " strand:" << strandID
<< endl; << endl;
const int32_t ZoneType = ZONE_FEPOLYHEDRON;
INTEGER4 *PassiveVarArray = nullptr;
INTEGER4 *VarShareArray = nullptr;
INTEGER4 ShrConn = 0;
INTEGER4 NumBConns = 0; /* No Boundary Connections */
INTEGER4 NumBItems = 0; /* No Boundary Items */
INTEGER4 ZoneType = ZoneType_FEPolyhedron;
if if
( (
!TECZNE112 teczne142
( (
const_cast<char*>(zoneName.c_str()), zoneName.c_str(), //< ZoneTitle
&ZoneType, &ZoneType, //< ZoneType
&NumNodes, &NumNodes, //< IMxOrNumPts
&NumElems, &NumElems, //< JMxOrNumElements
&NumFaces, &NumFaces, //< KMxOrNumFaces
&ICellMax, &tecConst_0, //< (unused set to zero) ICellMax
&JCellMax, &tecConst_0, //< (unused set to zero) JCellMax
&KCellMax, &tecConst_0, //< (unused set to zero) KCellMax
&SolTime, &SolTime, //< SolutionTime
&strandID, &strandID, //< StrandID
&ParentZone, &ParentZone, //< ParentZone
&IsBlock, &tecConst_True, //< IsBlock
&NFConns, &tecConst_0, //< (unused) NumFaceConnections
&FNMode, &tecConst_0, //< (unused) FaceNeighborMode
&nFaceNodes, &NumFaceNodes, //< TotalNumFaceNodes
&NumBConns, &NumBConns, //< NumConnectedBoundaryFaces
&NumBItems, &NumBItems, //< TotalNumBoundaryConnections
PassiveVarArray, nullptr, //< PassiveVarList
const_cast<INTEGER4*>(varLocArray.begin()), varLocArray.cdata(), //< ValueLocation
VarShareArray, nullptr, //< ShareVarFromZone
&ShrConn &ShrConn //< ShareConnectivityFromZone
) )
) )
{ {
// FatalErrorInFunction FatalErrorInFunction
// << "Error in TECZNE112." << exit(FatalError); << "Error in teczne142 - writing polyhedron zones."
<< exit(FatalError);
} }
} }
@ -157,32 +151,22 @@ Pout<< "zoneName:" << zoneName
void Foam::tecplotWriter::writePolygonalZone void Foam::tecplotWriter::writePolygonalZone
( (
const word& zoneName, const word& zoneName,
INTEGER4 strandID, const int32_t strandID,
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const List<INTEGER4>& varLocArray const UList<int32_t>& varLocArray
) const ) const
{ {
/* Call TECZNE112 */ const int32_t NumNodes = pp.nPoints(); // Number of unique nodes
INTEGER4 NumNodes = pp.nPoints(); /* number of unique nodes */ const int32_t NumElems = pp.size(); // Number of elements
INTEGER4 NumElems = pp.size(); /* number of elements */ const int32_t NumFaces = pp.nEdges(); // Number of unique faces
INTEGER4 NumFaces = pp.nEdges(); /* number of unique faces */ const double SolTime = time_.value(); // Solution time
INTEGER4 ICellMax = 0; /* Not Used, set to zero */ const int32_t ParentZone = 0; // Int: 0 = no parent zone
INTEGER4 JCellMax = 0; /* Not Used, set to zero */ const int32_t NumFaceNodes = 2*pp.nEdges();
INTEGER4 KCellMax = 0; /* Not Used, set to zero */
double SolTime = runTime_.value(); /* solution time */ const int32_t ShrConn = 0;
INTEGER4 ParentZone = 0; /* no parent zone */ const int32_t NumBConns = 0; // No Boundary Connections
const int32_t NumBItems = 0; // No Boundary Items
INTEGER4 IsBlock = 1; /* block format */
INTEGER4 NFConns = 0; /* not used for FEPolyhedron
* zones
*/
INTEGER4 FNMode = 0; /* not used for FEPolyhedron
* zones
*/
INTEGER4 NumFaceNodes = 2*pp.nEdges();
Pout<< "zoneName:" << zoneName Pout<< "zoneName:" << zoneName
<< " strandID:" << strandID << " strandID:" << strandID
@ -190,46 +174,38 @@ Pout<< "zoneName:" << zoneName
<< " solTime:" << SolTime << " solTime:" << SolTime
<< endl; << endl;
const int32_t ZoneType = ZONE_FEPOLYGON;
INTEGER4 *PassiveVarArray = nullptr;
INTEGER4 *VarShareArray = nullptr;
INTEGER4 ShrConn = 0;
INTEGER4 NumBConns = 0; /* No Boundary Connections */
INTEGER4 NumBItems = 0; /* No Boundary Items */
INTEGER4 ZoneType = ZoneType_FEPolygon;
if if
( (
!TECZNE112 teczne142
( (
const_cast<char*>(zoneName.c_str()), zoneName.c_str(), //< ZoneTitle
&ZoneType, &ZoneType, //< ZoneType
&NumNodes, &NumNodes, //< IMax or NumPts
&NumElems, &NumElems, //< JMax or NumElements
&NumFaces, &NumFaces, //< KMax or NumFaces
&ICellMax, &tecConst_0, //< (Unused set to zero) ICellMax
&JCellMax, &tecConst_0, //< (Unused set to zero) JCellMax
&KCellMax, &tecConst_0, //< (Unused set to zero) KCellMax
&SolTime, &SolTime, //< SolutionTime
&strandID, &strandID, //< StrandID
&ParentZone, &ParentZone, //< ParentZone
&IsBlock, &tecConst_True, //< IsBlock
&NFConns, &tecConst_0, //< (Unused for polygon zone) NumFaceConnections
&FNMode, &tecConst_0, //< (Unused for polygon zone) FaceNeighborMode
&NumFaceNodes, &NumFaceNodes, //< TotalNumFaceNodes
&NumBConns, &NumBConns, //< NumConnectedBoundaryFaces
&NumBItems, &NumBItems, //< TotalNumBoundaryConnections
PassiveVarArray, nullptr, //< PassiveVarList
const_cast<INTEGER4*>(varLocArray.begin()), varLocArray.cdata(), //< ValueLocation
VarShareArray, nullptr, //< ShareVarFromZone
&ShrConn &ShrConn //< ShareConnectivityFromZone
) )
) )
{ {
// FatalErrorInFunction FatalErrorInFunction
// << "Error in TECZNE112." << exit(FatalError); << "Error in teczne142 - writing polygon zones."
<< exit(FatalError);
} }
} }
@ -237,34 +213,24 @@ Pout<< "zoneName:" << zoneName
void Foam::tecplotWriter::writeOrderedZone void Foam::tecplotWriter::writeOrderedZone
( (
const word& zoneName, const word& zoneName,
INTEGER4 strandID, const int32_t strandID,
const label n, const label n,
const List<INTEGER4>& varLocArray const UList<int32_t>& varLocArray
) const ) const
{ {
/* Call TECZNE112 */ const int32_t IMax = n; // Number in I direction
INTEGER4 IMax = n; /* number of unique nodes */ const int32_t JMax = 1; // Number in J direction
INTEGER4 JMax = 1; /* number of elements */ const int32_t KMax = 1; // Number in K direction
INTEGER4 KMax = 1; /* number of unique faces */ const double SolTime = time_.value(); // Solution time
INTEGER4 ICellMax = 0; /* Not Used, set to zero */ const int32_t ParentZone = 0; // Bool: no parent zone
INTEGER4 JCellMax = 0; /* Not Used, set to zero */ const int32_t NFConns = 0; // Unused for ordered zones
INTEGER4 KCellMax = 0; /* Not Used, set to zero */ const int32_t FNMode = 0; // Unused for ordered zones
double SolTime = runTime_.value(); /* solution time */ const int32_t ShrConn = 0;
INTEGER4 ParentZone = 0; /* no parent zone */ const int32_t NumFaceNodes = 1;
const int32_t NumBConns = 0; // No Boundary Connections
INTEGER4 IsBlock = 1; /* block format */ const int32_t NumBItems = 0; // No Boundary Items
INTEGER4 NFConns = 0; /* not used for FEPolyhedron
* zones
*/
INTEGER4 FNMode = 0; /* not used for FEPolyhedron
* zones
*/
INTEGER4 NumFaceNodes = 1;
INTEGER4 NumBConns = 1; /* No Boundary Connections */
INTEGER4 NumBItems = 1; /* No Boundary Items */
Pout<< "zoneName:" << zoneName Pout<< "zoneName:" << zoneName
<< " strandID:" << strandID << " strandID:" << strandID
@ -272,85 +238,74 @@ Pout<< "zoneName:" << zoneName
<< " solTime:" << SolTime << " solTime:" << SolTime
<< endl; << endl;
const int32_t ZoneType = ZONE_ORDERED;
INTEGER4 *PassiveVarArray = nullptr;
INTEGER4 *VarShareArray = nullptr;
INTEGER4 ShrConn = 0;
INTEGER4 ZoneType = ZoneType_Ordered;
if if
( (
!TECZNE112 teczne142
( (
const_cast<char*>(zoneName.c_str()), zoneName.c_str(), //< ZoneTitle
&ZoneType, &ZoneType, //< ZoneType
&IMax, &IMax, //< IMax or NumPts
&JMax, &JMax, //< JMax or NumElements
&KMax, &KMax, //< KMax or NumFaces
&ICellMax, &tecConst_0, //< (Unused set to zero) ICellMax
&JCellMax, &tecConst_0, //< (Unused set to zero) JCellMax
&KCellMax, &tecConst_0, //< (Unused set to zero) KCellMax
&SolTime, &SolTime, //< SolutionTime
&strandID, &strandID, //< StrandID
&ParentZone, &ParentZone, //< ParentZone
&IsBlock, &tecConst_True, //< IsBlock
&NFConns, &NFConns, //< NumFaceConnections
&FNMode, &FNMode, //< FaceNeighborMode
&NumFaceNodes, &NumFaceNodes, //< TotalNumFaceNodes
&NumBConns, &NumBConns, //< NumConnectedBoundaryFaces
&NumBItems, &NumBItems, //< TotalNumBoundaryConnections
PassiveVarArray, nullptr, //< PassiveVarList
const_cast<INTEGER4*>(varLocArray.begin()), varLocArray.cdata(), //< ValueLocation
VarShareArray, nullptr, //< ShareVarFromZone
&ShrConn &ShrConn //< ShareConnectivityFromZone
) )
) )
{ {
// FatalErrorInFunction FatalErrorInFunction
// << "Error in TECZNE112." << exit(FatalError); << "Error in teczne142 - writing ordered zones."
<< exit(FatalError);
} }
} }
void Foam::tecplotWriter::writeConnectivity(const fvMesh& mesh) const void Foam::tecplotWriter::writeConnectivity(const fvMesh& mesh) const
{ {
List<INTEGER4> FaceNodeCounts(mesh.nFaces()); // first pass: get the sizes
List<int32_t> FaceNodeCounts(mesh.nFaces());
label nFaceNodes = 0;
forAll(mesh.faces(), facei) forAll(mesh.faces(), facei)
{ {
const face& f = mesh.faces()[facei]; const face& f = mesh.faces()[facei];
FaceNodeCounts[facei] = INTEGER4(f.size()); nFaceNodes += f.size();
FaceNodeCounts[facei] = int32_t(f.size());
} }
// second pass: get the nodes as a flat list
INTEGER4 nFaceNodes = 0; List<int32_t> FaceNodes(nFaceNodes);
forAll(mesh.faces(), facei)
{
nFaceNodes += mesh.faces()[facei].size();
}
List<INTEGER4> FaceNodes(nFaceNodes);
label nodeI = 0; label nodeI = 0;
forAll(mesh.faces(), facei) forAll(mesh.faces(), facei)
{ {
const face& f = mesh.faces()[facei]; const face& f = mesh.faces()[facei];
forAll(f, fp) forAll(f, fp)
{ {
FaceNodes[nodeI++] = INTEGER4(f[fp]+1); FaceNodes[nodeI++] = int32_t(f[fp]+1);
} }
} }
List<INTEGER4> FaceLeftElems(mesh.nFaces()); List<int32_t> FaceLeftElems(mesh.nFaces());
forAll(mesh.faceOwner(), facei) forAll(mesh.faceOwner(), facei)
{ {
FaceLeftElems[facei] = mesh.faceOwner()[facei]+1; FaceLeftElems[facei] = mesh.faceOwner()[facei]+1;
} }
List<INTEGER4> FaceRightElems(mesh.nFaces()); List<int32_t> FaceRightElems(mesh.nFaces());
forAll(mesh.faceNeighbour(), facei) forAll(mesh.faceNeighbour(), facei)
{ {
FaceRightElems[facei] = mesh.faceNeighbour()[facei]+1; FaceRightElems[facei] = mesh.faceNeighbour()[facei]+1;
@ -367,20 +322,21 @@ void Foam::tecplotWriter::writeConnectivity(const fvMesh& mesh) const
if if
( (
!TECPOLY112 tecpoly142
( (
FaceNodeCounts.begin(), /* The face node counts array */ FaceNodeCounts.cdata(), // The face node counts array
FaceNodes.begin(), /* The face nodes array */ FaceNodes.cdata(), // The face nodes array
FaceLeftElems.begin(), /* The left elements array */ FaceLeftElems.cdata(), // The left elements array
FaceRightElems.begin(), /* The right elements array */ FaceRightElems.cdata(), // The right elements array
nullptr, /* No boundary connection counts */ nullptr, // No face boundary connection counts
nullptr, /* No boundary connection elements */ nullptr, // No face boundary connection elements
nullptr /* No boundary connection zones */ nullptr // No face boundary connection zones
) )
) )
{ {
// FatalErrorInFunction FatalErrorInFunction
// << "Error in TECPOLY112." << exit(FatalError); << "Error in tecpoly142."
<< exit(FatalError);
} }
} }
@ -389,25 +345,25 @@ void Foam::tecplotWriter::writeConnectivity
const indirectPrimitivePatch& pp const indirectPrimitivePatch& pp
) const ) const
{ {
INTEGER4 NumFaces = pp.nEdges(); /* number of unique faces */ const int32_t NumFaces = pp.nEdges(); // Number of unique faces
INTEGER4 NumFaceNodes = 2*pp.nEdges(); const int32_t NumFaceNodes = 2*NumFaces; // 2 nodes per edge
// All faces (=edges) have 2 nodes // All faces (=edges) have 2 nodes
List<INTEGER4> FaceNodeCounts(NumFaces); List<int32_t> FaceNodeCounts(NumFaces);
FaceNodeCounts = 2; FaceNodeCounts = 2;
List<INTEGER4> FaceNodes(NumFaceNodes); List<int32_t> FaceNodes(NumFaceNodes);
label nodeI = 0; label nodeI = 0;
forAll(pp.edges(), edgeI) forAll(pp.edges(), edgei)
{ {
edge e = pp.edges()[edgeI]; edge e = pp.edges()[edgei];
if (e[0] > e[1]) if (e[0] > e[1])
{ {
e.flip(); e.flip();
} }
FaceNodes[nodeI++] = INTEGER4(e[0]+1); FaceNodes[nodeI++] = int32_t(e[0]+1);
FaceNodes[nodeI++] = INTEGER4(e[1]+1); FaceNodes[nodeI++] = int32_t(e[1]+1);
} }
/* Define the right and left elements of each face. /* Define the right and left elements of each face.
@ -430,22 +386,22 @@ void Foam::tecplotWriter::writeConnectivity
* (element 0). * (element 0).
*/ */
List<INTEGER4> FaceLeftElems(NumFaces); List<int32_t> FaceLeftElems(NumFaces);
List<INTEGER4> FaceRightElems(NumFaces); List<int32_t> FaceRightElems(NumFaces);
const labelListList& edgeFaces = pp.edgeFaces(); const labelListList& edgeFaces = pp.edgeFaces();
forAll(edgeFaces, edgeI) forAll(edgeFaces, edgei)
{ {
const labelList& eFaces = edgeFaces[edgeI]; const labelList& eFaces = edgeFaces[edgei];
if (eFaces.size() == 1) if (eFaces.size() == 1)
{ {
FaceLeftElems[edgeI] = 0; FaceLeftElems[edgei] = 0;
FaceRightElems[edgeI] = eFaces[0]+1; FaceRightElems[edgei] = eFaces[0]+1;
} }
else if (eFaces.size() == 2) else if (eFaces.size() == 2)
{ {
edge e = pp.edges()[edgeI]; edge e = pp.edges()[edgei];
if (e[0] > e[1]) if (e[0] > e[1])
{ {
e.flip(); e.flip();
@ -456,45 +412,46 @@ void Foam::tecplotWriter::writeConnectivity
// The face that uses the vertices of e in increasing order // The face that uses the vertices of e in increasing order
// is the left face. // is the left face.
label fp = findIndex(f0, e[0]); const label fp = findIndex(f0, e[0]);
bool f0IsLeft = (f0.nextLabel(fp) == e[1]); const bool f0IsLeft = (f0.nextLabel(fp) == e[1]);
if (f0IsLeft) if (f0IsLeft)
{ {
FaceLeftElems[edgeI] = eFaces[0]+1; FaceLeftElems[edgei] = eFaces[0]+1;
FaceRightElems[edgeI] = eFaces[1]+1; FaceRightElems[edgei] = eFaces[1]+1;
} }
else else
{ {
FaceLeftElems[edgeI] = eFaces[1]+1; FaceLeftElems[edgei] = eFaces[1]+1;
FaceRightElems[edgeI] = eFaces[0]+1; FaceRightElems[edgei] = eFaces[0]+1;
} }
} }
else else
{ {
// non-manifold. Treat as if open. // non-manifold. Treat as if open.
FaceLeftElems[edgeI] = 0; FaceLeftElems[edgei] = 0;
FaceRightElems[edgeI] = eFaces[0]+1; FaceRightElems[edgei] = eFaces[0]+1;
} }
} }
/* Write the face map (created above) using TECPOLY112. */ // Write the face map (created above)
if if
( (
!TECPOLY112 tecpoly142
( (
FaceNodeCounts.begin(), /* The face node counts array */ FaceNodeCounts.cdata(), // Face node counts array
FaceNodes.begin(), /* The face nodes array */ FaceNodes.cdata(), // Face nodes array
FaceLeftElems.begin(), /* The left elements array */ FaceLeftElems.cdata(), // Left elements array
FaceRightElems.begin(), /* The right elements array */ FaceRightElems.cdata(), // Right elements array
nullptr, /* No boundary connection counts */ nullptr, // No boundary connection counts
nullptr, /* No boundary connection elements */ nullptr, // No boundary connection elements
nullptr /* No boundary connection zones */ nullptr // No boundary connection zones
) )
) )
{ {
// FatalErrorInFunction FatalErrorInFunction
// << "Error in TECPOLY112." << exit(FatalError); << "Error in tecpoly142."
<< exit(FatalError);
} }
} }
@ -503,12 +460,12 @@ void Foam::tecplotWriter::writeEnd() const
{ {
Pout<< "writeEnd" << endl; Pout<< "writeEnd" << endl;
if (!TECEND112()) if (tecend142())
{ {
// FatalErrorInFunction FatalErrorInFunction
// << "Error in TECEND112." << exit(FatalError); << "Error in tecend142."
<< exit(FatalError);
} }
} }

View File

@ -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.
@ -27,6 +27,11 @@ Class
Description Description
Write binary tecplot files using tecio. Write binary tecplot files using tecio.
Note
The tecplot API uses pass by reference for all routines.
Its standard integer is defined as INTEGER4 (ie, int32_t),
which is also used when passing boolean values.
SourceFiles SourceFiles
tecplotWriter.C tecplotWriter.C
tecplotWriterTemplates.C tecplotWriterTemplates.C
@ -36,14 +41,11 @@ SourceFiles
#ifndef tecplotWriter_H #ifndef tecplotWriter_H
#define tecplotWriter_H #define tecplotWriter_H
#include "TECIO.h"
#include "Time.H" #include "Time.H"
#include "indirectPrimitivePatch.H" #include "indirectPrimitivePatch.H"
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
@ -57,10 +59,71 @@ class fvMesh;
class tecplotWriter class tecplotWriter
{ {
const Time& runTime_; //- Tecplot ZoneTypes
enum tecplotZoneType
{
ZONE_ORDERED = 0,
ZONE_FELINESEG = 1,
ZONE_FETRIANGLE = 2,
ZONE_FEQUADRILATERAL = 3,
ZONE_FETETRAHEDRON = 4,
ZONE_FEBRICK = 5,
ZONE_FEPOLYGON = 6,
ZONE_FEPOLYHEDRON = 7
};
// Static data members
// Values commonly used internally
static const int32_t tecConst_0;
static const int32_t tecConst_1;
static const int32_t tecConst_False;
static const int32_t tecConst_True;
// Private data
//- Time reference. Used for paths and the solution time.
const Time& time_;
// Private Member Functions
template<class GeoField>
static wordList getNames(const PtrList<const GeoField>&);
//- Disallow default bitwise copy construct
tecplotWriter(const tecplotWriter&) = delete;
//- Disallow default bitwise assignment
void operator=(const tecplotWriter&) = delete;
public: public:
//- Data location types
enum dataLocation
{
CELL_CENTERED = 0,
NODE_CENTERED = 1
};
//- Data file type
enum dataFileType
{
FILETYPE_FULL = 0,
FILETYPE_GRID = 1,
FILETYPE_SOLUTION = 2
};
// Static data members
//- Commonly used "X Y Z" string
static const string XYZ;
// Constructors // Constructors
//- Construct from components //- Construct from components
@ -69,92 +132,103 @@ public:
// Member Functions // Member Functions
//- Initialize writing
void writeInit void writeInit
( (
const word& name, const word& name,
const string& varNames, const string& varNames,
const fileName&, const fileName&,
INTEGER4 tecplotFileType const dataFileType fileType
) const; ) const;
//- Write mesh as polyhedral zone //- Write mesh as polyhedral zone
void writePolyhedralZone void writePolyhedralZone
( (
const word& zoneName, const word& zoneName,
const INTEGER4 strandID, const int32_t strandID,
const fvMesh& mesh, const fvMesh& mesh,
const List<INTEGER4>& varLocArray, const UList<int32_t>& varLocArray,
INTEGER4 nFaceNodes const int32_t NumFaceNodes
) const; ) const;
//- Write surface as polygonal zone //- Write surface as polygonal zone
void writePolygonalZone void writePolygonalZone
( (
const word& zoneName, const word& zoneName,
const INTEGER4 strandID, const int32_t strandID,
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const List<INTEGER4>& varLocArray const UList<int32_t>& varLocArray
) const; ) const;
//- Write unordered data (or rather 1D ordered) //- Write unordered data (or rather 1D ordered)
void writeOrderedZone void writeOrderedZone
( (
const word& zoneName, const word& zoneName,
INTEGER4 strandID, const int32_t strandID,
const label n, const label n,
const List<INTEGER4>& varLocArray const UList<int32_t>& varLocArray
) const; ) const;
//- Write mesh //- Write mesh
void writeConnectivity(const fvMesh& mesh) const; void writeConnectivity(const fvMesh&) const;
//- Write surface //- Write surface
void writeConnectivity(const indirectPrimitivePatch& pp) const; void writeConnectivity(const indirectPrimitivePatch& pp) const;
//- Finalize writing
void writeEnd() const; void writeEnd() const;
//- Write generic Field
//- Write generic Field, component-wise
template<class Type> template<class Type>
void writeField(const Field<Type>& fld) const; void writeField(const Field<Type>&) const;
//- Write generic Field, component-wise
template<class Type>
void writeField(const tmp<Field<Type>>&) const;
//- Write all fields listed
template<class GeoField>
void writeFields(const PtrList<const GeoField>&) const;
//- Get either fvPatchField or patchInternalField //- Get either fvPatchField or patchInternalField
template<class Type> template<class Type>
tmp<Field<Type>> getPatchField static tmp<Field<Type>> getPatchField
( (
const bool nearCellValue, const bool nearCellValue,
const GeometricField<Type, fvPatchField, volMesh>& vfld, const GeometricField<Type, fvPatchField, volMesh>&,
const label patchi const label patchi
) const; );
//- Get mixed field: fvsPatchField for boundary faces and //- Get mixed field: fvsPatchField for boundary faces and
// internalField for internal faces. // internalField for internal faces.
template<class Type> template<class Type>
tmp<Field<Type>> getFaceField static tmp<Field<Type>> getFaceField
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>&, const GeometricField<Type, fvsPatchField, surfaceMesh>&,
const labelList& faceLabels const labelUList& faceLabels
) const; );
template<class GeoField>
static wordList getNames(const PtrList<GeoField>&);
//- Fill in tecplot names/locations for the given input names
template<class Type> template<class Type>
static void getTecplotNames static void getTecplotNames
( (
const wordList& names, const wordList& names,
const INTEGER4 loc, const int32_t loc,
string& varNames, string& varNames,
DynamicList<INTEGER4>& varLocation DynamicList<int32_t>& varLocation
); );
//- Fill in tecplot names/locations for the given input fields
template<class GeoField> template<class GeoField>
static void getTecplotNames static void getTecplotNames
( (
const PtrList<GeoField>& flds, const PtrList<GeoField>& flds,
const INTEGER4 loc, const int32_t loc,
string& varNames, string& varNames,
DynamicList<INTEGER4>& varLocation DynamicList<int32_t>& varLocation
); );
}; };

View File

@ -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.
@ -23,14 +23,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
//extern "C"
//{
#include "MASTER.h"
#include "GLOBAL.h"
//}
#include "tecplotWriter.H" #include "tecplotWriter.H"
#include "TECIO.h"
#include "fvc.H" #include "fvc.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -38,39 +32,71 @@ License
template<class Type> template<class Type>
void Foam::tecplotWriter::writeField(const Field<Type>& fld) const void Foam::tecplotWriter::writeField(const Field<Type>& fld) const
{ {
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++) typedef typename pTraits<Type>::cmptType cmptType;
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; ++cmpt)
{ {
scalarField cmptFld(fld.component(cmpt)); tmp<Field<cmptType>> tcmptFld = fld.component(cmpt);
const Field<cmptType>& cmptFld = tcmptFld();
const int32_t size = int32_t(cmptFld.size());
// Convert to float // Convert to float
Field<float> floats(cmptFld.size()); Field<float> floats(size);
forAll(cmptFld, i) forAll(cmptFld, i)
{ {
floats[i] = float(cmptFld[i]); floats[i] = float(cmptFld[i]);
} }
INTEGER4 size = INTEGER4(floats.size());
INTEGER4 IsDouble = 0; //float
//Pout<< "Writing component:" << cmpt << " of size:" << size //Pout<< "Writing component:" << cmpt << " of size:" << size
// << " floats." << endl; // << " floats." << endl;
if (!TECDAT112(&size, floats.begin(), &IsDouble)) if
(
tecdat142
(
&size,
floats.cdata(),
&tecConst_False //< VIsDouble (0: single, 1: double)
)
)
{ {
// FatalErrorInFunction FatalErrorInFunction
// << "Error in TECDAT112." << exit(FatalError); << "Error in tecdat142."
<< exit(FatalError);
} }
} }
} }
template<class Type> template<class Type>
Foam::tmp<Field<Type>> Foam::tecplotWriter::getPatchField void Foam::tecplotWriter::writeField(const tmp<Field<Type>>& tfld) const
{
writeField(tfld());
}
template<class GeoField>
void Foam::tecplotWriter::writeFields
(
const PtrList<const GeoField>& flds
) const
{
forAll(flds, i)
{
writeField(flds[i]);
}
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::tecplotWriter::getPatchField
( (
const bool nearCellValue, const bool nearCellValue,
const GeometricField<Type, fvPatchField, volMesh>& vfld, const GeometricField<Type, fvPatchField, volMesh>& vfld,
const label patchi const label patchi
) const )
{ {
if (nearCellValue) if (nearCellValue)
{ {
@ -84,11 +110,12 @@ Foam::tmp<Field<Type>> Foam::tecplotWriter::getPatchField
template<class Type> template<class Type>
Foam::tmp<Field<Type>> Foam::tecplotWriter::getFaceField Foam::tmp<Foam::Field<Type>>
Foam::tecplotWriter::getFaceField
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld, const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld,
const labelList& faceLabels const labelUList& faceLabels
) const )
{ {
const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh(); const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh();
@ -97,9 +124,8 @@ Foam::tmp<Field<Type>> Foam::tecplotWriter::getFaceField
forAll(faceLabels, i) forAll(faceLabels, i)
{ {
label facei = faceLabels[i]; const label facei = faceLabels[i];
const label patchi = patches.whichPatch(facei);
label patchi = patches.whichPatch(facei);
if (patchi == -1) if (patchi == -1)
{ {
@ -117,9 +143,10 @@ Foam::tmp<Field<Type>> Foam::tecplotWriter::getFaceField
template<class GeoField> template<class GeoField>
Foam::wordList Foam::tecplotWriter::getNames Foam::wordList
Foam::tecplotWriter::getNames
( (
const PtrList<GeoField>& flds const PtrList<const GeoField>& flds
) )
{ {
wordList names(flds.size()); wordList names(flds.size());
@ -135,11 +162,13 @@ template<class Type>
void Foam::tecplotWriter::getTecplotNames void Foam::tecplotWriter::getTecplotNames
( (
const wordList& names, const wordList& names,
const INTEGER4 loc, const int32_t loc,
string& varNames, string& varNames,
DynamicList<INTEGER4>& varLocation DynamicList<int32_t>& varLocation
) )
{ {
const direction nCmpts = pTraits<Type>::nComponents;
forAll(names, i) forAll(names, i)
{ {
if (!varNames.empty()) if (!varNames.empty())
@ -147,8 +176,6 @@ void Foam::tecplotWriter::getTecplotNames
varNames += " "; varNames += " ";
} }
label nCmpts = pTraits<Type>::nComponents;
if (nCmpts == 1) if (nCmpts == 1)
{ {
varNames += names[i]; varNames += names[i];
@ -156,19 +183,13 @@ void Foam::tecplotWriter::getTecplotNames
} }
else else
{ {
for for (direction cmpt = 0; cmpt < nCmpts; ++cmpt)
(
direction cmpt = 0;
cmpt < nCmpts;
cmpt++
)
{ {
string fldName = varNames +=
(cmpt != 0 ? " " : string::null) (
+ names[i] (cmpt ? " " : string::null)
+ "_" + names[i] + "_" + pTraits<Type>::componentNames[cmpt]
+ pTraits<Type>::componentNames[cmpt]; );
varNames += fldName;
varLocation.append(loc); varLocation.append(loc);
} }
} }
@ -180,9 +201,9 @@ template<class GeoField>
void Foam::tecplotWriter::getTecplotNames void Foam::tecplotWriter::getTecplotNames
( (
const PtrList<GeoField>& flds, const PtrList<GeoField>& flds,
const INTEGER4 loc, const int32_t loc,
string& varNames, string& varNames,
DynamicList<INTEGER4>& varLocation DynamicList<int32_t>& varLocation
) )
{ {
getTecplotNames<typename GeoField::value_type> getTecplotNames<typename GeoField::value_type>