Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
henry
2009-11-03 20:58:43 +00:00
13 changed files with 2723 additions and 14 deletions

View File

@ -0,0 +1,6 @@
#!/bin/sh
if [ "$TEC_360_2009" ]
then
wmake
fi

View File

@ -0,0 +1,5 @@
tecplotWriter.C
vtkMesh.C
foamToTecplot360.C
EXE = $(FOAM_APPBIN)/foamToTecplot360

View File

@ -0,0 +1,14 @@
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

View File

@ -0,0 +1,87 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View File

@ -0,0 +1,71 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View File

@ -0,0 +1,517 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 */
INTEGER4 NumFaceNodes = 2*pp.nEdges();
// All faces (=edges) have 2 nodes
List<INTEGER4> FaceNodeCounts(NumFaces, 2);
List<INTEGER4> FaceNodes(NumFaceNodes);
label nodeI = 0;
forAll(pp.edges(), edgeI)
{
edge e = pp.edges()[edgeI];
if (e[0] > e[1])
{
e = e.reverseEdge();
}
FaceNodes[nodeI++] = INTEGER4(e[0]+1);
FaceNodes[nodeI++] = INTEGER4(e[1]+1);
}
/* Define the right and left elements of each face.
*
* The last step for writing out the polyhedral data is to
* define the right and left neighboring elements for each
* face. The neighboring elements can be determined using the
* right-hand rule. For each face, place your right-hand along
* the face which your fingers pointing the direction of
* incrementing node numbers (i.e. from node 1 to node 2).
* Your right thumb will point towards the right element; the
* element on the other side of your hand is the left element.
*
* The number zero is used to indicate that there isn't an
* element on that side of the face.
*
* Because of the way we numbered the nodes and faces, the
* right element for every face is the element itself
* (element 1) and the left element is "no-neighboring element"
* (element 0).
*/
List<INTEGER4> FaceLeftElems(NumFaces);
List<INTEGER4> FaceRightElems(NumFaces);
const labelListList& edgeFaces = pp.edgeFaces();
forAll(edgeFaces, edgeI)
{
const labelList& eFaces = edgeFaces[edgeI];
if (eFaces.size() == 1)
{
FaceLeftElems[edgeI] = 0;
FaceRightElems[edgeI] = eFaces[0]+1;
}
else if (eFaces.size() == 2)
{
edge e = pp.edges()[edgeI];
if (e[0] > e[1])
{
e = e.reverseEdge();
}
const face& f0 = pp.localFaces()[eFaces[0]];
// The face that uses the vertices of e in increasing order
// is the left face.
label fp = findIndex(f0, e[0]);
bool f0IsLeft = (f0.nextLabel(fp) == e[1]);
if (f0IsLeft)
{
FaceLeftElems[edgeI] = eFaces[0]+1;
FaceRightElems[edgeI] = eFaces[1]+1;
}
else
{
FaceLeftElems[edgeI] = eFaces[1]+1;
FaceRightElems[edgeI] = eFaces[0]+1;
}
}
else
{
// non-manifold. Treat as if open.
FaceLeftElems[edgeI] = 0;
FaceRightElems[edgeI] = eFaces[0]+1;
}
}
/* Write the face map (created above) using TECPOLY112. */
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")
// << "Error in TECPOLY112." << exit(FatalError);
}
}
void Foam::tecplotWriter::writeEnd() const
{
Pout<< "writeEnd" << endl;
if (!TECEND112())
{
// FatalErrorIn("tecplotWriter::writeEnd() const")
// << "Error in TECEND112." << exit(FatalError);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,179 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::tecplotWriter
Description
Write binary tecplot files using tecio.
SourceFiles
tecplotWriter.C
tecplotWriterTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef tecplotWriter_H
#define tecplotWriter_H
#include "TECIO.h"
#include "Time.H"
#include "indirectPrimitivePatch.H"
#include "volFields.H"
#include "surfaceFields.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class fvMesh;
/*---------------------------------------------------------------------------*\
Class tecplotWriter Declaration
\*---------------------------------------------------------------------------*/
class tecplotWriter
{
const Time& runTime_;
public:
// Constructors
//- Construct from components
tecplotWriter(const Time&);
// Member Functions
void writeInit
(
const word& name,
const string& varNames,
const fileName&,
INTEGER4 tecplotFileType
) const;
//- Write mesh as polyhedral zone
void writePolyhedralZone
(
const word& zoneName,
const INTEGER4 strandID,
const fvMesh& mesh,
const List<INTEGER4>& varLocArray,
INTEGER4 nFaceNodes
) const;
//- Write surface as polygonal zone
void writePolygonalZone
(
const word& zoneName,
const INTEGER4 strandID,
const indirectPrimitivePatch& pp,
const List<INTEGER4>& varLocArray
) const;
//- Write unordered data (or rather 1D ordered)
void writeOrderedZone
(
const word& zoneName,
INTEGER4 strandID,
const label n,
const List<INTEGER4>& varLocArray
) const;
//- Write mesh
void writeConnectivity(const fvMesh& mesh) const;
//- Write surface
void writeConnectivity(const indirectPrimitivePatch& pp) const;
void writeEnd() const;
//- Write generic Field
template<class Type>
void writeField(const Field<Type>& fld) const;
//- Get either fvPatchField or patchInternalField
template<class Type>
tmp<Field<Type> > getPatchField
(
const bool nearCellValue,
const GeometricField<Type, fvPatchField, volMesh>& vfld,
const label patchI
) const;
//- Get mixed field: fvsPatchField for boundary faces and
// internalField for internal faces.
template<class Type>
tmp<Field<Type> > getFaceField
(
const GeometricField<Type, fvsPatchField, surfaceMesh>&,
const labelList& faceLabels
) const;
template<class GeoField>
static wordList getNames(const PtrList<GeoField>&);
template<class Type>
static void getTecplotNames
(
const wordList& names,
const INTEGER4 loc,
string& varNames,
DynamicList<INTEGER4>& varLocation
);
template<class GeoField>
static void getTecplotNames
(
const PtrList<GeoField>& flds,
const INTEGER4 loc,
string& varNames,
DynamicList<INTEGER4>& varLocation
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "tecplotWriterTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,199 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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"
extern "C"
{
#include "MASTER.h"
#include "GLOBAL.h"
}
#include "fvc.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::tecplotWriter::writeField(const Field<Type>& fld) const
{
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
{
scalarField cmptFld(fld.component(cmpt));
// Convert to float
Field<float> floats(cmptFld.size());
forAll(cmptFld, i)
{
floats[i] = float(cmptFld[i]);
}
INTEGER4 size = INTEGER4(floats.size());
INTEGER4 IsDouble = 0; //float
//Pout<< "Writing component:" << cmpt << " of size:" << size
// << " floats." << endl;
if (!TECDAT112(&size, floats.begin(), &IsDouble))
{
// FatalErrorIn("tecplotWriter::writeField(..) const")
// << "Error in TECDAT112." << exit(FatalError);
}
}
}
template<class Type>
Foam::tmp<Field<Type> > Foam::tecplotWriter::getPatchField
(
const bool nearCellValue,
const GeometricField<Type, fvPatchField, volMesh>& vfld,
const label patchI
) const
{
if (nearCellValue)
{
return vfld.boundaryField()[patchI].patchInternalField();
}
else
{
return vfld.boundaryField()[patchI];
}
}
template<class Type>
Foam::tmp<Field<Type> > Foam::tecplotWriter::getFaceField
(
const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld,
const labelList& faceLabels
) const
{
const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh();
tmp<Field<Type> > tfld(new Field<Type>(faceLabels.size()));
Field<Type>& fld = tfld();
forAll(faceLabels, i)
{
label faceI = faceLabels[i];
label patchI = patches.whichPatch(faceI);
if (patchI == -1)
{
fld[i] = sfld[faceI];
}
else
{
label localFaceI = faceI - patches[patchI].start();
fld[i] = sfld.boundaryField()[patchI][localFaceI];
}
}
return tfld;
}
template<class GeoField>
Foam::wordList Foam::tecplotWriter::getNames
(
const PtrList<GeoField>& flds
)
{
wordList names(flds.size());
forAll(flds, i)
{
names[i] = flds[i].name();
}
return names;
}
template<class Type>
void Foam::tecplotWriter::getTecplotNames
(
const wordList& names,
const INTEGER4 loc,
string& varNames,
DynamicList<INTEGER4>& varLocation
)
{
forAll(names, i)
{
if (!varNames.empty())
{
varNames += " ";
}
label nCmpts = pTraits<Type>::nComponents;
if (nCmpts == 1)
{
varNames += names[i];
varLocation.append(loc);
}
else
{
for
(
direction cmpt = 0;
cmpt < nCmpts;
cmpt++
)
{
string fldName =
(cmpt != 0 ? " " : string::null)
+ names[i]
+ "_"
+ pTraits<Type>::componentNames[cmpt];
varNames += fldName;
varLocation.append(loc);
}
}
}
}
template<class GeoField>
void Foam::tecplotWriter::getTecplotNames
(
const PtrList<GeoField>& flds,
const INTEGER4 loc,
string& varNames,
DynamicList<INTEGER4>& varLocation
)
{
getTecplotNames<typename GeoField::value_type>
(
getNames(flds),
loc,
varNames,
varLocation
);
}
// ************************************************************************* //

View File

@ -0,0 +1,84 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "vtkMesh.H"
#include "fvMeshSubset.H"
#include "Time.H"
#include "cellSet.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::vtkMesh::vtkMesh
(
fvMesh& baseMesh,
const word& setName
)
:
baseMesh_(baseMesh),
subsetter_(baseMesh),
setName_(setName)
{
if (setName.size())
{
// Read cellSet using whole mesh
cellSet currentSet(baseMesh_, setName_);
// Set current subset
subsetter_.setLargeCellSubset(currentSet);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate()
{
polyMesh::readUpdateState meshState = baseMesh_.readUpdate();
if (meshState != polyMesh::UNCHANGED)
{
// Note: since fvMeshSubset has no movePoints() functionality reconstruct
// the subset even if only movement.
// topoPtr_.clear();
if (setName_.size())
{
Info<< "Subsetting mesh based on cellSet " << setName_ << endl;
// Read cellSet using whole mesh
cellSet currentSet(baseMesh_, setName_);
subsetter_.setLargeCellSubset(currentSet);
}
}
return meshState;
}
// ************************************************************************* //

View File

@ -0,0 +1,179 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::vtkMesh
Description
Encapsulation of VTK mesh data. Holds mesh or meshsubset and
polyhedral-cell decomposition on it.
SourceFiles
vtkMesh.C
\*---------------------------------------------------------------------------*/
#ifndef vtkMesh_H
#define vtkMesh_H
#include "fvMeshSubset.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class Time;
/*---------------------------------------------------------------------------*\
Class vtkMesh Declaration
\*---------------------------------------------------------------------------*/
class vtkMesh
{
// Private data
//- Reference to mesh
fvMesh& baseMesh_;
//- Subsetting engine + sub-fvMesh
fvMeshSubset subsetter_;
//- Current cellSet (or empty)
const word setName_;
// //- Current decomposition of topology
// mutable autoPtr<vtkTopo> topoPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
vtkMesh(const vtkMesh&);
//- Disallow default bitwise assignment
void operator=(const vtkMesh&);
public:
// Constructors
//- Construct from components
vtkMesh(fvMesh& baseMesh, const word& setName = "");
// Member Functions
// Access
//- whole mesh
const fvMesh& baseMesh() const
{
return baseMesh_;
}
const fvMeshSubset& subsetter() const
{
return subsetter_;
}
//- Check if running subMesh
bool useSubMesh() const
{
return setName_.size();
}
// //- topology
// const vtkTopo& topo() const
// {
// if (topoPtr_.empty())
// {
// topoPtr_.reset(new vtkTopo(mesh()));
// }
// return topoPtr_();
// }
//- Access either mesh or submesh
const fvMesh& mesh() const
{
if (useSubMesh())
{
return subsetter_.subMesh();
}
else
{
return baseMesh_;
}
}
// //- Number of field cells
// label nFieldCells() const
// {
// return topo().vertLabels().size();
// }
//
// //- Number of field points
// label nFieldPoints() const
// {
// return mesh().nPoints() + topo().addPointCellLabels().size();
// }
// Edit
//- Read mesh
polyMesh::readUpdateState readUpdate();
//- Map volume field (does in fact do very little interpolation;
// just copied from fvMeshSubset)
template<class GeoField>
tmp<GeoField> interpolate(const GeoField& fld) const
{
if (useSubMesh())
{
tmp<GeoField> subFld = subsetter_.interpolate(fld);
subFld().rename(fld.name());
return subFld;
}
else
{
return fld;
}
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -83,12 +83,13 @@ Usage
Combine all patches into a single file Combine all patches into a single file
@param -excludePatches \<patchNames\>\n @param -excludePatches \<patchNames\>\n
Specify patches to exclude. For example, Specify patches (wildcards) to exclude. For example,
@verbatim @verbatim
-excludePatches "( inlet_1 inlet_2 )" -excludePatches '( inlet_1 inlet_2 "proc.*")'
@endverbatim @endverbatim
The quoting is required to avoid shell expansions and to pass the The quoting is required to avoid shell expansions and to pass the
information as a single argument. information as a single argument. The double quotes denote a regular
expression.
@param -useTimeName \n @param -useTimeName \n
use the time index in the VTK file name instead of the time index use the time index in the VTK file name instead of the time index
@ -140,6 +141,7 @@ Note
#include "faceZoneMesh.H" #include "faceZoneMesh.H"
#include "Cloud.H" #include "Cloud.H"
#include "passiveParticle.H" #include "passiveParticle.H"
#include "stringListOps.H"
#include "vtkMesh.H" #include "vtkMesh.H"
#include "readFields.H" #include "readFields.H"
@ -192,7 +194,7 @@ void print(Ostream& os, const wordList& flds)
labelList getSelectedPatches labelList getSelectedPatches
( (
const polyBoundaryMesh& patches, const polyBoundaryMesh& patches,
const HashSet<word>& excludePatches const List<wordRe>& excludePatches //HashSet<word>& excludePatches
) )
{ {
DynamicList<label> patchIDs(patches.size()); DynamicList<label> patchIDs(patches.size());
@ -205,14 +207,19 @@ labelList getSelectedPatches
if if
( (
isA<emptyPolyPatch>(pp) isType<emptyPolyPatch>(pp)
|| (Pstream::parRun() && isA<processorPolyPatch>(pp)) || (Pstream::parRun() && isType<processorPolyPatch>(pp))
) )
{ {
Info<< " discarding empty/processor patch " << patchI Info<< " discarding empty/processor patch " << patchI
<< " " << pp.name() << endl; << " " << pp.name() << endl;
} }
else if (!excludePatches.found(pp.name())) else if (findStrings(excludePatches, pp.name()))
{
Info<< " excluding patch " << patchI
<< " " << pp.name() << endl;
}
else
{ {
patchIDs.append(patchI); patchIDs.append(patchI);
Info<< " patch " << patchI << " " << pp.name() << endl; Info<< " patch " << patchI << " " << pp.name() << endl;
@ -224,6 +231,8 @@ labelList getSelectedPatches
// Main program: // Main program:
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -283,7 +292,7 @@ int main(int argc, char *argv[])
bool allPatches = args.optionFound("allPatches"); bool allPatches = args.optionFound("allPatches");
HashSet<word> excludePatches; List<wordRe> excludePatches;
if (args.optionFound("excludePatches")) if (args.optionFound("excludePatches"))
{ {
args.optionLookup("excludePatches")() >> excludePatches; args.optionLookup("excludePatches")() >> excludePatches;
@ -771,7 +780,7 @@ int main(int argc, char *argv[])
{ {
const polyPatch& pp = patches[patchI]; const polyPatch& pp = patches[patchI];
if (!excludePatches.found(pp.name())) if (!findStrings(excludePatches, pp.name()))
{ {
mkDir(fvPath/pp.name()); mkDir(fvPath/pp.name());

View File

@ -26,9 +26,6 @@ License
#include "edgeMesh.H" #include "edgeMesh.H"
#include "mergePoints.H" #include "mergePoints.H"
#include "StaticHashTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -204,7 +201,7 @@ void Foam::edgeMesh::mergePoints(const scalar mergeDist)
} }
// Compact using a hashtable and commutative hash of edge. // Compact using a hashtable and commutative hash of edge.
StaticHashTable<label, edge, Hash<edge> > edgeToLabel HashTable<label, edge, Hash<edge> > edgeToLabel
( (
2*edges_.size() 2*edges_.size()
); );
@ -228,7 +225,7 @@ void Foam::edgeMesh::mergePoints(const scalar mergeDist)
for for
( (
StaticHashTable<label, edge, Hash<edge> >::const_iterator iter = HashTable<label, edge, Hash<edge> >::const_iterator iter =
edgeToLabel.begin(); edgeToLabel.begin();
iter != edgeToLabel.end(); iter != edgeToLabel.end();
++iter ++iter