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 @@
postChannel.C
channelIndex.C
EXE = $(FOAM_APPBIN)/postChannel

View File

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

View File

@ -0,0 +1,73 @@
/*
volTensorField gradU(fvc::grad(U));
volSymmTensorField D(symm(fvc::grad(U)));
volTensorField Dprim(symm(fvc::grad(U - UMean)));
volScalarField prod(-((U - UMean)*(U - UMean)) && D);
*/
/*
volScalarField txx
(
IOobject
(
"txx",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionSet(0, 1, -1, 0, 0)
);
txx =sqrt(Txx - (UMeanx*UMeanx));
txx.write();
volScalarField tyy
(
IOobject
(
"tyy",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionSet(0, 1, -1, 0, 0)
);
tyy = sqrt(Tyy - (UMeany*UMeany));
tyy.write();
volScalarField tzz
(
IOobject
(
"tzz",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionSet(0, 1, -1, 0, 0)
);
tzz = sqrt(Tzz - (UMeanz*UMeanz));
tzz.write();
volScalarField txy
(
IOobject
(
"txy",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionSet(0, 2, -2, 0, 0)
);
txy = Txy - (UMeanx*UMeany);
txy.write();
*/

View File

@ -0,0 +1,293 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "channelIndex.H"
#include "boolList.H"
#include "syncTools.H"
#include "OFstream.H"
#include "meshTools.H"
#include "Time.H"
#include "SortableList.H"
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::vector::components,
3
>::names[] =
{
"x",
"y",
"z"
};
}
const Foam::NamedEnum<Foam::vector::components, 3>
Foam::channelIndex::vectorComponentsNames_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Determines face blocking
void Foam::channelIndex::walkOppositeFaces
(
const polyMesh& mesh,
const labelList& startFaces,
boolList& blockedFace
)
{
const cellList& cells = mesh.cells();
const faceList& faces = mesh.faces();
label nBnd = mesh.nFaces() - mesh.nInternalFaces();
DynamicList<label> frontFaces(startFaces);
forAll(frontFaces, i)
{
label faceI = frontFaces[i];
blockedFace[faceI] = true;
}
while (returnReduce(frontFaces.size(), sumOp<label>()) > 0)
{
// Transfer across.
boolList isFrontBndFace(nBnd, false);
forAll(frontFaces, i)
{
label faceI = frontFaces[i];
if (!mesh.isInternalFace(faceI))
{
isFrontBndFace[faceI-mesh.nInternalFaces()] = true;
}
}
syncTools::swapBoundaryFaceList(mesh, isFrontBndFace);
// Add
forAll(isFrontBndFace, i)
{
label faceI = mesh.nInternalFaces()+i;
if (isFrontBndFace[i] && !blockedFace[faceI])
{
blockedFace[faceI] = true;
frontFaces.append(faceI);
}
}
// Transfer across cells
DynamicList<label> newFrontFaces(frontFaces.size());
forAll(frontFaces, i)
{
label faceI = frontFaces[i];
{
const cell& ownCell = cells[mesh.faceOwner()[faceI]];
label oppositeFaceI = ownCell.opposingFaceLabel(faceI, faces);
if (oppositeFaceI == -1)
{
FatalErrorIn("channelIndex::walkOppositeFaces(..)")
<< "Face:" << faceI << " owner cell:" << ownCell
<< " is not a hex?" << abort(FatalError);
}
else
{
if (!blockedFace[oppositeFaceI])
{
blockedFace[oppositeFaceI] = true;
newFrontFaces.append(oppositeFaceI);
}
}
}
if (mesh.isInternalFace(faceI))
{
const cell& neiCell = mesh.cells()[mesh.faceNeighbour()[faceI]];
label oppositeFaceI = neiCell.opposingFaceLabel(faceI, faces);
if (oppositeFaceI == -1)
{
FatalErrorIn("channelIndex::walkOppositeFaces(..)")
<< "Face:" << faceI << " neighbour cell:" << neiCell
<< " is not a hex?" << abort(FatalError);
}
else
{
if (!blockedFace[oppositeFaceI])
{
blockedFace[oppositeFaceI] = true;
newFrontFaces.append(oppositeFaceI);
}
}
}
}
frontFaces.transfer(newFrontFaces);
}
}
// Calculate regions.
void Foam::channelIndex::calcLayeredRegions
(
const polyMesh& mesh,
const labelList& startFaces
)
{
boolList blockedFace(mesh.nFaces(), false);
walkOppositeFaces
(
mesh,
startFaces,
blockedFace
);
if (false)
{
OFstream str(mesh.time().path()/"blockedFaces.obj");
label vertI = 0;
forAll(blockedFace, faceI)
{
if (blockedFace[faceI])
{
const face& f = mesh.faces()[faceI];
forAll(f, fp)
{
meshTools::writeOBJ(str, mesh.points()[f[fp]]);
}
str<< 'f';
forAll(f, fp)
{
str << ' ' << vertI+fp+1;
}
str << nl;
vertI += f.size();
}
}
}
// Do analysis for connected regions
cellRegion_.reset(new regionSplit(mesh, blockedFace));
Info<< "Detected " << cellRegion_().nRegions() << " layers." << nl << endl;
// Sum number of entries per region
regionCount_ = regionSum(scalarField(mesh.nCells(), 1.0));
// Average cell centres to determine ordering.
pointField regionCc
(
regionSum(mesh.cellCentres())
/ regionCount_
);
SortableList<scalar> sortComponent(regionCc.component(dir_));
sortMap_ = sortComponent.indices();
y_ = sortComponent;
if (symmetric_)
{
y_.setSize(cellRegion_().nRegions()/2);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::channelIndex::channelIndex
(
const polyMesh& mesh,
const dictionary& dict
)
:
symmetric_(readBool(dict.lookup("symmetric"))),
dir_(vectorComponentsNames_.read(dict.lookup("component")))
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
const wordList patchNames(dict.lookup("patches"));
label nFaces = 0;
forAll(patchNames, i)
{
const label patchI = patches.findPatchID(patchNames[i]);
if (patchI == -1)
{
FatalErrorIn("channelIndex::channelIndex(const polyMesh&)")
<< "Illegal patch " << patchNames[i]
<< ". Valid patches are " << patches.name()
<< exit(FatalError);
}
nFaces += patches[patchI].size();
}
labelList startFaces(nFaces);
nFaces = 0;
forAll(patchNames, i)
{
const polyPatch& pp = patches[patchNames[i]];
forAll(pp, j)
{
startFaces[nFaces++] = pp.start()+j;
}
}
// Calculate regions.
calcLayeredRegions(mesh, startFaces);
}
Foam::channelIndex::channelIndex
(
const polyMesh& mesh,
const labelList& startFaces,
const bool symmetric,
const direction dir
)
:
symmetric_(symmetric),
dir_(dir)
{
// Calculate regions.
calcLayeredRegions(mesh, startFaces);
}
// ************************************************************************* //

View File

@ -0,0 +1,157 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::channelIndex
Description
Does averaging of fields over layers of cells. Assumes layered mesh.
SourceFiles
channelIndex.C
\*---------------------------------------------------------------------------*/
#ifndef channelIndex_H
#define channelIndex_H
#include "regionSplit.H"
#include "direction.H"
#include "scalarField.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class channelIndex Declaration
\*---------------------------------------------------------------------------*/
class channelIndex
{
// Private data
static const NamedEnum<vector::components, 3> vectorComponentsNames_;
//- Is mesh symmetric
const bool symmetric_;
//- direction to sort
const direction dir_;
//- Per cell the global region
autoPtr<regionSplit> cellRegion_;
//- Per global region the number of cells (scalarField so we can use
// field algebra)
scalarField regionCount_;
//- From sorted region back to unsorted global region
labelList sortMap_;
//- Sorted component of cell centres
scalarField y_;
// Private Member Functions
void walkOppositeFaces
(
const polyMesh& mesh,
const labelList& startFaces,
boolList& blockedFace
);
void calcLayeredRegions
(
const polyMesh& mesh,
const labelList& startFaces
);
//- Disallow default bitwise copy construct and assignment
channelIndex(const channelIndex&);
void operator=(const channelIndex&);
public:
// Constructors
//- Construct from dictionary
channelIndex(const polyMesh&, const dictionary&);
//- Construct from supplied starting faces
channelIndex
(
const polyMesh& mesh,
const labelList& startFaces,
const bool symmetric,
const direction dir
);
// Member Functions
// Access
//- Sum field per region
template<class T>
Field<T> regionSum(const Field<T>& cellField) const;
//- collapse a field to a line
template<class T>
Field<T> collapse
(
const Field<T>& vsf,
const bool asymmetric=false
) const;
//- return the field of Y locations from the cell centres
const scalarField& y() const
{
return y_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "channelIndexTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,102 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "channelIndex.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
Foam::Field<T> Foam::channelIndex::regionSum(const Field<T>& cellField) const
{
Field<T> regionField(cellRegion_().nRegions(), pTraits<T>::zero);
forAll(cellRegion_(), cellI)
{
regionField[cellRegion_()[cellI]] += cellField[cellI];
}
// Global sum
Pstream::listCombineGather(regionField, plusEqOp<T>());
Pstream::listCombineScatter(regionField);
return regionField;
}
template<class T>
Foam::Field<T> Foam::channelIndex::collapse
(
const Field<T>& cellField,
const bool asymmetric
) const
{
// Average and order
const Field<T> summedField(regionSum(cellField));
Field<T> regionField
(
summedField
/ regionCount_,
sortMap_
);
// Symmetry?
if (symmetric_)
{
label nlb2 = cellRegion_().nRegions()/2;
if (asymmetric)
{
for (label j=0; j<nlb2; j++)
{
regionField[j] =
0.5
* (
regionField[j]
- regionField[cellRegion_().nRegions() - j - 1]
);
}
}
else
{
for (label j=0; j<nlb2; j++)
{
regionField[j] =
0.5
* (
regionField[j]
+ regionField[cellRegion_().nRegions() - j - 1]
);
}
}
regionField.setSize(nlb2);
}
return regionField;
}
// ************************************************************************* //

View File

@ -0,0 +1,63 @@
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance());
mkDir(path);
scalarField UMeanXvalues
(
channelIndexing.collapse(UMean.component(vector::X)())
);
scalarField UMeanYvalues
(
channelIndexing.collapse(UMean.component(vector::Y)())
);
scalarField UMeanZvalues
(
channelIndexing.collapse(UMean.component(vector::Z)())
);
scalarField RxxValues(channelIndexing.collapse(Rxx));
scalarField RyyValues(channelIndexing.collapse(Ryy));
scalarField RzzValues(channelIndexing.collapse(Rzz));
scalarField RxyValues(channelIndexing.collapse(Rxy, true));
scalarField pPrime2MeanValues(channelIndexing.collapse(pPrime2Mean));
/*
scalarField epsilonValues(channelIndexing.collapse(epsilonMean));
scalarField nuMeanValues(channelIndexing.collapse(nuMean));
scalarField nuPrimeValues(channelIndexing.collapse(nuPrime));
scalarField gammaDotMeanValues(channelIndexing.collapse(gammaDotMean));
scalarField gammaDotPrimeValues(channelIndexing.collapse(gammaDotPrime));
*/
scalarField urmsValues(sqrt(mag(RxxValues)));
scalarField vrmsValues(sqrt(mag(RyyValues)));
scalarField wrmsValues(sqrt(mag(RzzValues)));
scalarField kValues
(
0.5*(sqr(urmsValues) + sqr(vrmsValues) + sqr(wrmsValues))
);
const scalarField& y = channelIndexing.y();
makeGraph(y, UMeanXvalues, "Uf", path, gFormat);
makeGraph(y, urmsValues, "u", path, gFormat);
makeGraph(y, vrmsValues, "v", path, gFormat);
makeGraph(y, wrmsValues, "w", path, gFormat);
makeGraph(y, RxyValues, "uv", path, gFormat);
makeGraph(y, kValues, "k", path, gFormat);
makeGraph(y, pPrime2MeanValues, "pPrime2Mean", path, gFormat);
/*
makeGraph(y, epsilonValues, "epsilon", path, gFormat);
makeGraph(y, nuMeanValues, "nu", path, gFormat);
makeGraph(y, nuPrimeValues, "nuPrime", path, gFormat);
makeGraph(y, gammaDotMeanValues, "gammaDot", path, gFormat);
makeGraph(y, gammaDotPrimeValues, "gammaDotPrime", path, gFormat);
*/

View File

@ -0,0 +1,97 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
postChannel
Description
Post-processes data from channel flow calculations.
For each time: calculate: txx, txy,tyy, txy,
eps, prod, vorticity, enstrophy and helicity. Assuming that the mesh
is periodic in the x and z directions, collapse Umeanx, Umeany, txx,
txy and tyy to a line and print them as standard output.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "channelIndex.H"
#include "makeGraph.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::noParallel();
timeSelector::addOptions();
# include "setRootCase.H"
# include "createTime.H"
// Get times list
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"
# include "readTransportProperties.H"
const word& gFormat = runTime.graphFormat();
// Setup channel indexing for averaging over channel down to a line
IOdictionary channelDict
(
IOobject
(
"postChannelDict",
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
channelIndex channelIndexing(mesh, channelDict);
// For each time step read all fields
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Collapsing fields for time " << runTime.timeName() << endl;
# include "readFields.H"
# include "calculateFields.H"
// Average fields over channel down to a line
# include "collapse.H"
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,27 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object postChannelDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Seed patches to start layering from
patches (bottomWall);
// Direction in which the layers are
component y;
// Is the mesh symmetric? If so average(symmetric fields) or
// subtract(asymmetric) contributions from both halves
symmetric true;
// ************************************************************************* //

View File

@ -0,0 +1,112 @@
IOobject UMeanHeader
(
"UMean",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
if (!UMeanHeader.headerOk())
{
Info<< " No UMean field" << endl;
continue;
}
volVectorField UMean
(
UMeanHeader,
mesh
);
volSymmTensorField UPrime2Mean
(
IOobject
(
"UPrime2Mean",
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh
);
volScalarField Rxx(UPrime2Mean.component(symmTensor::XX));
volScalarField Ryy(UPrime2Mean.component(symmTensor::YY));
volScalarField Rzz(UPrime2Mean.component(symmTensor::ZZ));
volScalarField Rxy(UPrime2Mean.component(symmTensor::XY));
volScalarField pPrime2Mean
(
IOobject
(
"pPrime2Mean",
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh
);
/*
volScalarField epsilonMean
(
IOobject
(
"epsilonMean",
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh
);
volScalarField nuMean
(
IOobject
(
"nuMean",
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh
);
volScalarField gammaDotMean
(
IOobject
(
"gammaDotMean",
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh
);
volScalarField nuPrime2
(
IOobject
(
"nuPrime",
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh
);
volScalarField nuPrime = sqrt(mag(nuPrime2 - sqr(nuMean)));
volScalarField gammaDotPrime2
(
IOobject
(
"gammaDotPrime",
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh
);
volScalarField gammaDotPrime = sqrt(mag(gammaDotPrime2 -sqr(gammaDotMean)));
*/

View File

@ -0,0 +1,13 @@
Info<< nl << "Reading transportProperties" << endl;
IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);