wallDist: Add support for cached wall-reflection vectors
Currently these vectors are generated at the same time as the wall-distance field by the same run-time selected algorithm. This will be changed so that the wall-reflection vectors are only generated and stored if required.
This commit is contained in:
@ -1,3 +0,0 @@
|
||||
Test-WallDist.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-WallDist
|
||||
@ -1,7 +0,0 @@
|
||||
Test-WallDist.C:
|
||||
calculate distance to wall and reflection vectors.
|
||||
|
||||
Test-WallDist2.C:
|
||||
for debugging: same but do explicit iterations and dump every
|
||||
timestep.
|
||||
|
||||
@ -1,215 +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/>.
|
||||
|
||||
Description
|
||||
Wave propagation of nearwall distance through grid. Every iteration
|
||||
information goes through one layer of cells.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "wallFvPatch.H"
|
||||
#include "FaceCellWave.H"
|
||||
#include "wallPoint.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createMesh.H"
|
||||
|
||||
Info<< "Mesh read in = "
|
||||
<< runTime.cpuTimeIncrement()
|
||||
<< " s\n" << endl << endl;
|
||||
|
||||
Info<< "Creating field wDistNC\n" << endl;
|
||||
volScalarField wallDistUncorrected
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"wDistNC",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar
|
||||
(
|
||||
"wallDist",
|
||||
dimensionSet(0, 1, 0, 0, 0),
|
||||
0.0
|
||||
)
|
||||
);
|
||||
|
||||
//
|
||||
// Set initial changed faces: set wallPoint for wall faces to wall centre
|
||||
//
|
||||
|
||||
// Count walls
|
||||
label nWalls = 0;
|
||||
forAll(mesh.boundary(), patchI)
|
||||
{
|
||||
const fvPatch& patch = mesh.boundary()[patchI];
|
||||
|
||||
if (isA<wallFvPatch>(patch))
|
||||
{
|
||||
nWalls += patch.size();
|
||||
}
|
||||
}
|
||||
|
||||
List<wallPoint> faceDist(nWalls);
|
||||
labelList changedFaces(nWalls);
|
||||
|
||||
label nChangedFaces = 0;
|
||||
forAll(mesh.boundary(), patchI)
|
||||
{
|
||||
const fvPatch& patch = mesh.boundary()[patchI];
|
||||
|
||||
if (isA<wallFvPatch>(patch))
|
||||
{
|
||||
forAll(patch.Cf(), patchFaceI)
|
||||
{
|
||||
const polyPatch& polyPatch = mesh.boundaryMesh()[patchI];
|
||||
|
||||
label meshFaceI = polyPatch.start() + patchFaceI;
|
||||
|
||||
changedFaces[nChangedFaces] = meshFaceI;
|
||||
|
||||
faceDist[nChangedFaces] =
|
||||
wallPoint(patch.Cf()[patchFaceI], 0.0);
|
||||
|
||||
nChangedFaces++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<wallPoint> allFaceInfo(mesh.nFaces());
|
||||
List<wallPoint> allCellInfo(mesh.nCells());
|
||||
|
||||
FaceCellWave<wallPoint> wallDistCalc
|
||||
(
|
||||
mesh,
|
||||
changedFaces,
|
||||
faceDist,
|
||||
allFaceInfo,
|
||||
allCellInfo,
|
||||
0 // max iterations
|
||||
);
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
while (runTime.loop())
|
||||
{
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
|
||||
label nCells = wallDistCalc.faceToCell();
|
||||
|
||||
Info<< " Total changed cells : " << nCells << endl;
|
||||
|
||||
if (nCells == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
label nFaces = wallDistCalc.cellToFace();
|
||||
|
||||
Info<< " Total changed faces : " << nFaces << endl;
|
||||
|
||||
if (nFaces == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Copy face and cell values into field
|
||||
//
|
||||
|
||||
label nIllegal = 0;
|
||||
|
||||
// Copy cell values
|
||||
forAll(allCellInfo, cellI)
|
||||
{
|
||||
scalar dist = allCellInfo[cellI].distSqr();
|
||||
if (allCellInfo[cellI].valid(wallDistCalc.data()))
|
||||
{
|
||||
wallDistUncorrected[cellI] = Foam::sqrt(dist);
|
||||
}
|
||||
else
|
||||
{
|
||||
wallDistUncorrected[cellI] = -1;
|
||||
nIllegal++;
|
||||
}
|
||||
}
|
||||
|
||||
// Copy boundary values
|
||||
forAll(wallDistUncorrected.boundaryField(), patchI)
|
||||
{
|
||||
fvPatchScalarField& patchField =
|
||||
wallDistUncorrected.boundaryField()[patchI];
|
||||
|
||||
forAll(patchField, patchFaceI)
|
||||
{
|
||||
const label meshFaceI = patchField.patch().start() + patchFaceI;
|
||||
|
||||
scalar dist = allFaceInfo[meshFaceI].distSqr();
|
||||
if (allFaceInfo[meshFaceI].valid(wallDistCalc.data()))
|
||||
{
|
||||
patchField[patchFaceI] = Foam::sqrt(dist);
|
||||
}
|
||||
else
|
||||
{
|
||||
patchField[patchFaceI] = dist;
|
||||
nIllegal++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "nIllegal:" << nIllegal << endl;
|
||||
|
||||
|
||||
//
|
||||
// Write it
|
||||
//
|
||||
|
||||
wallDistUncorrected.write();
|
||||
|
||||
Info<< "ExecutionTime = "
|
||||
<< runTime.elapsedCpuTime()
|
||||
<< " s\n" << endl << endl;
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,135 +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/>.
|
||||
|
||||
Description
|
||||
Calculate distance to wall.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "wallDistData.H"
|
||||
#include "wallPointData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createMesh.H"
|
||||
|
||||
Info<< "Mesh read in = "
|
||||
<< runTime.cpuTimeIncrement()
|
||||
<< " s\n" << endl << endl;
|
||||
|
||||
|
||||
Info<< "Time now = " << runTime.timeName() << endl;
|
||||
|
||||
// wall distance and reflection vectors
|
||||
|
||||
volVectorField n
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"n",
|
||||
mesh.time().timeName(),
|
||||
mesh
|
||||
),
|
||||
mesh,
|
||||
dimensionedVector("n", dimLength, point::max)
|
||||
);
|
||||
|
||||
// Fill wall patches with unit normal
|
||||
forAll(mesh.boundary(), patchI)
|
||||
{
|
||||
const fvPatch& patch = mesh.boundary()[patchI];
|
||||
|
||||
if (isA<wallFvPatch>(patch))
|
||||
{
|
||||
fvPatchVectorField& wallData = n.boundaryField()[patchI];
|
||||
|
||||
forAll(patch.Cf(), patchFaceI)
|
||||
{
|
||||
wallData[patchFaceI] = patch.Cf()[patchFaceI];
|
||||
wallData[patchFaceI] /= Foam::mag(wallData[patchFaceI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Do distance calculation, transporting values of n.
|
||||
wallDistData<wallPointData<vector> > y(mesh, n, true);
|
||||
|
||||
if (y.nUnset() != 0)
|
||||
{
|
||||
WarningIn(args.executable())
|
||||
<< "There are " << y.nUnset()
|
||||
<< " remaining unset cells and/or boundary values" << endl;
|
||||
}
|
||||
|
||||
|
||||
y.write();
|
||||
y.data().write();
|
||||
|
||||
runTime++;
|
||||
|
||||
Info<< "Time now = " << runTime.timeName() << endl;
|
||||
|
||||
|
||||
// Move points
|
||||
|
||||
boundBox meshBb(mesh.points());
|
||||
|
||||
pointField newPoints(mesh.points());
|
||||
|
||||
const point half(0.5*(meshBb.min() + meshBb.max()));
|
||||
|
||||
forAll(newPoints, pointI)
|
||||
{
|
||||
point& pt = newPoints[pointI];
|
||||
|
||||
// expand around half
|
||||
pt.y() += pt.y() - half.y();
|
||||
}
|
||||
|
||||
mesh.movePoints(newPoints);
|
||||
|
||||
mesh.write();
|
||||
|
||||
y.correct();
|
||||
|
||||
y.write();
|
||||
y.data().write();
|
||||
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,119 +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/>.
|
||||
|
||||
Description
|
||||
Calculate distance to wall.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "wallDistData.H"
|
||||
#include "wallPointYPlus.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createMesh.H"
|
||||
|
||||
Info<< "Mesh read in = "
|
||||
<< runTime.cpuTimeIncrement()
|
||||
<< " s\n" << endl << endl;
|
||||
|
||||
|
||||
Info<< "Time now = " << runTime.timeName() << endl;
|
||||
|
||||
// wall distance and yStar
|
||||
|
||||
volScalarField yStar
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"yStar",
|
||||
mesh.time().timeName(),
|
||||
mesh
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("yStar", dimless, 1.0)
|
||||
);
|
||||
|
||||
// Fill wall patches of yStar with some value.
|
||||
forAll(mesh.boundary(), patchI)
|
||||
{
|
||||
const fvPatch& patch = mesh.boundary()[patchI];
|
||||
|
||||
if (isA<wallFvPatch>(patch))
|
||||
{
|
||||
fvPatchScalarField& wallData = yStar.boundaryField()[patchI];
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
{
|
||||
// Hack. Just some value.
|
||||
wallData[patchFaceI] = 1/2500.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Do distance calculation, transporting values of yStar
|
||||
wallPointYPlus::yPlusCutOff = 200;
|
||||
wallDistData<wallPointYPlus> y(mesh, yStar, true);
|
||||
|
||||
if (y.nUnset() != 0)
|
||||
{
|
||||
WarningIn(args.executable())
|
||||
<< "There are " << y.nUnset()
|
||||
<< " remaining unset cells and/or boundary values" << endl;
|
||||
}
|
||||
|
||||
|
||||
y.write();
|
||||
|
||||
y.data().write();
|
||||
|
||||
volScalarField yPlus
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"yPlus",
|
||||
mesh.time().timeName(),
|
||||
mesh
|
||||
),
|
||||
y/y.data()
|
||||
);
|
||||
|
||||
yPlus.write();
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
3
applications/test/wallDist/Make/files
Normal file
3
applications/test/wallDist/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-wallDist.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-wallDist
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Calculate distance to wall.
|
||||
Calculate and write the distance-to-wall field for a moving mesh.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -48,6 +48,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "Time now = " << runTime.timeName() << endl;
|
||||
|
||||
// Wall-reflection vectors
|
||||
const volVectorField& n = wallDist::New(mesh).n();
|
||||
n.write();
|
||||
|
||||
// Wall distance
|
||||
const volScalarField& y = wallDist::New(mesh).y();
|
||||
y.write();
|
||||
@ -74,8 +78,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
mesh.movePoints(newPoints);
|
||||
mesh.write();
|
||||
|
||||
y.correct();
|
||||
n.write();
|
||||
y.write();
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
Reference in New Issue
Block a user