Compare commits

..

6 Commits

Author SHA1 Message Date
db246431ff BUG: mappedPatch: do not use sampleMesh. Fixes #1951.
The helper function sampleMesh returns a reference to
the sampled mesh. This will fail if that mesh
is on a different world.
2020-12-09 10:23:42 +00:00
979dcf696c ENH: Adding dynamic mesh to solidFoam and tutorial 2020-12-08 15:01:32 +00:00
73ffde539b ENH: waterCooler: new tutorial. 2020-12-08 14:05:50 +00:00
2c41fea031 ENH: Added new multiWorld test case 2020-12-08 14:05:50 +00:00
04b9d1a397 ENH: Added new solidFoam solver 2020-12-08 14:05:44 +00:00
6ac9eba5bd ENH: mpi: use per-application communicator. 2020-12-08 14:04:43 +00:00
1086 changed files with 11210 additions and 59409 deletions

View File

@ -33,7 +33,6 @@ It is likely incomplete...
- Haakan Nilsson
- Niklas Nordin
- Mark Olesen
- Victor Olesen
- Evangelos Papoutsis-Kiachagias
- Juho Peltola
- Johan Roenby
@ -50,7 +49,3 @@ It is likely incomplete...
- Norbert Weber
- Henry Weller
- Niklas Wikstrom
- Thorsten Zirwes
<!----------------------------------------------------------------------------->

View File

@ -1,2 +1,2 @@
api=2012
patch=0
api=2011
patch=201012

View File

@ -1,3 +0,0 @@
acousticFoam.C
EXE = $(FOAM_APPBIN)/acousticFoam

View File

@ -1,14 +0,0 @@
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

View File

@ -1,99 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //

View File

@ -1,15 +0,0 @@
Info << "\nReading pa" << endl;
volScalarField pa
(
IOobject
(
"pa",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

View File

@ -1,8 +0,0 @@
fvSolution solutionDict(runTime);
const dictionary& pimpleDict = solutionDict.subDict("PIMPLE");
bool solvePrimaryRegion
(
pimpleDict.getOrDefault("solvePrimaryRegion", true)
);

View File

@ -1,15 +0,0 @@
fvScalarMatrix paEqn
(
fvm::d2dt2(pa) - sqr(c0)*fvc::laplacian(pa)
);
if (solvePrimaryRegion)
{
paEqn.relax();
paEqn.solve();
}
else
{
pa.correctBoundaryConditions();
}

View File

@ -1,23 +0,0 @@
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;

View File

@ -14,9 +14,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionFaModels/lnInclude
-I$(LIB_SRC)/regionModels/regionModel/lnInclude
EXE_LIBS = \
-lfiniteVolume \
@ -30,8 +28,4 @@ EXE_LIBS = \
-lturbulenceModels \
-lcompressibleTurbulenceModels \
-lradiationModels \
-lfvOptions \
-lfaOptions \
-lregionModels \
-lsampling \
-lregionFaModels
-lregionModels

View File

@ -1,4 +1,5 @@
EXE_INC = \
-DFULLDEBUG -g -O0 \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \

View File

@ -1,4 +0,0 @@
const volScalarField& rho = trho();
volScalarField& h = thermo.he();
const volScalarField& betav = *betavPtr;

View File

@ -4,6 +4,13 @@ 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;
@ -89,6 +96,7 @@ else
)
);
}
const volScalarField& betav = *betavPtr;
#include "createRadiationModel.H"
#include "createFvOptions.H"

View File

@ -60,7 +60,6 @@ int main(int argc, char *argv[])
#include "createTime.H"
#include "createDynamicFvMesh.H"
#include "createFields.H"
#include "createFieldRefs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,13 +36,13 @@ Description
#include "fvCFD.H"
#include "dynamicFvMesh.H"
#include "singlePhaseTransportModel.H"
#include "DPMIncompressibleTurbulenceModel.H"
#include "PhaseIncompressibleTurbulenceModel.H"
#include "pimpleControl.H"
#include "CorrectPhi.H"
#ifdef MPPIC
#include "basicKinematicCloud.H"
#define basicKinematicTypeCloud basicKinematicCloud
#include "basicKinematicMPPICCloud.H"
#define basicKinematicTypeCloud basicKinematicMPPICCloud
#else
#include "basicKinematicCollidingCloud.H"
#define basicKinematicTypeCloud basicKinematicCollidingCloud
@ -111,6 +110,7 @@ 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

View File

@ -1,7 +1,7 @@
EXE_INC = \
-I.. \
-I../.. \
-I../../DPMTurbulenceModels \
-I../DPMTurbulenceModels/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \

View File

@ -1,6 +1,6 @@
EXE_INC = \
-I.. \
-I../DPMTurbulenceModels \
-I../DPMTurbulenceModels/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,12 +38,12 @@ Description
#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "DPMIncompressibleTurbulenceModel.H"
#include "PhaseIncompressibleTurbulenceModel.H"
#include "pimpleControl.H"
#ifdef MPPIC
#include "basicKinematicCloud.H"
#define basicKinematicTypeCloud basicKinematicCloud
#include "basicKinematicMPPICCloud.H"
#define basicKinematicTypeCloud basicKinematicMPPICCloud
#else
#include "basicKinematicCollidingCloud.H"
#define basicKinematicTypeCloud basicKinematicCollidingCloud
@ -118,12 +117,6 @@ 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())
{

View File

@ -1,186 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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);
}
// ************************************************************************* //

View File

@ -1,144 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2013-2016 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,7 +25,7 @@ License
\*---------------------------------------------------------------------------*/
#include "DPMIncompressibleTurbulenceModel.H"
#include "PhaseIncompressibleTurbulenceModel.H"
#include "singlePhaseTransportModel.H"
#include "addToRunTimeSelectionTable.H"
#include "makeTurbulenceModel.H"
@ -41,7 +41,7 @@ defineTurbulenceModelTypes
volScalarField,
geometricOneField,
incompressibleTurbulenceModel,
DPMIncompressibleTurbulenceModel,
PhaseIncompressibleTurbulenceModel,
singlePhaseTransportModel
);
@ -50,21 +50,21 @@ makeBaseTurbulenceModel
volScalarField,
geometricOneField,
incompressibleTurbulenceModel,
DPMIncompressibleTurbulenceModel,
PhaseIncompressibleTurbulenceModel,
singlePhaseTransportModel
);
#define makeLaminarModel(Type) \
makeTemplatedTurbulenceModel \
(singlePhaseTransportModelDPMIncompressibleTurbulenceModel, laminar, Type)
(singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, laminar, Type)
#define makeRASModel(Type) \
makeTemplatedTurbulenceModel \
(singlePhaseTransportModelDPMIncompressibleTurbulenceModel, RAS, Type)
(singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, RAS, Type)
#define makeLESModel(Type) \
makeTemplatedTurbulenceModel \
(singlePhaseTransportModelDPMIncompressibleTurbulenceModel, LES, Type)
(singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, LES, Type)
#include "Stokes.H"
makeLaminarModel(Stokes);

View File

@ -1,6 +1,6 @@
EXE_INC = \
-I.. \
-I../DPMTurbulenceModels \
-I../DPMTurbulenceModels/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \

View File

@ -1,5 +1,5 @@
EXE_INC = \
-I./DPMTurbulenceModels \
-I./DPMTurbulenceModels/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
@ -13,6 +13,7 @@ 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

View File

@ -160,11 +160,10 @@ surfaceScalarField alphaPhic
alphacf*phic
);
autoPtr<DPMIncompressibleTurbulenceModel<singlePhaseTransportModel>>
autoPtr<PhaseIncompressibleTurbulenceModel<singlePhaseTransportModel>>
continuousPhaseTurbulence
(
DPMIncompressibleTurbulenceModel<singlePhaseTransportModel>::New
PhaseIncompressibleTurbulenceModel<singlePhaseTransportModel>::New
(
alphac,
Uc,

View File

@ -2,8 +2,6 @@ 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 \
@ -29,8 +27,6 @@ EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-ldynamicMesh \
-ldynamicFvMesh \
-lsampling \
-lturbulenceModels \
-lcompressibleTurbulenceModels \

View File

@ -81,15 +81,7 @@ 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);
}
}

View File

@ -3,8 +3,6 @@ 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 \
@ -30,8 +28,6 @@ EXE_LIBS = \
-lfvOptions \
-lsampling \
-lmeshTools \
-ldynamicMesh \
-ldynamicFvMesh \
-lturbulenceModels \
-lcompressibleTurbulenceModels \
-lspecie \

View File

@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2020 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2019 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,7 +47,6 @@ Description
#include "fvOptions.H"
#include "pimpleControl.H"
#include "pressureControl.H"
#include "CorrectPhi.H"
#include "localEulerDdtScheme.H"
#include "fvcSmooth.H"
#include "cloudMacros.H"
@ -77,13 +76,13 @@ int main(int argc, char *argv[])
#include "addCheckCaseOptions.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createDynamicFvMesh.H"
#include "createDyMControls.H"
#include "createMesh.H"
#include "createControl.H"
#include "createTimeControls.H"
#include "createFields.H"
#include "createFieldRefs.H"
#include "createRegionControls.H"
#include "initContinuityErrs.H"
#include "createRhoUfIfPresent.H"
turbulence->validate();
@ -99,23 +98,7 @@ int main(int argc, char *argv[])
while (runTime.run())
{
#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))
)
);
}
#include "readTimeControls.H"
if (LTS)
{
@ -131,44 +114,6 @@ 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();

View File

@ -103,7 +103,7 @@ License
);
}
// Update the boundary values of the reciprocal time-step
// Update tho boundary values of the reciprocal time-step
rDeltaT.correctBoundaryConditions();
// Spatially smooth the time scale field

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -52,7 +52,7 @@ Description
#include "CorrectPhi.H"
#include "fvcSmooth.H"
#include "basicKinematicCloud.H"
#include "basicKinematicMPPICCloud.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -147,7 +147,7 @@ volScalarField alphacRho(alphac*rho);
alphacRho.oldTime();
Info<< "Constructing kinematicCloud " << endl;
basicKinematicCloud kinematicCloud
basicKinematicMPPICCloud kinematicCloud
(
"kinematicCloud",
rho,

View File

@ -1,7 +1,5 @@
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 \
@ -12,7 +10,6 @@ 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 = \
@ -26,6 +23,4 @@ EXE_LIBS = \
-limmiscibleIncompressibleTwoPhaseMixture \
-lturbulenceModels \
-lincompressibleTurbulenceModels \
-lwaveModels \
-lVoFphaseTurbulentTransportModels \
-lincompressibleInterPhaseTransportModels
-lwaveModels

View File

@ -70,19 +70,14 @@ surfaceScalarField rhoPhi
fvc::interpolate(rho)*phi
);
typedef incompressibleInterPhaseTransportModel
<
immiscibleIncompressibleTwoPhaseMixture
> transportModelType;
autoPtr<transportModelType> turbulence
// Construct incompressible turbulence model
autoPtr<incompressible::turbulenceModel> turbulence
(
new transportModelType
(
rho, U, phi, rhoPhi, mixture
)
incompressible::turbulenceModel::New(U, phi, mixture)
);
#include "readGravitationalAcceleration.H"
#include "readhRef.H"
#include "gh.H"

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -46,7 +45,6 @@ Description
#include "CrankNicolsonDdtScheme.H"
#include "subCycle.H"
#include "immiscibleIncompressibleTwoPhaseMixture.H"
#include "incompressibleInterPhaseTransportModel.H"
#include "turbulentTransportModel.H"
#include "pimpleControl.H"
#include "fvOptions.H"
@ -78,6 +76,8 @@ int main(int argc, char *argv[])
#include "initCorrectPhi.H"
#include "createUfIfPresent.H"
turbulence->validate();
if (!LTS)
{
#include "CourantNo.H"

View File

@ -1,7 +1,5 @@
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 \
@ -16,7 +14,6 @@ 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 = \
@ -32,6 +29,4 @@ EXE_LIBS = \
-lturbulenceModels \
-lincompressibleTurbulenceModels \
-lwaveModels \
-lgeometricVoF \
-lVoFphaseTurbulentTransportModels \
-lincompressibleInterPhaseTransportModels
-lgeometricVoF

View File

@ -71,17 +71,10 @@ surfaceScalarField rhoPhi
);
typedef incompressibleInterPhaseTransportModel
<
immiscibleIncompressibleTwoPhaseMixture
> transportModelType;
autoPtr<transportModelType> turbulence
// Construct incompressible turbulence model
autoPtr<incompressible::turbulenceModel> turbulence
(
new transportModelType
(
rho, U, phi, rhoPhi, mixture
)
incompressible::turbulenceModel::New(U, phi, mixture)
);

View File

@ -10,7 +10,6 @@
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.
@ -60,7 +59,7 @@ Description
#include "CrankNicolsonDdtScheme.H"
#include "subCycle.H"
#include "immiscibleIncompressibleTwoPhaseMixture.H"
#include "incompressibleInterPhaseTransportModel.H"
#include "turbulentTransportModel.H"
#include "pimpleControl.H"
#include "fvOptions.H"
#include "CorrectPhi.H"
@ -92,6 +91,8 @@ int main(int argc, char *argv[])
#include "initCorrectPhi.H"
#include "createUfIfPresent.H"
turbulence->validate();
#include "CourantNo.H"
#include "setInitialDeltaT.H"

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -164,23 +164,6 @@ 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)

View File

@ -36,7 +36,6 @@ Description
#include "bitSet.H"
#include "BitOps.H"
#include "FlatOutput.H"
#include "bitSetOrBoolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -154,24 +153,6 @@ 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;
}

View File

@ -1,102 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View File

@ -1,73 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View File

@ -37,7 +37,6 @@ Description
#include "OSspecific.H"
#include "fvCFD.H"
#include "cpuTime.H"
#include "volFields.H"
#include "IOobjectList.H"
#include "regionProperties.H"
#include "decompositionInformation.H"
@ -90,16 +89,7 @@ int main(int argc, char *argv[])
// These are implicit so just ignore them
argList::ignoreOptionCompat({"dry-run", 0}, false);
argList::addBoolOption
(
"cellDist",
"Write cell distribution as volScalarField for visualization"
);
argList::addBoolOption
(
"cellDist-internal",
"Write cell distribution (internal field) for visualization"
);
argList::ignoreOptionCompat({"cellDist", 0}, false);
// Include explicit constant options, have zero from time range
timeSelector::addOptions(true, false);
@ -246,68 +236,6 @@ 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;

View File

@ -1,3 +0,0 @@
Test-fileOperation1.C
EXE = $(FOAM_USER_APPBIN)/Test-fileOperation1

View File

@ -1,2 +0,0 @@
/* EXE_INC = */
/* EXE_LIBS = */

View File

@ -1,125 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //

View File

@ -1,8 +1,6 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------
chtMultiRegionSimpleFoam -case fluid -world fluid 2>&1 | tee run_fluid.log
#!/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
read dummy
#------------------------------------------------------------------------------

View File

@ -1,8 +1,6 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------
chtMultiRegionSimpleFoam -case solid -world solid 2>&1 | tee run_solid.log
#!/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
read dummy
#------------------------------------------------------------------------------

View File

@ -57,6 +57,7 @@ Usage
#include "Time.H"
#include "IOdictionary.H"
#include "OSspecific.H"
#include "OFstream.H"
using namespace Foam;
@ -96,22 +97,6 @@ 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
(
@ -126,9 +111,6 @@ 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;
@ -167,38 +149,8 @@ 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)
@ -218,19 +170,14 @@ 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 =
(
args.found("no-outer")
? blkMesh.innerMesh(IOobject(regionName, meshInstance, runTime))
: blkMesh.mesh(IOobject(regionName, meshInstance, runTime))
);
blkMesh.mesh
(
IOobject(regionName, meshInstance, runTime)
);
polyMesh& mesh = *meshPtr;
const polyMesh& mesh = *meshPtr;
// Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));

View File

@ -704,7 +704,7 @@ int main(int argc, char *argv[])
regionName,
runTimeExtruded.constant(),
runTimeExtruded,
IOobject::NO_READ, // Do not read primitives, do read fv*
IOobject::NO_READ,
IOobject::AUTO_WRITE,
false
),

View File

@ -16,7 +16,6 @@ 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 = \
@ -26,5 +25,4 @@ EXE_LIBS = \
-ldecompose \
-lmeshTools \
-ldynamicMesh \
-lsampling \
-lfiniteVolume

View File

@ -311,7 +311,7 @@ tmp<scalarField> signedDistance
)
{
tmp<scalarField> tfld(new scalarField(points.size(), Foam::sqr(GREAT)));
scalarField& fld = tfld.ref();
scalarField& fld = tfld();
// Find nearest
List<pointIndexHit> nearest;
@ -713,7 +713,8 @@ int main(int argc, char *argv[])
fvm,
cellDistance,
pointDistance,
scalar(0) // distance
0, //distance,
false //regularise
);
isoFaces.setSize(iso.size());

View File

@ -154,7 +154,6 @@ int main(int argc, char *argv[])
"cellShapes",
"cellVolume",
"cellVolumeRatio",
"cellAspectRatio",
"minTetVolume",
"minPyrVolume",
"cellRegion",

View File

@ -133,9 +133,12 @@ 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;
@ -150,15 +153,15 @@ void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
for (label celli = 0; celli < mesh.nCells(); celli++)
{
if (hexMatcher::test(mesh, celli))
if (hex.isA(mesh, celli))
{
nHex++;
}
else if (tetMatcher::test(mesh, celli))
else if (tet.isA(mesh, celli))
{
nTet++;
}
else if (pyrMatcher::test(mesh, celli))
else if (pyr.isA(mesh, celli))
{
nPyr++;
}

View File

@ -7,7 +7,6 @@
#include "tetPointRef.H"
#include "regionSplit.H"
#include "wallDist.H"
#include "cellAspectRatio.H"
using namespace Foam;
@ -319,32 +318,6 @@ 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
// ~~~~~~~~~

View File

@ -680,7 +680,7 @@ autoPtr<mapPolyMesh> createRegionMesh
regionName,
mesh.time().timeName(),
mesh.time(),
IOobject::READ_IF_PRESENT, // read fv* if present
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh

View File

@ -66,14 +66,19 @@ using namespace Foam;
// Many ways to name processor directories
//
// Uncollated | "processor0", "processor1" ...
// Collated | "processors<N>"
// Collated (old) | "processors"
// Collated (new) | "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") && matcher.match(dir));
return
(
dir.starts_with("processor")
&& (dir == "processors" || matcher.match(dir))
);
}

View File

@ -71,14 +71,19 @@ using namespace Foam;
// Many ways to name processor directories
//
// Uncollated | "processor0", "processor1" ...
// Collated | "processors<N>"
// Collated (old) | "processors"
// Collated (new) | "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") && matcher.match(dir));
return
(
dir.starts_with("processor")
&& (dir == "processors" || matcher.match(dir))
);
}
@ -379,7 +384,13 @@ int main(int argc, char *argv[])
{
if (leadProcIdx < 0)
{
// Collated
// Collated (old)
leadProcIdx = procDirs.find("processors");
}
if (leadProcIdx < 0)
{
// Collated (new)
leadProcIdx = procDirs.find("processors" + Foam::name(nProcs));
}

View File

@ -519,26 +519,29 @@ int main(int argc, char *argv[])
{
const fileName& d = dirs[diri];
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)
)
)
// Starts with 'processors'
if (d.find("processors") == 0)
{
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;

View File

@ -36,7 +36,6 @@ License
#include "pointSet.H"
#include "faceSet.H"
#include "cellSet.H"
#include "basicFvGeometryScheme.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
@ -255,19 +254,6 @@ 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

View File

@ -92,7 +92,6 @@ Usage
#include "zeroGradientFvPatchFields.H"
#include "topoSet.H"
#include "regionProperties.H"
#include "basicFvGeometryScheme.H"
#include "parFvFieldReconstructor.H"
#include "parLagrangianRedistributor.H"
@ -153,30 +152,6 @@ 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
@ -2339,19 +2314,6 @@ 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");
@ -2362,16 +2324,15 @@ int main(int argc, char *argv[])
bool decompose = args.found("decompose");
bool overwrite = args.found("overwrite");
// 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);
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;
}
const wordRes selectedFields;
const wordRes selectedLagrangianFields;
@ -2608,14 +2569,12 @@ 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);
@ -2701,10 +2660,6 @@ 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
(
@ -2754,10 +2709,6 @@ 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
(
@ -2770,8 +2721,6 @@ int main(int argc, char *argv[])
),
true // read on master only
);
setBasicGeometry(baseMeshPtr());
Info<< "Reading local, decomposed mesh" << endl;
autoPtr<fvMesh> meshPtr = loadOrCreateMesh
@ -2992,14 +2941,12 @@ 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)
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -86,7 +86,15 @@ 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);

View File

@ -1,8 +1,7 @@
EXE_INC = \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/randomProcesses/lnInclude \
-I$(FFTW_INC_DIR)
-I$(LIB_SRC)/randomProcesses/lnInclude
EXE_LIBS = \
-lsampling \

View File

@ -87,6 +87,7 @@ Usage
See also
noiseFFT.H
noiseModel.H
windowModel.H

View File

@ -1,7 +0,0 @@
PDRfitMeshParams.C
PDRfitMeshScan.C
PDRfitMeshScans.C
PDRfitMesh.C
EXE = $(FOAM_APPBIN)/PDRfitMesh

View File

@ -1,339 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //

View File

@ -1,126 +0,0 @@
/*--------------------------------*- 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;
// ************************************************************************* //

View File

@ -1,123 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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);
};
// ************************************************************************* //

View File

@ -1,158 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View File

@ -1,859 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //

View File

@ -1,224 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View File

@ -1,464 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //

View File

@ -1,154 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View File

@ -1,15 +0,0 @@
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

View File

@ -1,171 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::optionalData
Description
A simplified version of std::optional (c++17), with much simpler
construction semantics.
\*---------------------------------------------------------------------------*/
#ifndef optionalData_H
#define optionalData_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class optionalData Declaration
\*---------------------------------------------------------------------------*/
template<class T>
class optionalData
{
// Private Data
//- Validity of the value
bool good_;
//- The value
T value_;
public:
// Generated Methods
//- Copy construct
optionalData(const optionalData<T>&) = default;
//- Move construct
optionalData(optionalData<T>&&) = default;
//- Copy assignment
optionalData<T>& operator=(const optionalData<T>&) = default;
//- Move assignment
optionalData<T>& operator=(optionalData<T>&&) = default;
// Constructors
//- Default construct
optionalData()
:
good_(false),
value_()
{}
//- Copy construct from value
optionalData(const T& val)
:
good_(true),
value_(val)
{}
//- Move construct from value
optionalData(T&& val)
:
good_(true),
value_(std::move(val))
{}
// Member Functions
//- True if it has a value
bool has_value() const noexcept
{
return good_;
}
//- Access to the value
T& value() noexcept
{
return value_;
}
//- Access to the value
const T& value() const noexcept
{
return value_;
}
//- Return value or default
const T& value_or(const T& deflt) const
{
return good_ ? value_ : deflt;
}
// Member Operators
//- True if it has a value
explicit operator bool() const noexcept
{
return good_;
}
//- Access the value
const T& operator*() const noexcept
{
return value_;
}
//- Access the value
T& operator*() noexcept
{
return value_;
}
//- Copy assignment from value
void operator=(const T& val)
{
good_ = true;
value_ = val;
}
//- Move assignment from value
void operator=(T&& val)
{
good_ = true;
value_ = std::move(val);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,11 +1,7 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------
wclean libso pdrFields
wclean PDRfitMesh
wclean PDRsetFields
#------------------------------------------------------------------------------

View File

@ -5,9 +5,6 @@ cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------
wmake $targetType pdrFields
wmake $targetType PDRfitMesh
wmake $targetType PDRsetFields
#------------------------------------------------------------------------------

View File

@ -83,8 +83,6 @@ 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"
@ -92,6 +90,8 @@ int main(int argc, char* argv[])
IOdictionary setFieldsDict(dictIO);
const bool dryrun = args.found("dry-run");
const fileName& casepath = runTime.globalPath();
pars.timeName = "0";

View File

@ -1149,9 +1149,9 @@ static void tail_field
const UList<PDRpatchDef>& patches
)
{
// ground
// seaGround
{
os.beginBlock(pars.groundPatchName);
os.beginBlock("seaGround");
os.writeKeyword("type") << wall_bc << token::END_STATEMENT << nl;
putUniform(os, "value", deflt);
os.endBlock();
@ -1222,14 +1222,13 @@ 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");
@ -1286,10 +1285,9 @@ void write_scalarField
os << nl;
os.beginBlock("boundaryField");
// outer
{
os.beginBlock(pars.outerPatchName);
os.beginBlock("outer");
os.writeEntry("type", "inletOutlet");
putUniform(os, "inletValue", deflt);
@ -1331,8 +1329,7 @@ void write_uniformField
// outer
{
os.beginBlock(pars.outerPatchName);
os.beginBlock("outer");
if (fieldName == "alphat" || fieldName == "nut")
{
// Different b.c. for alphat & nut
@ -1380,17 +1377,17 @@ void write_pU_fields
os << nl;
os.beginBlock("boundaryField");
// outer
// "outer"
{
os.beginBlock(pars.outerPatchName);
os.beginBlock("outer");
os.writeEntry("type", "inletOutlet");
putUniform(os, "inletValue", vector::zero);
os.endBlock();
}
// ground
// seaGround
{
os.beginBlock(pars.groundPatchName);
os.beginBlock("seaGround");
os.writeEntry("type", "zeroGradient");
os.endBlock();
}
@ -1500,10 +1497,9 @@ void write_pU_fields
os << nl;
os.beginBlock("boundaryField");
// outer
// "outer"
{
os.beginBlock(pars.outerPatchName);
os.beginBlock("outer");
os.writeEntry("type", "waveTransmissive");
os.writeEntry("gamma", 1.3);
os.writeEntry("fieldInf", deflt);
@ -1564,7 +1560,7 @@ void write_symmTensorField
// outer
{
os.beginBlock(pars.outerPatchName);
os.beginBlock("outer");
os.writeEntry("type", "inletOutlet");
putUniform(os, "inletValue", deflt);
@ -1632,7 +1628,7 @@ void write_symmTensorFieldV
// outer
{
os.beginBlock(pars.outerPatchName);
os.beginBlock("outer");
os.writeEntry("type", "inletOutlet");
putUniform(os, "inletValue", deflt);

View File

@ -94,7 +94,7 @@ void Foam::PDRmeshArrays::classify
<< " nPoints:" << pdrBlock.nPoints()
<< " nCells:" << pdrBlock.nCells()
<< " nFaces:" << pdrBlock.nFaces() << nl
<< " min-edge:" << pdrBlock.edgeLimits().min() << nl;
<< " min-edge:" << pdrBlock.minEdgeLen() << nl;
Info<< "Classifying ijk indexing... " << nl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -84,20 +84,6 @@ 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))
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 Shell Research Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -62,13 +62,6 @@ 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};
@ -143,7 +136,7 @@ public:
// Constructors
//- Default construct
//- Construct null
PDRparams() = default;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,6 +29,9 @@ Namespace
Description
Utilities for PDR (eg, for setFields)
SourceFiles
PDRUtils.C
\*---------------------------------------------------------------------------*/
#ifndef PDRutils_H
@ -45,17 +48,11 @@ namespace Foam
// Forward Declarations
class PDRobstacle;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace PDRutils
{
} // End namespace PDRutils
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Some files were not shown because too many files have changed in this diff Show More