Creation of OpenFOAM-dev repository 15/04/2008

This commit is contained in:
OpenFOAM-admin
2008-04-15 18:56:58 +01:00
commit 3170c7c0c9
9896 changed files with 4016171 additions and 0 deletions

View File

@ -0,0 +1,18 @@
sampleSurface.C
surfaces/surface/surface.C
surfaces/constantIsoSurface/constantIsoSurface.C
surfaces/interpolatedIsoSurface/interpolatedIsoSurface.C
surfaces/constantPatch/constantPatch.C
surfaces/interpolatedPatch/interpolatedPatch.C
surfaces/constantPlane/constantPlane.C
surfaces/interpolatedPlane/interpolatedPlane.C
surfaceWriters/surfaceWriter/surfaceWriters.C
surfaceWriters/foamFile/foamFileWriters.C
surfaceWriters/dx/dxWriters.C
surfaceWriters/raw/rawWriters.C
surfaceWriters/vtk/vtkWriters.C
surfaceWriters/stl/stlWriters.C
EXE = $(FOAM_APPBIN)/sampleSurface

View File

@ -0,0 +1,19 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-Isurfaces/surface \
-Isurfaces/constantPlane \
-Isurfaces/constantPatch \
-Isurfaces/isoSurface \
-IsurfaceWriters/surfaceWriter \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lsampling \
-ltriSurface \
-llagrangian \

View File

@ -0,0 +1,105 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "fieldsCache.H"
#include "volPointInterpolation.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::fieldsCache<Type>::fieldsCache()
:
HashPtrTable<GeometricField<Type, fvPatchField, volMesh> >(),
pointFields_(),
interpolators_()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
const Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh>&
Foam::fieldsCache<Type>::pointField
(
const word& name,
const volPointInterpolation& pInterp
) const
{
if (!pointFields_.found(name))
{
const GeometricField<Type, fvPatchField, volMesh>& vField =
*this->operator[](name);
tmp<GeometricField<Type, pointPatchField, pointMesh> > tptField =
pInterp.interpolate(vField);
GeometricField<Type, pointPatchField, pointMesh>* ptFieldPtr =
tptField.ptr();
pointFields_.insert(name, ptFieldPtr);
return *ptFieldPtr;
}
else
{
return *pointFields_[name];
}
}
template<class Type>
const Foam::interpolation<Type>& Foam::fieldsCache<Type>::interpolator
(
const word& name,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
if (!interpolators_.found(name))
{
const GeometricField<Type, fvPatchField, volMesh>& vField =
*this->operator[](name);
interpolation<Type>* interpolatorPtr =
interpolation<Type>::New
(
interpolationSchemes,
pInterp,
vField
).ptr();
interpolators_.insert(name, interpolatorPtr);
return *interpolatorPtr;
}
else
{
return *interpolators_[name];
}
}
// ************************************************************************* //

View File

@ -0,0 +1,109 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::fieldsCache
Description
SourceFiles
fieldsCache.C
\*---------------------------------------------------------------------------*/
#ifndef fieldsCache_H
#define fieldsCache_H
#include "volFields.H"
#include "pointFields.H"
#include "HashPtrTable.H"
#include "interpolation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fieldsCache Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class fieldsCache
:
public HashPtrTable<GeometricField<Type, fvPatchField, volMesh> >
{
private:
//- Cached pointFields
mutable HashPtrTable<GeometricField<Type, pointPatchField, pointMesh> >
pointFields_;
//- Cached interpolators
mutable HashPtrTable<interpolation<Type> > interpolators_;
public:
// Constructors
//- Construct null
fieldsCache();
// Member Functions
//- Get pointField of named field
const GeometricField<Type, pointPatchField, pointMesh>& pointField
(
const word&,
const volPointInterpolation& pInterp
) const;
//- Get interpolator for named field
const interpolation<Type>& interpolator
(
const word&,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "fieldsCache.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,842 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "argList.H"
#include "OSspecific.H"
#include "meshSearch.H"
#include "interpolation.H"
#include "volPointInterpolation.H"
#include "cuttingPlane.H"
#include "OFstream.H"
#include "Pstream.H"
#include "ListListOps.H"
#include "Cloud.H"
#include "passiveParticle.H"
#include "mergePoints.H"
#include "fieldsCache.H"
#include "surface.H"
#include "surfaceWriter.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Used to offset faces in Pstream::combineOffset
namespace Foam
{
template <>
class offsetOp<face>
{
public:
face operator()
(
const face& x,
const label offset
) const
{
face result(x.size());
forAll(x, xI)
{
result[xI] = x[xI] + offset;
}
return result;
}
};
}
void mergePoints
(
const polyMesh& mesh,
const scalar mergeTol,
List<pointField>& allPoints,
List<faceList>& allFaces,
labelListList& allOldToNew
)
{
const boundBox& bb = mesh.globalData().bb();
scalar mergeDim = mergeTol * mag(bb.max() - bb.min());
Info<< nl << "Merging all points within " << mergeDim << " meter." << endl;
allOldToNew.setSize(allPoints.size());
forAll(allPoints, surfaceI)
{
pointField newPoints;
labelList oldToNew;
bool hasMerged = mergePoints
(
allPoints[surfaceI],
mergeDim,
false, // verbosity
oldToNew,
newPoints
);
if (hasMerged)
{
// Copy points
allPoints[surfaceI].transfer(newPoints);
// Store point mapping
allOldToNew[surfaceI].transfer(oldToNew);
// Relabel faces.
faceList& faces = allFaces[surfaceI];
forAll(faces, faceI)
{
inplaceRenumber(allOldToNew[surfaceI], faces[faceI]);
}
Info<< "For surface " << surfaceI << " merged from "
<< allOldToNew[surfaceI].size() << " points down to "
<< allPoints[surfaceI].size() << " points." << endl;
}
}
}
template<class T>
void renumberData
(
const labelList& oldToNewPoints,
const label newSize,
Field<T>& values
)
{
if (oldToNewPoints.size() == values.size())
{
inplaceReorder(oldToNewPoints, values);
values.setSize(newSize);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
# include "addTimeOptions.H"
# include "setRootCase.H"
# include "createTime.H"
// Get times list
instantList Times = runTime.times();
// set startTime and endTime depending on -time and -latestTime options
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
# include "createMesh.H"
//
// Hack: initialize Cloud to initialize the processor table so from
// now on we can use cloud (in meshSearch) on single processors only.
//
Cloud<passiveParticle> dummyCloud(mesh, IDLList<passiveParticle>());
//
// Read control dictionary
//
IOdictionary sampleDict
(
IOobject
(
"sampleSurfaceDict",
runTime.system(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
const word interpolationScheme(sampleDict.lookup("interpolationScheme"));
const wordList fieldNames = sampleDict.lookup("fields");
//
// Construct writers
//
word writeFormat(sampleDict.lookup("surfaceFormat"));
autoPtr<surfaceWriter<scalar> > scalarFormatter
(
surfaceWriter<scalar>::New(writeFormat)
);
autoPtr<surfaceWriter<vector> > vectorFormatter
(
surfaceWriter<vector>::New(writeFormat)
);
autoPtr<surfaceWriter<sphericalTensor> > sphericalTensorFormatter
(
surfaceWriter<sphericalTensor>::New(writeFormat)
);
autoPtr<surfaceWriter<symmTensor> > symmTensorFormatter
(
surfaceWriter<symmTensor>::New(writeFormat)
);
autoPtr<surfaceWriter<tensor> > tensorFormatter
(
surfaceWriter<tensor>::New(writeFormat)
);
//
// Construct interpolation dictionary (same interpolation for all fields)
//
dictionary interpolationSchemes;
forAll(fieldNames, fieldI)
{
interpolationSchemes.add
(
fieldNames[fieldI],
interpolationScheme
);
}
fileName samplePath;
if (Pstream::parRun())
{
samplePath = runTime.path()/".."/"sampleSurfaces";
}
else
{
samplePath = runTime.path()/"sampleSurfaces";
}
if (Pstream::master() && exists(samplePath))
{
Info<< "Deleting sampleSurfaces/ directory" << endl << endl;
rmDir(samplePath);
}
// Set up interpolation
autoPtr<pointMesh> pMeshPtr(new pointMesh(mesh));
autoPtr<volPointInterpolation> pInterpPtr
(
new volPointInterpolation(mesh, pMeshPtr())
);
// Set up mesh searching
meshSearch searchEngine(mesh, true);
// Create sample surfaces
PtrList<surface> surfaces
(
sampleDict.lookup("surfaces"),
surface::iNew(mesh, searchEngine)
);
Info<< endl;
fileName oldPointsDir("constant");
for (label i=startTime; i<endTime; i++)
{
runTime.setTime(Times[i], i);
Info<< "Time = " << runTime.timeName() << endl;
//
// Handle geometry/topology changes
//
polyMesh::readUpdateState state = mesh.readUpdate();
bool meshChanged = false;
if
(
state == polyMesh::POINTS_MOVED
|| state == polyMesh::TOPO_CHANGE
)
{
// Geometry and topology changes
searchEngine.correct();
pMeshPtr.reset(new pointMesh(mesh));
pInterpPtr.reset(new volPointInterpolation(mesh, pMeshPtr()));
meshChanged = true;
}
if (Pstream::master())
{
Info<< "Creating directory " << samplePath/runTime.timeName()
<< endl << endl;
mkDir(samplePath/runTime.timeName());
}
//
// Cache used fields and interpolators
//
fieldsCache<scalar> scalarCache;
fieldsCache<vector> vectorCache;
fieldsCache<sphericalTensor> sphericalTensorCache;
fieldsCache<symmTensor> symmTensorCache;
fieldsCache<tensor> tensorCache;
forAll(fieldNames, fieldI)
{
const word& fieldName = fieldNames[fieldI];
IOobject fieldHeader
(
fieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
if (fieldHeader.headerOk())
{
if
(
fieldHeader.headerClassName() == volScalarField::typeName
)
{
Info<< "Loading " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volScalarField* fieldPtr
(
new volScalarField
(
fieldHeader,
mesh
)
);
scalarCache.insert(fieldName, fieldPtr);
}
else if
(
fieldHeader.headerClassName() == volVectorField::typeName
)
{
Info<< "Loading " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volVectorField* fieldPtr
(
new volVectorField
(
fieldHeader,
mesh
)
);
vectorCache.insert(fieldName, fieldPtr);
}
else if
(
fieldHeader.headerClassName()
== volSphericalTensorField::typeName
)
{
Info<< "Loading " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volSphericalTensorField* fieldPtr
(
new volSphericalTensorField
(
fieldHeader,
mesh
)
);
sphericalTensorCache.insert(fieldName, fieldPtr);
}
else if
(
fieldHeader.headerClassName()
== volSymmTensorField::typeName
)
{
Info<< "Loading " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volSymmTensorField* fieldPtr
(
new volSymmTensorField
(
fieldHeader,
mesh
)
);
symmTensorCache.insert(fieldName, fieldPtr);
}
else if
(
fieldHeader.headerClassName() == volTensorField::typeName
)
{
Info<< "Loading " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volTensorField* fieldPtr
(
new volTensorField
(
fieldHeader,
mesh
)
);
tensorCache.insert(fieldName, fieldPtr);
}
}
}
//
// Now we have fields cached and know whether mesh has changed.
// Update surfaces with this information.
//
forAll(surfaces, surfaceI)
{
surfaces[surfaceI].correct
(
meshChanged,
pInterpPtr,
interpolationSchemes,
scalarCache
);
}
//
// Combine surfaces onto master (bug:should not be redone for static
// meshes)
//
List<pointField> allPoints(surfaces.size());
List<faceList> allFaces(surfaces.size());
forAll(surfaces, surfaceI)
{
// Collect points from all processors
List<pointField> gatheredPoints(Pstream::nProcs());
gatheredPoints[Pstream::myProcNo()] = surfaces[surfaceI].points();
Pstream::gatherList(gatheredPoints);
if (Pstream::master())
{
allPoints[surfaceI] = ListListOps::combine<pointField>
(
gatheredPoints,
accessOp<pointField>()
);
}
// Collect faces from all processors and renumber using sizes of
// gathered points
List<faceList> gatheredFaces(Pstream::nProcs());
gatheredFaces[Pstream::myProcNo()] = surfaces[surfaceI].faces();
Pstream::gatherList(gatheredFaces);
if (Pstream::master())
{
allFaces[surfaceI] = static_cast<const faceList&>
(
ListListOps::combineOffset<faceList>
(
gatheredFaces,
ListListOps::subSizes
(
gatheredPoints,
accessOp<pointField>()
),
accessOp<faceList>(),
offsetOp<face>()
)
);
}
}
// Merge close points (1E-10 of mesh bounding box)
labelListList allOldToNewPoints;
mergePoints(mesh, 1E-10, allPoints, allFaces, allOldToNewPoints);
//
// Do actual interpolation
//
forAll(fieldNames, fieldI)
{
Info<< endl;
const word& fieldName = fieldNames[fieldI];
// Scalar fields
if (scalarCache.found(fieldName))
{
Info<< "Sampling volScalarField " << fieldName << endl << endl;
forAll(surfaces, surfaceI)
{
const surface& s = surfaces[surfaceI];
scalarField values
(
s.interpolate
(
fieldName,
scalarCache,
pInterpPtr,
interpolationSchemes
)
);
// Collect values from all processors
List<scalarField> gatheredValues(Pstream::nProcs());
gatheredValues[Pstream::myProcNo()] = values;
Pstream::gatherList(gatheredValues);
if (Pstream::master())
{
// Combine values into single field
scalarField allValues
(
ListListOps::combine<scalarField>
(
gatheredValues,
accessOp<scalarField>()
)
);
// Renumber (point data) to correspond to merged points
renumberData
(
allOldToNewPoints[surfaceI],
allPoints[surfaceI].size(),
allValues
);
// Write to time directory under sampleSurfaces/
scalarFormatter().write
(
samplePath,
runTime.timeName(),
s.name(),
allPoints[surfaceI],
allFaces[surfaceI],
fieldName,
allValues
);
}
}
}
// Vector fields
else if (vectorCache.found(fieldName))
{
Info<< "Sampling volVectorField " << fieldName << endl << endl;
forAll(surfaces, surfaceI)
{
const surface& s = surfaces[surfaceI];
vectorField values
(
s.interpolate
(
fieldName,
vectorCache,
pInterpPtr,
interpolationSchemes
)
);
// Collect values from all processors
List<vectorField> gatheredValues(Pstream::nProcs());
gatheredValues[Pstream::myProcNo()] = values;
Pstream::gatherList(gatheredValues);
if (Pstream::master())
{
vectorField allValues
(
ListListOps::combine<vectorField>
(
gatheredValues,
accessOp<vectorField>()
)
);
// Renumber (point data) to correspond to merged points
renumberData
(
allOldToNewPoints[surfaceI],
allPoints[surfaceI].size(),
allValues
);
// Write to time directory under sampleSurfaces/
vectorFormatter().write
(
samplePath,
runTime.timeName(),
s.name(),
allPoints[surfaceI],
allFaces[surfaceI],
fieldName,
allValues
);
}
}
}
// SphericalTensor fields
else if (sphericalTensorCache.found(fieldName))
{
Info<< "Sampling volSphericalTensorField "
<< fieldName << endl << endl;
forAll(surfaces, surfaceI)
{
const surface& s = surfaces[surfaceI];
sphericalTensorField values
(
s.interpolate
(
fieldName,
sphericalTensorCache,
pInterpPtr,
interpolationSchemes
)
);
// Collect values from all processors
List<sphericalTensorField>
gatheredValues(Pstream::nProcs());
gatheredValues[Pstream::myProcNo()] = values;
Pstream::gatherList(gatheredValues);
if (Pstream::master())
{
sphericalTensorField allValues
(
ListListOps::combine<sphericalTensorField>
(
gatheredValues,
accessOp<sphericalTensorField>()
)
);
// Renumber (point data) to correspond to merged points
renumberData
(
allOldToNewPoints[surfaceI],
allPoints[surfaceI].size(),
allValues
);
// Write to time directory under sampleSurfaces/
sphericalTensorFormatter().write
(
samplePath,
runTime.timeName(),
s.name(),
allPoints[surfaceI],
allFaces[surfaceI],
fieldName,
allValues
);
}
}
}
// SymmTensor fields
else if (symmTensorCache.found(fieldName))
{
Info<< "Sampling volSymmTensorField "
<< fieldName << endl << endl;
forAll(surfaces, surfaceI)
{
const surface& s = surfaces[surfaceI];
symmTensorField values
(
s.interpolate
(
fieldName,
symmTensorCache,
pInterpPtr,
interpolationSchemes
)
);
// Collect values from all processors
List<symmTensorField> gatheredValues(Pstream::nProcs());
gatheredValues[Pstream::myProcNo()] = values;
Pstream::gatherList(gatheredValues);
if (Pstream::master())
{
symmTensorField allValues
(
ListListOps::combine<symmTensorField>
(
gatheredValues,
accessOp<symmTensorField>()
)
);
// Renumber (point data) to correspond to merged points
renumberData
(
allOldToNewPoints[surfaceI],
allPoints[surfaceI].size(),
allValues
);
// Write to time directory under sampleSurfaces/
symmTensorFormatter().write
(
samplePath,
runTime.timeName(),
s.name(),
allPoints[surfaceI],
allFaces[surfaceI],
fieldName,
allValues
);
}
}
}
// Tensor fields
else if (tensorCache.found(fieldName))
{
Info<< "Sampling volTensorField " << fieldName << endl << endl;
forAll(surfaces, surfaceI)
{
const surface& s = surfaces[surfaceI];
tensorField values
(
s.interpolate
(
fieldName,
tensorCache,
pInterpPtr,
interpolationSchemes
)
);
// Collect values from all processors
List<tensorField> gatheredValues(Pstream::nProcs());
gatheredValues[Pstream::myProcNo()] = values;
Pstream::gatherList(gatheredValues);
if (Pstream::master())
{
tensorField allValues
(
ListListOps::combine<tensorField>
(
gatheredValues,
accessOp<tensorField>()
)
);
// Renumber (point data) to correspond to merged points
renumberData
(
allOldToNewPoints[surfaceI],
allPoints[surfaceI].size(),
allValues
);
// Write to time directory under sampleSurfaces/
tensorFormatter().write
(
samplePath,
runTime.timeName(),
s.name(),
allPoints[surfaceI],
allFaces[surfaceI],
fieldName,
allValues
);
}
}
}
}
Info<< endl;
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,117 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "/home/penfold/mattijs/foam/mattijs2.1/run/icoFoam";
case "cavity";
instance "system";
local "";
class dictionary;
object sampleDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Output format. Choice of
// foamFile : separate points, faces and values file
// dx : DX scalar or vector format
// vtk : VTK ascii format
// raw : x y z value format for use with e.g. gnuplot 'splot'.
// stl : ascii stl. Does not contain values!
surfaceFormat vtk;
// interpolationScheme : choice of
// cell : use cell-centre value only; constant over cells
// cellPoint : use cell-centre and vertex values
// cellPointFace : use cell-centre, vertex and face values.
// 1] vertex values determined from neighbouring cell-centre values
// 2] face values determined using the current face interpolation scheme
// for the field (linear, gamma, etc.)
interpolationScheme cellPointFace;
// sampling definition: choice of
// interpolatedPlane : values on plane defined by point, normal.
// One value per vertex using above
// interpolationScheme
// constantPlane : values on plane defined by point, normal.
// One (cell centre) value per triangle
// constantPatch : values on patch. One (face centre) value
// per triangle.
surfaces
(
constantPlane
{
name constantPlane;
basePoint (0.05 0.05 0.005);
normalVector (0.1 0.1 1);
// Optional: whether to leave as faces or triangulate (=default)
triangulate false;
}
interpolatedPlane
{
name interpolatedPlane;
basePoint (0.05 0.05 0.005);
normalVector (0.1 0.1 1);
triangulate false;
}
constantPatch
{
name movingWall_constant;
patchName movingWall;
triangulate false;
}
interpolatedPatch
{
name movingWall_interpolated;
patchName movingWall;
triangulate false;
}
constantIsoSurface
{
name constantIso;
field p;
value 0;
}
interpolatedIsoSurface
{
name someIso;
field p;
value 0;
}
);
// Fields to sample. Note: need to include isoSurface fields.
fields
(
p
U
);
// ************************************************************************* //

View File

@ -0,0 +1,325 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "dx.H"
#include "fileName.H"
#include "OFstream.H"
#include "faceList.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::dx<Type>::writeDXGeometry
(
const pointField& points,
const faceList& faces,
Ostream& os
) const
{
// Write vertex coordinates
os << "# The irregular positions" << nl
<< "object 1 class array type float rank 1 shape 3 items "
<< points.size() << " data follows" << nl;
forAll(points, pointI)
{
const point& pt = points[pointI];
os << float(pt.x()) << ' ' << float(pt.y()) << ' ' << float(pt.z())
<< nl;
}
os << nl;
// Write triangles
os << "# The irregular connections (triangles)" << nl
<< "object 2 class array type int rank 1 shape 3 items "
<< faces.size() << " data follows" << nl;
forAll(faces, faceI)
{
const face& f = faces[faceI];
if (f.size() != 3)
{
FatalErrorIn
(
"writeDXGeometry(Ostream&, const pointField&, const faceList&)"
) << "Face " << faceI << " vertices " << f
<< " is not a triangle."
<< exit(FatalError);
}
os << f[0] << ' ' << f[1] << ' ' << f[2] << nl;
}
os << "attribute \"element type\" string \"triangles\"" << nl
<< "attribute \"ref\" string \"positions\"" << nl << nl;
}
// Write scalarField in DX format
template<class Type>
void Foam::dx<Type>::writeDXData
(
const pointField& points,
const scalarField& values,
Ostream& os
) const
{
// Write data
os << "object 3 class array type float rank 0 items "
<< values.size()
<< " data follows" << nl;
forAll(values, elemI)
{
os << float(values[elemI]) << nl;
}
if (values.size() == points.size())
{
os << nl << "attribute \"dep\" string \"positions\""
<< nl << nl;
}
else
{
os << nl << "attribute \"dep\" string \"connections\""
<< nl << nl;
}
}
// Write vectorField in DX format
template<class Type>
void Foam::dx<Type>::writeDXData
(
const pointField& points,
const vectorField& values,
Ostream& os
) const
{
// Write data
os << "object 3 class array type float rank 1 shape 3 items "
<< values.size()
<< " data follows" << nl;
forAll(values, elemI)
{
os << float(values[elemI].x()) << ' '
<< float(values[elemI].y()) << ' '
<< float(values[elemI].z()) << nl;
}
if (values.size() == points.size())
{
os << nl << "attribute \"dep\" string \"positions\""
<< nl << nl;
}
else
{
os << nl << "attribute \"dep\" string \"connections\""
<< nl << nl;
}
}
// Write sphericalTensorField in DX format
template<class Type>
void Foam::dx<Type>::writeDXData
(
const pointField& points,
const sphericalTensorField& values,
Ostream& os
) const
{
// Write data
os << "object 3 class array type float rank 0 items "
<< values.size()
<< " data follows" << nl;
forAll(values, elemI)
{
os << float(values[elemI][0]) << nl;
}
if (values.size() == points.size())
{
os << nl << "attribute \"dep\" string \"positions\""
<< nl << nl;
}
else
{
os << nl << "attribute \"dep\" string \"connections\""
<< nl << nl;
}
}
// Write symmTensorField in DX format
template<class Type>
void Foam::dx<Type>::writeDXData
(
const pointField& points,
const symmTensorField& values,
Ostream& os
) const
{
// Write data
os << "object 3 class array type float rank 2 shape 3 items "
<< values.size()
<< " data follows" << nl;
forAll(values, elemI)
{
const symmTensor& t = values[elemI];
os << float(t.xx()) << ' ' << float(t.xy()) << ' ' << float(t.xz())
<< float(t.xy()) << ' ' << float(t.yy()) << ' ' << float(t.yz())
<< float(t.xz()) << ' ' << float(t.yz()) << ' ' << float(t.zz())
<< nl;
}
if (values.size() == points.size())
{
os << nl << "attribute \"dep\" string \"positions\""
<< nl << nl;
}
else
{
os << nl << "attribute \"dep\" string \"connections\""
<< nl << nl;
}
}
// Write tensorField in DX format
template<class Type>
void Foam::dx<Type>::writeDXData
(
const pointField& points,
const tensorField& values,
Ostream& os
) const
{
// Write data
os << "object 3 class array type float rank 2 shape 3 items "
<< values.size()
<< " data follows" << nl;
forAll(values, elemI)
{
const tensor& t = values[elemI];
os << float(t.xx()) << ' ' << float(t.xy()) << ' ' << float(t.xz())
<< float(t.yx()) << ' ' << float(t.yy()) << ' ' << float(t.yz())
<< float(t.zx()) << ' ' << float(t.zy()) << ' ' << float(t.zz())
<< nl;
}
if (values.size() == points.size())
{
os << nl << "attribute \"dep\" string \"positions\""
<< nl << nl;
}
else
{
os << nl << "attribute \"dep\" string \"connections\""
<< nl << nl;
}
}
// Write trailer in DX format
template<class Type>
void Foam::dx<Type>::writeDXTrailer(Ostream& os) const
{
os << "# the field, with three components: \"positions\","
<< " \"connections\", and \"data\"" << nl
<< "object \"irregular positions irregular "
<< "connections\" class field"
<< nl
<< "component \"positions\" value 1" << nl
<< "component \"connections\" value 2" << nl
<< "component \"data\" value 3" << nl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::dx<Type>::dx()
:
surfaceWriter<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::dx<Type>::~dx()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::dx<Type>::write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const fileName& fieldName,
const Field<Type>& values
) const
{
fileName surfaceDir(samplePath/timeDir);
if (!exists(surfaceDir))
{
mkDir(surfaceDir);
}
fileName planeFName(surfaceDir/fieldName + '_' + surfaceName + ".dx");
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
OFstream dxFile(planeFName);
writeDXGeometry(points, faces, dxFile);
writeDXData(points, values, dxFile);
writeDXTrailer(dxFile);
dxFile << "end" << nl;
}
// ************************************************************************* //

View File

@ -0,0 +1,150 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::dx
Description
SourceFiles
dx.C
\*---------------------------------------------------------------------------*/
#ifndef dx_H
#define dx_H
#include "surfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class dx Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class dx
:
public surfaceWriter<Type>
{
// Private Member Functions
void writeDXGeometry
(
const pointField& points,
const faceList& faces,
Ostream& os
) const;
void writeDXData
(
const pointField& points,
const scalarField& values,
Ostream& os
) const;
void writeDXData
(
const pointField& points,
const vectorField& values,
Ostream& os
) const;
void writeDXData
(
const pointField& points,
const sphericalTensorField& values,
Ostream& os
) const;
void writeDXData
(
const pointField& points,
const symmTensorField& values,
Ostream& os
) const;
void writeDXData
(
const pointField& points,
const tensorField& values,
Ostream& os
) const;
void writeDXTrailer(Ostream& os) const;
public:
//- Runtime type information
TypeName("dx");
// Constructors
//- Construct null
dx();
// Destructor
virtual ~dx();
// Member Functions
// Write
//- Writes single surface to file.
virtual void write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const fileName& fieldName,
const Field<Type>& values
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "dx.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "dxWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(dx);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::dxWriters
Description
SourceFiles
dxWriters.C
\*---------------------------------------------------------------------------*/
#ifndef dxWriters_H
#define dxWriters_H
#include "dx.H"
#include "surfaceWriters.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef dx<scalar> dxScalarWriter;
typedef dx<vector> dxVectorWriter;
typedef dx<sphericalTensor> dxSphericalTensorWriter;
typedef dx<symmTensor> dxSymmTensorWriter;
typedef dx<tensor> dxTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,99 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "foamFile.H"
#include "fileName.H"
#include "OFstream.H"
#include "faceList.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::foamFile<Type>::foamFile()
:
surfaceWriter<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::foamFile<Type>::~foamFile()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::foamFile<Type>::write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const fileName& fieldName,
const Field<Type>& values
) const
{
fileName planeFName(samplePath/timeDir/surfaceName);
if (!exists(planeFName))
{
mkDir(planeFName);
}
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
// Points
OFstream pointsFile(planeFName/"points");
pointsFile << points;
// Faces
OFstream facesFile(planeFName/"faces");
facesFile << faces;
// Values to separate directory (e.g. "scalarField/p")
fileName foamName(pTraits<Type>::typeName);
fileName valuesDir(planeFName / (foamName + Field<Type>::typeName));
if (!exists(valuesDir))
{
mkDir(valuesDir);
}
OFstream valuesFile(valuesDir/fieldName);
valuesFile << values;
}
// ************************************************************************* //

View File

@ -0,0 +1,104 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::foamFile
Description
SourceFiles
foamFile.C
\*---------------------------------------------------------------------------*/
#ifndef foamFile_H
#define foamFile_H
#include "surfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class foamFile Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class foamFile
:
public surfaceWriter<Type>
{
public:
//- Runtime type information
TypeName("foamFile");
// Constructors
//- Construct null
foamFile();
// Destructor
virtual ~foamFile();
// Member Functions
// Write
//- Writes single surface to file.
virtual void write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const fileName& fieldName,
const Field<Type>& values
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "foamFile.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "foamFileWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(foamFile);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::foamFileWriters
Description
SourceFiles
foamFileWriters.C
\*---------------------------------------------------------------------------*/
#ifndef foamFileWriters_H
#define foamFileWriters_H
#include "foamFile.H"
#include "surfaceWriters.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef foamFile<scalar> foamFileScalarWriter;
typedef foamFile<vector> foamFileVectorWriter;
typedef foamFile<sphericalTensor> foamFileSphericalTensorWriter;
typedef foamFile<symmTensor> foamFileSymmTensorWriter;
typedef foamFile<tensor> foamFileTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,359 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "raw.H"
#include "fileName.H"
#include "OFstream.H"
#include "faceList.H"
#include "OSspecific.H"
#include "IOmanip.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::raw<Type>::writeGeometry
(
const pointField& points,
const label& pointI,
Ostream& os
) const
{
const point& pt = points[pointI];
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << ' ';
}
template<class Type>
void Foam::raw<Type>::writeGeometry
(
const pointField& points,
const faceList& faces,
const label& faceI,
Ostream& os
) const
{
const point& ct = faces[faceI].centre(points);
os << ct.x() << ' ' << ct.y() << ' ' << ct.z() << ' ';
}
// Write scalarField in raw format
template<class Type>
void Foam::raw<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const scalarField& values,
Ostream& os
) const
{
// header
os << "# " << fieldName;
if (values.size() == points.size())
{
os << " POINT_DATA " << values.size()
<< nl;
}
else
{
os << " FACE_DATA " << values.size()
<< nl;
}
os << "# x y z " << fieldName
<< endl;
// Write data
forAll(values, elemI)
{
if (values.size() == points.size())
{
writeGeometry(points, elemI, os);
}
else
{
writeGeometry(points, faces, elemI, os);
}
os << values[elemI] << endl;
}
os << nl;
}
// Write vectorField in raw format
template<class Type>
void Foam::raw<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const vectorField& values,
Ostream& os
) const
{
// header
os << "# " << fieldName;
if (values.size() == points.size())
{
os << " POINT_DATA " << values.size()
<< nl;
}
else
{
os << " FACE_DATA " << values.size()
<< nl;
}
os << "# x y z "
<< fieldName << "_x "
<< fieldName << "_y "
<< fieldName << "_z "
<< endl;
// Write data
forAll(values, elemI)
{
const vector& v = values[elemI];
if (values.size() == points.size())
{
writeGeometry(points, elemI, os);
}
else
{
writeGeometry(points, faces, elemI, os);
}
os << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
}
}
// Write sphericalTensorField in raw format
template<class Type>
void Foam::raw<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const sphericalTensorField& values,
Ostream& os
) const
{
// header
os << "# " << fieldName;
if (values.size() == points.size())
{
os << " POINT_DATA " << values.size()
<< nl;
}
else
{
os << " FACE_DATA " << values.size()
<< nl;
}
os << "# ii ";
os << fieldName << "_ii" << endl;
// Write data
forAll(values, elemI)
{
const sphericalTensor& v = values[elemI];
if (values.size() == points.size())
{
writeGeometry(points, elemI, os);
}
else
{
writeGeometry(points, faces, elemI, os);
}
os << v[0] << nl;
}
}
// Write symmTensorField in raw format
template<class Type>
void Foam::raw<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const symmTensorField& values,
Ostream& os
) const
{
// header
os << "# " << fieldName;
if (values.size() == points.size())
{
os << " POINT_DATA " << values.size()
<< nl;
}
else
{
os << " FACE_DATA " << values.size()
<< nl;
}
os << "# xx xy xz yy yz ";
for(int i=0; i<6; i++)
{
os << fieldName << "_" << i << " ";
}
os << endl;
// Write data
forAll(values, elemI)
{
const symmTensor& v = values[elemI];
if (values.size() == points.size())
{
writeGeometry(points, elemI, os);
}
else
{
writeGeometry(points, faces, elemI, os);
}
os << v[0] << ' ' << v[1] << ' ' << v[2]
<< v[3] << ' ' << v[4] << ' ' << v[5]
<< nl;
}
}
// Write tensorField in raw format
template<class Type>
void Foam::raw<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const tensorField& values,
Ostream& os
) const
{
// header
os << "# " << fieldName;
if (values.size() == points.size())
{
os << " POINT_DATA " << values.size()
<< nl;
}
else
{
os << " FACE_DATA " << values.size()
<< nl;
}
os << "# xx xy xz yx yy yz zx zy zz";
for(int i=0; i<9; i++)
{
os << fieldName << "_" << i << " ";
}
os << endl;
// Write data
forAll(values, elemI)
{
const tensor& v = values[elemI];
if (values.size() == points.size())
{
writeGeometry(points, elemI, os);
}
else
{
writeGeometry(points, faces, elemI, os);
}
os << v[0] << ' ' << v[1] << ' ' << v[2]
<< v[3] << ' ' << v[4] << ' ' << v[5]
<< v[6] << ' ' << v[7] << ' ' << v[8] << nl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::raw<Type>::raw()
:
surfaceWriter<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::raw<Type>::~raw()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::raw<Type>::write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const fileName& fieldName,
const Field<Type>& values
) const
{
fileName surfaceDir(samplePath/timeDir);
if (!exists(surfaceDir))
{
mkDir(surfaceDir);
}
fileName planeFName(surfaceDir/fieldName + '_' + surfaceName + ".raw");
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
OFstream rawFile(planeFName);
writeData(fieldName, points, faces, values, rawFile);
}
// ************************************************************************* //

View File

@ -0,0 +1,166 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::raw
Description
SourceFiles
raw.C
\*---------------------------------------------------------------------------*/
#ifndef raw_H
#define raw_H
#include "surfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class raw Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class raw
:
public surfaceWriter<Type>
{
// Private Member Functions
void writeGeometry
(
const pointField& points,
const label& pointI,
Ostream& os
) const;
void writeGeometry
(
const pointField& points,
const faceList& faces,
const label& faceI,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const scalarField& values,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const vectorField& values,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const sphericalTensorField& values,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const symmTensorField& values,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const tensorField& values,
Ostream& os
) const;
public:
//- Runtime type information
TypeName("raw");
// Constructors
//- Construct null
raw();
// Destructor
virtual ~raw();
// Member Functions
// Write
//- Writes single surface to file.
virtual void write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const fileName& fieldName,
const Field<Type>& values
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "raw.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "rawWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(raw);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::rawWriters
Description
SourceFiles
rawWriters.C
\*---------------------------------------------------------------------------*/
#ifndef rawWriters_H
#define rawWriters_H
#include "raw.H"
#include "surfaceWriters.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef raw<scalar> rawScalarWriter;
typedef raw<vector> rawVectorWriter;
typedef raw<sphericalTensor> rawSphericalTensorWriter;
typedef raw<symmTensor> rawSymmTensorWriter;
typedef raw<tensor> rawTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,112 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "stl.H"
#include "fileName.H"
#include "OFstream.H"
#include "faceList.H"
#include "OSspecific.H"
#include "triSurface.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::stl<Type>::stl()
:
surfaceWriter<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::stl<Type>::~stl()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::stl<Type>::write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const fileName& fieldName,
const Field<Type>& values
) const
{
fileName surfaceDir(samplePath/timeDir);
if (!exists(surfaceDir))
{
mkDir(surfaceDir);
}
fileName planeFName(surfaceDir/fieldName + '_' + surfaceName + ".stl");
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
// Convert faces to triangles.
DynamicList<labelledTri> tris(faces.size());
forAll(faces, i)
{
const face& f = faces[i];
faceList triFaces(f.nTriangles(points));
label nTris = 0;
f.triangles(points, nTris, triFaces);
forAll(triFaces, triI)
{
const face& tri = triFaces[triI];
tris.append(labelledTri(tri[0], tri[1], tri[2], 0));
}
}
triSurface
(
tris.shrink(),
geometricSurfacePatchList
(
1,
geometricSurfacePatch
(
"patch", // geometricType
string::validate<word>(fieldName), // fieldName
0 // index
)
),
points
).write(planeFName);
}
// ************************************************************************* //

View File

@ -0,0 +1,104 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::stl
Description
SourceFiles
stl.C
\*---------------------------------------------------------------------------*/
#ifndef stl_H
#define stl_H
#include "surfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class stl Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class stl
:
public surfaceWriter<Type>
{
public:
//- Runtime type information
TypeName("stl");
// Constructors
//- Construct null
stl();
// Destructor
virtual ~stl();
// Member Functions
// Write
//- Writes single surface to file.
virtual void write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const fileName& fieldName,
const Field<Type>& values
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "stl.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "stlWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(stl);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::stlWriters
Description
SourceFiles
stlWriters.C
\*---------------------------------------------------------------------------*/
#ifndef stlWriters_H
#define stlWriters_H
#include "stl.H"
#include "surfaceWriters.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef stl<scalar> stlScalarWriter;
typedef stl<vector> stlVectorWriter;
typedef stl<sphericalTensor> stlSphericalTensorWriter;
typedef stl<symmTensor> stlSymmTensorWriter;
typedef stl<tensor> stlTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,78 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "surfaceWriter.H"
#include "HashTable.H"
#include "word.H"
#include "fileName.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
autoPtr<surfaceWriter<Type> > surfaceWriter<Type>::New(const word& writeType)
{
typename wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_
->find(writeType);
if (cstrIter == wordConstructorTablePtr_->end())
{
FatalErrorIn
(
"surfaceWriter::New(const word&)"
) << "Unknown write type " << writeType
<< endl << endl
<< "Valid write types : " << endl
<< wordConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<surfaceWriter<Type> >(cstrIter()());
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
surfaceWriter<Type>::surfaceWriter()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
surfaceWriter<Type>::~surfaceWriter()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,158 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::surfaceWriter
Description
SourceFiles
surfaceWriter.C
\*---------------------------------------------------------------------------*/
#ifndef surfaceWriter_H
#define surfaceWriter_H
#include "Field.H"
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "autoPtr.H"
#include "pointField.H"
#include "faceList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class surfaceWriter Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class surfaceWriter
{
public:
//- Runtime type information
TypeName("surfaceWriter");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
surfaceWriter,
word,
(),
()
);
// Selectors
//- Return a reference to the selected surfaceWriter
static autoPtr<surfaceWriter> New(const word& writeFormat);
// Constructors
//- Construct null
surfaceWriter();
// Destructor
virtual ~surfaceWriter();
// Member Functions
//- Writes single surface to file. Either one value per vertex or
// one value per face (detected by values.size()==faces.size())
virtual void write
(
const fileName& samplePath, // <root>/<case>/sampleSurfaces
const fileName& timeDir, // time directory
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const fileName& fieldName, // name of field
const Field<Type>& values
) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "surfaceWriter.C"
#endif
// Only used internally
#define makeTypeWritersTypeName(type) \
\
defineNamedTemplateTypeNameAndDebug(type, 0);
// Used externally sometimes
#define makeWritersTypeName(typeWriter) \
\
makeTypeWritersTypeName(typeWriter##ScalarWriter); \
makeTypeWritersTypeName(typeWriter##VectorWriter); \
makeTypeWritersTypeName(typeWriter##SphericalTensorWriter); \
makeTypeWritersTypeName(typeWriter##SymmTensorWriter); \
makeTypeWritersTypeName(typeWriter##TensorWriter);
// Define type info for single template instantiation (e.g. vector)
#define makeWriterTypes(WriterType, type) \
\
defineNamedTemplateTypeNameAndDebug(type, 0); \
\
addToRunTimeSelectionTable \
( \
WriterType, type, word \
);
// Define type info info for scalar, vector etc. instantiations
#define makeWriters(typeWriter) \
\
makeWriterTypes(scalarWriter, typeWriter##ScalarWriter); \
makeWriterTypes(vectorWriter, typeWriter##VectorWriter); \
makeWriterTypes(sphericalTensorWriter, typeWriter##SphericalTensorWriter); \
makeWriterTypes(symmTensorWriter, typeWriter##SymmTensorWriter);\
makeWriterTypes(tensorWriter, typeWriter##TensorWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "surfaceWriters.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineNamedTemplateTypeNameAndDebug(scalarWriter, 0);
defineTemplateRunTimeSelectionTable(scalarWriter, word);
defineNamedTemplateTypeNameAndDebug(vectorWriter, 0);
defineTemplateRunTimeSelectionTable(vectorWriter, word);
defineNamedTemplateTypeNameAndDebug(sphericalTensorWriter, 0);
defineTemplateRunTimeSelectionTable(sphericalTensorWriter, word);
defineNamedTemplateTypeNameAndDebug(symmTensorWriter, 0);
defineTemplateRunTimeSelectionTable(symmTensorWriter, word);
defineNamedTemplateTypeNameAndDebug(tensorWriter, 0);
defineTemplateRunTimeSelectionTable(tensorWriter, word);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,59 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::surfaceWriter
Description
\*---------------------------------------------------------------------------*/
#ifndef surfaceWriters_H
#define surfaceWriters_H
#include "surfaceWriter.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef surfaceWriter<scalar> scalarWriter;
typedef surfaceWriter<vector> vectorWriter;
typedef surfaceWriter<sphericalTensor> sphericalTensorWriter;
typedef surfaceWriter<symmTensor> symmTensorWriter;
typedef surfaceWriter<tensor> tensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,330 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "vtk.H"
#include "fileName.H"
#include "OFstream.H"
#include "faceList.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::vtk<Type>::writeGeometry
(
const pointField& points,
const faceList& faces,
Ostream& os
) const
{
// Write vertex coordinates
os
<< "# vtk DataFile Version 2.0" << nl
<< "sampleSurface" << nl
<< "ASCII" << nl
<< "DATASET POLYDATA" << nl;
os << "POINTS " << points.size() << " float" << nl;
forAll(points, pointI)
{
const point& pt = points[pointI];
os << float(pt.x()) << ' ' << float(pt.y()) << ' ' << float(pt.z())
<< nl;
}
os << endl;
// Write triangles
label nFaceVerts = 0;
forAll(faces, faceI)
{
const face& f = faces[faceI];
nFaceVerts += f.size() + 1;
}
os << "POLYGONS " << faces.size() << ' ' << nFaceVerts << nl;
forAll(faces, faceI)
{
const face& f = faces[faceI];
os << f.size();
forAll(f, fp)
{
os << ' ' << f[fp];
}
os << nl;
}
}
// Write scalarField in vtk format
template<class Type>
void Foam::vtk<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const scalarField& values,
Ostream& os
) const
{
// Write data
if (values.size() == points.size())
{
os << "POINT_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
else
{
os << "CELL_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
os << fieldName << " 1 " << values.size() << " float" << nl;
forAll(values, elemI)
{
os << float(values[elemI]);
if (elemI > 0 && (elemI%10) == 0)
{
os << nl;
}
else
{
os << ' ';
}
}
os << nl;
}
// Write vectorField in vtk format
template<class Type>
void Foam::vtk<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const vectorField& values,
Ostream& os
) const
{
// Write data
if (values.size() == points.size())
{
os << "POINT_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
else
{
os << "CELL_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
os << fieldName << " 3 " << values.size() << " float" << nl;
forAll(values, elemI)
{
const vector& v = values[elemI];
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2]) << nl;
}
}
// Write sphericalTensorField in vtk format
template<class Type>
void Foam::vtk<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const sphericalTensorField& values,
Ostream& os
) const
{
// Write data
if (values.size() == points.size())
{
os << "POINT_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
else
{
os << "CELL_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
os << fieldName << " 1 " << values.size() << " float" << nl;
forAll(values, elemI)
{
const sphericalTensor& v = values[elemI];
os << float(v[0])
<< nl;
}
}
// Write symmTensorField in vtk format
template<class Type>
void Foam::vtk<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const symmTensorField& values,
Ostream& os
) const
{
// Write data
if (values.size() == points.size())
{
os << "POINT_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
else
{
os << "CELL_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
os << fieldName << " 6 " << values.size() << " float" << nl;
forAll(values, elemI)
{
const symmTensor& v = values[elemI];
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
<< float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5])
<< nl;
}
}
// Write tensorField in vtk format
template<class Type>
void Foam::vtk<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const tensorField& values,
Ostream& os
) const
{
// Write data
if (values.size() == points.size())
{
os << "POINT_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
else
{
os << "CELL_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
os << fieldName << " 9 " << values.size() << " float" << nl;
forAll(values, elemI)
{
const tensor& v = values[elemI];
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
<< float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5])
<< float(v[6]) << ' ' << float(v[7]) << ' ' << float(v[8])
<< nl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template<class Type>
Foam::vtk<Type>::vtk()
:
surfaceWriter<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::vtk<Type>::~vtk()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::vtk<Type>::write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const fileName& fieldName,
const Field<Type>& values
) const
{
fileName surfaceDir(samplePath/timeDir);
if (!exists(surfaceDir))
{
mkDir(surfaceDir);
}
fileName planeFName(surfaceDir/fieldName + '_' + surfaceName + ".vtk");
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
OFstream vtkFile(planeFName);
writeGeometry(points, faces, vtkFile);
writeData(fieldName, points, values, vtkFile);
}
// ************************************************************************* //

View File

@ -0,0 +1,153 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::vtk
Description
SourceFiles
vtk.C
\*---------------------------------------------------------------------------*/
#ifndef vtk_H
#define vtk_H
#include "surfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class vtk Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class vtk
:
public surfaceWriter<Type>
{
// Private Member Functions
void writeGeometry
(
const pointField& points,
const faceList& faces,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const scalarField& values,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const vectorField& values,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const sphericalTensorField& values,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const symmTensorField& values,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const tensorField& values,
Ostream& os
) const;
public:
//- Runtime type information
TypeName("vtk");
// Constructors
//- Construct null
vtk();
// Destructor
virtual ~vtk();
// Member Functions
// Write
//- Writes single surface to file.
virtual void write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const fileName& fieldName,
const Field<Type>& values
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "vtk.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "vtkWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(vtk);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::vtkWriters
Description
SourceFiles
vtkWriters.C
\*---------------------------------------------------------------------------*/
#ifndef vtkWriters_H
#define vtkWriters_H
#include "vtk.H"
#include "surfaceWriters.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef vtk<scalar> vtkScalarWriter;
typedef vtk<vector> vtkVectorWriter;
typedef vtk<sphericalTensor> vtkSphericalTensorWriter;
typedef vtk<symmTensor> vtkSymmTensorWriter;
typedef vtk<tensor> vtkTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,271 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "constantIsoSurface.H"
#include "meshSearch.H"
#include "polyMesh.H"
#include "interpolation.H"
#include "dictionary.H"
#include "meshCutSurface.H"
#include "cellDecompIsoSurfaceCuts.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(constantIsoSurface, 0);
addToRunTimeSelectionTable(surface, constantIsoSurface, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::constantIsoSurface::interpolate
(
const word& fieldName,
const fieldsCache<Type>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
const GeometricField<Type, fvPatchField, volMesh>& vField =
*cache[fieldName];
tmp<Field<Type> > tresult(new Field<Type>(faces().size()));
Field<Type>& result = tresult();
forAll(result, faceI)
{
result[faceI] = vField[cellLabels_[faceI]];
}
return tresult;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::constantIsoSurface::constantIsoSurface
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& isoFieldName,
const scalar isoVal
)
:
surface(mesh, searchEngine, name),
isoFieldName_(isoFieldName),
isoVal_(isoVal),
points_(0),
faces_(0),
cellLabels_(0)
{}
Foam::constantIsoSurface::constantIsoSurface
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
surface(mesh, searchEngine, dict),
isoFieldName_(dict.lookup("field")),
isoVal_(readScalar(dict.lookup("value"))),
points_(0),
faces_(0),
cellLabels_(0)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::constantIsoSurface::~constantIsoSurface()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::constantIsoSurface::correct
(
const bool meshChanged,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes,
const fieldsCache<scalar>& scalarCache
)
{
if (!scalarCache.found(isoFieldName_))
{
FatalErrorIn
(
"constantIsoSurface::correct(const bool meshChanged,"
"const volPointInterpolation&, const fieldsCache<scalar>&"
", const fieldsCache<vector>&, const fieldsCache<tensor>&)"
) << "Field " << isoFieldName_ << " not loaded." << endl
<< "It has to be one of the sampled fields"
<< exit(FatalError);
}
const volScalarField& vField = *scalarCache[isoFieldName_];
const pointScalarField& pField =
scalarCache.pointField(isoFieldName_, pInterp);
// Create smooth volField.
volScalarField smoothVolField(vField);
const labelListList& cellPoints = vField.mesh().cellPoints();
forAll(cellPoints, cellI)
{
const labelList& cPoints = cellPoints[cellI];
scalar sum = 0;
forAll(cPoints, i)
{
sum += pField[cPoints[i]];
}
smoothVolField[cellI] = sum / cPoints.size();
}
cellDecompIsoSurfaceCuts isoSurfaceCuts
(
smoothVolField,
pField,
isoVal_,
-0.1
);
meshCutSurface isoSurf(isoSurfaceCuts);
points_ = isoSurf.points();
// Convert triangles into faces
faces_.setSize(isoSurf.size());
cellLabels_.setSize(isoSurf.size());
forAll(isoSurf, triI)
{
face& f = faces_[triI];
const labelledTri& t = isoSurf[triI];
f.setSize(3);
f[0] = t[0];
f[1] = t[1];
f[2] = t[2];
cellLabels_[triI] = t.region();
}
Pout<< "Created " << name() << " :"
<< " isoValue:" << isoVal_
<< " field:" << isoFieldName_
<< " faces:" << faces_.size()
<< " points:" << points_.size() << endl;
}
Foam::tmp<Foam::scalarField> Foam::constantIsoSurface::interpolate
(
const word& fieldName,
const fieldsCache<scalar>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<scalar>(fieldName, cache, pInterp, interpolationSchemes);
}
Foam::tmp<Foam::vectorField> Foam::constantIsoSurface::interpolate
(
const word& fieldName,
const fieldsCache<vector>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<vector>(fieldName, cache, pInterp, interpolationSchemes);
}
Foam::tmp<Foam::sphericalTensorField> Foam::constantIsoSurface::interpolate
(
const word& fieldName,
const fieldsCache<sphericalTensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<sphericalTensor>
(
fieldName,
cache,
pInterp,
interpolationSchemes
);
}
Foam::tmp<Foam::symmTensorField> Foam::constantIsoSurface::interpolate
(
const word& fieldName,
const fieldsCache<symmTensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<symmTensor>
(
fieldName,
cache,
pInterp,
interpolationSchemes
);
}
Foam::tmp<Foam::tensorField> Foam::constantIsoSurface::interpolate
(
const word& fieldName,
const fieldsCache<tensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<tensor>(fieldName, cache, pInterp, interpolationSchemes);
}
// ************************************************************************* //

View File

@ -0,0 +1,199 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::constantIsoSurface
Description
SourceFiles
constantIsoSurface.C
\*---------------------------------------------------------------------------*/
#ifndef constantIsoSurface_H
#define constantIsoSurface_H
#include "surface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//class meshSearch;
class dictionary;
class plane;
class volPointInterpolation;
template<class Type> class fieldsCache;
class cellDecompIsoSurfaceCuts;
/*---------------------------------------------------------------------------*\
Class constantIsoSurface Declaration
\*---------------------------------------------------------------------------*/
class constantIsoSurface
:
public surface
{
// Private data
//- Name of field to use to construct isosurface
const word isoFieldName_;
//- Iso surface value
const scalar isoVal_;
//- Generated points
mutable pointField points_;
//- Generated triangles
mutable faceList faces_;
//- Labels into original cells
mutable labelList cellLabels_;
// Private Member Functions
template<class Type>
tmp<Field<Type> > interpolate
(
const word& fieldName,
const fieldsCache<Type>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const;
public:
//- Runtime type information
TypeName("constantIsoSurface");
// Constructors
//- Construct from components
constantIsoSurface
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& isoFieldName,
const scalar isoVal
);
//- Construct from dictionary
constantIsoSurface
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~constantIsoSurface();
// Member Functions
//- Points of surface
virtual const pointField& points() const
{
return points_;
};
//- Faces of surface
virtual const faceList& faces() const
{
return faces_;
}
//- Correct for mesh movement and/or field changes
virtual void correct
(
const bool meshChanged,
const volPointInterpolation&,
const dictionary& interpolationSchemes,
const fieldsCache<scalar>&
);
//- interpolate field to surface
virtual tmp<scalarField> interpolate
(
const word&,
const fieldsCache<scalar>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<vectorField> interpolate
(
const word&,
const fieldsCache<vector>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<sphericalTensorField> interpolate
(
const word&,
const fieldsCache<sphericalTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<symmTensorField> interpolate
(
const word&,
const fieldsCache<symmTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<tensorField> interpolate
(
const word&,
const fieldsCache<tensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,282 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "constantPatch.H"
#include "meshSearch.H"
#include "polyMesh.H"
#include "interpolation.H"
#include "dictionary.H"
#include "polyPatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(constantPatch, 0);
addToRunTimeSelectionTable(surface, constantPatch, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::constantPatch::makeTriangles()
{
if (patchIndex_ != -1)
{
const polyPatch& patch = mesh().boundaryMesh()[patchIndex_];
// Count triangles
label nTris = 0;
const faceList& localFaces = patch.localFaces();
forAll(localFaces, patchFaceI)
{
const face& f = localFaces[patchFaceI];
nTris += f.nTriangles(patch.localPoints());
}
// Triangulation is done using all localPoints
points_ = patch.localPoints();
faces_.setSize(nTris);
patchFaceLabels_.setSize(nTris);
label triI = 0;
label oldTriI = 0;
forAll(localFaces, patchFaceI)
{
const face& f = localFaces[patchFaceI];
f.triangles(patch.localPoints(), triI, faces_);
for(label i = oldTriI; i < triI; i++)
{
patchFaceLabels_[i] = patchFaceI;
}
oldTriI = triI;
}
}
}
void Foam::constantPatch::copyFaces()
{
if (patchIndex_ != -1)
{
const polyPatch& patch = mesh().boundaryMesh()[patchIndex_];
points_ = patch.localPoints();
faces_ = patch.localFaces();
patchFaceLabels_.setSize(faces_.size());
forAll(patchFaceLabels_, i)
{
patchFaceLabels_[i] = i;
}
}
}
void Foam::constantPatch::createGeometry()
{
if (triangulate_)
{
makeTriangles();
}
else
{
copyFaces();
}
Pout<< "Created " << name() << " :"
<< " patch:" << patchName_
<< " faces:" << faces_.size()
<< " points:" << points_.size() << endl;
}
template <class Type>
Foam::tmp<Foam::Field<Type> > Foam::constantPatch::interpolate
(
const word& fieldName,
const fieldsCache<Type>& cache
) const
{
// One value per face
tmp<Field<Type> > tvalues(new Field<Type>(patchFaceLabels_.size()));
Field<Type>& values = tvalues();
if (patchIndex_ != -1)
{
const GeometricField<Type, fvPatchField, volMesh>& vField =
*cache[fieldName];
const Field<Type>& bField = vField.boundaryField()[patchIndex_];
forAll(patchFaceLabels_, elemI)
{
values[elemI] = bField[patchFaceLabels_[elemI]];
}
}
return tvalues;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::constantPatch::constantPatch
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& patchName,
const bool triangulate
)
:
surface(mesh, searchEngine, name),
patchName_(patchName),
patchIndex_(mesh.boundaryMesh().findPatchID(patchName_)),
triangulate_(triangulate),
points_(0),
faces_(0),
patchFaceLabels_(0)
{
createGeometry();
}
Foam::constantPatch::constantPatch
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
surface(mesh, searchEngine, dict),
patchName_(dict.lookup("patchName")),
patchIndex_(mesh.boundaryMesh().findPatchID(patchName_)),
triangulate_(getBool(dict, "triangulate", true)),
points_(0),
faces_(0),
patchFaceLabels_(0)
{
createGeometry();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::constantPatch::~constantPatch()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::constantPatch::correct
(
const bool meshChanged,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes,
const fieldsCache<scalar>& scalarCache
)
{
if (meshChanged)
{
createGeometry();
}
}
Foam::tmp<Foam::scalarField> Foam::constantPatch::interpolate
(
const word& fieldName,
const fieldsCache<scalar>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<scalar>(fieldName, cache);
}
Foam::tmp<Foam::vectorField> Foam::constantPatch::interpolate
(
const word& fieldName,
const fieldsCache<vector>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<vector>(fieldName, cache);
}
Foam::tmp<Foam::sphericalTensorField> Foam::constantPatch::interpolate
(
const word& fieldName,
const fieldsCache<sphericalTensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<sphericalTensor>(fieldName, cache);
}
Foam::tmp<Foam::symmTensorField> Foam::constantPatch::interpolate
(
const word& fieldName,
const fieldsCache<symmTensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<symmTensor>(fieldName, cache);
}
Foam::tmp<Foam::tensorField> Foam::constantPatch::interpolate
(
const word& fieldName,
const fieldsCache<tensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<tensor>(fieldName, cache);
}
// ************************************************************************* //

View File

@ -0,0 +1,223 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::constantPatch
Description
SourceFiles
constantPatch.C
\*---------------------------------------------------------------------------*/
#ifndef constantPatch_H
#define constantPatch_H
#include "surface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//class meshSearch;
class dictionary;
class plane;
class volPointInterpolation;
template<class Type> class fieldsCache;
/*---------------------------------------------------------------------------*\
Class constantPatch Declaration
\*---------------------------------------------------------------------------*/
class constantPatch
:
public surface
{
// Private data
//- Name of patch
const word patchName_;
//- Index of patch in boundaryMesh
const label patchIndex_;
//- Make triangles or keep faces
const bool triangulate_;
//- Zero size or copy of patch.localPoints()
pointField points_;
//- Generated triangles
faceList faces_;
//- Original patch face labels
labelList patchFaceLabels_;
// Private Member Functions
//- Triangulate patch
void makeTriangles();
void copyFaces();
//- Do all to construct geometry.
void createGeometry();
//- Interpolate field onto faces
template <class Type>
tmp<Field<Type> > interpolate
(
const word&,
const fieldsCache<Type>&
) const;
public:
//- Runtime type information
TypeName("constantPatch");
// Constructors
//- Construct from components
constantPatch
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& patchName,
const bool triangulate = true
);
//- Construct from dictionary
constantPatch
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~constantPatch();
// Member Functions
const word patchName() const
{
return patchName_;
}
label patchIndex() const
{
return patchIndex_;
}
const labelList& patchFaceLabels() const
{
return patchFaceLabels_;
}
//- Points of surface
virtual const pointField& points() const
{
return points_;
}
//- Faces of surface
virtual const faceList& faces() const
{
return faces_;
}
//- Correct for mesh movement and/or field changes
virtual void correct
(
const bool meshChanged,
const volPointInterpolation&,
const dictionary& interpolationSchemes,
const fieldsCache<scalar>&
);
//- interpolate field to surface
virtual tmp<scalarField> interpolate
(
const word&,
const fieldsCache<scalar>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<vectorField> interpolate
(
const word&,
const fieldsCache<vector>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<sphericalTensorField> interpolate
(
const word&,
const fieldsCache<sphericalTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<symmTensorField> interpolate
(
const word&,
const fieldsCache<symmTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<tensorField> interpolate
(
const word&,
const fieldsCache<tensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,263 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "constantPlane.H"
#include "meshSearch.H"
#include "polyMesh.H"
#include "interpolation.H"
#include "dictionary.H"
#include "plane.H"
#include "cuttingPlane.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(constantPlane, 0);
addToRunTimeSelectionTable(surface, constantPlane, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::constantPlane::makeTriangles(const cuttingPlane& cut)
{
// Count triangles
label nTris = 0;
forAll(cut.faces(), cutFaceI)
{
const face& f = cut.faces()[cutFaceI];
nTris += f.nTriangles(cut.points());
}
// Triangulation uses all points from cut
points_ = cut.points();
faces_.setSize(nTris);
meshCells_.setSize(nTris);
label triI = 0;
label oldTriI = 0;
forAll(cut.faces(), cutFaceI)
{
const face& f = cut.faces()[cutFaceI];
f.triangles(cut.points(), triI, faces_);
for(label i = oldTriI; i < triI; i++)
{
meshCells_[i] = cut.cells()[cutFaceI];
}
oldTriI = triI;
}
}
void Foam::constantPlane::copyFaces(const cuttingPlane& cut)
{
points_ = cut.points();
faces_ = cut.faces();
meshCells_ = cut.cells();
}
void Foam::constantPlane::createGeometry()
{
cuttingPlane plane(mesh(), planeDesc_);
if (triangulate_)
{
makeTriangles(plane);
}
else
{
copyFaces(plane);
}
Pout<< "Created " << name() << " :"
<< " base:" << planeDesc_.refPoint()
<< " normal:" << planeDesc_.normal()
<< " faces:" << faces_.size()
<< " points:" << points_.size() << endl;
}
template <class Type>
Foam::tmp<Foam::Field<Type> > Foam::constantPlane::interpolate
(
const word& fieldName,
const fieldsCache<Type>& cache
) const
{
// One value per face
tmp<Field<Type> > tvalues(new Field<Type>(meshCells_.size()));
Field<Type>& values = tvalues();
const GeometricField<Type, fvPatchField, volMesh>& field =
*cache[fieldName];
forAll(meshCells_, elemI)
{
values[elemI] = field[meshCells_[elemI]];
}
return tvalues;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::constantPlane::constantPlane
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const plane& planeDesc,
const bool triangulate
)
:
surface(mesh, searchEngine, name),
planeDesc_(planeDesc),
triangulate_(triangulate),
points_(0),
faces_(0),
meshCells_(0)
{
createGeometry();
}
Foam::constantPlane::constantPlane
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
surface(mesh, searchEngine, dict),
planeDesc_(dict.lookup("basePoint"), dict.lookup("normalVector")),
triangulate_(getBool(dict, "triangulate", true)),
points_(0),
faces_(0),
meshCells_(0)
{
createGeometry();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::constantPlane::~constantPlane()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::constantPlane::correct
(
const bool meshChanged,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes,
const fieldsCache<scalar>& scalarCache
)
{
if (meshChanged)
{
// Only change of mesh changes plane.
createGeometry();
}
}
Foam::tmp<Foam::scalarField> Foam::constantPlane::interpolate
(
const word& fieldName,
const fieldsCache<scalar>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<scalar>(fieldName, cache);
}
Foam::tmp<Foam::vectorField> Foam::constantPlane::interpolate
(
const word& fieldName,
const fieldsCache<vector>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<vector>(fieldName, cache);
}
Foam::tmp<Foam::sphericalTensorField> Foam::constantPlane::interpolate
(
const word& fieldName,
const fieldsCache<sphericalTensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<sphericalTensor>(fieldName, cache);
}
Foam::tmp<Foam::symmTensorField> Foam::constantPlane::interpolate
(
const word& fieldName,
const fieldsCache<symmTensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<symmTensor>(fieldName, cache);
}
Foam::tmp<Foam::tensorField> Foam::constantPlane::interpolate
(
const word& fieldName,
const fieldsCache<tensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<tensor>(fieldName, cache);
}
// ************************************************************************* //

View File

@ -0,0 +1,219 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::constantPlane
Description
SourceFiles
constantPlane.C
\*---------------------------------------------------------------------------*/
#ifndef constantPlane_H
#define constantPlane_H
#include "surface.H"
#include "cuttingPlane.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class polyMesh;
class meshSearch;
class dictionary;
class plane;
class volPointInterpolation;
template<class Type> class fieldsCache;
/*---------------------------------------------------------------------------*\
Class constantPlane Declaration
\*---------------------------------------------------------------------------*/
class constantPlane
:
public surface
{
// Private data
//- Cutting plane description
const plane planeDesc_;
//- Make triangles or keep faces
const bool triangulate_;
//- Generated points
pointField points_;
//- Generated faces
faceList faces_;
//- Fro every face original cell in mesh
labelList meshCells_;
// Private Member Functions
//- Cut & triangulate
void makeTriangles(const cuttingPlane&);
//- Copy cut; do not triangulate
void copyFaces(const cuttingPlane&);
//- Do all to create geometry. Cut&triangulate if nessecary
void createGeometry();
//- Interpolate field onto faces
template <class Type>
tmp<Field<Type> > interpolate
(
const word& fieldName,
const fieldsCache<Type>& cache
) const;
public:
//- Runtime type information
TypeName("constantPlane");
// Constructors
//- Construct from components
constantPlane
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const plane& planeDesc,
const bool triangulate = true
);
//- Construct from dictionary
constantPlane
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~constantPlane();
// Member Functions
const plane& planeDesc() const
{
return planeDesc_;
}
const labelList& meshCells() const
{
return meshCells_;
}
//- Points of surface
virtual const pointField& points() const
{
return points_;
}
//- Faces of surface
virtual const faceList& faces() const
{
return faces_;
}
//- Correct for mesh movement and/or field changes
virtual void correct
(
const bool meshChanged,
const volPointInterpolation&,
const dictionary& interpolationSchemes,
const fieldsCache<scalar>&
);
//- interpolate field to surface
virtual tmp<scalarField> interpolate
(
const word&,
const fieldsCache<scalar>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<vectorField> interpolate
(
const word&,
const fieldsCache<vector>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<sphericalTensorField> interpolate
(
const word&,
const fieldsCache<sphericalTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<symmTensorField> interpolate
(
const word&,
const fieldsCache<symmTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<tensorField> interpolate
(
const word&,
const fieldsCache<tensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,281 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "interpolatedIsoSurface.H"
#include "meshSearch.H"
#include "polyMesh.H"
#include "interpolation.H"
#include "dictionary.H"
#include "meshCutSurface.H"
#include "cellDecompIsoSurfaceCuts.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(interpolatedIsoSurface, 0);
addToRunTimeSelectionTable(surface, interpolatedIsoSurface, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::interpolatedIsoSurface::interpolate
(
const word& fieldName,
const fieldsCache<Type>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
const GeometricField<Type, fvPatchField, volMesh>& vField =
*cache[fieldName];
const GeometricField<Type, pointPatchField, pointMesh>& pField =
cache.pointField(fieldName, pInterp);
return meshCutSurface::interpolate(isoSurfCuts(), vField, pField);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::interpolatedIsoSurface::interpolatedIsoSurface
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& isoFieldName,
const scalar isoVal
)
:
surface(mesh, searchEngine, name),
isoFieldName_(isoFieldName),
isoVal_(isoVal),
points_(0),
faces_(0),
isoSurfCutsPtr_(NULL)
{}
Foam::interpolatedIsoSurface::interpolatedIsoSurface
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
surface(mesh, searchEngine, dict),
isoFieldName_(dict.lookup("field")),
isoVal_(readScalar(dict.lookup("value"))),
points_(0),
faces_(0),
isoSurfCutsPtr_(NULL)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::interpolatedIsoSurface::~interpolatedIsoSurface()
{
if (isoSurfCutsPtr_)
{
delete isoSurfCutsPtr_;
isoSurfCutsPtr_ = NULL;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::cellDecompIsoSurfaceCuts&
Foam::interpolatedIsoSurface::isoSurfCuts() const
{
if (!isoSurfCutsPtr_)
{
FatalErrorIn("interpolatedIsoSurface::isoSurfCuts()")
<< "No interpolatedIsoSurfaceCuts allocated" << abort(FatalError);
}
return *isoSurfCutsPtr_;
}
void Foam::interpolatedIsoSurface::correct
(
const bool meshChanged,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes,
const fieldsCache<scalar>& scalarCache
)
{
if (!scalarCache.found(isoFieldName_))
{
FatalErrorIn
(
"interpolatedIsoSurface::correct(const bool meshChanged,"
"const volPointInterpolation&, const fieldsCache<scalar>&"
", const fieldsCache<vector>&, const fieldsCache<tensor>&)"
) << "Field " << isoFieldName_ << " not loaded." << endl
<< "It has to be one of the sampled fields"
<< exit(FatalError);
}
const volScalarField& vField = *scalarCache[isoFieldName_];
const pointScalarField& pField =
scalarCache.pointField(isoFieldName_, pInterp);
if (isoSurfCutsPtr_)
{
delete isoSurfCutsPtr_;
}
isoSurfCutsPtr_ = new cellDecompIsoSurfaceCuts
(
vField,
pField,
isoVal_,
-0.1
);
meshCutSurface isoSurf(isoSurfCuts());
points_ = isoSurf.points();
// Convert triangles into faces
faces_.setSize(isoSurf.size());
forAll(isoSurf, triI)
{
face& f = faces_[triI];
const labelledTri& t = isoSurf[triI];
f.setSize(3);
f[0] = t[0];
f[1] = t[1];
f[2] = t[2];
}
Pout<< "Created " << name() << " :"
<< " isoValue:" << isoVal_
<< " field:" << isoFieldName_
<< " faces:" << faces_.size()
<< " points:" << points_.size() << endl;
}
Foam::tmp<Foam::scalarField> Foam::interpolatedIsoSurface::interpolate
(
const word& fieldName,
const fieldsCache<scalar>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
if (fieldName == isoFieldName_)
{
// Same field as isoSurface was based on -> single value.
return tmp<scalarField>(new scalarField(points_.size(), isoVal_));
}
else
{
return interpolate<scalar>
(
fieldName,
cache,
pInterp,
interpolationSchemes
);
}
}
Foam::tmp<Foam::vectorField> Foam::interpolatedIsoSurface::interpolate
(
const word& fieldName,
const fieldsCache<vector>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<vector>(fieldName, cache, pInterp, interpolationSchemes);
}
Foam::tmp<Foam::sphericalTensorField> Foam::interpolatedIsoSurface::interpolate
(
const word& fieldName,
const fieldsCache<sphericalTensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<sphericalTensor>
(
fieldName,
cache,
pInterp,
interpolationSchemes
);
}
Foam::tmp<Foam::symmTensorField> Foam::interpolatedIsoSurface::interpolate
(
const word& fieldName,
const fieldsCache<symmTensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<symmTensor>
(
fieldName,
cache,
pInterp,
interpolationSchemes
);
}
Foam::tmp<Foam::tensorField> Foam::interpolatedIsoSurface::interpolate
(
const word& fieldName,
const fieldsCache<tensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<tensor>(fieldName, cache, pInterp, interpolationSchemes);
}
// ************************************************************************* //

View File

@ -0,0 +1,203 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::interpolatedIsoSurface
Description
SourceFiles
interpolatedIsoSurface.C
\*---------------------------------------------------------------------------*/
#ifndef interpolatedIsoSurface_H
#define interpolatedIsoSurface_H
#include "surface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//class meshSearch;
class dictionary;
class plane;
class volPointInterpolation;
template<class Type> class fieldsCache;
class cellDecompIsoSurfaceCuts;
/*---------------------------------------------------------------------------*\
Class interpolatedIsoSurface Declaration
\*---------------------------------------------------------------------------*/
class interpolatedIsoSurface
:
public surface
{
// Private data
//- Name of field to use to construct isosurface
const word isoFieldName_;
//- Iso surface value
const scalar isoVal_;
//- Generated points
mutable pointField points_;
//- Generated triangles
mutable faceList faces_;
//- Iso surface edge descriptors
const cellDecompIsoSurfaceCuts* isoSurfCutsPtr_;
// Private Member Functions
template<class Type>
tmp<Field<Type> > interpolate
(
const word& fieldName,
const fieldsCache<Type>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const;
public:
//- Runtime type information
TypeName("interpolatedIsoSurface");
// Constructors
//- Construct from components
interpolatedIsoSurface
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& isoFieldName,
const scalar isoVal
);
//- Construct from dictionary
interpolatedIsoSurface
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~interpolatedIsoSurface();
// Member Functions
//- Access isoSurface edge cuts
const cellDecompIsoSurfaceCuts& isoSurfCuts() const;
//- Points of surface
virtual const pointField& points() const
{
return points_;
};
//- Faces of surface
virtual const faceList& faces() const
{
return faces_;
}
//- Correct for mesh movement and/or field changes. Differs from
// constantIsoSurface one since meshCuts are stored for use in
// interpolation later on
virtual void correct
(
const bool meshChanged,
const volPointInterpolation&,
const dictionary& interpolationSchemes,
const fieldsCache<scalar>&
);
//- interpolate field to surface
virtual tmp<scalarField> interpolate
(
const word&,
const fieldsCache<scalar>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<vectorField> interpolate
(
const word&,
const fieldsCache<vector>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<sphericalTensorField> interpolate
(
const word&,
const fieldsCache<sphericalTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<symmTensorField> interpolate
(
const word&,
const fieldsCache<symmTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<tensorField> interpolate
(
const word&,
const fieldsCache<tensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,211 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "interpolatedPatch.H"
#include "meshSearch.H"
#include "polyMesh.H"
#include "interpolation.H"
#include "dictionary.H"
#include "polyPatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(interpolatedPatch, 0);
addToRunTimeSelectionTable(surface, interpolatedPatch, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template <class Type>
Foam::tmp<Foam::Field<Type> > Foam::interpolatedPatch::interpolate
(
const word& fieldName,
const fieldsCache<Type>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
// One value per vertex
tmp<Field<Type> > tvalues(new Field<Type>(points().size()));
Field<Type>& values = tvalues();
// Get interpolator from cache
const interpolation<Type>& interpolator =
cache.interpolator(fieldName, pInterp, interpolationSchemes);
if (patchIndex() != -1)
{
const polyPatch& patch = mesh().boundaryMesh()[patchIndex()];
const labelList& own = mesh().faceOwner();
boolList pointDone(points().size(), false);
forAll(faces(), cutFaceI)
{
const face& f = faces()[cutFaceI];
forAll(f, faceVertI)
{
label pointI = f[faceVertI];
if (!pointDone[pointI])
{
label faceI = patchFaceLabels()[cutFaceI] + patch.start();
label cellI = own[faceI];
values[pointI] =
interpolator.interpolate
(
points()[pointI],
cellI,
faceI
);
pointDone[pointI] = true;
}
}
}
}
return tvalues;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::interpolatedPatch::interpolatedPatch
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& patchName,
const bool triangulate
)
:
constantPatch(mesh, searchEngine, name, patchName, triangulate)
{}
Foam::interpolatedPatch::interpolatedPatch
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
constantPatch(mesh, searchEngine, dict)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::interpolatedPatch::~interpolatedPatch()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::scalarField> Foam::interpolatedPatch::interpolate
(
const word& fieldName,
const fieldsCache<scalar>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<scalar>(fieldName, cache, pInterp, interpolationSchemes);
}
Foam::tmp<Foam::vectorField> Foam::interpolatedPatch::interpolate
(
const word& fieldName,
const fieldsCache<vector>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<vector>(fieldName, cache, pInterp, interpolationSchemes);
}
Foam::tmp<Foam::sphericalTensorField> Foam::interpolatedPatch::interpolate
(
const word& fieldName,
const fieldsCache<sphericalTensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<sphericalTensor>
(
fieldName,
cache,
pInterp,
interpolationSchemes
);
}
Foam::tmp<Foam::symmTensorField> Foam::interpolatedPatch::interpolate
(
const word& fieldName,
const fieldsCache<symmTensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<symmTensor>
(
fieldName,
cache,
pInterp,
interpolationSchemes
);
}
Foam::tmp<Foam::tensorField> Foam::interpolatedPatch::interpolate
(
const word& fieldName,
const fieldsCache<tensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<tensor>(fieldName, cache, pInterp, interpolationSchemes);
}
// ************************************************************************* //

View File

@ -0,0 +1,163 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::interpolatedPatch
Description
SourceFiles
interpolatedPatch.C
\*---------------------------------------------------------------------------*/
#ifndef interpolatedPatch_H
#define interpolatedPatch_H
#include "surface.H"
#include "constantPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class meshSearch;
class dictionary;
class plane;
class volPointInterpolation;
template<class Type> class fieldsCache;
/*---------------------------------------------------------------------------*\
Class interpolatedPatch Declaration
\*---------------------------------------------------------------------------*/
class interpolatedPatch
:
public constantPatch
{
// Private Member Functions
//- Interpolate field onto faces
template <class Type>
tmp<Field<Type> > interpolate
(
const word& fieldName,
const fieldsCache<Type>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const;
public:
//- Runtime type information
TypeName("interpolatedPatch");
// Constructors
//- Construct from components
interpolatedPatch
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& patchName,
const bool triangulate = true
);
//- Construct from dictionary
interpolatedPatch
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~interpolatedPatch();
// Member Functions
//- correct() implemented by constantPatch::correct()
//- interpolate field to surface
virtual tmp<scalarField> interpolate
(
const word&,
const fieldsCache<scalar>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<vectorField> interpolate
(
const word&,
const fieldsCache<vector>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<sphericalTensorField> interpolate
(
const word&,
const fieldsCache<sphericalTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<symmTensorField> interpolate
(
const word&,
const fieldsCache<symmTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<tensorField> interpolate
(
const word&,
const fieldsCache<tensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,203 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "interpolatedPlane.H"
#include "meshSearch.H"
#include "polyMesh.H"
#include "meshSearch.H"
#include "interpolation.H"
#include "dictionary.H"
#include "plane.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(interpolatedPlane, 0);
addToRunTimeSelectionTable(surface, interpolatedPlane, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template <class Type>
Foam::tmp<Foam::Field<Type> > Foam::interpolatedPlane::interpolate
(
const word& fieldName,
const fieldsCache<Type>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
// One value per point
tmp<Field<Type> > tvalues(new Field<Type>(points().size()));
Field<Type>& values = tvalues();
// Get interpolator from cache
const interpolation<Type>& interpolator =
cache.interpolator(fieldName, pInterp, interpolationSchemes);
boolList pointDone(points().size(), false);
forAll(faces(), cutFaceI)
{
const face& f = faces()[cutFaceI];
forAll(f, faceVertI)
{
label pointI = f[faceVertI];
if (!pointDone[pointI])
{
values[pointI] =
interpolator.interpolate
(
points()[pointI],
meshCells()[cutFaceI]
);
pointDone[pointI] = true;
}
}
}
return tvalues;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::interpolatedPlane::interpolatedPlane
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const plane& planeDesc,
const bool triangulate
)
:
constantPlane(mesh, searchEngine, name, planeDesc, triangulate)
{}
// Construct from dictionary
Foam::interpolatedPlane::interpolatedPlane
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
constantPlane(mesh, searchEngine, dict)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::interpolatedPlane::~interpolatedPlane()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::scalarField> Foam::interpolatedPlane::interpolate
(
const word& fieldName,
const fieldsCache<scalar>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<scalar>(fieldName, cache, pInterp, interpolationSchemes);
}
Foam::tmp<Foam::vectorField> Foam::interpolatedPlane::interpolate
(
const word& fieldName,
const fieldsCache<vector>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<vector>(fieldName, cache, pInterp, interpolationSchemes);
}
Foam::tmp<Foam::sphericalTensorField> Foam::interpolatedPlane::interpolate
(
const word& fieldName,
const fieldsCache<sphericalTensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<sphericalTensor>
(
fieldName,
cache,
pInterp,
interpolationSchemes
);
}
Foam::tmp<Foam::symmTensorField> Foam::interpolatedPlane::interpolate
(
const word& fieldName,
const fieldsCache<symmTensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<symmTensor>
(
fieldName,
cache,
pInterp,
interpolationSchemes
);
}
Foam::tmp<Foam::tensorField> Foam::interpolatedPlane::interpolate
(
const word& fieldName,
const fieldsCache<tensor>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const
{
return interpolate<tensor>(fieldName, cache, pInterp, interpolationSchemes);
}
// ************************************************************************* //

View File

@ -0,0 +1,164 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::interpolatedPlane
Description
SourceFiles
interpolatedPlane.C
\*---------------------------------------------------------------------------*/
#ifndef interpolatedPlane_H
#define interpolatedPlane_H
#include "surface.H"
#include "constantPlane.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class polyMesh;
class meshSearch;
class dictionary;
class plane;
class volPointInterpolation;
/*---------------------------------------------------------------------------*\
Class interpolatedPlane Declaration
\*---------------------------------------------------------------------------*/
class interpolatedPlane
:
public constantPlane
{
// Private Member Functions
//- Interpolate field onto vertices
template<class Type>
tmp<Field<Type> > interpolate
(
const word& fieldName,
const fieldsCache<Type>& cache,
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes
) const;
public:
//- Runtime type information
TypeName("interpolatedPlane");
// Constructors
//- Construct from components
interpolatedPlane
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const plane& planeDesc,
const bool triangulate
);
//- Construct from dictionary
interpolatedPlane
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~interpolatedPlane();
// Member Functions
//- correct surface for new mesh done by constantPlane::correct()
//- interpolate field to surface
virtual tmp<scalarField> interpolate
(
const word&,
const fieldsCache<scalar>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<vectorField> interpolate
(
const word&,
const fieldsCache<vector>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<sphericalTensorField> interpolate
(
const word&,
const fieldsCache<sphericalTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<symmTensorField> interpolate
(
const word&,
const fieldsCache<symmTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
//- interpolate field to surface
virtual tmp<tensorField> interpolate
(
const word&,
const fieldsCache<tensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,135 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
Description
\*---------------------------------------------------------------------------*/
#include "surface.H"
#include "polyMesh.H"
#include "primitiveMesh.H"
#include "meshSearch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(surface, 0);
defineRunTimeSelectionTable(surface, word);
autoPtr<surface> surface::New
(
const word& sampleType,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
{
wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_
->find(sampleType);
if (cstrIter == wordConstructorTablePtr_->end())
{
FatalErrorIn
(
"surface::New(const word&, "
"const polyMesh&, meshSearch&, const dictionary&)"
) << "Unknown sample type " << sampleType
<< endl << endl
<< "Valid sample types : " << endl
<< wordConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<surface>
(
cstrIter()
(
mesh,
searchEngine,
dict
)
);
}
} // End namespace Foam
bool Foam::surface::getBool
(
const dictionary& dict,
const word& key,
const bool defaultVal
)
{
if (dict.found(key))
{
return readBool(dict.lookup(key));
}
else
{
return defaultVal;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from mesh, name
Foam::surface::surface
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name
)
:
mesh_(mesh),
searchEngine_(searchEngine),
name_(name)
{}
// Construct from dictionary
Foam::surface::surface
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
mesh_(mesh),
searchEngine_(searchEngine),
name_(dict.lookup("name"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surface::~surface()
{}
// ************************************************************************* //

View File

@ -0,0 +1,261 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::surface
Description
SourceFiles
surface.C
\*---------------------------------------------------------------------------*/
#ifndef surface_H
#define surface_H
#include "pointField.H"
#include "word.H"
#include "labelList.H"
#include "faceList.H"
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "autoPtr.H"
#include "volFieldsFwd.H"
#include "fieldsCache.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class polyMesh;
class meshSearch;
class volPointInterpolation;
template<class Type> class fieldsCache;
/*---------------------------------------------------------------------------*\
Class surface Declaration
\*---------------------------------------------------------------------------*/
class surface
{
// Private data
//- Reference to mesh
const polyMesh& mesh_;
//- Reference to mesh searching class
meshSearch& searchEngine_;
//- Name of set
const word name_;
protected:
// Protected static functions
//- Read bool from dictionary. Return provided value if not found
static bool getBool(const dictionary& dict, const word&, const bool);
public:
//- Runtime type information
TypeName("surface");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
surface,
word,
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
),
(mesh, searchEngine, dict)
);
//- Class used for the read-construction of
// PtrLists of surface
class iNew
{
const polyMesh& mesh_;
meshSearch& searchEngine_;
public:
iNew(const polyMesh& mesh, meshSearch& searchEngine)
:
mesh_(mesh),
searchEngine_(searchEngine)
{}
autoPtr<surface> operator()(Istream& is) const
{
word sampleType(is);
dictionary dict(is);
return surface::New(sampleType, mesh_, searchEngine_, dict);
}
};
// Constructors
//- Construct from mesh, name
surface
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name
);
//- Construct from dictionary
surface
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
//- Clone
autoPtr<surface> clone() const
{
notImplemented("autoPtr<surface> clone() const");
return autoPtr<surface>(NULL);
}
// Selectors
//- Return a reference to the selected surface
static autoPtr<surface> New
(
const word& sampleType,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~surface();
// Member Functions
const polyMesh& mesh() const
{
return mesh_;
}
meshSearch& searchEngine() const
{
return searchEngine_;
}
//- Name of surface
const word& name() const
{
return name_;
}
//- Points of surface
virtual const pointField& points() const = 0;
//- Faces of surface
virtual const faceList& faces() const = 0;
//- Correct for mesh movement and/or field changes
virtual void correct
(
const bool meshChanged,
const volPointInterpolation&,
const dictionary& interpolationSchemes,
const fieldsCache<scalar>&
) = 0;
//- interpolate field to surface
virtual tmp<scalarField> interpolate
(
const word&,
const fieldsCache<scalar>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const = 0;
//- interpolate field to surface
virtual tmp<vectorField> interpolate
(
const word&,
const fieldsCache<vector>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const = 0;
//- interpolate field to surface
virtual tmp<sphericalTensorField> interpolate
(
const word&,
const fieldsCache<sphericalTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const = 0;
//- interpolate field to surface
virtual tmp<symmTensorField> interpolate
(
const word&,
const fieldsCache<symmTensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const = 0;
//- interpolate field to surface
virtual tmp<tensorField> interpolate
(
const word&,
const fieldsCache<tensor>&,
const volPointInterpolation&,
const dictionary& interpolationSchemes
) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //