Add the OpenFOAM source tree

This commit is contained in:
Henry
2014-12-10 22:40:10 +00:00
parent ee487c860d
commit 446e5777f0
13379 changed files with 3983377 additions and 0 deletions

View File

@ -0,0 +1,4 @@
foamToGMV.C
itoa.C
EXE = $(FOAM_APPBIN)/foamToGMV

View File

@ -0,0 +1,13 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lgenericPatchFields \
-llagrangian

View File

@ -0,0 +1,100 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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, see <http://www.gnu.org/licenses/>.
Application
foamToGMV
Description
Translates foam output to GMV readable files.
A free post-processor with available binaries from
http://www-xdiv.lanl.gov/XCM/gmv/
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "OFstream.H"
#include "instantList.H"
#include "IOobjectList.H"
#include "itoa.H"
#include "Cloud.H"
#include "passiveParticle.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
const label nTypes = 4;
const word fieldTypes[] =
{
"volScalarField",
"volVectorField",
"surfaceScalarField",
cloud::prefix
};
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "readConversionProperties.H"
// get the available time-steps
instantList TimeList = runTime.times();
Info<< TimeList << endl;
label nTimes = TimeList.size();
for (label n=1; n < nTimes; n++)
{
if (TimeList[n].value() > startTime)
{
Info<< "Time = " << TimeList[n].value() << nl;
// Set Time
runTime.setTime(TimeList[n], n);
word CurTime = runTime.timeName();
IOobjectList objects(mesh, runTime.timeName());
# include "moveMesh.H"
// set the filename of the GMV file
fileName gmvFileName = "plotGMV." + itoa(n);
OFstream gmvFile(args.rootPath()/args.caseName()/gmvFileName);
# include "gmvOutputHeader.H"
# include "gmvOutput.H"
# include "gmvOutputTail.H"
}
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,94 @@
for (label i=0; i < nTypes; i++)
{
wordList fieldNames = objects.names(fieldTypes[i]);
if (fieldTypes[i] == "volScalarField")
{
gmvFile << "variable" << nl;
}
forAll(fieldNames, j)
{
const word& fieldName = fieldNames[j];
IOobject fieldObject
(
fieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (fieldTypes[i] == "volScalarField")
{
volScalarField fld(fieldObject, mesh);
gmvFile << fieldName << " 0" << nl;
for (label indx=0;indx<mesh.nCells();indx++)
{
gmvFile << fld[indx] << " ";
}
gmvFile << nl;
}
if (fieldTypes[i] == "volVectorField")
{
if (fieldName == vComp)
{
volVectorField fld(fieldObject, mesh);
gmvFile << "velocity 0" << nl;
for (label indx=0;indx<mesh.nCells();indx++)
{
gmvFile << fld[indx].x() << " ";
}
for (label indx=0;indx<mesh.nCells();indx++)
{
gmvFile << fld[indx].y() << " ";
}
for (label indx=0;indx<mesh.nCells();indx++)
{
gmvFile << fld[indx].z() << " ";
}
gmvFile << nl;
}
}
if (fieldTypes[i] == "surfaceScalarField")
{
// ...
}
}
if (fieldTypes[i] == cloud::prefix)
{
IOobject lagrangianHeader
(
"positions",
runTime.timeName(),
cloud::prefix,
mesh,
IOobject::NO_READ
);
if (lagrangianHeader.headerOk())
{
Cloud<passiveParticle> particles(mesh);
IOobjectList objects(mesh, runTime.timeName(), cloud::prefix);
wordList lagrangianScalarNames = objects.names("scalarField");
wordList lagrangianVectorNames = objects.names("vectorField");
if (particles.size())
{
# include "gmvOutputLagrangian.H"
}
}
}
if (fieldTypes[i] == "volScalarField")
{
gmvFile << "endvars" << nl;
}
}

View File

@ -0,0 +1,53 @@
const pointField& points = mesh.points();
label nPoints = points.size();
const cellShapeList& cells = mesh.cellShapes();
gmvFile << "gmvinput " << format << nl;
gmvFile << "nodes " << nPoints << nl;
for (label indx=0;indx<nPoints;indx++)
{
gmvFile << points[indx].x() << " ";
}
gmvFile << nl;
for (label indx=0;indx<nPoints;indx++)
{
gmvFile << points[indx].y() << " ";
}
gmvFile << nl;
for (label indx=0;indx<nPoints;indx++)
{
gmvFile << points[indx].z() << " ";
}
gmvFile << nl;
gmvFile << "cells " << cells.size() << nl;
forAll(cells, indx)
{
label nNodes = cells[indx].size();
if (nNodes == 8)
{
gmvFile << "hex " << 8 << " ";
for (label ip=0; ip<nNodes; ip++)
{
gmvFile << cells[indx][ip] + 1 << " ";
}
gmvFile << nl;
}
else if (nNodes == 4)
{
gmvFile << "tet " << 4 << " ";
for (label ip=0; ip<nNodes; ip++)
{
gmvFile << cells[indx][ip] + 1 << " ";
}
gmvFile << nl;
}
else if (nNodes == 6)
{
gmvFile << "prism " << 6 << " ";
for (label ip=0; ip<nNodes; ip++)
{
gmvFile << cells[indx][ip] + 1 << " ";
}
gmvFile << nl;
}
}

View File

@ -0,0 +1,98 @@
gmvFile << "tracers " << particles.size() << nl;
forAllConstIter(Cloud<passiveParticle>, particles, iter)
{
gmvFile << iter().position().x() << ' ';
}
gmvFile << nl;
forAllConstIter(Cloud<passiveParticle>, particles, iter)
{
gmvFile << iter().position().y() << ' ';
}
gmvFile << nl;
forAllConstIter(Cloud<passiveParticle>, particles, iter)
{
gmvFile << iter().position().z() << ' ';
}
gmvFile << nl;
forAll(lagrangianScalarNames, i)
{
const word& name = lagrangianScalarNames[i];
IOField<scalar> fld
(
IOobject
(
name,
runTime.timeName(),
cloud::prefix,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
if (fld.size())
{
gmvFile << name << nl;
forAll(fld, n)
{
gmvFile << fld[n] << token::SPACE;
}
gmvFile << nl;
}
}
forAll(lagrangianVectorNames, i)
{
const word& name = lagrangianVectorNames[i];
IOField<vector> fld
(
IOobject
(
name,
runTime.timeName(),
cloud::prefix,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
if (fld.size())
{
gmvFile << name + "x" << nl;
forAll(fld, n)
{
gmvFile << fld[n].x() << token::SPACE;
}
gmvFile << nl;
gmvFile << name + "y" << nl;
forAll(fld, n)
{
gmvFile << fld[n].y() << token::SPACE;
}
gmvFile << nl;
gmvFile << name + "z" << nl;
forAll(fld, n)
{
gmvFile << fld[n].z() << token::SPACE;
}
gmvFile << nl;
}
}
gmvFile << "endtrace"<< nl;

View File

@ -0,0 +1,48 @@
gmvFile << "tracers " << particles.size() << nl;
forAllConstIter(discretePhase, particles, iter)
{
gmvFile << iter().position().x() << " ";
}
gmvFile << nl;
forAllConstIter(discretePhase, particles, iter)
{
gmvFile << iter().position().y() << " ";
}
gmvFile << nl;
forAllConstIter(discretePhase, particles, iter)
{
gmvFile << iter().position().z() << " ";
}
gmvFile << nl;
gmvFile << "U" << nl;
forAllConstIter(discretePhase, particles, iter)
{
gmvFile << iter().velocity().x() << " ";
}
gmvFile << nl;
gmvFile << "V" << nl;
forAllConstIter(discretePhase, particles, iter)
{
gmvFile << iter().velocity().y() << " ";
}
gmvFile << nl;
gmvFile << "W" << nl;
forAllConstIter(discretePhase, particles, iter)
{
{
gmvFile << iter().velocity().z() << " ";
}
gmvFile << nl;
gmvFile << "Diam" << nl;
forAllConstIter(discretePhase, particles, iter)
{
gmvFile << iter().d() << " ";
}
gmvFile << "endtrace"<< nl;

View File

@ -0,0 +1,50 @@
gmvFile << "tracers " << particles.size() << nl;
forAllConstIter(Cloud<passiveParticle>, particles, iter)
{
gmvFile << iter().position().x() << " ";
}
gmvFile << nl;
forAllConstIter(Cloud<passiveParticle>, particles, iter)
{
gmvFile << iter().position().y() << " ";
}
gmvFile << nl;
forAllConstIter(Cloud<passiveParticle>, particles, iter)
{
gmvFile << iter().position().z() << " ";
}
gmvFile << nl;
forAll(lagrangianScalarNames, i)
{
word name = lagrangianScalarNames[i];
IOField<scalar> s
(
IOobject
(
name,
runTime.timeName(),
cloud::prefix,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
if (s.size())
{
gmvFile << name << nl;
forAll(s, n)
{
gmvFile << s[n] << token::SPACE;
}
gmvFile << nl;
}
}
gmvFile << "endtrace"<< nl;

View File

@ -0,0 +1,3 @@
gmvFile
<< "probtime " << runTime.timeName() << nl
<< "endgmv" << nl;

View File

@ -0,0 +1,61 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "itoa.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
word itoa(const label n)
{
const label offset = '0';
const label length = 3;
char val[length + 1];
label leftOfN = n;
for (label i=0; i<length; i++)
{
label j = label(leftOfN/pow(10, length-i-1));
leftOfN -= j*pow(10,length-i-1);
val[i] = offset + j;
}
val[length] = 0;
return val;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,44 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Description
\*---------------------------------------------------------------------------*/
#include "word.H"
#include "label.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
word itoa(const label n);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,27 @@
IOobject ioPoints
(
"points",
runTime.timeName(),
mesh.name(),
mesh
);
if (ioPoints.headerOk())
{
Info<< "new points available" << endl;
// Reading new points
pointIOField newPoints
(
IOobject
(
"points",
runTime.timeName(),
mesh.name(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
mesh.movePoints(newPoints);
}

View File

@ -0,0 +1,51 @@
IOdictionary conversionProperties
(
IOobject
(
"conversionProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
scalar startTime
(
readScalar(conversionProperties.lookup("startTime"))
);
word vComp
(
conversionProperties.lookup("vector")
);
word format
(
conversionProperties.lookup("format")
);
if ((format != "ascii") && (format != "ieeei4r8"))
{
FatalError
<< "format type: " << format << " unknown."
<< " Valid options are: ascii ieeei4r8"
<< abort(FatalError);
}
word cells
(
conversionProperties.lookup("cells")
);
if
(
(cells != "hex")
)
{
FatalError
<< "cells type: " << cells << " unknown."
<< abort(FatalError);
}