t minus 13 weeks: Codename Fraunhofer Flakes

Regelmäßige GitLab und Mattermost Downtime am Mittwoch, den 21.10.21 ab 17 Uhr bis 20 Uhr. Bitte meldet euch im dem Wartungszeitfenster ab, da es sonst zu Datenverlust kommen kann. | Fraunhofer GitLab and Mattermost will be down for scheduled maintenance from Wednesday, 21.10.21, 5:00 pm (CET/UTC+2) until 20:00 am (CET/UTC+2). Please log off during the maintenance, otherwise data loss may occur.

Commit 67e74ea0 authored by Elia Daniele's avatar Elia Daniele
Browse files

Initial commit

parents
calculateCp.C
EXE = $(FOAM_USER_APPBIN)/calculateCp2D
# c++FLAGS += -DFULLDEBUG -g -O0
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lgenericPatchFields \
-lsampling \
-lmeshTools \
-lsurfMesh \
-ltriSurface
# This application calculates the pressure distribution (cp-curve)
# of an airfoil (chord length 1 m, aligned with one coordinate axis).
# load OpenFOAM with
source /opt/openfoam4/etc/bashrc
# compile the code with
wmake
# and execute the code in your airfoil case with
calculateCp2D
# a "calculateCpDict" is required in your system folder
/*---------------------------------------------------------------------------*\
_ _ |
| | | | | OLDEV: CFD tools developed by
___ | | __| | ___ __ __ | Fraunhofer IWES and ForWind
/ _ \ | | / _` | / _ \\ \ / / | in Oldenburg, Germany
| (_) || || (_| || __/ \ V / |
\___/ |_| \__,_| \___| \_/ | http://www.iwes.fraunhofer.de
| http://www.forwind.de
-------------------------------------------------------------------------------
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OLDEV and it is based on OpenFOAM.
OLDEV is owned by the Fraunhofer IWES and ForWind Oldenburg CFD groups.
It is not allowed to use it outside the scope of Fraunhofer IWES or
ForWind Oldenburg CFD projects. It is forbidden to use, modify, copy or
redistribute OLDEV files for any other purpose.
OLDEV is developed 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.
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
calculateCp2D
Description
This tool computes the pressure coefficients of a 2D airfoil (Cp-curve).
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "wallFvPatch.H"
#include "pointBoundaryMesh.H"
#include "PrimitivePatchInterpolation.H"
#include "OFstream.H"
#include "neighbourBoundaryPoints.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Write function
void writeFile(Ostream& os,const pointField& points, const scalarField& Cp)
{
os << "# x/chord (-) " << tab << " y/chord (-) " << tab << " Cp (-) " << endl;
forAll(points, pointI)
{
const point& pt = points[pointI];
os << pt.x() << "\t" << pt.y() << "\t" << Cp[pointI] << endl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
timeSelector::addOptions();
#include "setRootCase.H"
Info << "\nNOTE:"
<< "\n\tThis tool computes a pressure distribution (Cp-curve)."
<< "\n\tWorks vertex based and for pure 2D meshes only."
<< "\n\tChord length of airfoil should be 1m."
<< "\n\tChord should be aligned with one coordinate axis.\n"
<< endl;
#include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
#include "createMesh.H"
Info << "Reading calculateCpDict\n" << endl;
IOdictionary calculateCpDict
(
IOobject
(
"calculateCpDict",
runTime.system(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
// Read body patch data
word bodyPatchName(calculateCpDict.lookup("bodyPatch"));
label bodyPatchID = mesh.boundaryMesh().findPatchID(bodyPatchName);
// Interpolation from faces to points
primitivePatch primPatch
(
SubList< face >
(
mesh.boundaryMesh()[bodyPatchID].localFaces(),
mesh.boundaryMesh()[bodyPatchID].localFaces().size()
),
mesh.boundaryMesh()[bodyPatchID].localPoints()
);
PrimitivePatchInterpolation< primitivePatch > ppi
(
primPatch
);
scalar span_ = readScalar(calculateCpDict.lookup("span"));
vector spanAxis_(calculateCpDict.lookupOrDefault<vector>("spanAxis", vector(0,0,1)));
// Reading pressure field for Cp
const word definedPressureField_(calculateCpDict.lookup("definedPressureField"));
Info<< "Reading field " << definedPressureField_ << "\n"<< endl;
volScalarField definedPressureField
(
IOobject
(
calculateCpDict.lookup("definedPressureField"),
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh
);
scalarField pBody = definedPressureField.boundaryField()[bodyPatchID];
//scalar pMax = max(pBody);
//Info << "Maximum pressure on " << bodyPatchName << ": " << pMax << " [m^2/s^2]" << endl;
// Pressure interpolated from faces to points
scalarField pBodyPoints = ppi.faceToPointInterpolate(pBody);
// Global point list of the patch points
labelList globalPoints = mesh.boundaryMesh()[bodyPatchID].meshPoints();
polyPatch bodyPatch = mesh.boundaryMesh()[bodyPatchID];
pointField bodyPoints = mesh.boundaryMesh()[bodyPatchID].localPoints();
// Points and definedPressureField at same span position as local point list
labelHashSet spanBodyPointList;
labelList allBodyPointsList = mesh.boundaryMesh()[bodyPatchID].boundaryPoints();
forAll(allBodyPointsList,c)
{
label tmp = 0;
// span in z-direction
if(spanAxis_.x()==spanAxis_.y())
tmp = 2;
// span in y-direction
else if(spanAxis_.x()==spanAxis_.z())
tmp = 1;
// span in x-direction
else if(spanAxis_.y()==spanAxis_.z())
tmp = 0;
if(bodyPoints[c][tmp]==span_)
{
spanBodyPointList.insert(c);
}
}
labelListList boundaryNeighbours = neighbourBoundaryPointsLocal(mesh, bodyPatch);
// labelList of all points with same span position
labelList spanLabels(spanBodyPointList.size());
labelHashSet tmpLabelSet;
// Inital point
spanLabels[0] = spanBodyPointList.toc()[0];
tmpLabelSet.insert(spanLabels[0]);
for(label c=1; c<spanBodyPointList.size(); c++)
{
label tmpLabel = 0;
// Go through all boundary neighbours (labelListList)
for(label i=0; i<3; i++)
{
// If point is not found, check same position
if(!tmpLabelSet.found(boundaryNeighbours[spanLabels[c-1]][i]))
{
if(spanBodyPointList.found(boundaryNeighbours[spanLabels[c-1]][i]))
{
tmpLabelSet.insert(boundaryNeighbours[spanLabels[c-1]][i]);
tmpLabel = boundaryNeighbours[spanLabels[c-1]][i];
i=2;
}
}
}
spanLabels[c] = tmpLabel;
}
// Assigning sorted labels to points and pressure
pointField spanBodyPoints(spanLabels.size());
scalarField spanPressure (spanLabels.size());
scalarField spanCp (spanLabels.size());
forAll(spanLabels,c)
{
spanBodyPoints[c] = bodyPoints[spanLabels[c]];
spanPressure[c] = pBodyPoints[spanLabels[c]];
}
scalar pMax = max(spanPressure);
Info << "Maximum pressure on " << bodyPatchName << ": " << pMax << " [m^2/s^2]" << endl;
forAll(spanLabels,c)
{
spanCp[c] = spanPressure[c]/pMax;
}
// Write file
word CpValues = "Cp.dat";
OFstream str(CpValues);
writeFile(str,spanBodyPoints,spanCp);
Info<< "\nEnd\n" << endl;
return 0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
/*---------------------------------------------------------------------------*\
_ _ |
| | | | | OLDEV: CFD tools developed by
___ | | __| | ___ __ __ | Fraunhofer IWES and ForWind
/ _ \ | | / _` | / _ \\ \ / / | in Oldenburg, Germany
| (_) || || (_| || __/ \ V / |
\___/ |_| \__,_| \___| \_/ | http://www.iwes.fraunhofer.de
| http://www.forwind.de
-------------------------------------------------------------------------------
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object calculateCpCfDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// name of patch of interest
bodyPatch airfoil;
// name of pressure field: p or pMean
definedPressureField p;
// exact position of on span (for 2D meshes only)
span 0.1;
spanAxis (0 0 1);
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
_ _ |
| | | | | OLDEV: CFD tools developed by
___ | | __| | ___ __ __ | Fraunhofer IWES and ForWind
/ _ \ | | / _` | / _ \\ \ / / | in Oldenburg, Germany
| (_) || || (_| || __/ \ V / |
\___/ |_| \__,_| \___| \_/ | http://www.iwes.fraunhofer.de
| http://www.forwind.de
-------------------------------------------------------------------------------
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OLDEV and it is based on OpenFOAM.
OLDEV is owned by the Fraunhofer IWES and ForWind Oldenburg CFD groups.
It is not allowed to use it outside the scope of Fraunhofer IWES or
ForWind Oldenburg CFD projects. It is forbidden to use, modify, copy or
redistribute OLDEV files for any other purpose.
OLDEV is developed 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.
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
The function returns a labelListList which contains the local labels
of all neighbour points on a defined boundary.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "polyMesh.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
labelListList neighbourBoundaryPointsLocal(const polyMesh& mesh_, const polyPatch& boundaryMesh_)
{
const labelList& globalLabels = boundaryMesh_.meshPoints();
labelListList neighboursGlobal(globalLabels.size());
labelListList neighboursLocal (globalLabels.size(), labelList(6));
// Contains the local labels of all neighbour points on a defined boundary
labelListList neighbourBoundaryPointsLocal(globalLabels.size(), labelList(3));
// Checking for all neighbours of boundary points and selecting the neighbours on boundary only
forAll(neighboursGlobal,c)
{
neighboursGlobal[c] = mesh_.pointPoints()[globalLabels[c]] ;
label tmpSize = neighboursGlobal[c].size() ;
for(label i=0; i<tmpSize; i++)
{
neighboursLocal[c][i] = boundaryMesh_.whichPoint(neighboursGlobal[c][i]) ;
}
for(label i=tmpSize; i<6; i++)
{
neighboursLocal[c][i] = -1;
}
labelHashSet boundaryNeighbours;
for(label i=0; i<6; i++)
{
if(neighboursLocal[c][i]>=0)
{
boundaryNeighbours.insert(neighboursLocal[c][i]);
}
}
for(label i=0; i<3; i++)
{
neighbourBoundaryPointsLocal[c][i] = boundaryNeighbours.toc()[i];
}
}
return neighbourBoundaryPointsLocal;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (14.9111299 1.63040066 0);
boundaryField
{
inflowOutflow
{
type inletOutlet;
inletValue $internalField;
}
frontAndBack
{
type empty;
}
airfoil
{
type fixedValue;
value uniform (0 0 0);
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object kl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
inflowOutflow
{
type inletOutlet;
inletValue $internalField;
}
frontAndBack
{
type empty;
}
airfoil
{
type fixedValue;
value uniform 0;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object kt;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
// k = 1.5(U*TI)^2
internalField uniform 0.00016538;
boundaryField
{
inflowOutflow
{
type inletOutlet;
inletValue $internalField;
}
frontAndBack
{
type empty;
}
airfoil
{
type fixedValue;
value uniform 0;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 7.5e-05;
boundaryField
{
inflowOutflow
{
type inletOutlet;
inletValue $internalField;
}
frontAndBack
{
type empty;
}
airfoil
{
type nutLowReWallFunction;
value uniform 0;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object omega;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 0 0 -1 0 0 0 0 ];
// omega = k^0.5 / l
internalField uniform 0.038579;