mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: ensightWriter: added ensight format to sampledSets
This commit is contained in:
@ -20,6 +20,7 @@ FoamFile
|
|||||||
// gnuplot
|
// gnuplot
|
||||||
// raw
|
// raw
|
||||||
// vtk
|
// vtk
|
||||||
|
// ensight
|
||||||
// csv
|
// csv
|
||||||
setFormat raw;
|
setFormat raw;
|
||||||
|
|
||||||
|
|||||||
@ -59,6 +59,8 @@ License
|
|||||||
#include "upwindFECCellToFaceStencilObject.H"
|
#include "upwindFECCellToFaceStencilObject.H"
|
||||||
|
|
||||||
#include "centredCFCFaceToCellStencilObject.H"
|
#include "centredCFCFaceToCellStencilObject.H"
|
||||||
|
#include "meshSearchMeshObject.H"
|
||||||
|
#include "meshSearchFACECENTRETETSMeshObject.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -99,6 +101,11 @@ void Foam::fvMesh::clearGeom()
|
|||||||
CentredFitData<quadraticLinearFitPolynomial>::Delete(*this);
|
CentredFitData<quadraticLinearFitPolynomial>::Delete(*this);
|
||||||
skewCorrectionVectors::Delete(*this);
|
skewCorrectionVectors::Delete(*this);
|
||||||
//quadraticFitSnGradData::Delete(*this);
|
//quadraticFitSnGradData::Delete(*this);
|
||||||
|
|
||||||
|
// Note: should be in polyMesh::clearGeom but meshSearch not in OpenFOAM
|
||||||
|
// library
|
||||||
|
meshSearchMeshObject::Delete(*this);
|
||||||
|
meshSearchFACECENTRETETSMeshObject::Delete(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -128,6 +135,11 @@ void Foam::fvMesh::clearAddressing()
|
|||||||
upwindFECCellToFaceStencilObject::Delete(*this);
|
upwindFECCellToFaceStencilObject::Delete(*this);
|
||||||
|
|
||||||
centredCFCFaceToCellStencilObject::Delete(*this);
|
centredCFCFaceToCellStencilObject::Delete(*this);
|
||||||
|
|
||||||
|
// Note: should be in polyMesh::clearGeom but meshSearch not in OpenFOAM
|
||||||
|
// library
|
||||||
|
meshSearchMeshObject::Delete(*this);
|
||||||
|
meshSearchFACECENTRETETSMeshObject::Delete(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -87,67 +87,22 @@ Foam::tmp<Foam::pointField> Foam::mappedPatchBase::facePoints
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const polyMesh& mesh = pp.boundaryMesh().mesh();
|
const polyMesh& mesh = pp.boundaryMesh().mesh();
|
||||||
const labelList& tetBasePts = mesh.tetBasePtIs();
|
|
||||||
const pointField& p = pp.points();
|
// Force construction of min-tet decomp
|
||||||
const pointField& cellCentres = mesh.cellCentres();
|
(void)mesh.tetBasePtIs();
|
||||||
const labelList& faceCells = pp.faceCells();
|
|
||||||
|
|
||||||
// Initialise to face-centre
|
// Initialise to face-centre
|
||||||
tmp<pointField> tfacePoints(new pointField(patch_.faceCentres()));
|
tmp<pointField> tfacePoints(new pointField(patch_.size()));
|
||||||
pointField& facePoints = tfacePoints();
|
pointField& facePoints = tfacePoints();
|
||||||
|
|
||||||
forAll(pp, faceI)
|
forAll(pp, faceI)
|
||||||
{
|
{
|
||||||
const face& f = pp[faceI];
|
facePoints[faceI] = facePoint
|
||||||
|
|
||||||
if (f.size() <= 3)
|
|
||||||
{
|
|
||||||
// Point already on tets of cell.
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Find intersection of (face-centre-decomposition) centre to
|
|
||||||
// cell-centre with face-diagonal-decomposition triangles.
|
|
||||||
const point& cc = cellCentres[faceCells[faceI]];
|
|
||||||
vector d = facePoints[faceI]-cc;
|
|
||||||
|
|
||||||
const label fp0 = tetBasePts[faceI];
|
|
||||||
const point& basePoint = p[f[fp0]];
|
|
||||||
|
|
||||||
//bool foundPoint = false;
|
|
||||||
|
|
||||||
label fp = f.fcIndex(fp0);
|
|
||||||
for (label i = 2; i < f.size(); i++)
|
|
||||||
{
|
|
||||||
const point& thisPoint = p[f[fp]];
|
|
||||||
label nextFp = f.fcIndex(fp);
|
|
||||||
const point& nextPoint = p[f[nextFp]];
|
|
||||||
|
|
||||||
const triPointRef tri(basePoint, thisPoint, nextPoint);
|
|
||||||
pointHit hitInfo = tri.intersection
|
|
||||||
(
|
(
|
||||||
cc,
|
mesh,
|
||||||
d,
|
pp.start()+faceI,
|
||||||
intersection::HALF_RAY
|
polyMesh::FACEDIAGTETS
|
||||||
);
|
).rawPoint();
|
||||||
|
|
||||||
if (hitInfo.hit() && hitInfo.distance() > 0)
|
|
||||||
{
|
|
||||||
facePoints[faceI] = hitInfo.hitPoint();
|
|
||||||
//foundPoint = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp = nextFp;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (!foundPoint)
|
|
||||||
//{
|
|
||||||
// Pout<< "cell:" << faceCells[faceI] << " at:" << cc
|
|
||||||
// << " face-centre:" << patch_.faceCentres()[faceI]
|
|
||||||
// << " did not find any intersection." << endl;
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tfacePoints;
|
return tfacePoints;
|
||||||
@ -572,11 +527,13 @@ void Foam::mappedPatchBase::calcMapping() const
|
|||||||
) << "Did not find " << nNotFound
|
) << "Did not find " << nNotFound
|
||||||
<< " out of " << sampleProcs.size() << " total samples."
|
<< " out of " << sampleProcs.size() << " total samples."
|
||||||
<< " Sampling these on owner cell centre instead." << endl
|
<< " Sampling these on owner cell centre instead." << endl
|
||||||
<< "patch_:" << patch_.name() << endl
|
<< "On patch " << patch_.name()
|
||||||
<< "sampleRegion_:" << sampleRegion_ << endl
|
<< " on region " << sampleRegion_
|
||||||
<< "mode_:" << sampleModeNames_[mode_] << endl
|
<< " in mode " << sampleModeNames_[mode_] << endl
|
||||||
<< "samplePatch_:" << samplePatch_ << endl
|
<< "whilst sampling patch " << samplePatch_ << endl
|
||||||
<< "offsetMode_:" << offsetModeNames_[offsetMode_] << endl;
|
<< " with offset mode " << offsetModeNames_[offsetMode_]
|
||||||
|
<< endl
|
||||||
|
<< "Suppressing further warnings from " << type() << endl;
|
||||||
|
|
||||||
hasWarned = true;
|
hasWarned = true;
|
||||||
}
|
}
|
||||||
@ -1137,6 +1094,87 @@ Foam::tmp<Foam::pointField> Foam::mappedPatchBase::samplePoints() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::pointIndexHit Foam::mappedPatchBase::facePoint
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const label faceI,
|
||||||
|
const polyMesh::cellRepresentation decompMode
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const point& fc = mesh.faceCentres()[faceI];
|
||||||
|
|
||||||
|
switch (decompMode)
|
||||||
|
{
|
||||||
|
case polyMesh::FACEPLANES:
|
||||||
|
case polyMesh::FACECENTRETETS:
|
||||||
|
{
|
||||||
|
// For both decompositions the face centre is guaranteed to be
|
||||||
|
// on the face
|
||||||
|
return pointIndexHit(true, fc, faceI);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case polyMesh::FACEDIAGTETS:
|
||||||
|
{
|
||||||
|
// Find the intersection of a ray from face centre to cell
|
||||||
|
// centre
|
||||||
|
// Find intersection of (face-centre-decomposition) centre to
|
||||||
|
// cell-centre with face-diagonal-decomposition triangles.
|
||||||
|
|
||||||
|
const pointField& p = mesh.points();
|
||||||
|
const face& f = mesh.faces()[faceI];
|
||||||
|
|
||||||
|
if (f.size() <= 3)
|
||||||
|
{
|
||||||
|
// Return centre of triangle.
|
||||||
|
return pointIndexHit(true, fc, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
label cellI = mesh.faceOwner()[faceI];
|
||||||
|
const point& cc = mesh.cellCentres()[cellI];
|
||||||
|
vector d = fc-cc;
|
||||||
|
|
||||||
|
const label fp0 = mesh.tetBasePtIs()[faceI];
|
||||||
|
const point& basePoint = p[f[fp0]];
|
||||||
|
|
||||||
|
label fp = f.fcIndex(fp0);
|
||||||
|
for (label i = 2; i < f.size(); i++)
|
||||||
|
{
|
||||||
|
const point& thisPoint = p[f[fp]];
|
||||||
|
label nextFp = f.fcIndex(fp);
|
||||||
|
const point& nextPoint = p[f[nextFp]];
|
||||||
|
|
||||||
|
const triPointRef tri(basePoint, thisPoint, nextPoint);
|
||||||
|
pointHit hitInfo = tri.intersection
|
||||||
|
(
|
||||||
|
cc,
|
||||||
|
d,
|
||||||
|
intersection::HALF_RAY
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hitInfo.hit() && hitInfo.distance() > 0)
|
||||||
|
{
|
||||||
|
return pointIndexHit(true, hitInfo.hitPoint(), i-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
fp = nextFp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall-back
|
||||||
|
return pointIndexHit(false, fc, -1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
FatalErrorIn("mappedPatchBase::facePoint()")
|
||||||
|
<< "problem" << abort(FatalError);
|
||||||
|
return pointIndexHit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::mappedPatchBase::write(Ostream& os) const
|
void Foam::mappedPatchBase::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
os.writeKeyword("sampleMode") << sampleModeNames_[mode_]
|
os.writeKeyword("sampleMode") << sampleModeNames_[mode_]
|
||||||
|
|||||||
@ -339,9 +339,24 @@ public:
|
|||||||
//- Get the patch on the region
|
//- Get the patch on the region
|
||||||
const polyPatch& samplePolyPatch() const;
|
const polyPatch& samplePolyPatch() const;
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
|
||||||
//- Get the sample points
|
//- Get the sample points
|
||||||
tmp<pointField> samplePoints() const;
|
tmp<pointField> samplePoints() const;
|
||||||
|
|
||||||
|
//- Get a point on the face given a face decomposition method:
|
||||||
|
// face-centre-tet : face centre. Returns index of face.
|
||||||
|
// face-planes : face centre. Returns index of face.
|
||||||
|
// face-diagonal : intersection of ray from cellcentre to
|
||||||
|
// facecentre with any of the triangles.
|
||||||
|
// Returns index (0..size-2) of triangle.
|
||||||
|
static pointIndexHit facePoint
|
||||||
|
(
|
||||||
|
const polyMesh&,
|
||||||
|
const label faceI,
|
||||||
|
const polyMesh::cellRepresentation
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Distribute
|
// Distribute
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ sampledSet/polyLine/polyLineSet.C
|
|||||||
sampledSet/face/faceOnlySet.C
|
sampledSet/face/faceOnlySet.C
|
||||||
sampledSet/midPoint/midPointSet.C
|
sampledSet/midPoint/midPointSet.C
|
||||||
sampledSet/midPointAndFace/midPointAndFaceSet.C
|
sampledSet/midPointAndFace/midPointAndFaceSet.C
|
||||||
|
/* sampledSet/patchSeed/patchSeedSet.C */
|
||||||
sampledSet/sampledSet/sampledSet.C
|
sampledSet/sampledSet/sampledSet.C
|
||||||
sampledSet/sampledSets/sampledSets.C
|
sampledSet/sampledSets/sampledSets.C
|
||||||
sampledSet/sampledSets/sampledSetsGrouping.C
|
sampledSet/sampledSets/sampledSetsGrouping.C
|
||||||
@ -21,6 +22,7 @@ sampledSet/uniform/uniformSet.C
|
|||||||
setWriters = sampledSet/writers
|
setWriters = sampledSet/writers
|
||||||
|
|
||||||
$(setWriters)/writers.C
|
$(setWriters)/writers.C
|
||||||
|
$(setWriters)/ensight/ensightSetWriterRunTime.C
|
||||||
$(setWriters)/gnuplot/gnuplotSetWriterRunTime.C
|
$(setWriters)/gnuplot/gnuplotSetWriterRunTime.C
|
||||||
$(setWriters)/jplot/jplotSetWriterRunTime.C
|
$(setWriters)/jplot/jplotSetWriterRunTime.C
|
||||||
$(setWriters)/raw/rawSetWriterRunTime.C
|
$(setWriters)/raw/rawSetWriterRunTime.C
|
||||||
|
|||||||
315
src/sampling/sampledSet/writers/ensight/ensightSetWriter.C
Normal file
315
src/sampling/sampledSet/writers/ensight/ensightSetWriter.C
Normal file
@ -0,0 +1,315 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "ensightSetWriter.H"
|
||||||
|
#include "coordSet.H"
|
||||||
|
#include "OFstream.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "IOmanip.H"
|
||||||
|
#include "foamVersion.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::ensightSetWriter<Type>::ensightSetWriter()
|
||||||
|
:
|
||||||
|
writer<Type>()
|
||||||
|
{}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::ensightSetWriter<Type>::~ensightSetWriter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::fileName Foam::ensightSetWriter<Type>::getFileName
|
||||||
|
(
|
||||||
|
const coordSet& points,
|
||||||
|
const wordList& valueSetNames
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
this->getBaseName(points, valueSetNames)
|
||||||
|
//+ '_'
|
||||||
|
//+ pTraits<Type>::typeName
|
||||||
|
+ ".case";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::ensightSetWriter<Type>::write
|
||||||
|
(
|
||||||
|
const coordSet& points,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<const Field<Type>*>& valueSets,
|
||||||
|
Ostream& os
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const fileName base(os.name().lessExt());
|
||||||
|
const fileName meshFile(base + ".mesh");
|
||||||
|
|
||||||
|
// Write .case file
|
||||||
|
os << "FORMAT" << nl
|
||||||
|
<< "type: ensight gold" << nl
|
||||||
|
<< nl
|
||||||
|
<< "GEOMETRY" << nl
|
||||||
|
<< "model: 1 " << meshFile.name().c_str() << nl
|
||||||
|
<< nl
|
||||||
|
<< "VARIABLE"
|
||||||
|
<< nl;
|
||||||
|
forAll(valueSetNames, setI)
|
||||||
|
{
|
||||||
|
fileName dataFile(base + ".***." + valueSetNames[setI]);
|
||||||
|
|
||||||
|
os.setf(ios_base::left);
|
||||||
|
os << pTraits<Type>::typeName
|
||||||
|
<< " per node: 1 "
|
||||||
|
<< setw(15) << valueSetNames[setI]
|
||||||
|
<< " " << dataFile.name().c_str()
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
os << nl
|
||||||
|
<< "TIME" << nl
|
||||||
|
<< "time set: 1" << nl
|
||||||
|
<< "number of steps: 1" << nl
|
||||||
|
<< "filename start number: 0" << nl
|
||||||
|
<< "filename increment: 1" << nl
|
||||||
|
<< "time values:" << nl
|
||||||
|
<< "0.00000e+00" << nl;
|
||||||
|
|
||||||
|
// Write .mesh file
|
||||||
|
{
|
||||||
|
string desc = string("written by OpenFOAM-") + Foam::FOAMversion;
|
||||||
|
OFstream os(meshFile);
|
||||||
|
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||||
|
os.precision(5);
|
||||||
|
|
||||||
|
os << "EnSight Geometry File" << nl
|
||||||
|
<< desc.c_str() << nl
|
||||||
|
<< "node id assign" << nl
|
||||||
|
<< "element id assign" << nl
|
||||||
|
<< "part" << nl
|
||||||
|
<< setw(10) << 1 << nl
|
||||||
|
<< "internalMesh" << nl
|
||||||
|
<< "coordinates" << nl
|
||||||
|
<< setw(10) << points.size() << nl;
|
||||||
|
|
||||||
|
for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++)
|
||||||
|
{
|
||||||
|
forAll(points, pointI)
|
||||||
|
{
|
||||||
|
const scalar comp = points[pointI][cmpt];
|
||||||
|
if (mag(comp) >= scalar(floatScalarVSMALL))
|
||||||
|
{
|
||||||
|
os << setw(12) << comp << nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os << setw(12) << scalar(0) << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os << "point" << nl
|
||||||
|
<< setw(10) << points.size() << nl;
|
||||||
|
forAll(points, pointI)
|
||||||
|
{
|
||||||
|
os << setw(10) << pointI+1 << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write data files
|
||||||
|
forAll(valueSetNames, setI)
|
||||||
|
{
|
||||||
|
fileName dataFile(base + ".000." + valueSetNames[setI]);
|
||||||
|
OFstream os(dataFile);
|
||||||
|
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||||
|
os.precision(5);
|
||||||
|
{
|
||||||
|
os << pTraits<Type>::typeName << nl
|
||||||
|
<< "part" << nl
|
||||||
|
<< setw(10) << 1 << nl
|
||||||
|
<< "coordinates" << nl;
|
||||||
|
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
|
||||||
|
{
|
||||||
|
const scalarField fld = valueSets[setI]->component(cmpt);
|
||||||
|
forAll(fld, i)
|
||||||
|
{
|
||||||
|
if (mag(fld[i]) >= scalar(floatScalarVSMALL))
|
||||||
|
{
|
||||||
|
os << setw(12) << fld[i] << nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os << setw(12) << scalar(0) << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::ensightSetWriter<Type>::write
|
||||||
|
(
|
||||||
|
const bool writeTracks,
|
||||||
|
const PtrList<coordSet>& tracks,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<List<Field<Type> > >& valueSets,
|
||||||
|
Ostream& os
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const fileName base(os.name().lessExt());
|
||||||
|
const fileName meshFile(base + ".mesh");
|
||||||
|
|
||||||
|
// Write .case file
|
||||||
|
os << "FORMAT" << nl
|
||||||
|
<< "type: ensight gold" << nl
|
||||||
|
<< nl
|
||||||
|
<< "GEOMETRY" << nl
|
||||||
|
<< "model: 1 " << meshFile.name().c_str() << nl
|
||||||
|
<< nl
|
||||||
|
<< "VARIABLE"
|
||||||
|
<< nl;
|
||||||
|
forAll(valueSetNames, setI)
|
||||||
|
{
|
||||||
|
fileName dataFile(base + ".***." + valueSetNames[setI]);
|
||||||
|
|
||||||
|
os.setf(ios_base::left);
|
||||||
|
os << pTraits<Type>::typeName
|
||||||
|
<< " per node: 1 "
|
||||||
|
<< setw(15) << valueSetNames[setI]
|
||||||
|
<< " " << dataFile.name().c_str()
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
os << nl
|
||||||
|
<< "TIME" << nl
|
||||||
|
<< "time set: 1" << nl
|
||||||
|
<< "number of steps: 1" << nl
|
||||||
|
<< "filename start number: 0" << nl
|
||||||
|
<< "filename increment: 1" << nl
|
||||||
|
<< "time values:" << nl
|
||||||
|
<< "0.00000e+00" << nl;
|
||||||
|
|
||||||
|
// Write .mesh file
|
||||||
|
{
|
||||||
|
string desc = string("written by OpenFOAM-") + Foam::FOAMversion;
|
||||||
|
OFstream os(meshFile);
|
||||||
|
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||||
|
os.precision(5);
|
||||||
|
os << "EnSight Geometry File" << nl
|
||||||
|
<< desc.c_str() << nl
|
||||||
|
<< "node id assign" << nl
|
||||||
|
<< "element id assign" << nl;
|
||||||
|
|
||||||
|
forAll(tracks, trackI)
|
||||||
|
{
|
||||||
|
const coordSet& points = tracks[trackI];
|
||||||
|
|
||||||
|
os << "part" << nl
|
||||||
|
<< setw(10) << trackI+1 << nl
|
||||||
|
<< "internalMesh" << nl
|
||||||
|
<< "coordinates" << nl
|
||||||
|
<< setw(10) << points.size() << nl;
|
||||||
|
|
||||||
|
for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++)
|
||||||
|
{
|
||||||
|
forAll(points, pointI)
|
||||||
|
{
|
||||||
|
const scalar comp = points[pointI][cmpt];
|
||||||
|
if (mag(comp) >= scalar(floatScalarVSMALL))
|
||||||
|
{
|
||||||
|
os << setw(12) << comp << nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os << setw(12) << scalar(0) << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeTracks)
|
||||||
|
{
|
||||||
|
os << "bar2" << nl
|
||||||
|
<< setw(10) << points.size()-1 << nl;
|
||||||
|
for (label i = 0; i < points.size()-1; i++)
|
||||||
|
{
|
||||||
|
os << setw(10) << i+1
|
||||||
|
<< setw(10) << i+2
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Write data files
|
||||||
|
forAll(valueSetNames, setI)
|
||||||
|
{
|
||||||
|
fileName dataFile(base + ".000." + valueSetNames[setI]);
|
||||||
|
OFstream os(dataFile);
|
||||||
|
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||||
|
os.precision(5);
|
||||||
|
{
|
||||||
|
os << pTraits<Type>::typeName << nl;
|
||||||
|
|
||||||
|
const List<Field<Type> >& fieldVals = valueSets[setI];
|
||||||
|
forAll(fieldVals, trackI)
|
||||||
|
{
|
||||||
|
os << "part" << nl
|
||||||
|
<< setw(10) << trackI+1 << nl
|
||||||
|
<< "coordinates" << nl;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
direction cmpt = 0;
|
||||||
|
cmpt < pTraits<Type>::nComponents;
|
||||||
|
cmpt++
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const scalarField fld = fieldVals[trackI].component(cmpt);
|
||||||
|
forAll(fld, i)
|
||||||
|
{
|
||||||
|
if (mag(fld[i]) >= scalar(floatScalarVSMALL))
|
||||||
|
{
|
||||||
|
os << setw(12) << fld[i] << nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os << setw(12) << scalar(0) << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
111
src/sampling/sampledSet/writers/ensight/ensightSetWriter.H
Normal file
111
src/sampling/sampledSet/writers/ensight/ensightSetWriter.H
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::ensightSetWriter
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
ensightSetWriter.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef ensightSetWriter_H
|
||||||
|
#define ensightSetWriter_H
|
||||||
|
|
||||||
|
#include "writer.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class ensightSetWriter Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
class ensightSetWriter
|
||||||
|
:
|
||||||
|
public writer<Type>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("ensight");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
ensightSetWriter();
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~ensightSetWriter();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual fileName getFileName
|
||||||
|
(
|
||||||
|
const coordSet&,
|
||||||
|
const wordList&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const coordSet&,
|
||||||
|
const wordList&,
|
||||||
|
const List<const Field<Type>*>&,
|
||||||
|
Ostream&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const bool writeTracks,
|
||||||
|
const PtrList<coordSet>&,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<List<Field<Type> > >&,
|
||||||
|
Ostream&
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "ensightSetWriter.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "ensightSetWriter.H"
|
||||||
|
#include "writers.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
makeSetWriters(ensightSetWriter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -14,7 +14,7 @@ streamLines
|
|||||||
outputControl outputTime;
|
outputControl outputTime;
|
||||||
// outputInterval 10;
|
// outputInterval 10;
|
||||||
|
|
||||||
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot;
|
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot; //csv; //ensight;
|
||||||
|
|
||||||
// Velocity field to use for tracking.
|
// Velocity field to use for tracking.
|
||||||
U U;
|
U U;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ streamLines
|
|||||||
outputControl outputTime;
|
outputControl outputTime;
|
||||||
// outputInterval 10;
|
// outputInterval 10;
|
||||||
|
|
||||||
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot;
|
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot; //csv; //ensight;
|
||||||
|
|
||||||
// Velocity field to use for tracking.
|
// Velocity field to use for tracking.
|
||||||
UName U;
|
UName U;
|
||||||
|
|||||||
@ -58,7 +58,7 @@ functions
|
|||||||
outputControl outputTime;
|
outputControl outputTime;
|
||||||
// outputInterval 10;
|
// outputInterval 10;
|
||||||
|
|
||||||
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot;
|
setFormat vtk; //gnuplot;//xmgr;//raw;//jplot;//csv;//ensight;
|
||||||
|
|
||||||
// Velocity field to use for tracking.
|
// Velocity field to use for tracking.
|
||||||
UName U;
|
UName U;
|
||||||
|
|||||||
@ -58,7 +58,7 @@ functions
|
|||||||
outputControl outputTime;
|
outputControl outputTime;
|
||||||
// outputInterval 10;
|
// outputInterval 10;
|
||||||
|
|
||||||
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot;
|
setFormat vtk; //gnuplot;//xmgr;//raw;//jplot;//csv;//ensight;
|
||||||
|
|
||||||
// Velocity field to use for tracking.
|
// Velocity field to use for tracking.
|
||||||
UName U;
|
UName U;
|
||||||
|
|||||||
Reference in New Issue
Block a user