Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry
2013-02-15 17:14:36 +00:00
39 changed files with 695 additions and 4977 deletions

View File

@ -1,7 +0,0 @@
foamToFieldview9.C
fieldviewTopology.C
write_binary_uns.c
calcFaceAddressing.C
writeFunctions.C
EXE = $(FOAM_APPBIN)/foamToFieldview9

View File

@ -1,10 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lgenericPatchFields \
-llagrangian

View File

@ -1,92 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "calcFaceAddressing.H"
using namespace Foam;
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
// Returns the face labels of the shape in an order consistent with the
// shape.
labelList calcFaceAddressing
(
const faceList& allFaces, // faces given faceLabels
const cellShape& shape,
const labelList& faces, // faceLabels for given cell
const label cellI
)
{
// return value.
labelList shapeToMesh(shape.nFaces(), -1);
const faceList modelFaces(shape.faces());
// Loop over all faces of cellShape
forAll(modelFaces, cellFaceI)
{
// face (vertex list)
const face& modelFace = modelFaces[cellFaceI];
// Loop over all face labels
forAll(faces, faceI)
{
const face& vertLabels = allFaces[faces[faceI]];
if (vertLabels == modelFace)
{
//Info<< "match:" << modelFace
// << " to " << vertLabels << endl;
shapeToMesh[cellFaceI] = faces[faceI];
break;
}
}
if (shapeToMesh[cellFaceI] == -1)
{
FatalErrorIn("foamToFieldview : calcFaceAddressing")
<< "calcFaceAddressing : can't match face to shape.\n"
<< " shape face:" << modelFace << endl
<< " face labels:" << faces << endl
<< " cellI:" << cellI << endl;
FatalError
<< "Faces consist of vertices:" << endl;
forAll(faces, faceI)
{
FatalError
<< " face:" << faces[faceI]
<< allFaces[faces[faceI]] << endl;
}
FatalError
<< exit(FatalError);
}
}
return shapeToMesh;
}
// ************************************************************************* //

View File

@ -1,55 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass
Foam::calcFaceAddressing
Description
SourceFiles
calcFaceAddressing.C
\*---------------------------------------------------------------------------*/
#ifndef calcFaceAddressing_H
#define calcFaceAddressing_H
#include "faceList.H"
#include "cellShape.H"
#include "labelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::labelList calcFaceAddressing
(
const Foam::faceList& allFaces, // faces given faceLabels
const Foam::cellShape& shape,
const Foam::labelList& faces, // faceLabels for given cell
const Foam::label cellI
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,197 +0,0 @@
// Construct List of pointers to all vol fields
int nFields = volScalarNames.size() + 3*volVectorNames.size();
List<volScalarField*> volFieldPtrs
(
nFields,
reinterpret_cast<volScalarField*>(0)
);
stringList volFieldNames(nFields);
nFields = 0;
{
// Load all scalar fields and store ptr to it
forAll(volScalarNames, fieldI)
{
word fieldName = volScalarNames[fieldI];
// Check if present
IOobject ioHeader
(
fieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (ioHeader.headerOk())
{
volFieldPtrs[nFields] = new volScalarField
(
ioHeader,
mesh
);
}
fieldName = getFieldViewName(fieldName);
volFieldNames[nFields] = fieldName;
nFields++;
}
// Load all (componenents of) vector fields
forAll(volVectorNames, fieldI)
{
word fieldName = volVectorNames[fieldI];
// Check if present
IOobject ioHeader
(
fieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (ioHeader.headerOk())
{
volVectorField vvf(ioHeader, mesh);
// X component
volFieldPtrs[nFields] =
new volScalarField
(
vvf.component(vector::X)
);
// Y component
volFieldPtrs[nFields+1] =
new volScalarField
(
vvf.component(vector::Y)
);
// Z component
volFieldPtrs[nFields+2] =
new volScalarField
(
vvf.component(vector::Z)
);
}
fieldName = getFieldViewName(fieldName);
volFieldNames[nFields] = fieldName + ("x;" + fieldName);
volFieldNames[nFields+1] = fieldName + "y";
volFieldNames[nFields+2] = fieldName + "z";
nFields += 3;
}
}
//
// Construct List of pointers to all surface fields
//
int nSurfFields = surfScalarNames.size() + 3*surfVectorNames.size();
List<surfaceScalarField*> surfFieldPtrs
(
nSurfFields,
reinterpret_cast<surfaceScalarField*>(0)
);
stringList surfFieldNames(nSurfFields);
nSurfFields = 0;
{
// Load all scalar fields
forAll(surfScalarNames, fieldI)
{
word fieldName = surfScalarNames[fieldI];
// Check if present
IOobject ioHeader
(
fieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (ioHeader.headerOk())
{
surfFieldPtrs[nSurfFields] =
new surfaceScalarField
(
ioHeader,
mesh
);
}
fieldName = getFieldViewName(fieldName);
surfFieldNames[nSurfFields] = fieldName;
nSurfFields++;
}
// Set (componenents of) vector fields
forAll(surfVectorNames, fieldI)
{
word fieldName = surfVectorNames[fieldI];
// Check if present
IOobject ioHeader
(
fieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (ioHeader.headerOk())
{
surfaceVectorField svf(ioHeader, mesh);
// X component
surfFieldPtrs[nSurfFields] =
new surfaceScalarField
(
svf.component(vector::X)
);
// Y component
surfFieldPtrs[nSurfFields+1] =
new surfaceScalarField
(
svf.component(vector::Y)
);
// Z component
surfFieldPtrs[nSurfFields+2] =
new surfaceScalarField
(
svf.component(vector::Z)
);
}
fieldName = getFieldViewName(fieldName);
surfFieldNames[nSurfFields] = fieldName + ("x;" + fieldName);
surfFieldNames[nSurfFields+1] = fieldName + "y";
surfFieldNames[nSurfFields+2] = fieldName + "z";
nSurfFields += 3;
}
}

View File

@ -1,75 +0,0 @@
// Construct of ptrs to all spray fields
List<IOField<scalar>* > sprayScalarFieldPtrs
(
sprayScalarNames.size(),
reinterpret_cast<IOField<scalar>*>(0)
);
List<IOField<vector>* > sprayVectorFieldPtrs
(
sprayVectorNames.size(),
reinterpret_cast<IOField<vector>*>(0)
);
{
int sprayFieldI = 0;
// Set scalar fields
forAll(sprayScalarNames, fieldI)
{
IOobject ioHeader
(
sprayScalarNames[fieldI],
runTime.timeName(),
cloud::prefix,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (ioHeader.headerOk())
{
sprayScalarFieldPtrs[sprayFieldI] = new IOField<scalar>(ioHeader);
}
else
{
Info<< " dummy lagrangian field for "
<< sprayScalarNames[fieldI] << endl;
}
sprayFieldI++;
}
}
// Set vector fields
{
int sprayFieldI = 0;
forAll(sprayVectorNames, fieldI)
{
IOobject ioHeader
(
sprayVectorNames[fieldI],
runTime.timeName(),
cloud::prefix,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (ioHeader.headerOk())
{
sprayVectorFieldPtrs[sprayFieldI] = new IOField<vector>(ioHeader);
}
else
{
Info<< " dummy lagrangian field for "
<< sprayVectorNames[fieldI] << endl;
}
sprayFieldI++;
}
}

View File

@ -1,436 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "fieldviewTopology.H"
#include "polyMesh.H"
#include "cellShape.H"
#include "cellModeller.H"
#include "wallPolyPatch.H"
#include "symmetryPolyPatch.H"
#include "fv_reader_tags.h"
extern "C"
{
unsigned int fv_encode_elem_header(int elem_type, int wall_info[]);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::labelList Foam::fieldviewTopology::calcFaceAddressing
(
const faceList& allFaces, // faces given faceLabels
const cellShape& shape,
const labelList& faces, // faceLabels for given cell
const label cellI
)
{
// return value.
labelList shapeToMesh(shape.nFaces(), -1);
const faceList modelFaces(shape.faces());
// Loop over all faces of cellShape
forAll(modelFaces, cellFaceI)
{
// face (vertex list)
const face& modelFace = modelFaces[cellFaceI];
// Loop over all face labels
forAll(faces, faceI)
{
const face& vertLabels = allFaces[faces[faceI]];
if (vertLabels == modelFace)
{
shapeToMesh[cellFaceI] = faces[faceI];
break;
}
}
if (shapeToMesh[cellFaceI] == -1)
{
FatalErrorIn("foamToFieldview : calcFaceAddressing")
<< "calcFaceAddressing : can't match face to shape.\n"
<< " shape face:" << modelFace << endl
<< " face labels:" << faces << endl
<< " cellI:" << cellI << endl;
FatalError << "Faces consist of vertices:" << endl;
forAll(faces, faceI)
{
FatalError
<< " face:" << faces[faceI]
<< allFaces[faces[faceI]] << endl;
}
FatalError << exit(FatalError);
}
}
return shapeToMesh;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::fieldviewTopology::fieldviewTopology
(
const polyMesh& mesh,
const bool setWallInfo
)
:
hexLabels_((1+8)*mesh.nCells()),
prismLabels_((1+6)*mesh.nCells()),
pyrLabels_((1+5)*mesh.nCells()),
tetLabels_((1+4)*mesh.nCells()),
nPoly_(0),
quadFaceLabels_(mesh.boundaryMesh().size()),
nPolyFaces_(mesh.boundaryMesh().size())
{
// Mark all faces that are to be seen as wall for particle
// tracking and all cells that use one or more of these walls
List<int> wallFace(mesh.nFaces(), NOT_A_WALL);
boolList wallCell(mesh.nCells(), false);
if (setWallInfo)
{
forAll(mesh.boundaryMesh(), patchI)
{
const polyPatch& currPatch = mesh.boundaryMesh()[patchI];
if
(
isA<wallPolyPatch>(currPatch)
|| isA<symmetryPolyPatch>(currPatch)
)
{
forAll(currPatch, patchFaceI)
{
label meshFaceI = currPatch.start() + patchFaceI;
wallFace[meshFaceI] = A_WALL;
wallCell[mesh.faceOwner()[meshFaceI]] = true;
}
}
}
}
const cellModel& tet = *(cellModeller::lookup("tet"));
const cellModel& pyr = *(cellModeller::lookup("pyr"));
const cellModel& prism = *(cellModeller::lookup("prism"));
const cellModel& wedge = *(cellModeller::lookup("wedge"));
const cellModel& tetWedge = *(cellModeller::lookup("tetWedge"));
const cellModel& hex = *(cellModeller::lookup("hex"));
// Pre calculate headers for cells not on walls
List<int> notWallFlags(6, NOT_A_WALL);
unsigned int tetNotWall = fv_encode_elem_header
(
FV_TET_ELEM_ID, notWallFlags.begin()
);
unsigned int pyrNotWall = fv_encode_elem_header
(
FV_PYRA_ELEM_ID, notWallFlags.begin()
);
unsigned int prismNotWall = fv_encode_elem_header
(
FV_PRISM_ELEM_ID, notWallFlags.begin()
);
unsigned int hexNotWall = fv_encode_elem_header
(
FV_HEX_ELEM_ID, notWallFlags.begin()
);
// Some aliases
const cellList& cellFaces = mesh.cells();
const cellShapeList& cellShapes = mesh.cellShapes();
label hexi = 0;
label prismi = 0;
label pyri = 0;
label teti = 0;
const faceList& allFaces = mesh.faces();
List<int> wallFlags(6);
forAll(cellShapes, celli)
{
const cellShape& cellShape = cellShapes[celli];
const cellModel& cellModel = cellShape.model();
if (cellModel == tet)
{
if (!wallCell[celli])
{
tetLabels_[teti++] = tetNotWall;
}
else
{
labelList modelToMesh = calcFaceAddressing
(
allFaces, cellShape, cellFaces[celli], celli
);
wallFlags[0] = wallFace[modelToMesh[0]];
wallFlags[1] = wallFace[modelToMesh[1]];
wallFlags[2] = wallFace[modelToMesh[2]];
wallFlags[3] = wallFace[modelToMesh[3]];
tetLabels_[teti++] = fv_encode_elem_header
(
FV_TET_ELEM_ID, wallFlags.begin()
);
}
tetLabels_[teti++] = cellShape[0] + 1;
tetLabels_[teti++] = cellShape[1] + 1;
tetLabels_[teti++] = cellShape[2] + 1;
tetLabels_[teti++] = cellShape[3] + 1;
}
else if (cellModel == pyr)
{
if (!wallCell[celli])
{
pyrLabels_[pyri++] = pyrNotWall;
}
else
{
labelList modelToMesh = calcFaceAddressing
(
allFaces, cellShape, cellFaces[celli], celli
);
wallFlags[0] = wallFace[modelToMesh[0]];
wallFlags[1] = wallFace[modelToMesh[3]];
wallFlags[2] = wallFace[modelToMesh[2]];
wallFlags[3] = wallFace[modelToMesh[1]];
wallFlags[4] = wallFace[modelToMesh[4]];
pyrLabels_[pyri++] = fv_encode_elem_header
(
FV_PYRA_ELEM_ID, wallFlags.begin()
);
}
pyrLabels_[pyri++] = cellShape[0] + 1;
pyrLabels_[pyri++] = cellShape[1] + 1;
pyrLabels_[pyri++] = cellShape[2] + 1;
pyrLabels_[pyri++] = cellShape[3] + 1;
pyrLabels_[pyri++] = cellShape[4] + 1;
}
else if (cellModel == prism)
{
if (!wallCell[celli])
{
prismLabels_[prismi++] = prismNotWall;
}
else
{
labelList modelToMesh = calcFaceAddressing
(
allFaces, cellShape, cellFaces[celli], celli
);
wallFlags[0] = wallFace[modelToMesh[4]];
wallFlags[1] = wallFace[modelToMesh[2]];
wallFlags[2] = wallFace[modelToMesh[3]];
wallFlags[3] = wallFace[modelToMesh[0]];
wallFlags[4] = wallFace[modelToMesh[1]];
prismLabels_[prismi++] = fv_encode_elem_header
(
FV_PRISM_ELEM_ID, wallFlags.begin()
);
}
prismLabels_[prismi++] = cellShape[0] + 1;
prismLabels_[prismi++] = cellShape[3] + 1;
prismLabels_[prismi++] = cellShape[4] + 1;
prismLabels_[prismi++] = cellShape[1] + 1;
prismLabels_[prismi++] = cellShape[5] + 1;
prismLabels_[prismi++] = cellShape[2] + 1;
}
else if (cellModel == tetWedge)
{
// Treat as prism with collapsed edge
if (!wallCell[celli])
{
prismLabels_[prismi++] = prismNotWall;
}
else
{
labelList modelToMesh = calcFaceAddressing
(
allFaces, cellShape, cellFaces[celli], celli
);
wallFlags[0] = wallFace[modelToMesh[1]];
wallFlags[1] = wallFace[modelToMesh[2]];
wallFlags[2] = wallFace[modelToMesh[3]];
wallFlags[3] = wallFace[modelToMesh[0]];
wallFlags[4] = wallFace[modelToMesh[3]];
prismLabels_[prismi++] = fv_encode_elem_header
(
FV_PRISM_ELEM_ID, wallFlags.begin()
);
}
prismLabels_[prismi++] = cellShape[0] + 1;
prismLabels_[prismi++] = cellShape[3] + 1;
prismLabels_[prismi++] = cellShape[4] + 1;
prismLabels_[prismi++] = cellShape[1] + 1;
prismLabels_[prismi++] = cellShape[4] + 1;
prismLabels_[prismi++] = cellShape[2] + 1;
}
else if (cellModel == wedge)
{
if (!wallCell[celli])
{
hexLabels_[hexi++] = hexNotWall;
}
else
{
labelList modelToMesh = calcFaceAddressing
(
allFaces, cellShape, cellFaces[celli], celli
);
wallFlags[0] = wallFace[modelToMesh[2]];
wallFlags[1] = wallFace[modelToMesh[3]];
wallFlags[2] = wallFace[modelToMesh[0]];
wallFlags[3] = wallFace[modelToMesh[1]];
wallFlags[4] = wallFace[modelToMesh[4]];
wallFlags[5] = wallFace[modelToMesh[5]];
hexLabels_[hexi++] = fv_encode_elem_header
(
FV_HEX_ELEM_ID, wallFlags.begin()
);
}
hexLabels_[hexi++] = cellShape[0] + 1;
hexLabels_[hexi++] = cellShape[1] + 1;
hexLabels_[hexi++] = cellShape[0] + 1;
hexLabels_[hexi++] = cellShape[2] + 1;
hexLabels_[hexi++] = cellShape[3] + 1;
hexLabels_[hexi++] = cellShape[4] + 1;
hexLabels_[hexi++] = cellShape[6] + 1;
hexLabels_[hexi++] = cellShape[5] + 1;
}
else if (cellModel == hex)
{
if (!wallCell[celli])
{
hexLabels_[hexi++] = hexNotWall;
}
else
{
labelList modelToMesh = calcFaceAddressing
(
allFaces, cellShape, cellFaces[celli], celli
);
wallFlags[0] = wallFace[modelToMesh[0]];
wallFlags[1] = wallFace[modelToMesh[1]];
wallFlags[2] = wallFace[modelToMesh[4]];
wallFlags[3] = wallFace[modelToMesh[5]];
wallFlags[4] = wallFace[modelToMesh[2]];
wallFlags[5] = wallFace[modelToMesh[3]];
hexLabels_[hexi++] = fv_encode_elem_header
(
FV_HEX_ELEM_ID, wallFlags.begin()
);
}
hexLabels_[hexi++] = cellShape[0] + 1;
hexLabels_[hexi++] = cellShape[1] + 1;
hexLabels_[hexi++] = cellShape[3] + 1;
hexLabels_[hexi++] = cellShape[2] + 1;
hexLabels_[hexi++] = cellShape[4] + 1;
hexLabels_[hexi++] = cellShape[5] + 1;
hexLabels_[hexi++] = cellShape[7] + 1;
hexLabels_[hexi++] = cellShape[6] + 1;
}
else
{
nPoly_++;
}
}
hexLabels_.setSize(hexi);
prismLabels_.setSize(prismi);
pyrLabels_.setSize(pyri);
tetLabels_.setSize(teti);
//
// Patches
//
forAll(mesh.boundaryMesh(), patchI)
{
const polyPatch& patchFaces = mesh.boundaryMesh()[patchI];
labelList& faceLabels = quadFaceLabels_[patchI];
// Faces, each 4 labels. Size big enough
faceLabels.setSize(patchFaces.size()*4);
label labelI = 0;
forAll(patchFaces, faceI)
{
const face& patchFace = patchFaces[faceI];
if (patchFace.size() == 3)
{
faceLabels[labelI++] = patchFace[0] + 1;
faceLabels[labelI++] = patchFace[1] + 1;
faceLabels[labelI++] = patchFace[2] + 1;
faceLabels[labelI++] = 0; // Fieldview:triangle definition
}
else if (patchFace.size() == 4)
{
faceLabels[labelI++] = patchFace[0] + 1;
faceLabels[labelI++] = patchFace[1] + 1;
faceLabels[labelI++] = patchFace[2] + 1;
faceLabels[labelI++] = patchFace[3] + 1;
}
}
faceLabels.setSize(labelI);
label nFaces = labelI/4;
nPolyFaces_[patchI] = patchFaces.size() - nFaces;
}
}
// ************************************************************************* //

View File

@ -1,176 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fieldviewTopology
Description
SourceFiles
fieldviewTopology.C
\*---------------------------------------------------------------------------*/
#ifndef fieldviewTopology_H
#define fieldviewTopology_H
#include "labelList.H"
#include "faceList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class polyMesh;
class cellShape;
/*---------------------------------------------------------------------------*\
Class fieldviewTopology Declaration
\*---------------------------------------------------------------------------*/
class fieldviewTopology
{
// Private data
//- Hexes in fieldview format
List<int> hexLabels_;
List<int> prismLabels_;
List<int> pyrLabels_;
List<int> tetLabels_;
//- Number of non-hex/prism/pyr/tet labels
label nPoly_;
//
// Patches
//
//- Quad and tri patch faces in fv format
labelListList quadFaceLabels_;
//- Number of polyhedral faces per patch
labelList nPolyFaces_;
// Private Member Functions
static labelList calcFaceAddressing
(
const faceList& allFaces, // faces given faceLabels
const cellShape& shape,
const labelList& faces, // faceLabels for given cell
const label cellI
);
//- Disallow default bitwise copy construct
fieldviewTopology(const fieldviewTopology&);
//- Disallow default bitwise assignment
void operator=(const fieldviewTopology&);
public:
// Constructors
//- Construct from components
fieldviewTopology(const polyMesh& mesh, const bool setWallInfo);
// Member Functions
// Access
const List<int>& hexLabels() const
{
return hexLabels_;
}
const List<int>& prismLabels() const
{
return prismLabels_;
}
const List<int>& pyrLabels() const
{
return pyrLabels_;
}
const List<int>& tetLabels() const
{
return tetLabels_;
}
label nHex() const
{
return hexLabels().size()/9;
}
label nPrism() const
{
return prismLabels().size()/7;
}
label nPyr() const
{
return pyrLabels().size()/6;
}
label nTet() const
{
return tetLabels().size()/5;
}
label nPoly() const
{
return nPoly_;
}
const labelListList& quadFaceLabels() const
{
return quadFaceLabels_;
}
const labelList& nPolyFaces() const
{
return nPolyFaces_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,37 +0,0 @@
#ifndef FV_READER_TAGS_H
#define FV_READER_TAGS_H
/* Numeric tags (codes) for FIELDVIEW binary file format. */
#define FV_MAGIC 0x00010203 /* decimal 66051 */
/* Content of the file (grid only, results only or combined). */
#define FV_GRIDS_FILE 1
#define FV_RESULTS_FILE 2
#define FV_COMBINED_FILE 3
#define FV_NODES 1001
#define FV_FACES 1002
#define FV_ELEMENTS 1003
#define FV_VARIABLES 1004
#define FV_BNDRY_VARS 1006
#define FV_ARB_POLY_FACES 1007
#define FV_ARB_POLY_ELEMENTS 1008
#define FV_ARB_POLY_BNDRY_VARS 1009
#define FV_TET_ELEM_ID 1
#define FV_HEX_ELEM_ID 2
#define FV_PRISM_ELEM_ID 3
#define FV_PYRA_ELEM_ID 4
#define FV_ARB_POLY_ELEM_ID 5
/* Values for "wall_info" array (see comments in fv_encode_elem_header). */
#ifdef __STDC__
#define A_WALL (07u)
#define NOT_A_WALL (0u)
#else
#define A_WALL (07)
#define NOT_A_WALL (0)
#endif
#endif /* FV_READER_TAGS_H */

View File

@ -1,68 +0,0 @@
HashSet<word> volScalarHash;
HashSet<word> volVectorHash;
HashSet<word> surfScalarHash;
HashSet<word> surfVectorHash;
HashSet<word> sprayScalarHash;
HashSet<word> sprayVectorHash;
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
// Add all fields to hashtable
IOobjectList objects(mesh, runTime.timeName());
{
wordList fieldNames(objects.names(volScalarField::typeName));
forAll(fieldNames, fieldI)
{
volScalarHash.insert(fieldNames[fieldI]);
}
}
{
wordList fieldNames(objects.names(volVectorField::typeName));
forAll(fieldNames, fieldI)
{
volVectorHash.insert(fieldNames[fieldI]);
}
}
{
wordList fieldNames(objects.names(surfaceScalarField::typeName));
forAll(fieldNames, fieldI)
{
surfScalarHash.insert(fieldNames[fieldI]);
}
}
{
wordList fieldNames(objects.names(surfaceVectorField::typeName));
forAll(fieldNames, fieldI)
{
surfVectorHash.insert(fieldNames[fieldI]);
}
}
// Same for spray
IOobjectList sprayObjects(mesh, runTime.timeName(), cloud::prefix);
{
wordList fieldNames(sprayObjects.names(scalarIOField::typeName));
forAll(fieldNames, fieldI)
{
sprayScalarHash.insert(fieldNames[fieldI]);
}
}
{
wordList fieldNames(sprayObjects.names(vectorIOField::typeName));
forAll(fieldNames, fieldI)
{
sprayVectorHash.insert(fieldNames[fieldI]);
}
}
}
wordList volScalarNames(volScalarHash.toc());
wordList volVectorNames(volVectorHash.toc());
wordList surfScalarNames(surfScalarHash.toc());
wordList surfVectorNames(surfVectorHash.toc());
wordList sprayScalarNames(sprayScalarHash.toc());
wordList sprayVectorNames(sprayVectorHash.toc());

View File

@ -1,34 +0,0 @@
//
// Check if new points (so moving mesh)
//
{
IOobject pointsHeader
(
"points",
runTime.timeName(),
polyMesh::defaultRegion,
runTime
);
if (pointsHeader.headerOk())
{
// points exists for time step, let's read them
Info<< " Points file detected - updating points" << endl;
// Reading new points
pointIOField newPoints
(
IOobject
(
"points",
runTime.timeName(),
polyMesh::defaultRegion,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
mesh.polyMesh::movePoints(newPoints);
}
}

View File

@ -1,97 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "writeFunctions.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// C++ version of fwrite_str80 from FieldView/uns/write_binary_uns.c
// Write padded string of 80 char.
bool writeStr80(std::ostream& os, const string& str)
{
char cBuf[80];
memset(cBuf, '\0', 80);
int len = str.size();
strncpy(cBuf, str.c_str(), (len < 80 ? len : 80));
os.write(cBuf, 80*sizeof(char));
return os.good();
}
// Write single integer
bool writeInt(std::ostream& os, int val1)
{
os.write(reinterpret_cast<char*>(&val1), sizeof(int));
return os.good();
}
// Write single float
bool writeFloat(std::ostream& os, scalar val1)
{
float floatVal = val1;
os.write(reinterpret_cast<char*>(&floatVal), sizeof(float));
return os.good();
}
// Debug: write raw bytes
void writeBytes(char* start, int nBytes)
{
cout.setf(std::ios::hex, std::ios::basefield);
cout<< start << " : ";
for (int i = 0; i < nBytes; i++)
{
cout<< " " << start[i];
}
cout << std::endl;
cout.setf(std::ios::dec);
}
// Debug: write wall flags data
void writeWallFlags(Ostream& os, label cellI, const labelList& wallFlags)
{
os << "cell " << cellI << " wallsFlags:";
forAll(wallFlags, wallFaceI)
{
os << wallFlags[wallFaceI] << ' ';
}
os << endl;
}
// ************************************************************************* //

View File

@ -1,56 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass
Foam::writeFunctions
Description
SourceFiles
writeFunctions.C
\*---------------------------------------------------------------------------*/
#ifndef writeFunctions_H
#define writeFunctions_H
#include "scalar.H"
#include "string.H"
#include "labelList.H"
#include <iostream>
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool writeStr80(std::ostream& os, const string& str);
bool writeInt(std::ostream& os, int val1);
bool writeFloat(std::ostream& os, scalar val1);
void writeBytes(char* start, int nBytes);
void writeWallFlags(Ostream& os, label cellI, const labelList& wallFlags);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,26 +0,0 @@
{
/* Output the magic number. */
writeInt(fvParticleFile, FV_MAGIC);
/* Output file header and version number. */
writeStr80(fvParticleFile, "FVPARTICLES");
/* version */
writeInt(fvParticleFile, 1);
writeInt(fvParticleFile, 1);
int nFields = sprayScalarNames.size() + 3*sprayVectorNames.size();
writeInt(fvParticleFile, nFields);
forAll(sprayScalarNames, nameI)
{
writeStr80(fvParticleFile, sprayScalarNames[nameI]);
}
forAll(sprayVectorNames, nameI)
{
const string& name(sprayVectorNames[nameI]);
writeStr80(fvParticleFile, name + ("x;" + name));
writeStr80(fvParticleFile, name + ("y;" + name));
writeStr80(fvParticleFile, name + ("z;" + name));
}
}

View File

@ -1,641 +0,0 @@
/*
** Support functions for writing a combined (grid and results) file
** in the binary FIELDVIEW unstructured format.
*/
/* Include system stuff for I/O and string and exit functions. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Include the defines for the FV_* codes and wall_info values. */
#include "fv_reader_tags.h"
/* Don't change these - used by fv_encode_elem_header ! */
#define MAX_NUM_ELEM_FACES 6
#define BITS_PER_WALL 3
#define ELEM_TYPE_BIT_SHIFT (MAX_NUM_ELEM_FACES*BITS_PER_WALL)
/*
** fv_encode_elem_header: return an encoded binary element header
**
** Input:
** elem_type: integer element type as shown in fv_reader_tags.h
** wall_info: array of integer "wall" flags, one for each face of
** the element. The wall flags are used during streamline
** calculation. Currently, the only meaningful values are
** A_WALL and NOT_A_WALL as shown in fv_reader_tags.h.
** Streamlines are forced away from faces marked as
** "A_WALL", by limiting velocity and position very near
** the wall.
** Output:
** Function return value is the encoded binary element header.
*/
#ifdef __STDC__
unsigned int fv_encode_elem_header (int elem_type, int wall_info[])
#else
unsigned int fv_encode_elem_header (elem_type, wall_info)
int elem_type;
int wall_info[];
#endif
{
unsigned int header;
int i, nfaces;
switch (elem_type)
{
case FV_TET_ELEM_ID:
header = (1 << ELEM_TYPE_BIT_SHIFT);
nfaces = 4;
break;
case FV_HEX_ELEM_ID:
header = (4 << ELEM_TYPE_BIT_SHIFT);
nfaces = 6;
break;
case FV_PRISM_ELEM_ID:
header = (3 << ELEM_TYPE_BIT_SHIFT);
nfaces = 5;
break;
case FV_PYRA_ELEM_ID:
header = (2 << ELEM_TYPE_BIT_SHIFT);
nfaces = 5;
break;
default:
fprintf(stderr, "ERROR: Unknown element type\n");
return 0;
}
for (i = 0; i < nfaces; i++)
{
unsigned int u = wall_info[i];
if (u > A_WALL)
{
fprintf(stderr, "ERROR: Bad wall value\n");
return 0;
}
header |= (u << (i*BITS_PER_WALL));
}
return header;
}
/*
** fwrite_str80: write out a string padded to 80 characters.
**
** Like fwrite, this returns the number of items written, which
** should be 80 if successful, and less than 80 if it failed.
*/
#ifdef __STDC__
size_t fwrite_str80 (char *str, FILE *fp)
#else
int fwrite_str80 (str, fp)
char *str;
FILE *fp;
#endif
{
char cbuf[80];
size_t len;
int i;
/* Most of this just to avoid garbage after the name. */
len = strlen(str);
strncpy(cbuf, str, len < 80 ? len : 80);
for (i = len; i < 80; i++)
cbuf[i] = '\0'; /* pad with zeros */
return fwrite(cbuf, sizeof(char), 80, fp);
}
/*
** Sample program which writes out a single unstructured grid containing
** four hex elements, with pressure and velocity data at the nodes, and
** surface data for temperature and velocity on some of the boundaries.
**
** The data is written as a combined (grid and results) file in the
** binary FIELDVIEW unstructured format.
**
** For simplicity, no error checking is done on the calls to fwrite
** and fwrite_str80.
*/
#if 0 /***** CHANGE THIS TO "#if 1" TO RUN THE SAMPLE PROGRAM. *****/
int main()
{
char *file_name = "quad_hex.uns";
FILE *outfp;
int num_grids = 1;
int num_face_types = 5;
/*
** Note that one of the boundary type names is "wall."
** The boundary name "wall" has no special meaning in FIELDVIEW.
** Boundary types and element walls are independent pieces of
** information. The only way to mark an element face as a wall
** (for streamline calculation) is with the wall_info array passed
** to fv_encode_elem_header.
*/
static char *face_type_names[5] = { "bottom", "top", "wall",
"trimmed cell", "hanging node cell"};
/*
** Each boundary type is flagged with 1 or 0 depending on
** whether surface results are present or absent (see below).
*/
static int results_flag[5] = { 1, 1, 0, 1, 1 };
/*
** Each boundary type is flagged with 1 or 0 depending on
** whether surface normals can be calculated from a "right
** hand rule" (see below).
*/
static int normals_flag[5] = { 1, 1, 0, 1, 1 };
/*
** Note that vector variables are specified by a ';' and vector name
** following the first scalar name of 3 scalar components of the
** vector. If writing 2-D results, the third component must still
** be provided here, and its values must be written in the variables
** section below (typically padded with zeros.)
*/
int num_vars = 4;
static char *var_names[4] = { "pressure", "uvel; velocity", "vvel", "wvel" };
int num_bvars = 4;
static char *bvar_names[4] = { "temperature", "uvel; velocity", "vvel", "wvel" };
unsigned int elem_header;
int grid, i;
int ibuf[10];
int nnodes = 31; /* Number of nodes in the grid. */
const int num_faces_trim_cell = 7;
const int num_faces_hang_cell = 6;
/* Constants. */
static float consts[4] = { 1., 0., 0., 0. };
/* XYZ coordinates of the nodes. */
static float x[31] = {-1., -1., 1., 1., -1., -1., 1., 1., -1., -1., 1.,1., 2., 2., 3., 3., 2.5, 3., 2., 3., 3., 2., 2.5,
3., 3., 3., 2.5, 2., 2., 2.0, 2.5};
static float y[31] = {-1., -1., -1., -1., 1., 1., 1., 1., 3., 3., 3., 3.,
0., 0., 0., 0., 0., .5, 1., 1., 1., 1., .5,
2., 2., 1.5, 2., 2., 2., 1.45, 1.5};
static float z[31] = {-1., 1., -1., 1., -1., 1., -1., 1., -1., 1., -1.,1., 1., 0., 0., .5, 1., 1., 1., 1., 0., 0., .5,
0., 1., 1., 1., 1., 0., 1., 1.};
/* hex1 and hex2 are hex elements, defined as an array of node numbers. */
static int hex1[8] = {1,2,3,4,5,6,7,8};
static int hex2[8] = {5,6,7,8,9,10,11,12};
/*
** Face definitions for boundary faces.
** All faces have 4 vertices. If the face is triangular,
** the last vertex should be zero.
*/
static int bot_faces[4] = { 1,2,4,3 };
static int top_faces[4] = { 9,10,12,11 };
static int wall_faces[8][4] =
{ {1,2,6,5}, {5,6,10,9}, {3,4,8,7}, {7,8,12,11},
{1,3,7,5}, {5,7,11,9}, {2,4,8,6}, {6,8,12,10} };
/* Arbitrary Polyhedron faces: */
static int trim_cell_face[num_faces_trim_cell][6] =
{ {5,13,14,15,16,17}, {3,16,18,17},
{5,15,21,20,18,16}, {5,13,17,18,20,19},
{4,13,19,22,14}, {4,14,22,21,15},
{4,19,20,21,22} };
static int hang_cell_face[num_faces_hang_cell][8] =
{ {5,20,21,24,25,26},
{5,24,29,28,27,25},
{7,20,26,25,27,28,30,19},
{4,20,19,22,21},
{4,21,22,29,24},
{5,22,19,30,28,29} };
/* Wall values for element faces. */
static int hex1_walls[6] = { A_WALL, A_WALL, NOT_A_WALL,
NOT_A_WALL, A_WALL, A_WALL };
static int hex2_walls[6] = { A_WALL, A_WALL, NOT_A_WALL,
NOT_A_WALL, A_WALL, A_WALL };
/* 4 variables (pressure and velocity values) at the 31 grid nodes. */
static float vars[4][31] =
{ {1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.10,1.11,
1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.10,1.11,
1.12,1.13,1.14,1.15,1.16,1.17,1.18},
{0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,
1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.10,1.11,
1.12,1.13,1.14,1.15,1.16,1.17,1.18},
{1.2,1.1,1.0,0.9,0.8,0.7,0.6,0.5,0.4,0.3,0.2,0.1,
1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.10,1.11,
1.12,1.13,1.14,1.15,1.16,1.17,1.18},
{0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,
1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.10,1.11,
1.12,1.13,1.14,1.15,1.16,1.17,1.18} };
/*
** 4 boundary variables (temperature and velocity values) defined on
** the single top face, and the the single bottom face.
*/
static float top_bvars[4] = { 1.0, 2.0,4.0,2.5 };
static float bot_bvars[4] = { 1.0, 4.5,3.0,3.0 };
/* Arbitrary Polyhedron boundary face variables: */
static float trim_cell_bvars[4][num_faces_trim_cell] =
{ {1.0,1.1,1.2,1.3,1.4,1.5,1.6},
{1.7,1.8,1.9,1.1,1.11,1.12,1.13},
{1.14,1.15,1.16,1.17,1.18,1.19,1.2},
{1.21,1.22,1.23,1.24,1.25,1.26,1.27} };
static float hang_cell_bvars[4][num_faces_hang_cell] =
{ {1.1,1.11,1.12,1.13,1.14,1.15},
{1.16,1.17,1.18,1.19,1.2,1.21},
{1.22,1.23,1.24,1.25,1.26,1.27},
{1.28,1.29,1.30,1.31,1.32,1.33} };
/* Open the file for binary write access. */
if ((outfp = fopen(file_name, "wb")) == NULL)
{
perror ("Cannot open output file");
exit(1);
}
/* Output the magic number. */
ibuf[0] = FV_MAGIC;
fwrite(ibuf, sizeof(int), 1, outfp);
/* Output file header and version number. */
fwrite_str80("FIELDVIEW", outfp);
/*
** This version of the FIELDVIEW unstructured file is "3.0".
** This is written as two integers.
*/
ibuf[0] = 3;
ibuf[1] = 0;
fwrite(ibuf, sizeof(int), 2, outfp);
/* File type code - new in version 2.7 */
ibuf[0] = FV_COMBINED_FILE;
fwrite(ibuf, sizeof(int), 1, outfp);
/* Reserved field, always write a zero - new in version 2.6 */
ibuf[0] = 0;
fwrite(ibuf, sizeof(int), 1, outfp);
/* Output constants for time, fsmach, alpha and re. */
fwrite(consts, sizeof(float), 4, outfp);
/* Output the number of grids. */
ibuf[0] = num_grids;
fwrite(ibuf, sizeof(int), 1, outfp);
/*
** Output the table of boundary types.
** Each boundary type is preceded by 2 integer flags.
** The first flag is an "surface results flag".
** A value of 1 means surface results will be present for this
** boundary type (if any boundary variables are specified in the
** boundary variable names table below).
** A value of 0 means no surface results will be present.
** The second flag indicates whether boundary faces of this type have
** consistent "clockness" for the purpose of calculating a surface
** normal. A value of 1 means that all faces of this type are
** written following a "right hand rule" for clockness. In other
** words, if the vertices are written on counter-clockwise:
** 4 --- 3
** | |
** 1 --- 2
** then the normal to the face is pointing towards you (not away
** from you). A value of 0 means that the faces do not have any
** consistent clockness. The "clockness" of surface normals is
** only used for calculating certain special surface integrals
** that involve surface normals. If the surface normals flag
** is 0, these special integrals will not be available.
*/
ibuf[0] = num_face_types;
fwrite(ibuf, sizeof(int), 1, outfp);
for (i = 0; i < num_face_types; i++) {
ibuf[0] = results_flag[i];
ibuf[1] = normals_flag[i];
fwrite(ibuf, sizeof(int), 2, outfp);
fwrite_str80(face_type_names[i], outfp);
}
/* Output the table of variable names. */
/* The number of variables can be zero. */
ibuf[0] = num_vars;
fwrite(ibuf, sizeof(int), 1, outfp);
for (i = 0; i < num_vars; i++)
fwrite_str80(var_names[i], outfp);
/*
** Output the table of boundary variable names.
** Boundary variables are associated with boundary faces, rather than
** with grid nodes.
** FIELDVIEW will automatically append "[BNDRY]" to each name
** so boundary variables can be easily distinguished from ordinary
** (grid node) variables.
** The number of boundary variables can be different from the number
** of ordinary variables. The number of boundary variables can be
** zero.
*/
ibuf[0] = num_bvars;
fwrite(ibuf, sizeof(int), 1, outfp);
for (i = 0; i < num_bvars; i++)
fwrite_str80(bvar_names[i], outfp);
/* Output grid data. */
for (grid = 0; grid < num_grids; grid++)
{
/* Output the node definition section for this grid. */
ibuf[0] = FV_NODES;
ibuf[1] = nnodes;
fwrite(ibuf, sizeof(int), 2, outfp);
/*
** Output the X, then Y, then Z node coordinates.
** Note that all of the X coordinates are output before any of
** the Y coordinates.
*/
fwrite(x, sizeof(float), nnodes, outfp);
fwrite(y, sizeof(float), nnodes, outfp);
fwrite(z, sizeof(float), nnodes, outfp);
/*
** Output boundary faces of the 3 different types.
** All faces have 4 vertices. If the face is triangular,
** the last vertex should be zero.
** TIP: A single boundary type can be broken into several sections
** if you prefer. Also, boundary face sections do not have to
** be in order. You may have a section of 10 faces of type 3,
** followed by a section of 20 faces of type 2, followed by a
** section of 15 more faces of type 3. Breaking a boundary
** type into very many short sections is less efficient. The
** boundaries will require more memory and be somewhat
** slower to calculate in FIELDVIEW.
**
*/
ibuf[0] = FV_FACES;
ibuf[1] = 1; /* first boundary type */
ibuf[2] = 1; /* number of faces of this type */
fwrite(ibuf, sizeof(int), 3, outfp);
fwrite(bot_faces, sizeof(int), 4, outfp);
ibuf[0] = FV_FACES;
ibuf[1] = 2; /* second boundary type */
ibuf[2] = 1; /* number of faces of this type */
fwrite(ibuf, sizeof(int), 3, outfp);
fwrite(top_faces, sizeof(int), 4, outfp);
ibuf[0] = FV_FACES;
ibuf[1] = 3; /* third boundary type */
ibuf[2] = 8; /* number of faces of this type */
fwrite(ibuf, sizeof(int), 3, outfp);
fwrite(wall_faces, sizeof(int), 8*4, outfp);
/* Arbitrary Polygon boundary faces:
** The format (in psuedocode) is as follows:
** >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
** FV_ARB_POLY_FACES (section header)
** BndryFaceType NumBndryFaces
**
** [for N = 1, NumBndryFaces]
** NumVertsFaceN Vert1 Vert2 ... Vert{NumVertsFaceN}
**
** <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
** * The above block should be repeated for different boundary face
** types, as is the case for standard boundary faces.
** * These blocks should be after the blocks for standard faces,
** within the FIELDVIEW-Uns file.
** * The node ordering for specifying faces should follow a
** right-handed rule with the normal pointing away from the
** cell center. So nodes should be given by traversing the face
** in a counter-clockwise manner.
** * Hanging nodes are not permitted on boundary faces.
*/
ibuf[0] = FV_ARB_POLY_FACES;
ibuf[1] = 4; /* boundary face type */
ibuf[2] = 7; /* num faces for the trimmed cell */
fwrite(ibuf, sizeof(int), 3, outfp);
for (i = 0; i < num_faces_trim_cell; ++i) /* loop over the faces */
fwrite(trim_cell_face[i], sizeof(int), trim_cell_face[i][0] + 1,
outfp);
ibuf[0] = FV_ARB_POLY_FACES;
ibuf[1] = 5; /* boundary face type */
ibuf[2] = 6; /* num faces for the hanging node cell */
fwrite(ibuf, sizeof(int), 3, outfp);
for (i = 0; i < num_faces_hang_cell; ++i) /* loop over the faces */
fwrite(hang_cell_face[i], sizeof(int), hang_cell_face[i][0] + 1,
outfp);
/*
** Start an elements section.
** There may be as many elements sections as needed.
** Each section may contain a single element type or a
** mixture of element types.
** For maximum efficiency, each section should contain
** a significant percentage of the elements in the grid.
** The most efficient case is a single section containing
** all elements in the grid.
*/
ibuf[0] = FV_ELEMENTS;
ibuf[1] = 0; /* tet count */
ibuf[2] = 2; /* hex count */
ibuf[3] = 0; /* prism count */
ibuf[4] = 0; /* pyramid count */
fwrite(ibuf, sizeof(int), 5, outfp);
/* Write header for first element. */
elem_header = fv_encode_elem_header(FV_HEX_ELEM_ID, hex1_walls);
if (elem_header == 0)
{
fprintf (stderr, "fv_encode_elem_header failed for first hex.\n");
exit(1);
}
fwrite (&elem_header, sizeof(elem_header), 1, outfp);
/* Write node definition for first element. */
fwrite(hex1, sizeof(int), 8, outfp);
/* Write header for second element. */
elem_header = fv_encode_elem_header(FV_HEX_ELEM_ID, hex2_walls);
if (elem_header == 0)
{
fprintf (stderr, "fv_encode_elem_header failed for second hex.\n");
exit(1);
}
fwrite (&elem_header, sizeof(elem_header), 1, outfp);
/* Write node definition for second element. */
fwrite(hex2, sizeof(int), 8, outfp);
/* Arbitrary Polyhedron elements:
** The format (in psuedocode) is as follows:
** >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
** FV_ARB_POLY_ELEMENTS (section header)
** NumArbPolyElements
**
** [for elem = 1, NumArbPolyElements]
** {
** NumFaces NumNodesElement CenterNode
**
** [for face = 1, NumFaces]
** WallFlag NumNodesFace FaceNode1 ... FaceNode{NumNodesFace}
** NumHangNodes HangNode1 ... HangNode{NumHangNodes}
** }
** <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
** * These blocks can be after or before the standard element blocks.
** There can be any number of these for any one grid.
** * The WallFlag has the same meaning as for standard elements,
** i.e., A_WALL or NOT_A_WALL.
** * The node ordering for specifying faces should follow a
** right-handed rule with the normal pointing away from the
** cell center. So nodes should be given by traversing the face
** in a counter-clockwise manner.
** * Hanging nodes are associated with a face interior and should
** not be on an edge. Hanging nodes on an edge should be
** interpretted as a regular face node.
*/
ibuf[0] = FV_ARB_POLY_ELEMENTS;
ibuf[1] = 2; /* have 2 elements here */
fwrite(ibuf, sizeof(int), 2, outfp);
/* trimmed face element */
ibuf[0] = 7; /* num faces for the trimmed cell */
ibuf[1] = 11; /* number of nodes including a center node */
ibuf[2] = 23; /* the center node */
fwrite(ibuf, sizeof(int), 3, outfp);
ibuf[0] = A_WALL; /* wall value */
ibuf[1] = 0; /* number of hanging nodes */
for (i = 0; i < num_faces_trim_cell; ++i) /* write out face info */
{
fwrite(ibuf, sizeof(int), 1, outfp); /* write wall value */
fwrite(trim_cell_face[i], sizeof(int), trim_cell_face[i][0] + 1,
outfp); /* write num verts and verts */
fwrite(&ibuf[1], sizeof(int), 1, outfp); /* write num hang nodes */
}
/* hanging node element */
ibuf[0] = 6; /* num faces for the hanging node cell */
ibuf[1] = 12; /* number of nodes excluding a center node */
ibuf[2] = -1; /* the center node, this indicates that FIELDVIEW
** should calculate the center node and associated
** centernode variable values
*/
fwrite(ibuf, sizeof(int), 3, outfp);
ibuf[0] = A_WALL; /* wall value */
ibuf[1] = 0; /* number of hanging nodes */
ibuf[2] = 1; /* number of hanging nodes for face 3 */
ibuf[3] = 31; /* the node number for the hanging node on face 3*/
for (i = 0; i < 2; ++i) /* write out face info for first 2 faces */
{
fwrite(ibuf, sizeof(int), 1, outfp); /* write wall value */
fwrite(hang_cell_face[i], sizeof(int), hang_cell_face[i][0] + 1,
outfp); /* write num verts and verts */
fwrite(&ibuf[1], sizeof(int), 1, outfp); /* write num hang nodes */
}
/* this face has a hanging node */
fwrite(ibuf, sizeof(int), 1, outfp);
fwrite(hang_cell_face[2], sizeof(int), hang_cell_face[2][0] + 1, outfp);
fwrite(&ibuf[2], sizeof(int), 2, outfp);
/* write out face info for last 3 faces */
for (i = 3; i < num_faces_hang_cell; ++i)
{
fwrite(ibuf, sizeof(int), 1, outfp); /* write wall value */
fwrite(hang_cell_face[i], sizeof(int), hang_cell_face[i][0] + 1,
outfp); /* write num verts and verts */
fwrite(&ibuf[1], sizeof(int), 1, outfp); /* write num hang nodes */
}
/*
** Output the variables data.
** You must write the section header even if the number
** of variables is zero.
*/
ibuf[0] = FV_VARIABLES;
fwrite(ibuf, sizeof(int), 1, outfp);
/*
** Note that all of the data for the first variable is output
** before any of the data for the second variable.
*/
for (i = 0; i < num_vars; i++)
fwrite(vars[i], sizeof(float), nnodes, outfp);
/*
** Output the boundary variables data.
** Remember that the Boundary Table above has a "surface results
** flag" indicating which boundary types have surface results.
** The data should be written in the same order as the faces in
** the Boundary Faces section, skipping over faces whose boundary
** type has a surface results flag of zero (false).
** For each variable, you should write one number per boundary face.
** You must write the section header even if the number of boundary
** variables is zero.
*/
ibuf[0] = FV_BNDRY_VARS;
fwrite(ibuf, sizeof(int), 1, outfp);
/*
** Note that all of the data for the first variable is output
** before any of the data for the second variable.
*/
for (i = 0; i < num_bvars; i++) {
int num_faces;
/*
** The data for the bottom face is written first for each
** variable, because the bottom face was written first in the
** "Boundary Faces" section.
** The "wall" faces are skipped, because the surface results
** flag for the wall boundary type was 0 (false) in the
** Boundary Table section.
*/
num_faces = 1; /* number of bottom faces */
fwrite(&bot_bvars[i], sizeof(float), num_faces, outfp);
num_faces = 1; /* number of top faces */
fwrite(&top_bvars[i], sizeof(float), num_faces, outfp);
}
/* Arbitrary Polyhedron boundary face results:
** The format is the same as for standard boundary face results.
*/
ibuf[0] = FV_ARB_POLY_BNDRY_VARS;
fwrite(ibuf, sizeof(int), 1, outfp);
for (i = 0; i < num_bvars; ++i)
{
int num_faces;
num_faces = 7; /* num faces for the trimmed cell */
fwrite(trim_cell_bvars[i], sizeof(float), num_faces, outfp);
num_faces = 6; /* num faces for the hanging node cell */
fwrite(hang_cell_bvars[i], sizeof(float), num_faces, outfp);
}
}
if (fclose(outfp) != 0)
{
perror ("Cannot close output file");
exit(1);
}
return 0;
}
#endif /* end commenting out the sample program */

View File

@ -1,10 +0,0 @@
#!/bin/sh
# disabled
# if [ "$FV_HOME" -a -r $FV_HOME ]
# then
# wmake fieldview9Reader
# fi
# ----------------------------------------------------------------- end-of-file

View File

@ -1,5 +0,0 @@
errno.c
readerDatabase.C
fieldview9Reader.C
EXE = $(FOAM_APPBIN)/fvbinFoam

View File

@ -1,103 +0,0 @@
/*
* Note: compilation options takes from ld_fv script from Fieldview9.
* Only Linux tested.
*
*/
#if defined(linux) || defined(linux64)
FV_LIBS = \
$(FV_HOME)/user/obj/linux_x86/fv.o \
-lGL -lGLU -lXmu -lXp -lXt $(XLIBS) -ldl
#elif defined(solaris) || defined(solarisGcc)
FV_LIBS = \
$(FV_HOME)/user/obj/solaris/fv.o \
-i \
-L/usr/dt/lib -R/usr/dt/lib -lMrm -lXm \
-L/opt/SUNWits/Graphics-sw/xgl-3.0/lib \
-R/opt/SUNWits/Graphics-sw/xgl-3.0/lib -lxgl \
-L/usr/openwin/lib -R/usr/openwin/lib \
-L$(FV_HOME)/user/obj/solaris \
-lGL -lGLU -lXt $(XLIBS) \
-lgen -lnsl -lsocket -lw -lintl -ldl
#elif defined(sgiN32) || defined(sgiN32Gcc)
FV_LIBS = \
$(FV_HOME)/user/obj/iris/fv.o \
$(FV_HOME)/user/obj/iris/fv2.o \
$(FV_HOME)/user/obj/iris/fv3.o \
$(FV_HOME)/user/obj/iris/netserver.o \
$(FV_HOME)/user/obj/iris/pV_Server.o \
$(FV_HOME)/user/obj/iris/dore.o \
$(FV_HOME)/user/obj/iris/libpV3ser.a \
$(FV_HOME)/user/obj/iris/libgpvm3.a \
$(FV_HOME)/user/obj/iris/libpvm3.a \
$(FV_HOME)/user/obj/iris/libBLT.a \
$(FV_HOME)/user/obj/iris/libtk8.2.a \
$(FV_HOME)/user/obj/iris/libtcl8.2.a \
-lGL -lGLU -lgl \
-lMrm -lXm -lXt $(XLIBS) -lPW \
-lftn -lc
#elif defined(sgi64) || defined(sgi64Gcc)
FV_LIBS = \
$(FV_HOME)/user/obj/iris64/fv.o \
$(FV_HOME)/user/obj/iris64/fv2.o \
$(FV_HOME)/user/obj/iris64/fv3.o \
$(FV_HOME)/user/obj/iris64/netserver.o \
$(FV_HOME)/user/obj/iris64/pV_Server.o \
$(FV_HOME)/user/obj/iris64/dore.o \
$(FV_HOME)/user/obj/iris64/libpV3ser.a \
$(FV_HOME)/user/obj/iris64/libgpvm3.a \
$(FV_HOME)/user/obj/iris64/libpvm3.a \
$(FV_HOME)/user/obj/iris64/libBLT.a \
$(FV_HOME)/user/obj/iris64/libtk8.2.a \
$(FV_HOME)/user/obj/iris64/libtcl8.2.a \
-lGL -lGLU \
-lMrm -lXm -lXt $(XLIBS) -lPW \
-lftn -lc
#elif defined(ibm) || defined(ibmGcc)
FV_LIBS = \
-bh:4 -T512 -H512 \
-bmaxdata:0x60000000 \
$(FV_HOME)/user/obj/ibm_rs/fv.o \
-L/usr/lib -L$(FV_HOME)/user/obj/ibm_rs \
-lMrm -lXm -lXt -lX11 -lxlf90 \
-lGL -lGLU -lXext \
-lm -lc -lPW -lIM -lgl
#elif defined(hpux)
FV_LIBS = \
$(FV_HOME)/user/obj/hp_700/fv.o \
-L/opt/graphics/common/lib \
-L/usr/lib/Motif1.2 \
-L/opt/graphics/OpenGL/lib \
-L$(FV_HOME)/user/obj/hp_700 \
-lGL -lGLU -lXext \
-lXwindow -lhpgfx \
-lXhp11 -lMrm -lXm -lXt -lX11 \
-lM -lc -lPW -ldld -ldce $endlib \
-Wl,+b: -Wl,+s
#endif
EXE_INC = \
-I$(FV_HOME)/uns \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/browser/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
EXE_LIBS = \
$(FV_LIBS) \
-lfiniteVolume \
-lgenericPatchFields \
-lmeshTools

View File

@ -1,56 +0,0 @@
Fieldview9 reader module
------------------------
This is a version of the fvbin executable with a built-in reader for Foam
data.
1] Limitations
--------------
- only volScalarFields and volVectorFields and only on points, not on boundary.
- handles polyhedra by decomposition (introduces cell centre)
- no surface fields, no lagrangian fields, no tetFem fields.
- does not run in parallel
2] Building
-----------
It has only been tested on Linux. Other platforms should build with a little
bit of effort. Have a look at the Fieldview link script and see which options
you need to add to Make/options to make it build.
Instructions:
0. Make sure FV_HOME is set to the root of the FieldView installation.
(i.e. $FV_HOME/user should exist)
1. Add $FV_HOME/bin to your path and make sure you can actually run fv.
2. Make the new fv executable by typing
wmake
This should create an 'fvbinFoam' executable.
3. On Linux you can directly run this executable instead of through the 'fv'
script. On other machines you might have to backup the old $FV_HOME/bin/fvbin
executable and move the fvbinFoam one into its position. Now you can use the
fv script to start it all up.
3] Running
----------
After starting it up (see step above) you should have a 'Foam Reader' under
the 'Data Files' pull-down menu. This will open a file selection box. Go to the
case directory and click on any file. The reader will recognize that the
current directory is a case directory (it has checks for a 'constant' directory)
and start reading the mesh. It will
pop-up a box with time steps and a list of variables as usual.
In case of a case with topology changes (i.e. more than one mesh) it
will ask for the time step a second time. This is due to a limitation in
Fieldview. Choose the same time as before.
In the terminal window it will print various informational messages.
A not fairly well tested feature is cellSet displaying. Instead of selecting
a case directory selecting a cellSet (in a polyMesh/sets/ directory) it
will try to subset the mesh using the selected cellSet. It is not possible
to display fields on subsetted meshes.

View File

@ -1,340 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "readerDatabase.H"
#include "demandDrivenData.H"
#include "fvMesh.H"
#include "fvMeshSubset.H"
#include "Time.H"
#include "fileName.H"
#include "instant.H"
#include "cellSet.H"
#include "cellModeller.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const bool Foam::readerDatabase::debug_ = Foam::env("readerDatabase");
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Gets cell numbers of all polyHedra
void Foam::readerDatabase::getPolyHedra()
{
const cellModel& tet = *(cellModeller::lookup("tet"));
const cellModel& pyr = *(cellModeller::lookup("pyr"));
const cellModel& prism = *(cellModeller::lookup("prism"));
const cellModel& wedge = *(cellModeller::lookup("wedge"));
const cellModel& tetWedge = *(cellModeller::lookup("tetWedge"));
const cellModel& hex = *(cellModeller::lookup("hex"));
DynamicList<label> polys(mesh().nCells()/100 + 1);
const cellShapeList& cellShapes = mesh().cellShapes();
forAll(cellShapes, celli)
{
const cellShape& cellShape = cellShapes[celli];
const cellModel& cellModel = cellShape.model();
if
(
(cellModel != tet)
&& (cellModel != pyr)
&& (cellModel != prism)
&& (cellModel != wedge)
&& (cellModel != tetWedge)
&& (cellModel != hex)
)
{
polys.append(celli);
}
}
Info<< "Found " << polys.size() << " polyhedral cells " << endl;
polys_.transfer(polys);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Null constructor
Foam::readerDatabase::readerDatabase()
:
fieldviewNames_(10),
runTimePtr_(NULL),
meshPtr_(NULL),
setName_(""),
polys_(),
volScalarNames_(),
volVectorNames_()
{
// Initialize name mapping table. See note on static in header file.
fieldviewNames_.insert("alpha", "aalpha");
fieldviewNames_.insert("Alpha", "AAlpha");
fieldviewNames_.insert("fsmach", "ffsmach");
fieldviewNames_.insert("FSMach", "FFSMach");
fieldviewNames_.insert("re", "rre");
fieldviewNames_.insert("Re", "RRe");
fieldviewNames_.insert("time", "ttime");
fieldviewNames_.insert("Time", "TTime");
fieldviewNames_.insert("pi", "ppi");
fieldviewNames_.insert("PI", "PPI");
fieldviewNames_.insert("x", "xx");
fieldviewNames_.insert("X", "XX");
fieldviewNames_.insert("y", "yy");
fieldviewNames_.insert("Y", "YY");
fieldviewNames_.insert("z", "zz");
fieldviewNames_.insert("Z", "ZZ");
fieldviewNames_.insert("rcyl", "rrcyl");
fieldviewNames_.insert("Rcyl", "RRcyl");
fieldviewNames_.insert("theta", "ttheta");
fieldviewNames_.insert("Theta", "TTheta");
fieldviewNames_.insert("rsphere", "rrsphere");
fieldviewNames_.insert("Rsphere", "RRsphere");
fieldviewNames_.insert("k", "kk");
fieldviewNames_.insert("K", "KK");
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::readerDatabase::~readerDatabase()
{
deleteDemandDrivenData(meshPtr_);
deleteDemandDrivenData(runTimePtr_);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::Time& Foam::readerDatabase::runTime() const
{
if (!runTimePtr_)
{
FatalErrorIn("readerDatabase::runTime()")
<< "No database set" << abort(FatalError);
}
return *runTimePtr_;
}
const Foam::fvMesh& Foam::readerDatabase::mesh() const
{
if (!meshPtr_)
{
FatalErrorIn("readerDatabase::runTime()")
<< "No mesh set" << abort(FatalError);
}
if (setName_.empty())
{
return *meshPtr_;
}
else
{
return meshPtr_->subMesh();
}
}
const Foam::labelList& Foam::readerDatabase::polys() const
{
return polys_;
}
const Foam::wordList& Foam::readerDatabase::volScalarNames() const
{
return volScalarNames_;
}
const Foam::wordList& Foam::readerDatabase::volVectorNames() const
{
return volVectorNames_;
}
const Foam::word& Foam::readerDatabase::getFvName(const word& foamName) const
{
if (fieldviewNames_.found(foamName))
{
return fieldviewNames_[foamName];
}
else
{
return foamName;
}
}
bool Foam::readerDatabase::setRunTime
(
const fileName& rootDir,
const fileName& caseName,
const word& setName
)
{
bool newDatabase = false;
if (runTimePtr_)
{
if
(
(runTimePtr_->caseName() != caseName)
|| (runTimePtr_->rootPath() != rootDir)
|| (setName_ != setName)
)
{
if (debug_)
{
Info<< "Deleting old mesh since deleting old database" << endl;
}
deleteDemandDrivenData(meshPtr_);
if (debug_)
{
Info<< "Deleting old database for " << runTimePtr_->caseName()
<< endl;
}
deleteDemandDrivenData(runTimePtr_);
}
}
setName_ = setName;
if (!runTimePtr_)
{
if (debug_)
{
Info<< "Deleting old mesh since loading new Time" << endl;
}
deleteDemandDrivenData(meshPtr_);
if (debug_)
{
Info<< "Creating database for " << caseName << endl;
}
runTimePtr_ = new Time(Time::controlDictName, rootDir, caseName);
newDatabase = true;
}
return newDatabase;
}
void Foam::readerDatabase::loadMesh()
{
deleteDemandDrivenData(meshPtr_);
Info<< "Loading new mesh" << endl;
meshPtr_ = new fvMeshSubset
(
*runTimePtr_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
);
if (setName_.size())
{
Info<< "Subsetting mesh based on cellSet " << setName_ << endl;
fvMeshSubset& mesh = *meshPtr_;
cellSet currentSet(mesh, setName_);
mesh.setCellSubset(currentSet);
}
getPolyHedra();
}
Foam::polyMesh::readUpdateState Foam::readerDatabase::setTime
(
const instant& timeInstance,
const label timeIndex
)
{
runTime().setTime(timeInstance, timeIndex);
polyMesh::readUpdateState meshChange;
if (meshPtr_)
{
// Update loaded mesh
meshChange = meshPtr_->readUpdate();
if (setName_.size() && meshChange != polyMesh::UNCHANGED)
{
Info<< "Subsetting mesh based on " << setName_ << endl;
fvMeshSubset& mesh = *meshPtr_;
cellSet currentSet(mesh, setName_);
mesh.setCellSubset(currentSet);
}
if
(
(meshChange == polyMesh::TOPO_CHANGE)
|| (meshChange == polyMesh::TOPO_PATCH_CHANGE)
)
{
getPolyHedra();
}
}
else
{
// Force new mesh to be loaded for current time
loadMesh();
meshChange = polyMesh::TOPO_CHANGE;
}
return meshChange;
}
void Foam::readerDatabase::setFieldNames
(
const wordList& vsNames,
const wordList& vvNames
)
{
volScalarNames_ = vsNames;
volVectorNames_ = vvNames;
}
// ************************************************************************* //

View File

@ -1,172 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::readerDatabase
Description
Singleton caching OpenFOAM database and mesh and various.
Used in Fv reader to keep track of data in between callbacks.
SourceFiles
readerDatabase.C
\*---------------------------------------------------------------------------*/
#ifndef readerDatabase_H
#define readerDatabase_H
#include "wordList.H"
#include "Time.H"
#include "polyMesh.H"
#include "label.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class fvMesh;
class fvMeshSubset;
class Time;
class fileName;
class instant;
/*---------------------------------------------------------------------------*\
Class readerDatabase Declaration
\*---------------------------------------------------------------------------*/
class readerDatabase
{
// Private data
//- Names for protected Fieldview keywords. Gets set at construction
// time.
// Note: Should be static but this gives problem with construction
// order since *this is static as well.
HashTable<word> fieldviewNames_;
// Private data
//- Cached database
Time* runTimePtr_;
//- Cached mesh, guaranteed uptodate with runTime.
fvMeshSubset* meshPtr_;
//- Empty string or name of current set.
word setName_;
//- Cell labels of polyHedra. Uptodate with meshPtr.
labelList polys_;
//- All volScalarFields in all time directories
wordList volScalarNames_;
//- All volVectorFields ,,
wordList volVectorNames_;
// Private Member Functions
//- Gets cell numbers of all polyHedra
void getPolyHedra();
//- Disallow default bitwise copy construct
readerDatabase(const readerDatabase&);
//- Disallow default bitwise assignment
void operator=(const readerDatabase&);
public:
// Static
//- Debug flag. Note: uses envvar instead of controlDict since
// *this is static as well. Might be initialized before controlDict
// read.
static const bool debug_;
// Constructors
//- Construct null
readerDatabase();
//- Destructor
~readerDatabase();
// Member Functions
// Access
const Time& runTime() const;
const fvMesh& mesh() const;
const labelList& polys() const;
const wordList& volScalarNames() const;
const wordList& volVectorNames() const;
//- Get fieldview compatible name.
const word& getFvName(const word& foamName) const;
// Edit
//- Create database (if nessecary).
// Returns true if new Time created, false if old one reused.
// Optional fvMeshSubset using setName.
bool setRunTime
(
const fileName& rootDir,
const fileName& caseName,
const word& setName
);
//- Forcibly load mesh.
void loadMesh();
//- Set time (use this instead of database::setTime), updates
// mesh as well and returns mesh update status
polyMesh::readUpdateState setTime(const instant&, const label);
//- Set volScalarNames, volVectorNames.
void setFieldNames(const wordList&, const wordList&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -27,6 +27,7 @@ $(derivedSources)/rotorDiskSource/trimModel/trimModel/trimModel.C
$(derivedSources)/rotorDiskSource/trimModel/trimModel/trimModelNew.C
$(derivedSources)/rotorDiskSource/trimModel/fixed/fixedTrim.C
$(derivedSources)/rotorDiskSource/trimModel/targetCoeff/targetCoeffTrim.C
$(derivedSources)/heatExchangerSource/heatExchangerSource.C
interRegion = sources/interRegion
$(interRegion)/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.C
@ -36,6 +37,7 @@ $(interRegion)/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTra
$(interRegion)/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C
/* constraints */
generalConstraints=constraints/general

View File

@ -0,0 +1,338 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*----------------------------------------------------------------------------*/
#include "heatExchangerSource.H"
#include "fvMesh.H"
#include "fvMatrix.H"
#include "addToRunTimeSelectionTable.H"
#include "basicThermo.H"
#include "coupledPolyPatch.H"
#include "surfaceInterpolate.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(heatExchangerSource, 0);
addToRunTimeSelectionTable
(
option,
heatExchangerSource,
dictionary
);
}
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::fv::heatExchangerSource::init()
{
const faceZone& fZone = mesh_.faceZones()[zoneID_];
faceId_.setSize(fZone.size());
facePatchId_.setSize(fZone.size());
faceSign_.setSize(fZone.size());
label count = 0;
forAll(fZone, i)
{
label faceI = fZone[i];
label faceId = -1;
label facePatchId = -1;
if (mesh_.isInternalFace(faceI))
{
faceId = faceI;
facePatchId = -1;
}
else
{
facePatchId = mesh_.boundaryMesh().whichPatch(faceI);
const polyPatch& pp = mesh_.boundaryMesh()[facePatchId];
if (isA<coupledPolyPatch>(pp))
{
if (refCast<const coupledPolyPatch>(pp).owner())
{
faceId = pp.whichFace(faceI);
}
else
{
faceId = -1;
}
}
else if (!isA<emptyPolyPatch>(pp))
{
faceId = faceI - pp.start();
}
else
{
faceId = -1;
facePatchId = -1;
}
}
if (faceId >= 0)
{
if (fZone.flipMap()[i])
{
faceSign_[count] = -1;
}
else
{
faceSign_[count] = 1;
}
faceId_[count] = faceId;
facePatchId_[count] = facePatchId;
count++;
}
}
faceId_.setSize(count);
facePatchId_.setSize(count);
faceSign_.setSize(count);
calculateTotalArea(faceZoneArea_);
}
void Foam::fv::heatExchangerSource::addHeatSource
(
scalarField& heSource,
const labelList& cells,
const scalarField& Vcells,
const vectorField& U,
const scalar Qt,
const scalarField& deltaTCells,
const scalar totHeat
) const
{
forAll(cells, i)
{
heSource[cells[i]] -=
Qt*Vcells[cells[i]]*mag(U[cells[i]])*deltaTCells[i]/totHeat;
}
}
void Foam::fv::heatExchangerSource::calculateTotalArea(scalar& var)
{
var = 0;
forAll(faceId_, i)
{
label faceI = faceId_[i];
if (facePatchId_[i] != -1)
{
label patchI = facePatchId_[i];
var += mesh_.magSf().boundaryField()[patchI][faceI];
}
else
{
var += mesh_.magSf()[faceI];
}
}
reduce(var, sumOp<scalar>());
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::heatExchangerSource::heatExchangerSource
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
option(name, modelType, dict, mesh),
secondaryMassFlowRate_(readScalar(coeffs_.lookup("secondaryMassFlowRate"))),
secondaryInletT_(readScalar(coeffs_.lookup("secondaryInletT"))),
primaryInletT_(readScalar(coeffs_.lookup("primaryInletT"))),
eTable_(),
UName_(coeffs_.lookupOrDefault<word>("UName", "U")),
TName_(coeffs_.lookupOrDefault<word>("TName", "T")),
phiName_(coeffs_.lookupOrDefault<word>("phiName", "phi")),
faceZoneName_(coeffs_.lookup("faceZone")),
zoneID_(mesh_.faceZones().findZoneID(faceZoneName_)),
faceId_(),
facePatchId_(),
faceSign_(),
faceZoneArea_(0)
{
if (zoneID_ < 0)
{
FatalErrorIn
(
"heatExchangerSource::heatExchangerSource"
"("
" const word& name,"
" const word& modelType,"
" const dictionary& dict,"
" const fvMesh& mesh"
")"
)
<< type() << " " << this->name() << ": "
<< " Unknown face zone name: " << faceZoneName_
<< ". Valid face zones are: " << mesh_.faceZones().names()
<< nl << exit(FatalError);
}
coeffs_.lookup("fieldNames") >> fieldNames_;
applied_.setSize(fieldNames_.size(), false);
eTable_.reset(new interpolation2DTable<scalar>(coeffs_));
init();
Info<< " - creating heatExchangerSource: "
<< this->name() << endl;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fv::heatExchangerSource::addSup
(
fvMatrix<scalar>& eqn,
const label
)
{
const basicThermo& thermo =
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
const surfaceScalarField Cpf = fvc::interpolate(thermo.Cp());
const surfaceScalarField& phi =
mesh_.lookupObject<surfaceScalarField>(phiName_);
scalar totalphi = 0;
scalar CpfMean = 0;
forAll(faceId_, i)
{
label faceI = faceId_[i];
if (facePatchId_[i] != -1)
{
label patchI = facePatchId_[i];
totalphi += phi.boundaryField()[patchI][faceI]*faceSign_[i];
CpfMean +=
Cpf.boundaryField()[patchI][faceI]
* mesh_.magSf().boundaryField()[patchI][faceI];
}
else
{
totalphi += phi[faceI]*faceSign_[i];
CpfMean += Cpf[faceI]*mesh_.magSf()[faceI];
}
}
reduce(CpfMean, sumOp<scalar>());
reduce(totalphi, sumOp<scalar>());
scalar Qt =
eTable_()(mag(totalphi), secondaryMassFlowRate_)
* (secondaryInletT_ - primaryInletT_)
* (CpfMean/faceZoneArea_)*mag(totalphi);
const volScalarField& T = mesh_.lookupObject<volScalarField>(TName_);
const scalarField TCells(T, cells_);
scalar Tref = 0;
if (Qt > 0)
{
Tref = max(TCells);
reduce(Tref, maxOp<scalar>());
}
else
{
Tref = min(TCells);
reduce(Tref, minOp<scalar>());
}
scalarField deltaTCells(cells_.size(), 0);
forAll(deltaTCells, i)
{
if (Qt > 0)
{
deltaTCells[i] = max(Tref - TCells[i], 0.0);
}
else
{
deltaTCells[i] = max(TCells[i] - Tref, 0.0);
}
}
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
const scalarField& cellsV = mesh_.V();
scalar totHeat = 0;
forAll(cells_, i)
{
totHeat += cellsV[cells_[i]]*mag(U[cells_[i]])*deltaTCells[i];
}
reduce(totHeat, sumOp<scalar>());
scalarField& heSource = eqn.source();
if (V() > VSMALL && mag(Qt) > VSMALL)
{
addHeatSource(heSource, cells_, cellsV, U, Qt, deltaTCells, totHeat);
}
if (debug && Pstream::master())
{
Info<< indent << "Net mass flux [Kg/s] = " << totalphi << nl;
Info<< indent << "Total energy exchange [W] = " << Qt << nl;
Info<< indent << "Tref [K] = " << Tref << nl;
Info<< indent << "Efficiency : "
<< eTable_()(mag(totalphi), secondaryMassFlowRate_) << endl;
}
}
void Foam::fv::heatExchangerSource::writeData(Ostream& os) const
{
os << indent << name_ << endl;
dict_.write(os);
}
bool Foam::fv::heatExchangerSource::read(const dictionary& dict)
{
if (option::read(dict))
{
coeffs_.lookup("secondaryMassFlowRate") >> secondaryMassFlowRate_;
coeffs_.lookup("secondaryInletT") >> secondaryInletT_;
coeffs_.lookup("primaryInletT") >> primaryInletT_;
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,237 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::fv::heatExchangerSource
Description
Heat exchanger source model.
The total heat exchange is given by:
Qt = e(phi, secondaryMassFlowRate)
* (secondaryInletT - primaryInletT)
* phi*Cp;
where:
e(phi, secondaryMassFlowRate) is a effectivenes table in function of
mass net flux coming imto the heat exchanger (phi) and
secondaryMassFlowRate
Then the distribution inside the hear exchanger is given by:
Qcell = V*Ucell*(Tcell - Tref)/sum(V*Ucell*(Tcell - Tref));
where:
Qcell is the source for cell
V is the volume of the cell
Ucell is the local cell velocity
Tcell is the local call temperature
Tref : min(T) or max(T) in the cell zone depending on the sign of Qt
Example :
heatExchangerSource1
{
type heatExchangerSource;
active true;
selectionMode cellZone;
cellZone porosity;
heatExchangerSourceCoeffs
{
fieldNames (e);
secondaryMassFlowRate 1.0;
secondaryInletT 336;
primaryInletT 293;
faceZone facesZoneInletOriented;
outOfBounds clamp;
fileName "effTable";
}
}
Note:
the table with name "fileName" should have the same units as
secondaryMassFlowRate and kg/s for phi
faceZone is the faces at the inlet of the cellzone, it needs to be
created with flip map flags. It is used to integrate the net mass flow
rate into the heat exchanger
SourceFiles
heatExchangerSource.C
\*---------------------------------------------------------------------------*/
#ifndef heatExchangerSource_H
#define heatExchangerSource_H
#include "fvOption.H"
#include "autoPtr.H"
#include "interpolation2DTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class heatExchangerSource Declaration
\*---------------------------------------------------------------------------*/
class heatExchangerSource
:
public option
{
protected:
// Protected data
//- Secondary flow mass rate [Kg/s]
scalar secondaryMassFlowRate_;
//- Inlet secondary temperature [K]
scalar secondaryInletT_;
//- Primary air temperature at the heat exchanger inlet [K]
scalar primaryInletT_;
//- 2D look up table efficiency = F(total primary mass flow rate [Kg/s]
//, secondary mass flow rate [Kg/s])
autoPtr<interpolation2DTable<scalar> > eTable_;
//- Name of velocity field; default = U
word UName_;
//- Name of temperature field; default = T
word TName_;
//- Name of the flux
word phiName_;
//- Name of the faceZone at the heat exchange inlet
word faceZoneName_;
//- Id for the face zone
label zoneID_;
//- Local list of face IDs
labelList faceId_;
//- Local list of patch ID per face
labelList facePatchId_;
//- List of +1/-1 representing face flip map
// (1 use as is, -1 negate)
labelList faceSign_;
//- Area of the face zone
scalar faceZoneArea_;
private:
// Private Member Functions
//- Disallow default bitwise copy construct
heatExchangerSource(const heatExchangerSource&);
//- Disallow default bitwise assignment
void operator=(const heatExchangerSource&);
//- Add heat source
void addHeatSource
(
scalarField& Tsource,
const labelList& cells,
const scalarField& V,
const vectorField& U,
const scalar Qt,
const scalarField& deltaTref,
const scalar totalHeat
) const;
//- Init heat exchanger source model
void init();
//- Calculate total area of faceZone accross procesors
void calculateTotalArea(scalar& var);
public:
//- Runtime type information
TypeName("heatExchangerSource");
// Constructors
//- Construct from components
heatExchangerSource
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
);
//- Destructor
virtual ~heatExchangerSource()
{}
// Member Functions
// Public Functions
//- Source term to fvMatrix<scalar>
virtual void addSup(fvMatrix<scalar>& eqn, const label fieldI);
// I-O
//- Write data
virtual void writeData(Ostream&) const;
//- Read dictionary
virtual bool read(const dictionary& dict);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -167,13 +167,7 @@ void Foam::fieldAverage::calcAverages()
prevTimeIndex_ = currentTimeIndex;
}
Info<< "Calculating averages" << nl << endl;
forAll(faItems_, fieldI)
{
totalIter_[fieldI]++;
totalTime_[fieldI] += obr_.time().deltaTValue();
}
addMeanSqrToPrime2Mean<scalar, scalar>
(
@ -202,6 +196,12 @@ void Foam::fieldAverage::calcAverages()
meanVectorFields_,
prime2MeanSymmTensorFields_
);
forAll(faItems_, fieldI)
{
totalIter_[fieldI]++;
totalTime_[fieldI] += obr_.time().deltaTValue();
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -137,8 +137,8 @@ void Foam::forceCoeffs::write()
scalar Cd = sum(coeffs[1]);
scalar Cm = sum(coeffs[2]);
scalar Clf = Cl/2.0 - Cm;
scalar Clr = Cl/2.0 + Cm;
scalar Clf = Cl/2.0 + Cm;
scalar Clr = Cl/2.0 - Cm;
file()
<< obr_.time().value() << tab
@ -178,6 +178,17 @@ void Foam::forceCoeffs::write()
}
OFstream osCoeffs(forcesDir/"forceCoeffs_bins");
if (binCumulative_)
{
for (label i = 1; i < coeffs[0].size(); i++)
{
coeffs[0][i] += coeffs[0][i-1];
coeffs[1][i] += coeffs[1][i-1];
coeffs[2][i] += coeffs[2][i-1];
}
}
binWriterPtr->write(axis, fieldNames, coeffs, osCoeffs);
}

View File

@ -241,11 +241,25 @@ void Foam::forces::writeBins() const
wordList fieldNames(IStringStream("(pressure viscous)")());
List<Field<vector> > f(force_);
List<Field<vector> > m(moment_);
if (binCumulative_)
{
for (label i = 1; i < f[0].size(); i++)
{
f[0][i] += f[0][i-1];
f[1][i] += f[1][i-1];
m[0][i] += m[0][i-1];
m[1][i] += m[1][i-1];
}
}
OFstream osForce(forcesDir/"force_bins");
binWriterPtr->write(axis, fieldNames, force_, osForce);
binWriterPtr->write(axis, fieldNames, f, osForce);
OFstream osMoment(forcesDir/"moment_bins");
binWriterPtr->write(axis, fieldNames, moment_, osMoment);
binWriterPtr->write(axis, fieldNames, m, osMoment);
if (localSystem_)
@ -257,6 +271,17 @@ void Foam::forces::writeBins() const
localMoment[0] = coordSys_.localVector(moment_[0]);
localMoment[1] = coordSys_.localVector(moment_[1]);
if (binCumulative_)
{
for (label i = 1; i < localForce[0].size(); i++)
{
localForce[0][i] += localForce[0][i-1];
localForce[1][i] += localForce[1][i-1];
localMoment[0][i] += localMoment[0][i-1];
localMoment[1][i] += localMoment[1][i-1];
}
}
OFstream osLocalForce(forcesDir/"force_local");
binWriterPtr->write(axis, fieldNames, localForce, osLocalForce);
@ -298,7 +323,8 @@ Foam::forces::forces
binDx_(0.0),
binMin_(GREAT),
binPoints_(),
binFormat_("undefined")
binFormat_("undefined"),
binCumulative_(true)
{
// Check if the available mesh is an fvMesh otherise deactivate
if (!isA<fvMesh>(obr_))
@ -356,7 +382,8 @@ Foam::forces::forces
binDx_(0.0),
binMin_(GREAT),
binPoints_(),
binFormat_("undefined")
binFormat_("undefined"),
binCumulative_(true)
{}
@ -448,9 +475,11 @@ void Foam::forces::read(const dictionary& dict)
localSystem_ = true;
}
// read bin information if present
if (dict.readIfPresent<label>("nBin", nBin_))
if (dict.found("binData"))
{
const dictionary& binDict(dict.subDict("binData"));
binDict.lookup("nBin") >> nBin_;
if (nBin_ < 0)
{
FatalIOErrorIn
@ -470,7 +499,7 @@ void Foam::forces::read(const dictionary& dict)
if (nBin_ > 1)
{
dict.lookup("binDir") >> binDir_;
binDict.lookup("direction") >> binDir_;
binDir_ /= mag(binDir_);
binMin_ = GREAT;
@ -499,7 +528,9 @@ void Foam::forces::read(const dictionary& dict)
binPoints_[i] = (i + 0.5)*binDir_*binDx_;
}
dict.lookup("binFormat") >> binFormat_;
binDict.lookup("format") >> binFormat_;
binDict.lookup("cumulative") >> binCumulative_;
// allocate storage for forces and moments
forAll(force_, i)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -209,6 +209,9 @@ protected:
//- Write format for bin data
word binFormat_;
//- Should bin data be cumulative?
bool binCumulative_;
// Protected Member Functions

View File

@ -103,7 +103,7 @@ contactAngleForce::contactAngleForce
IOobject::NO_WRITE
),
owner_.regionMesh(),
dimensionedScalar("mask", dimless, 0.0)
dimensionedScalar("mask", dimless, 1.0)
)
{
initialise();
@ -149,8 +149,6 @@ tmp<fvVectorMatrix> contactAngleForce::correct(volVectorField& U)
volVectorField gradAlpha(fvc::grad(alpha));
scalarField nHits(owner_.regionMesh().nCells(), 0.0);
forAll(nbr, faceI)
{
const label cellO = own[faceI];
@ -166,14 +164,13 @@ tmp<fvVectorMatrix> contactAngleForce::correct(volVectorField& U)
cellI = cellN;
}
if (cellI != -1 && mask_[cellI] > 0)
if (cellI != -1 && mask_[cellI] > 0.5)
{
const scalar dx = owner_.regionMesh().deltaCoeffs()[faceI];
const scalar invDx = owner_.regionMesh().deltaCoeffs()[faceI];
const vector n =
gradAlpha[cellI]/(mag(gradAlpha[cellI]) + ROOTVSMALL);
scalar theta = cos(degToRad(distribution_->sample()));
force[cellI] += Ccf_*n*sigma[cellI]*(1.0 - theta)/dx;
nHits[cellI]++;
force[cellI] += Ccf_*n*sigma[cellI]*(1.0 - theta)/invDx;
}
}
@ -183,12 +180,12 @@ tmp<fvVectorMatrix> contactAngleForce::correct(volVectorField& U)
{
const fvPatchField<scalar>& alphaf = alpha.boundaryField()[patchI];
const fvPatchField<scalar>& maskf = mask_.boundaryField()[patchI];
const scalarField& dx = alphaf.patch().deltaCoeffs();
const scalarField& invDx = alphaf.patch().deltaCoeffs();
const labelUList& faceCells = alphaf.patch().faceCells();
forAll(alphaf, faceI)
{
if (maskf[faceI] > 0)
if (maskf[faceI] > 0.5)
{
label cellO = faceCells[faceI];
@ -199,16 +196,14 @@ tmp<fvVectorMatrix> contactAngleForce::correct(volVectorField& U)
/(mag(gradAlpha[cellO]) + ROOTVSMALL);
scalar theta = cos(degToRad(distribution_->sample()));
force[cellO] +=
Ccf_*n*sigma[cellO]*(1.0 - theta)/dx[faceI];
nHits[cellO]++;
Ccf_*n*sigma[cellO]*(1.0 - theta)/invDx[faceI];
}
}
}
}
}
force /= (max(nHits, scalar(1.0))*magSf);
tForce().correctBoundaryConditions();
force /= magSf;
if (owner_.regionMesh().time().outputTime())
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -66,13 +66,8 @@ drippingInjection::drippingInjection
rndGen_
)
),
diameter_(owner.regionMesh().nCells(), 0.0)
{
forAll(diameter_, faceI)
{
diameter_[faceI] = parcelDistribution_->sample();
}
}
diameter_(owner.regionMesh().nCells(), -1.0)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -117,27 +112,41 @@ void drippingInjection::correct
// Collect the data to be transferred
forAll(massToInject, cellI)
forAll(massDrip, cellI)
{
scalar rhoc = rho[cellI];
scalar diam = diameter_[cellI];
scalar minMass = particlesPerParcel_*rhoc*pi/6*pow3(diam);
if (massDrip[cellI] > minMass)
if (massDrip[cellI] > 0)
{
// All drip mass can be injected
massToInject[cellI] += massDrip[cellI];
availableMass[cellI] -= massDrip[cellI];
// set new particle diameter if not already set
if (diameter_[cellI] < 0)
{
diameter_[cellI] = parcelDistribution_->sample();
}
// Set particle diameter
diameterToInject[cellI] = diameter_[cellI];
scalar& diam = diameter_[cellI];
scalar rhoc = rho[cellI];
scalar minMass = particlesPerParcel_*rhoc*pi/6*pow3(diam);
// Retrieve new particle diameter sample
diameter_[cellI] = parcelDistribution_->sample();
if (massDrip[cellI] > minMass)
{
// All drip mass can be injected
massToInject[cellI] += massDrip[cellI];
availableMass[cellI] -= massDrip[cellI];
// Set particle diameter
diameterToInject[cellI] = diam;
// Retrieve new particle diameter sample
diam = parcelDistribution_->sample();
}
else
{
// Particle mass below minimum threshold - cannot be injected
massToInject[cellI] = 0.0;
diameterToInject[cellI] = 0.0;
}
}
else
{
// Mass below minimum threshold - cannot be injected
massToInject[cellI] = 0.0;
diameterToInject[cellI] = 0.0;
}

View File

@ -121,7 +121,7 @@ inline Foam::scalar Foam::incompressiblePerfectGas<Specie>::psi
scalar T
) const
{
return 1.0/(this->R()*T);
return 0.0;
}
@ -132,7 +132,7 @@ inline Foam::scalar Foam::incompressiblePerfectGas<Specie>::Z
scalar
) const
{
return 1.0;
return 0.0;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -39,7 +39,7 @@ Description
k = kLowReWallFunction
epsilon = epsilonLowReWallFunction
v2 = v2WalLFunction
v2 = v2WallFunction
f = fWallFunction
These are applicable to both low- and high-Reynolds number flows.

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -39,7 +39,7 @@ Description
k = kLowReWallFunction
epsilon = epsilonLowReWallFunction
v2 = v2WalLFunction
v2 = v2WallFunction
f = fWallFunction
These are applicable to both low- and high-Reynolds number flows.

View File

@ -27,9 +27,13 @@ forceCoeffs1
lRef 1.42; // Wheelbase length
Aref 0.75; // Estimated
nBin 20; // output data into bins
binDir (1 0 0); // bin direction
binFormat gnuplot;
binData
{
nBin 20; // output data into 20 bins
direction (1 0 0); // bin direction
format gnuplot;
cumulative yes;
}
}