Compare commits

..

2 Commits

Author SHA1 Message Date
29e4d6b961 wip 2020-06-04 22:31:53 +02:00
2970275410 ENH: constexpr for scalar constants in SolverPerformance
STYLE: simplify coding in SolverPerformance
2020-06-04 11:34:55 +02:00
8715 changed files with 27281 additions and 146364 deletions

View File

@ -3,7 +3,7 @@
Before opening a new issue, make sure to search for keywords in the issues
filtered by the "bug" label and check to see if it has already been reported
You can see how your report will be rendered on the platform by using the
"preview" tab above
-->

3
.gitmodules vendored
View File

@ -14,6 +14,3 @@
[submodule "visualization"]
path = modules/visualization
url = https://develop.openfoam.com/modules/visualization.git
[submodule "external-solver"]
path = modules/external-solver
url = https://develop.openfoam.com/Modules/external-solver.git

View File

@ -73,13 +73,16 @@ echo
applications/Allwmake $targetType $*
# Additional components/modules
if [ "$FOAM_MODULE_PREFIX" = false ] || [ "$FOAM_MODULE_PREFIX" = none ]
if [ -d "$WM_PROJECT_DIR/modules" ]
then
echo "========================================"
echo "OpenFOAM modules disabled (prefix=${FOAM_MODULE_PREFIX})"
echo "Compile OpenFOAM modules"
echo " ignoring possible compilation errors"
echo " make certain to check the output file"
echo
elif [ -d "$WM_PROJECT_DIR/modules" ]
then
set +e
export WM_CONTINUE_ON_ERROR=true
(cd "$WM_PROJECT_DIR/modules" 2>/dev/null && wmake -all)
fi

View File

@ -1,50 +0,0 @@
# Contributors to OpenFOAM
The following is an list of known contributors to OpenFOAM.
It is likely incomplete...
## Contributors (alphabetical by surname)
- William Bainbridge
- Gabriel Barajas
- Kutalmis Bercin
- Greg Collecutt
- Jonathan Cranford
- Sergio Ferraris
- Matej Forman
- Marian Fuchs
- Pawan Ghildiyal
- Chris Greenshields
- Bernhard Gschaider
- Andrew Heather
- David Hill
- Mattijs Janssens
- Andrew Jackson
- Hrvoje Jasak
- Alexander Kabat vel Job
- Thilo Knacke
- Tommaso Lucchini
- Graham Macpherson
- Alexey Matveichev
- Karl Meredith
- Laurence McGlashan
- Timo Niemi
- Haakan Nilsson
- Niklas Nordin
- Mark Olesen
- Vaggelis Papoutsis
- Juho Peltola
- Johan Roenby
- Henrik Rusche
- Bruno Santos
- Henning Scheufler
- Prashant Sonakar
- Hilary Spencer
- Gavin Tabor
- Zeljko Tukovic
- Eugene De Villiers
- Yi Wang
- Norbert Weber
- Henry Weller
- Niklas Wikstrom

View File

@ -1,4 +1,4 @@
## META-INFO
# META-INFO
Meta-information is generally for OpenFOAM internal use only.
@ -12,7 +12,7 @@ will need to be updated accordingly:
- etc/openfoam
- wmake/scripts/wmake-build-info
### api-info
## api-info
This file and its contents are to be tracked by git.
@ -21,7 +21,7 @@ This file and its contents are to be tracked by git.
- File content (patch) is manually generated content.
### build-info
## build-info
This file is ***never*** to be tracked by git, but may be present in
shipped source archives.
@ -30,9 +30,9 @@ shipped source archives.
git information and cached from previous wmake (api)
### Content types
## Content types
#### api
### api
Format: `date +%y%m`
@ -41,7 +41,7 @@ Format: `date +%y%m`
Example, `1712` for the Dec-2017 release.
#### patch
### patch
Format: `date +%y%m%d`
@ -57,7 +57,7 @@ ascribed too much meaning, but will often correspond to the last
merge with a *maintenance* (*eg*, `master`) branch.
### Flow of information
## Flow of information
Changes in the build information must be reflected in information
available in the final binaries. Conversely, it is necessary for later
@ -76,11 +76,11 @@ the saved information needs synchronization. The command
`wmake -build-info -update` performs the synchronization.
### Notes
## Notes
The saved information is split into two separate files. The `api-info`
contains more permanent information, whereas the `build-info` is more
transient in nature.
----
2020-06-23
2020-05-05

View File

@ -1,2 +1,2 @@
api=2006
patch=220610
api=2004
patch=200506

View File

@ -1,4 +1,4 @@
## About OpenFOAM
# About OpenFOAM
OpenFOAM is a free, open source CFD software [released and developed by OpenCFD Ltd since 2004](http://www.openfoam.com/history/).
It has a large user base across most areas of engineering and science, from both commercial and academic organisations.
OpenFOAM has an extensive range of features to solve anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to acoustics, solid mechanics and electromagnetics.
@ -11,7 +11,7 @@ individual and group contributors, integrations
[governance guided activities](https://www.openfoam.com/governance/).
## Copyright
# Copyright
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
@ -22,7 +22,7 @@ description of the GNU General Public License terms under which you
may redistribute files.
## OpenFOAM Trademark
# OpenFOAM Trademark
OpenCFD Ltd grants use of its OpenFOAM trademark by Third Parties on a
licence basis. ESI Group and OpenFOAM Foundation Ltd are currently
@ -35,7 +35,7 @@ any questions on the use of the OpenFOAM trademark.
Violations of the Trademark are monitored, and will be duly prosecuted.
## Using OpenFOAM
# Using OpenFOAM
If OpenFOAM has already been compiled on your system, simply source
the appropriate `etc/bashrc` or `etc/cshrc` file and get started.
@ -44,7 +44,7 @@ For example, for the OpenFOAM-v1912 version:
source /installation/path/OpenFOAM-v1912/etc/bashrc
```
## Compiling OpenFOAM
# Compiling OpenFOAM
If you are compiling OpenFOAM from source, please see the relevant
guides:
@ -55,7 +55,7 @@ guides:
| [ThirdParty][repo third] | [readme][link third-readme] | [system requirements][link third-require] | [build][link third-build] |
## How do I know which version I am currently using?
# How do I know which version I am currently using?
The value of the `$WM_PROJECT_DIR` or even `$WM_PROJECT_VERSION` are
not guaranteed to have any correspondence to the OpenFOAM release
@ -110,7 +110,7 @@ patching changes made within the currently active environment and
should be used with caution.
## ThirdParty directory
# ThirdParty directory
OpenFOAM normally ships with a directory of 3rd-party software and
build scripts for some 3rd-party software that is either necessary or
@ -197,7 +197,7 @@ ThirdParty directory will contain either an `Allwmake` file or a
[link third-require]: https://develop.openfoam.com/Development/ThirdParty-common/blob/develop/Requirements.md
## Useful Links
# Useful Links
- Download [source](https://sourceforge.net/projects/openfoam/files/) and [download and installation instructions](http://www.openfoam.com/download/)
- [Documentation](http://www.openfoam.com/documentation)

View File

@ -19,3 +19,4 @@
Kmesh K(mesh);
UOprocess forceGen(K, runTime.deltaTValue(), turbulenceProperties);

View File

@ -47,3 +47,4 @@
rho.writeMinMax(Info);
}

View File

@ -1,6 +1 @@
const volScalarField& psi = thermo.psi();
bool adjustFringe
(
simple.dict().getOrDefault("oversetAdjustPhi", false)
);

View File

@ -80,3 +80,7 @@ dimensionedScalar initialMass = fvc::domainIntegrate(rho);
#include "createInterpolatedCells.H"
bool adjustFringe
(
simple.dict().getOrDefault("oversetAdjustPhi", false)
);

View File

@ -63,3 +63,4 @@ edgeScalarField phis
),
linearEdgeInterpolate(Us) & aMesh.Le()
);

View File

@ -57,3 +57,4 @@ edgeScalarField phis
),
linearEdgeInterpolate(Us) & aMesh.Le()
);

View File

@ -1,3 +1,4 @@
dimensionedScalar compressibility = fvc::domainIntegrate(psi);
bool compressible = (compressibility.value() > SMALL);

View File

@ -1,3 +1,4 @@
dimensionedScalar compressibility = fvc::domainIntegrate(psi);
bool compressible = (compressibility.value() > SMALL);

View File

@ -1,3 +1,4 @@
chtMultiRegionSimpleFoam.C
EXE = $(FOAM_APPBIN)/chtMultiRegionSimpleFoam

View File

@ -38,3 +38,4 @@ EXE_LIBS = \
-lsampling \
-lreactingTwoPhaseSystem \
-lreactingPhaseSystem

View File

@ -1,8 +1,7 @@
PtrList<uniformDimensionedScalarField> cumulativeContErrIO(fluidRegions.size());
forAll(cumulativeContErrIO, i)
{
const fvMesh& mesh = fluidRegions[i];
#include "setRegionFluidFields.H"
cumulativeContErrIO.set
(
i,

View File

@ -1,8 +1,7 @@
PtrList<uniformDimensionedScalarField> cumulativeContErrIO(fluidRegions.size());
forAll(cumulativeContErrIO, i)
{
const fvMesh& mesh = fluidRegions[i];
#include "setRegionFluidFields.H"
cumulativeContErrIO.set
(
i,

View File

@ -65,3 +65,4 @@
const dimensionedScalar rhoMin = rhoMinFluid[i];
const pressureControl& pressureControl = pressureControls[i];

View File

@ -77,3 +77,4 @@ surfaceScalarField phiHbyA
),
fvc::flux(U)
);

View File

@ -1,15 +1,11 @@
volScalarField rAU(1.0/UEqn.A());
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA));
if (pimple.ddtCorr())
{
phiHbyA += MRF.zeroFilter(fvc::interpolate(rAU)*fvc::ddtCorr(U, phi, Uf));
}
else
{
phiHbyA += MRF.zeroFilter(fvc::interpolate(rAU));
}
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
+ MRF.zeroFilter(fvc::interpolate(rAU)*fvc::ddtCorr(U, phi, Uf))
);
MRF.makeRelative(phiHbyA);

View File

@ -43,3 +43,4 @@ autoPtr<incompressible::turbulenceModel> turbulence
);
#include "createMRF.H"

View File

@ -1 +1,2 @@
IOporosityModelList pZones(mesh);

View File

@ -1,4 +1 @@
const volScalarField& T = thermo.T();
const volScalarField& psi = thermo.psi();
const label inertIndex(composition.species()[inertSpecie]);

View File

@ -22,6 +22,8 @@ if (!composition.species().found(inertSpecie))
}
volScalarField& p = thermo.p();
const volScalarField& T = thermo.T();
const volScalarField& psi = thermo.psi();
multivariateSurfaceInterpolationScheme<scalar>::fieldTable fields;

View File

@ -25,3 +25,4 @@ fvMesh filmMesh
IOobject::MUST_READ
)
);

View File

@ -2,3 +2,4 @@ bool solvePrimaryRegion
(
pimple.dict().getOrDefault("solvePrimaryRegion", true)
);

View File

@ -40,3 +40,4 @@ else
rho == alpha1*rho1 + alpha2*rho2;
mu = mixture.mu();

View File

@ -8,6 +8,5 @@ wclean libso VoFphaseCompressibleTurbulenceModels
wclean
wclean compressibleInterDyMFoam
wclean compressibleInterFilmFoam
wclean compressibleInterIsoFoam
#------------------------------------------------------------------------------

View File

@ -11,6 +11,5 @@ wmake $targetType VoFphaseCompressibleTurbulenceModels
wmake $targetType
wmake $targetType compressibleInterDyMFoam
wmake $targetType compressibleInterFilmFoam
wmake $targetType compressibleInterIsoFoam
#------------------------------------------------------------------------------

View File

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

View File

@ -1,39 +0,0 @@
EXE_INC = \
-I.. \
-I../../VoF \
-I../twoPhaseMixtureThermo \
-I../VoFphaseCompressibleTurbulenceModels \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/fvOptions/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude \
-I$(LIB_SRC)/transportModels/geometricVoF/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lsurfMesh \
-lmeshTools \
-ldynamicMesh \
-ldynamicFvMesh \
-ltwoPhaseMixtureThermo \
-ltwoPhaseSurfaceTension \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lspecie \
-ltwoPhaseMixture \
-ltwoPhaseProperties \
-linterfaceProperties \
-lturbulenceModels \
-lcompressibleTurbulenceModels \
-lVoFphaseCompressibleTurbulenceModels \
-lgeometricVoF

View File

@ -1,3 +0,0 @@
const dictionary& alphaControls = mesh.solverDict(alpha1.name());
label nAlphaSubCycles(alphaControls.get<label>("nAlphaSubCycles"));

View File

@ -1,15 +0,0 @@
// Update alpha1
#include "alphaSuSp.H"
advector.advect(Sp,(Su + divU*min(alpha1(), scalar(1)))());
// Update rhoPhi
rhoPhi = advector.getRhoPhi(rho1, rho2);
alphaPhi10 = advector.alphaPhi();
alpha2 = 1.0 - alpha1;
Info<< "Phase-1 volume fraction = "
<< alpha1.weightedAverage(mesh.Vsc()).value()
<< " Min(" << alpha1.name() << ") = " << min(alpha1).value()
<< " Max(" << alpha1.name() << ") - 1 = " << max(alpha1).value() - 1
<< endl;

View File

@ -1,43 +0,0 @@
volScalarField::Internal Sp
(
IOobject
(
"Sp",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(dgdt.dimensions(), Zero)
);
volScalarField::Internal Su
(
IOobject
(
"Su",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(dgdt.dimensions(), Zero)
);
forAll(dgdt, celli)
{
if (dgdt[celli] > 0.0)
{
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
}
else if (dgdt[celli] < 0.0)
{
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
}
}
volScalarField::Internal divU
(
mesh.moving()
? fvc::div(phi + mesh.phi())
: fvc::div(phi)
);

View File

@ -1,70 +0,0 @@
if (pimple.nCorrPIMPLE() > 1)
{
if (!pimple.firstIter())
{
// Resetting alpha1 to value before advection in first PIMPLE
// iteration.
alpha1 = alpha1.oldTime();
}
}
tmp<surfaceScalarField> talphaPhi1(alphaPhi10);
if (nAlphaSubCycles > 1)
{
dimensionedScalar totalDeltaT = runTime.deltaT();
talphaPhi1 = new surfaceScalarField
(
IOobject
(
"alphaPhi1",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(alphaPhi10.dimensions(), Zero)
);
surfaceScalarField rhoPhiSum
(
IOobject
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero)
);
for
(
subCycle<volScalarField> alphaSubCycle(alpha1, nAlphaSubCycles);
!(++alphaSubCycle).end();
)
{
#include "alphaEqn.H"
talphaPhi1.ref() += (runTime.deltaT()/totalDeltaT)*alphaPhi10;
rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi;
}
rhoPhi = rhoPhiSum;
}
else
{
#include "alphaEqn.H"
}
rho == alpha1*rho1 + alpha2*rho2;
const surfaceScalarField& alphaPhi1 = talphaPhi1();
surfaceScalarField alphaPhi2("alphaPhi2", phi - alphaPhi1);
volScalarField::Internal contErr
(
(
fvc::ddt(rho) + fvc::div(rhoPhi)
- (fvOptions(alpha1, mixture.thermo1().rho())&rho1)
- (fvOptions(alpha2, mixture.thermo2().rho())&rho2)
)()
);

View File

@ -1,203 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020 Johan Roenby
Copyright (C) 2020 DLR
-------------------------------------------------------------------------------
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
compressibleInterFlow
Description
Solver derived from interFoam for two compressible, immiscible
fluids using the isoAdvector phase-fraction based interface capturing
approach, with optional mesh motion and mesh topology changes including
adaptive re-meshing.
Reference:
\verbatim
Roenby, J., Bredmose, H. and Jasak, H. (2016).
A computational method for sharp interface advection
Royal Society Open Science, 3
doi 10.1098/rsos.160405
\endverbatim
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "dynamicFvMesh.H"
#include "CMULES.H"
#include "EulerDdtScheme.H"
#include "localEulerDdtScheme.H"
#include "CrankNicolsonDdtScheme.H"
#include "subCycle.H"
#include "compressibleInterPhaseTransportModel.H"
#include "pimpleControl.H"
#include "fvOptions.H"
#include "CorrectPhi.H"
#include "fvcSmooth.H"
#include "dynamicRefineFvMesh.H"
#include "isoAdvection.H"
#include "twoPhaseMixtureThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Solver for two compressible, non-isothermal immiscible fluids"
" using VOF phase-fraction based interface capturing.\n"
"With optional mesh motion and mesh topology changes including"
" adaptive re-meshing."
);
#include "postProcess.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createDynamicFvMesh.H"
#include "initContinuityErrs.H"
#include "createDyMControls.H"
#include "createFields.H"
#include "createUf.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
volScalarField& p = mixture.p();
volScalarField& T = mixture.T();
const volScalarField& psi1 = mixture.thermo1().psi();
const volScalarField& psi2 = mixture.thermo2().psi();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
#include "readDyMControls.H"
// Store divU and divUp from the previous mesh so that it can be mapped
// and used in correctPhi to ensure the corrected phi has the
// same divergence
volScalarField divU("divU0", fvc::div(fvc::absolute(phi, U)));
#include "CourantNo.H"
#include "alphaCourantNo.H"
#include "setDeltaT.H"
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;
// --- Pressure-velocity PIMPLE corrector loop
while (pimple.loop())
{
if (pimple.firstIter() || moveMeshOuterCorrectors)
{
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
if (isA<dynamicRefineFvMesh>(mesh))
{
advector.surf().reconstruct();
}
mesh.update();
if (mesh.changing())
{
gh = (g & mesh.C()) - ghRef;
ghf = (g & mesh.Cf()) - ghRef;
if (isA<dynamicRefineFvMesh>(mesh))
{
advector.surf().mapAlphaField();
alpha2 = 1.0 - alpha1;
alpha2.correctBoundaryConditions();
rho == alpha1*rho1 + alpha2*rho2;
rho.correctBoundaryConditions();
rho.oldTime() = rho;
alpha2.oldTime() = alpha2;
}
MRF.update();
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
}
if ((mesh.changing() && correctPhi))
{
// Calculate absolute flux from the mapped surface velocity
phi = mesh.Sf() & Uf;
#include "correctPhi.H"
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
mixture.correct();
}
if (mesh.changing() && checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
}
#include "alphaControls.H"
#include "compressibleAlphaEqnSubCycle.H"
turbulence.correctPhasePhi();
#include "UEqn.H"
volScalarField divUp("divUp", fvc::div(fvc::absolute(phi, U), p));
#include "TEqn.H"
// --- Pressure corrector loop
while (pimple.correct())
{
#include "pEqn.H"
}
if (pimple.turbCorr())
{
turbulence.correct();
}
}
runTime.write();
runTime.printExecutionTime(Info);
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -1,13 +0,0 @@
CorrectPhi
(
U,
phi,
p,
dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1),
divU,
pimple
);
//***HGW phi.oldTime() = phi;
#include "continuityErrs.H"

View File

@ -1,110 +0,0 @@
#include "createRDeltaT.H"
Info<< "Reading field p_rgh\n" << endl;
volScalarField p_rgh
(
IOobject
(
"p_rgh",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
#include "createPhi.H"
Info<< "Constructing twoPhaseMixtureThermo\n" << endl;
twoPhaseMixtureThermo mixture(U, phi);
volScalarField& alpha1(mixture.alpha1());
volScalarField& alpha2(mixture.alpha2());
Info<< "Reading thermophysical properties\n" << endl;
const volScalarField& rho1 = mixture.thermo1().rho();
const volScalarField& rho2 = mixture.thermo2().rho();
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
alpha1*rho1 + alpha2*rho2
);
dimensionedScalar pMin
(
"pMin",
dimPressure,
mixture
);
mesh.setFluxRequired(p_rgh.name());
mesh.setFluxRequired(alpha1.name());
#include "readGravitationalAcceleration.H"
#include "readhRef.H"
#include "gh.H"
// Mass flux
// Initialisation does not matter because rhoPhi is reset after the
// alpha1 solution before it is used in the U equation.
surfaceScalarField rhoPhi
(
IOobject
(
"rhoPhi",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
fvc::interpolate(rho)*phi
);
volScalarField dgdt(alpha1*fvc::div(phi));
#include "createAlphaFluxes.H"
Foam::isoAdvection advector(alpha1,phi,U);
// Construct compressible turbulence model
compressibleInterPhaseTransportModel turbulence
(
rho,
U,
phi,
rhoPhi,
alphaPhi10,
mixture
);
#include "createK.H"
#include "createMRF.H"
#include "createFvOptions.H"

View File

@ -1,169 +0,0 @@
{
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh));
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
+ MRF.zeroFilter(fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, Uf))
);
MRF.makeRelative(phiHbyA);
surfaceScalarField phig
(
(
mixture.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf()
);
phiHbyA += phig;
// Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phiHbyA, U);
tmp<fvScalarMatrix> p_rghEqnComp1;
tmp<fvScalarMatrix> p_rghEqnComp2;
if (pimple.transonic())
{
#include "rhofs.H"
surfaceScalarField phid1("phid1", fvc::interpolate(psi1)*phi);
surfaceScalarField phid2("phid2", fvc::interpolate(psi2)*phi);
p_rghEqnComp1 =
(
(
fvc::ddt(alpha1, rho1) + fvc::div(alphaPhi1*rho1f)
- (fvOptions(alpha1, mixture.thermo1().rho())&rho1)
)/rho1
- fvc::ddt(alpha1) - fvc::div(alphaPhi1)
+ (alpha1/rho1)
*correction
(
psi1*fvm::ddt(p_rgh)
+ fvm::div(phid1, p_rgh) - fvm::Sp(fvc::div(phid1), p_rgh)
)
);
p_rghEqnComp1.ref().relax();
p_rghEqnComp2 =
(
(
fvc::ddt(alpha2, rho2) + fvc::div(alphaPhi2*rho2f)
- (fvOptions(alpha2, mixture.thermo2().rho())&rho2)
)/rho2
- fvc::ddt(alpha2) - fvc::div(alphaPhi2)
+ (alpha2/rho2)
*correction
(
psi2*fvm::ddt(p_rgh)
+ fvm::div(phid2, p_rgh) - fvm::Sp(fvc::div(phid2), p_rgh)
)
);
p_rghEqnComp2.ref().relax();
}
else
{
#include "rhofs.H"
p_rghEqnComp1 =
pos(alpha1)
*(
(
fvc::ddt(alpha1, rho1) + fvc::div(alphaPhi1*rho1f)
- (fvOptions(alpha1, mixture.thermo1().rho())&rho1)
)/rho1
- fvc::ddt(alpha1) - fvc::div(alphaPhi1)
+ (alpha1*psi1/rho1)*correction(fvm::ddt(p_rgh))
);
p_rghEqnComp2 =
pos(alpha2)
*(
(
fvc::ddt(alpha2, rho2) + fvc::div(alphaPhi2*rho2f)
- (fvOptions(alpha2, mixture.thermo2().rho())&rho2)
)/rho2
- fvc::ddt(alpha2) - fvc::div(alphaPhi2)
+ (alpha2*psi2/rho2)*correction(fvm::ddt(p_rgh))
);
}
if (mesh.moving())
{
p_rghEqnComp1.ref() += fvc::div(mesh.phi())*alpha1;
p_rghEqnComp2.ref() += fvc::div(mesh.phi())*alpha2;
}
p_rghEqnComp1.ref() *= pos(alpha1);
p_rghEqnComp2.ref() *= pos(alpha2);
if (pimple.transonic())
{
p_rghEqnComp1.ref().relax();
p_rghEqnComp2.ref().relax();
}
// Cache p_rgh prior to solve for density update
volScalarField p_rgh_0(p_rgh);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqnIncomp
(
fvc::div(phiHbyA)
- fvm::laplacian(rAUf, p_rgh)
);
solve
(
p_rghEqnComp1() + p_rghEqnComp2() + p_rghEqnIncomp,
mesh.solver(p_rgh.select(pimple.finalInnerIter()))
);
if (pimple.finalNonOrthogonalIter())
{
p = max(p_rgh + (alpha1*rho1 + alpha2*rho2)*gh, pMin);
p_rgh = p - (alpha1*rho1 + alpha2*rho2)*gh;
dgdt =
(
alpha1*(p_rghEqnComp2 & p_rgh)
- alpha2*(p_rghEqnComp1 & p_rgh)
);
phi = phiHbyA + p_rghEqnIncomp.flux();
U = HbyA
+ rAU*fvc::reconstruct((phig + p_rghEqnIncomp.flux())/rAUf);
U.correctBoundaryConditions();
fvOptions.correct(U);
}
}
// Correct Uf if the mesh is moving
{
Uf = fvc::interpolate(U);
surfaceVectorField n(mesh.Sf()/mesh.magSf());
Uf += n*(fvc::absolute(phi, U)/mesh.magSf() - (n & Uf));
}
// Update densities from change in p_rgh
mixture.thermo1().correctRho(psi1*(p_rgh - p_rgh_0));
mixture.thermo2().correctRho(psi2*(p_rgh - p_rgh_0));
rho = alpha1*rho1 + alpha2*rho2;
// Correct p_rgh for consistency with p and the updated densities
p_rgh = p - rho*gh;
p_rgh.correctBoundaryConditions();
K = 0.5*magSqr(U);
}

View File

@ -7,8 +7,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidSpecie/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/transportModels/geometricVoF/lnInclude
-I$(LIB_SRC)/transportModels/compressible/lnInclude
LIB_LIBS = \
-lfiniteVolume \
@ -16,5 +15,4 @@ LIB_LIBS = \
-lfluidThermophysicalModels \
-lreactionThermophysicalModels \
-lsolidThermo \
-lsolidSpecie \
-lgeometricVoF
-lsolidSpecie

View File

@ -28,7 +28,7 @@ License
#include "interfaceHeatResistance.H"
#include "constants.H"
#include "cutCellIso.H"
#include "isoCutCell.H"
#include "volPointInterpolation.H"
#include "wallPolyPatch.H"
#include "fvcSmooth.H"
@ -52,7 +52,7 @@ interfaceHeatResistance<Thermo, OtherThermo>
volPointInterpolation::New(mesh).interpolate(alpha)
);
cutCellIso cutCell(mesh, ap);
isoCutCell cutCell(mesh, ap);
forAll(interfaceArea_, celli)
{
@ -61,7 +61,7 @@ interfaceHeatResistance<Thermo, OtherThermo>
if (status == 0) // cell is cut
{
interfaceArea_[celli] =
mag(cutCell.faceArea())/mesh.V()[celli];
mag(cutCell.isoFaceArea())/mesh.V()[celli];
}
}
@ -147,7 +147,7 @@ Foam::meltingEvaporationModels::interfaceHeatResistance<Thermo, OtherThermo>
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
IOobject::NO_WRITE
),
this->mesh_,
dimensionedScalar(dimDensity/dimTime, Zero)
@ -160,7 +160,7 @@ Foam::meltingEvaporationModels::interfaceHeatResistance<Thermo, OtherThermo>
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
IOobject::AUTO_WRITE
),
this->mesh_,
dimensionedScalar(dimDensity/dimTime, Zero)
@ -173,7 +173,7 @@ Foam::meltingEvaporationModels::interfaceHeatResistance<Thermo, OtherThermo>
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
IOobject::AUTO_WRITE
),
this->mesh_,
dimensionedScalar(dimMass/dimArea/dimTemperature/dimTime, Zero)

View File

@ -27,7 +27,7 @@ License
#include "kineticGasEvaporation.H"
#include "constants.H"
#include "cutCellIso.H"
#include "isoCutCell.H"
#include "volPointInterpolation.H"
#include "wallPolyPatch.H"
#include "fvcSmooth.H"
@ -50,7 +50,7 @@ void Foam::meltingEvaporationModels::kineticGasEvaporation<Thermo, OtherThermo>
volPointInterpolation::New(mesh).interpolate(alpha)
);
cutCellIso cutCell(mesh, ap);
isoCutCell cutCell(mesh, ap);
forAll(interfaceArea_, celli)
{
@ -59,7 +59,7 @@ void Foam::meltingEvaporationModels::kineticGasEvaporation<Thermo, OtherThermo>
if (status == 0) // cell is cut
{
interfaceArea_[celli] =
mag(cutCell.faceArea())/mesh.V()[celli];
mag(cutCell.isoFaceArea())/mesh.V()[celli];
}
}
@ -143,7 +143,7 @@ Foam::meltingEvaporationModels::kineticGasEvaporation<Thermo, OtherThermo>
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
IOobject::AUTO_WRITE
),
this->mesh_,
dimensionedScalar(dimMass/dimArea/dimTemperature/dimTime, Zero)
@ -156,7 +156,7 @@ Foam::meltingEvaporationModels::kineticGasEvaporation<Thermo, OtherThermo>
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
IOobject::NO_WRITE
),
this->mesh_,
dimensionedScalar(dimDensity/dimTime, Zero)

View File

@ -1,17 +1,16 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/transportModels/geometricVoF/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lgeometricVoF \
-ltwoPhaseMixture \
-linterfaceProperties \
-ltwoPhaseProperties \
-lincompressibleTransportModels \
-lfiniteVolume \
-lfluidThermophysicalModels

View File

@ -29,7 +29,7 @@ License
#include "interfaceHeatResistance.H"
#include "addToRunTimeSelectionTable.H"
#include "twoPhaseMixtureEThermo.H"
#include "cutCellIso.H"
#include "isoCutCell.H"
#include "volPointInterpolation.H"
#include "calculatedFvPatchFields.H"
#include "wallPolyPatch.H"
@ -342,7 +342,7 @@ updateInterface()
volPointInterpolation::New(mesh_).interpolate(mixture_.alpha1())
);
cutCellIso cutCell(mesh_, ap);
isoCutCell cutCell(mesh_, ap);
forAll(interfaceArea_, celli)
{
@ -351,7 +351,7 @@ updateInterface()
if (status == 0) // cell is cut
{
interfaceArea_[celli] =
mag(cutCell.faceArea())/mesh_.V()[celli];
mag(cutCell.isoFaceArea())/mesh_.V()[celli];
}
}

View File

@ -1,26 +1,19 @@
EXE_INC = \
-I../VoF \
-I../interFoam \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/geometricVoF/lnInclude \
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
-I$(LIB_SRC)/transportModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude \
-I$(LIB_SRC)/transportModels/geometricVoF/lnInclude
-I$(LIB_SRC)/transportModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lsurfMesh \
-lmeshTools \
-lsampling \
-ldynamicFvMesh \
@ -29,5 +22,4 @@ EXE_LIBS = \
-limmiscibleIncompressibleTwoPhaseMixture \
-lturbulenceModels \
-lincompressibleTurbulenceModels \
-lwaveModels \
-lgeometricVoF
-lwaveModels

View File

@ -0,0 +1,33 @@
MRF.correctBoundaryVelocity(U);
fvVectorMatrix UEqn
(
fvm::ddt(rho, U) + fvm::div(rhoPhi, U)
+ MRF.DDt(rho, U)
+ turbulence->divDevRhoReff(rho, U)
==
fvOptions(rho, U)
);
UEqn.relax();
fvOptions.constrain(UEqn);
if (pimple.momentumPredictor())
{
solve
(
UEqn
==
fvc::reconstruct
(
(
mixture.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
- fvc::snGrad(p_rgh)
) * mesh.magSf()
)
);
fvOptions.correct(U);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2011-2017 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,27 +23,37 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Global
alphaCourantNo
Description
Calculates and outputs the mean and maximum Courant Numbers.
\*---------------------------------------------------------------------------*/
#include "rawIOField.H"
#include "fieldTypes.H"
#include "addToRunTimeSelectionTable.H"
scalar maxAlphaCo
(
runTime.controlDict().get<scalar>("maxAlphaCo")
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scalar alphaCoNum = 0.0;
scalar meanAlphaCoNum = 0.0;
namespace Foam
if (mesh.nInternalFaces())
{
scalarField sumPhi
(
mixture.nearInterface()().primitiveField()
*fvc::surfaceSum(mag(phi))().primitiveField()
);
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
alphaCoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue();
defineNamedTemplateTypeNameAndDebug(rawIOField<scalar>, 0);
defineNamedTemplateTypeNameAndDebug(rawIOField<vector>, 0);
defineNamedTemplateTypeNameAndDebug(rawIOField<sphericalTensor>, 0);
defineNamedTemplateTypeNameAndDebug(rawIOField<symmTensor>, 0);
defineNamedTemplateTypeNameAndDebug(rawIOField<tensor>, 0);
meanAlphaCoNum =
0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaTValue();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
Info<< "Interface Courant Number mean: " << meanAlphaCoNum
<< " max: " << alphaCoNum << endl;
// ************************************************************************* //

View File

@ -6,8 +6,7 @@
}
// Updating alpha1
#include "alphaSuSp.H"
advector.advect(Sp, Su);
advector.advect();
// Making U absolute again after advection step
if (mesh.moving())

View File

@ -0,0 +1,11 @@
CorrectPhi
(
U,
phi,
p_rgh,
surfaceScalarField("rAUf", fvc::interpolate(rAU())),
geometricZeroField(),
pimple
);
#include "continuityErrs.H"

View File

@ -0,0 +1,34 @@
tmp<volScalarField> rAU;
if (correctPhi)
{
rAU = new volScalarField
(
IOobject
(
"rAU",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("rAU", dimTime/dimDensity, 1)
);
#include "correctPhi.H"
}
else
{
CorrectPhi
(
U,
phi,
p_rgh,
dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1),
geometricZeroField(),
pimple
);
#include "continuityErrs.H"
}

View File

@ -9,7 +9,6 @@
Copyright (C) 2016 DHI
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2018 Johan Roenby
Copyright (C) 2019-2020 DLR
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -64,7 +63,6 @@ Description
#include "fvOptions.H"
#include "CorrectPhi.H"
#include "fvcSmooth.H"
#include "dynamicRefineFvMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -115,29 +113,14 @@ int main(int argc, char *argv[])
{
if (pimple.firstIter() || moveMeshOuterCorrectors)
{
if (isA<dynamicRefineFvMesh>(mesh))
{
advector.surf().reconstruct();
}
mesh.update();
if (mesh.changing())
{
gh = (g & mesh.C()) - ghRef;
ghf = (g & mesh.Cf()) - ghRef;
if (isA<dynamicRefineFvMesh>(mesh))
{
advector.surf().mapAlphaField();
alpha2 = 1.0 - alpha1;
alpha2.correctBoundaryConditions();
rho == alpha1*rho1 + alpha2*rho2;
rho.correctBoundaryConditions();
rho.oldTime() = rho;
alpha2.oldTime() = alpha2;
}
MRF.update();
if (correctPhi)

View File

@ -0,0 +1,89 @@
{
if (correctPhi)
{
rAU.ref() = 1.0/UEqn.A();
}
else
{
rAU = 1.0/UEqn.A();
}
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU()));
volVectorField HbyA(constrainHbyA(rAU()*UEqn.H(), U, p_rgh));
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
+ MRF.zeroFilter(fvc::interpolate(rho*rAU())*fvc::ddtCorr(U, phi, Uf))
);
MRF.makeRelative(phiHbyA);
if (p_rgh.needReference())
{
fvc::makeRelative(phiHbyA, U);
adjustPhi(phiHbyA, U, p_rgh);
fvc::makeAbsolute(phiHbyA, U);
}
surfaceScalarField phig
(
(
mixture.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf()
);
phiHbyA += phig;
// Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqn
(
fvm::laplacian(rAUf, p_rgh) == fvc::div(phiHbyA)
);
p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter())));
if (pimple.finalNonOrthogonalIter())
{
phi = phiHbyA - p_rghEqn.flux();
p_rgh.relax();
U = HbyA + rAU()*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf);
U.correctBoundaryConditions();
fvOptions.correct(U);
}
}
#include "continuityErrs.H"
// Correct Uf if the mesh is moving
fvc::correctUf(Uf, U, phi);
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
p == p_rgh + rho*gh;
if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pRefCell)
);
p_rgh = p - rho*gh;
}
if (!correctPhi)
{
rAU.clear();
}
}

View File

@ -0,0 +1,2 @@
const dimensionedScalar& rho1f(rho1);
const dimensionedScalar& rho2f(rho2);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2011-2017 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,43 +23,33 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Global
setDeltaT
Description
Reset the timestep to maintain a constant maximum courant Number.
Reduction of time-step is immediate, but increase is damped to avoid
unstable oscillations.
\*---------------------------------------------------------------------------*/
inline const Foam::primitivePatch& Foam::advancingFrontAMI::srcPatch() const
if (adjustTimeStep)
{
if (!tsrcPatch0_.valid())
{
FatalErrorInFunction
<< "tsrcPatch0_ not allocated"
<< abort(FatalError);
}
scalar maxDeltaTFact =
min(maxCo/(CoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL));
return tsrcPatch0_();
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT
(
min
(
deltaTFact*runTime.deltaTValue(),
maxDeltaT
)
);
Info<< "deltaT = " << runTime.deltaTValue() << endl;
}
inline const Foam::primitivePatch& Foam::advancingFrontAMI::tgtPatch() const
{
if (extendedTgtPatchPtr_)
{
return extendedTgtPatchPtr_();
}
if (!ttgtPatch0_.valid())
{
FatalErrorInFunction
<< "srcPatch0Ptr not allocated"
<< abort(FatalError);
}
return ttgtPatch0_();
}
inline const Foam::labelList& Foam::advancingFrontAMI::srcNonOverlap() const
{
return srcNonOverlap_;
}
// ************************************************************************* //

View File

@ -3,5 +3,4 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lmultiphaseSystem

View File

@ -10,8 +10,6 @@ EXE_INC = \
-I../twoPhaseSystem/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lcompressibleTwoPhaseSystem \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \

View File

@ -1,4 +1,3 @@
/* Install into FOAM_APPBIN to support 'fake' builds (to test packaging) */
Test-dummyLib.C
EXE = $(FOAM_APPBIN)/Test-dummyLib

View File

@ -1,4 +1,3 @@
/* Install into FOAM_LIBBIN to support 'fake' builds (to test packaging) */
dummyLib.C
LIB = $(FOAM_LIBBIN)/libOpenFOAM-dummy

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -4,3 +4,4 @@
EXE_INC = \
-DFULLDEBUG -g -O0

View File

@ -0,0 +1,403 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-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 "polyMesh.H"
#include "IFstream.H"
#include "AverageField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::PatchFunction1Types::MappedField<Type>::MappedField
(
const polyPatch& pp,
const word& entryName,
const dictionary& dict
)
:
PatchFunction1<Type>(pp, entryName, dict),
fieldTableName_(entryName),
setAverage_(dict.getOrDefault("setAverage", false)),
perturb_(dict.getOrDefault<scalar>("perturb", 1e-5)),
pointsName_(dict.getOrDefault<word>("points", "points")),
mapMethod_
(
dict.getOrDefault<word>
(
"mapMethod",
"planarInterpolation"
)
),
mapperPtr_(nullptr),
sampleTimes_(0),
startSampleTime_(-1),
startSampledValues_(0),
startAverage_(Zero),
endSampleTime_(-1),
endSampledValues_(0),
endAverage_(Zero),
offset_()
{
if (dict.found("offset"))
{
offset_ = Function1<Type>::New("offset", dict);
}
if
(
mapMethod_ != "planarInterpolation"
&& mapMethod_ != "nearest"
)
{
FatalIOErrorInFunction(dict)
<< "mapMethod should be one of 'planarInterpolation'"
<< ", 'nearest'" << exit(FatalIOError);
}
dict.readIfPresent("fieldTable", fieldTableName_);
}
template<class Type>
Foam::PatchFunction1Types::MappedField<Type>::MappedField
(
const MappedField<Type>& ut
)
:
PatchFunction1<Type>(ut),
fieldTableName_(ut.fieldTableName_),
setAverage_(ut.setAverage_),
perturb_(ut.perturb_),
pointsName_(ut.pointsName_),
mapMethod_(ut.mapMethod_),
mapperPtr_(nullptr),
sampleTimes_(ut.sampleTimes_),
startSampleTime_(ut.startSampleTime_),
startSampledValues_(ut.startSampledValues_),
startAverage_(ut.startAverage_),
endSampleTime_(ut.endSampleTime_),
endSampledValues_(ut.endSampledValues_),
endAverage_(ut.endAverage_),
offset_(ut.offset_.clone())
{}
template<class Type>
Foam::PatchFunction1Types::MappedField<Type>::MappedField
(
const MappedField<Type>& ut,
const polyPatch& pp
)
:
PatchFunction1<Type>(ut, pp),
fieldTableName_(ut.fieldTableName_),
setAverage_(ut.setAverage_),
perturb_(ut.perturb_),
pointsName_(ut.pointsName_),
mapMethod_(ut.mapMethod_),
mapperPtr_(nullptr),
sampleTimes_(ut.sampleTimes_),
startSampleTime_(ut.startSampleTime_),
startSampledValues_(ut.startSampledValues_),
startAverage_(ut.startAverage_),
endSampleTime_(ut.endSampleTime_),
endSampledValues_(ut.endSampledValues_),
endAverage_(ut.endAverage_),
offset_(ut.offset_.clone())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::PatchFunction1Types::MappedField<Type>::autoMap
(
const FieldMapper& mapper
)
{
if (startSampledValues_.size())
{
startSampledValues_.autoMap(mapper);
endSampledValues_.autoMap(mapper);
}
// Clear interpolator
mapperPtr_.clear();
startSampleTime_ = -1;
endSampleTime_ = -1;
}
template<class Type>
void Foam::PatchFunction1Types::MappedField<Type>::rmap
(
const PatchFunction1<Type>& pf1,
const labelList& addr
)
{
const PatchFunction1Types::MappedField<Type>& tiptf =
refCast<const PatchFunction1Types::MappedField<Type>>(pf1);
startSampledValues_.rmap(tiptf.startSampledValues_, addr);
endSampledValues_.rmap(tiptf.endSampledValues_, addr);
// Clear interpolator
mapperPtr_.clear();
startSampleTime_ = -1;
endSampleTime_ = -1;
}
template<class Type>
void Foam::PatchFunction1Types::MappedField<Type>::checkTable() const
{
const polyMesh& mesh = this->patch_.boundaryMesh().mesh();
// Initialise
if (mapperPtr_.empty())
{
// Reread values and interpolate
fileName samplePointsFile
(
mesh.time().path()
/mesh.time().caseConstant()
/"boundaryData"
/this->patch_.name()
/pointsName_
);
pointField samplePoints((IFstream(samplePointsFile)()));
DebugInfo
<< " Read " << samplePoints.size() << " sample points from "
<< samplePointsFile << endl;
// tbd: run-time selection
bool nearestOnly =
(
!mapMethod_.empty()
&& mapMethod_ != "planarInterpolation"
);
// Allocate the interpolator
mapperPtr_.reset
(
new pointToPointPlanarInterpolation
(
samplePoints,
this->patch_.faceCentres(),
perturb_,
nearestOnly
)
);
// Read the times for which data is available
const fileName samplePointsDir = samplePointsFile.path();
sampleTimes_ = Time::findTimes(samplePointsDir);
DebugInfo
<< "In directory "
<< samplePointsDir << " found times "
<< pointToPointPlanarInterpolation::timeNames(sampleTimes_)
<< endl;
}
// Find current time in sampleTimes
label lo = -1;
label hi = -1;
bool foundTime = mapperPtr_().findTime
(
sampleTimes_,
startSampleTime_,
mesh.time().value(),
lo,
hi
);
if (!foundTime)
{
FatalErrorInFunction
<< "Cannot find starting sampling values for current time "
<< mesh.time().value() << nl
<< "Have sampling values for times "
<< pointToPointPlanarInterpolation::timeNames(sampleTimes_) << nl
<< "In directory "
<< mesh.time().constant()/"boundaryData"/this->patch_.name()
<< "\n on patch " << this->patch_.name()
<< " of field " << fieldTableName_
<< exit(FatalError);
}
// Update sampled data fields.
if (lo != startSampleTime_)
{
startSampleTime_ = lo;
if (startSampleTime_ == endSampleTime_)
{
// No need to reread since are end values
if (debug)
{
Pout<< "checkTable : Setting startValues to (already read) "
<< "boundaryData"
/this->patch_.name()
/sampleTimes_[startSampleTime_].name()
<< endl;
}
startSampledValues_ = endSampledValues_;
startAverage_ = endAverage_;
}
else
{
if (debug)
{
Pout<< "checkTable : Reading startValues from "
<< "boundaryData"
/this->patch_.name()
/sampleTimes_[lo].name()
<< endl;
}
// Reread values and interpolate
fileName valsFile
(
mesh.time().path()
/mesh.time().caseConstant()
/"boundaryData"
/this->patch_.name()
/sampleTimes_[startSampleTime_].name()
/fieldTableName_
);
Field<Type> vals;
if (setAverage_)
{
AverageField<Type> avals((IFstream(valsFile)()));
vals = avals;
startAverage_ = avals.average();
}
else
{
IFstream(valsFile)() >> vals;
}
if (vals.size() != mapperPtr_().sourceSize())
{
FatalErrorInFunction
<< "Number of values (" << vals.size()
<< ") differs from the number of points ("
<< mapperPtr_().sourceSize()
<< ") in file " << valsFile << exit(FatalError);
}
startSampledValues_ = mapperPtr_().interpolate(vals);
}
}
if (hi != endSampleTime_)
{
endSampleTime_ = hi;
if (endSampleTime_ == -1)
{
// endTime no longer valid. Might as well clear endValues.
if (debug)
{
Pout<< "checkTable : Clearing endValues" << endl;
}
endSampledValues_.clear();
}
else
{
if (debug)
{
Pout<< "checkTable : Reading endValues from "
<< "boundaryData"
/this->patch_.name()
/sampleTimes_[endSampleTime_].name()
<< endl;
}
// Reread values and interpolate
fileName valsFile
(
mesh.time().path()
/mesh.time().caseConstant()
/"boundaryData"
/this->patch_.name()
/sampleTimes_[endSampleTime_].name()
/fieldTableName_
);
Field<Type> vals;
if (setAverage_)
{
AverageField<Type> avals((IFstream(valsFile)()));
vals = avals;
endAverage_ = avals.average();
}
else
{
IFstream(valsFile)() >> vals;
}
if (vals.size() != mapperPtr_().sourceSize())
{
FatalErrorInFunction
<< "Number of values (" << vals.size()
<< ") differs from the number of points ("
<< mapperPtr_().sourceSize()
<< ") in file " << valsFile << exit(FatalError);
}
endSampledValues_ = mapperPtr_().interpolate(vals);
}
}
}
template<class Type>
void Foam::PatchFunction1Types::MappedField<Type>::writeData
(
Ostream& os
) const
{
PatchFunction1<Type>::writeData(os);
//os << token::END_STATEMENT << nl;
// uniformValuePtr_->writeData(os);
//os << endl;
}
// ************************************************************************* //

View File

@ -0,0 +1,221 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 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::PatchFunction1Types::MappedField
Description
SourceFiles
MappedField.C
\*---------------------------------------------------------------------------*/
#ifndef PatchFunction1Types_MappedField_H
#define PatchFunction1Types_MappedField_H
#include "PatchFunction1.H"
#include "pointToPointPlanarInterpolation.H"
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace PatchFunction1Types
{
/*---------------------------------------------------------------------------*\
Class MappedField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class MappedField
:
public PatchFunction1<Type>
{
// Private data
//- Name of the field data table, defaults to the name of the field
word fieldTableName_;
//- If true adjust the mapped field to maintain average value
Switch setAverage_;
//- Fraction of perturbation (fraction of bounding box) to add
scalar perturb_;
//- Name of points file; default = "points"
word pointsName_;
//- Interpolation scheme to use
word mapMethod_;
//- 2D interpolation (for 'planarInterpolation' mapMethod)
mutable autoPtr<pointToPointPlanarInterpolation> mapperPtr_;
//- List of boundaryData time directories
mutable instantList sampleTimes_;
//- Current starting index in sampleTimes
mutable label startSampleTime_;
//- Interpolated values from startSampleTime
mutable Field<Type> startSampledValues_;
//- If setAverage: starting average value
mutable Type startAverage_;
//- Current end index in sampleTimes
mutable label endSampleTime_;
//- Interpolated values from endSampleTime
mutable Field<Type> endSampledValues_;
//- If setAverage: end average value
mutable Type endAverage_;
//- Time varying offset values to interpolated data
autoPtr<Function1<Type>> offset_;
// Private Member Functions
void checkTable() const;
//- No copy assignment
void operator=(const MappedField<Type>&) = delete;
public:
// Runtime type information
TypeName("mapped");
// Constructors
//- Construct from components
MappedField
(
const polyPatch& pp,
const word& entryName,
const Field<Type>& value
);
//- Construct from entry name and dictionary
MappedField
(
const polyPatch& pp,
const word& entryName,
const dictionary& dict
);
//- Copy constructor
explicit MappedField(const MappedField<Type>& ut);
//- Copy constructor setting patch
explicit MappedField
(
const MappedField<Type>& ut,
const polyPatch& pp
);
//- Construct and return a clone
virtual tmp<PatchFunction1<Type>> clone() const
{
return tmp<PatchFunction1<Type>>
(
new MappedField<Type>(*this)
);
}
//- Construct and return a clone setting patch
virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const
{
return tmp<PatchFunction1<Type>>
(
new MappedField<Type>(*this, pp)
);
}
//- Destructor
virtual ~MappedField() = default;
// Member Functions
// Evaluation
//- Return MappedField value
virtual inline tmp<Field<Type>> value(const scalar) const;
//- Integrate between two values
virtual inline tmp<Field<Type>> integrate
(
const scalar x1,
const scalar x2
) const;
// Mapping
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap(const FieldMapper& mapper);
//- Reverse map the given PatchFunction1 onto this PatchFunction1
virtual void rmap
(
const PatchFunction1<Type>& pf1,
const labelList& addr
);
// I-O
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace PatchFunction1Types
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "MappedFieldI.H"
#ifdef NoRepository
#include "MappedField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,150 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 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 "MappedField.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
inline Foam::tmp<Foam::Field<Type>>
Foam::PatchFunction1Types::MappedField<Type>::value
(
const scalar x
) const
{
const polyMesh& mesh = this->patch_.boundaryMesh().mesh();
checkTable();
tmp<Field<Type>> tfld(new Field<Type>(this->patch_.size()));
Field<Type>& fld = tfld.ref();
Type wantedAverage;
if (endSampleTime_ == -1)
{
// Only start value
if (debug)
{
Pout<< "updateCoeffs : Sampled, non-interpolated values"
<< " from start time:"
<< sampleTimes_[startSampleTime_].name() << nl;
}
fld = startSampledValues_;
wantedAverage = startAverage_;
}
else
{
scalar start = sampleTimes_[startSampleTime_].value();
scalar end = sampleTimes_[endSampleTime_].value();
scalar s = (mesh.time().value() - start)/(end - start);
if (debug)
{
Pout<< "updateCoeffs : Sampled, interpolated values"
<< " between start time:"
<< sampleTimes_[startSampleTime_].name()
<< " and end time:" << sampleTimes_[endSampleTime_].name()
<< " with weight:" << s << endl;
}
fld = ((1 - s)*startSampledValues_ + s*endSampledValues_);
wantedAverage = (1 - s)*startAverage_ + s*endAverage_;
}
// Enforce average. Either by scaling (if scaling factor > 0.5) or by
// offsetting.
if (setAverage_)
{
const scalarField magSf(mag(this->patch_.faceAreas()));
Type averagePsi = gSum(magSf*fld)/gSum(magSf);
if (debug)
{
Pout<< "updateCoeffs :"
<< " actual average:" << averagePsi
<< " wanted average:" << wantedAverage
<< endl;
}
if (mag(averagePsi) < VSMALL)
{
// Field too small to scale. Offset instead.
const Type offset = wantedAverage - averagePsi;
if (debug)
{
Pout<< "updateCoeffs :"
<< " offsetting with:" << offset << endl;
}
fld += offset;
}
else
{
const scalar scale = mag(wantedAverage)/mag(averagePsi);
if (debug)
{
Pout<< "updateCoeffs :"
<< " scaling with:" << scale << endl;
}
fld *= scale;
}
}
// Apply offset to mapped values
if (offset_.valid())
{
const scalar t = mesh.time().timeOutputValue();
fld += offset_->value(t);
}
if (debug)
{
Pout<< "updateCoeffs : set fixedValue to min:" << gMin(fld)
<< " max:" << gMax(fld)
<< " avg:" << gAverage(fld) << endl;
}
return this->transform(tfld);
}
template<class Type>
inline Foam::tmp<Foam::Field<Type>>
Foam::PatchFunction1Types::MappedField<Type>::integrate
(
const scalar x1,
const scalar x2
) const
{
NotImplemented;
return tmp<Field<Type>>(nullptr);
}
// ************************************************************************* //

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,29 +24,24 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-Polynomial
PolynomialTest
Description
Test application for the templated Polynomial class
\*---------------------------------------------------------------------------*/
#include "StringStream.H"
#include "Polynomial.H"
#include "FixedList.H"
#include "polynomialFunction.H"
#include "ITstream.H"
#include "OTstream.H"
#include "Random.H"
#include "cpuTime.H"
using namespace Foam;
std::initializer_list<scalar> coeffs
{
0.11, 0.45, -0.94, 1.58, -2.58, 0.08, 3.15, -4.78
};
const FixedList<scalar, 8> coeff(coeffs);
const int PolySize = 8;
const scalar coeff[] = { 0.11, 0.45, -0.94, 1.58, -2.58, 0.08, 3.15, -4.78 };
const char* polyDef = "(0.11 0.45 -0.94 1.58 -2.58 0.08 3.15 -4.78)";
scalar polyValue(const scalar x)
@ -82,10 +76,10 @@ scalar intPolyValue(const scalar x)
scalar polyValue1(const scalar x)
{
// Naive evaluation using pow()
// "normal" evaluation using pow()
scalar value = coeff[0];
for (label i=1; i < coeff.size(); ++i)
for (int i=1; i < PolySize; ++i)
{
value += coeff[i]*pow(x, i);
}
@ -96,11 +90,11 @@ scalar polyValue1(const scalar x)
scalar polyValue2(const scalar x)
{
// Calculation avoiding pow()
// calculation avoiding pow()
scalar value = coeff[0];
scalar powX = x;
for (label i=1; i < coeff.size(); ++i)
for (int i=1; i < PolySize; ++i)
{
value += coeff[i] * powX;
powX *= x;
@ -114,27 +108,19 @@ scalar polyValue2(const scalar x)
int main(int argc, char *argv[])
{
constexpr label n = 10000;
constexpr label nIters = 1000;
scalar sum = 0;
const label n = 10000;
const label nIters = 1000;
scalar sum = 0.0;
Info<< "null poly = " << (Polynomial<8>{}) << nl
<< "null poly = " << (polynomialFunction{8}) << nl
Info<< "null poly = " << (Polynomial<8>()) << nl
<< "null poly = " << (polynomialFunction(8)) << nl
<< endl;
Polynomial<8> poly{coeffs};
Polynomial<9> intPoly{poly.integral(0)};
Polynomial<8> poly(coeff);
Polynomial<9> intPoly(poly.integral(0.0));
polynomialFunction polyfunc;
// Could profit from a bi-directional stream
{
OTstream os;
os << poly;
ITstream is("input", std::move(os.tokens()));
is >> polyfunc;
}
IStringStream is(polyDef);
polynomialFunction polyfunc(is);
Info<< "poly = " << poly << nl
<< "intPoly = " << intPoly << nl
@ -166,7 +152,7 @@ int main(int argc, char *argv[])
Info<< "2.5*poly = " << polyCopy << nl << endl;
Random rnd(123456);
for (label i=0; i<10; ++i)
for (int i=0; i<10; i++)
{
scalar x = rnd.sample01<scalar>()*100;
@ -176,18 +162,18 @@ int main(int argc, char *argv[])
scalar pxTest = poly.value(x);
scalar ipxTest = intPoly.value(x);
Info<<"\nx = " << x << nl
<< " px, pxTest = " << px << ", " << pxTest << nl
<< " ipx, ipxTest = " << ipx << ", " << ipxTest << nl;
Info<<"\nx = " << x << endl;
Info<< " px, pxTest = " << px << ", " << pxTest << endl;
Info<< " ipx, ipxTest = " << ipx << ", " << ipxTest << endl;
if (mag(px - pxTest) > SMALL)
{
Info<< " *** WARNING: px != pxTest: " << px - pxTest << nl;
Info<< " *** WARNING: px != pxTest: " << px - pxTest << endl;
}
if (mag(ipx - ipxTest) > SMALL)
{
Info<< " *** WARNING: ipx != ipxTest: " << ipx - ipxTest << nl;
Info<< " *** WARNING: ipx != ipxTest: " << ipx - ipxTest << endl;
}
Info<< endl;
@ -202,7 +188,7 @@ int main(int argc, char *argv[])
cpuTime timer;
for (label loop = 0; loop < n; ++loop)
for (int loop = 0; loop < n; ++loop)
{
sum = 0.0;
for (label iter = 0; iter < nIters; ++iter)
@ -213,7 +199,7 @@ int main(int argc, char *argv[])
Info<< "value: " << sum
<< " in " << timer.cpuTimeIncrement() << " s\n";
for (label loop = 0; loop < n; ++loop)
for (int loop = 0; loop < n; ++loop)
{
sum = 0.0;
for (label iter = 0; iter < nIters; ++iter)
@ -225,7 +211,7 @@ int main(int argc, char *argv[])
<< " in " << timer.cpuTimeIncrement() << " s\n";
for (label loop = 0; loop < n; ++loop)
for (int loop = 0; loop < n; ++loop)
{
sum = 0.0;
for (label iter = 0; iter < nIters; ++iter)
@ -237,7 +223,7 @@ int main(int argc, char *argv[])
<< " in " << timer.cpuTimeIncrement() << " s\n";
for (label loop = 0; loop < n; ++loop)
for (int loop = 0; loop < n; ++loop)
{
sum = 0.0;
for (label iter = 0; iter < nIters; ++iter)
@ -248,7 +234,7 @@ int main(int argc, char *argv[])
Info<< "hard-coded 1: " << sum
<< " in " << timer.cpuTimeIncrement() << " s\n";
for (label loop = 0; loop < n; ++loop)
for (int loop = 0; loop < n; ++loop)
{
sum = 0.0;
for (label iter = 0; iter < nIters; ++iter)

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.
@ -37,6 +37,7 @@ using namespace Foam::MatrixTools;
#define RUNALL true
const bool verbose = true;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void horizontalLine()

View File

@ -1,305 +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/>.
Description
Various tools for test applications.
\*---------------------------------------------------------------------------*/
using namespace Foam;
#include "Random.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Total number of unit tests
unsigned nTest_ = 0;
// Total number of failed unit tests
unsigned nFail_ = 0;
// Create a non-complex random Matrix.
template<class MatrixType>
typename std::enable_if
<
!std::is_same<complex, typename MatrixType::cmptType>:: value,
MatrixType
>::type makeRandomMatrix
(
const labelPair& dims,
Random& rndGen
)
{
MatrixType mat(dims);
std::generate
(
mat.begin(),
mat.end(),
[&]{return rndGen.GaussNormal<scalar>();}
);
return mat;
}
// Create a complex random Matrix.
template<class MatrixType>
typename std::enable_if
<
std::is_same<complex, typename MatrixType::cmptType>:: value,
MatrixType
>::type makeRandomMatrix
(
const labelPair& dims,
Random& rndGen
)
{
MatrixType mat(dims);
for (auto& x : mat)
{
x = complex(rndGen.GaussNormal<scalar>(), rndGen.GaussNormal<scalar>());
}
return mat;
}
// Copy an initializer list into a DiagonalMatrix
template<class Type>
void assignMatrix
(
UList<Type>& A,
std::initializer_list<Type> list
)
{
std::copy(list.begin(), list.end(), A.begin());
}
// Copy an initializer list into a SymmetricSquareMatrix.
template<class Form, class Type>
void assignMatrix
(
Matrix<Form, Type>& A,
std::initializer_list<typename Matrix<Form, Type>::cmptType> list
)
{
const label nargs = list.size();
if (nargs != A.size())
{
FatalErrorInFunction
<< "Mismatch in matrix dimension ("
<< A.m() << ", "
<< A.n() << ") and number of args (" << nargs << ')' << nl
<< exit(FatalError);
}
std::copy(list.begin(), list.end(), A.begin());
}
// Return a copy of the Matrix collapsed into one dimension.
template<class Form, class Type>
List<Type> flt
(
const Matrix<Form, Type>& A,
const bool rowMajorOrder = true
)
{
List<Type> flatMatrix(A.size());
if (rowMajorOrder)
{
std::copy(A.cbegin(), A.cend(), flatMatrix.begin());
}
else
{
for (label j = 0; j < A.n(); ++j)
{
for (label i = 0; i < A.m(); ++i)
{
flatMatrix[i + j*A.m()] = A(i, j);
}
}
}
return flatMatrix;
}
// Compare two floating point types, and print output.
// Do ++nFail_ if values of two objects are not equal within a given tolerance.
// The function is converted from PEP-485.
template<class Type>
typename std::enable_if
<
std::is_same<floatScalar, Type>::value ||
std::is_same<doubleScalar, Type>::value ||
std::is_same<complex, Type>::value,
void
>::type cmp
(
const word& msg,
const Type& x,
const Type& y,
const scalar absTol = 0, //<! useful for cmps near zero
const scalar relTol = 1e-8 //<! are values the same within 8 decimals
)
{
Info<< msg << x << "?=" << y << endl;
unsigned nFail = 0;
if (max(absTol, relTol*max(mag(x), mag(y))) < mag(x - y))
{
++nFail;
}
if (nFail)
{
Info<< nl
<< " #### Fail in " << nFail << " comps ####" << nl << endl;
++nFail_;
}
++nTest_;
}
// Compare two containers elementwise, and print output.
// Do ++nFail_ if two components are not equal within a given tolerance.
// The function is converted from PEP-485
template<class Type>
typename std::enable_if
<
!std::is_same<floatScalar, Type>::value &&
!std::is_same<doubleScalar, Type>::value &&
!std::is_same<complex, Type>::value,
void
>::type cmp
(
const word& msg,
const Type& x,
const Type& y,
const scalar absTol = 0,
const scalar relTol = 1e-8
)
{
Info<< msg << x << "?=" << y << endl;
unsigned nFail = 0;
for (label i = 0; i < x.size(); ++i)
{
if (max(absTol, relTol*max(mag(x[i]), mag(y[i]))) < mag(x[i] - y[i]))
{
++nFail;
}
}
if (nFail)
{
Info<< nl
<< " #### Fail in " << nFail << " comps ####" << nl << endl;
++nFail_;
}
++nTest_;
}
// Compare two containers elementwise, and print output.
// Do ++nFail_ if two components are not equal within a given tolerance.
// The function is converted from PEP-485
template<class Type1, class Type2>
typename std::enable_if
<
!std::is_same<floatScalar, Type1>::value &&
!std::is_same<doubleScalar, Type1>::value &&
!std::is_same<complex, Type1>::value,
void
>::type cmp
(
const word& msg,
const Type1& x,
const Type2& y,
const scalar absTol = 0,
const scalar relTol = 1e-8
)
{
Info<< msg << x << "?=" << y << endl;
unsigned nFail = 0;
for (label i = 0; i < x.size(); ++i)
{
if (max(absTol, relTol*max(mag(x[i]), mag(y[i]))) < mag(x[i] - y[i]))
{
++nFail;
}
}
if (nFail)
{
Info<< nl
<< " #### Fail in " << nFail << " comps ####" << nl << endl;
++nFail_;
}
++nTest_;
}
// Compare two Booleans, and print output.
// Do ++nFail_ if two Booleans are not equal.
void cmp
(
const word& msg,
const bool x,
const bool y
)
{
Info<< msg << x << "?=" << y << endl;
unsigned nFail = 0;
if (x != y)
{
++nFail;
}
if (nFail)
{
Info<< nl
<< " #### Fail in " << nFail << " comps ####" << nl << endl;
++nFail_;
}
++nTest_;
}
// ************************************************************************* //

View File

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

View File

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

View File

@ -1,89 +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-boolVector
Description
Some simple tests for boolVector
\*---------------------------------------------------------------------------*/
#include "boolVector.H"
#include "IOstreams.H"
#include "Switch.H"
using namespace Foam;
void print(const boolVector& v)
{
Info<< v
<< " any:" << Switch::name(v.any())
<< " all:" << Switch::name(v.all())
<< " none:" << Switch::name(v.none())
<< " count:" << v.count() << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
Info<< "boolVector" << nl
<< " size = " << boolVector::size() << nl
<< " contiguous = " << is_contiguous<boolVector>::value << nl
<< nl;
{
boolVector vec;
Info<< "null: " << vec << nl;
}
Info<< "false: " << boolVector(false) << nl;
Info<< "true: " << boolVector(true) << nl;
Info<< "zero: " << boolVector(Zero) << nl;
Info<< nl;
{
boolVector vec{1, 0, 1};
print(vec);
vec.flip();
print(vec);
vec = false;
print(vec);
vec = true;
print(vec);
}
Info<< "\nEnd\n" << nl;
return 0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

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

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

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