Commit ba1422df authored by mattijs's avatar mattijs
Browse files

Tecplot360 writer

parent 6930293d
tecplotWriter.C
vtkMesh.C
foamToTecplot360.C
EXE = $(FOAM_APPBIN)/foamToTecplot360
EXE_INC = \
-I$(TEC_360_2009)/include \
/* -I../tecio/tecsrc/lnInclude/ */ \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
$(TEC_360_2009)/lib/tecio64.a \
/* -L$(FOAM_USER_LIBBIN) -ltecio */ \
-llagrangian \
-lfiniteVolume \
-lmeshTools
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "readFields.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class GeoField>
void readFields
(
const vtkMesh& vMesh,
const typename GeoField::Mesh& mesh,
const IOobjectList& objects,
const HashSet<word>& selectedFields,
PtrList<GeoField>& fields
)
{
// Search list of objects for volScalarFields
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
// Construct the vol scalar fields
label nFields = fields.size();
fields.setSize(nFields + fieldObjects.size());
for
(
IOobjectList::iterator iter = fieldObjects.begin();
iter != fieldObjects.end();
++iter
)
{
if (selectedFields.empty() || selectedFields.found(iter()->name()))
{
fields.set
(
nFields,
vMesh.interpolate
(
GeoField
(
*iter(),
mesh
)
)
);
nFields++;
}
}
fields.setSize(nFields);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
Foam::readFields
Description
SourceFiles
readFields.C
\*---------------------------------------------------------------------------*/
#ifndef readFields_H
#define readFields_H
#include "fvMesh.H"
#include "PtrList.H"
#include "IOobjectList.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Read the fields and optionally subset and put on the pointer list
template<class GeoField>
void readFields
(
const vtkMesh& vMesh,
const typename GeoField::Mesh& mesh,
const IOobjectList& objects,
const HashSet<word>& selectedFields,
PtrList<GeoField>& fields
);
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "readFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "tecplotWriter.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::tecplotWriter::tecplotWriter(const Time& runTime)
:
runTime_(runTime)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::tecplotWriter::writeInit
(
const word& name,
const string& varNames,
const fileName& fName,
INTEGER4 tecplotFileType
) const
{
Pout<< endl
<< endl
<< "Name:" << name
<< " varNames:" << varNames
<< " to file:" << fName
<< " of type:" << tecplotFileType
<< endl;
INTEGER4 IsDouble = 0; //float
INTEGER4 Debug = 0; //nodebug
if
(
!TECINI112
(
const_cast<char*>(name.c_str()), /* Data Set Title */
const_cast<char*>(varNames.c_str()), /* Variable List */
const_cast<char*>(fName.c_str()), /* File Name */
const_cast<char*>(runTime_.path().c_str()), /* Scratch Directory */
&tecplotFileType,
&Debug,
&IsDouble
)
)
{
// FatalErrorIn("tecplotWriter::writeInit(..) const")
// << "Error in TECINI112." << exit(FatalError);
}
}
void Foam::tecplotWriter::writePolyhedralZone
(
const word& zoneName,
const INTEGER4 strandID,
const fvMesh& mesh,
const List<INTEGER4>& varLocArray,
INTEGER4 nFaceNodes
) const
{
/* Call TECZNE112 */
INTEGER4 NumNodes = mesh.nPoints(); /* number of unique nodes */
INTEGER4 NumElems = mesh.nCells(); /* number of elements */
INTEGER4 NumFaces = mesh.nFaces(); /* number of unique faces */
INTEGER4 ICellMax = 0; /* Not Used, set to zero */
INTEGER4 JCellMax = 0; /* Not Used, set to zero */
INTEGER4 KCellMax = 0; /* Not Used, set to zero */
double SolTime = runTime_.value(); /* solution time */
INTEGER4 StrandID = 1; /* static zone */
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
//<< " varLocArray:" << varLocArray
<< " solTime:" << SolTime
<< endl;
INTEGER4 *PassiveVarArray = NULL;
INTEGER4 *VarShareArray = NULL;
INTEGER4 ShrConn = 0;
INTEGER4 NumBConns = 0; /* No Boundary Connections */
INTEGER4 NumBItems = 0; /* No Boundary Items */
INTEGER4 ZoneType = ZoneType_FEPolyhedron;
if
(
!TECZNE112
(
const_cast<char*>(zoneName.c_str()),
&ZoneType,
&NumNodes,
&NumElems,
&NumFaces,
&ICellMax,
&JCellMax,
&KCellMax,
&SolTime,
&StrandID,
&ParentZone,
&IsBlock,
&NFConns,
&FNMode,
&nFaceNodes,
&NumBConns,
&NumBItems,
PassiveVarArray,
const_cast<INTEGER4*>(varLocArray.begin()),
VarShareArray,
&ShrConn
)
)
{
// FatalErrorIn("tecplotWriter::writePolyhedralZone(..) const")
// << "Error in TECZNE112." << exit(FatalError);
}
}
void Foam::tecplotWriter::writePolygonalZone
(
const word& zoneName,
INTEGER4 strandID,
const indirectPrimitivePatch& pp,
const List<INTEGER4>& varLocArray
) const
{
/* Call TECZNE112 */
INTEGER4 NumNodes = pp.nPoints(); /* number of unique nodes */
INTEGER4 NumElems = pp.size(); /* number of elements */
INTEGER4 NumFaces = pp.nEdges(); /* number of unique faces */
INTEGER4 ICellMax = 0; /* Not Used, set to zero */
INTEGER4 JCellMax = 0; /* Not Used, set to zero */
INTEGER4 KCellMax = 0; /* Not Used, set to zero */
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
*/
INTEGER4 NumFaceNodes = 2*pp.nEdges();
Pout<< "zoneName:" << zoneName
<< " strandID:" << strandID
//<< " varLocArray:" << varLocArray
<< " solTime:" << SolTime
<< endl;
INTEGER4 *PassiveVarArray = NULL;
INTEGER4 *VarShareArray = NULL;
INTEGER4 ShrConn = 0;
INTEGER4 NumBConns = 0; /* No Boundary Connections */
INTEGER4 NumBItems = 0; /* No Boundary Items */
INTEGER4 ZoneType = ZoneType_FEPolygon;
if
(
!TECZNE112
(
const_cast<char*>(zoneName.c_str()),
&ZoneType,
&NumNodes,
&NumElems,
&NumFaces,
&ICellMax,
&JCellMax,
&KCellMax,
&SolTime,
&strandID,
&ParentZone,
&IsBlock,
&NFConns,
&FNMode,
&NumFaceNodes,
&NumBConns,
&NumBItems,
PassiveVarArray,
const_cast<INTEGER4*>(varLocArray.begin()),
VarShareArray,
&ShrConn
)
)
{
// FatalErrorIn("tecplotWriter::writePolygonalZone(..) const")
// << "Error in TECZNE112." << exit(FatalError);
}
}
void Foam::tecplotWriter::writeOrderedZone
(
const word& zoneName,
INTEGER4 strandID,
const label n,
const List<INTEGER4>& varLocArray
) const
{
/* Call TECZNE112 */
INTEGER4 IMax = n; /* number of unique nodes */
INTEGER4 JMax = 1; /* number of elements */
INTEGER4 KMax = 1; /* number of unique faces */
INTEGER4 ICellMax = 0; /* Not Used, set to zero */
INTEGER4 JCellMax = 0; /* Not Used, set to zero */
INTEGER4 KCellMax = 0; /* Not Used, set to zero */
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
*/
INTEGER4 NumFaceNodes = 1;
INTEGER4 NumBConns = 1; /* No Boundary Connections */
INTEGER4 NumBItems = 1; /* No Boundary Items */
Pout<< "zoneName:" << zoneName
<< " strandID:" << strandID
//<< " varLocArray:" << varLocArray
<< " solTime:" << SolTime
<< endl;
INTEGER4 *PassiveVarArray = NULL;
INTEGER4 *VarShareArray = NULL;
INTEGER4 ShrConn = 0;
INTEGER4 ZoneType = ZoneType_Ordered;
if
(
!TECZNE112
(
const_cast<char*>(zoneName.c_str()),
&ZoneType,
&IMax,
&JMax,
&KMax,
&ICellMax,
&JCellMax,
&KCellMax,
&SolTime,
&strandID,
&ParentZone,
&IsBlock,
&NFConns,
&FNMode,
&NumFaceNodes,
&NumBConns,
&NumBItems,
PassiveVarArray,
const_cast<INTEGER4*>(varLocArray.begin()),
VarShareArray,
&ShrConn
)
)
{
// FatalErrorIn("tecplotWriter::writePolygonalZone(..) const")
// << "Error in TECZNE112." << exit(FatalError);
}
}
void Foam::tecplotWriter::writeConnectivity(const fvMesh& mesh) const
{
List<INTEGER4> FaceNodeCounts(mesh.nFaces());
forAll(mesh.faces(), faceI)
{
const face& f = mesh.faces()[faceI];
FaceNodeCounts[faceI] = INTEGER4(f.size());
}
INTEGER4 nFaceNodes = 0;
forAll(mesh.faces(), faceI)
{
nFaceNodes += mesh.faces()[faceI].size();
}
List<INTEGER4> FaceNodes(nFaceNodes);
label nodeI = 0;
forAll(mesh.faces(), faceI)
{
const face& f = mesh.faces()[faceI];
forAll(f, fp)
{
FaceNodes[nodeI++] = INTEGER4(f[fp]+1);
}
}
List<INTEGER4> FaceLeftElems(mesh.nFaces());
forAll(mesh.faceOwner(), faceI)
{
FaceLeftElems[faceI] = mesh.faceOwner()[faceI]+1;
}
List<INTEGER4> FaceRightElems(mesh.nFaces());
forAll(mesh.faceNeighbour(), faceI)
{
FaceRightElems[faceI] = mesh.faceNeighbour()[faceI]+1;
}
for
(
label faceI = mesh.nInternalFaces();
faceI < mesh.nFaces();
faceI++
)
{
FaceRightElems[faceI] = 0;
}
if
(
!TECPOLY112
(
FaceNodeCounts.begin(), /* The face node counts array */
FaceNodes.begin(), /* The face nodes array */
FaceLeftElems.begin(), /* The left elements array */
FaceRightElems.begin(), /* The right elements array */
NULL, /* No boundary connection counts */
NULL, /* No boundary connection elements */
NULL /* No boundary connection zones */
)
)
{
// FatalErrorIn("tecplotWriter::writeConnectivity(const fvMesh&) const")
// << "Error in TECPOLY112." << exit(FatalError);
}
}
void Foam::tecplotWriter::writeConnectivity
(
const indirectPrimitivePatch& pp
) const
{
INTEGER4 NumFaces = pp.nEdges(); /* number of unique faces */