mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' into cvm
This commit is contained in:
@ -0,0 +1,3 @@
|
||||
buoyantBoussinesqSimpleFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/buoyantBoussinesqSimpleFoam
|
||||
@ -0,0 +1,12 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/turbulenceModels \
|
||||
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels \
|
||||
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools \
|
||||
-lincompressibleRASModels \
|
||||
-lincompressibleTransportModels
|
||||
@ -0,0 +1,19 @@
|
||||
{
|
||||
volScalarField kappaEff
|
||||
(
|
||||
"kappaEff",
|
||||
turbulence->nu() + turbulence->nut()/Prt
|
||||
);
|
||||
|
||||
fvScalarMatrix TEqn
|
||||
(
|
||||
fvm::div(phi, T)
|
||||
- fvm::Sp(fvc::div(phi), T)
|
||||
- fvm::laplacian(kappaEff, T)
|
||||
);
|
||||
|
||||
TEqn.relax();
|
||||
|
||||
eqnResidual = TEqn.solve().initialResidual();
|
||||
maxResidual = max(eqnResidual, maxResidual);
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
// Solve the momentum equation
|
||||
|
||||
tmp<fvVectorMatrix> UEqn
|
||||
(
|
||||
fvm::div(phi, U)
|
||||
- fvm::Sp(fvc::div(phi), U)
|
||||
+ turbulence->divDevReff(U)
|
||||
);
|
||||
|
||||
UEqn().relax();
|
||||
|
||||
eqnResidual = solve
|
||||
(
|
||||
UEqn()
|
||||
==
|
||||
-fvc::reconstruct
|
||||
(
|
||||
(
|
||||
fvc::snGrad(pd)
|
||||
- betaghf*fvc::snGrad(T)
|
||||
) * mesh.magSf()
|
||||
)
|
||||
).initialResidual();
|
||||
|
||||
maxResidual = max(eqnResidual, maxResidual);
|
||||
@ -0,0 +1,105 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Application
|
||||
buoyantBoussinesqSimpleFoam
|
||||
|
||||
Description
|
||||
Steady-state solver for buoyant, turbulent flow of incompressible fluids
|
||||
|
||||
Uses the Boussinesq approximation:
|
||||
\f[
|
||||
rho_{eff} = 1 - beta(T - T_{ref})
|
||||
\f]
|
||||
|
||||
where:
|
||||
\f$ rho_{eff} \f$ = the effective (driving) density
|
||||
beta = thermal expansion coefficient [1/K]
|
||||
T = temperature [K]
|
||||
\f$ T_{ref} \f$ = reference temperature [K]
|
||||
|
||||
Valid when:
|
||||
\f[
|
||||
rho_{eff} << 1
|
||||
\f]
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "singlePhaseTransportModel.H"
|
||||
#include "RASModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createMesh.H"
|
||||
# include "readEnvironmentalProperties.H"
|
||||
# include "createFields.H"
|
||||
# include "initContinuityErrs.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
{
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readSIMPLEControls.H"
|
||||
# include "initConvergenceCheck.H"
|
||||
|
||||
pd.storePrevIter();
|
||||
|
||||
// Pressure-velocity SIMPLE corrector
|
||||
{
|
||||
# include "UEqn.H"
|
||||
# include "TEqn.H"
|
||||
# include "pdEqn.H"
|
||||
}
|
||||
|
||||
turbulence->correct();
|
||||
|
||||
if (runTime.write())
|
||||
{
|
||||
# include "writeAdditionalFields.H"
|
||||
}
|
||||
|
||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||
<< nl << endl;
|
||||
|
||||
# include "convergenceCheck.H"
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,9 @@
|
||||
// check convergence
|
||||
|
||||
if (maxResidual < convergenceCriterion)
|
||||
{
|
||||
Info<< "reached convergence criterion: " << convergenceCriterion << endl;
|
||||
runTime.writeAndEnd();
|
||||
Info<< "latestTime = " << runTime.timeName() << endl;
|
||||
}
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
Info<< "Reading thermophysical properties\n" << endl;
|
||||
|
||||
Info<< "Reading field T\n" << endl;
|
||||
volScalarField T
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"T",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
// kinematic pd
|
||||
Info<< "Reading field pd\n" << endl;
|
||||
volScalarField pd
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pd",
|
||||
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"
|
||||
|
||||
# include "readTransportProperties.H"
|
||||
|
||||
Info<< "Creating turbulence model\n" << endl;
|
||||
autoPtr<incompressible::RASModel> turbulence
|
||||
(
|
||||
incompressible::RASModel::New(U, phi, laminarTransport)
|
||||
);
|
||||
|
||||
Info<< "Calculating field beta*(g.h)\n" << endl;
|
||||
surfaceScalarField betaghf("betagh", beta*(g & mesh.Cf()));
|
||||
|
||||
label pdRefCell = 0;
|
||||
scalar pdRefValue = 0.0;
|
||||
setRefCell
|
||||
(
|
||||
pd,
|
||||
mesh.solutionDict().subDict("SIMPLE"),
|
||||
pdRefCell,
|
||||
pdRefValue
|
||||
);
|
||||
@ -0,0 +1,7 @@
|
||||
// initialize values for convergence checks
|
||||
|
||||
scalar eqnResidual = 1, maxResidual = 0;
|
||||
scalar convergenceCriterion = 0;
|
||||
|
||||
simple.readIfPresent("convergence", convergenceCriterion);
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
{
|
||||
volScalarField rUA("rUA", 1.0/UEqn().A());
|
||||
surfaceScalarField rUAf("(1|A(U))", fvc::interpolate(rUA));
|
||||
|
||||
U = rUA*UEqn().H();
|
||||
UEqn.clear();
|
||||
|
||||
phi = fvc::interpolate(U) & mesh.Sf();
|
||||
adjustPhi(phi, U, pd);
|
||||
surfaceScalarField buoyancyPhi = -betaghf*fvc::snGrad(T)*rUAf*mesh.magSf();
|
||||
phi -= buoyancyPhi;
|
||||
|
||||
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
||||
{
|
||||
fvScalarMatrix pdEqn
|
||||
(
|
||||
fvm::laplacian(rUAf, pd) == fvc::div(phi)
|
||||
);
|
||||
|
||||
pdEqn.setReference(pdRefCell, pdRefValue);
|
||||
|
||||
// retain the residual from the first iteration
|
||||
if (nonOrth == 0)
|
||||
{
|
||||
eqnResidual = pdEqn.solve().initialResidual();
|
||||
maxResidual = max(eqnResidual, maxResidual);
|
||||
}
|
||||
else
|
||||
{
|
||||
pdEqn.solve();
|
||||
}
|
||||
|
||||
if (nonOrth == nNonOrthCorr)
|
||||
{
|
||||
// Calculate the conservative fluxes
|
||||
phi -= pdEqn.flux();
|
||||
|
||||
// Explicitly relax pressure for momentum corrector
|
||||
pd.relax();
|
||||
|
||||
// Correct the momentum source with the pressure gradient flux
|
||||
// calculated from the relaxed pressure
|
||||
U -= rUA*fvc::reconstruct((buoyancyPhi + pdEqn.flux())/rUAf);
|
||||
U.correctBoundaryConditions();
|
||||
}
|
||||
}
|
||||
|
||||
#include "continuityErrs.H"
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
singlePhaseTransportModel laminarTransport(U, phi);
|
||||
|
||||
// thermal expansion coefficient [1/K]
|
||||
dimensionedScalar beta(laminarTransport.lookup("beta"));
|
||||
|
||||
// reference temperature [K]
|
||||
dimensionedScalar TRef(laminarTransport.lookup("TRef"));
|
||||
|
||||
// reference kinematic pressure [m2/s2]
|
||||
dimensionedScalar pRef(laminarTransport.lookup("pRef"));
|
||||
|
||||
// turbulent Prandtl number
|
||||
dimensionedScalar Prt(laminarTransport.lookup("Prt"));
|
||||
@ -0,0 +1,29 @@
|
||||
{
|
||||
volScalarField rhoEff
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"rhoEff",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
1.0 - beta*(T - TRef)
|
||||
);
|
||||
rhoEff.write();
|
||||
|
||||
volScalarField p
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"p",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
pd + rhoEff*(g & mesh.C()) + pRef
|
||||
);
|
||||
p.write();
|
||||
}
|
||||
@ -9,4 +9,18 @@
|
||||
|
||||
UEqn.relax();
|
||||
|
||||
solve(UEqn == -fvc::grad(pd) - fvc::grad(rho)*gh);
|
||||
if (momentumPredictor)
|
||||
{
|
||||
solve
|
||||
(
|
||||
UEqn
|
||||
==
|
||||
-fvc::reconstruct
|
||||
(
|
||||
(
|
||||
fvc::snGrad(pd)
|
||||
+ ghf*fvc::snGrad(rho)
|
||||
) * mesh.magSf()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -41,37 +41,41 @@ Description
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
#include "createMesh.H"
|
||||
#include "readEnvironmentalProperties.H"
|
||||
#include "createFields.H"
|
||||
#include "initContinuityErrs.H"
|
||||
#include "readTimeControls.H"
|
||||
#include "compressibleCourantNo.H"
|
||||
#include "setInitialDeltaT.H"
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createMesh.H"
|
||||
# include "readEnvironmentalProperties.H"
|
||||
# include "createFields.H"
|
||||
# include "initContinuityErrs.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
while (runTime.run())
|
||||
{
|
||||
# include "readPISOControls.H"
|
||||
# include "compressibleCourantNo.H"
|
||||
//# include "setDeltaT.H"
|
||||
#include "readTimeControls.H"
|
||||
#include "readPISOControls.H"
|
||||
#include "compressibleCourantNo.H"
|
||||
#include "setDeltaT.H"
|
||||
|
||||
runTime++;
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "rhoEqn.H"
|
||||
#include "rhoEqn.H"
|
||||
|
||||
# include "UEqn.H"
|
||||
#include "UEqn.H"
|
||||
|
||||
// --- PISO loop
|
||||
|
||||
for (int corr=0; corr<nCorr; corr++)
|
||||
{
|
||||
# include "hEqn.H"
|
||||
# include "pEqn.H"
|
||||
#include "hEqn.H"
|
||||
#include "pEqn.H"
|
||||
}
|
||||
|
||||
turbulence->correct();
|
||||
|
||||
@ -52,11 +52,13 @@
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Creating field dpdt\n" << endl;
|
||||
volScalarField dpdt = fvc::ddt(p);
|
||||
Info<< "Creating field DpDt\n" << endl;
|
||||
volScalarField DpDt =
|
||||
fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
|
||||
|
||||
Info<< "Calculating field g.h\n" << endl;
|
||||
volScalarField gh("gh", g & mesh.C());
|
||||
surfaceScalarField ghf("gh", g & mesh.Cf());
|
||||
|
||||
dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef"));
|
||||
|
||||
|
||||
@ -5,9 +5,7 @@
|
||||
+ fvm::div(phi, h)
|
||||
- fvm::laplacian(turbulence->alphaEff(), h)
|
||||
==
|
||||
dpdt
|
||||
+ fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p))
|
||||
- p*fvc::div(phi/fvc::interpolate(rho))
|
||||
DpDt
|
||||
);
|
||||
|
||||
hEqn.relax();
|
||||
|
||||
@ -1,60 +1,67 @@
|
||||
bool closedVolume = pd.needReference();
|
||||
|
||||
rho = thermo->rho();
|
||||
|
||||
volScalarField rUA = 1.0/UEqn.A();
|
||||
U = rUA*UEqn.H();
|
||||
|
||||
phi =
|
||||
fvc::interpolate(rho)
|
||||
*(
|
||||
(fvc::interpolate(U) & mesh.Sf())
|
||||
+ fvc::ddtPhiCorr(rUA, rho, U, phi)
|
||||
)
|
||||
- fvc::interpolate(rho*rUA*gh)*fvc::snGrad(rho)*mesh.magSf();
|
||||
|
||||
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
||||
{
|
||||
fvScalarMatrix pdEqn
|
||||
bool closedVolume = pd.needReference();
|
||||
|
||||
rho = thermo->rho();
|
||||
|
||||
volScalarField rUA = 1.0/UEqn.A();
|
||||
surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA));
|
||||
|
||||
U = rUA*UEqn.H();
|
||||
|
||||
surfaceScalarField phiU
|
||||
(
|
||||
fvm::ddt(psi, pd)
|
||||
+ fvc::ddt(psi)*pRef
|
||||
+ fvc::ddt(psi, rho)*gh
|
||||
+ fvc::div(phi)
|
||||
- fvm::laplacian(rho*rUA, pd)
|
||||
fvc::interpolate(rho)
|
||||
*(
|
||||
(fvc::interpolate(U) & mesh.Sf())
|
||||
+ fvc::ddtPhiCorr(rUA, rho, U, phi)
|
||||
)
|
||||
);
|
||||
|
||||
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
|
||||
phi = phiU - ghf*fvc::snGrad(rho)*rhorUAf*mesh.magSf();
|
||||
|
||||
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
||||
{
|
||||
pdEqn.solve(mesh.solver(pd.name() + "Final"));
|
||||
}
|
||||
else
|
||||
{
|
||||
pdEqn.solve(mesh.solver(pd.name()));
|
||||
fvScalarMatrix pdEqn
|
||||
(
|
||||
fvm::ddt(psi, pd)
|
||||
+ fvc::ddt(psi)*pRef
|
||||
+ fvc::ddt(psi, rho)*gh
|
||||
+ fvc::div(phi)
|
||||
- fvm::laplacian(rhorUAf, pd)
|
||||
);
|
||||
|
||||
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
|
||||
{
|
||||
pdEqn.solve(mesh.solver(pd.name() + "Final"));
|
||||
}
|
||||
else
|
||||
{
|
||||
pdEqn.solve(mesh.solver(pd.name()));
|
||||
}
|
||||
|
||||
if (nonOrth == nNonOrthCorr)
|
||||
{
|
||||
phi += pdEqn.flux();
|
||||
}
|
||||
}
|
||||
|
||||
if (nonOrth == nNonOrthCorr)
|
||||
U += rUA*fvc::reconstruct((phi - phiU)/rhorUAf);
|
||||
U.correctBoundaryConditions();
|
||||
|
||||
p == pd + rho*gh + pRef;
|
||||
DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
|
||||
|
||||
#include "rhoEqn.H"
|
||||
#include "compressibleContinuityErrs.H"
|
||||
|
||||
// For closed-volume cases adjust the pressure and density levels
|
||||
// to obey overall mass continuity
|
||||
if (closedVolume)
|
||||
{
|
||||
phi += pdEqn.flux();
|
||||
p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
|
||||
/fvc::domainIntegrate(thermo->psi());
|
||||
rho = thermo->rho();
|
||||
}
|
||||
}
|
||||
|
||||
p == pd + rho*gh + pRef;
|
||||
dpdt = fvc::ddt(p);
|
||||
|
||||
#include "rhoEqn.H"
|
||||
#include "compressibleContinuityErrs.H"
|
||||
|
||||
U -= rUA*(fvc::grad(pd) + fvc::grad(rho)*gh);
|
||||
U.correctBoundaryConditions();
|
||||
|
||||
|
||||
// For closed-volume cases adjust the pressure and density levels
|
||||
// to obey overall mass continuity
|
||||
if (closedVolume)
|
||||
{
|
||||
p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
|
||||
/fvc::domainIntegrate(thermo->psi());
|
||||
pd == p - (rho*gh + pRef);
|
||||
rho = thermo->rho();
|
||||
}
|
||||
|
||||
@ -11,7 +11,15 @@
|
||||
|
||||
eqnResidual = solve
|
||||
(
|
||||
UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh
|
||||
UEqn()
|
||||
==
|
||||
-fvc::reconstruct
|
||||
(
|
||||
(
|
||||
fvc::snGrad(pd)
|
||||
+ ghf*fvc::snGrad(rho)
|
||||
) * mesh.magSf()
|
||||
)
|
||||
).initialResidual();
|
||||
|
||||
maxResidual = max(eqnResidual, maxResidual);
|
||||
|
||||
@ -53,6 +53,7 @@
|
||||
|
||||
Info<< "Calculating field g.h\n" << endl;
|
||||
volScalarField gh("gh", g & mesh.C());
|
||||
surfaceScalarField ghf("gh", g & mesh.Cf());
|
||||
|
||||
dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef"));
|
||||
|
||||
|
||||
@ -1,55 +1,65 @@
|
||||
volScalarField rUA = 1.0/UEqn().A();
|
||||
U = rUA*UEqn().H();
|
||||
UEqn.clear();
|
||||
|
||||
phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
|
||||
bool closedVolume = adjustPhi(phi, U, p);
|
||||
phi -= fvc::interpolate(rho*gh*rUA)*fvc::snGrad(rho)*mesh.magSf();
|
||||
|
||||
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
||||
{
|
||||
fvScalarMatrix pdEqn
|
||||
(
|
||||
fvm::laplacian(rho*rUA, pd) == fvc::div(phi)
|
||||
);
|
||||
volScalarField rUA = 1.0/UEqn().A();
|
||||
surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA));
|
||||
|
||||
pdEqn.setReference(pdRefCell, pdRefValue);
|
||||
// retain the residual from the first iteration
|
||||
if (nonOrth == 0)
|
||||
U = rUA*UEqn().H();
|
||||
UEqn.clear();
|
||||
|
||||
phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
|
||||
bool closedVolume = adjustPhi(phi, U, p);
|
||||
surfaceScalarField buoyancyPhi = ghf*fvc::snGrad(rho)*rhorUAf*mesh.magSf();
|
||||
phi -= buoyancyPhi;
|
||||
|
||||
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
||||
{
|
||||
eqnResidual = pdEqn.solve().initialResidual();
|
||||
maxResidual = max(eqnResidual, maxResidual);
|
||||
}
|
||||
else
|
||||
{
|
||||
pdEqn.solve();
|
||||
fvScalarMatrix pdEqn
|
||||
(
|
||||
fvm::laplacian(rhorUAf, pd) == fvc::div(phi)
|
||||
);
|
||||
|
||||
pdEqn.setReference(pdRefCell, pdRefValue);
|
||||
|
||||
// retain the residual from the first iteration
|
||||
if (nonOrth == 0)
|
||||
{
|
||||
eqnResidual = pdEqn.solve().initialResidual();
|
||||
maxResidual = max(eqnResidual, maxResidual);
|
||||
}
|
||||
else
|
||||
{
|
||||
pdEqn.solve();
|
||||
}
|
||||
|
||||
if (nonOrth == nNonOrthCorr)
|
||||
{
|
||||
// Calculate the conservative fluxes
|
||||
phi -= pdEqn.flux();
|
||||
|
||||
// Explicitly relax pressure for momentum corrector
|
||||
pd.relax();
|
||||
|
||||
// Correct the momentum source with the pressure gradient flux
|
||||
// calculated from the relaxed pressure
|
||||
U -= rUA*fvc::reconstruct((buoyancyPhi + pdEqn.flux())/rhorUAf);
|
||||
U.correctBoundaryConditions();
|
||||
}
|
||||
}
|
||||
|
||||
if (nonOrth == nNonOrthCorr)
|
||||
#include "continuityErrs.H"
|
||||
|
||||
p == pd + rho*gh + pRef;
|
||||
|
||||
// For closed-volume cases adjust the pressure and density levels
|
||||
// to obey overall mass continuity
|
||||
if (closedVolume)
|
||||
{
|
||||
phi -= pdEqn.flux();
|
||||
p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
|
||||
/fvc::domainIntegrate(thermo->psi());
|
||||
}
|
||||
}
|
||||
|
||||
#include "continuityErrs.H"
|
||||
rho = thermo->rho();
|
||||
rho.relax();
|
||||
Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl;
|
||||
|
||||
// Explicitly relax pressure for momentum corrector
|
||||
pd.relax();
|
||||
|
||||
p = pd + rho*gh + pRef;
|
||||
|
||||
U -= rUA*(fvc::grad(pd) + fvc::grad(rho)*gh);
|
||||
U.correctBoundaryConditions();
|
||||
|
||||
// For closed-volume cases adjust the pressure and density levels
|
||||
// to obey overall mass continuity
|
||||
if (closedVolume)
|
||||
{
|
||||
p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
|
||||
/fvc::domainIntegrate(thermo->psi());
|
||||
pd == p - (rho*gh + pRef);
|
||||
}
|
||||
|
||||
rho = thermo->rho();
|
||||
rho.relax();
|
||||
Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
EXE_INC = \
|
||||
-I../buoyantSimpleFoam \
|
||||
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
|
||||
-I$(LIB_SRC)/turbulenceModels \
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
// Solve the Momentum equation
|
||||
|
||||
tmp<fvVectorMatrix> UEqn
|
||||
(
|
||||
fvm::div(phi, U)
|
||||
- fvm::Sp(fvc::div(phi), U)
|
||||
+ turbulence->divDevRhoReff(U)
|
||||
);
|
||||
|
||||
UEqn().relax();
|
||||
|
||||
eqnResidual = solve
|
||||
(
|
||||
UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh
|
||||
).initialResidual();
|
||||
|
||||
maxResidual = max(eqnResidual, maxResidual);
|
||||
|
||||
@ -54,6 +54,7 @@
|
||||
|
||||
Info<< "Calculating field g.h\n" << endl;
|
||||
volScalarField gh("gh", g & mesh.C());
|
||||
surfaceScalarField ghf("gh", g & mesh.Cf());
|
||||
|
||||
dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef"));
|
||||
|
||||
|
||||
@ -1,54 +0,0 @@
|
||||
volScalarField rUA = 1.0/UEqn().A();
|
||||
U = rUA*UEqn().H();
|
||||
UEqn.clear();
|
||||
phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
|
||||
bool closedVolume = adjustPhi(phi, U, p);
|
||||
phi -= fvc::interpolate(rho*gh*rUA)*fvc::snGrad(rho)*mesh.magSf();
|
||||
|
||||
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
||||
{
|
||||
fvScalarMatrix pdEqn
|
||||
(
|
||||
fvm::laplacian(rho*rUA, pd) == fvc::div(phi)
|
||||
);
|
||||
|
||||
pdEqn.setReference(pdRefCell, pdRefValue);
|
||||
// retain the residual from the first iteration
|
||||
if (nonOrth == 0)
|
||||
{
|
||||
eqnResidual = pdEqn.solve().initialResidual();
|
||||
maxResidual = max(eqnResidual, maxResidual);
|
||||
}
|
||||
else
|
||||
{
|
||||
pdEqn.solve();
|
||||
}
|
||||
|
||||
if (nonOrth == nNonOrthCorr)
|
||||
{
|
||||
phi -= pdEqn.flux();
|
||||
}
|
||||
}
|
||||
|
||||
#include "continuityErrs.H"
|
||||
|
||||
// Explicitly relax pressure for momentum corrector
|
||||
pd.relax();
|
||||
|
||||
p = pd + rho*gh + pRef;
|
||||
|
||||
U -= rUA*(fvc::grad(pd) + fvc::grad(rho)*gh);
|
||||
U.correctBoundaryConditions();
|
||||
|
||||
// For closed-volume cases adjust the pressure and density levels
|
||||
// to obey overall mass continuity
|
||||
if (closedVolume)
|
||||
{
|
||||
p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
|
||||
/fvc::domainIntegrate(thermo->psi());
|
||||
pd == p - (rho*gh + pRef);
|
||||
}
|
||||
|
||||
rho = thermo->rho();
|
||||
rho.relax();
|
||||
Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl;
|
||||
@ -7,6 +7,8 @@ derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemper
|
||||
derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C
|
||||
derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C
|
||||
|
||||
fluid/compressibleCourantNo.C
|
||||
|
||||
chtMultiRegionFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/chtMultiRegionFoam
|
||||
|
||||
@ -36,16 +36,10 @@ Description
|
||||
#include "turbulenceModel.H"
|
||||
#include "fixedGradientFvPatchFields.H"
|
||||
#include "regionProperties.H"
|
||||
#include "compressibleCourantNo.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "solveContinuityEquation.C"
|
||||
#include "solveMomentumEquation.C"
|
||||
#include "compressibleContinuityErrors.C"
|
||||
#include "solvePressureDifferenceEquation.C"
|
||||
#include "solveEnthalpyEquation.C"
|
||||
#include "compressibleCourantNo.C"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
@ -58,7 +52,6 @@ int main(int argc, char *argv[])
|
||||
# include "createSolidMeshes.H"
|
||||
|
||||
# include "createFluidFields.H"
|
||||
|
||||
# include "createSolidFields.H"
|
||||
|
||||
# include "initContinuityErrs.H"
|
||||
@ -89,6 +82,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "\nSolving for fluid region "
|
||||
<< fluidRegions[i].name() << endl;
|
||||
# include "setRegionFluidFields.H"
|
||||
# include "readFluidMultiRegionPISOControls.H"
|
||||
# include "solveFluid.H"
|
||||
}
|
||||
@ -97,6 +91,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "\nSolving for solid region "
|
||||
<< solidRegions[i].name() << endl;
|
||||
# include "setRegionSolidFields.H"
|
||||
# include "readSolidMultiRegionPISOControls.H"
|
||||
# include "solveSolid.H"
|
||||
}
|
||||
|
||||
@ -1,10 +1,25 @@
|
||||
tmp<fvVectorMatrix> UEqn = solveMomentumEquation
|
||||
// Solve the Momentum equation
|
||||
tmp<fvVectorMatrix> UEqn
|
||||
(
|
||||
momentumPredictor,
|
||||
Uf[i],
|
||||
rhof[i],
|
||||
phif[i],
|
||||
pdf[i],
|
||||
ghf[i],
|
||||
turb[i]
|
||||
fvm::ddt(rho, U)
|
||||
+ fvm::div(phi, U)
|
||||
+ turb.divDevRhoReff(U)
|
||||
);
|
||||
|
||||
UEqn().relax();
|
||||
|
||||
if (momentumPredictor)
|
||||
{
|
||||
solve
|
||||
(
|
||||
UEqn()
|
||||
==
|
||||
-fvc::reconstruct
|
||||
(
|
||||
(
|
||||
fvc::snGrad(pd)
|
||||
+ ghf*fvc::snGrad(rho)
|
||||
) * mesh.magSf()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Continuity errors for fluid meshes
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void compressibleContinuityErrors
|
||||
(
|
||||
scalar& cumulativeContErr,
|
||||
const volScalarField& rho,
|
||||
const basicThermo& thermo
|
||||
)
|
||||
{
|
||||
dimensionedScalar totalMass = fvc::domainIntegrate(rho);
|
||||
|
||||
scalar sumLocalContErr =
|
||||
(
|
||||
fvc::domainIntegrate(mag(rho - thermo.rho()))/totalMass
|
||||
).value();
|
||||
|
||||
scalar globalContErr =
|
||||
(
|
||||
fvc::domainIntegrate(rho - thermo.rho())/totalMass
|
||||
).value();
|
||||
|
||||
cumulativeContErr += globalContErr;
|
||||
|
||||
const word& regionName = rho.mesh().name();
|
||||
|
||||
Info<< "time step continuity errors (" << regionName << ")"
|
||||
<< ": sum local = " << sumLocalContErr
|
||||
<< ", global = " << globalContErr
|
||||
<< ", cumulative = " << cumulativeContErr
|
||||
<< endl;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
{
|
||||
dimensionedScalar totalMass = fvc::domainIntegrate(rho);
|
||||
|
||||
scalar sumLocalContErr =
|
||||
(
|
||||
fvc::domainIntegrate(mag(rho - thermo.rho()))/totalMass
|
||||
).value();
|
||||
|
||||
scalar globalContErr =
|
||||
(
|
||||
fvc::domainIntegrate(rho - thermo.rho())/totalMass
|
||||
).value();
|
||||
|
||||
cumulativeContErr[i] += globalContErr;
|
||||
|
||||
Info<< "time step continuity errors (" << mesh.name() << ")"
|
||||
<< ": sum local = " << sumLocalContErr
|
||||
<< ", global = " << globalContErr
|
||||
<< ", cumulative = " << cumulativeContErr[i]
|
||||
<< endl;
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -22,13 +22,12 @@ License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Calculates and outputs the mean and maximum Courant Numbers for the fluid
|
||||
regions
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
scalar compressibleCourantNo
|
||||
#include "compressibleCourantNo.H"
|
||||
#include "fvc.H"
|
||||
|
||||
Foam::scalar Foam::compressibleCourantNo
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const Time& runTime,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,15 +23,27 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Solve continuity equation
|
||||
Calculates and outputs the mean and maximum Courant Numbers for the fluid
|
||||
regions
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void solveContinuityEquation
|
||||
(
|
||||
volScalarField& rho,
|
||||
const surfaceScalarField& phi
|
||||
)
|
||||
#ifndef compressibleCourantNo_H
|
||||
#define compressibleCourantNo_H
|
||||
|
||||
#include "fvMesh.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
solve(fvm::ddt(rho) + fvc::div(phi));
|
||||
scalar compressibleCourantNo
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const Time& runTime,
|
||||
const volScalarField& rho,
|
||||
const surfaceScalarField& phi
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -7,8 +7,8 @@
|
||||
(
|
||||
fluidRegions[regionI],
|
||||
runTime,
|
||||
rhof[regionI],
|
||||
phif[regionI]
|
||||
rhoFluid[regionI],
|
||||
phiFluid[regionI]
|
||||
),
|
||||
CoNum
|
||||
);
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
// Initialise fluid field pointer lists
|
||||
PtrList<basicThermo> thermof(fluidRegions.size());
|
||||
PtrList<volScalarField> rhof(fluidRegions.size());
|
||||
PtrList<volScalarField> Kf(fluidRegions.size());
|
||||
PtrList<volVectorField> Uf(fluidRegions.size());
|
||||
PtrList<surfaceScalarField> phif(fluidRegions.size());
|
||||
PtrList<compressible::turbulenceModel> turb(fluidRegions.size());
|
||||
PtrList<volScalarField> DpDtf(fluidRegions.size());
|
||||
PtrList<volScalarField> ghf(fluidRegions.size());
|
||||
PtrList<volScalarField> pdf(fluidRegions.size());
|
||||
PtrList<basicThermo> thermoFluid(fluidRegions.size());
|
||||
PtrList<volScalarField> rhoFluid(fluidRegions.size());
|
||||
PtrList<volScalarField> KFluid(fluidRegions.size());
|
||||
PtrList<volVectorField> UFluid(fluidRegions.size());
|
||||
PtrList<surfaceScalarField> phiFluid(fluidRegions.size());
|
||||
PtrList<compressible::turbulenceModel> turbulence(fluidRegions.size());
|
||||
PtrList<volScalarField> DpDtFluid(fluidRegions.size());
|
||||
PtrList<volScalarField> ghFluid(fluidRegions.size());
|
||||
PtrList<surfaceScalarField> ghfFluid(fluidRegions.size());
|
||||
PtrList<volScalarField> pdFluid(fluidRegions.size());
|
||||
|
||||
List<scalar> initialMassf(fluidRegions.size());
|
||||
List<scalar> initialMassFluid(fluidRegions.size());
|
||||
|
||||
dimensionedScalar pRef
|
||||
(
|
||||
@ -24,8 +25,8 @@
|
||||
Info<< "*** Reading fluid mesh thermophysical properties for region "
|
||||
<< fluidRegions[i].name() << nl << endl;
|
||||
|
||||
Info<< " Adding to pdf\n" << endl;
|
||||
pdf.set
|
||||
Info<< " Adding to pdFluid\n" << endl;
|
||||
pdFluid.set
|
||||
(
|
||||
i,
|
||||
new volScalarField
|
||||
@ -42,16 +43,15 @@
|
||||
)
|
||||
);
|
||||
|
||||
Info<< " Adding to thermof\n" << endl;
|
||||
|
||||
thermof.set
|
||||
Info<< " Adding to thermoFluid\n" << endl;
|
||||
thermoFluid.set
|
||||
(
|
||||
i,
|
||||
basicThermo::New(fluidRegions[i]).ptr()
|
||||
);
|
||||
|
||||
Info<< " Adding to rhof\n" << endl;
|
||||
rhof.set
|
||||
Info<< " Adding to rhoFluid\n" << endl;
|
||||
rhoFluid.set
|
||||
(
|
||||
i,
|
||||
new volScalarField
|
||||
@ -64,12 +64,12 @@
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
thermof[i].rho()
|
||||
thermoFluid[i].rho()
|
||||
)
|
||||
);
|
||||
|
||||
Info<< " Adding to Kf\n" << endl;
|
||||
Kf.set
|
||||
Info<< " Adding to KFluid\n" << endl;
|
||||
KFluid.set
|
||||
(
|
||||
i,
|
||||
new volScalarField
|
||||
@ -82,12 +82,12 @@
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
thermof[i].Cp()*thermof[i].alpha()
|
||||
thermoFluid[i].Cp()*thermoFluid[i].alpha()
|
||||
)
|
||||
);
|
||||
|
||||
Info<< " Adding to Uf\n" << endl;
|
||||
Uf.set
|
||||
Info<< " Adding to UFluid\n" << endl;
|
||||
UFluid.set
|
||||
(
|
||||
i,
|
||||
new volVectorField
|
||||
@ -104,8 +104,8 @@
|
||||
)
|
||||
);
|
||||
|
||||
Info<< " Adding to phif\n" << endl;
|
||||
phif.set
|
||||
Info<< " Adding to phiFluid\n" << endl;
|
||||
phiFluid.set
|
||||
(
|
||||
i,
|
||||
new surfaceScalarField
|
||||
@ -118,29 +118,29 @@
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
linearInterpolate(rhof[i]*Uf[i])
|
||||
linearInterpolate(rhoFluid[i]*UFluid[i])
|
||||
& fluidRegions[i].Sf()
|
||||
)
|
||||
);
|
||||
|
||||
Info<< " Adding to turb\n" << endl;
|
||||
turb.set
|
||||
Info<< " Adding to turbulence\n" << endl;
|
||||
turbulence.set
|
||||
(
|
||||
i,
|
||||
autoPtr<compressible::turbulenceModel>
|
||||
(
|
||||
compressible::turbulenceModel::New
|
||||
(
|
||||
rhof[i],
|
||||
Uf[i],
|
||||
phif[i],
|
||||
thermof[i]
|
||||
rhoFluid[i],
|
||||
UFluid[i],
|
||||
phiFluid[i],
|
||||
thermoFluid[i]
|
||||
)
|
||||
).ptr()
|
||||
);
|
||||
|
||||
Info<< " Adding to DpDtf\n" << endl;
|
||||
DpDtf.set
|
||||
Info<< " Adding to DpDtFluid\n" << endl;
|
||||
DpDtFluid.set
|
||||
(
|
||||
i,
|
||||
new volScalarField
|
||||
@ -150,9 +150,9 @@
|
||||
surfaceScalarField
|
||||
(
|
||||
"phiU",
|
||||
phif[i]/fvc::interpolate(rhof[i])
|
||||
phiFluid[i]/fvc::interpolate(rhoFluid[i])
|
||||
),
|
||||
thermof[i].p()
|
||||
thermoFluid[i].p()
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -162,8 +162,8 @@
|
||||
("environmentalProperties");
|
||||
dimensionedVector g(environmentalProperties.lookup("g"));
|
||||
|
||||
Info<< " Adding to ghf\n" << endl;
|
||||
ghf.set
|
||||
Info<< " Adding to ghFluid\n" << endl;
|
||||
ghFluid.set
|
||||
(
|
||||
i,
|
||||
new volScalarField
|
||||
@ -172,12 +172,21 @@
|
||||
g & fluidRegions[i].C()
|
||||
)
|
||||
);
|
||||
ghfFluid.set
|
||||
(
|
||||
i,
|
||||
new surfaceScalarField
|
||||
(
|
||||
"ghf",
|
||||
g & fluidRegions[i].Cf()
|
||||
)
|
||||
);
|
||||
|
||||
Info<< " Updating p from pd\n" << endl;
|
||||
thermof[i].p() == pdf[i] + rhof[i]*ghf[i] + pRef;
|
||||
thermof[i].correct();
|
||||
thermoFluid[i].p() == pdFluid[i] + rhoFluid[i]*ghFluid[i] + pRef;
|
||||
thermoFluid[i].correct();
|
||||
|
||||
initialMassf[i] = fvc::domainIntegrate(rhof[i]).value();
|
||||
initialMassFluid[i] = fvc::domainIntegrate(rhoFluid[i]).value();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,9 +1,17 @@
|
||||
solveEnthalpyEquation
|
||||
{
|
||||
tmp<fvScalarMatrix> hEqn
|
||||
(
|
||||
rhof[i],
|
||||
DpDtf[i],
|
||||
phif[i],
|
||||
turb[i],
|
||||
thermof[i]
|
||||
fvm::ddt(rho, h)
|
||||
+ fvm::div(phi, h)
|
||||
- fvm::laplacian(turb.alphaEff(), h)
|
||||
==
|
||||
DpDt
|
||||
);
|
||||
hEqn().relax();
|
||||
hEqn().solve();
|
||||
|
||||
thermo.correct();
|
||||
|
||||
Info<< "Min/max T:" << min(thermo.T()) << ' ' << max(thermo.T())
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
List<scalar> cumulativeContErr(fluidRegions.size(), 0.0);
|
||||
@ -1,60 +1,75 @@
|
||||
{
|
||||
bool closedVolume = false;
|
||||
bool closedVolume = pd.needReference();
|
||||
|
||||
rhof[i] = thermof[i].rho();
|
||||
rho = thermo.rho();
|
||||
|
||||
volScalarField rUA = 1.0/UEqn().A();
|
||||
Uf[i] = rUA*UEqn().H();
|
||||
surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA));
|
||||
|
||||
phif[i] =
|
||||
fvc::interpolate(rhof[i])
|
||||
U = rUA*UEqn().H();
|
||||
|
||||
surfaceScalarField phiU
|
||||
(
|
||||
fvc::interpolate(rho)
|
||||
*(
|
||||
(fvc::interpolate(Uf[i]) & fluidRegions[i].Sf())
|
||||
+ fvc::ddtPhiCorr(rUA, rhof[i], Uf[i], phif[i])
|
||||
(fvc::interpolate(U) & mesh.Sf())
|
||||
+ fvc::ddtPhiCorr(rUA, rho, U, phi)
|
||||
)
|
||||
- fvc::interpolate(rhof[i]*rUA*ghf[i])
|
||||
*fvc::snGrad(rhof[i])
|
||||
*fluidRegions[i].magSf();
|
||||
);
|
||||
|
||||
// Solve pressure difference
|
||||
# include "pdEqn.H"
|
||||
phi = phiU - ghf*fvc::snGrad(rho)*rhorUAf*mesh.magSf();
|
||||
|
||||
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
||||
{
|
||||
fvScalarMatrix pdEqn
|
||||
(
|
||||
fvm::ddt(psi, pd)
|
||||
+ fvc::ddt(psi)*pRef
|
||||
+ fvc::ddt(psi, rho)*gh
|
||||
+ fvc::div(phi)
|
||||
- fvm::laplacian(rho*rUA, pd)
|
||||
);
|
||||
|
||||
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
|
||||
{
|
||||
pdEqn.solve(mesh.solver(pd.name() + "Final"));
|
||||
}
|
||||
else
|
||||
{
|
||||
pdEqn.solve(mesh.solver(pd.name()));
|
||||
}
|
||||
|
||||
if (nonOrth == nNonOrthCorr)
|
||||
{
|
||||
phi += pdEqn.flux();
|
||||
}
|
||||
}
|
||||
|
||||
// Correct velocity field
|
||||
U += rUA*fvc::reconstruct((phi - phiU)/rhorUAf);
|
||||
U.correctBoundaryConditions();
|
||||
|
||||
// Update pressure field (including bc)
|
||||
p == pd + rho*gh + pRef;
|
||||
DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
|
||||
|
||||
// Solve continuity
|
||||
# include "rhoEqn.H"
|
||||
|
||||
// Update pressure field (including bc)
|
||||
thermof[i].p() == pdf[i] + rhof[i]*ghf[i] + pRef;
|
||||
DpDtf[i] = fvc::DDt
|
||||
(
|
||||
surfaceScalarField("phiU", phif[i]/fvc::interpolate(rhof[i])),
|
||||
thermof[i].p()
|
||||
);
|
||||
|
||||
// Update continuity errors
|
||||
compressibleContinuityErrors(cumulativeContErr, rhof[i], thermof[i]);
|
||||
|
||||
// Correct velocity field
|
||||
Uf[i] -= rUA*(fvc::grad(pdf[i]) + fvc::grad(rhof[i])*ghf[i]);
|
||||
Uf[i].correctBoundaryConditions();
|
||||
# include "compressibleContinuityErrors.H"
|
||||
|
||||
// For closed-volume cases adjust the pressure and density levels
|
||||
// to obey overall mass continuity
|
||||
if (closedVolume)
|
||||
{
|
||||
thermof[i].p() +=
|
||||
(
|
||||
dimensionedScalar
|
||||
(
|
||||
"massIni",
|
||||
dimMass,
|
||||
initialMassf[i]
|
||||
)
|
||||
- fvc::domainIntegrate(thermof[i].psi()*thermof[i].p())
|
||||
)/fvc::domainIntegrate(thermof[i].psi());
|
||||
pdf[i] == thermof[i].p() - (rhof[i]*ghf[i] + pRef);
|
||||
rhof[i] = thermof[i].rho();
|
||||
p += (massIni - fvc::domainIntegrate(psi*p))/fvc::domainIntegrate(psi);
|
||||
rho = thermo.rho();
|
||||
}
|
||||
|
||||
// Update thermal conductivity
|
||||
Kf[i] = thermof[i].Cp()*turb[i].alphaEff();
|
||||
K = thermoFluid[i].Cp()*turb.alphaEff();
|
||||
|
||||
// Update pd (including bc)
|
||||
pd == p - (rho*gh + pRef);
|
||||
}
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
solvePressureDifferenceEquation
|
||||
(
|
||||
corr,
|
||||
nCorr,
|
||||
nNonOrthCorr,
|
||||
closedVolume,
|
||||
pdf[i],
|
||||
pRef,
|
||||
rhof[i],
|
||||
thermof[i].psi(),
|
||||
rUA,
|
||||
ghf[i],
|
||||
phif[i]
|
||||
);
|
||||
@ -1 +1 @@
|
||||
solveContinuityEquation(rhof[i], phif[i]);
|
||||
solve(fvm::ddt(rho) + fvc::div(phi));
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
if (adjustTimeStep)
|
||||
{
|
||||
if (CoNum > SMALL)
|
||||
{
|
||||
runTime.setDeltaT
|
||||
(
|
||||
min
|
||||
(
|
||||
maxCo*runTime.deltaT().value()/CoNum,
|
||||
maxDeltaT
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
const fvMesh& mesh = fluidRegions[i];
|
||||
|
||||
basicThermo& thermo = thermoFluid[i];
|
||||
volScalarField& rho = rhoFluid[i];
|
||||
volScalarField& K = KFluid[i];
|
||||
volVectorField& U = UFluid[i];
|
||||
surfaceScalarField phi = phiFluid[i];
|
||||
compressible::turbulenceModel& turb = turbulence[i];
|
||||
volScalarField& DpDt = DpDtFluid[i];
|
||||
const volScalarField& gh = ghFluid[i];
|
||||
const surfaceScalarField& ghf = ghfFluid[i];
|
||||
volScalarField& pd = pdFluid[i];
|
||||
|
||||
volScalarField& p = thermo.p();
|
||||
const volScalarField& psi = thermo.psi();
|
||||
volScalarField& h = thermo.h();
|
||||
|
||||
const dimensionedScalar massIni("massIni", dimMass, initialMassFluid[i]);
|
||||
@ -1,56 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Solve enthalpy equation
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void solveEnthalpyEquation
|
||||
(
|
||||
const volScalarField& rho,
|
||||
const volScalarField& DpDt,
|
||||
const surfaceScalarField& phi,
|
||||
const compressible::turbulenceModel& turb,
|
||||
basicThermo& thermo
|
||||
)
|
||||
{
|
||||
volScalarField& h = thermo.h();
|
||||
|
||||
tmp<fvScalarMatrix> hEqn
|
||||
(
|
||||
fvm::ddt(rho, h)
|
||||
+ fvm::div(phi, h)
|
||||
- fvm::laplacian(turb.alphaEff(), h)
|
||||
==
|
||||
DpDt
|
||||
);
|
||||
hEqn().relax();
|
||||
hEqn().solve();
|
||||
|
||||
thermo.correct();
|
||||
|
||||
Info<< "Min/max T:" << min(thermo.T()) << ' ' << max(thermo.T())
|
||||
<< endl;
|
||||
}
|
||||
@ -12,4 +12,4 @@
|
||||
# include "pEqn.H"
|
||||
}
|
||||
}
|
||||
turb[i].correct();
|
||||
turb.correct();
|
||||
|
||||
@ -1,57 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Solve momentum equation and return matrix for use in pressure equation
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
tmp<fvVectorMatrix> solveMomentumEquation
|
||||
(
|
||||
const bool momentumPredictor,
|
||||
volVectorField& U,
|
||||
const volScalarField& rho,
|
||||
const surfaceScalarField& phi,
|
||||
const volScalarField& pd,
|
||||
const volScalarField& gh,
|
||||
const compressible::turbulenceModel& turb
|
||||
)
|
||||
{
|
||||
// Solve the Momentum equation
|
||||
tmp<fvVectorMatrix> UEqn
|
||||
(
|
||||
fvm::ddt(rho, U)
|
||||
+ fvm::div(phi, U)
|
||||
+ turb.divDevRhoReff(U)
|
||||
);
|
||||
|
||||
UEqn().relax();
|
||||
|
||||
if (momentumPredictor)
|
||||
{
|
||||
solve(UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh);
|
||||
}
|
||||
|
||||
return UEqn;
|
||||
}
|
||||
@ -1,73 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Solve pressure difference equation
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void solvePressureDifferenceEquation
|
||||
(
|
||||
const label corr,
|
||||
const label nCorr,
|
||||
const label nNonOrthCorr,
|
||||
bool& closedVolume,
|
||||
volScalarField& pd,
|
||||
const dimensionedScalar& pRef,
|
||||
const volScalarField& rho,
|
||||
const volScalarField& psi,
|
||||
const volScalarField& rUA,
|
||||
const volScalarField& gh,
|
||||
surfaceScalarField& phi
|
||||
)
|
||||
{
|
||||
closedVolume = pd.needReference();
|
||||
|
||||
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
||||
{
|
||||
fvScalarMatrix pdEqn
|
||||
(
|
||||
fvm::ddt(psi, pd)
|
||||
+ fvc::ddt(psi)*pRef
|
||||
+ fvc::ddt(psi, rho)*gh
|
||||
+ fvc::div(phi)
|
||||
- fvm::laplacian(rho*rUA, pd)
|
||||
);
|
||||
|
||||
//pdEqn.solve();
|
||||
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
|
||||
{
|
||||
pdEqn.solve(pd.mesh().solver(pd.name() + "Final"));
|
||||
}
|
||||
else
|
||||
{
|
||||
pdEqn.solve(pd.mesh().solver(pd.name()));
|
||||
}
|
||||
|
||||
if (nonOrth == nNonOrthCorr)
|
||||
{
|
||||
phi += pdEqn.flux();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
// fvMesh& mesh = solidRegions[i];
|
||||
|
||||
volScalarField& rho = rhos[i];
|
||||
volScalarField& cp = cps[i];
|
||||
volScalarField& K = Ks[i];
|
||||
volScalarField& T = Ts[i];
|
||||
@ -3,10 +3,9 @@
|
||||
{
|
||||
solve
|
||||
(
|
||||
fvm::ddt(rhosCps[i], Ts[i]) - fvm::laplacian(Ks[i], Ts[i])
|
||||
fvm::ddt(rho*cp, T) - fvm::laplacian(K, T)
|
||||
);
|
||||
}
|
||||
|
||||
Info<< "Min/max T:" << min(Ts[i]) << ' ' << max(Ts[i])
|
||||
<< endl;
|
||||
Info<< "Min/max T:" << min(T) << ' ' << max(T) << endl;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
phic = min(interface.cAlpha()*phic, max(phic));
|
||||
surfaceScalarField phir = phic*interface.nHatf();
|
||||
|
||||
for (int gCorr=0; gCorr<nAlphaCorr; gCorr++)
|
||||
for (int aCorr=0; aCorr<nAlphaCorr; aCorr++)
|
||||
{
|
||||
surfaceScalarField phiAlpha =
|
||||
fvc::flux
|
||||
|
||||
@ -81,17 +81,20 @@ Foam::phaseModel::phaseModel
|
||||
{
|
||||
Info<< "Reading face flux field " << phiName << endl;
|
||||
|
||||
phiPtr_ = new surfaceScalarField
|
||||
phiPtr_.reset
|
||||
(
|
||||
IOobject
|
||||
new surfaceScalarField
|
||||
(
|
||||
phiName,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
IOobject
|
||||
(
|
||||
phiName,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -112,18 +115,21 @@ Foam::phaseModel::phaseModel
|
||||
}
|
||||
}
|
||||
|
||||
phiPtr_ = new surfaceScalarField
|
||||
phiPtr_.reset
|
||||
(
|
||||
IOobject
|
||||
new surfaceScalarField
|
||||
(
|
||||
phiName,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
fvc::interpolate(U_) & mesh.Sf(),
|
||||
phiTypes
|
||||
IOobject
|
||||
(
|
||||
phiName,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
fvc::interpolate(U_) & mesh.Sf(),
|
||||
phiTypes
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ class phaseModel
|
||||
volVectorField U_;
|
||||
|
||||
//- Fluxes
|
||||
surfaceScalarField* phiPtr_;
|
||||
autoPtr<surfaceScalarField> phiPtr_;
|
||||
|
||||
|
||||
public:
|
||||
@ -133,12 +133,12 @@ public:
|
||||
|
||||
const surfaceScalarField& phi() const
|
||||
{
|
||||
return *phiPtr_;
|
||||
return phiPtr_();
|
||||
}
|
||||
|
||||
surfaceScalarField& phi()
|
||||
{
|
||||
return *phiPtr_;
|
||||
return phiPtr_();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -111,6 +111,33 @@ int main(int argc, char *argv[])
|
||||
Info<< "setD : " << setD << endl;
|
||||
Info<< "setB ^ setC ^ setD : " << (setB ^ setC ^ setD) << endl;
|
||||
|
||||
// test operator[]
|
||||
|
||||
Info<< "setD : " << setD << endl;
|
||||
if (setD[0])
|
||||
{
|
||||
Info<< "setD has 0" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "setD has no 0" << endl;
|
||||
}
|
||||
|
||||
|
||||
if (setD[11])
|
||||
{
|
||||
Info<< "setD has 11" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "setD has no 0" << endl;
|
||||
}
|
||||
|
||||
Info<< "setD : " << setD << endl;
|
||||
|
||||
// this doesn't work (yet?)
|
||||
// setD[12] = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,6 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool changed;
|
||||
Info<< "PackedList max_bits() = " << PackedList<0>::max_bits() << nl;
|
||||
|
||||
Info<< "\ntest allocation with value\n";
|
||||
@ -46,11 +45,50 @@ int main(int argc, char *argv[])
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest assign uniform value\n";
|
||||
list1 = 2;
|
||||
list1 = 3;
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest assign uniform value (with overflow)\n";
|
||||
list1 = -1;
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest assign between references\n";
|
||||
list1[2] = 3;
|
||||
list1[4] = list1[2];
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest assign between references, with chaining\n";
|
||||
list1[4] = list1[2] = 1;
|
||||
list1.print(Info);
|
||||
|
||||
{
|
||||
const PackedList<3>& constLst = list1;
|
||||
Info<< "\ntest operator[] const with out-of-range index\n";
|
||||
constLst.print(Info);
|
||||
if (!constLst[20])
|
||||
{
|
||||
Info<< "[20] is false (expected) list size should be unchanged (const)\n";
|
||||
}
|
||||
constLst.print(Info);
|
||||
|
||||
Info<< "\ntest operator[] non-const with out-of-range index\n";
|
||||
if (!list1[20])
|
||||
{
|
||||
Info<< "[20] is false (expected) but list was resized?? (non-const)\n";
|
||||
}
|
||||
list1.print(Info);
|
||||
}
|
||||
|
||||
|
||||
Info<< "\ntest operator[] with out-of-range index\n";
|
||||
if (!list1[20])
|
||||
{
|
||||
Info<< "[20] is false, as expected\n";
|
||||
}
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest resize with value (without reallocation)\n";
|
||||
list1.resize(6, 3);
|
||||
list1.resize(8, list1.max_value());
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest set() function\n";
|
||||
@ -96,7 +134,7 @@ int main(int argc, char *argv[])
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest setCapacity() operation\n";
|
||||
list1.setCapacity(30);
|
||||
list1.setCapacity(100);
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest operator[] assignment\n";
|
||||
@ -108,7 +146,15 @@ int main(int argc, char *argv[])
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest setCapacity smaller\n";
|
||||
list1.setCapacity(32);
|
||||
list1.setCapacity(24);
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest resize much smaller\n";
|
||||
list1.resize(150);
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest trim\n";
|
||||
list1.trim();
|
||||
list1.print(Info);
|
||||
|
||||
// add in some misc values
|
||||
@ -118,37 +164,54 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\ntest iterator\n";
|
||||
PackedList<3>::iterator iter = list1.begin();
|
||||
Info<< "iterator:" << iter() << "\n";
|
||||
Info<< "begin():";
|
||||
iter.print(Info) << "\n";
|
||||
|
||||
Info<< "\ntest iterator operator=\n";
|
||||
changed = (iter = 5);
|
||||
|
||||
Info<< "iterator:" << iter() << "\n";
|
||||
Info<< "changed:" << changed << "\n";
|
||||
changed = (iter = 5);
|
||||
Info<< "changed:" << changed << "\n";
|
||||
iter() = 5;
|
||||
iter.print(Info);
|
||||
list1.print(Info);
|
||||
|
||||
iter = list1[31];
|
||||
Info<< "iterator:" << iter() << "\n";
|
||||
iter.print(Info);
|
||||
|
||||
|
||||
Info<< "\ntest get() method\n";
|
||||
Info<< "get(10):" << list1.get(10)
|
||||
<< " and list[10]:" << unsigned(list1[10]) << "\n";
|
||||
Info<< "get(10):" << list1.get(10) << " and list[10]:" << list1[10] << "\n";
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest iterator indexing\n";
|
||||
Info<< "end() ";
|
||||
list1.end().print(Info) << "\n";
|
||||
Info<< "cend() ";
|
||||
list1.cend().print(Info) << "\n";
|
||||
|
||||
for (iter = list1[31]; iter != list1.end(); ++iter)
|
||||
{
|
||||
iter.print(Info);
|
||||
Info<< "\ntest assignment of iterator\n";
|
||||
list1.print(Info);
|
||||
PackedList<3>::iterator cit = list1[25];
|
||||
cit.print(Info);
|
||||
list1.end().print(Info);
|
||||
}
|
||||
|
||||
Info<< "\ntest operator[] auto-vivify\n";
|
||||
const unsigned int val = list1[45];
|
||||
|
||||
Info<< "list[45]:" << val << "\n";
|
||||
list1.print(Info);
|
||||
for
|
||||
(
|
||||
PackedList<3>::iterator cit = list1[5];
|
||||
cit != list1.end();
|
||||
++cit
|
||||
)
|
||||
{
|
||||
cit.print(Info);
|
||||
}
|
||||
|
||||
// Info<< "\ntest operator[] auto-vivify\n";
|
||||
// const unsigned int val = list1[45];
|
||||
//
|
||||
// Info<< "list[45]:" << val << "\n";
|
||||
// list1[45] = list1.max_value();
|
||||
// Info<< "list[45]:" << list1[45] << "\n";
|
||||
// list1[49] = list1.max_value();
|
||||
// list1.print(Info);
|
||||
|
||||
|
||||
Info<< "\ntest copy constructor + append\n";
|
||||
@ -161,8 +224,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\ntest pattern that fills all bits\n";
|
||||
PackedList<4> list3(8, 8);
|
||||
list3[list3.size()-2] = 0;
|
||||
list3[list3.size()-1] = list3.max_value();
|
||||
|
||||
label pos = list3.size() - 1;
|
||||
|
||||
list3[pos--] = list3.max_value();
|
||||
list3[pos--] = 0;
|
||||
list3[pos--] = list3.max_value();
|
||||
list3.print(Info);
|
||||
|
||||
Info<< "removed final value: " << list3.remove() << endl;
|
||||
list3.print(Info);
|
||||
|
||||
Info<< "\n\nDone.\n";
|
||||
|
||||
3
applications/test/PackedList2/Make/files
Normal file
3
applications/test/PackedList2/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
PackedListTest2.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/PackedListTest2
|
||||
0
applications/test/PackedList2/Make/options
Normal file
0
applications/test/PackedList2/Make/options
Normal file
348
applications/test/PackedList2/PackedListTest2.C
Normal file
348
applications/test/PackedList2/PackedListTest2.C
Normal file
@ -0,0 +1,348 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Application
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "boolList.H"
|
||||
#include "PackedBoolList.H"
|
||||
#include "HashSet.H"
|
||||
#include "cpuTime.H"
|
||||
#include <vector>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const label n = 1000000;
|
||||
const label nIters = 1000;
|
||||
|
||||
unsigned int sum = 0;
|
||||
|
||||
PackedBoolList packed(n, 1);
|
||||
boolList unpacked(n, true);
|
||||
std::vector<bool> stlVector(n, true);
|
||||
|
||||
labelHashSet emptyHash;
|
||||
labelHashSet fullHash(1000);
|
||||
for(label i = 0; i < n; i++)
|
||||
{
|
||||
fullHash.insert(i);
|
||||
}
|
||||
|
||||
cpuTime timer;
|
||||
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
packed.resize(40);
|
||||
packed.shrink();
|
||||
packed.resize(n, 1);
|
||||
}
|
||||
Info<< "resize/shrink/resize:" << timer.cpuTimeIncrement() << " s\n\n";
|
||||
|
||||
// set every other bit on:
|
||||
Info<< "set every other bit on and count\n";
|
||||
packed.storage() = 0xAAAAAAAAu;
|
||||
|
||||
// Count packed
|
||||
sum = 0;
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
forAll(packed, i)
|
||||
{
|
||||
sum += packed[i];
|
||||
}
|
||||
}
|
||||
Info<< "Counting brute-force:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Count packed
|
||||
sum = 0;
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
sum += packed.count();
|
||||
}
|
||||
Info<< "Counting via count():" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Dummy addition
|
||||
sum = 0;
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
forAll(unpacked, i)
|
||||
{
|
||||
sum += i + 1;
|
||||
}
|
||||
}
|
||||
Info<< "Dummy loop:" << timer.cpuTimeIncrement() << " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
|
||||
//
|
||||
// Read
|
||||
//
|
||||
|
||||
// Read stl
|
||||
sum = 0;
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
for(unsigned int i = 0; i < stlVector.size(); i++)
|
||||
{
|
||||
sum += stlVector[i];
|
||||
}
|
||||
}
|
||||
Info<< "Reading stl:" << timer.cpuTimeIncrement() << " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read unpacked
|
||||
sum = 0;
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
forAll(unpacked, i)
|
||||
{
|
||||
sum += unpacked[i];
|
||||
}
|
||||
}
|
||||
Info<< "Reading unpacked:" << timer.cpuTimeIncrement() << " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read packed
|
||||
sum = 0;
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
forAll(packed, i)
|
||||
{
|
||||
sum += packed.get(i);
|
||||
}
|
||||
}
|
||||
Info<< "Reading packed using get:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read packed
|
||||
sum = 0;
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
forAll(packed, i)
|
||||
{
|
||||
sum += packed[i];
|
||||
}
|
||||
}
|
||||
Info<< "Reading packed using reference:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read via iterator
|
||||
sum = 0;
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
for
|
||||
(
|
||||
PackedBoolList::iterator it = packed.begin();
|
||||
it != packed.end();
|
||||
++it
|
||||
)
|
||||
{
|
||||
sum += it;
|
||||
}
|
||||
}
|
||||
Info<< "Reading packed using iterator:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read via iterator
|
||||
sum = 0;
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
for
|
||||
(
|
||||
PackedBoolList::const_iterator cit = packed.cbegin();
|
||||
cit != packed.cend();
|
||||
++cit
|
||||
)
|
||||
{
|
||||
sum += cit();
|
||||
}
|
||||
}
|
||||
Info<< "Reading packed using const_iterator():" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read empty hash
|
||||
sum = 0;
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
forAll(unpacked, i)
|
||||
{
|
||||
sum += emptyHash.found(i);
|
||||
}
|
||||
}
|
||||
Info<< "Reading empty labelHashSet:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read full hash
|
||||
sum = 0;
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
forAll(unpacked, i)
|
||||
{
|
||||
sum += fullHash.found(i);
|
||||
}
|
||||
}
|
||||
Info<< "Reading full labelHashSet:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
|
||||
|
||||
//
|
||||
// Write
|
||||
//
|
||||
|
||||
// Write stl
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
for (unsigned int i = 0; i < stlVector.size(); i++)
|
||||
{
|
||||
stlVector[i] = true;
|
||||
}
|
||||
}
|
||||
Info<< "Writing stl:" << timer.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
// Write unpacked
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
forAll(unpacked, i)
|
||||
{
|
||||
unpacked[i] = true;
|
||||
}
|
||||
}
|
||||
Info<< "Writing unpacked:" << timer.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
|
||||
// Write packed
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
forAll(packed, i)
|
||||
{
|
||||
packed[i] = 1;
|
||||
}
|
||||
}
|
||||
Info<< "Writing packed using reference:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
|
||||
|
||||
// Write packed
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
forAll(packed, i)
|
||||
{
|
||||
packed.set(i, 1);
|
||||
}
|
||||
}
|
||||
Info<< "Writing packed using set:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
|
||||
|
||||
// Write packed
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
for
|
||||
(
|
||||
PackedBoolList::iterator it = packed.begin();
|
||||
it != packed.end();
|
||||
++it
|
||||
)
|
||||
{
|
||||
it() = 1;
|
||||
}
|
||||
}
|
||||
Info<< "Writing packed using iterator:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
|
||||
|
||||
// Write packed
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
packed = 0;
|
||||
}
|
||||
Info<< "Writing packed uniform 0:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
|
||||
|
||||
// Write packed
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
packed = 1;
|
||||
}
|
||||
Info<< "Writing packed uniform 1:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
|
||||
|
||||
PackedList<3> oddPacked(n, 3);
|
||||
|
||||
// Write packed
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
packed = 0;
|
||||
}
|
||||
Info<< "Writing packed<3> uniform 0:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
|
||||
|
||||
// Write packed
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
packed = 1;
|
||||
}
|
||||
Info<< "Writing packed<3> uniform 1:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -31,6 +31,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fileName.H"
|
||||
#include "SubList.H"
|
||||
#include "IOstreams.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
@ -50,19 +51,55 @@ int main()
|
||||
|
||||
fileName pathName(wrdList);
|
||||
|
||||
Info<< "pathName = " << pathName << endl;
|
||||
Info<< "pathName.name() = " << pathName.name() << endl;
|
||||
Info<< "pathName.path() = " << pathName.path() << endl;
|
||||
Info<< "pathName.ext() = " << pathName.ext() << endl;
|
||||
Info<< "pathName = " << pathName << nl
|
||||
<< "pathName.name() = " << pathName.name() << nl
|
||||
<< "pathName.path() = " << pathName.path() << nl
|
||||
<< "pathName.ext() = " << pathName.ext() << endl;
|
||||
|
||||
Info<< "pathName.components() = " << pathName.components() << endl;
|
||||
Info<< "pathName.component(2) = " << pathName.component(2) << endl;
|
||||
Info<< "pathName.components() = " << pathName.components() << nl
|
||||
<< "pathName.component(2) = " << pathName.component(2) << nl
|
||||
<< endl;
|
||||
|
||||
// try with different combination
|
||||
for (label start = 0; start < wrdList.size(); ++start)
|
||||
{
|
||||
fileName instance, local;
|
||||
word name;
|
||||
|
||||
fileName path(SubList<word>(wrdList, wrdList.size()-start, start));
|
||||
fileName path2 = "." / path;
|
||||
|
||||
path.IOobjectComponents
|
||||
(
|
||||
instance,
|
||||
local,
|
||||
name
|
||||
);
|
||||
|
||||
Info<< "IOobjectComponents for " << path << nl
|
||||
<< " instance = " << instance << nl
|
||||
<< " local = " << local << nl
|
||||
<< " name = " << name << endl;
|
||||
|
||||
path2.IOobjectComponents
|
||||
(
|
||||
instance,
|
||||
local,
|
||||
name
|
||||
);
|
||||
|
||||
Info<< "IOobjectComponents for " << path2 << nl
|
||||
<< " instance = " << instance << nl
|
||||
<< " local = " << local << nl
|
||||
<< " name = " << name << endl;
|
||||
|
||||
}
|
||||
|
||||
// test findEtcFile
|
||||
Info<< "\n\nfindEtcFile tests:" << nl
|
||||
<< " controlDict => " << findEtcFile("controlDict") << nl
|
||||
<< " badName => " << findEtcFile("badName") << endl;
|
||||
|
||||
Info<< "This should emit a fatal error:" << endl;
|
||||
Info<< " badName(die) => " << findEtcFile("badName", true) << nl
|
||||
<< endl;
|
||||
|
||||
@ -464,6 +464,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createPolyMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
scalar minLen(readScalar(IStringStream(args.additionalArgs()[0])()));
|
||||
scalar angle(readScalar(IStringStream(args.additionalArgs()[1])()));
|
||||
@ -587,8 +588,12 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
runTime++;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
Info << "Writing collapsed mesh to time " << runTime.value() << endl;
|
||||
Info<< "Writing collapsed mesh to time " << runTime.timeName() << endl;
|
||||
|
||||
mesh.write();
|
||||
}
|
||||
|
||||
@ -441,6 +441,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createPolyMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
|
||||
|
||||
@ -502,6 +503,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (nChanged > 0)
|
||||
{
|
||||
if (overwrite)
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
Info<< "Writing morphed mesh to time " << runTime.timeName() << endl;
|
||||
|
||||
mesh.write();
|
||||
|
||||
@ -334,6 +334,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createPolyMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
bool overwrite = args.options().found("overwrite");
|
||||
|
||||
@ -553,9 +554,13 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
runTime++;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
// Write resulting mesh
|
||||
Info << "Writing modified mesh to time " << runTime.value() << endl;
|
||||
Info << "Writing modified mesh to time " << runTime.timeName() << endl;
|
||||
mesh.write();
|
||||
}
|
||||
else if (edgeToPos.size())
|
||||
@ -602,9 +607,13 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
runTime++;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
// Write resulting mesh
|
||||
Info << "Writing modified mesh to time " << runTime.value() << endl;
|
||||
Info << "Writing modified mesh to time " << runTime.timeName() << endl;
|
||||
mesh.write();
|
||||
}
|
||||
else
|
||||
@ -641,9 +650,13 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
runTime++;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
// Write resulting mesh
|
||||
Info << "Writing modified mesh to time " << runTime.value() << endl;
|
||||
Info << "Writing modified mesh to time " << runTime.timeName() << endl;
|
||||
mesh.write();
|
||||
}
|
||||
|
||||
|
||||
@ -58,6 +58,8 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
pointMesh pMesh(mesh);
|
||||
|
||||
word cellSetName(args.args()[1]);
|
||||
@ -177,6 +179,10 @@ int main(int argc, char *argv[])
|
||||
Pout<< "Refined from " << returnReduce(map().nOldCells(), sumOp<label>())
|
||||
<< " to " << mesh.globalData().nTotalCells() << " cells." << nl << endl;
|
||||
|
||||
if (overwrite)
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
Info<< "Writing mesh to " << runTime.timeName() << endl;
|
||||
|
||||
mesh.write();
|
||||
|
||||
@ -56,6 +56,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createPolyMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
word patchName(args.additionalArgs()[0]);
|
||||
|
||||
@ -226,8 +227,13 @@ int main(int argc, char *argv[])
|
||||
// Update stored labels on meshCutter.
|
||||
cutter.updateMesh(morphMap());
|
||||
|
||||
if (overwrite)
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
// Write resulting mesh
|
||||
Info << "Writing refined morphMesh to time " << runTime.value() << endl;
|
||||
Info << "Writing refined morphMesh to time " << runTime.timeName() << endl;
|
||||
|
||||
mesh.write();
|
||||
|
||||
|
||||
@ -55,6 +55,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
bool overwrite = args.options().found("overwrite");
|
||||
|
||||
@ -167,6 +168,10 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
runTime++;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
// Take over refinement levels and write to new time directory.
|
||||
Pout<< "Writing mesh to time " << runTime.timeName() << endl;
|
||||
|
||||
@ -534,6 +534,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createPolyMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
|
||||
|
||||
@ -693,7 +694,13 @@ int main(int argc, char *argv[])
|
||||
Info<< "Remaining:" << cellsToCut.size() << endl;
|
||||
|
||||
// Write resulting mesh
|
||||
Info << "Writing refined morphMesh to time " << runTime.value() << endl;
|
||||
if (overwrite)
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
Info<< "Writing refined morphMesh to time " << runTime.timeName()
|
||||
<< endl;
|
||||
|
||||
mesh.write();
|
||||
}
|
||||
|
||||
@ -354,6 +354,7 @@ int main(int argc, char *argv[])
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
|
||||
# include "createMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
// Mark boundary edges and points.
|
||||
// (Note: in 1.4.2 we can use the built-in mesh point ordering
|
||||
@ -499,7 +500,10 @@ int main(int argc, char *argv[])
|
||||
if (!overwrite)
|
||||
{
|
||||
runTime++;
|
||||
mesh.setInstance(runTime.timeName());
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
Info<< "Writing dual mesh to " << runTime.timeName() << endl;
|
||||
|
||||
@ -78,10 +78,10 @@ int main(int argc, char *argv[])
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
const word dictName("blockMeshDict");
|
||||
|
||||
word regionName;
|
||||
fileName polyMeshDir;
|
||||
word dictName("blockMeshDict");
|
||||
fileName dictPath(runTime.constant());
|
||||
|
||||
if (args.options().found("region"))
|
||||
{
|
||||
@ -98,55 +98,58 @@ int main(int argc, char *argv[])
|
||||
polyMeshDir = polyMesh::meshSubDir;
|
||||
}
|
||||
|
||||
fileName dictLocal = polyMeshDir;
|
||||
autoPtr<IOobject> meshDictIoPtr;
|
||||
|
||||
if (args.options().found("dict"))
|
||||
{
|
||||
wordList elems(fileName(args.options()["dict"]).components());
|
||||
dictName = elems[elems.size()-1];
|
||||
dictPath = elems[0];
|
||||
dictLocal = "";
|
||||
fileName dictPath(args.options()["dict"]);
|
||||
|
||||
if (elems.size() == 1)
|
||||
{
|
||||
dictPath = ".";
|
||||
}
|
||||
else if (elems.size() > 2)
|
||||
{
|
||||
dictLocal = fileName(SubList<word>(elems, elems.size()-2, 1));
|
||||
}
|
||||
meshDictIoPtr.set
|
||||
(
|
||||
new IOobject
|
||||
(
|
||||
( dictPath.isDir() ? dictPath/dictName : dictPath ),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
meshDictIoPtr.set
|
||||
(
|
||||
new IOobject
|
||||
(
|
||||
dictName,
|
||||
runTime.constant(),
|
||||
polyMeshDir,
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
bool writeTopo = args.options().found("blockTopology");
|
||||
|
||||
IOobject meshDictIo
|
||||
(
|
||||
dictName,
|
||||
dictPath,
|
||||
dictLocal,
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
if (!meshDictIo.headerOk())
|
||||
if (!meshDictIoPtr->headerOk())
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Cannot open mesh description file\n "
|
||||
<< meshDictIo.objectPath()
|
||||
<< meshDictIoPtr->objectPath()
|
||||
<< nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
Info<< nl << "Creating block mesh from\n "
|
||||
<< meshDictIo.objectPath() << nl << endl;
|
||||
|
||||
IOdictionary meshDict(meshDictIo);
|
||||
<< meshDictIoPtr->objectPath() << nl << endl;
|
||||
|
||||
IOdictionary meshDict(meshDictIoPtr());
|
||||
blockMesh blocks(meshDict);
|
||||
|
||||
if (writeTopo)
|
||||
|
||||
if (args.options().found("blockTopology"))
|
||||
{
|
||||
// Write mesh as edges.
|
||||
{
|
||||
|
||||
@ -63,6 +63,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createPolyMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
scalar thickness(readScalar(IStringStream(args.additionalArgs()[0])()));
|
||||
bool overwrite = args.options().found("overwrite");
|
||||
@ -182,6 +183,10 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
runTime++;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
// Take over refinement levels and write to new time directory.
|
||||
Pout<< "Writing extruded mesh to time " << runTime.timeName() << nl
|
||||
|
||||
@ -10,4 +10,8 @@ EXE_INC = \
|
||||
|
||||
EXE_LIBS = \
|
||||
-L$(FOAM_MPI_LIBBIN) -lparMetisDecompositionMethod \
|
||||
-lfiniteVolume \
|
||||
-ldecompositionMethods \
|
||||
-lmeshTools \
|
||||
-ldynamicMesh \
|
||||
-lautoMesh
|
||||
|
||||
@ -48,6 +48,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createPolyMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
bool overwrite = args.options().found("overwrite");
|
||||
|
||||
@ -61,6 +62,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
attachPolyTopoChanger(mesh).attach();
|
||||
|
||||
if (overwrite)
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
mesh.write();
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
@ -77,6 +77,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createPolyMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
Info<< "Mesh read in = "
|
||||
<< runTime.cpuTimeIncrement()
|
||||
@ -243,6 +244,10 @@ int main(int argc, char *argv[])
|
||||
polyMeshRepatcher.repatch();
|
||||
|
||||
// Write resulting mesh
|
||||
if (overwrite)
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
mesh.write();
|
||||
|
||||
|
||||
|
||||
@ -74,19 +74,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
Info<< "Reading mesh for time = " << runTime.value() << endl;
|
||||
|
||||
Info<< "Create mesh\n" << endl;
|
||||
polyMesh mesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
polyMesh::defaultRegion,
|
||||
runTime.timeName(),
|
||||
runTime
|
||||
)
|
||||
);
|
||||
# include "createPolyMesh.H"
|
||||
|
||||
Info<< "Reading cellSetDict\n" << endl;
|
||||
|
||||
|
||||
@ -60,6 +60,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
const faceZoneMesh& faceZones = mesh.faceZones();
|
||||
@ -247,6 +248,10 @@ int main(int argc, char *argv[])
|
||||
mesh.movePoints(map().preMotionPoints());
|
||||
}
|
||||
|
||||
if (overwrite)
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
Pout<< "Writing mesh to " << runTime.timeName() << endl;
|
||||
|
||||
mesh.write();
|
||||
|
||||
@ -569,6 +569,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
# include "createPolyMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
@ -909,6 +910,10 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
runTime++;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
// Write resulting mesh
|
||||
Info<< "Writing repatched mesh to " << runTime.timeName() << nl << endl;
|
||||
|
||||
@ -74,19 +74,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
Info<< "Reading mesh for time = " << runTime.value() << endl;
|
||||
|
||||
Info<< "Create mesh\n" << endl;
|
||||
polyMesh mesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
polyMesh::defaultRegion,
|
||||
runTime.timeName(),
|
||||
runTime
|
||||
)
|
||||
);
|
||||
# include "createPolyMesh.H"
|
||||
|
||||
Info<< "Reading faceSetDict\n" << endl;
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ int main(int argc, char *argv[])
|
||||
# include "setRoots.H"
|
||||
# include "createTimes.H"
|
||||
|
||||
Info<< "Reading master mesh for time = " << runTimeMaster.value() << endl;
|
||||
Info<< "Reading master mesh for time = " << runTimeMaster.timeName() << endl;
|
||||
|
||||
Info<< "Create mesh\n" << endl;
|
||||
mergePolyMesh masterMesh
|
||||
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
|
||||
Info<< "Reading mesh to add for time = " << runTimeToAdd.value() << endl;
|
||||
Info<< "Reading mesh to add for time = " << runTimeToAdd.timeName() << endl;
|
||||
|
||||
Info<< "Create mesh\n" << endl;
|
||||
polyMesh meshToAdd
|
||||
@ -71,7 +71,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
runTimeMaster++;
|
||||
|
||||
Info<< "Writing combined mesh to " << runTimeMaster.value() << endl;
|
||||
Info<< "Writing combined mesh to " << runTimeMaster.timeName() << endl;
|
||||
|
||||
masterMesh.addMesh(meshToAdd);
|
||||
masterMesh.merge();
|
||||
|
||||
@ -229,6 +229,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
bool split = args.options().found("split");
|
||||
bool overwrite = args.options().found("overwrite");
|
||||
@ -338,7 +339,10 @@ int main(int argc, char *argv[])
|
||||
mesh.movePoints(map().preMotionPoints());
|
||||
}
|
||||
|
||||
|
||||
if (overwrite)
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
Pout<< "Writing mesh to time " << runTime.timeName() << endl;
|
||||
mesh.write();
|
||||
|
||||
|
||||
@ -74,19 +74,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
Info<< "Reading mesh for time = " << runTime.value() << endl;
|
||||
|
||||
Info<< "Create mesh\n" << endl;
|
||||
polyMesh mesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
polyMesh::defaultRegion,
|
||||
runTime.timeName(),
|
||||
runTime
|
||||
)
|
||||
);
|
||||
# include "createPolyMesh.H"
|
||||
|
||||
Info<< "Reading pointSetDict\n" << endl;
|
||||
|
||||
|
||||
@ -300,6 +300,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createPolyMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
printEdgeStats(mesh);
|
||||
|
||||
@ -427,6 +428,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
// Write resulting mesh
|
||||
if (overwrite)
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
mesh.write();
|
||||
|
||||
|
||||
|
||||
@ -383,9 +383,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
|
||||
|
||||
# include "createMesh.H"
|
||||
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
const bool blockOrder = args.options().found("blockOrder");
|
||||
|
||||
@ -631,6 +630,11 @@ int main(int argc, char *argv[])
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
if (overwrite)
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
Info<< "Writing mesh to " << runTime.timeName() << endl;
|
||||
|
||||
mesh.write();
|
||||
|
||||
@ -124,6 +124,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createPolyMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
word setName(args.additionalArgs()[0]);
|
||||
word masterPatch(args.additionalArgs()[1]);
|
||||
@ -262,7 +263,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
splitter.attach();
|
||||
|
||||
Info << nl << "Writing polyMesh" << endl;
|
||||
if (overwrite)
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
Info<< "Writing mesh to " << runTime.timeName() << endl;
|
||||
if (!mesh.write())
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
|
||||
@ -30,12 +30,17 @@ Description
|
||||
- any face inbetween differing cellZones (-cellZones)
|
||||
|
||||
Output is:
|
||||
- mesh with multiple regions
|
||||
- mesh with multiple regions or
|
||||
- mesh with cells put into cellZones (-makeCellZones)
|
||||
|
||||
Should work in parallel but cellZone interfaces cannot align with
|
||||
Note:
|
||||
- Should work in parallel but cellZone interfaces cannot align with
|
||||
processor boundaries so use the correct option in decomposition to
|
||||
preserve those interfaces.
|
||||
- If a cell zone gets split into more than one region it can detect
|
||||
the largest matching region (-sloppyCellZones). This will accept any
|
||||
region that covers more than 50% of the zone. It has to be a subset
|
||||
so cannot have any cells in any other zone.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -758,7 +763,8 @@ void createAndWriteRegion
|
||||
const regionSplit& cellRegion,
|
||||
const wordList& regionNames,
|
||||
const EdgeMap<label>& interfaceToPatch,
|
||||
const label regionI
|
||||
const label regionI,
|
||||
const word& newMeshInstance
|
||||
)
|
||||
{
|
||||
Info<< "Creating mesh for region " << regionI
|
||||
@ -902,6 +908,7 @@ void createAndWriteRegion
|
||||
|
||||
Info<< "Writing new mesh" << endl;
|
||||
|
||||
newMesh().setInstance(newMeshInstance);
|
||||
newMesh().write();
|
||||
|
||||
// Write addressing files like decomposePar
|
||||
@ -1036,78 +1043,181 @@ EdgeMap<label> addRegionPatches
|
||||
}
|
||||
|
||||
|
||||
// Checks if regionI in cellRegion corresponds to existing zone.
|
||||
label findCorrespondingZone
|
||||
//// Checks if regionI in cellRegion is subset of existing cellZone. Returns -1
|
||||
//// if no zone found, zone otherwise
|
||||
//label findCorrespondingSubZone
|
||||
//(
|
||||
// const cellZoneMesh& cellZones,
|
||||
// const labelList& existingZoneID,
|
||||
// const labelList& cellRegion,
|
||||
// const label regionI
|
||||
//)
|
||||
//{
|
||||
// // Zone corresponding to region. No corresponding zone.
|
||||
// label zoneI = labelMax;
|
||||
//
|
||||
// labelList regionCells = findIndices(cellRegion, regionI);
|
||||
//
|
||||
// if (regionCells.empty())
|
||||
// {
|
||||
// // My local portion is empty. Maps to any empty cellZone. Mark with
|
||||
// // special value which can get overwritten by other processors.
|
||||
// zoneI = -1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Get zone for first element.
|
||||
// zoneI = existingZoneID[regionCells[0]];
|
||||
//
|
||||
// if (zoneI == -1)
|
||||
// {
|
||||
// zoneI = labelMax;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // 1. All regionCells in zoneI?
|
||||
// forAll(regionCells, i)
|
||||
// {
|
||||
// if (existingZoneID[regionCells[i]] != zoneI)
|
||||
// {
|
||||
// zoneI = labelMax;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Determine same zone over all processors.
|
||||
// reduce(zoneI, maxOp<label>());
|
||||
//
|
||||
// if (zoneI == labelMax)
|
||||
// {
|
||||
// // Cells in region that are not in zoneI
|
||||
// zoneI = -1;
|
||||
// }
|
||||
//
|
||||
// return zoneI;
|
||||
//}
|
||||
|
||||
|
||||
//XXXXXXXXX
|
||||
// Find region that covers most of cell zone
|
||||
label findCorrespondingRegion
|
||||
(
|
||||
const cellZoneMesh& cellZones,
|
||||
const labelList& existingZoneID,
|
||||
const labelList& cellRegion,
|
||||
const label regionI
|
||||
const labelList& existingZoneID, // per cell the (unique) zoneID
|
||||
const regionSplit& cellRegion,
|
||||
const label zoneI,
|
||||
const label minOverlapSize
|
||||
)
|
||||
{
|
||||
// Zone corresponding to region. No corresponding zone.
|
||||
label zoneI = labelMax;
|
||||
// Per region the number of cells in zoneI
|
||||
labelList cellsInZone(cellRegion.nRegions(), 0);
|
||||
|
||||
labelList regionCells = findIndices(cellRegion, regionI);
|
||||
|
||||
if (regionCells.empty())
|
||||
forAll(cellRegion, cellI)
|
||||
{
|
||||
// My local portion is empty. Maps to any empty cellZone. Mark with
|
||||
// special value which can get overwritten by other processors.
|
||||
zoneI = -1;
|
||||
if (existingZoneID[cellI] == zoneI)
|
||||
{
|
||||
cellsInZone[cellRegion[cellI]]++;
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::listCombineGather(cellsInZone, plusEqOp<label>());
|
||||
Pstream::listCombineScatter(cellsInZone);
|
||||
|
||||
// Pick region with largest overlap of zoneI
|
||||
label regionI = findMax(cellsInZone);
|
||||
|
||||
|
||||
if (cellsInZone[regionI] < minOverlapSize)
|
||||
{
|
||||
// Region covers too little of zone. Not good enough.
|
||||
regionI = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get zone for first element.
|
||||
zoneI = existingZoneID[regionCells[0]];
|
||||
|
||||
if (zoneI == -1)
|
||||
// Check that region contains no cells that aren't in cellZone.
|
||||
forAll(cellRegion, cellI)
|
||||
{
|
||||
zoneI = labelMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 1. All regionCells in zoneI?
|
||||
forAll(regionCells, i)
|
||||
if (cellRegion[cellI] == regionI && existingZoneID[cellI] != zoneI)
|
||||
{
|
||||
if (existingZoneID[regionCells[i]] != zoneI)
|
||||
{
|
||||
zoneI = labelMax;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Determine same zone over all processors.
|
||||
reduce(zoneI, maxOp<label>());
|
||||
|
||||
|
||||
// 2. All of cellZone present?
|
||||
|
||||
if (zoneI == labelMax)
|
||||
{
|
||||
zoneI = -1;
|
||||
}
|
||||
else if (zoneI != -1)
|
||||
{
|
||||
const cellZone& cz = cellZones[zoneI];
|
||||
|
||||
forAll(cz, i)
|
||||
{
|
||||
if (cellRegion[cz[i]] != regionI)
|
||||
{
|
||||
zoneI = -1;
|
||||
// cellI in regionI but not in zoneI
|
||||
regionI = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If one in error, all should be in error. Note that branch gets taken
|
||||
// on all procs.
|
||||
reduce(zoneI, minOp<label>());
|
||||
reduce(regionI, minOp<label>());
|
||||
}
|
||||
|
||||
return zoneI;
|
||||
return regionI;
|
||||
}
|
||||
//XXXXXXXXX
|
||||
|
||||
|
||||
//// Checks if cellZone has corresponding cellRegion.
|
||||
//label findCorrespondingRegion
|
||||
//(
|
||||
// const cellZoneMesh& cellZones,
|
||||
// const labelList& existingZoneID, // per cell the (unique) zoneID
|
||||
// const regionSplit& cellRegion,
|
||||
// const label zoneI
|
||||
//)
|
||||
//{
|
||||
// // Region corresponding to zone. Start off with special value: no
|
||||
// // corresponding region.
|
||||
// label regionI = labelMax;
|
||||
//
|
||||
// const cellZone& cz = cellZones[zoneI];
|
||||
//
|
||||
// if (cz.empty())
|
||||
// {
|
||||
// // My local portion is empty. Maps to any empty cellZone. Mark with
|
||||
// // special value which can get overwritten by other processors.
|
||||
// regionI = -1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// regionI = cellRegion[cz[0]];
|
||||
//
|
||||
// forAll(cz, i)
|
||||
// {
|
||||
// if (cellRegion[cz[i]] != regionI)
|
||||
// {
|
||||
// regionI = labelMax;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Determine same zone over all processors.
|
||||
// reduce(regionI, maxOp<label>());
|
||||
//
|
||||
//
|
||||
// // 2. All of region present?
|
||||
//
|
||||
// if (regionI == labelMax)
|
||||
// {
|
||||
// regionI = -1;
|
||||
// }
|
||||
// else if (regionI != -1)
|
||||
// {
|
||||
// forAll(cellRegion, cellI)
|
||||
// {
|
||||
// if (cellRegion[cellI] == regionI && existingZoneID[cellI] != zoneI)
|
||||
// {
|
||||
// // cellI in regionI but not in zoneI
|
||||
// regionI = -1;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// // If one in error, all should be in error. Note that branch gets taken
|
||||
// // on all procs.
|
||||
// reduce(regionI, minOp<label>());
|
||||
// }
|
||||
//
|
||||
// return regionI;
|
||||
//}
|
||||
|
||||
|
||||
// Main program:
|
||||
@ -1120,11 +1230,14 @@ int main(int argc, char *argv[])
|
||||
argList::validOptions.insert("largestOnly", "");
|
||||
argList::validOptions.insert("insidePoint", "point");
|
||||
argList::validOptions.insert("overwrite", "");
|
||||
argList::validOptions.insert("detectOnly", "");
|
||||
argList::validOptions.insert("sloppyCellZones", "");
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
word blockedFacesName;
|
||||
if (args.options().found("blockedFaces"))
|
||||
@ -1134,10 +1247,13 @@ int main(int argc, char *argv[])
|
||||
<< blockedFacesName << nl << endl;
|
||||
}
|
||||
|
||||
bool makeCellZones = args.options().found("makeCellZones");
|
||||
bool largestOnly = args.options().found("largestOnly");
|
||||
bool insidePoint = args.options().found("insidePoint");
|
||||
bool useCellZones = args.options().found("cellZones");
|
||||
bool overwrite = args.options().found("overwrite");
|
||||
bool detectOnly = args.options().found("detectOnly");
|
||||
bool sloppyCellZones = args.options().found("sloppyCellZones");
|
||||
|
||||
if (insidePoint && largestOnly)
|
||||
{
|
||||
@ -1281,6 +1397,31 @@ int main(int argc, char *argv[])
|
||||
Info<< "Writing region per cell file (for manual decomposition) to "
|
||||
<< cellToRegion.objectPath() << nl << endl;
|
||||
}
|
||||
// Write for postprocessing
|
||||
{
|
||||
volScalarField cellToRegion
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"cellToRegion",
|
||||
mesh.facesInstance(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("zero", dimless, 0)
|
||||
);
|
||||
forAll(cellRegion, cellI)
|
||||
{
|
||||
cellToRegion[cellI] = cellRegion[cellI];
|
||||
}
|
||||
cellToRegion.write();
|
||||
|
||||
Info<< "Writing region per cell as volScalarField to "
|
||||
<< cellToRegion.objectPath() << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
// Sizes per region
|
||||
@ -1307,40 +1448,131 @@ int main(int argc, char *argv[])
|
||||
Info<< endl;
|
||||
|
||||
|
||||
// Sizes per cellzone
|
||||
// ~~~~~~~~~~~~~~~~~~
|
||||
|
||||
labelList zoneSizes(cellZones.size(), 0);
|
||||
if (useCellZones || makeCellZones || sloppyCellZones)
|
||||
{
|
||||
List<wordList> zoneNames(Pstream::nProcs());
|
||||
zoneNames[Pstream::myProcNo()] = cellZones.names();
|
||||
Pstream::gatherList(zoneNames);
|
||||
Pstream::scatterList(zoneNames);
|
||||
|
||||
forAll(zoneNames, procI)
|
||||
{
|
||||
if (zoneNames[procI] != zoneNames[0])
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "cellZones not synchronised across processors." << endl
|
||||
<< "Master has cellZones " << zoneNames[0] << endl
|
||||
<< "Processor " << procI
|
||||
<< " has cellZones " << zoneNames[procI]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
forAll(cellZones, zoneI)
|
||||
{
|
||||
zoneSizes[zoneI] = returnReduce
|
||||
(
|
||||
cellZones[zoneI].size(),
|
||||
sumOp<label>()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Whether region corresponds to a cellzone
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Info<< "Region\tZone\tName" << nl
|
||||
<< "------\t----\t----" << endl;
|
||||
|
||||
// Region per zone
|
||||
labelList regionToZone(cellRegion.nRegions());
|
||||
labelList regionToZone(cellRegion.nRegions(), -1);
|
||||
// Name of region
|
||||
wordList regionNames(cellRegion.nRegions());
|
||||
// Zone to region
|
||||
labelList zoneToRegion(cellZones.size(), -1);
|
||||
|
||||
if (sloppyCellZones)
|
||||
{
|
||||
Info<< "Trying to match regions to existing cell zones;"
|
||||
<< " region can be subset of cell zone." << nl << endl;
|
||||
|
||||
forAll(cellZones, zoneI)
|
||||
{
|
||||
label regionI = findCorrespondingRegion
|
||||
(
|
||||
zoneID,
|
||||
cellRegion,
|
||||
zoneI,
|
||||
label(0.5*zoneSizes[zoneI]) // minimum overlap
|
||||
);
|
||||
|
||||
if (regionI != -1)
|
||||
{
|
||||
Info<< "Sloppily matched region " << regionI
|
||||
<< " size " << regionSizes[regionI]
|
||||
<< " to zone " << zoneI << " size " << zoneSizes[zoneI]
|
||||
<< endl;
|
||||
zoneToRegion[zoneI] = regionI;
|
||||
regionToZone[regionI] = zoneI;
|
||||
regionNames[regionI] = cellZones[zoneI].name();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Trying to match regions to existing cell zones." << nl << endl;
|
||||
|
||||
forAll(cellZones, zoneI)
|
||||
{
|
||||
label regionI = findCorrespondingRegion
|
||||
(
|
||||
zoneID,
|
||||
cellRegion,
|
||||
zoneI,
|
||||
1 // minimum overlap
|
||||
);
|
||||
|
||||
if (regionI != -1)
|
||||
{
|
||||
zoneToRegion[zoneI] = regionI;
|
||||
regionToZone[regionI] = zoneI;
|
||||
regionNames[regionI] = cellZones[zoneI].name();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Allocate region names for unmatched regions.
|
||||
forAll(regionToZone, regionI)
|
||||
{
|
||||
regionToZone[regionI] = findCorrespondingZone
|
||||
(
|
||||
cellZones,
|
||||
zoneID,
|
||||
cellRegion,
|
||||
regionI
|
||||
);
|
||||
|
||||
if (regionToZone[regionI] != -1)
|
||||
{
|
||||
regionNames[regionI] = cellZones[regionToZone[regionI]].name();
|
||||
}
|
||||
else
|
||||
if (regionToZone[regionI] == -1)
|
||||
{
|
||||
regionNames[regionI] = "domain" + Foam::name(regionI);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Print region to zone
|
||||
Info<< "Region\tZone\tName" << nl
|
||||
<< "------\t----\t----" << endl;
|
||||
forAll(regionToZone, regionI)
|
||||
{
|
||||
Info<< regionI << '\t' << regionToZone[regionI] << '\t'
|
||||
<< regionNames[regionI] << nl;
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
//// Print zone to region
|
||||
//Info<< "Zone\tName\tRegion" << nl
|
||||
// << "----\t----\t------" << endl;
|
||||
//forAll(zoneToRegion, zoneI)
|
||||
//{
|
||||
// Info<< zoneI << '\t' << cellZones[zoneI].name() << '\t'
|
||||
// << zoneToRegion[zoneI] << nl;
|
||||
//}
|
||||
//Info<< endl;
|
||||
|
||||
|
||||
|
||||
// Since we're going to mess with patches make sure all non-processor ones
|
||||
// are on all processors.
|
||||
@ -1361,7 +1593,8 @@ int main(int argc, char *argv[])
|
||||
interfaceSizes
|
||||
);
|
||||
|
||||
Info<< "Region\tRegion\tFaces" << nl
|
||||
Info<< "Sizes inbetween regions:" << nl << nl
|
||||
<< "Region\tRegion\tFaces" << nl
|
||||
<< "------\t------\t-----" << endl;
|
||||
|
||||
forAll(interfaces, interI)
|
||||
@ -1373,7 +1606,10 @@ int main(int argc, char *argv[])
|
||||
Info<< endl;
|
||||
|
||||
|
||||
|
||||
if (detectOnly)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Read objects in time directory
|
||||
@ -1423,7 +1659,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "Only one region. Doing nothing." << endl;
|
||||
}
|
||||
else if (args.options().found("makeCellZones"))
|
||||
else if (makeCellZones)
|
||||
{
|
||||
Info<< "Putting cells into cellZones instead of splitting mesh."
|
||||
<< endl;
|
||||
@ -1479,12 +1715,16 @@ int main(int argc, char *argv[])
|
||||
if (!overwrite)
|
||||
{
|
||||
runTime++;
|
||||
mesh.setInstance(runTime.timeName());
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
Info<< "Writing cellZones as new mesh to time " << runTime.timeName()
|
||||
<< nl << endl;
|
||||
|
||||
mesh.setInstance(runTime.timeName());
|
||||
mesh.write();
|
||||
|
||||
|
||||
@ -1567,7 +1807,8 @@ int main(int argc, char *argv[])
|
||||
cellRegion,
|
||||
regionNames,
|
||||
interfaceToPatch,
|
||||
regionI
|
||||
regionI,
|
||||
(overwrite ? oldInstance : runTime.timeName())
|
||||
);
|
||||
}
|
||||
else if (largestOnly)
|
||||
@ -1584,7 +1825,8 @@ int main(int argc, char *argv[])
|
||||
cellRegion,
|
||||
regionNames,
|
||||
interfaceToPatch,
|
||||
regionI
|
||||
regionI,
|
||||
(overwrite ? oldInstance : runTime.timeName())
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -1602,7 +1844,8 @@ int main(int argc, char *argv[])
|
||||
cellRegion,
|
||||
regionNames,
|
||||
interfaceToPatch,
|
||||
regionI
|
||||
regionI,
|
||||
(overwrite ? oldInstance : runTime.timeName())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,6 +137,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
|
||||
word masterPatchName(args.additionalArgs()[0]);
|
||||
@ -391,6 +392,10 @@ int main(int argc, char *argv[])
|
||||
mesh.movePoints(morphMap->preMotionPoints());
|
||||
|
||||
// Write mesh
|
||||
if (overwrite)
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
Info << nl << "Writing polyMesh to time " << runTime.timeName() << endl;
|
||||
|
||||
IOstream::defaultPrecision(10);
|
||||
|
||||
@ -159,6 +159,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
# include "createMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
word setName(args.additionalArgs()[0]);
|
||||
bool overwrite = args.options().found("overwrite");
|
||||
@ -276,7 +277,7 @@ int main(int argc, char *argv[])
|
||||
// Read point fields and subset
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
pointMesh pMesh(mesh);
|
||||
const pointMesh& pMesh = pointMesh::New(mesh);
|
||||
|
||||
wordList pointScalarNames(objects.names(pointScalarField::typeName));
|
||||
PtrList<pointScalarField> pointScalarFlds(pointScalarNames.size());
|
||||
@ -331,8 +332,12 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
runTime++;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
Info<< "Writing subsetted mesh and fields to time " << runTime.value()
|
||||
Info<< "Writing subsetted mesh and fields to time " << runTime.timeName()
|
||||
<< endl;
|
||||
subsetter.subMesh().write();
|
||||
|
||||
|
||||
@ -190,16 +190,15 @@ void Foam::vtkPV3Foam::convertPointField
|
||||
}
|
||||
|
||||
vtkFloatArray *pointData = vtkFloatArray::New();
|
||||
pointData->SetNumberOfTuples( nPoints + addPointCellLabels.size() );
|
||||
pointData->SetNumberOfComponents( nComp );
|
||||
pointData->Allocate( nComp*(nPoints + addPointCellLabels.size()) );
|
||||
pointData->SetName( tf.name().c_str() );
|
||||
|
||||
pointData->SetNumberOfTuples(nPoints + addPointCellLabels.size());
|
||||
pointData->SetNumberOfComponents(nComp);
|
||||
pointData->Allocate(nComp*(nPoints + addPointCellLabels.size()));
|
||||
pointData->SetName(ptf.name().c_str());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert convertPointField: "
|
||||
<< tf.name()
|
||||
<< ptf.name()
|
||||
<< " size = " << nPoints
|
||||
<< " nComp=" << nComp
|
||||
<< " nTuples = " << (nPoints + addPointCellLabels.size())
|
||||
|
||||
@ -161,6 +161,10 @@ surfaces
|
||||
isoField rho;
|
||||
isoValue 0.5;
|
||||
interpolate true;
|
||||
|
||||
//zone ABC; // Optional: zone only
|
||||
//exposedPatchName fixedWalls; // Optional: zone only
|
||||
|
||||
// regularise false; // Optional: do not simplify
|
||||
}
|
||||
constantIso
|
||||
@ -171,8 +175,27 @@ surfaces
|
||||
isoField rho;
|
||||
isoValue 0.5;
|
||||
interpolate false;
|
||||
regularise false; // do not simplify
|
||||
}
|
||||
|
||||
triangleCut
|
||||
{
|
||||
// Cutingplaneusing iso surface
|
||||
type cuttingPlane;
|
||||
planeType pointAndNormal;
|
||||
pointAndNormalDict
|
||||
{
|
||||
basePoint (0.4 0 0.4);
|
||||
normalVector (1 0.2 0.2);
|
||||
}
|
||||
interpolate true;
|
||||
|
||||
//zone ABC; // Optional: zone only
|
||||
//exposedPatchName fixedWalls; // Optional: zone only
|
||||
|
||||
// regularise false; // Optional: do not simplify
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -78,56 +78,61 @@ int main(int argc, char *argv[])
|
||||
Time runTime(args.rootPath(), args.caseName());
|
||||
const stringList& params = args.additionalArgs();
|
||||
|
||||
word dictName("coordinateSystems");
|
||||
fileName dictPath(runTime.constant());
|
||||
fileName dictLocal;
|
||||
|
||||
if (args.options().found("dict"))
|
||||
{
|
||||
wordList elems(fileName(args.options()["dict"]).components());
|
||||
dictName = elems[elems.size()-1];
|
||||
dictPath = elems[0];
|
||||
dictLocal = "";
|
||||
|
||||
if (elems.size() == 1)
|
||||
{
|
||||
dictPath = ".";
|
||||
}
|
||||
else if (elems.size() > 2)
|
||||
{
|
||||
dictLocal = fileName(SubList<word>(elems, elems.size()-2, 1));
|
||||
}
|
||||
}
|
||||
const word dictName("coordinateSystems");
|
||||
|
||||
autoPtr<coordinateSystem> fromCsys;
|
||||
autoPtr<coordinateSystem> toCsys;
|
||||
|
||||
if (args.options().found("from") || args.options().found("to"))
|
||||
{
|
||||
IOobject csDictIo
|
||||
(
|
||||
dictName,
|
||||
dictPath,
|
||||
dictLocal,
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
autoPtr<IOobject> csDictIoPtr;
|
||||
|
||||
if (!csDictIo.headerOk())
|
||||
if (args.options().found("dict"))
|
||||
{
|
||||
fileName dictPath(args.options()["dict"]);
|
||||
|
||||
csDictIoPtr.set
|
||||
(
|
||||
new IOobject
|
||||
(
|
||||
( dictPath.isDir() ? dictPath/dictName : dictPath ),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
csDictIoPtr.set
|
||||
(
|
||||
new IOobject
|
||||
(
|
||||
dictName,
|
||||
runTime.constant(),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (!csDictIoPtr->headerOk())
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Cannot open coordinateSystems file\n "
|
||||
<< csDictIo.objectPath() << nl
|
||||
<< csDictIoPtr->objectPath() << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
coordinateSystems csLst(csDictIo);
|
||||
coordinateSystems csLst(csDictIoPtr());
|
||||
|
||||
if (args.options().found("from"))
|
||||
{
|
||||
word csName(args.options()["from"]);
|
||||
const word csName(args.options()["from"]);
|
||||
|
||||
label csId = csLst.find(csName);
|
||||
if (csId < 0)
|
||||
@ -143,7 +148,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.options().found("to"))
|
||||
{
|
||||
word csName(args.options()["to"]);
|
||||
const word csName(args.options()["to"]);
|
||||
|
||||
label csId = csLst.find(csName);
|
||||
if (csId < 0)
|
||||
|
||||
@ -56,6 +56,7 @@ Note
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "triSurface.H"
|
||||
#include "PackedBoolList.H"
|
||||
|
||||
#include "MeshedSurfaces.H"
|
||||
#include "UnsortedMeshedSurfaces.H"
|
||||
@ -115,7 +116,7 @@ int main(int argc, char *argv[])
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -154,7 +155,7 @@ int main(int argc, char *argv[])
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -192,7 +193,7 @@ int main(int argc, char *argv[])
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -230,7 +231,7 @@ int main(int argc, char *argv[])
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user