mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -1,3 +0,0 @@
|
|||||||
channelFoam.C
|
|
||||||
|
|
||||||
EXE = $(FOAM_APPBIN)/channelFoam
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
EXE_INC = \
|
|
||||||
-I$(LIB_SRC)/turbulenceModels \
|
|
||||||
-I$(LIB_SRC)/turbulenceModels/incompressible/LES/LESModel \
|
|
||||||
-I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude \
|
|
||||||
-I$(LIB_SRC)/transportModels \
|
|
||||||
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
|
|
||||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
|
||||||
-I$(LIB_SRC)/sampling/lnInclude
|
|
||||||
|
|
||||||
EXE_LIBS = \
|
|
||||||
-lincompressibleLESModels \
|
|
||||||
-lincompressibleTransportModels \
|
|
||||||
-lfiniteVolume \
|
|
||||||
-lmeshTools
|
|
||||||
@ -1,154 +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/>.
|
|
||||||
|
|
||||||
Application
|
|
||||||
channelFoam
|
|
||||||
|
|
||||||
Description
|
|
||||||
Incompressible LES solver for flow in a channel.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "fvCFD.H"
|
|
||||||
#include "singlePhaseTransportModel.H"
|
|
||||||
#include "LESModel.H"
|
|
||||||
#include "IFstream.H"
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "Random.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
#include "setRootCase.H"
|
|
||||||
#include "createTime.H"
|
|
||||||
#include "createMesh.H"
|
|
||||||
#include "readTransportProperties.H"
|
|
||||||
#include "createFields.H"
|
|
||||||
#include "initContinuityErrs.H"
|
|
||||||
#include "createGradP.H"
|
|
||||||
|
|
||||||
Info<< "\nStarting time loop\n" << endl;
|
|
||||||
|
|
||||||
while (runTime.loop())
|
|
||||||
{
|
|
||||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
|
||||||
|
|
||||||
#include "readPISOControls.H"
|
|
||||||
|
|
||||||
#include "CourantNo.H"
|
|
||||||
|
|
||||||
sgsModel->correct();
|
|
||||||
|
|
||||||
fvVectorMatrix UEqn
|
|
||||||
(
|
|
||||||
fvm::ddt(U)
|
|
||||||
+ fvm::div(phi, U)
|
|
||||||
+ sgsModel->divDevBeff(U)
|
|
||||||
==
|
|
||||||
flowDirection*gradP
|
|
||||||
);
|
|
||||||
|
|
||||||
if (momentumPredictor)
|
|
||||||
{
|
|
||||||
solve(UEqn == -fvc::grad(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// --- PISO loop
|
|
||||||
|
|
||||||
volScalarField rAU(1.0/UEqn.A());
|
|
||||||
|
|
||||||
for (int corr=0; corr<nCorr; corr++)
|
|
||||||
{
|
|
||||||
U = rAU*UEqn.H();
|
|
||||||
phi = (fvc::interpolate(U) & mesh.Sf())
|
|
||||||
+ fvc::ddtPhiCorr(rAU, U, phi);
|
|
||||||
|
|
||||||
adjustPhi(phi, U, p);
|
|
||||||
|
|
||||||
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
|
||||||
{
|
|
||||||
fvScalarMatrix pEqn
|
|
||||||
(
|
|
||||||
fvm::laplacian(rAU, p) == fvc::div(phi)
|
|
||||||
);
|
|
||||||
|
|
||||||
pEqn.setReference(pRefCell, pRefValue);
|
|
||||||
|
|
||||||
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
|
|
||||||
{
|
|
||||||
pEqn.solve(mesh.solver(p.name() + "Final"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pEqn.solve(mesh.solver(p.name()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nonOrth == nNonOrthCorr)
|
|
||||||
{
|
|
||||||
phi -= pEqn.flux();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "continuityErrs.H"
|
|
||||||
|
|
||||||
U -= rAU*fvc::grad(p);
|
|
||||||
U.correctBoundaryConditions();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Correct driving force for a constant mass flow rate
|
|
||||||
|
|
||||||
// Extract the velocity in the flow direction
|
|
||||||
dimensionedScalar magUbarStar =
|
|
||||||
(flowDirection & U)().weightedAverage(mesh.V());
|
|
||||||
|
|
||||||
// Calculate the pressure gradient increment needed to
|
|
||||||
// adjust the average flow-rate to the correct value
|
|
||||||
dimensionedScalar gragPplus =
|
|
||||||
(magUbar - magUbarStar)/rAU.weightedAverage(mesh.V());
|
|
||||||
|
|
||||||
U += flowDirection*rAU*gragPplus;
|
|
||||||
|
|
||||||
gradP += gragPplus;
|
|
||||||
|
|
||||||
Info<< "Uncorrected Ubar = " << magUbarStar.value() << tab
|
|
||||||
<< "pressure gradient = " << gradP.value() << endl;
|
|
||||||
|
|
||||||
runTime.write();
|
|
||||||
|
|
||||||
#include "writeGradP.H"
|
|
||||||
|
|
||||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
|
||||||
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
|
||||||
<< nl << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
Info<< "End\n" << endl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
Info<< "Reading field p\n" << endl;
|
|
||||||
volScalarField p
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"p",
|
|
||||||
runTime.timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::AUTO_WRITE
|
|
||||||
),
|
|
||||||
mesh
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
Info<< "Reading field U\n" << endl;
|
|
||||||
volVectorField U
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"U",
|
|
||||||
runTime.timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::AUTO_WRITE
|
|
||||||
),
|
|
||||||
mesh
|
|
||||||
);
|
|
||||||
|
|
||||||
# include "createPhi.H"
|
|
||||||
|
|
||||||
|
|
||||||
label pRefCell = 0;
|
|
||||||
scalar pRefValue = 0.0;
|
|
||||||
setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue);
|
|
||||||
|
|
||||||
|
|
||||||
singlePhaseTransportModel laminarTransport(U, phi);
|
|
||||||
|
|
||||||
autoPtr<incompressible::LESModel> sgsModel
|
|
||||||
(
|
|
||||||
incompressible::LESModel::New(U, phi, laminarTransport)
|
|
||||||
);
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
dimensionedScalar gradP
|
|
||||||
(
|
|
||||||
"gradP",
|
|
||||||
dimensionSet(0, 1, -2, 0, 0),
|
|
||||||
0.0
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
IFstream gradPFile
|
|
||||||
(
|
|
||||||
runTime.path()/runTime.timeName()/"uniform"/"gradP.raw"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (gradPFile.good())
|
|
||||||
{
|
|
||||||
gradPFile >> gradP;
|
|
||||||
Info<< "Reading average pressure gradient" <<endl
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Info<< "Initializing with 0 pressure gradient" <<endl
|
|
||||||
<< endl;
|
|
||||||
};
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
Info<< "\nReading transportProperties\n" << endl;
|
|
||||||
IOdictionary transportProperties
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"transportProperties",
|
|
||||||
runTime.constant(),
|
|
||||||
mesh,
|
|
||||||
IOobject::MUST_READ_IF_MODIFIED,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
dimensionedScalar nu
|
|
||||||
(
|
|
||||||
transportProperties.lookup("nu")
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Read centerline velocity for channel simulations
|
|
||||||
dimensionedVector Ubar
|
|
||||||
(
|
|
||||||
transportProperties.lookup("Ubar")
|
|
||||||
);
|
|
||||||
|
|
||||||
dimensionedScalar magUbar = mag(Ubar);
|
|
||||||
vector flowDirection = (Ubar/magUbar).value();
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
if (runTime.outputTime())
|
|
||||||
{
|
|
||||||
OFstream gradPFile
|
|
||||||
(
|
|
||||||
runTime.path()/runTime.timeName()/"uniform"/"gradP.raw"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (gradPFile.good())
|
|
||||||
{
|
|
||||||
gradPFile << gradP << endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalErrorIn(args.executable())
|
|
||||||
<< "Cannot open file "
|
|
||||||
<< runTime.path()/runTime.timeName()/"uniform"/"gradP.raw"
|
|
||||||
<< exit(FatalError);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -36,7 +36,6 @@ void Foam::interpolation2DTable<Type>::readTable()
|
|||||||
|
|
||||||
// Read data from file
|
// Read data from file
|
||||||
reader_()(fName, *this);
|
reader_()(fName, *this);
|
||||||
//IFstream(fName)() >> *this;
|
|
||||||
|
|
||||||
if (this->empty())
|
if (this->empty())
|
||||||
{
|
{
|
||||||
@ -361,7 +360,6 @@ void Foam::interpolation2DTable<Type>::write(Ostream& os) const
|
|||||||
{
|
{
|
||||||
reader_->write(os);
|
reader_->write(os);
|
||||||
}
|
}
|
||||||
//*this >> os;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -654,100 +652,6 @@ Type Foam::interpolation2DTable<Type>::operator()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
label loY2 = 0;
|
|
||||||
label hiY2 = 0;
|
|
||||||
|
|
||||||
nY = matrix::operator[](hiX).second().size();
|
|
||||||
|
|
||||||
minLimit = matrix::operator[](loX).second()[0].first();
|
|
||||||
maxLimit = matrix::operator[](loX).second()[nY-1].first();
|
|
||||||
|
|
||||||
if (lookupValue < minLimit)
|
|
||||||
{
|
|
||||||
switch (boundsHandling_)
|
|
||||||
{
|
|
||||||
case interpolation2DTable::ERROR:
|
|
||||||
{
|
|
||||||
FatalErrorIn
|
|
||||||
(
|
|
||||||
"Foam::interpolation2DTable<Type>::operator[]"
|
|
||||||
"(const scalar, const scalar) const"
|
|
||||||
) << "value (" << lookupValue << ") underflow" << nl
|
|
||||||
<< exit(FatalError);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case interpolation2DTable::WARN:
|
|
||||||
{
|
|
||||||
WarningIn
|
|
||||||
(
|
|
||||||
"Foam::interpolation2DTable<Type>::operator[]"
|
|
||||||
"(const scalar, const scalar) const"
|
|
||||||
) << "value (" << lookupValue << ") underflow" << nl
|
|
||||||
<< " Continuing with the first entry"
|
|
||||||
<< endl;
|
|
||||||
// fall-through to 'CLAMP'
|
|
||||||
}
|
|
||||||
case interpolation2DTable::CLAMP:
|
|
||||||
{
|
|
||||||
loY2 = 0;
|
|
||||||
loY2 = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (lookupValue >= maxLimit)
|
|
||||||
{
|
|
||||||
switch (boundsHandling_)
|
|
||||||
{
|
|
||||||
case interpolation2DTable::ERROR:
|
|
||||||
{
|
|
||||||
FatalErrorIn
|
|
||||||
(
|
|
||||||
"Foam::interpolation2DTable<Type>::operator[]"
|
|
||||||
"(const scalar, const scalar) const"
|
|
||||||
) << "value (" << lookupValue << ") overflow" << nl
|
|
||||||
<< exit(FatalError);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case interpolation2DTable::WARN:
|
|
||||||
{
|
|
||||||
WarningIn
|
|
||||||
(
|
|
||||||
"Foam::interpolation2DTable<Type>::operator[]"
|
|
||||||
"(const scalar, const scalar) const"
|
|
||||||
) << "value (" << lookupValue << ") overflow" << nl
|
|
||||||
<< " Continuing with the last entry"
|
|
||||||
<< endl;
|
|
||||||
// fall-through to 'CLAMP'
|
|
||||||
}
|
|
||||||
case interpolation2DTable::CLAMP:
|
|
||||||
{
|
|
||||||
loY2 = nY-1;
|
|
||||||
loY2 = nY;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Finds the lo and hi of Y on the high x
|
|
||||||
for (label i = 0; i < nY; ++i)
|
|
||||||
{
|
|
||||||
if
|
|
||||||
(
|
|
||||||
lookupValue >= matrix::operator[](hiX).second()[i].first()
|
|
||||||
)
|
|
||||||
{
|
|
||||||
loY2 = hiY2 = i;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hiY2 = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loX == hiX)
|
if (loX == hiX)
|
||||||
{
|
{
|
||||||
// we are at the end of the table - or there is only a single entry
|
// we are at the end of the table - or there is only a single entry
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -36,6 +36,8 @@ void Foam::processorLduInterface::send
|
|||||||
const UList<Type>& f
|
const UList<Type>& f
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
label nBytes = f.byteSize();
|
||||||
|
|
||||||
if (commsType == Pstream::blocking || commsType == Pstream::scheduled)
|
if (commsType == Pstream::blocking || commsType == Pstream::scheduled)
|
||||||
{
|
{
|
||||||
OPstream::write
|
OPstream::write
|
||||||
@ -43,32 +45,32 @@ void Foam::processorLduInterface::send
|
|||||||
commsType,
|
commsType,
|
||||||
neighbProcNo(),
|
neighbProcNo(),
|
||||||
reinterpret_cast<const char*>(f.begin()),
|
reinterpret_cast<const char*>(f.begin()),
|
||||||
f.byteSize(),
|
nBytes,
|
||||||
tag()
|
tag()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (commsType == Pstream::nonBlocking)
|
else if (commsType == Pstream::nonBlocking)
|
||||||
{
|
{
|
||||||
resizeBuf(receiveBuf_, f.size()*sizeof(Type));
|
resizeBuf(receiveBuf_, nBytes);
|
||||||
|
|
||||||
IPstream::read
|
IPstream::read
|
||||||
(
|
(
|
||||||
commsType,
|
commsType,
|
||||||
neighbProcNo(),
|
neighbProcNo(),
|
||||||
receiveBuf_.begin(),
|
receiveBuf_.begin(),
|
||||||
receiveBuf_.size(),
|
nBytes,
|
||||||
tag()
|
tag()
|
||||||
);
|
);
|
||||||
|
|
||||||
resizeBuf(sendBuf_, f.byteSize());
|
resizeBuf(sendBuf_, nBytes);
|
||||||
memcpy(sendBuf_.begin(), f.begin(), f.byteSize());
|
memcpy(sendBuf_.begin(), f.begin(), nBytes);
|
||||||
|
|
||||||
OPstream::write
|
OPstream::write
|
||||||
(
|
(
|
||||||
commsType,
|
commsType,
|
||||||
neighbProcNo(),
|
neighbProcNo(),
|
||||||
sendBuf_.begin(),
|
sendBuf_.begin(),
|
||||||
f.byteSize(),
|
nBytes,
|
||||||
tag()
|
tag()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -172,7 +174,7 @@ void Foam::processorLduInterface::compressedSend
|
|||||||
commsType,
|
commsType,
|
||||||
neighbProcNo(),
|
neighbProcNo(),
|
||||||
receiveBuf_.begin(),
|
receiveBuf_.begin(),
|
||||||
receiveBuf_.size(),
|
nBytes,
|
||||||
tag()
|
tag()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,24 @@ Description
|
|||||||
Storage and named access for the indices of a tet which is part of
|
Storage and named access for the indices of a tet which is part of
|
||||||
the decomposition of a cell.
|
the decomposition of a cell.
|
||||||
|
|
||||||
|
Tets are designated by
|
||||||
|
- cell (of course)
|
||||||
|
- face on cell
|
||||||
|
- three points on face (faceBasePt, facePtA, facePtB)
|
||||||
|
When constructing from a mesh and index in the face (tetPtI):
|
||||||
|
- faceBasePt is the mesh.tetBasePtIs() base point
|
||||||
|
- facePtA is tetPtI away from faceBasePt
|
||||||
|
- facePtB is next one after/before facePtA
|
||||||
|
e.g.:
|
||||||
|
|
||||||
|
+---+
|
||||||
|
|2 /|
|
||||||
|
| / |
|
||||||
|
|/ 1| <- tetPt (so 1 for first triangle, 2 for second)
|
||||||
|
+---+
|
||||||
|
^
|
||||||
|
faceBasePt
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
tetIndicesI.H
|
tetIndicesI.H
|
||||||
tetIndices.C
|
tetIndices.C
|
||||||
|
|||||||
@ -45,11 +45,7 @@ void processorFvPatchField<scalar>::initInterfaceMatrixUpdate
|
|||||||
{
|
{
|
||||||
this->patch().patchInternalField(psiInternal, scalarSendBuf_);
|
this->patch().patchInternalField(psiInternal, scalarSendBuf_);
|
||||||
|
|
||||||
if
|
if (commsType == Pstream::nonBlocking && !Pstream::floatTransfer)
|
||||||
(
|
|
||||||
Pstream::defaultCommsType == Pstream::nonBlocking
|
|
||||||
&& !Pstream::floatTransfer
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// Fast path.
|
// Fast path.
|
||||||
if (debug && !this->ready())
|
if (debug && !this->ready())
|
||||||
@ -122,6 +118,7 @@ void processorFvPatchField<scalar>::updateInterfaceMatrix
|
|||||||
{
|
{
|
||||||
UPstream::waitRequest(outstandingRecvRequest_);
|
UPstream::waitRequest(outstandingRecvRequest_);
|
||||||
}
|
}
|
||||||
|
// Recv finished so assume sending finished as well.
|
||||||
outstandingSendRequest_ = -1;
|
outstandingSendRequest_ = -1;
|
||||||
outstandingRecvRequest_ = -1;
|
outstandingRecvRequest_ = -1;
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ sampledSet/polyLine/polyLineSet.C
|
|||||||
sampledSet/face/faceOnlySet.C
|
sampledSet/face/faceOnlySet.C
|
||||||
sampledSet/midPoint/midPointSet.C
|
sampledSet/midPoint/midPointSet.C
|
||||||
sampledSet/midPointAndFace/midPointAndFaceSet.C
|
sampledSet/midPointAndFace/midPointAndFaceSet.C
|
||||||
/* sampledSet/patchSeed/patchSeedSet.C */
|
sampledSet/patchSeed/patchSeedSet.C
|
||||||
sampledSet/sampledSet/sampledSet.C
|
sampledSet/sampledSet/sampledSet.C
|
||||||
sampledSet/sampledSets/sampledSets.C
|
sampledSet/sampledSets/sampledSets.C
|
||||||
sampledSet/sampledSets/sampledSetsGrouping.C
|
sampledSet/sampledSets/sampledSetsGrouping.C
|
||||||
|
|||||||
239
src/sampling/sampledSet/patchSeed/patchSeedSet.C
Normal file
239
src/sampling/sampledSet/patchSeed/patchSeedSet.C
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012 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 "patchSeedSet.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "treeBoundBox.H"
|
||||||
|
#include "treeDataFace.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "meshTools.H"
|
||||||
|
//#include "Random.H"
|
||||||
|
// For 'facePoint' helper function only
|
||||||
|
#include "mappedPatchBase.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(patchSeedSet, 0);
|
||||||
|
addToRunTimeSelectionTable(sampledSet, patchSeedSet, word);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::patchSeedSet::calcSamples
|
||||||
|
(
|
||||||
|
DynamicList<point>& samplingPts,
|
||||||
|
DynamicList<label>& samplingCells,
|
||||||
|
DynamicList<label>& samplingFaces,
|
||||||
|
DynamicList<label>& samplingSegments,
|
||||||
|
DynamicList<scalar>& samplingCurveDist
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "patchSeedSet : sampling on patches :" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct search tree for all patch faces.
|
||||||
|
label sz = 0;
|
||||||
|
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||||
|
{
|
||||||
|
const polyPatch& pp = mesh().boundaryMesh()[iter.key()];
|
||||||
|
|
||||||
|
sz += pp.size();
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< " " << pp.name() << " size " << pp.size() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
labelList patchFaces(sz);
|
||||||
|
sz = 0;
|
||||||
|
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||||
|
{
|
||||||
|
const polyPatch& pp = mesh().boundaryMesh()[iter.key()];
|
||||||
|
forAll(pp, i)
|
||||||
|
{
|
||||||
|
patchFaces[sz++] = pp.start()+i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
label totalSize = returnReduce(sz, sumOp<label>());
|
||||||
|
|
||||||
|
|
||||||
|
// Shuffle and truncate if in random mode
|
||||||
|
if (maxPoints_ < totalSize)
|
||||||
|
{
|
||||||
|
// Check what fraction of maxPoints_ I need to generate locally.
|
||||||
|
label myMaxPoints = label(scalar(sz)/totalSize*maxPoints_);
|
||||||
|
|
||||||
|
rndGenPtr_.reset(new Random(123456));
|
||||||
|
Random& rndGen = rndGenPtr_();
|
||||||
|
|
||||||
|
labelList subset = identity(sz);
|
||||||
|
for (label iter = 0; iter < 4; iter++)
|
||||||
|
{
|
||||||
|
forAll(subset, i)
|
||||||
|
{
|
||||||
|
label j = rndGen.integer(0, subset.size()-1);
|
||||||
|
Swap(subset[i], subset[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Truncate
|
||||||
|
subset.setSize(myMaxPoints);
|
||||||
|
|
||||||
|
// Subset patchFaces
|
||||||
|
patchFaces = UIndirectList<label>(patchFaces, subset)();
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "In random mode : selected " << patchFaces
|
||||||
|
<< " faces out of " << sz << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get points on patchFaces.
|
||||||
|
globalIndex globalSampleNumbers(patchFaces.size());
|
||||||
|
|
||||||
|
samplingPts.setCapacity(patchFaces.size());
|
||||||
|
samplingCells.setCapacity(patchFaces.size());
|
||||||
|
samplingFaces.setCapacity(patchFaces.size());
|
||||||
|
samplingSegments.setCapacity(patchFaces.size());
|
||||||
|
samplingCurveDist.setCapacity(patchFaces.size());
|
||||||
|
|
||||||
|
// For calculation of min-decomp tet base points
|
||||||
|
(void)mesh().tetBasePtIs();
|
||||||
|
|
||||||
|
forAll(patchFaces, i)
|
||||||
|
{
|
||||||
|
label faceI = patchFaces[i];
|
||||||
|
pointIndexHit info = mappedPatchBase::facePoint
|
||||||
|
(
|
||||||
|
mesh(),
|
||||||
|
faceI,
|
||||||
|
polyMesh::FACEDIAGTETS
|
||||||
|
);
|
||||||
|
label cellI = mesh().faceOwner()[faceI];
|
||||||
|
|
||||||
|
if (info.hit())
|
||||||
|
{
|
||||||
|
// Move the point into the cell
|
||||||
|
const point& cc = mesh().cellCentres()[cellI];
|
||||||
|
samplingPts.append
|
||||||
|
(
|
||||||
|
info.hitPoint() + 1E-1*(cc-info.hitPoint())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
samplingPts.append(info.rawPoint());
|
||||||
|
}
|
||||||
|
samplingCells.append(cellI);
|
||||||
|
samplingFaces.append(faceI);
|
||||||
|
samplingSegments.append(0);
|
||||||
|
samplingCurveDist.append(globalSampleNumbers.toGlobal(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::patchSeedSet::genSamples()
|
||||||
|
{
|
||||||
|
// Storage for sample points
|
||||||
|
DynamicList<point> samplingPts;
|
||||||
|
DynamicList<label> samplingCells;
|
||||||
|
DynamicList<label> samplingFaces;
|
||||||
|
DynamicList<label> samplingSegments;
|
||||||
|
DynamicList<scalar> samplingCurveDist;
|
||||||
|
|
||||||
|
calcSamples
|
||||||
|
(
|
||||||
|
samplingPts,
|
||||||
|
samplingCells,
|
||||||
|
samplingFaces,
|
||||||
|
samplingSegments,
|
||||||
|
samplingCurveDist
|
||||||
|
);
|
||||||
|
|
||||||
|
samplingPts.shrink();
|
||||||
|
samplingCells.shrink();
|
||||||
|
samplingFaces.shrink();
|
||||||
|
samplingSegments.shrink();
|
||||||
|
samplingCurveDist.shrink();
|
||||||
|
|
||||||
|
setSamples
|
||||||
|
(
|
||||||
|
samplingPts,
|
||||||
|
samplingCells,
|
||||||
|
samplingFaces,
|
||||||
|
samplingSegments,
|
||||||
|
samplingCurveDist
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::patchSeedSet::patchSeedSet
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const polyMesh& mesh,
|
||||||
|
meshSearch& searchEngine,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
sampledSet(name, mesh, searchEngine, dict),
|
||||||
|
patchSet_
|
||||||
|
(
|
||||||
|
mesh.boundaryMesh().patchSet
|
||||||
|
(
|
||||||
|
wordReList(dict.lookup("patches"))
|
||||||
|
)
|
||||||
|
),
|
||||||
|
//searchDist_(readScalar(dict.lookup("maxDistance"))),
|
||||||
|
//offsetDist_(readScalar(dict.lookup("offsetDist"))),
|
||||||
|
maxPoints_(readLabel(dict.lookup("maxPoints")))
|
||||||
|
{
|
||||||
|
genSamples();
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
write(Info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::patchSeedSet::~patchSeedSet()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
133
src/sampling/sampledSet/patchSeed/patchSeedSet.H
Normal file
133
src/sampling/sampledSet/patchSeed/patchSeedSet.H
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012 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::patchSeedSet
|
||||||
|
|
||||||
|
Description
|
||||||
|
Initialises points on or just off patch
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
patchSeedSet.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef patchSeedSet_H
|
||||||
|
#define patchSeedSet_H
|
||||||
|
|
||||||
|
#include "sampledSet.H"
|
||||||
|
#include "DynamicList.H"
|
||||||
|
#include "HashSet.H"
|
||||||
|
#include "Random.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class patchSeedSet Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class patchSeedSet
|
||||||
|
:
|
||||||
|
public sampledSet
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Patches to sample
|
||||||
|
const labelHashSet patchSet_;
|
||||||
|
|
||||||
|
// //- Maximum distance to look for nearest
|
||||||
|
// const scalar searchDist_;
|
||||||
|
//
|
||||||
|
// //- Offset distance
|
||||||
|
// const scalar offsetDist_;
|
||||||
|
|
||||||
|
//- Maximum number of patch faces to seed
|
||||||
|
const label maxPoints_;
|
||||||
|
|
||||||
|
//- Random number generator (if maxPoints < num patch faces)
|
||||||
|
autoPtr<Random> rndGenPtr_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Samples all points in sampleCoords.
|
||||||
|
void calcSamples
|
||||||
|
(
|
||||||
|
DynamicList<point>& samplingPts,
|
||||||
|
DynamicList<label>& samplingCells,
|
||||||
|
DynamicList<label>& samplingFaces,
|
||||||
|
DynamicList<label>& samplingSegments,
|
||||||
|
DynamicList<scalar>& samplingCurveDist
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Uses calcSamples to obtain samples. Copies them into *this.
|
||||||
|
void genSamples();
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("patchSeed");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
// //- Construct from components
|
||||||
|
// patchSeedSet
|
||||||
|
// (
|
||||||
|
// const word& name,
|
||||||
|
// const polyMesh& mesh,
|
||||||
|
// meshSearch& searchEngine,
|
||||||
|
// const word& axis,
|
||||||
|
// const List<point>& sampleCoords,
|
||||||
|
// const labelHashSet& patchSet,
|
||||||
|
// const scalar searchDist
|
||||||
|
// );
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
patchSeedSet
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const polyMesh& mesh,
|
||||||
|
meshSearch& searchEngine,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~patchSeedSet();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
/*--------------------------------*- 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;
|
||||||
|
location "constant";
|
||||||
|
object sourcesProperties;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
momentumSource
|
||||||
|
{
|
||||||
|
type pressureGradientExplicitSource;
|
||||||
|
active on; //on/off switch
|
||||||
|
timeStart 0.0; //start time
|
||||||
|
duration 1000000.0; //duration
|
||||||
|
selectionMode all; //cellSet // points //cellZone
|
||||||
|
|
||||||
|
pressureGradientExplicitSourceCoeffs
|
||||||
|
{
|
||||||
|
fieldNames (U);
|
||||||
|
Ubar ( 0.1335 0 0 );
|
||||||
|
gradPini gradPIni [0 1 -2 0 0 ] 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*--------------------------------*- 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;
|
||||||
|
location "constant";
|
||||||
|
object turbulenceProperties;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
simulationType LESModel;
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -15,7 +15,7 @@ FoamFile
|
|||||||
}
|
}
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
application channelFoam;
|
application pimpleFoam;
|
||||||
|
|
||||||
startFrom startTime;
|
startFrom startTime;
|
||||||
|
|
||||||
@ -33,41 +33,25 @@ solvers
|
|||||||
relTol 0;
|
relTol 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
U
|
"(U|k)"
|
||||||
{
|
{
|
||||||
solver PBiCG;
|
solver PBiCG;
|
||||||
preconditioner DILU;
|
preconditioner DILU;
|
||||||
tolerance 1e-05;
|
tolerance 1e-05;
|
||||||
relTol 0;
|
relTol 0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
k
|
"(U|k)Final"
|
||||||
{
|
{
|
||||||
solver PBiCG;
|
$U;
|
||||||
preconditioner DILU;
|
|
||||||
tolerance 1e-05;
|
|
||||||
relTol 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
B
|
|
||||||
{
|
|
||||||
solver PBiCG;
|
|
||||||
preconditioner DILU;
|
|
||||||
tolerance 1e-05;
|
|
||||||
relTol 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
nuTilda
|
|
||||||
{
|
|
||||||
solver PBiCG;
|
|
||||||
preconditioner DILU;
|
|
||||||
tolerance 1e-05;
|
tolerance 1e-05;
|
||||||
relTol 0;
|
relTol 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PISO
|
PIMPLE
|
||||||
{
|
{
|
||||||
|
nOuterCorrectors 1;
|
||||||
nCorrectors 2;
|
nCorrectors 2;
|
||||||
nNonOrthogonalCorrectors 0;
|
nNonOrthogonalCorrectors 0;
|
||||||
pRefCell 1001;
|
pRefCell 1001;
|
||||||
Reference in New Issue
Block a user