Commit 4bb11a28 authored by andy's avatar andy
Browse files

ENH: Removed fieldview reader/converter

parent 9e6202e4
foamToFieldview9.C
fieldviewTopology.C
write_binary_uns.c
calcFaceAddressing.C
writeFunctions.C
EXE = $(FOAM_APPBIN)/foamToFieldview9
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lgenericPatchFields \
-llagrangian
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
// 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;
}
}
// 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++;
}
}
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
}
}