Compare commits
150 Commits
feature-lo
...
feature-PD
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ed3fcd4c0 | |||
| 18cd5d864e | |||
| 73207dfcd7 | |||
| 6d6c204745 | |||
| 04f3b26ba6 | |||
| 5e539b30a9 | |||
| 6ca6b34add | |||
| e9dcc59c4d | |||
| c5dece6a09 | |||
| 6068148c22 | |||
| a92cd03a89 | |||
| 9ee0023bc0 | |||
| 0923c1277c | |||
| 06a0bf1868 | |||
| 6d4e72dc3f | |||
| eb33b7957e | |||
| 5bc846553c | |||
| 9207140e37 | |||
| d7b1a666b5 | |||
| f7dc0d8edb | |||
| 8427eccd00 | |||
| 9a39481062 | |||
| fbfc09979e | |||
| a0fe5e4fb2 | |||
| 8afed765be | |||
| 66865b9fbc | |||
| 260db42f7f | |||
| 7f17a71f9c | |||
| 05d0a4f1d4 | |||
| 4bd1bd7522 | |||
| 3e431de285 | |||
| 12efbd8965 | |||
| 5af5222141 | |||
| 4a80672afb | |||
| 3db12bbdef | |||
| dbaed65d75 | |||
| 723edc1c61 | |||
| 7456335ba6 | |||
| 0d21f248a9 | |||
| 062fad4662 | |||
| a4dc2cc94b | |||
| 9f5b8d0ebb | |||
| dfe98fdf67 | |||
| 2811c05444 | |||
| dc0372858d | |||
| 373d88a4c4 | |||
| d5260b18d7 | |||
| c77194e6a1 | |||
| b012475c01 | |||
| 05bf4e119a | |||
| 19bd7ed21f | |||
| e82956a9dc | |||
| 5a8caa35b2 | |||
| a16c4ae920 | |||
| 9f53fdcc36 | |||
| bb07945ad2 | |||
| 27ec25dfef | |||
| a629fb7db2 | |||
| 75769add98 | |||
| b700456ac4 | |||
| 75f13e1890 | |||
| ea2e24b6c7 | |||
| 8fa0921556 | |||
| 696704a0dd | |||
| 4fdeb3be83 | |||
| b89f389606 | |||
| 4c501c4567 | |||
| cf3d983b80 | |||
| e2d7ad5c60 | |||
| 649b1b1971 | |||
| 67204543d0 | |||
| 8534983b0a | |||
| cfde0d679a | |||
| 7ffa36dfa9 | |||
| 5d3f355d9d | |||
| 2eae536a70 | |||
| d119b8b8f9 | |||
| 821222834d | |||
| f7e4b374d9 | |||
| d0b59a4529 | |||
| 73339d4985 | |||
| 6dbaeaba50 | |||
| 36159cb16d | |||
| 95748b0183 | |||
| 7d83fb792a | |||
| 4981061c09 | |||
| ae674b2809 | |||
| ba300c3c6f | |||
| 0fb515298d | |||
| aee0c30a3e | |||
| c2204eaa27 | |||
| 24d6497209 | |||
| 27ea73f905 | |||
| 5ec8a4d4b1 | |||
| 7754e5bd6c | |||
| 4c3a95c808 | |||
| 7a99866db0 | |||
| 8fe0d1bacd | |||
| 4c7f92d29c | |||
| bcae4b7a4f | |||
| e646218af9 | |||
| ba4a675cd3 | |||
| 31ecf0d732 | |||
| 6ac8e06245 | |||
| 46dbfabd9d | |||
| 4a166c6f3e | |||
| 9d765adaf4 | |||
| 8268d8aaba | |||
| b179cd355e | |||
| 27a676ca20 | |||
| 341aea0f5c | |||
| b9f7f04bed | |||
| a98fbcd493 | |||
| 54ebe724ea | |||
| 0dd91a9dc4 | |||
| 97448c655d | |||
| c3c4f30a55 | |||
| a89ecdeee0 | |||
| bc430ccdef | |||
| 25246f22a6 | |||
| 348c2a87ad | |||
| df777ce3c6 | |||
| b017ef47bb | |||
| faba8ee2a1 | |||
| 89f2cda3ab | |||
| 627d79dba6 | |||
| c51bfdcd05 | |||
| 3e4341ad02 | |||
| 5de23079ea | |||
| 8ad61f8e9d | |||
| 56b5234fbc | |||
| ccde68d410 | |||
| 9da5215786 | |||
| 2f6082712e | |||
| 811a83599e | |||
| b1a27d3d00 | |||
| be783632f2 | |||
| 61dd6aa701 | |||
| 4421021e99 | |||
| 0b68f14f7d | |||
| df74e8448c | |||
| a939042e1b | |||
| 08efeb1a03 | |||
| e697ac277f | |||
| b966b7cd4b | |||
| b7c8a45de2 | |||
| 7b5c6868dd | |||
| cb924ec3d2 | |||
| 1bc2ffad99 | |||
| 3b949b66ff |
@ -33,6 +33,7 @@ It is likely incomplete...
|
||||
- Haakan Nilsson
|
||||
- Niklas Nordin
|
||||
- Mark Olesen
|
||||
- Victor Olesen
|
||||
- Evangelos Papoutsis-Kiachagias
|
||||
- Juho Peltola
|
||||
- Johan Roenby
|
||||
@ -49,3 +50,7 @@ It is likely incomplete...
|
||||
- Norbert Weber
|
||||
- Henry Weller
|
||||
- Niklas Wikstrom
|
||||
- Thorsten Zirwes
|
||||
|
||||
|
||||
<!----------------------------------------------------------------------------->
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
api=2011
|
||||
patch=201012
|
||||
api=2012
|
||||
patch=0
|
||||
|
||||
3
applications/solvers/acoustic/acousticFoam/Make/files
Normal file
3
applications/solvers/acoustic/acousticFoam/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
acousticFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/acousticFoam
|
||||
14
applications/solvers/acoustic/acousticFoam/Make/options
Normal file
14
applications/solvers/acoustic/acousticFoam/Make/options
Normal file
@ -0,0 +1,14 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/fvOption/lnInclude \
|
||||
-I$(LIB_SRC)/regionFaModels/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels/compressible/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lfvOptions \
|
||||
-lmeshTools \
|
||||
-lsampling \
|
||||
-lregionFaModels
|
||||
99
applications/solvers/acoustic/acousticFoam/acousticFoam.C
Normal file
99
applications/solvers/acoustic/acousticFoam/acousticFoam.C
Normal file
@ -0,0 +1,99 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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
|
||||
acousticFoam
|
||||
|
||||
Group
|
||||
grpAcousticSolvers
|
||||
|
||||
Description
|
||||
Acoustic solver solving the acoustic pressure wave equation.
|
||||
|
||||
\f[
|
||||
\ddt2{pa} - c^2 \laplacian{pa} = 0
|
||||
\f]
|
||||
|
||||
where
|
||||
\vartable
|
||||
c | Sound speed
|
||||
pa | Acoustic pressure
|
||||
\endvartable
|
||||
|
||||
SourceFiles
|
||||
acousticFoam.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "fvOptions.H"
|
||||
#include "pimpleControl.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addNote
|
||||
(
|
||||
"Acoustic solver solving the acoustic pressure wave equation."
|
||||
);
|
||||
|
||||
#include "postProcess.H"
|
||||
|
||||
#include "addCheckCaseOptions.H"
|
||||
#include "setRootCaseLists.H"
|
||||
#include "createTime.H"
|
||||
#include "createMesh.H"
|
||||
#include "createControl.H"
|
||||
#include "createRegionControls.H"
|
||||
|
||||
#include "readTransportProperties.H"
|
||||
#include "createFields.H"
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
while (runTime.run())
|
||||
{
|
||||
++runTime;
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
while (pimple.correct())
|
||||
{
|
||||
#include "paEqn.H"
|
||||
}
|
||||
|
||||
runTime.write();
|
||||
|
||||
runTime.printExecutionTime(Info);
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
15
applications/solvers/acoustic/acousticFoam/createFields.H
Normal file
15
applications/solvers/acoustic/acousticFoam/createFields.H
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
Info << "\nReading pa" << endl;
|
||||
|
||||
volScalarField pa
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pa",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
@ -0,0 +1,8 @@
|
||||
fvSolution solutionDict(runTime);
|
||||
|
||||
const dictionary& pimpleDict = solutionDict.subDict("PIMPLE");
|
||||
|
||||
bool solvePrimaryRegion
|
||||
(
|
||||
pimpleDict.getOrDefault("solvePrimaryRegion", true)
|
||||
);
|
||||
15
applications/solvers/acoustic/acousticFoam/paEqn.H
Normal file
15
applications/solvers/acoustic/acousticFoam/paEqn.H
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
fvScalarMatrix paEqn
|
||||
(
|
||||
fvm::d2dt2(pa) - sqr(c0)*fvc::laplacian(pa)
|
||||
);
|
||||
|
||||
if (solvePrimaryRegion)
|
||||
{
|
||||
paEqn.relax();
|
||||
paEqn.solve();
|
||||
}
|
||||
else
|
||||
{
|
||||
pa.correctBoundaryConditions();
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
Info<< "\nReading transportProperties" << endl;
|
||||
|
||||
IOdictionary transportProperties
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"transportProperties",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
dimensionedScalar c0("c0", dimVelocity, transportProperties);
|
||||
|
||||
dimensionedScalar rho("rho", dimDensity, transportProperties);
|
||||
|
||||
scalar MaxCo =
|
||||
max(mesh.surfaceInterpolation::deltaCoeffs()*c0).value()
|
||||
*runTime.deltaT().value();
|
||||
|
||||
Info<< "Max acoustic Courant Number = " << MaxCo << endl;
|
||||
@ -14,7 +14,9 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
|
||||
-I$(LIB_SRC)/regionModels/regionModel/lnInclude
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
|
||||
-I$(LIB_SRC)/regionFaModels/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
@ -28,4 +30,8 @@ EXE_LIBS = \
|
||||
-lturbulenceModels \
|
||||
-lcompressibleTurbulenceModels \
|
||||
-lradiationModels \
|
||||
-lregionModels
|
||||
-lfvOptions \
|
||||
-lfaOptions \
|
||||
-lregionModels \
|
||||
-lsampling \
|
||||
-lregionFaModels
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
EXE_INC = \
|
||||
-DFULLDEBUG -g -O0 \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
const volScalarField& rho = trho();
|
||||
volScalarField& h = thermo.he();
|
||||
const volScalarField& betav = *betavPtr;
|
||||
|
||||
@ -4,13 +4,6 @@ autoPtr<solidThermo> pThermo(solidThermo::New(mesh));
|
||||
solidThermo& thermo = pThermo();
|
||||
|
||||
tmp<volScalarField> trho = thermo.rho();
|
||||
const volScalarField& rho = trho();
|
||||
|
||||
tmp<volScalarField> tcp = thermo.Cp();
|
||||
const volScalarField& cp = tcp();
|
||||
|
||||
volScalarField& p = thermo.p();
|
||||
volScalarField& h = thermo.he();
|
||||
|
||||
autoPtr<coordinateSystem> coordinatesPtr;
|
||||
autoPtr<volSymmTensorField> taniAlpha;
|
||||
@ -96,7 +89,6 @@ else
|
||||
)
|
||||
);
|
||||
}
|
||||
const volScalarField& betav = *betavPtr;
|
||||
|
||||
#include "createRadiationModel.H"
|
||||
#include "createFvOptions.H"
|
||||
|
||||
@ -60,6 +60,7 @@ int main(int argc, char *argv[])
|
||||
#include "createTime.H"
|
||||
#include "createDynamicFvMesh.H"
|
||||
#include "createFields.H"
|
||||
#include "createFieldRefs.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,13 +37,13 @@ Description
|
||||
#include "fvCFD.H"
|
||||
#include "dynamicFvMesh.H"
|
||||
#include "singlePhaseTransportModel.H"
|
||||
#include "PhaseIncompressibleTurbulenceModel.H"
|
||||
#include "DPMIncompressibleTurbulenceModel.H"
|
||||
#include "pimpleControl.H"
|
||||
#include "CorrectPhi.H"
|
||||
|
||||
#ifdef MPPIC
|
||||
#include "basicKinematicMPPICCloud.H"
|
||||
#define basicKinematicTypeCloud basicKinematicMPPICCloud
|
||||
#include "basicKinematicCloud.H"
|
||||
#define basicKinematicTypeCloud basicKinematicCloud
|
||||
#else
|
||||
#include "basicKinematicCollidingCloud.H"
|
||||
#define basicKinematicTypeCloud basicKinematicCollidingCloud
|
||||
@ -110,7 +111,6 @@ int main(int argc, char *argv[])
|
||||
continuousPhaseTransport.correct();
|
||||
muc = rhoc*continuousPhaseTransport.nu();
|
||||
|
||||
Info<< "Evolving " << kinematicCloud.name() << endl;
|
||||
kinematicCloud.evolve();
|
||||
|
||||
// Update continuous phase volume fraction field
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
EXE_INC = \
|
||||
-I.. \
|
||||
-I../.. \
|
||||
-I../DPMTurbulenceModels/lnInclude \
|
||||
-I../../DPMTurbulenceModels \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
EXE_INC = \
|
||||
-I.. \
|
||||
-I../DPMTurbulenceModels/lnInclude \
|
||||
-I../DPMTurbulenceModels \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -38,12 +39,12 @@ Description
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "singlePhaseTransportModel.H"
|
||||
#include "PhaseIncompressibleTurbulenceModel.H"
|
||||
#include "DPMIncompressibleTurbulenceModel.H"
|
||||
#include "pimpleControl.H"
|
||||
|
||||
#ifdef MPPIC
|
||||
#include "basicKinematicMPPICCloud.H"
|
||||
#define basicKinematicTypeCloud basicKinematicMPPICCloud
|
||||
#include "basicKinematicCloud.H"
|
||||
#define basicKinematicTypeCloud basicKinematicCloud
|
||||
#else
|
||||
#include "basicKinematicCollidingCloud.H"
|
||||
#define basicKinematicTypeCloud basicKinematicCollidingCloud
|
||||
@ -117,6 +118,12 @@ int main(int argc, char *argv[])
|
||||
cloudVolSUSu.correctBoundaryConditions();
|
||||
cloudSU.source() = Zero;
|
||||
|
||||
// cloudVolSUSu.primitiveFieldRef() =
|
||||
// (cloudSU.diag()*Uc() - cloudSU.source())/mesh.V();
|
||||
// cloudVolSUSu.correctBoundaryConditions();
|
||||
// cloudSU.source() = cloudSU.diag()*Uc();
|
||||
|
||||
|
||||
// --- Pressure-velocity PIMPLE corrector loop
|
||||
while (pimple.loop())
|
||||
{
|
||||
|
||||
@ -0,0 +1,186 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "DPMIncompressibleTurbulenceModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class TransportModel>
|
||||
Foam::DPMIncompressibleTurbulenceModel<TransportModel>::
|
||||
DPMIncompressibleTurbulenceModel
|
||||
(
|
||||
const word& type,
|
||||
const volScalarField& alpha,
|
||||
const geometricOneField& rho,
|
||||
const volVectorField& U,
|
||||
const surfaceScalarField& alphaRhoPhi,
|
||||
const surfaceScalarField& phi,
|
||||
const TransportModel& transportModel,
|
||||
const word& propertiesName
|
||||
)
|
||||
:
|
||||
TurbulenceModel
|
||||
<
|
||||
volScalarField,
|
||||
geometricOneField,
|
||||
incompressibleTurbulenceModel,
|
||||
TransportModel
|
||||
>
|
||||
(
|
||||
alpha,
|
||||
rho,
|
||||
U,
|
||||
alphaRhoPhi,
|
||||
phi,
|
||||
transportModel,
|
||||
propertiesName
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class TransportModel>
|
||||
Foam::autoPtr<Foam::DPMIncompressibleTurbulenceModel<TransportModel>>
|
||||
Foam::DPMIncompressibleTurbulenceModel<TransportModel>::New
|
||||
(
|
||||
const volScalarField& alpha,
|
||||
const volVectorField& U,
|
||||
const surfaceScalarField& alphaRhoPhi,
|
||||
const surfaceScalarField& phi,
|
||||
const TransportModel& transportModel,
|
||||
const word& propertiesName
|
||||
)
|
||||
{
|
||||
return autoPtr<DPMIncompressibleTurbulenceModel>
|
||||
(
|
||||
static_cast<DPMIncompressibleTurbulenceModel*>(
|
||||
TurbulenceModel
|
||||
<
|
||||
volScalarField,
|
||||
geometricOneField,
|
||||
incompressibleTurbulenceModel,
|
||||
TransportModel
|
||||
>::New
|
||||
(
|
||||
alpha,
|
||||
geometricOneField(),
|
||||
U,
|
||||
alphaRhoPhi,
|
||||
phi,
|
||||
transportModel,
|
||||
propertiesName
|
||||
).ptr())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class TransportModel>
|
||||
Foam::tmp<Foam::volScalarField>
|
||||
Foam::DPMIncompressibleTurbulenceModel<TransportModel>::pPrime() const
|
||||
{
|
||||
return tmp<volScalarField>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
IOobject::groupName("pPrime", this->alphaRhoPhi_.group()),
|
||||
this->runTime_.timeName(),
|
||||
this->mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
this->mesh_,
|
||||
dimensionedScalar(dimPressure, Zero)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class TransportModel>
|
||||
Foam::tmp<Foam::surfaceScalarField>
|
||||
Foam::DPMIncompressibleTurbulenceModel<TransportModel>::pPrimef() const
|
||||
{
|
||||
return tmp<surfaceScalarField>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
IOobject::groupName("pPrimef", this->alphaRhoPhi_.group()),
|
||||
this->runTime_.timeName(),
|
||||
this->mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
this->mesh_,
|
||||
dimensionedScalar(dimPressure, Zero)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class TransportModel>
|
||||
Foam::tmp<Foam::volSymmTensorField>
|
||||
Foam::DPMIncompressibleTurbulenceModel<TransportModel>::devReff() const
|
||||
{
|
||||
return devRhoReff();
|
||||
}
|
||||
|
||||
|
||||
template<class TransportModel>
|
||||
Foam::tmp<Foam::fvVectorMatrix>
|
||||
Foam::DPMIncompressibleTurbulenceModel<TransportModel>::divDevReff
|
||||
(
|
||||
volVectorField& U
|
||||
) const
|
||||
{
|
||||
return divDevRhoReff(U);
|
||||
}
|
||||
|
||||
|
||||
template<class TransportModel>
|
||||
Foam::tmp<Foam::volSymmTensorField>
|
||||
Foam::DPMIncompressibleTurbulenceModel<TransportModel>::devRhoReff() const
|
||||
{
|
||||
NotImplemented;
|
||||
|
||||
return devReff();
|
||||
}
|
||||
|
||||
|
||||
template<class TransportModel>
|
||||
Foam::tmp<Foam::fvVectorMatrix>
|
||||
Foam::DPMIncompressibleTurbulenceModel<TransportModel>::divDevRhoReff
|
||||
(
|
||||
volVectorField& U
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
|
||||
return divDevReff(U);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,144 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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::DPMIncompressibleTurbulenceModel
|
||||
|
||||
Description
|
||||
Templated abstract base class for volumen occupancy incompressible
|
||||
turbulence models.
|
||||
|
||||
SourceFiles
|
||||
DPMIncompressibleTurbulenceModel.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef DPMIncompressibleTurbulenceModel_H
|
||||
#define DPMIncompressibleTurbulenceModel_H
|
||||
|
||||
#include "TurbulenceModel.H"
|
||||
#include "incompressibleTurbulenceModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class DPMIncompressibleTurbulenceModel Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class TransportModel>
|
||||
class DPMIncompressibleTurbulenceModel
|
||||
:
|
||||
public TurbulenceModel
|
||||
<
|
||||
volScalarField,
|
||||
geometricOneField,
|
||||
incompressibleTurbulenceModel,
|
||||
TransportModel
|
||||
>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
typedef volScalarField alphaField;
|
||||
typedef geometricOneField rhoField;
|
||||
typedef TransportModel transportModel;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct
|
||||
DPMIncompressibleTurbulenceModel
|
||||
(
|
||||
const word& type,
|
||||
const alphaField& alpha,
|
||||
const geometricOneField& rho,
|
||||
const volVectorField& U,
|
||||
const surfaceScalarField& alphaRhoPhi,
|
||||
const surfaceScalarField& phi,
|
||||
const TransportModel& transportModel,
|
||||
const word& propertiesName
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected turbulence model
|
||||
static autoPtr<DPMIncompressibleTurbulenceModel> New
|
||||
(
|
||||
const alphaField& alpha,
|
||||
const volVectorField& U,
|
||||
const surfaceScalarField& alphaRhoPhi,
|
||||
const surfaceScalarField& phi,
|
||||
const TransportModel& transportModel,
|
||||
const word& propertiesName = turbulenceModel::propertiesName
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~DPMIncompressibleTurbulenceModel() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the phase-pressure'
|
||||
// (derivative of phase-pressure w.r.t. phase-fraction)
|
||||
virtual tmp<volScalarField> pPrime() const;
|
||||
|
||||
//- Return the face-phase-pressure'
|
||||
// (derivative of phase-pressure w.r.t. phase-fraction)
|
||||
virtual tmp<surfaceScalarField> pPrimef() const;
|
||||
|
||||
//- Return the effective stress tensor
|
||||
virtual tmp<volSymmTensorField> devReff() const;
|
||||
|
||||
//- Return the source term for the momentum equation
|
||||
virtual tmp<fvVectorMatrix> divDevReff(volVectorField& U) const;
|
||||
|
||||
//- Return the effective stress tensor
|
||||
virtual tmp<volSymmTensorField> devRhoReff() const;
|
||||
|
||||
//- Return the source term for the momentum equation
|
||||
virtual tmp<fvVectorMatrix> divDevRhoReff(volVectorField& U) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "DPMIncompressibleTurbulenceModel.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,7 +25,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PhaseIncompressibleTurbulenceModel.H"
|
||||
#include "DPMIncompressibleTurbulenceModel.H"
|
||||
#include "singlePhaseTransportModel.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "makeTurbulenceModel.H"
|
||||
@ -41,7 +41,7 @@ defineTurbulenceModelTypes
|
||||
volScalarField,
|
||||
geometricOneField,
|
||||
incompressibleTurbulenceModel,
|
||||
PhaseIncompressibleTurbulenceModel,
|
||||
DPMIncompressibleTurbulenceModel,
|
||||
singlePhaseTransportModel
|
||||
);
|
||||
|
||||
@ -50,21 +50,21 @@ makeBaseTurbulenceModel
|
||||
volScalarField,
|
||||
geometricOneField,
|
||||
incompressibleTurbulenceModel,
|
||||
PhaseIncompressibleTurbulenceModel,
|
||||
DPMIncompressibleTurbulenceModel,
|
||||
singlePhaseTransportModel
|
||||
);
|
||||
|
||||
#define makeLaminarModel(Type) \
|
||||
makeTemplatedTurbulenceModel \
|
||||
(singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, laminar, Type)
|
||||
(singlePhaseTransportModelDPMIncompressibleTurbulenceModel, laminar, Type)
|
||||
|
||||
#define makeRASModel(Type) \
|
||||
makeTemplatedTurbulenceModel \
|
||||
(singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, RAS, Type)
|
||||
(singlePhaseTransportModelDPMIncompressibleTurbulenceModel, RAS, Type)
|
||||
|
||||
#define makeLESModel(Type) \
|
||||
makeTemplatedTurbulenceModel \
|
||||
(singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, LES, Type)
|
||||
(singlePhaseTransportModelDPMIncompressibleTurbulenceModel, LES, Type)
|
||||
|
||||
#include "Stokes.H"
|
||||
makeLaminarModel(Stokes);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
EXE_INC = \
|
||||
-I.. \
|
||||
-I../DPMTurbulenceModels/lnInclude \
|
||||
-I../DPMTurbulenceModels \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
EXE_INC = \
|
||||
-I./DPMTurbulenceModels/lnInclude \
|
||||
-I./DPMTurbulenceModels \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
@ -13,7 +13,6 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
|
||||
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/phaseIncompressible/lnInclude \
|
||||
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
|
||||
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude
|
||||
|
||||
|
||||
@ -160,10 +160,11 @@ surfaceScalarField alphaPhic
|
||||
alphacf*phic
|
||||
);
|
||||
|
||||
autoPtr<PhaseIncompressibleTurbulenceModel<singlePhaseTransportModel>>
|
||||
|
||||
autoPtr<DPMIncompressibleTurbulenceModel<singlePhaseTransportModel>>
|
||||
continuousPhaseTurbulence
|
||||
(
|
||||
PhaseIncompressibleTurbulenceModel<singlePhaseTransportModel>::New
|
||||
DPMIncompressibleTurbulenceModel<singlePhaseTransportModel>::New
|
||||
(
|
||||
alphac,
|
||||
Uc,
|
||||
|
||||
@ -2,6 +2,8 @@ EXE_INC = \
|
||||
-I../reactingParcelFoam \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I${LIB_SRC}/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
|
||||
-I${LIB_SRC}/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
|
||||
@ -27,6 +29,8 @@ EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lfvOptions \
|
||||
-lmeshTools \
|
||||
-ldynamicMesh \
|
||||
-ldynamicFvMesh \
|
||||
-lsampling \
|
||||
-lturbulenceModels \
|
||||
-lcompressibleTurbulenceModels \
|
||||
|
||||
@ -81,7 +81,15 @@ else if (pimple.SIMPLErho())
|
||||
rho = thermo.rho();
|
||||
}
|
||||
|
||||
// Correct rhoUf if the mesh is moving
|
||||
fvc::correctRhoUf(rhoUf, rho, U, phi);
|
||||
|
||||
if (thermo.dpdt())
|
||||
{
|
||||
dpdt = fvc::ddt(p);
|
||||
|
||||
if (mesh.moving())
|
||||
{
|
||||
dpdt -= fvc::div(fvc::meshPhi(rho, U), p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,8 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I${LIB_SRC}/sampling/lnInclude \
|
||||
-I${LIB_SRC}/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \
|
||||
@ -28,6 +30,8 @@ EXE_LIBS = \
|
||||
-lfvOptions \
|
||||
-lsampling \
|
||||
-lmeshTools \
|
||||
-ldynamicMesh \
|
||||
-ldynamicFvMesh \
|
||||
-lturbulenceModels \
|
||||
-lcompressibleTurbulenceModels \
|
||||
-lspecie \
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,8 +37,8 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "dynamicFvMesh.H"
|
||||
#include "turbulentFluidThermoModel.H"
|
||||
|
||||
#include "surfaceFilmModel.H"
|
||||
#include "rhoReactionThermo.H"
|
||||
#include "CombustionModel.H"
|
||||
@ -47,6 +47,7 @@ Description
|
||||
#include "fvOptions.H"
|
||||
#include "pimpleControl.H"
|
||||
#include "pressureControl.H"
|
||||
#include "CorrectPhi.H"
|
||||
#include "localEulerDdtScheme.H"
|
||||
#include "fvcSmooth.H"
|
||||
#include "cloudMacros.H"
|
||||
@ -76,13 +77,13 @@ int main(int argc, char *argv[])
|
||||
#include "addCheckCaseOptions.H"
|
||||
#include "setRootCaseLists.H"
|
||||
#include "createTime.H"
|
||||
#include "createMesh.H"
|
||||
#include "createControl.H"
|
||||
#include "createTimeControls.H"
|
||||
#include "createDynamicFvMesh.H"
|
||||
#include "createDyMControls.H"
|
||||
#include "createFields.H"
|
||||
#include "createFieldRefs.H"
|
||||
#include "createRegionControls.H"
|
||||
#include "initContinuityErrs.H"
|
||||
#include "createRhoUfIfPresent.H"
|
||||
|
||||
turbulence->validate();
|
||||
|
||||
@ -98,7 +99,23 @@ int main(int argc, char *argv[])
|
||||
|
||||
while (runTime.run())
|
||||
{
|
||||
#include "readTimeControls.H"
|
||||
#include "readDyMControls.H"
|
||||
|
||||
// Store divrhoU from the previous mesh
|
||||
// so that it can be mapped and used in correctPhi
|
||||
// to ensure the corrected phi has the same divergence
|
||||
autoPtr<volScalarField> divrhoU;
|
||||
if (solvePrimaryRegion && correctPhi)
|
||||
{
|
||||
divrhoU.reset
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
"divrhoU",
|
||||
fvc::div(fvc::absolute(phi, rho, U))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (LTS)
|
||||
{
|
||||
@ -114,6 +131,44 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
// Store momentum to set rhoUf for introduced faces.
|
||||
autoPtr<volVectorField> rhoU;
|
||||
if (solvePrimaryRegion && rhoUf.valid())
|
||||
{
|
||||
rhoU.reset(new volVectorField("rhoU", rho*U));
|
||||
}
|
||||
|
||||
// Store the particle positions
|
||||
parcels.storeGlobalPositions();
|
||||
|
||||
// Do any mesh changes
|
||||
mesh.update();
|
||||
|
||||
if (solvePrimaryRegion && mesh.changing())
|
||||
{
|
||||
gh = (g & mesh.C()) - ghRef;
|
||||
ghf = (g & mesh.Cf()) - ghRef;
|
||||
|
||||
MRF.update();
|
||||
|
||||
if (correctPhi)
|
||||
{
|
||||
// Calculate absolute flux
|
||||
// from the mapped surface velocity
|
||||
phi = mesh.Sf() & rhoUf();
|
||||
|
||||
#include "../../compressible/rhoPimpleFoam/correctPhi.H"
|
||||
|
||||
// Make the fluxes relative to the mesh-motion
|
||||
fvc::makeRelative(phi, rho, U);
|
||||
}
|
||||
|
||||
if (checkMeshCourantNo)
|
||||
{
|
||||
#include "meshCourantNo.H"
|
||||
}
|
||||
}
|
||||
|
||||
parcels.evolve();
|
||||
surfaceFilm.evolve();
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ License
|
||||
);
|
||||
}
|
||||
|
||||
// Update tho boundary values of the reciprocal time-step
|
||||
// Update the boundary values of the reciprocal time-step
|
||||
rDeltaT.correctBoundaryConditions();
|
||||
|
||||
// Spatially smooth the time scale field
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,7 +52,7 @@ Description
|
||||
#include "CorrectPhi.H"
|
||||
#include "fvcSmooth.H"
|
||||
|
||||
#include "basicKinematicMPPICCloud.H"
|
||||
#include "basicKinematicCloud.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -147,7 +147,7 @@ volScalarField alphacRho(alphac*rho);
|
||||
alphacRho.oldTime();
|
||||
|
||||
Info<< "Constructing kinematicCloud " << endl;
|
||||
basicKinematicMPPICCloud kinematicCloud
|
||||
basicKinematicCloud kinematicCloud
|
||||
(
|
||||
"kinematicCloud",
|
||||
rho,
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
EXE_INC = \
|
||||
-I../VoF \
|
||||
-I$(LIB_SRC)/phaseSystemModels/twoPhaseInter/incompressibleInterPhaseTransportModel/lnInclude \
|
||||
-I$(LIB_SRC)/phaseSystemModels/twoPhaseInter/VoFphaseIncompressibleTurbulenceModels/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
@ -10,6 +12,7 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/phaseIncompressible/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
@ -23,4 +26,6 @@ EXE_LIBS = \
|
||||
-limmiscibleIncompressibleTwoPhaseMixture \
|
||||
-lturbulenceModels \
|
||||
-lincompressibleTurbulenceModels \
|
||||
-lwaveModels
|
||||
-lwaveModels \
|
||||
-lVoFphaseTurbulentTransportModels \
|
||||
-lincompressibleInterPhaseTransportModels
|
||||
|
||||
@ -70,14 +70,19 @@ surfaceScalarField rhoPhi
|
||||
fvc::interpolate(rho)*phi
|
||||
);
|
||||
|
||||
typedef incompressibleInterPhaseTransportModel
|
||||
<
|
||||
immiscibleIncompressibleTwoPhaseMixture
|
||||
> transportModelType;
|
||||
|
||||
// Construct incompressible turbulence model
|
||||
autoPtr<incompressible::turbulenceModel> turbulence
|
||||
autoPtr<transportModelType> turbulence
|
||||
(
|
||||
incompressible::turbulenceModel::New(U, phi, mixture)
|
||||
new transportModelType
|
||||
(
|
||||
rho, U, phi, rhoPhi, mixture
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
#include "readGravitationalAcceleration.H"
|
||||
#include "readhRef.H"
|
||||
#include "gh.H"
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -45,6 +46,7 @@ Description
|
||||
#include "CrankNicolsonDdtScheme.H"
|
||||
#include "subCycle.H"
|
||||
#include "immiscibleIncompressibleTwoPhaseMixture.H"
|
||||
#include "incompressibleInterPhaseTransportModel.H"
|
||||
#include "turbulentTransportModel.H"
|
||||
#include "pimpleControl.H"
|
||||
#include "fvOptions.H"
|
||||
@ -76,8 +78,6 @@ int main(int argc, char *argv[])
|
||||
#include "initCorrectPhi.H"
|
||||
#include "createUfIfPresent.H"
|
||||
|
||||
turbulence->validate();
|
||||
|
||||
if (!LTS)
|
||||
{
|
||||
#include "CourantNo.H"
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
EXE_INC = \
|
||||
-I../VoF \
|
||||
-I$(LIB_SRC)/phaseSystemModels/twoPhaseInter/incompressibleInterPhaseTransportModel/lnInclude \
|
||||
-I$(LIB_SRC)/phaseSystemModels/twoPhaseInter/VoFphaseIncompressibleTurbulenceModels/lnInclude \
|
||||
-I../interFoam \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||
@ -14,6 +16,7 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/phaseIncompressible/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
@ -29,4 +32,6 @@ EXE_LIBS = \
|
||||
-lturbulenceModels \
|
||||
-lincompressibleTurbulenceModels \
|
||||
-lwaveModels \
|
||||
-lgeometricVoF
|
||||
-lgeometricVoF \
|
||||
-lVoFphaseTurbulentTransportModels \
|
||||
-lincompressibleInterPhaseTransportModels
|
||||
|
||||
@ -71,10 +71,17 @@ surfaceScalarField rhoPhi
|
||||
);
|
||||
|
||||
|
||||
// Construct incompressible turbulence model
|
||||
autoPtr<incompressible::turbulenceModel> turbulence
|
||||
typedef incompressibleInterPhaseTransportModel
|
||||
<
|
||||
immiscibleIncompressibleTwoPhaseMixture
|
||||
> transportModelType;
|
||||
|
||||
autoPtr<transportModelType> turbulence
|
||||
(
|
||||
incompressible::turbulenceModel::New(U, phi, mixture)
|
||||
new transportModelType
|
||||
(
|
||||
rho, U, phi, rhoPhi, mixture
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
Copyright (C) 2017 OpenCFD Ltd.
|
||||
Copyright (C) 2018 Johan Roenby
|
||||
Copyright (C) 2019-2020 DLR
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,7 +60,7 @@ Description
|
||||
#include "CrankNicolsonDdtScheme.H"
|
||||
#include "subCycle.H"
|
||||
#include "immiscibleIncompressibleTwoPhaseMixture.H"
|
||||
#include "turbulentTransportModel.H"
|
||||
#include "incompressibleInterPhaseTransportModel.H"
|
||||
#include "pimpleControl.H"
|
||||
#include "fvOptions.H"
|
||||
#include "CorrectPhi.H"
|
||||
@ -91,8 +92,6 @@ int main(int argc, char *argv[])
|
||||
#include "initCorrectPhi.H"
|
||||
#include "createUfIfPresent.H"
|
||||
|
||||
turbulence->validate();
|
||||
|
||||
#include "CourantNo.H"
|
||||
#include "setInitialDeltaT.H"
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -164,6 +164,23 @@ inline bool compare
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "bitSet::null()" << nl
|
||||
<< "sizeof : " << sizeof(bitSet::null()) << " bytes" << nl;
|
||||
|
||||
info(bitSet::null());
|
||||
|
||||
{
|
||||
bitSet emptySet;
|
||||
info(emptySet);
|
||||
extent(emptySet);
|
||||
|
||||
emptySet.resize(10);
|
||||
info(emptySet);
|
||||
extent(emptySet);
|
||||
}
|
||||
|
||||
Info<< nl << "Tests" << nl;
|
||||
|
||||
bitSet list1(22);
|
||||
// Set every third one on
|
||||
forAll(list1, i)
|
||||
|
||||
@ -36,6 +36,7 @@ Description
|
||||
#include "bitSet.H"
|
||||
#include "BitOps.H"
|
||||
#include "FlatOutput.H"
|
||||
#include "bitSetOrBoolList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -153,6 +154,24 @@ int main(int argc, char *argv[])
|
||||
Info<< "\nafter set [13,5]\n";
|
||||
compare(list1, "1..1..1..1..111111....");
|
||||
|
||||
{
|
||||
boolList list2(5, true);
|
||||
list2.unset(2);
|
||||
|
||||
Info<< "Test wrapper idea" << nl;
|
||||
|
||||
bitSetOrBoolList wrapper(list2);
|
||||
|
||||
if (wrapper.test(1))
|
||||
{
|
||||
Info<< "1 is on" << nl;
|
||||
}
|
||||
if (!wrapper.test(2))
|
||||
{
|
||||
Info<< "2 is off" << nl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "\nDone" << nl << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
102
applications/test/boolList/bitSetOrBoolList.H
Normal file
102
applications/test/boolList/bitSetOrBoolList.H
Normal file
@ -0,0 +1,102 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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::bitSetOrBoolList
|
||||
|
||||
Description
|
||||
Simple wrapper for handling test() on bitSet or boolList
|
||||
without a templating layer or lambda expresssion.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef bitSetOrBoolList_H
|
||||
#define bitSetOrBoolList_H
|
||||
|
||||
#include "bitSet.H"
|
||||
#include "boolList.H"
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class bitSetOrBoolList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class bitSetOrBoolList
|
||||
{
|
||||
const bitSet& bits_;
|
||||
const boolList& bools_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct with a bitSet reference
|
||||
explicit bitSetOrBoolList(const bitSet& select)
|
||||
:
|
||||
bits_(select),
|
||||
bools_(boolList::null())
|
||||
{}
|
||||
|
||||
//- Construct with a boolList reference
|
||||
explicit bitSetOrBoolList(const boolList& select)
|
||||
:
|
||||
bits_(bitSet::null()),
|
||||
bools_(select)
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Is empty
|
||||
bool empty() const
|
||||
{
|
||||
return bits_.empty() && bools_.empty();
|
||||
}
|
||||
|
||||
//- Size
|
||||
label size() const
|
||||
{
|
||||
return bits_.size() + bools_.size();
|
||||
}
|
||||
|
||||
//- Test function
|
||||
bool test(const label i) const
|
||||
{
|
||||
return bits_.test(i) || bools_.test(i);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
73
applications/test/boolList/disabledBoolList.H
Normal file
73
applications/test/boolList/disabledBoolList.H
Normal file
@ -0,0 +1,73 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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::disabledBoolList
|
||||
|
||||
Description
|
||||
A trivial structure to use as a boolList replacement when testing
|
||||
compilation without using the [] accessors.
|
||||
|
||||
Example,
|
||||
\code
|
||||
const disableBoolList blockedFace;
|
||||
...
|
||||
|
||||
if (blockedFace.test(facei)) ... // Good
|
||||
if (blockedFace[facei]) ... // Compile error
|
||||
\endcode
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef disabledBoolList_H
|
||||
#define disabledBoolList_H
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class disabledBoolList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
struct disabledBoolList
|
||||
{
|
||||
bool empty() const { return true; }
|
||||
|
||||
int size() const { return 0; }
|
||||
|
||||
bool test(int) const { return true; }
|
||||
|
||||
void set(bool) {}
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -37,6 +37,7 @@ Description
|
||||
#include "OSspecific.H"
|
||||
#include "fvCFD.H"
|
||||
#include "cpuTime.H"
|
||||
#include "volFields.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "regionProperties.H"
|
||||
#include "decompositionInformation.H"
|
||||
@ -89,7 +90,16 @@ int main(int argc, char *argv[])
|
||||
|
||||
// These are implicit so just ignore them
|
||||
argList::ignoreOptionCompat({"dry-run", 0}, false);
|
||||
argList::ignoreOptionCompat({"cellDist", 0}, false);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"cellDist",
|
||||
"Write cell distribution as volScalarField for visualization"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"cellDist-internal",
|
||||
"Write cell distribution (internal field) for visualization"
|
||||
);
|
||||
|
||||
// Include explicit constant options, have zero from time range
|
||||
timeSelector::addOptions(true, false);
|
||||
@ -236,6 +246,68 @@ int main(int argc, char *argv[])
|
||||
Info<< nl;
|
||||
}
|
||||
info.printSummary(Info);
|
||||
|
||||
|
||||
if (args.found("cellDist-internal"))
|
||||
{
|
||||
volScalarField::Internal cellDist
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"cellDist",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("cellDist", dimless, -1)
|
||||
);
|
||||
|
||||
forAll(cellToProc, celli)
|
||||
{
|
||||
cellDist[celli] = cellToProc[celli];
|
||||
}
|
||||
|
||||
cellDist.write();
|
||||
|
||||
Info<< nl << "Wrote decomposition as volScalarField::Internal to "
|
||||
<< cellDist.name() << " for visualization."
|
||||
<< endl;
|
||||
|
||||
fileHandler().flush();
|
||||
}
|
||||
else if (args.found("cellDist"))
|
||||
{
|
||||
volScalarField cellDist
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"cellDist",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("cellDist", dimless, -1),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
|
||||
forAll(cellToProc, celli)
|
||||
{
|
||||
cellDist[celli] = cellToProc[celli];
|
||||
}
|
||||
|
||||
cellDist.correctBoundaryConditions();
|
||||
cellDist.write();
|
||||
|
||||
Info<< nl << "Wrote decomposition as volScalarField to "
|
||||
<< cellDist.name() << " for visualization."
|
||||
<< endl;
|
||||
|
||||
fileHandler().flush();
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
3
applications/test/fileOperation1/Make/files
Normal file
3
applications/test/fileOperation1/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-fileOperation1.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-fileOperation1
|
||||
2
applications/test/fileOperation1/Make/options
Normal file
2
applications/test/fileOperation1/Make/options
Normal file
@ -0,0 +1,2 @@
|
||||
/* EXE_INC = */
|
||||
/* EXE_LIBS = */
|
||||
125
applications/test/fileOperation1/Test-fileOperation1.C
Normal file
125
applications/test/fileOperation1/Test-fileOperation1.C
Normal file
@ -0,0 +1,125 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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
|
||||
Test-fileOperation1
|
||||
|
||||
Description
|
||||
Test string parsing and other bits for fileOperation
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "fileName.H"
|
||||
#include "fileOperation.H"
|
||||
#include "SubList.H"
|
||||
#include "IOobject.H"
|
||||
#include "IOstreams.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
word toString(const fileOperation::procRangeType& group)
|
||||
{
|
||||
if (group.empty())
|
||||
{
|
||||
return word::null;
|
||||
}
|
||||
return Foam::name(group.first()) + "-" + Foam::name(group.last());
|
||||
}
|
||||
|
||||
|
||||
void testSplitPath(const fileName& pathName)
|
||||
{
|
||||
fileName path, procDir, local;
|
||||
fileOperation::procRangeType group;
|
||||
label nProcs;
|
||||
|
||||
const label proci =
|
||||
fileOperation::splitProcessorPath
|
||||
(
|
||||
pathName,
|
||||
path,
|
||||
procDir,
|
||||
local,
|
||||
group,
|
||||
nProcs
|
||||
);
|
||||
|
||||
|
||||
Info<< nl
|
||||
<< "Input = " << pathName << nl
|
||||
<< " path = " << path << nl
|
||||
<< " proc = " << procDir << nl
|
||||
<< " local = " << local << nl
|
||||
<< " group = " << group << " = " << toString(group) << nl
|
||||
<< " proci = " << proci << nl
|
||||
<< " nProcs = " << nProcs << nl;
|
||||
}
|
||||
|
||||
|
||||
void testSplitPaths(std::initializer_list<const char* const> dirNames)
|
||||
{
|
||||
for (const auto& dirName : dirNames)
|
||||
{
|
||||
testSplitPath(fileName(dirName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addArgument("fileName .. fileNameN");
|
||||
argList::addOption("istream", "file", "test Istream values");
|
||||
|
||||
|
||||
testSplitPaths
|
||||
({
|
||||
"foo/bar",
|
||||
"foo/processor5/system",
|
||||
"foo/processors100_0-5/constant",
|
||||
"foo/processors20_12-16/constant",
|
||||
"/new-processor-gen/case1/processors20",
|
||||
"/new-processor-gen/case1/processors100_0-5/constant",
|
||||
"/new-processor-gen/case1/processors/input",
|
||||
"devel/processor/ideas/processor0/system",
|
||||
|
||||
"/path/processor0Generation1/case1/processor10/input",
|
||||
|
||||
"path/processors100_ab-cd/constant",
|
||||
"path/processors100_a11-d00/constant",
|
||||
});
|
||||
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,6 +1,8 @@
|
||||
#!/bin/bash
|
||||
#. /home/mattijs/OpenFOAM/OpenFOAM-plus.feature-localWorld/etc/bashrc
|
||||
. $WM_PROJECT_DIR/etc/bashrc
|
||||
#cd /home/mattijs/OpenFOAM/OpenFOAM-plus.feature-localWorld/applications/test/multiWorld/chtMultiRegionSimpleFoam
|
||||
chtMultiRegionSimpleFoam -case ./fluid -world fluid 2>&1 | tee run_fluid.log
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
chtMultiRegionSimpleFoam -case fluid -world fluid 2>&1 | tee run_fluid.log
|
||||
read dummy
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#!/bin/bash
|
||||
. $WM_PROJECT_DIR/etc/bashrc
|
||||
#. /home/mattijs/OpenFOAM/OpenFOAM-plus.feature-localWorld/etc/bashrc
|
||||
#cd /home/mattijs/OpenFOAM/OpenFOAM-plus.feature-localWorld/applications/test/multiWorld/chtMultiRegionSimpleFoam
|
||||
chtMultiRegionSimpleFoam -case ./solid -world solid 2>&1 | tee run_solid.log
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
chtMultiRegionSimpleFoam -case solid -world solid 2>&1 | tee run_solid.log
|
||||
read dummy
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -57,7 +57,6 @@ Usage
|
||||
#include "Time.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "OSspecific.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -97,6 +96,22 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
argList::addOptionCompat("no-clean", {"noClean", -2006});
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"no-outer",
|
||||
"Create without any other region"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"print-dict",
|
||||
"Print blockMeshDict equivalent and exit"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"write-dict",
|
||||
"Write system/blockMeshDict.PDRblockMesh and exit"
|
||||
);
|
||||
|
||||
argList::addOption("dict", "file", "Alternative PDRblockMeshDict");
|
||||
argList::addOption
|
||||
(
|
||||
@ -111,6 +126,9 @@ int main(int argc, char *argv[])
|
||||
// Remove old files, unless disabled
|
||||
const bool removeOldFiles = !args.found("no-clean");
|
||||
|
||||
// Suppress creation of the outer region
|
||||
const bool noOuterRegion = args.found("no-outer");
|
||||
|
||||
const word regionName(polyMesh::defaultRegion);
|
||||
const word regionPath;
|
||||
|
||||
@ -149,8 +167,38 @@ int main(int argc, char *argv[])
|
||||
Info<< "Creating PDRblockMesh from "
|
||||
<< runTime.relativePath(dictIO.objectPath()) << endl;
|
||||
|
||||
// Always start from a PDRblock
|
||||
PDRblock blkMesh(meshDict, true);
|
||||
|
||||
if (args.found("print-dict"))
|
||||
{
|
||||
Info<< nl << "Equivalent blockMeshDict" << nl << nl;
|
||||
|
||||
blkMesh.blockMeshDict(Info, true);
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (args.found("write-dict"))
|
||||
{
|
||||
// Generate system/blockMeshDict and exit
|
||||
blkMesh.writeBlockMeshDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"blockMeshDict.PDRblockMesh",
|
||||
runTime.system(), // instance
|
||||
runTime, // registry
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false // Do not register
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Instance for resulting mesh
|
||||
if (useTime)
|
||||
@ -170,14 +218,19 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
Info<< nl << "Creating polyMesh from PDRblockMesh" << endl;
|
||||
if (noOuterRegion)
|
||||
{
|
||||
Info<< "Outer region disabled, using ijk generation" << nl;
|
||||
}
|
||||
|
||||
autoPtr<polyMesh> meshPtr =
|
||||
blkMesh.mesh
|
||||
(
|
||||
IOobject(regionName, meshInstance, runTime)
|
||||
);
|
||||
(
|
||||
args.found("no-outer")
|
||||
? blkMesh.innerMesh(IOobject(regionName, meshInstance, runTime))
|
||||
: blkMesh.mesh(IOobject(regionName, meshInstance, runTime))
|
||||
);
|
||||
|
||||
const polyMesh& mesh = *meshPtr;
|
||||
polyMesh& mesh = *meshPtr;
|
||||
|
||||
// Set the precision of the points data to 10
|
||||
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
|
||||
|
||||
@ -704,7 +704,7 @@ int main(int argc, char *argv[])
|
||||
regionName,
|
||||
runTimeExtruded.constant(),
|
||||
runTimeExtruded,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_READ, // Do not read primitives, do read fv*
|
||||
IOobject::AUTO_WRITE,
|
||||
false
|
||||
),
|
||||
|
||||
@ -16,6 +16,7 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I../vectorTools
|
||||
|
||||
EXE_LIBS = \
|
||||
@ -25,4 +26,5 @@ EXE_LIBS = \
|
||||
-ldecompose \
|
||||
-lmeshTools \
|
||||
-ldynamicMesh \
|
||||
-lsampling \
|
||||
-lfiniteVolume
|
||||
|
||||
@ -311,7 +311,7 @@ tmp<scalarField> signedDistance
|
||||
)
|
||||
{
|
||||
tmp<scalarField> tfld(new scalarField(points.size(), Foam::sqr(GREAT)));
|
||||
scalarField& fld = tfld();
|
||||
scalarField& fld = tfld.ref();
|
||||
|
||||
// Find nearest
|
||||
List<pointIndexHit> nearest;
|
||||
@ -713,8 +713,7 @@ int main(int argc, char *argv[])
|
||||
fvm,
|
||||
cellDistance,
|
||||
pointDistance,
|
||||
0, //distance,
|
||||
false //regularise
|
||||
scalar(0) // distance
|
||||
);
|
||||
|
||||
isoFaces.setSize(iso.size());
|
||||
|
||||
@ -154,6 +154,7 @@ int main(int argc, char *argv[])
|
||||
"cellShapes",
|
||||
"cellVolume",
|
||||
"cellVolumeRatio",
|
||||
"cellAspectRatio",
|
||||
"minTetVolume",
|
||||
"minPyrVolume",
|
||||
"cellRegion",
|
||||
|
||||
@ -133,12 +133,9 @@ void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
|
||||
<< endl;
|
||||
|
||||
// Construct shape recognizers
|
||||
hexMatcher hex;
|
||||
prismMatcher prism;
|
||||
wedgeMatcher wedge;
|
||||
pyrMatcher pyr;
|
||||
tetWedgeMatcher tetWedge;
|
||||
tetMatcher tet;
|
||||
|
||||
// Counters for different cell types
|
||||
label nHex = 0;
|
||||
@ -153,15 +150,15 @@ void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
|
||||
|
||||
for (label celli = 0; celli < mesh.nCells(); celli++)
|
||||
{
|
||||
if (hex.isA(mesh, celli))
|
||||
if (hexMatcher::test(mesh, celli))
|
||||
{
|
||||
nHex++;
|
||||
}
|
||||
else if (tet.isA(mesh, celli))
|
||||
else if (tetMatcher::test(mesh, celli))
|
||||
{
|
||||
nTet++;
|
||||
}
|
||||
else if (pyr.isA(mesh, celli))
|
||||
else if (pyrMatcher::test(mesh, celli))
|
||||
{
|
||||
nPyr++;
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "tetPointRef.H"
|
||||
#include "regionSplit.H"
|
||||
#include "wallDist.H"
|
||||
#include "cellAspectRatio.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -318,6 +319,32 @@ void Foam::writeFields
|
||||
aspectRatio.write();
|
||||
}
|
||||
|
||||
if (selectedFields.found("cellAspectRatio"))
|
||||
{
|
||||
volScalarField aspectRatio
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"cellAspectRatio",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE,
|
||||
false
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar(dimless, Zero),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
|
||||
aspectRatio.ref().field() = cellAspectRatio(mesh);
|
||||
|
||||
aspectRatio.correctBoundaryConditions();
|
||||
Info<< " Writing approximate aspect ratio to "
|
||||
<< aspectRatio.name() << endl;
|
||||
aspectRatio.write();
|
||||
}
|
||||
|
||||
|
||||
// cell type
|
||||
// ~~~~~~~~~
|
||||
|
||||
@ -680,7 +680,7 @@ autoPtr<mapPolyMesh> createRegionMesh
|
||||
regionName,
|
||||
mesh.time().timeName(),
|
||||
mesh.time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::READ_IF_PRESENT, // read fv* if present
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
|
||||
@ -66,19 +66,14 @@ using namespace Foam;
|
||||
// Many ways to name processor directories
|
||||
//
|
||||
// Uncollated | "processor0", "processor1" ...
|
||||
// Collated (old) | "processors"
|
||||
// Collated (new) | "processors<N>"
|
||||
// Collated | "processors<N>"
|
||||
// Host collated | "processors<N>_<low>-<high>"
|
||||
|
||||
const regExp matcher("processors?[0-9]+(_[0-9]+-[0-9]+)?");
|
||||
|
||||
bool isProcessorDir(const string& dir)
|
||||
{
|
||||
return
|
||||
(
|
||||
dir.starts_with("processor")
|
||||
&& (dir == "processors" || matcher.match(dir))
|
||||
);
|
||||
return (dir.starts_with("processor") && matcher.match(dir));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -71,19 +71,14 @@ using namespace Foam;
|
||||
// Many ways to name processor directories
|
||||
//
|
||||
// Uncollated | "processor0", "processor1" ...
|
||||
// Collated (old) | "processors"
|
||||
// Collated (new) | "processors<N>"
|
||||
// Collated | "processors<N>"
|
||||
// Host collated | "processors<N>_<low>-<high>"
|
||||
|
||||
const regExp matcher("processors?[0-9]+(_[0-9]+-[0-9]+)?");
|
||||
|
||||
bool isProcessorDir(const string& dir)
|
||||
{
|
||||
return
|
||||
(
|
||||
dir.starts_with("processor")
|
||||
&& (dir == "processors" || matcher.match(dir))
|
||||
);
|
||||
return (dir.starts_with("processor") && matcher.match(dir));
|
||||
}
|
||||
|
||||
|
||||
@ -384,13 +379,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (leadProcIdx < 0)
|
||||
{
|
||||
// Collated (old)
|
||||
leadProcIdx = procDirs.find("processors");
|
||||
}
|
||||
|
||||
if (leadProcIdx < 0)
|
||||
{
|
||||
// Collated (new)
|
||||
// Collated
|
||||
leadProcIdx = procDirs.find("processors" + Foam::name(nProcs));
|
||||
}
|
||||
|
||||
|
||||
@ -519,29 +519,26 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
const fileName& d = dirs[diri];
|
||||
|
||||
// Starts with 'processors'
|
||||
if (d.find("processors") == 0)
|
||||
label proci = -1;
|
||||
|
||||
if
|
||||
(
|
||||
d.starts_with("processor")
|
||||
&&
|
||||
(
|
||||
// Collated is "processors"
|
||||
d[9] == 's'
|
||||
|
||||
// Uncollated has integer(s) after 'processor'
|
||||
|| Foam::read(d.substr(9), proci)
|
||||
)
|
||||
)
|
||||
{
|
||||
if (fileHandler().exists(d))
|
||||
{
|
||||
fileHandler().rmDir(d);
|
||||
}
|
||||
}
|
||||
|
||||
// Starts with 'processor'
|
||||
if (d.find("processor") == 0)
|
||||
{
|
||||
// Check that integer after processor
|
||||
fileName num(d.substr(9));
|
||||
label proci = -1;
|
||||
if (Foam::read(num.c_str(), proci))
|
||||
{
|
||||
if (fileHandler().exists(d))
|
||||
{
|
||||
fileHandler().rmDir(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
procDirsProblem = false;
|
||||
|
||||
@ -36,6 +36,7 @@ License
|
||||
#include "pointSet.H"
|
||||
#include "faceSet.H"
|
||||
#include "cellSet.H"
|
||||
#include "basicFvGeometryScheme.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -254,6 +255,19 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
|
||||
auto meshPtr = autoPtr<fvMesh>::New(io);
|
||||
fvMesh& mesh = *meshPtr;
|
||||
|
||||
// Make sure to use a non-parallel geometry calculation method
|
||||
{
|
||||
tmp<fvGeometryScheme> basicGeometry
|
||||
(
|
||||
fvGeometryScheme::New
|
||||
(
|
||||
mesh,
|
||||
dictionary(),
|
||||
basicFvGeometryScheme::typeName
|
||||
)
|
||||
);
|
||||
mesh.geometry(basicGeometry);
|
||||
}
|
||||
|
||||
|
||||
// Sync patches
|
||||
|
||||
@ -92,6 +92,7 @@ Usage
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
#include "topoSet.H"
|
||||
#include "regionProperties.H"
|
||||
#include "basicFvGeometryScheme.H"
|
||||
|
||||
#include "parFvFieldReconstructor.H"
|
||||
#include "parLagrangianRedistributor.H"
|
||||
@ -152,6 +153,30 @@ scalar getMergeDistance
|
||||
}
|
||||
|
||||
|
||||
void setBasicGeometry(fvMesh& mesh)
|
||||
{
|
||||
// Set the fvGeometryScheme to basic since it does not require
|
||||
// any parallel communication to construct the geometry. During
|
||||
// redistributePar one might temporarily end up with processors
|
||||
// with zero procBoundaries. Normally procBoundaries trigger geometry
|
||||
// calculation (e.g. send over cellCentres) so on the processors without
|
||||
// procBoundaries this will not happen. The call to the geometry calculation
|
||||
// is not synchronised and this might lead to a hang for geometry schemes
|
||||
// that do require synchronisation
|
||||
|
||||
tmp<fvGeometryScheme> basicGeometry
|
||||
(
|
||||
fvGeometryScheme::New
|
||||
(
|
||||
mesh,
|
||||
dictionary(),
|
||||
basicFvGeometryScheme::typeName
|
||||
)
|
||||
);
|
||||
mesh.geometry(basicGeometry);
|
||||
}
|
||||
|
||||
|
||||
void printMeshData(const polyMesh& mesh)
|
||||
{
|
||||
// Collect all data on master
|
||||
@ -2314,6 +2339,19 @@ int main(int argc, char *argv[])
|
||||
// (replacement for setRootCase that does not abort)
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
|
||||
// As much as possible avoid synchronised operation. To be looked at more
|
||||
// closely for the three scenarios:
|
||||
// - decompose - reads on master (and from parent directory) and sends
|
||||
// dictionary to slaves
|
||||
// - distribute - reads on potentially a different number of processors
|
||||
// than it writes to
|
||||
// - reconstruct - reads parallel, write on master only and to parent
|
||||
// directory
|
||||
const_cast<fileOperation&>(fileHandler()).distributed(true);
|
||||
|
||||
|
||||
#include "foamDlOpenLibs.H"
|
||||
|
||||
const bool reconstruct = args.found("reconstruct");
|
||||
@ -2324,15 +2362,16 @@ int main(int argc, char *argv[])
|
||||
bool decompose = args.found("decompose");
|
||||
bool overwrite = args.found("overwrite");
|
||||
|
||||
if (Foam::sigFpe::requested())
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Detected floating point exception trapping (FOAM_SIGFPE)."
|
||||
<< " This might give" << nl
|
||||
<< " problems when mapping fields. Switch it off in case"
|
||||
<< " of problems." << endl;
|
||||
}
|
||||
|
||||
// Disable NaN setting and floating point error trapping. This is to avoid
|
||||
// any issues inside the field redistribution inside fvMeshDistribute
|
||||
// which temporarily moves processor faces into existing patches. These
|
||||
// will now not have correct values. After all bits have been assembled
|
||||
// the processor fields will be restored but until then there might
|
||||
// be uninitialised values which might upset some patch field constructors.
|
||||
// Workaround by disabling floating point error trapping. TBD: have
|
||||
// actual field redistribution instead of subsetting inside
|
||||
// fvMeshDistribute.
|
||||
Foam::sigFpe::unset(true);
|
||||
|
||||
const wordRes selectedFields;
|
||||
const wordRes selectedLagrangianFields;
|
||||
@ -2569,12 +2608,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
// See where the mesh is
|
||||
//const bool oldParRun = Pstream::parRun(false);
|
||||
fileName facesInstance = runTime.findInstance
|
||||
(
|
||||
meshSubDir,
|
||||
"faces",
|
||||
IOobject::READ_IF_PRESENT
|
||||
);
|
||||
//Pstream::parRun(oldParRun);
|
||||
//Pout<< "facesInstance:" << facesInstance << endl;
|
||||
|
||||
Pstream::scatter(facesInstance);
|
||||
@ -2660,6 +2701,10 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
fvMesh& mesh = meshPtr();
|
||||
|
||||
// Use basic geometry calculation to avoid synchronisation
|
||||
// problems. See comment in routine
|
||||
setBasicGeometry(mesh);
|
||||
|
||||
// Global matching tolerance
|
||||
const scalar tolDim = getMergeDistance
|
||||
(
|
||||
@ -2709,6 +2754,10 @@ int main(int argc, char *argv[])
|
||||
Info<< "Time = " << runTime.timeName() << endl << endl;
|
||||
|
||||
|
||||
// Read undecomposed mesh on master and 'empty' mesh
|
||||
// (zero faces, point, cells but valid patches and zones) on slaves.
|
||||
// This is a bit of tricky code and hidden inside fvMeshTools for
|
||||
// now.
|
||||
Info<< "Reading undecomposed mesh (on master)" << endl;
|
||||
autoPtr<fvMesh> baseMeshPtr = fvMeshTools::newMesh
|
||||
(
|
||||
@ -2721,6 +2770,8 @@ int main(int argc, char *argv[])
|
||||
),
|
||||
true // read on master only
|
||||
);
|
||||
setBasicGeometry(baseMeshPtr());
|
||||
|
||||
|
||||
Info<< "Reading local, decomposed mesh" << endl;
|
||||
autoPtr<fvMesh> meshPtr = loadOrCreateMesh
|
||||
@ -2941,12 +2992,14 @@ int main(int argc, char *argv[])
|
||||
runTime.caseName() = baseRunTime.caseName();
|
||||
}
|
||||
|
||||
const bool oldParRun = Pstream::parRun(false);
|
||||
masterInstDir = runTime.findInstance
|
||||
(
|
||||
meshSubDir,
|
||||
"faces",
|
||||
IOobject::READ_IF_PRESENT
|
||||
);
|
||||
Pstream::parRun(oldParRun);
|
||||
|
||||
if (decompose)
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -86,15 +86,7 @@ int main(int argc, char *argv[])
|
||||
#include "createTime.H"
|
||||
|
||||
// Determine the processor count
|
||||
#ifdef fileOperation_H
|
||||
const label nProcs = fileHandler().nProcs(args.path());
|
||||
#else
|
||||
label nProcs = 0;
|
||||
while (isDir(args.path()/("processor" + Foam::name(nProcs))))
|
||||
{
|
||||
++nProcs;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Create the processor databases
|
||||
PtrList<Time> databases(nProcs);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/randomProcesses/lnInclude
|
||||
-I$(LIB_SRC)/randomProcesses/lnInclude \
|
||||
-I$(FFTW_INC_DIR)
|
||||
|
||||
EXE_LIBS = \
|
||||
-lsampling \
|
||||
|
||||
@ -87,7 +87,6 @@ Usage
|
||||
|
||||
|
||||
See also
|
||||
noiseFFT.H
|
||||
noiseModel.H
|
||||
windowModel.H
|
||||
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
wclean libso pdrFields
|
||||
|
||||
wclean PDRfitMesh
|
||||
|
||||
wclean PDRsetFields
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -5,6 +5,9 @@ cd "${0%/*}" || exit # Run from this directory
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
wmake $targetType pdrFields
|
||||
|
||||
wmake $targetType PDRfitMesh
|
||||
|
||||
wmake $targetType PDRsetFields
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -0,0 +1,7 @@
|
||||
PDRfitMeshParams.C
|
||||
PDRfitMeshScan.C
|
||||
PDRfitMeshScans.C
|
||||
|
||||
PDRfitMesh.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/PDRfitMesh
|
||||
339
applications/utilities/preProcessing/PDR/PDRfitMesh/PDRfitMesh.C
Normal file
339
applications/utilities/preProcessing/PDR/PDRfitMesh/PDRfitMesh.C
Normal file
@ -0,0 +1,339 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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/>.
|
||||
|
||||
Applications
|
||||
PDRfitMesh
|
||||
|
||||
Description
|
||||
Scans extents of obstacles to establish reasonable estimates
|
||||
for generating a PDRblockMeshDict.
|
||||
|
||||
SourceFiles
|
||||
PDRfitMesh.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "Fstream.H"
|
||||
#include "IOdictionary.H"
|
||||
|
||||
#include "PDRfitMeshScans.H"
|
||||
#include "PDRsetFields.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
argList::addNote
|
||||
(
|
||||
"Processes a set of geometrical obstructions to determine"
|
||||
" reasonable estimates for generating a PDRblockMeshDict"
|
||||
);
|
||||
argList::noParallel();
|
||||
argList::noFunctionObjects();
|
||||
|
||||
argList::addOption("dict", "file", "Alternative PDRsetFieldsDict");
|
||||
argList::addOption("params", "file", "Alternative PDRfitMeshDict");
|
||||
argList::addBoolOption
|
||||
(
|
||||
"overwrite",
|
||||
"Overwrite existing system/PDRblockMeshDict"
|
||||
);
|
||||
|
||||
argList::addBoolOption("verbose", "Increase verbosity");
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"dry-run",
|
||||
"Equivalent to -print-dict"
|
||||
);
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"print-dict",
|
||||
"Print PDRblockMeshDict equivalent and exit"
|
||||
);
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"write-vtk",
|
||||
"Write obstacles as VTK files"
|
||||
);
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
const bool dryrun = args.found("dry-run");
|
||||
const bool printDict = args.found("print-dict");
|
||||
|
||||
const word dictName("PDRsetFieldsDict");
|
||||
#include "setSystemRunTimeDictionaryIO.H"
|
||||
|
||||
Info<< "Reading " << dictIO.name() << nl << endl;
|
||||
|
||||
IOdictionary setFieldsDict(dictIO);
|
||||
|
||||
const fileName& casepath = runTime.globalPath();
|
||||
|
||||
// Program parameters (globals)
|
||||
pars.read(setFieldsDict);
|
||||
|
||||
// Params for fitMesh
|
||||
// - like setSystemRunTimeDictionaryIO
|
||||
|
||||
IOobject paramIO = IOobject::selectIO
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"PDRfitMeshDict",
|
||||
runTime.system(),
|
||||
runTime,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
args.getOrDefault<fileName>("params", "")
|
||||
);
|
||||
|
||||
if (paramIO.typeHeaderOk<IOdictionary>(true))
|
||||
{
|
||||
Info<< "Using PDRfitMesh parameters from "
|
||||
<< runTime.relativePath(paramIO.objectPath()) << nl
|
||||
<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
paramIO.readOpt() = IOobject::NO_READ;
|
||||
Info<< "No PDRfitMeshDict found, using defaults" << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
IOdictionary fitParamsDict(paramIO, dictionary());
|
||||
|
||||
PDRfitMeshParams fitParams(fitParamsDict);
|
||||
|
||||
|
||||
// Essential parameters
|
||||
|
||||
scalar cellWidth = 0;
|
||||
|
||||
if
|
||||
(
|
||||
!setFieldsDict.readIfPresent("cellWidth", cellWidth)
|
||||
&& !fitParamsDict.readIfPresent("cellWidth", cellWidth)
|
||||
)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "No cellWidth specified in any dictionary" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
// Storage for obstacles and cylinder-like obstacles
|
||||
DynamicList<PDRobstacle> obstacles, cylinders;
|
||||
|
||||
// Read in obstacles
|
||||
if (pars.legacyObsSpec)
|
||||
{
|
||||
PDRobstacle::legacyReadFiles
|
||||
(
|
||||
pars.obsfile_dir, pars.obsfile_names,
|
||||
boundBox::invertedBox, // ie, no bounds
|
||||
obstacles,
|
||||
cylinders
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
PDRobstacle::readFiles
|
||||
(
|
||||
pars.obsfile_dir, pars.obsfile_names,
|
||||
boundBox::invertedBox, // ie, no bounds
|
||||
obstacles,
|
||||
cylinders
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Output names
|
||||
//
|
||||
|
||||
IOobject outputIO
|
||||
(
|
||||
"PDRblockMeshDict",
|
||||
runTime.system(),
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false // unregistered
|
||||
);
|
||||
|
||||
|
||||
enum class writeType { DRY_RUN, OKAY, OVERWRITE, NO_CLOBBER };
|
||||
|
||||
writeType writable = writeType::OKAY;
|
||||
|
||||
if (dryrun || printDict)
|
||||
{
|
||||
writable = writeType::DRY_RUN;
|
||||
}
|
||||
else if (isFile(outputIO.objectPath()))
|
||||
{
|
||||
if (args.found("overwrite"))
|
||||
{
|
||||
writable = writeType::OVERWRITE;
|
||||
}
|
||||
else
|
||||
{
|
||||
writable = writeType::NO_CLOBBER;
|
||||
InfoErr
|
||||
<< nl
|
||||
<< "File exists: "
|
||||
<< runTime.relativePath(outputIO.objectPath()) << nl
|
||||
<< "Move out of the way or specify -overwrite" << nl << nl
|
||||
<< "Exiting" << nl << nl;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
writable = writeType::OKAY;
|
||||
}
|
||||
|
||||
|
||||
if (args.found("write-vtk"))
|
||||
{
|
||||
PDRobstacle::generateVtk(casepath/"VTK", obstacles, cylinders);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// The fitting routines
|
||||
//
|
||||
|
||||
// Collapse into a single list of obstacles
|
||||
obstacles.append(std::move(cylinders));
|
||||
|
||||
PDRfitMeshScan::verbose(args.found("verbose"));
|
||||
|
||||
Vector<PDRblock::gridControl> griding =
|
||||
PDRfitMeshScans().calcGriding(obstacles, fitParams, cellWidth);
|
||||
|
||||
|
||||
//
|
||||
// Output
|
||||
//
|
||||
|
||||
if (writable == writeType::DRY_RUN)
|
||||
{
|
||||
InfoErr << nl;
|
||||
if (!printDict)
|
||||
{
|
||||
InfoErr
|
||||
<< "dry-run: ";
|
||||
}
|
||||
InfoErr
|
||||
<< "Displaying equivalent PDRblockMeshDict" << nl
|
||||
<< nl;
|
||||
}
|
||||
else if (writable == writeType::OKAY)
|
||||
{
|
||||
InfoErr
|
||||
<< nl
|
||||
<< "Write "
|
||||
<< runTime.relativePath(outputIO.objectPath()) << nl;
|
||||
}
|
||||
else if (writable == writeType::OVERWRITE)
|
||||
{
|
||||
InfoErr
|
||||
<< nl
|
||||
<< "Overwrite existing "
|
||||
<< runTime.relativePath(outputIO.objectPath()) << nl;
|
||||
}
|
||||
// NO_CLOBBER already handled
|
||||
|
||||
|
||||
{
|
||||
autoPtr<Ostream> outputFilePtr;
|
||||
|
||||
if
|
||||
(
|
||||
writable == writeType::OKAY
|
||||
|| writable == writeType::OVERWRITE
|
||||
)
|
||||
{
|
||||
outputFilePtr.reset(new OFstream(outputIO.objectPath()));
|
||||
}
|
||||
|
||||
Ostream& os = bool(outputFilePtr) ? *outputFilePtr : Info();
|
||||
|
||||
outputIO.writeHeader(os, IOdictionary::typeName_());
|
||||
|
||||
os.writeEntry
|
||||
(
|
||||
"expansion",
|
||||
PDRfitMeshScan::expansionName()
|
||||
);
|
||||
os << nl;
|
||||
|
||||
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
|
||||
{
|
||||
griding[cmpt].writeDict(os, cmpt);
|
||||
}
|
||||
|
||||
const dictionary* outerDict;
|
||||
|
||||
if
|
||||
(
|
||||
(outerDict = setFieldsDict.findDict("outer")) != nullptr
|
||||
|| (outerDict = fitParamsDict.findDict("outer")) != nullptr
|
||||
)
|
||||
{
|
||||
outerDict->writeEntry(os);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Define our own "outer"
|
||||
os.beginBlock("outer");
|
||||
os.writeEntry("type", "none");
|
||||
os.endBlock();
|
||||
}
|
||||
|
||||
IOobject::writeEndDivider(os);
|
||||
}
|
||||
|
||||
Info<< nl << "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,126 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2012 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object PDRfitMeshDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Tuning parameters (defaults) for PDRfitMesh
|
||||
// - these normally do not need much changing
|
||||
|
||||
|
||||
// Note the following are normally read from PDRsetFieldsDict
|
||||
//
|
||||
// - cellWidth
|
||||
// - cellWidthFactor
|
||||
// - outer (contains optional zmin)
|
||||
//
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Finding planes
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// User defined bounds
|
||||
bounds
|
||||
{
|
||||
// xmin -1e16;
|
||||
// xmax 1e16;
|
||||
|
||||
// ymin -1e16;
|
||||
// ymax 1e16;
|
||||
|
||||
// zmin -1e16;
|
||||
// zmax 1e16;
|
||||
}
|
||||
|
||||
|
||||
outer
|
||||
{
|
||||
//- Ground datum (hard zmin)
|
||||
// zmin -1e16;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Finding planes
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
|
||||
// Ignore faces smaller than this multiple of cell face area
|
||||
minFaceArea 5.0;
|
||||
|
||||
// Only fit a plane if the face area at the coordinate is at least
|
||||
// this times the cell face area
|
||||
minAreaRatio 20.0;
|
||||
|
||||
// Size of search zones for face areas will be this * the cell width.
|
||||
// So faces closer than this zone size might be grouped together
|
||||
areaWidthFactor 0.7;
|
||||
|
||||
|
||||
// Very long zones produce bad outer boundary shape from
|
||||
// makePDRmeshBlocks, so we subdivide a zone if its length is greater
|
||||
// than this * the height of the area of cuboid vells
|
||||
maxZoneToHeight 2.0;
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Choosing cell width
|
||||
//
|
||||
// <cellWidth> and <cellWidthFactor> read from PDRsetFieldsDict
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Minimum number of cells in any direction
|
||||
nCellsMin 10;
|
||||
|
||||
// Width of obstacles must be less than this * cell width to added
|
||||
// into subgrid length
|
||||
widthFactor 1.0;
|
||||
|
||||
// Optimal average number of obstacles per cell
|
||||
obsPerCell 2.0;
|
||||
|
||||
//- Maximum cellWidth when auto-sizing
|
||||
maxCellWidth 1e16;
|
||||
|
||||
// Do not use a cellWidth more than this times the initial estimate
|
||||
maxWidthEstimate 5.0;
|
||||
|
||||
// Assume converged if optimised width changes by less than this
|
||||
maxWidthRatio 1.2;
|
||||
|
||||
// Maximum iterations in optimising cellWidth
|
||||
maxIterations 5;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Defining outer region
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Fraction of rectangular cell layers each side of the central region.
|
||||
nEdgeLayers 5.0;
|
||||
|
||||
|
||||
// FUTURE?
|
||||
//
|
||||
// // Ratio of the outer extension distance to the average radius of the
|
||||
// // congested region
|
||||
// ratioOuterToCongRad 20.0;
|
||||
//
|
||||
// // Cell size ratio - should be same as that hard-wired in makePDRmeshBlocks
|
||||
// outerRatio 1.2;
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,123 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "PDRfitMeshParams.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::PDRfitMeshParams::readBounds(const dictionary& dict)
|
||||
{
|
||||
scalar value;
|
||||
|
||||
if (dict.readIfPresent("xmin", value))
|
||||
{
|
||||
minBounds.x() = optionalData<scalar>(value);
|
||||
}
|
||||
if (dict.readIfPresent("ymin", value))
|
||||
{
|
||||
minBounds.y() = optionalData<scalar>(value);
|
||||
}
|
||||
if (dict.readIfPresent("zmin", value))
|
||||
{
|
||||
minBounds.z() = optionalData<scalar>(value);
|
||||
}
|
||||
|
||||
if (dict.readIfPresent("xmax", value))
|
||||
{
|
||||
maxBounds.x() = optionalData<scalar>(value);
|
||||
}
|
||||
if (dict.readIfPresent("ymax", value))
|
||||
{
|
||||
maxBounds.y() = optionalData<scalar>(value);
|
||||
}
|
||||
if (dict.readIfPresent("zmax", value))
|
||||
{
|
||||
maxBounds.z() = optionalData<scalar>(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::PDRfitMeshParams::PDRfitMeshParams(const dictionary& dict)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::PDRfitMeshParams::read(const dictionary& dict)
|
||||
{
|
||||
const dictionary* dictptr;
|
||||
|
||||
// Geometric limits
|
||||
|
||||
if ((dictptr = dict.findDict("bounds")) != nullptr)
|
||||
{
|
||||
readBounds(*dictptr);
|
||||
}
|
||||
|
||||
if ((dictptr = dict.findDict("outer")) != nullptr)
|
||||
{
|
||||
const dictionary& d = *dictptr;
|
||||
|
||||
d.readIfPresent("zmin", ground);
|
||||
}
|
||||
|
||||
|
||||
// Finding planes
|
||||
|
||||
dict.readIfPresent("minFaceArea", minFaceArea);
|
||||
dict.readIfPresent("minAreaRatio", minAreaRatio);
|
||||
dict.readIfPresent("areaWidthFactor", areaWidthFactor);
|
||||
dict.readIfPresent("maxZoneToHeight", maxZoneToHeight);
|
||||
|
||||
|
||||
// Choosing cell width
|
||||
|
||||
dict.readIfPresent("nCellsMin", nCellsMin);
|
||||
dict.readIfPresent("widthFactor", widthFactor);
|
||||
dict.readIfPresent("obsPerCell", obsPerCell);
|
||||
dict.readIfPresent("maxCellWidth", maxCellWidth);
|
||||
dict.readIfPresent("maxWidthEstimate", maxWidthEstimate);
|
||||
dict.readIfPresent("maxWidthRatio", maxWidthRatio);
|
||||
dict.readIfPresent("maxIterations", maxIterations);
|
||||
|
||||
|
||||
// Outer region
|
||||
|
||||
dict.readIfPresent("nEdgeLayers", nEdgeLayers);
|
||||
|
||||
dict.readIfPresent("outerRatio", outerRatio);
|
||||
|
||||
// dict.readIfPresent("outerRadius", outerRadius);
|
||||
};
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,158 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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::PDRfitMeshParams
|
||||
|
||||
Description
|
||||
Parameters for PDRfitMesh
|
||||
|
||||
SourceFiles
|
||||
PDRfitMeshParams.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PDRfitMeshParams_H
|
||||
#define PDRfitMeshParams_H
|
||||
|
||||
#include "labelList.H"
|
||||
#include "scalarList.H"
|
||||
#include "dictionary.H"
|
||||
#include "optionalData.H"
|
||||
#include "MinMax.H"
|
||||
#include "Vector.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PDRfitMeshParams Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class PDRfitMeshParams
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Read optional bounds
|
||||
void readBounds(const dictionary& dict);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Data Members
|
||||
|
||||
//- Optional user bounds (xmin, xmax, ymin, ymax, zmin, zmax)
|
||||
Vector<optionalData<scalar>> minBounds, maxBounds;
|
||||
|
||||
//- Ground datum (hard zmin)
|
||||
scalar ground = -1e16;
|
||||
|
||||
|
||||
// Finding planes
|
||||
|
||||
//- Ignore faces smaller than this multiple of cell face area
|
||||
scalar minFaceArea = 5.0;
|
||||
|
||||
//- Only fit a plane if the face area at the coordinate is at
|
||||
//- least this times the cell face area
|
||||
scalar minAreaRatio = 20.0;
|
||||
|
||||
//- Size of search zones for face areas will be this * the
|
||||
//- cell width.
|
||||
// Faces closer than this zone size may be grouped together
|
||||
scalar areaWidthFactor = 0.7;
|
||||
|
||||
// Very long zones produce bad outer boundary shape from
|
||||
// makePDRmeshBlocks, so we subdivide a zone if its length is
|
||||
// greater than this * the height of the area of cuboid vells
|
||||
scalar maxZoneToHeight = 2.0;
|
||||
|
||||
|
||||
// Choosing cell width
|
||||
|
||||
// Minimum number of cells in any direction
|
||||
label nCellsMin = 10;
|
||||
|
||||
// Width of obstacles must be less than this * cell width to
|
||||
// added into subgrid length
|
||||
scalar widthFactor = 1.0;
|
||||
|
||||
// Optimal average number of obstacles per cell
|
||||
scalar obsPerCell = 2.0;
|
||||
|
||||
//- Maximum cellWidth when auto-sizing
|
||||
scalar maxCellWidth = 1e16;
|
||||
|
||||
//- Do not use a cellWidth more than this times the initial estimate
|
||||
scalar maxWidthEstimate = 5.0;
|
||||
|
||||
//- Converged if optimised width changes by less than this amount
|
||||
scalar maxWidthRatio = 1.2;
|
||||
|
||||
//- Maximum iterations in optimising cellWidth
|
||||
label maxIterations = 5;
|
||||
|
||||
|
||||
// Outer region
|
||||
|
||||
//- Fraction of rectangular cell layers on each side of the
|
||||
//- central region
|
||||
scalar nEdgeLayers = 5;
|
||||
|
||||
//- Cell size ratio - should be same as used for PDRblockMesh
|
||||
scalar outerRatio = 1.2;
|
||||
|
||||
//FUTURE? // Ratio of the outer extension distance to the average
|
||||
//FUTURE? // radius of the congested region
|
||||
//FUTURE? scalar outerRadius = 20.0;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Default construct
|
||||
PDRfitMeshParams() = default;
|
||||
|
||||
//- Construct and read dictionary
|
||||
explicit PDRfitMeshParams(const dictionary& dict);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read program parameters from dictionary
|
||||
void read(const dictionary& dict);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,859 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016 Shell Research Ltd.
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "PDRfitMeshScan.H"
|
||||
#include "PDRfitMeshParams.H"
|
||||
#include "PDRblock.H"
|
||||
#include "PDRobstacle.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::PDRfitMeshScan::verbose_ = false;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::PDRfitMeshScan::expansionName()
|
||||
{
|
||||
return PDRblock::expansionNames_[PDRblock::EXPAND_RELATIVE];
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::PDRfitMeshScan::addCoord
|
||||
(
|
||||
const scalar coord,
|
||||
const scalar weight
|
||||
)
|
||||
{
|
||||
if (!limits_.contains(coord))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const scalar coordOffset = (coord - limits_.min());
|
||||
|
||||
if (coordOffset < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Negative coordinate! " << coordOffset << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// We divide the range into a series of steps, and decide
|
||||
// which step this coord is in
|
||||
|
||||
|
||||
// Note: would be simpler to record the totals only in the
|
||||
// half steps in this routine then get the full-step values
|
||||
// at the end by adding half steps
|
||||
|
||||
|
||||
// Add the area to the total already found in this step
|
||||
// and update the weighted average position of these obstacle faces
|
||||
|
||||
const label stepi1 = 2*floor(coordOffset / stepWidth_);
|
||||
|
||||
|
||||
// Also do half-step offset in case several faces
|
||||
// are around the step boundary.
|
||||
//
|
||||
// Stored in odd-numbered elements
|
||||
|
||||
const label stepi2 =
|
||||
Foam::max
|
||||
(
|
||||
0,
|
||||
1 + 2*floor((coordOffset - 0.5*stepWidth_) / stepWidth_)
|
||||
);
|
||||
|
||||
|
||||
// Last, keep track of totals in half-step ranges
|
||||
|
||||
const label stepih = floor(coordOffset / stepWidth_);
|
||||
|
||||
|
||||
const label maxSize = Foam::max(stepi1, stepi2);
|
||||
|
||||
if (weightedPos_.size() <= maxSize)
|
||||
{
|
||||
weightedPos_.resize(maxSize+1, Zero);
|
||||
totalArea_.resize(maxSize+1, Zero);
|
||||
|
||||
weightedPos2_.resize(maxSize+1, Zero);
|
||||
totalArea2_.resize(maxSize+1, Zero);
|
||||
}
|
||||
|
||||
weightedPos_[stepi1] += (coord * weight);
|
||||
totalArea_[stepi1] += weight;
|
||||
|
||||
weightedPos_[stepi2] += (coord * weight);
|
||||
totalArea_[stepi2] += weight;
|
||||
|
||||
weightedPos2_[stepih] += (coord * weight);
|
||||
totalArea2_[stepih] += weight;
|
||||
}
|
||||
|
||||
|
||||
// void Foam::PDRfitMeshScan::clear()
|
||||
// {
|
||||
// weightedPos_.clear(); totalArea_.clear();
|
||||
// weightedPos2_.clear(); totalArea2_.clear();
|
||||
// }
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::PDRfitMeshScan::reset()
|
||||
{
|
||||
limits_.min() = GREAT;
|
||||
limits_.max() = -GREAT;
|
||||
|
||||
hard_min_ = -GREAT;
|
||||
|
||||
nsteps_ = 0;
|
||||
stepWidth_ = 0;
|
||||
minFaceArea_ = 0;
|
||||
|
||||
weightedPos_.clear();
|
||||
totalArea_.clear();
|
||||
|
||||
weightedPos2_.clear();
|
||||
totalArea2_.clear();
|
||||
}
|
||||
|
||||
|
||||
void Foam::PDRfitMeshScan::resize
|
||||
(
|
||||
const scalar cellWidth,
|
||||
const PDRfitMeshParams& pars
|
||||
)
|
||||
{
|
||||
if (limits_.valid())
|
||||
{
|
||||
nsteps_ =
|
||||
(
|
||||
limits_.mag() / (mag(cellWidth) * pars.areaWidthFactor)
|
||||
+ 0.5
|
||||
);
|
||||
|
||||
nsteps_ = max(nsteps_, pars.nCellsMin);
|
||||
|
||||
stepWidth_ = limits_.mag() / nsteps_;
|
||||
|
||||
minFaceArea_ = pars.minFaceArea;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsteps_ = 0;
|
||||
stepWidth_ = 0;
|
||||
minFaceArea_ = 0;
|
||||
|
||||
WarningInFunction
|
||||
<< "No valid limits defined" << endl;
|
||||
}
|
||||
|
||||
weightedPos_.clear();
|
||||
totalArea_.clear();
|
||||
|
||||
weightedPos2_.clear();
|
||||
totalArea2_.clear();
|
||||
|
||||
// resize
|
||||
weightedPos_.resize(2*nsteps_+1, Zero);
|
||||
totalArea_.resize(2*nsteps_+1, Zero);
|
||||
|
||||
weightedPos2_.resize(2*nsteps_+1, Zero);
|
||||
totalArea2_.resize(2*nsteps_+1, Zero);
|
||||
}
|
||||
|
||||
|
||||
void Foam::PDRfitMeshScan::adjustLimits
|
||||
(
|
||||
const scalar point0,
|
||||
const scalar point1
|
||||
)
|
||||
{
|
||||
limits_.add(point0);
|
||||
limits_.add(point1);
|
||||
}
|
||||
|
||||
|
||||
void Foam::PDRfitMeshScan::addArea
|
||||
(
|
||||
const scalar area,
|
||||
const scalar point0,
|
||||
const scalar point1
|
||||
)
|
||||
{
|
||||
if (!nsteps_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "No step-size defined" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (area < minFaceArea_ * sqr(stepWidth_))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
addCoord(point0, area);
|
||||
addCoord(point1, area);
|
||||
}
|
||||
|
||||
|
||||
void Foam::PDRfitMeshScan::print(Ostream& os) const
|
||||
{
|
||||
if (nsteps_)
|
||||
{
|
||||
os << "steps:" << nsteps_;
|
||||
}
|
||||
|
||||
if (limits_.valid())
|
||||
{
|
||||
os << " limits:" << limits_;
|
||||
}
|
||||
|
||||
scalar totalArea = 0;
|
||||
for (const scalar areaValue : totalArea_)
|
||||
{
|
||||
totalArea += areaValue;
|
||||
}
|
||||
|
||||
os << " area:" << totalArea;
|
||||
os << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Evaluates (r**n - 1) / (r - 1) including in the limit r=1
|
||||
inline static scalar rn1r1(const scalar r, const label n)
|
||||
{
|
||||
if (mag(r - 1.0) < SMALL)
|
||||
{
|
||||
return n;
|
||||
}
|
||||
|
||||
return (pow(r, n) - 1.0)/(r - 1.0);
|
||||
}
|
||||
|
||||
|
||||
inline static scalar end_val
|
||||
(
|
||||
const scalar width,
|
||||
const scalar ratio,
|
||||
const label n
|
||||
)
|
||||
{
|
||||
return width / rn1r1(ratio, n);
|
||||
}
|
||||
|
||||
|
||||
static scalar fit_slope
|
||||
(
|
||||
const scalar left,
|
||||
const scalar width,
|
||||
const label n,
|
||||
scalar& r
|
||||
)
|
||||
{
|
||||
const scalar wol = width / left;
|
||||
|
||||
// Initial value
|
||||
r = (left < width / n) ? 1.01 : 0.99;
|
||||
|
||||
for (int nIter = 0; nIter < 25; ++nIter)
|
||||
{
|
||||
scalar rm1 = r - 1.0;
|
||||
scalar rn = pow(r, n);
|
||||
scalar f = (rn - 1.0) * r / rm1 - wol;
|
||||
scalar fprime = ((n * rm1 - 1) * rn + 1) / sqr(rm1);
|
||||
|
||||
scalar new_r = r - f / fprime;
|
||||
scalar delta = mag(new_r - r);
|
||||
|
||||
r = 0.5 * (r + new_r);
|
||||
|
||||
// InfoErr
|
||||
// << "New r: " << new_r << ' '
|
||||
// << f << ' ' << fprime << ' ' << delta << ' ' << nIter << nl;
|
||||
|
||||
if (delta <= 1e-3)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return end_val(width, 1.0/r, n);
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::PDRblock::gridControl
|
||||
Foam::PDRfitMeshScan::calcGridControl
|
||||
(
|
||||
const scalar cellWidth,
|
||||
const scalar max_zone,
|
||||
const PDRfitMeshParams& pars
|
||||
)
|
||||
{
|
||||
// Prune out small areas
|
||||
{
|
||||
const scalar minArea = sqr(cellWidth) * pars.minAreaRatio;
|
||||
if (verbose())
|
||||
{
|
||||
Info<< "Checking planes. Min-area: " << minArea << nl;
|
||||
}
|
||||
|
||||
for (scalar& areaValue : totalArea_)
|
||||
{
|
||||
if (areaValue < minArea)
|
||||
{
|
||||
areaValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (scalar& areaValue : totalArea2_)
|
||||
{
|
||||
if (areaValue < minArea)
|
||||
{
|
||||
areaValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Initially only the two outer boundaries and absolute limits
|
||||
|
||||
DynamicList<scalar> initialCoord(nsteps_+1);
|
||||
|
||||
initialCoord.resize(4);
|
||||
initialCoord[0] = -GREAT;
|
||||
initialCoord[1] = Foam::max(limits_.min(), hard_min_);
|
||||
initialCoord[2] = limits_.max();
|
||||
initialCoord[3] = GREAT;
|
||||
|
||||
|
||||
// Select largest areas for fitting.
|
||||
// - done manually (instead of via sort) to handle full/half-steps
|
||||
// - find the largest area, add that to the list and remove its
|
||||
// area (and immediate surroundings) from the input.
|
||||
|
||||
// We have the "full steps overlapping so that we do not miss
|
||||
// a group of adjacent faces that are split over a boundary.
|
||||
// When we have identified a plane, we need to zero that
|
||||
// step, and also the overlapping ones to avoid
|
||||
// double-counting. when we have done that twice, we might
|
||||
// have completely removed the half-step that was between
|
||||
// them. That is why we also have the areas stored in
|
||||
// half-steps, so that is not lost.
|
||||
|
||||
while (initialCoord.size()-4 < totalArea_.size())
|
||||
{
|
||||
label n_big = 0;
|
||||
scalar largest = 0;
|
||||
|
||||
// Find largest area, using "real" scanned areas
|
||||
// thus checking the stored even locations.
|
||||
|
||||
for (label ii=0; ii < 2*nsteps_; ++ii)
|
||||
{
|
||||
if (largest < totalArea_[ii])
|
||||
{
|
||||
largest = totalArea_[ii];
|
||||
n_big = ii;
|
||||
}
|
||||
if (largest < totalArea2_[ii])
|
||||
{
|
||||
largest = totalArea2_[ii];
|
||||
n_big = -ii-1;
|
||||
}
|
||||
}
|
||||
|
||||
if (mag(largest) < SMALL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (n_big >= 0)
|
||||
{
|
||||
// Full step
|
||||
|
||||
const scalar pos = averagePosition(n_big);
|
||||
|
||||
// Remove from future checks
|
||||
totalArea_[n_big] = 0;
|
||||
|
||||
if (pos > hard_min_ + 0.4 * cellWidth)
|
||||
{
|
||||
// Only accept if not close to the ground
|
||||
|
||||
initialCoord.append(pos);
|
||||
|
||||
// Remove this and adjacent areas, which overlap this one
|
||||
if (n_big > 1)
|
||||
{
|
||||
totalArea_[n_big-1] = 0;
|
||||
}
|
||||
if (n_big < 2*nsteps_ - 1)
|
||||
{
|
||||
totalArea_[n_big+1] = 0;
|
||||
}
|
||||
|
||||
// Remove half-steps contained by this step
|
||||
totalArea2_[n_big] = 0;
|
||||
totalArea2_[n_big+1] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Half step
|
||||
n_big = -n_big-1;
|
||||
|
||||
const scalar pos = averageHalfPosition(n_big);
|
||||
|
||||
// Remove from future checks
|
||||
totalArea2_[n_big] = 0;
|
||||
|
||||
// On the first passes, this area will be included in full steps,
|
||||
// but it may eventually only remain in the half-step,
|
||||
// which could be the next largest
|
||||
|
||||
if (pos > hard_min_ + 0.4 * cellWidth)
|
||||
{
|
||||
// Only accept if not close to the ground
|
||||
|
||||
initialCoord.append(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now sort the positions
|
||||
Foam::sort(initialCoord);
|
||||
|
||||
// Avoid small zones near the begin/end positions
|
||||
|
||||
if
|
||||
(
|
||||
(initialCoord[2] - initialCoord[1])
|
||||
< (0.4 * cellWidth)
|
||||
)
|
||||
{
|
||||
// Remove [1] if too close to [2]
|
||||
initialCoord.remove(1);
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
initialCoord[initialCoord.size()-2]
|
||||
- initialCoord[initialCoord.size()-3]
|
||||
)
|
||||
< (0.4 * cellWidth)
|
||||
)
|
||||
{
|
||||
// Remove [N-3] if too close to [N-2]
|
||||
initialCoord.remove(initialCoord.size()-3);
|
||||
}
|
||||
|
||||
|
||||
// This is somewhat questionable (horrible mix of C and C++ addressing).
|
||||
//
|
||||
// If we have specified a max_zone (max number of cells per segment)
|
||||
// we will actually generate more divisions than originally
|
||||
// anticipated.
|
||||
|
||||
// So over-dimension arrays by a larger factor (eg, 20-100)
|
||||
// which is presumably good enough.
|
||||
|
||||
// FIXME: Needs revisiting (2020-12-16)
|
||||
|
||||
label nCoords = initialCoord.size();
|
||||
|
||||
scalarList coord(50*initialCoord.size(), Zero);
|
||||
SubList<scalar>(coord, initialCoord.size()) = initialCoord;
|
||||
|
||||
scalarList width(coord.size(), Zero);
|
||||
labelList nDivs(width.size(), Zero);
|
||||
|
||||
//
|
||||
// Set up initially uniform zones
|
||||
//
|
||||
for (label ii=1; ii < (nCoords-2); ++ii)
|
||||
{
|
||||
width[ii] = coord[ii+1] - coord[ii];
|
||||
nDivs[ii] = width[ii] / stepWidth_ * pars.areaWidthFactor + 0.5;
|
||||
|
||||
while (nDivs[ii] < 1)
|
||||
{
|
||||
// Positions too close - merge them
|
||||
--nCoords;
|
||||
|
||||
coord[ii] = 0.5 * (coord[ii+1] + coord[ii]);
|
||||
width[ii-1] = coord[ii] - coord[ii-1];
|
||||
nDivs[ii-1] =
|
||||
width[ii-1] / stepWidth_ * pars.areaWidthFactor + 0.5;
|
||||
|
||||
if (ii < (nCoords - 2))
|
||||
{
|
||||
for (label iii=ii+1; iii < nCoords-1; ++iii)
|
||||
{
|
||||
coord[iii] = coord[iii+1];
|
||||
}
|
||||
width[ii] = coord[ii+1] - coord[ii];
|
||||
|
||||
nDivs[ii] =
|
||||
width[ii] / stepWidth_ * pars.areaWidthFactor + 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
nDivs[ii] = 1; // Dummy value to terminate while
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Initially all steps have equal width (ratio == 1)
|
||||
|
||||
scalarList first(width.size(), Zero);
|
||||
|
||||
for (label ii=1; ii < (nCoords-2); ++ii)
|
||||
{
|
||||
first[ii] = width[ii] / nDivs[ii];
|
||||
}
|
||||
|
||||
scalarList last(first);
|
||||
scalarList ratio(width.size(), scalar(1));
|
||||
|
||||
// For diagnostics
|
||||
charList marker(width.size(), char('x'));
|
||||
marker[0] = '0';
|
||||
|
||||
|
||||
// Now adjust the inter-cell ratios to reduce cell-size changes
|
||||
// between zones
|
||||
|
||||
if (nCoords > 5)
|
||||
{
|
||||
// The outer zones can be adjusted to fit the adjacent steps
|
||||
|
||||
last[1] = first[2];
|
||||
first[nCoords-3] = last[nCoords-4];
|
||||
|
||||
// We adjust the cell size ratio in each zone so that the
|
||||
// cell sizes at the ends of the zones fit as well as
|
||||
// possible with their neighbours. Work forward through the
|
||||
// zones and then repeat a few times so that the adjustment
|
||||
// settles down.
|
||||
|
||||
for (int nIter = 0; nIter < 2; ++nIter)
|
||||
{
|
||||
for (label ii=1; ii < (nCoords-2); ++ii)
|
||||
{
|
||||
if (nDivs[ii] == 1)
|
||||
{
|
||||
// If only one step, no grading is possible
|
||||
|
||||
marker[ii] = '1'; // For Diagnostics
|
||||
continue;
|
||||
}
|
||||
marker[ii] = 'L'; // For Diagnostics
|
||||
|
||||
// Try making the in-zone steps equal to the step at
|
||||
// the left end to the last of the previous zone.
|
||||
|
||||
// If the step at the right is less than this, then
|
||||
// good... (fF this is the penultimate zone, we do
|
||||
// not need to worry about the step on the right
|
||||
// because the extent of the last zone can be
|
||||
// adjusted later to fit.)
|
||||
|
||||
scalar r_fit = 1;
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
(ii > 1)
|
||||
&& mag
|
||||
(
|
||||
log
|
||||
(
|
||||
fit_slope
|
||||
(
|
||||
last[ii-1],
|
||||
width[ii],
|
||||
nDivs[ii],
|
||||
r_fit
|
||||
)
|
||||
/ first[ii+1]
|
||||
)
|
||||
)
|
||||
< mag(log(r_fit))
|
||||
)
|
||||
|| (ii == nCoords-3)
|
||||
)
|
||||
{
|
||||
ratio[ii] = r_fit;
|
||||
}
|
||||
else
|
||||
{
|
||||
marker[ii] = 'R';
|
||||
|
||||
// otherwise try making the in-zone steps equal to
|
||||
// the step at the right end to the last of the
|
||||
// previous zone. If the step at the right is less
|
||||
// thhan this, then good... (If this is the second
|
||||
// zone, we do not need to worry about the step on
|
||||
// the left because the extent of the first zone
|
||||
// can be adjusted later to fit.)
|
||||
|
||||
if
|
||||
(
|
||||
mag
|
||||
(
|
||||
log
|
||||
(
|
||||
fit_slope
|
||||
(
|
||||
first[ii+1],
|
||||
width[ii],
|
||||
nDivs[ii],
|
||||
r_fit
|
||||
)
|
||||
/ last[ii-1]
|
||||
)
|
||||
)
|
||||
< mag(log(r_fit))
|
||||
|
||||
|| (ii == 1)
|
||||
)
|
||||
{
|
||||
ratio[ii] = 1.0 / r_fit;
|
||||
}
|
||||
else
|
||||
{
|
||||
ratio[ii] =
|
||||
pow(first[ii+1] / last[ii-1], 1.0/(nDivs[ii]-1));
|
||||
|
||||
marker[ii] = 'M';
|
||||
}
|
||||
}
|
||||
|
||||
first[ii] = end_val(width[ii], ratio[ii], nDivs[ii]);
|
||||
last[ii] = end_val(width[ii], 1.0/ratio[ii], nDivs[ii]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Adjust the ratio and the width in the first zone to
|
||||
// grade from cellWidth at the outside to the first cell of
|
||||
// the next zone. Increase the number of steps to keep edge
|
||||
// at least two (nEdgeLayers) cell widths from min.
|
||||
}
|
||||
|
||||
|
||||
if (coord[1] > hard_min_ + first[1] / pars.outerRatio)
|
||||
{
|
||||
nDivs[0] = pars.nEdgeLayers;
|
||||
ratio[0] = 1.0 / pars.outerRatio;
|
||||
coord[0] = coord[1] - first[1] * rn1r1(pars.outerRatio, nDivs[0]);
|
||||
|
||||
// Reduce the number of steps if we have extended below hard_min_
|
||||
while (coord[0] < hard_min_ && nDivs[0] > 1)
|
||||
{
|
||||
--nDivs[0];
|
||||
coord[0] = coord[1] - first[1] * rn1r1(pars.outerRatio, nDivs[0]);
|
||||
}
|
||||
|
||||
if (nDivs[0] < label(pars.nEdgeLayers))
|
||||
{
|
||||
// We had to adjust for hard_min_, so now fit exaxtly
|
||||
coord[0] = hard_min_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No room for outer zone. Remove it.
|
||||
--nCoords;
|
||||
|
||||
for (label ii = 0; ii < nCoords; ++ii)
|
||||
{
|
||||
coord[ii] = coord[ii+1];
|
||||
nDivs[ii] = nDivs[ii+1];
|
||||
ratio[ii] = ratio[ii+1];
|
||||
first[ii] = first[ii+1];
|
||||
last[ii] = last[ii+1];
|
||||
}
|
||||
coord[0] = hard_min_;
|
||||
}
|
||||
|
||||
width[0] = coord[1] - coord[0];
|
||||
first[0] = end_val(width[0],ratio[0],nDivs[0]);
|
||||
last[0] = end_val(width[0],1.0/ratio[0],nDivs[0]);
|
||||
|
||||
|
||||
// Now do the upper edge zone
|
||||
{
|
||||
const label np2 = nCoords - 2;
|
||||
|
||||
ratio[np2] = pars.outerRatio;
|
||||
nDivs[np2] = pars.nEdgeLayers;
|
||||
|
||||
coord[np2+1] =
|
||||
coord[np2] + last[np2-1] * rn1r1(pars.outerRatio, nDivs[np2]);
|
||||
|
||||
width[np2] = coord[np2+1] - coord[np2];
|
||||
|
||||
first[np2] = last[np2-1];
|
||||
last[np2] = first[np2] * pow(pars.outerRatio, nDivs[np2] - 1);
|
||||
}
|
||||
|
||||
|
||||
// If we have a zone along the length of the plant that is much
|
||||
// longer than the width or height, then makePDRMeshBlocks does
|
||||
// not produce a very good outer boundary shape.
|
||||
// So here we divide the zone into several zones of roughly equal width.
|
||||
// A bit commplicated because of the increasing or decreasing step
|
||||
// sizes across the zone.
|
||||
|
||||
if (max_zone > 0)
|
||||
{
|
||||
for (label ii = 0; ii < (nCoords-1); ++ii)
|
||||
{
|
||||
if (width[ii] > max_zone && nDivs[ii] > 1)
|
||||
{
|
||||
// No. of extra zones
|
||||
const label nExtra = width[ii] / max_zone - 1;
|
||||
|
||||
// Make space for extra zones
|
||||
for (label ij = nCoords-1; ij > ii; --ij)
|
||||
{
|
||||
width[ij+nExtra] = width[ij];
|
||||
ratio[ij+nExtra] = ratio[ij];
|
||||
first[ij+nExtra] = first[ij];
|
||||
last[ij+nExtra] = last[ij];
|
||||
nDivs[ij+nExtra] = nDivs[ij];
|
||||
coord[ij+nExtra] = coord[ij];
|
||||
}
|
||||
nCoords += nExtra;
|
||||
|
||||
const scalar subWidth = width[ii] / (nExtra + 1);
|
||||
scalar bdy = coord[ii];
|
||||
|
||||
last[ii+nExtra] = last[ii];
|
||||
nDivs[ii+nExtra] = nDivs[ii]; // will be decremented
|
||||
width[ii+nExtra] = width[ii]; // will be decremented
|
||||
|
||||
// Current position
|
||||
scalar here = coord[ii];
|
||||
scalar step = first[ii];
|
||||
|
||||
// Look for cell boundaries close to where we want
|
||||
// to put the zone boundaries
|
||||
for (label ij = ii; ij < ii+nExtra; ++ij)
|
||||
{
|
||||
label ist = 0;
|
||||
bdy += subWidth;
|
||||
do
|
||||
{
|
||||
here += step;
|
||||
step *= ratio[ii];
|
||||
++ist;
|
||||
} while ((here + 0.5 * step) < bdy);
|
||||
|
||||
// Found a cell boundary at 'here' that is close to bdy
|
||||
|
||||
// Create this sub-zone
|
||||
last[ij] = step / ratio[ii];
|
||||
first[ij+1] = step;
|
||||
coord[ij+1] = here;
|
||||
width[ij] = coord[ij+1] - coord[ij];
|
||||
nDivs[ij] = ist;
|
||||
ratio[ij+1] = ratio[ij];
|
||||
|
||||
// Decrement what remains for the last sub-zone
|
||||
nDivs[ii+nExtra] -= ist;
|
||||
width[ii+nExtra] -= width[ij];
|
||||
}
|
||||
|
||||
ii += nExtra;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (verbose())
|
||||
{
|
||||
printf("Zone Cell widths Ratios\n");
|
||||
printf("start first last left mid right\n");
|
||||
for (label ii = 0; ii < (nCoords-1); ++ii)
|
||||
{
|
||||
printf
|
||||
(
|
||||
"%6.2f %6.2f %6.2f %c %6.2f %6.2f %6.2f\n",
|
||||
coord[ii], first[ii], last[ii],
|
||||
marker[ii],
|
||||
first[ii]/last[ii-1], ratio[ii], first[ii+1]/last[ii]
|
||||
);
|
||||
}
|
||||
printf("%6.2f\n", coord[nCoords-1]);
|
||||
}
|
||||
|
||||
|
||||
// Copy back into a gridControl form
|
||||
|
||||
PDRblock::gridControl grid;
|
||||
|
||||
grid.resize(nCoords);
|
||||
for (label i = 0; i < nCoords; ++i)
|
||||
{
|
||||
grid[i] = coord[i];
|
||||
}
|
||||
for (label i = 0; i < nCoords-1; ++i)
|
||||
{
|
||||
grid.divisions_[i] = nDivs[i];
|
||||
}
|
||||
for (label i = 0; i < nCoords-1; ++i)
|
||||
{
|
||||
grid.expansion_[i] = ratio[i];
|
||||
}
|
||||
|
||||
return grid;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,224 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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::PDRfitMeshScan
|
||||
|
||||
Description
|
||||
Scanning of obstacles in a single direction for PDRfitMesh
|
||||
|
||||
SourceFiles
|
||||
PDRfitMeshScan.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PDRfitMeshScan_H
|
||||
#define PDRfitMeshScan_H
|
||||
|
||||
#include "scalarList.H"
|
||||
#include "DynamicList.H"
|
||||
#include "MinMax.H"
|
||||
#include "PDRblock.H"
|
||||
#include "PDRfitMeshParams.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PDRfitMeshScan Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class PDRfitMeshScan
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Lower and upper limits
|
||||
scalarMinMax limits_;
|
||||
|
||||
//- Absolute lower limit (eg, for the ground plane)
|
||||
scalar hard_min_ = -GREAT;
|
||||
|
||||
//- Number of steps
|
||||
label nsteps_ = 0;
|
||||
|
||||
//- Step width = limits / nsteps
|
||||
scalar stepWidth_ = 0;
|
||||
|
||||
//- Minimum per cell face area. Defined via PDRfitMeshParams
|
||||
scalar minFaceArea_ = 0;
|
||||
|
||||
//- Area-weighted position
|
||||
DynamicList<scalar> weightedPos_;
|
||||
|
||||
//- Area-weights for position
|
||||
DynamicList<scalar> totalArea_;
|
||||
|
||||
//- Area-weighted half-cell position
|
||||
DynamicList<scalar> weightedPos2_;
|
||||
|
||||
//- Area-weights for half-cell position
|
||||
DynamicList<scalar> totalArea2_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Area-averaged position at index
|
||||
inline scalar averagePosition(const label i) const
|
||||
{
|
||||
return
|
||||
(
|
||||
totalArea_[i] < VSMALL
|
||||
? 0
|
||||
: (weightedPos_[i] / totalArea_[i])
|
||||
);
|
||||
}
|
||||
|
||||
//- Area-averaged half-position at index
|
||||
inline scalar averageHalfPosition(const label i) const
|
||||
{
|
||||
return
|
||||
(
|
||||
totalArea2_[i] < VSMALL
|
||||
? 0
|
||||
: (weightedPos2_[i] / totalArea2_[i])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Add coordinate and weight. Already sanity checked
|
||||
void addCoord(const scalar coord, const scalar weight);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Public Data
|
||||
|
||||
//- Output verbosity
|
||||
static bool verbose_;
|
||||
|
||||
//- Use gridControl as per PDRblock, with EXPAND_RELATIVE
|
||||
typedef PDRblock::gridControl gridControl;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Default construct
|
||||
PDRfitMeshScan()
|
||||
:
|
||||
limits_(GREAT, -GREAT),
|
||||
hard_min_(-GREAT),
|
||||
nsteps_(0),
|
||||
stepWidth_(0)
|
||||
{}
|
||||
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Get verbosity
|
||||
static inline bool verbose() noexcept
|
||||
{
|
||||
return verbose_;
|
||||
}
|
||||
|
||||
//- Set verbosity
|
||||
static inline bool verbose(const bool val) noexcept
|
||||
{
|
||||
bool old(verbose_);
|
||||
verbose_ = val;
|
||||
return old;
|
||||
}
|
||||
|
||||
//- The expansion name
|
||||
static word expansionName();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The min/max limits
|
||||
const scalarMinMax& limits() const noexcept
|
||||
{
|
||||
return limits_;
|
||||
}
|
||||
|
||||
//- The min/max limits
|
||||
scalarMinMax& limits() noexcept
|
||||
{
|
||||
return limits_;
|
||||
}
|
||||
|
||||
//- The step-width
|
||||
scalar stepWidth() const noexcept
|
||||
{
|
||||
return stepWidth_;
|
||||
}
|
||||
|
||||
//- Set the hard-min
|
||||
void hard_min(const scalar val) noexcept
|
||||
{
|
||||
hard_min_ = val;
|
||||
}
|
||||
|
||||
|
||||
//- Reset to initial state
|
||||
void reset();
|
||||
|
||||
//- Adjust limits to accommodate the specified point coordinates
|
||||
void adjustLimits(const scalar point0, const scalar point1);
|
||||
|
||||
//- Define number of steps (and step-size) according to the
|
||||
//- current limits and the specified parameters
|
||||
void resize(const scalar cellWidth, const PDRfitMeshParams& pars);
|
||||
|
||||
void addArea
|
||||
(
|
||||
const scalar weight,
|
||||
const scalar point0,
|
||||
const scalar point1
|
||||
);
|
||||
|
||||
//- Calculate equivalent grid control from the scanned planes
|
||||
PDRblock::gridControl
|
||||
calcGridControl
|
||||
(
|
||||
const scalar cellWidth,
|
||||
const scalar max_zone,
|
||||
const PDRfitMeshParams& pars
|
||||
);
|
||||
|
||||
void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,464 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016 Shell Research Ltd.
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "PDRfitMeshScans.H"
|
||||
#include "PDRobstacle.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::PDRfitMeshScans::prepare
|
||||
(
|
||||
const UList<PDRobstacle>& obstacles,
|
||||
const PDRfitMeshParams& fitParams,
|
||||
scalar cellWidth
|
||||
)
|
||||
{
|
||||
reset();
|
||||
|
||||
// Scan for obstacle limits
|
||||
scanLimits(obstacles);
|
||||
|
||||
// Clip with optional user bounds
|
||||
|
||||
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
|
||||
{
|
||||
scalarMinMax& limits = (*this)[cmpt].limits();
|
||||
|
||||
if (fitParams.minBounds[cmpt].has_value())
|
||||
{
|
||||
limits.min() = fitParams.minBounds[cmpt].value();
|
||||
}
|
||||
if (fitParams.maxBounds[cmpt].has_value())
|
||||
{
|
||||
limits.max() = fitParams.maxBounds[cmpt].value();
|
||||
}
|
||||
}
|
||||
|
||||
// Get obstacle locations and subgrid length (if any)
|
||||
scanAreas(obstacles, fitParams, cellWidth);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::PDRfitMeshScans::volume() const
|
||||
{
|
||||
scalar vol = 1;
|
||||
|
||||
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
|
||||
{
|
||||
const scalarMinMax& limits = (*this)[cmpt].limits();
|
||||
|
||||
if (limits.valid())
|
||||
{
|
||||
vol *= limits.mag();
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return vol;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::PDRfitMeshScans::cellVolume() const
|
||||
{
|
||||
scalar vol = 1;
|
||||
|
||||
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
|
||||
{
|
||||
vol *= (*this)[cmpt].stepWidth();
|
||||
}
|
||||
|
||||
return vol;
|
||||
}
|
||||
|
||||
|
||||
void Foam::PDRfitMeshScans::reset()
|
||||
{
|
||||
subgridLen_ = 0;
|
||||
|
||||
for (PDRfitMeshScan& pln : *this)
|
||||
{
|
||||
pln.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::PDRfitMeshScans::resize
|
||||
(
|
||||
const scalar cellWidth,
|
||||
const PDRfitMeshParams& pars
|
||||
)
|
||||
{
|
||||
for (PDRfitMeshScan& pln : *this)
|
||||
{
|
||||
pln.resize(cellWidth, pars);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Foam::PDRfitMeshScans::print(Ostream& os) const
|
||||
{
|
||||
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
|
||||
{
|
||||
os << vector::componentNames[cmpt] << ' ';
|
||||
(*this)[cmpt].print(os);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::PDRfitMeshScans::scanLimits
|
||||
(
|
||||
const UList<PDRobstacle>& obstacles
|
||||
)
|
||||
{
|
||||
for (const PDRobstacle& obs : obstacles)
|
||||
{
|
||||
switch (obs.typeId)
|
||||
{
|
||||
case PDRobstacle::CYLINDER:
|
||||
case PDRobstacle::DIAG_BEAM:
|
||||
{
|
||||
(*this)[obs.orient].adjustLimits
|
||||
(
|
||||
obs.pt[obs.orient],
|
||||
obs.pt[obs.orient] + obs.len()
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
case PDRobstacle::CUBOID_1:
|
||||
case PDRobstacle::LOUVRE_BLOWOFF:
|
||||
case PDRobstacle::CUBOID:
|
||||
case PDRobstacle::WALL_BEAM:
|
||||
case PDRobstacle::GRATING:
|
||||
case PDRobstacle::RECT_PATCH:
|
||||
{
|
||||
(*this).x().adjustLimits(obs.x(), obs.x() + obs.span.x());
|
||||
(*this).y().adjustLimits(obs.y(), obs.y() + obs.span.y());
|
||||
(*this).z().adjustLimits(obs.z(), obs.z() + obs.span.z());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar
|
||||
Foam::PDRfitMeshScans::scanAreas
|
||||
(
|
||||
const UList<PDRobstacle>& obstacles,
|
||||
const scalar minSubgridLen
|
||||
)
|
||||
{
|
||||
scalar subgridLen = 0;
|
||||
|
||||
const bool checkSubgrid = (minSubgridLen > 0);
|
||||
|
||||
if (verbose())
|
||||
{
|
||||
Info<< "Scan " << obstacles.size()
|
||||
<< " obstacles. Check for subgrid < " << minSubgridLen
|
||||
<< nl;
|
||||
}
|
||||
|
||||
// When sorting flat elements, convert vector -> List
|
||||
List<scalar> gridSpan(3);
|
||||
|
||||
for (const PDRobstacle& obs : obstacles)
|
||||
{
|
||||
switch (obs.typeId)
|
||||
{
|
||||
case PDRobstacle::CYLINDER:
|
||||
{
|
||||
// #ifdef FULLDEBUG
|
||||
// Info<< "Add " << obs.info() << nl;
|
||||
// #endif
|
||||
|
||||
(*this)[obs.orient].addArea
|
||||
(
|
||||
sqr(0.5*obs.dia()),
|
||||
obs.pt[obs.orient],
|
||||
obs.pt[obs.orient] + obs.len()
|
||||
);
|
||||
|
||||
// Store total length of subgrid obstcales
|
||||
if (checkSubgrid && obs.dia() < minSubgridLen)
|
||||
{
|
||||
subgridLen += obs.len();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PDRobstacle::DIAG_BEAM:
|
||||
{
|
||||
// #ifdef FULLDEBUG
|
||||
// Info<< "Add " << obs.info() << nl;
|
||||
// #endif
|
||||
|
||||
(*this)[obs.orient].addArea
|
||||
(
|
||||
(obs.wa * obs.wb),
|
||||
obs.pt[obs.orient],
|
||||
obs.pt[obs.orient] + obs.len()
|
||||
);
|
||||
|
||||
// Store total length of subgrid obstcales
|
||||
if (checkSubgrid && Foam::max(obs.wa, obs.wb) < minSubgridLen)
|
||||
{
|
||||
subgridLen += obs.len();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PDRobstacle::CUBOID_1:
|
||||
case PDRobstacle::LOUVRE_BLOWOFF:
|
||||
case PDRobstacle::CUBOID:
|
||||
case PDRobstacle::WALL_BEAM:
|
||||
case PDRobstacle::GRATING:
|
||||
case PDRobstacle::RECT_PATCH:
|
||||
{
|
||||
// #ifdef FULLDEBUG
|
||||
// Info<< "Add " << obs.info() << nl;
|
||||
// #endif
|
||||
|
||||
// Can be lazy here, addArea() filters out zero areas
|
||||
|
||||
(*this)[vector::X].addArea
|
||||
(
|
||||
(obs.span.y() * obs.span.z()),
|
||||
obs.x(),
|
||||
obs.x() + obs.span.x()
|
||||
);
|
||||
|
||||
(*this)[vector::Y].addArea
|
||||
(
|
||||
(obs.span.z() * obs.span.x()),
|
||||
obs.y(),
|
||||
obs.y() + obs.span.y()
|
||||
);
|
||||
|
||||
(*this)[vector::Z].addArea
|
||||
(
|
||||
(obs.span.x() * obs.span.y()),
|
||||
obs.z(),
|
||||
obs.z() + obs.span.z()
|
||||
);
|
||||
|
||||
if (checkSubgrid)
|
||||
{
|
||||
gridSpan[0] = obs.span.x();
|
||||
gridSpan[1] = obs.span.y();
|
||||
gridSpan[2] = obs.span.z();
|
||||
Foam::sort(gridSpan);
|
||||
|
||||
// Ignore zero dimension when considering subgrid
|
||||
|
||||
// Store total length of subgrid obstcales
|
||||
if (gridSpan[1] < minSubgridLen)
|
||||
{
|
||||
subgridLen += gridSpan.last();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return subgridLen;
|
||||
}
|
||||
|
||||
|
||||
void Foam::PDRfitMeshScans::scanAreas
|
||||
(
|
||||
const UList<PDRobstacle>& obstacles
|
||||
)
|
||||
{
|
||||
(void)scanAreas(obstacles, -GREAT);
|
||||
}
|
||||
|
||||
|
||||
void Foam::PDRfitMeshScans::scanAreas
|
||||
(
|
||||
const UList<PDRobstacle>& obstacles,
|
||||
const PDRfitMeshParams& fitParams,
|
||||
scalar cellWidth
|
||||
)
|
||||
{
|
||||
resize(mag(cellWidth), fitParams);
|
||||
|
||||
const scalar minSubgridLen =
|
||||
(cellWidth < 0 ? (mag(cellWidth) * fitParams.widthFactor) : 0);
|
||||
|
||||
subgridLen_ = scanAreas(obstacles, minSubgridLen);
|
||||
}
|
||||
|
||||
|
||||
Foam::Vector<Foam::PDRblock::gridControl>
|
||||
Foam::PDRfitMeshScans::calcGriding
|
||||
(
|
||||
const UList<PDRobstacle>& obstacles,
|
||||
const PDRfitMeshParams& fitParams,
|
||||
scalar cellWidth
|
||||
)
|
||||
{
|
||||
prepare(obstacles, fitParams, cellWidth);
|
||||
|
||||
const scalar innerVol = volume();
|
||||
|
||||
// Set hard lower limit at the ground
|
||||
|
||||
z().hard_min(fitParams.ground);
|
||||
|
||||
if (z().limits().min() < fitParams.ground)
|
||||
{
|
||||
z().limits().min() = fitParams.ground;
|
||||
}
|
||||
|
||||
if (verbose())
|
||||
{
|
||||
print(Info);
|
||||
Info<< "cellWidth = " << cellWidth << nl;
|
||||
Info<< "inner volume: " << innerVol << nl;
|
||||
Info<< "subgrid length: " << subgridLen_ << nl;
|
||||
}
|
||||
|
||||
|
||||
// Read in obstacles and record face planes Also record length of
|
||||
// subgrid obstacles so that we can optimise cell size to get
|
||||
// desired average no, of obstacles oper cell. Determinuing which
|
||||
// obstacles are subgrid is iself dependent on the cell size.
|
||||
// Therefore we iterate (if cell_width is -ve) If cell_width is
|
||||
// +ve just use the user-supplied value.
|
||||
|
||||
{
|
||||
// The cell-widths during optimisation
|
||||
scalar prev_cw = 0, cw = 0;
|
||||
|
||||
const bool optimiseWidth = (cellWidth < 0);
|
||||
|
||||
for (label nIter = 0; nIter < fitParams.maxIterations; ++nIter)
|
||||
{
|
||||
scanAreas(obstacles, fitParams, cellWidth);
|
||||
|
||||
if (cellWidth < 0)
|
||||
{
|
||||
constexpr scalar relax = 0.7;
|
||||
|
||||
prev_cw = cw;
|
||||
|
||||
if (subgridLen_ < cellWidth)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "No sub-grid obstacles found" << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Optimise to average subgrid obstacles per cell
|
||||
cw = sqrt(fitParams.obsPerCell * innerVol / subgridLen_);
|
||||
cw = Foam::min(cw, fitParams.maxCellWidth);
|
||||
|
||||
if (cw > cellWidth * fitParams.maxWidthEstimate)
|
||||
{
|
||||
Warning
|
||||
<< "Calculated cell width more than"
|
||||
" maxWidthEstimate x estimate." << nl
|
||||
<< "Too few sub-grid obstacles?"
|
||||
<< nl;
|
||||
}
|
||||
|
||||
Info<< "Current cellwidth: " << cw << nl;
|
||||
|
||||
scalar ratio = cw / cellWidth;
|
||||
|
||||
if (ratio < 1)
|
||||
{
|
||||
ratio = 1/ratio;
|
||||
}
|
||||
|
||||
if (ratio < fitParams.maxWidthRatio)
|
||||
{
|
||||
cellWidth = -cellWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellWidth = relax * (-cw) + (1.0 - relax) * cellWidth;
|
||||
}
|
||||
Info<< "Cell width: " << cellWidth << nl;
|
||||
}
|
||||
|
||||
if (cellWidth > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cellWidth < 0)
|
||||
{
|
||||
cellWidth = 0.5 * (cw + prev_cw);
|
||||
}
|
||||
|
||||
if (optimiseWidth)
|
||||
{
|
||||
Info<< nl << "Final cell width: " << cellWidth << nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now we fit the mesh to the planes and write out the result
|
||||
|
||||
resize(cellWidth, fitParams);
|
||||
cellWidth = cbrt(cellVolume()) / fitParams.areaWidthFactor;
|
||||
|
||||
scanAreas(obstacles, fitParams, cellWidth);
|
||||
|
||||
const scalar max_zone =
|
||||
(
|
||||
(z().limits().mag() + fitParams.nEdgeLayers * cellWidth)
|
||||
* fitParams.maxZoneToHeight
|
||||
);
|
||||
|
||||
|
||||
Vector<PDRblock::gridControl> griding;
|
||||
|
||||
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
|
||||
{
|
||||
griding[cmpt] =
|
||||
(*this)[cmpt].calcGridControl(cellWidth, max_zone, fitParams);
|
||||
}
|
||||
|
||||
return griding;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,154 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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::PDRfitMeshScans
|
||||
|
||||
Description
|
||||
Scanning of obstacles in a multiple directions for PDRfitMesh
|
||||
|
||||
SourceFiles
|
||||
PDRfitMeshScans.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PDRfitMeshScans_H
|
||||
#define PDRfitMeshScans_H
|
||||
|
||||
#include "PDRfitMeshScan.H"
|
||||
#include "vector.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class PDRobstacle;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PDRfitMeshScans Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class PDRfitMeshScans
|
||||
:
|
||||
public Vector<PDRfitMeshScan>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- The evaluated sub-grid length
|
||||
scalar subgridLen_ = 0;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Prepare limits, scan areas
|
||||
void prepare
|
||||
(
|
||||
const UList<PDRobstacle>& obstacles,
|
||||
const PDRfitMeshParams& fitParams,
|
||||
scalar cellWidth
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// Default Constructors
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Verbosity
|
||||
static inline bool verbose() noexcept
|
||||
{
|
||||
return PDRfitMeshScan::verbose();
|
||||
}
|
||||
|
||||
//- Calculate the grid controls for the given obstacles
|
||||
//- and parameters
|
||||
Vector<PDRblock::gridControl>
|
||||
calcGriding
|
||||
(
|
||||
const UList<PDRobstacle>& obstacles,
|
||||
const PDRfitMeshParams& fitParams,
|
||||
scalar cellWidth
|
||||
);
|
||||
|
||||
|
||||
// Low-level functions
|
||||
|
||||
//- The volume of the limits
|
||||
scalar volume() const;
|
||||
|
||||
//- The volume of single cell of the respective step-width
|
||||
scalar cellVolume() const;
|
||||
|
||||
//- Reset to initial state
|
||||
void reset();
|
||||
|
||||
//- Define number of steps (and step-size) according to the
|
||||
//- current limits and the specified parameters
|
||||
void resize(const scalar cellWidth, const PDRfitMeshParams& pars);
|
||||
|
||||
//- Adjust directional limits to accommodate obstacles
|
||||
void scanLimits(const UList<PDRobstacle>& obstacles);
|
||||
|
||||
//- Populate with areas/positions of the obstacles,
|
||||
//- and check for sub-grid obstacles
|
||||
// Sets the internal
|
||||
void scanAreas
|
||||
(
|
||||
const UList<PDRobstacle>& obstacles,
|
||||
const PDRfitMeshParams& fitParams,
|
||||
scalar cellWidth
|
||||
);
|
||||
|
||||
//- Populate with areas/positions of the obstacles,
|
||||
//- and check for sub-grid obstacles
|
||||
//
|
||||
// \return total subgrid lengths
|
||||
scalar scanAreas
|
||||
(
|
||||
const UList<PDRobstacle>& obstacles,
|
||||
const scalar minSubgridLen
|
||||
);
|
||||
|
||||
//- Populate with areas/positions of the obstacles,
|
||||
//- without checks for sub-grid obstacles
|
||||
void scanAreas(const UList<PDRobstacle>& obstacles);
|
||||
|
||||
//- Print information
|
||||
void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,15 @@
|
||||
EXE_INC = \
|
||||
-I../pdrFields/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/mesh/blockMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lfileFormats \
|
||||
-lsurfMesh \
|
||||
-lmeshTools \
|
||||
-lblockMesh \
|
||||
-lpdrFields
|
||||
@ -83,6 +83,8 @@ int main(int argc, char* argv[])
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
const bool dryrun = args.found("dry-run");
|
||||
|
||||
const word dictName("PDRsetFieldsDict");
|
||||
#include "setSystemRunTimeDictionaryIO.H"
|
||||
|
||||
@ -90,8 +92,6 @@ int main(int argc, char* argv[])
|
||||
|
||||
IOdictionary setFieldsDict(dictIO);
|
||||
|
||||
const bool dryrun = args.found("dry-run");
|
||||
|
||||
const fileName& casepath = runTime.globalPath();
|
||||
|
||||
pars.timeName = "0";
|
||||
@ -1149,9 +1149,9 @@ static void tail_field
|
||||
const UList<PDRpatchDef>& patches
|
||||
)
|
||||
{
|
||||
// seaGround
|
||||
// ground
|
||||
{
|
||||
os.beginBlock("seaGround");
|
||||
os.beginBlock(pars.groundPatchName);
|
||||
os.writeKeyword("type") << wall_bc << token::END_STATEMENT << nl;
|
||||
putUniform(os, "value", deflt);
|
||||
os.endBlock();
|
||||
@ -1222,13 +1222,14 @@ static void tail_field
|
||||
os.endBlock();
|
||||
}
|
||||
|
||||
if ( pars.two_d )
|
||||
if (pars.two_d)
|
||||
{
|
||||
os.beginBlock("z_boundaries");
|
||||
os.writeEntry("type", "empty");
|
||||
os.endBlock();
|
||||
}
|
||||
if ( pars.outer_orthog )
|
||||
|
||||
if (pars.outer_orthog)
|
||||
{
|
||||
os.beginBlock("outer_inner");
|
||||
os.writeEntry("type", "cyclicAMI");
|
||||
@ -1285,9 +1286,10 @@ void write_scalarField
|
||||
os << nl;
|
||||
os.beginBlock("boundaryField");
|
||||
|
||||
|
||||
// outer
|
||||
{
|
||||
os.beginBlock("outer");
|
||||
os.beginBlock(pars.outerPatchName);
|
||||
|
||||
os.writeEntry("type", "inletOutlet");
|
||||
putUniform(os, "inletValue", deflt);
|
||||
@ -1329,7 +1331,8 @@ void write_uniformField
|
||||
|
||||
// outer
|
||||
{
|
||||
os.beginBlock("outer");
|
||||
os.beginBlock(pars.outerPatchName);
|
||||
|
||||
if (fieldName == "alphat" || fieldName == "nut")
|
||||
{
|
||||
// Different b.c. for alphat & nut
|
||||
@ -1377,17 +1380,17 @@ void write_pU_fields
|
||||
os << nl;
|
||||
os.beginBlock("boundaryField");
|
||||
|
||||
// "outer"
|
||||
// outer
|
||||
{
|
||||
os.beginBlock("outer");
|
||||
os.beginBlock(pars.outerPatchName);
|
||||
os.writeEntry("type", "inletOutlet");
|
||||
putUniform(os, "inletValue", vector::zero);
|
||||
os.endBlock();
|
||||
}
|
||||
|
||||
// seaGround
|
||||
// ground
|
||||
{
|
||||
os.beginBlock("seaGround");
|
||||
os.beginBlock(pars.groundPatchName);
|
||||
os.writeEntry("type", "zeroGradient");
|
||||
os.endBlock();
|
||||
}
|
||||
@ -1497,9 +1500,10 @@ void write_pU_fields
|
||||
os << nl;
|
||||
os.beginBlock("boundaryField");
|
||||
|
||||
// "outer"
|
||||
// outer
|
||||
{
|
||||
os.beginBlock("outer");
|
||||
os.beginBlock(pars.outerPatchName);
|
||||
|
||||
os.writeEntry("type", "waveTransmissive");
|
||||
os.writeEntry("gamma", 1.3);
|
||||
os.writeEntry("fieldInf", deflt);
|
||||
@ -1560,7 +1564,7 @@ void write_symmTensorField
|
||||
|
||||
// outer
|
||||
{
|
||||
os.beginBlock("outer");
|
||||
os.beginBlock(pars.outerPatchName);
|
||||
|
||||
os.writeEntry("type", "inletOutlet");
|
||||
putUniform(os, "inletValue", deflt);
|
||||
@ -1628,7 +1632,7 @@ void write_symmTensorFieldV
|
||||
|
||||
// outer
|
||||
{
|
||||
os.beginBlock("outer");
|
||||
os.beginBlock(pars.outerPatchName);
|
||||
|
||||
os.writeEntry("type", "inletOutlet");
|
||||
putUniform(os, "inletValue", deflt);
|
||||
@ -94,7 +94,7 @@ void Foam::PDRmeshArrays::classify
|
||||
<< " nPoints:" << pdrBlock.nPoints()
|
||||
<< " nCells:" << pdrBlock.nCells()
|
||||
<< " nFaces:" << pdrBlock.nFaces() << nl
|
||||
<< " min-edge:" << pdrBlock.minEdgeLen() << nl;
|
||||
<< " min-edge:" << pdrBlock.edgeLimits().min() << nl;
|
||||
|
||||
Info<< "Classifying ijk indexing... " << nl;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -84,6 +84,20 @@ void Foam::PDRparams::readDefaults(const dictionary& dict)
|
||||
dict.readIfPresent("blockageNoCT", blockageNoCT);
|
||||
dict.readIfPresent("scale", scale);
|
||||
|
||||
|
||||
const dictionary* dictptr;
|
||||
|
||||
groundPatchName = "ground";
|
||||
outerPatchName = "outer";
|
||||
|
||||
if ((dictptr = dict.findDict("patchNames")) != nullptr)
|
||||
{
|
||||
const dictionary& d = *dictptr;
|
||||
|
||||
d.readIfPresent("ground", groundPatchName);
|
||||
d.readIfPresent("outer", outerPatchName);
|
||||
}
|
||||
|
||||
UPatchBc = "fixedValue;value uniform (0 0 0)";
|
||||
if (dict.readIfPresent("UPatchBc", UPatchBc))
|
||||
{
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016 Shell Research Ltd.
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -62,6 +62,13 @@ public:
|
||||
fileName obsfile_dir;
|
||||
wordList obsfile_names;
|
||||
word timeName;
|
||||
|
||||
//- The name for the "ground" patch
|
||||
word groundPatchName;
|
||||
|
||||
//- The name for the "outer" patch
|
||||
word outerPatchName;
|
||||
|
||||
string UPatchBc; //!< "fixedValue;value uniform (0 0 0)"
|
||||
|
||||
bool legacyMeshSpec{false};
|
||||
@ -136,7 +143,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
//- Default construct
|
||||
PDRparams() = default;
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,9 +29,6 @@ Namespace
|
||||
Description
|
||||
Utilities for PDR (eg, for setFields)
|
||||
|
||||
SourceFiles
|
||||
PDRUtils.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PDRutils_H
|
||||
@ -48,11 +45,17 @@ namespace Foam
|
||||
// Forward Declarations
|
||||
class PDRobstacle;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace PDRutils
|
||||
{
|
||||
|
||||
|
||||
} // End namespace PDRutils
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -264,6 +264,8 @@ public:
|
||||
);
|
||||
|
||||
//- Trim obstacle to ensure it is within the specified bounding box
|
||||
//- and return the intersection type.
|
||||
// Returns UNKNOWN for unknown types and invalid bounding boxes
|
||||
volumeType trim(const boundBox& bb);
|
||||
|
||||
//- Surface (points, faces) representation
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user