mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
@ -0,0 +1,3 @@
|
|||||||
|
laplacianDyMFoam.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/overLaplacianDyMFoam
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/overset/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
-loverset
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
Info<< "Reading field T\n" << endl;
|
||||||
|
|
||||||
|
volScalarField T
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"T",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add overset specific interpolations
|
||||||
|
{
|
||||||
|
dictionary oversetDict;
|
||||||
|
oversetDict.add("T", true);
|
||||||
|
|
||||||
|
const_cast<dictionary&>
|
||||||
|
(
|
||||||
|
mesh.schemesDict()
|
||||||
|
).add
|
||||||
|
(
|
||||||
|
"oversetInterpolationRequired",
|
||||||
|
oversetDict,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Info<< "Reading transportProperties\n" << endl;
|
||||||
|
|
||||||
|
IOdictionary transportProperties
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"transportProperties",
|
||||||
|
runTime.constant(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ_IF_MODIFIED,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
Info<< "Reading diffusivity DT\n" << endl;
|
||||||
|
|
||||||
|
dimensionedScalar DT
|
||||||
|
(
|
||||||
|
transportProperties.lookup("DT")
|
||||||
|
);
|
||||||
@ -0,0 +1,110 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
laplacianFoam
|
||||||
|
|
||||||
|
Group
|
||||||
|
grpBasicSolvers
|
||||||
|
|
||||||
|
Description
|
||||||
|
Laplace equation solver for a scalar quantity.
|
||||||
|
|
||||||
|
\heading Solver details
|
||||||
|
The solver is applicable to, e.g. for thermal diffusion in a solid. The
|
||||||
|
equation is given by:
|
||||||
|
|
||||||
|
\f[
|
||||||
|
\ddt{T} = \div \left( D_T \grad T \right)
|
||||||
|
\f]
|
||||||
|
|
||||||
|
Where:
|
||||||
|
\vartable
|
||||||
|
T | Scalar field which is solved for, e.g. temperature
|
||||||
|
D_T | Diffusion coefficient
|
||||||
|
\endvartable
|
||||||
|
|
||||||
|
\heading Required fields
|
||||||
|
\plaintable
|
||||||
|
T | Scalar field which is solved for, e.g. temperature
|
||||||
|
\endplaintable
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "fvCFD.H"
|
||||||
|
#include "fvOptions.H"
|
||||||
|
#include "simpleControl.H"
|
||||||
|
#include "dynamicFvMesh.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
#include "createTime.H"
|
||||||
|
#include "createNamedDynamicFvMesh.H"
|
||||||
|
|
||||||
|
simpleControl simple(mesh);
|
||||||
|
|
||||||
|
#include "createFields.H"
|
||||||
|
#include "createFvOptions.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Info<< "\nCalculating temperature distribution\n" << endl;
|
||||||
|
|
||||||
|
while (simple.loop())
|
||||||
|
{
|
||||||
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
|
mesh.update();
|
||||||
|
|
||||||
|
while (simple.correctNonOrthogonal())
|
||||||
|
{
|
||||||
|
fvScalarMatrix TEqn
|
||||||
|
(
|
||||||
|
fvm::ddt(T) - fvm::laplacian(DT, T)
|
||||||
|
==
|
||||||
|
fvOptions(T)
|
||||||
|
);
|
||||||
|
|
||||||
|
fvOptions.constrain(TEqn);
|
||||||
|
TEqn.solve();
|
||||||
|
fvOptions.correct(T);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "write.H"
|
||||||
|
|
||||||
|
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||||
|
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||||
|
<< nl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
if (runTime.outputTime())
|
||||||
|
{
|
||||||
|
volVectorField gradT(fvc::grad(T));
|
||||||
|
|
||||||
|
volScalarField gradTx
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"gradTx",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
gradT.component(vector::X)
|
||||||
|
);
|
||||||
|
|
||||||
|
volScalarField gradTy
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"gradTy",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
gradT.component(vector::Y)
|
||||||
|
);
|
||||||
|
|
||||||
|
volScalarField gradTz
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"gradTz",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
gradT.component(vector::Z)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
runTime.write();
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
rhoPimpleDyMFoam.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/overRhoPimpleDyMFoam
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I.. \
|
||||||
|
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
|
||||||
|
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
|
||||||
|
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||||
|
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/cfdTools \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
-I$(LIB_SRC)/sampling/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/overset/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
-lcompressibleTransportModels \
|
||||||
|
-lfluidThermophysicalModels \
|
||||||
|
-lspecie \
|
||||||
|
-lturbulenceModels \
|
||||||
|
-lcompressibleTurbulenceModels \
|
||||||
|
-loverset \
|
||||||
|
-lfvOptions \
|
||||||
|
-ldynamicFvMesh \
|
||||||
|
-ltopoChangerFvMesh
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
CorrectPhi
|
||||||
|
(
|
||||||
|
U,
|
||||||
|
phi,
|
||||||
|
p,
|
||||||
|
rho,
|
||||||
|
psi,
|
||||||
|
dimensionedScalar("rAUf", dimTime, 1),
|
||||||
|
divrhoU,
|
||||||
|
pimple
|
||||||
|
);
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
#include "createTimeControls.H"
|
||||||
|
|
||||||
|
bool correctPhi
|
||||||
|
(
|
||||||
|
pimple.dict().lookupOrDefault<Switch>("correctPhi", true)
|
||||||
|
);
|
||||||
|
|
||||||
|
bool checkMeshCourantNo
|
||||||
|
(
|
||||||
|
pimple.dict().lookupOrDefault<Switch>("checkMeshCourantNo", false)
|
||||||
|
);
|
||||||
@ -0,0 +1,117 @@
|
|||||||
|
Info<< "Reading thermophysical properties\n" << endl;
|
||||||
|
|
||||||
|
autoPtr<psiThermo> pThermo
|
||||||
|
(
|
||||||
|
psiThermo::New(mesh)
|
||||||
|
);
|
||||||
|
psiThermo& thermo = pThermo();
|
||||||
|
thermo.validate(args.executable(), "h", "e");
|
||||||
|
|
||||||
|
volScalarField& p = thermo.p();
|
||||||
|
const volScalarField& psi = thermo.psi();
|
||||||
|
|
||||||
|
volScalarField rho
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"rho",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::READ_IF_PRESENT,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
thermo.rho()
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "Reading field U\n" << endl;
|
||||||
|
volVectorField U
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"U",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
#include "compressibleCreatePhi.H"
|
||||||
|
|
||||||
|
dimensionedScalar rhoMax
|
||||||
|
(
|
||||||
|
dimensionedScalar::lookupOrDefault
|
||||||
|
(
|
||||||
|
"rhoMax",
|
||||||
|
pimple.dict(),
|
||||||
|
dimDensity,
|
||||||
|
GREAT
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
dimensionedScalar rhoMin
|
||||||
|
(
|
||||||
|
dimensionedScalar::lookupOrDefault
|
||||||
|
(
|
||||||
|
"rhoMin",
|
||||||
|
pimple.dict(),
|
||||||
|
dimDensity,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "Creating turbulence model\n" << endl;
|
||||||
|
autoPtr<compressible::turbulenceModel> turbulence
|
||||||
|
(
|
||||||
|
compressible::turbulenceModel::New
|
||||||
|
(
|
||||||
|
rho,
|
||||||
|
U,
|
||||||
|
phi,
|
||||||
|
thermo
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
mesh.setFluxRequired(p.name());
|
||||||
|
|
||||||
|
Info<< "Creating field dpdt\n" << endl;
|
||||||
|
volScalarField dpdt
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"dpdt",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
dimensionedScalar("dpdt", p.dimensions()/dimTime, 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "Creating field kinetic energy K\n" << endl;
|
||||||
|
volScalarField K("K", 0.5*magSqr(U));
|
||||||
|
|
||||||
|
|
||||||
|
//- Overset specific
|
||||||
|
|
||||||
|
// Add solver-specific interpolations
|
||||||
|
{
|
||||||
|
dictionary oversetDict;
|
||||||
|
oversetDict.add("U", true);
|
||||||
|
oversetDict.add("p", true);
|
||||||
|
oversetDict.add("HbyA", true);
|
||||||
|
oversetDict.add("grad(p)", true);
|
||||||
|
|
||||||
|
const_cast<dictionary&>
|
||||||
|
(
|
||||||
|
mesh.schemesDict()
|
||||||
|
).add
|
||||||
|
(
|
||||||
|
"oversetInterpolationRequired",
|
||||||
|
oversetDict,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mask field for zeroing out contributions on hole cells
|
||||||
|
#include "createCellMask.H"
|
||||||
@ -0,0 +1,123 @@
|
|||||||
|
rho = thermo.rho();
|
||||||
|
rho = max(rho, rhoMin);
|
||||||
|
rho = min(rho, rhoMax);
|
||||||
|
rho.relax();
|
||||||
|
|
||||||
|
surfaceScalarField faceMask(localMin<scalar>(mesh).interpolate(cellMask));
|
||||||
|
|
||||||
|
volScalarField rAU(1.0/UEqn.A());
|
||||||
|
surfaceScalarField rhorAUf("rhorAUf", faceMask*fvc::interpolate(rho*rAU));
|
||||||
|
volVectorField HbyA("HbyA", constrainHbyA(rAU*UEqn.H(), U, p));
|
||||||
|
//mesh.interpolate(HbyA);
|
||||||
|
|
||||||
|
if (pimple.nCorrPISO() <= 1)
|
||||||
|
{
|
||||||
|
tUEqn.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pimple.transonic())
|
||||||
|
{
|
||||||
|
surfaceScalarField phid
|
||||||
|
(
|
||||||
|
"phid",
|
||||||
|
fvc::interpolate(psi)
|
||||||
|
*(
|
||||||
|
fvc::flux(HbyA)
|
||||||
|
+ rhorAUf*fvc::ddtCorr(rho, U, rhoUf)/fvc::interpolate(rho)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
fvc::makeRelative(phid, psi, U);
|
||||||
|
MRF.makeRelative(fvc::interpolate(psi), phid);
|
||||||
|
|
||||||
|
while (pimple.correctNonOrthogonal())
|
||||||
|
{
|
||||||
|
fvScalarMatrix pEqn
|
||||||
|
(
|
||||||
|
fvm::ddt(psi, p)
|
||||||
|
+ fvm::div(phid, p)
|
||||||
|
- fvm::laplacian(rhorAUf, p)
|
||||||
|
==
|
||||||
|
fvOptions(psi, p, rho.name())
|
||||||
|
);
|
||||||
|
|
||||||
|
pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter())));
|
||||||
|
|
||||||
|
if (pimple.finalNonOrthogonalIter())
|
||||||
|
{
|
||||||
|
phi == pEqn.flux();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
surfaceScalarField phiHbyA
|
||||||
|
(
|
||||||
|
"phiHbyA",
|
||||||
|
fvc::flux(rho*HbyA)
|
||||||
|
+ rhorAUf*fvc::ddtCorr(rho, U, rhoUf)
|
||||||
|
);
|
||||||
|
|
||||||
|
fvc::makeRelative(phiHbyA, rho, U);
|
||||||
|
MRF.makeRelative(fvc::interpolate(rho), phiHbyA);
|
||||||
|
|
||||||
|
// Update the pressure BCs to ensure flux consistency
|
||||||
|
constrainPressure(p, rho, U, phiHbyA, rhorAUf, MRF);
|
||||||
|
|
||||||
|
while (pimple.correctNonOrthogonal())
|
||||||
|
{
|
||||||
|
// Pressure corrector
|
||||||
|
fvScalarMatrix pEqn
|
||||||
|
(
|
||||||
|
fvm::ddt(psi, p)
|
||||||
|
+ fvc::div(phiHbyA)
|
||||||
|
- fvm::laplacian(rhorAUf, p)
|
||||||
|
==
|
||||||
|
fvOptions(psi, p, rho.name())
|
||||||
|
);
|
||||||
|
|
||||||
|
pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter())));
|
||||||
|
|
||||||
|
if (pimple.finalNonOrthogonalIter())
|
||||||
|
{
|
||||||
|
phi = phiHbyA + pEqn.flux();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "rhoEqn.H"
|
||||||
|
#include "compressibleContinuityErrs.H"
|
||||||
|
|
||||||
|
// Explicitly relax pressure for momentum corrector
|
||||||
|
p.relax();
|
||||||
|
|
||||||
|
// Recalculate density from the relaxed pressure
|
||||||
|
rho = thermo.rho();
|
||||||
|
rho = max(rho, rhoMin);
|
||||||
|
rho = min(rho, rhoMax);
|
||||||
|
rho.relax();
|
||||||
|
Info<< "rho max/min : " << max(rho).value()
|
||||||
|
<< " " << min(rho).value() << endl;
|
||||||
|
|
||||||
|
volVectorField gradP(fvc::grad(p));
|
||||||
|
//mesh.interpolate(gradP);
|
||||||
|
U = HbyA - rAU*cellMask*gradP;
|
||||||
|
U.correctBoundaryConditions();
|
||||||
|
fvOptions.correct(U);
|
||||||
|
K = 0.5*magSqr(U);
|
||||||
|
|
||||||
|
{
|
||||||
|
rhoUf = fvc::interpolate(rho*U);
|
||||||
|
surfaceVectorField n(mesh.Sf()/mesh.magSf());
|
||||||
|
rhoUf += n*(fvc::absolute(phi, rho, U)/mesh.magSf() - (n & rhoUf));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thermo.dpdt())
|
||||||
|
{
|
||||||
|
dpdt = fvc::ddt(p);
|
||||||
|
|
||||||
|
if (mesh.moving())
|
||||||
|
{
|
||||||
|
dpdt -= fvc::div(fvc::meshPhi(rho, U), p);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
#include "readTimeControls.H"
|
||||||
|
|
||||||
|
correctPhi = pimple.dict().lookupOrDefault<Switch>("correctPhi", true);
|
||||||
|
|
||||||
|
checkMeshCourantNo =
|
||||||
|
pimple.dict().lookupOrDefault<Switch>("checkMeshCourantNo", false);
|
||||||
@ -0,0 +1,173 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
rhoPimpleFoam
|
||||||
|
|
||||||
|
Group
|
||||||
|
grpCompressibleSolvers grpMovingMeshSolvers
|
||||||
|
|
||||||
|
Description
|
||||||
|
Transient solver for laminar or turbulent flow of compressible fluids
|
||||||
|
for HVAC and similar applications.
|
||||||
|
|
||||||
|
Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and
|
||||||
|
pseudo-transient simulations.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "fvCFD.H"
|
||||||
|
#include "dynamicFvMesh.H"
|
||||||
|
#include "psiThermo.H"
|
||||||
|
#include "turbulentFluidThermoModel.H"
|
||||||
|
#include "bound.H"
|
||||||
|
#include "pimpleControl.H"
|
||||||
|
#include "CorrectPhi.H"
|
||||||
|
#include "fvOptions.H"
|
||||||
|
#include "localEulerDdtScheme.H"
|
||||||
|
#include "fvcSmooth.H"
|
||||||
|
#include "cellCellStencilObject.H"
|
||||||
|
#include "localMin.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#include "setRootCase.H"
|
||||||
|
#include "createTime.H"
|
||||||
|
#include "createDynamicFvMesh.H"
|
||||||
|
|
||||||
|
pimpleControl pimple(mesh);
|
||||||
|
|
||||||
|
#include "createRDeltaT.H"
|
||||||
|
#include "initContinuityErrs.H"
|
||||||
|
#include "createFields.H"
|
||||||
|
#include "createMRF.H"
|
||||||
|
#include "createFvOptions.H"
|
||||||
|
#include "createRhoUf.H"
|
||||||
|
#include "createControls.H"
|
||||||
|
|
||||||
|
turbulence->validate();
|
||||||
|
|
||||||
|
if (!LTS)
|
||||||
|
{
|
||||||
|
#include "compressibleCourantNo.H"
|
||||||
|
#include "setInitialDeltaT.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Info<< "\nStarting time loop\n" << endl;
|
||||||
|
|
||||||
|
while (runTime.run())
|
||||||
|
{
|
||||||
|
#include "readControls.H"
|
||||||
|
|
||||||
|
{
|
||||||
|
// Store divrhoU from the previous mesh so that it can be mapped
|
||||||
|
// and used in correctPhi to ensure the corrected phi has the
|
||||||
|
// same divergence
|
||||||
|
volScalarField divrhoU
|
||||||
|
(
|
||||||
|
"divrhoU",
|
||||||
|
fvc::div(fvc::absolute(phi, rho, U))
|
||||||
|
);
|
||||||
|
|
||||||
|
if (LTS)
|
||||||
|
{
|
||||||
|
#include "setRDeltaT.H"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#include "compressibleCourantNo.H"
|
||||||
|
#include "setDeltaT.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
runTime++;
|
||||||
|
|
||||||
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
|
// Store momentum to set rhoUf for introduced faces.
|
||||||
|
volVectorField rhoU("rhoU", rho*U);
|
||||||
|
|
||||||
|
// Do any mesh changes
|
||||||
|
mesh.update();
|
||||||
|
|
||||||
|
if (mesh.changing())
|
||||||
|
{
|
||||||
|
#include "setCellMask.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mesh.changing() && correctPhi)
|
||||||
|
{
|
||||||
|
// Calculate absolute flux from the mapped surface velocity
|
||||||
|
phi = mesh.Sf() & rhoUf;
|
||||||
|
|
||||||
|
#include "correctPhi.H"
|
||||||
|
|
||||||
|
// Make the fluxes relative to the mesh-motion
|
||||||
|
fvc::makeRelative(phi, rho, U);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mesh.changing() && checkMeshCourantNo)
|
||||||
|
{
|
||||||
|
#include "meshCourantNo.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "rhoEqn.H"
|
||||||
|
Info<< "rhoEqn max/min : " << max(rho).value()
|
||||||
|
<< " " << min(rho).value() << endl;
|
||||||
|
|
||||||
|
// --- Pressure-velocity PIMPLE corrector loop
|
||||||
|
while (pimple.loop())
|
||||||
|
{
|
||||||
|
#include "UEqn.H"
|
||||||
|
#include "EEqn.H"
|
||||||
|
|
||||||
|
// --- Pressure corrector loop
|
||||||
|
while (pimple.correct())
|
||||||
|
{
|
||||||
|
#include "pEqn.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pimple.turbCorr())
|
||||||
|
{
|
||||||
|
turbulence->correct();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
runTime.write();
|
||||||
|
|
||||||
|
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||||
|
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||||
|
<< nl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Global
|
||||||
|
CourantNo
|
||||||
|
|
||||||
|
Description
|
||||||
|
Calculates and outputs the mean and maximum Courant Numbers.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
scalar CoNum = 0.0;
|
||||||
|
scalar meanCoNum = 0.0;
|
||||||
|
|
||||||
|
if (mesh.nInternalFaces())
|
||||||
|
{
|
||||||
|
surfaceScalarField phiMask(localMin<scalar>(mesh).interpolate(cellMask));
|
||||||
|
|
||||||
|
scalarField sumPhi(fvc::surfaceSum(mag(phiMask*phi))().internalField());
|
||||||
|
|
||||||
|
CoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue();
|
||||||
|
|
||||||
|
meanCoNum =
|
||||||
|
0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaTValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "Courant Number mean: " << meanCoNum
|
||||||
|
<< " max: " << CoNum << endl;
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
pimpleDyMFoam.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/overPimpleDyMFoam
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I.. \
|
||||||
|
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||||
|
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
|
||||||
|
-I$(LIB_SRC)/transportModels \
|
||||||
|
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/sampling/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/overset/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
-lturbulenceModels \
|
||||||
|
-lincompressibleTurbulenceModels \
|
||||||
|
-lincompressibleTransportModels \
|
||||||
|
-lfiniteVolume \
|
||||||
|
-lfvOptions \
|
||||||
|
-lsampling \
|
||||||
|
-ldynamicFvMesh \
|
||||||
|
-ltopoChangerFvMesh \
|
||||||
|
-ldynamicMesh \
|
||||||
|
-loverset
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
// Solve the Momentum equation
|
||||||
|
|
||||||
|
MRF.correctBoundaryVelocity(U);
|
||||||
|
|
||||||
|
tmp<fvVectorMatrix> tUEqn
|
||||||
|
(
|
||||||
|
fvm::ddt(U) + fvm::div(phi, U)
|
||||||
|
+ MRF.DDt(U)
|
||||||
|
+ turbulence->divDevReff(U)
|
||||||
|
==
|
||||||
|
fvOptions(U)
|
||||||
|
);
|
||||||
|
fvVectorMatrix& UEqn = tUEqn.ref();
|
||||||
|
|
||||||
|
UEqn.relax();
|
||||||
|
|
||||||
|
fvOptions.constrain(UEqn);
|
||||||
|
|
||||||
|
if (pimple.momentumPredictor())
|
||||||
|
{
|
||||||
|
solve(UEqn == -cellMask*fvc::grad(p));
|
||||||
|
|
||||||
|
fvOptions.correct(U);
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Global
|
||||||
|
continuityErrs
|
||||||
|
|
||||||
|
Description
|
||||||
|
Calculates and prints the continuity errors.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
{
|
||||||
|
volScalarField contErr(interpolatedCells*cellMask*fvc::div(phi));
|
||||||
|
|
||||||
|
scalar sumLocalContErr = runTime.deltaTValue()*
|
||||||
|
mag(contErr)().weightedAverage(mesh.V()).value();
|
||||||
|
|
||||||
|
scalar globalContErr = runTime.deltaTValue()*
|
||||||
|
contErr.weightedAverage(mesh.V()).value();
|
||||||
|
cumulativeContErr += globalContErr;
|
||||||
|
|
||||||
|
Info<< "time step continuity errors : sum local = " << sumLocalContErr
|
||||||
|
<< ", global = " << globalContErr
|
||||||
|
<< ", cumulative = " << cumulativeContErr
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,113 @@
|
|||||||
|
if (mesh.changing())
|
||||||
|
{
|
||||||
|
volVectorField::Boundary& bfld = U.boundaryFieldRef();
|
||||||
|
forAll(bfld, patchi)
|
||||||
|
{
|
||||||
|
if (bfld[patchi].fixesValue())
|
||||||
|
{
|
||||||
|
bfld[patchi].initEvaluate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
surfaceScalarField::Boundary& phiBfld = phi.boundaryFieldRef();
|
||||||
|
forAll(bfld, patchi)
|
||||||
|
{
|
||||||
|
if (bfld[patchi].fixesValue())
|
||||||
|
{
|
||||||
|
bfld[patchi].evaluate();
|
||||||
|
|
||||||
|
phiBfld[patchi] = bfld[patchi] & mesh.Sf().boundaryField()[patchi];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Initialize BCs list for pcorr to zero-gradient
|
||||||
|
wordList pcorrTypes
|
||||||
|
(
|
||||||
|
p.boundaryField().size(),
|
||||||
|
zeroGradientFvPatchScalarField::typeName
|
||||||
|
);
|
||||||
|
|
||||||
|
// Set BCs of pcorr to fixed-value for patches at which p is fixed
|
||||||
|
forAll(p.boundaryField(), patchi)
|
||||||
|
{
|
||||||
|
if (p.boundaryField()[patchi].fixesValue())
|
||||||
|
{
|
||||||
|
pcorrTypes[patchi] = fixedValueFvPatchScalarField::typeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
volScalarField pcorr
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"pcorr",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
dimensionedScalar("pcorr", p.dimensions(), 0.0),
|
||||||
|
pcorrTypes
|
||||||
|
);
|
||||||
|
|
||||||
|
{
|
||||||
|
dimensionedScalar rAUf("rAUf", dimTime, 1.0);
|
||||||
|
|
||||||
|
const cellCellStencilObject& overlap = Stencil::New(mesh);
|
||||||
|
const labelList& cellTypes = overlap.cellTypes();
|
||||||
|
const labelIOList& zoneIDs = overlap.zoneID();
|
||||||
|
|
||||||
|
while (pimple.correctNonOrthogonal())
|
||||||
|
{
|
||||||
|
label nZones = gMax(zoneIDs)+1;
|
||||||
|
|
||||||
|
//label refCellI2 = -1;
|
||||||
|
labelList refCells(nZones, -1);
|
||||||
|
labelList refZones(nZones, -1);
|
||||||
|
|
||||||
|
forAll(zoneIDs, cellI)
|
||||||
|
{
|
||||||
|
label zoneId = zoneIDs[cellI];
|
||||||
|
if
|
||||||
|
(
|
||||||
|
refCells[zoneId] == -1
|
||||||
|
&& cellTypes[cellI] == cellCellStencil::CALCULATED
|
||||||
|
&& refZones[zoneId] == -1
|
||||||
|
)
|
||||||
|
{
|
||||||
|
refCells[zoneId] = cellI;
|
||||||
|
refZones[zoneId] = zoneId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fvScalarMatrix pcorrEqn
|
||||||
|
(
|
||||||
|
fvm::laplacian(rAUf, pcorr) == fvc::div(phi)
|
||||||
|
);
|
||||||
|
|
||||||
|
//pcorrEqn.setReference(refCellI2, 0.0, true);
|
||||||
|
scalarList values(nZones, 0.0);
|
||||||
|
pcorrEqn.setReferences(refCells, values, true);
|
||||||
|
|
||||||
|
const dictionary& d = mesh.solver
|
||||||
|
(
|
||||||
|
pcorr.select
|
||||||
|
(
|
||||||
|
pimple.finalInnerIter()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
mesh.fvMesh::solve(pcorrEqn, d);
|
||||||
|
|
||||||
|
if (pimple.finalNonOrthogonalIter())
|
||||||
|
{
|
||||||
|
phi -= pcorrEqn.flux();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (runTime.outputTime())
|
||||||
|
{
|
||||||
|
volScalarField("contPhiPcorr", fvc::div(phi)).write();
|
||||||
|
pcorr.write();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
#include "createTimeControls.H"
|
||||||
|
|
||||||
|
bool correctPhi
|
||||||
|
(
|
||||||
|
pimple.dict().lookupOrDefault("correctPhi", false)
|
||||||
|
);
|
||||||
|
|
||||||
|
bool checkMeshCourantNo
|
||||||
|
(
|
||||||
|
pimple.dict().lookupOrDefault("checkMeshCourantNo", false)
|
||||||
|
);
|
||||||
|
|
||||||
|
bool massFluxInterpolation
|
||||||
|
(
|
||||||
|
pimple.dict().lookupOrDefault("massFluxInterpolation", false)
|
||||||
|
);
|
||||||
|
|
||||||
|
bool adjustFringe
|
||||||
|
(
|
||||||
|
pimple.dict().lookupOrDefault("oversetAdjustPhi", false)
|
||||||
|
);
|
||||||
|
|
||||||
|
bool ddtCorr
|
||||||
|
(
|
||||||
|
pimple.dict().lookupOrDefault("ddtCorr", true)
|
||||||
|
);
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
Info<< "Reading field p\n" << endl;
|
||||||
|
volScalarField p
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"p",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "Reading field U\n" << endl;
|
||||||
|
volVectorField U
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"U",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
#include "createPhi.H"
|
||||||
|
|
||||||
|
|
||||||
|
label pRefCell = 0;
|
||||||
|
scalar pRefValue = 0.0;
|
||||||
|
setRefCell(p, pimple.dict(), pRefCell, pRefValue);
|
||||||
|
mesh.setFluxRequired(p.name());
|
||||||
|
|
||||||
|
|
||||||
|
//- Overset specific
|
||||||
|
|
||||||
|
// Add solver-specific interpolations
|
||||||
|
{
|
||||||
|
dictionary oversetDict;
|
||||||
|
oversetDict.add("U", true);
|
||||||
|
oversetDict.add("p", true);
|
||||||
|
oversetDict.add("HbyA", true);
|
||||||
|
oversetDict.add("grad(p)", true);
|
||||||
|
|
||||||
|
const_cast<dictionary&>
|
||||||
|
(
|
||||||
|
mesh.schemesDict()
|
||||||
|
).add
|
||||||
|
(
|
||||||
|
"oversetInterpolationRequired",
|
||||||
|
oversetDict,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mask field for zeroing out contributions on hole cells
|
||||||
|
#include "createCellMask.H"
|
||||||
|
|
||||||
|
// Create bool field with interpolated cells
|
||||||
|
#include "createInterpolatedCells.H"
|
||||||
|
|
||||||
|
singlePhaseTransportModel laminarTransport(U, phi);
|
||||||
|
|
||||||
|
autoPtr<incompressible::turbulenceModel> turbulence
|
||||||
|
(
|
||||||
|
incompressible::turbulenceModel::New(U, phi, laminarTransport)
|
||||||
|
);
|
||||||
@ -0,0 +1,269 @@
|
|||||||
|
// Interpolation used
|
||||||
|
interpolationCellPoint<vector> UInterpolator(HbyA);
|
||||||
|
|
||||||
|
// Determine faces on outside of interpolated cells
|
||||||
|
PackedBoolList isOwnerInterpolatedFace(mesh.nInternalFaces());
|
||||||
|
PackedBoolList isNeiInterpolatedFace(mesh.nInternalFaces());
|
||||||
|
|
||||||
|
// Determine donor cells
|
||||||
|
labelListList donorCell(mesh.nInternalFaces());
|
||||||
|
|
||||||
|
scalarListList weightCellCells(mesh.nInternalFaces());
|
||||||
|
|
||||||
|
// Interpolated HbyA faces
|
||||||
|
vectorField UIntFaces(mesh.nInternalFaces(), vector::zero);
|
||||||
|
|
||||||
|
// Determine receptor neighbourd cells
|
||||||
|
labelList receptorNeigCell(mesh.nInternalFaces(), -1);
|
||||||
|
|
||||||
|
{
|
||||||
|
const cellCellStencilObject& overlap = Stencil::New(mesh);
|
||||||
|
const labelList& cellTypes = overlap.cellTypes();
|
||||||
|
const labelIOList& zoneID = overlap.zoneID();
|
||||||
|
|
||||||
|
label nZones = gMax(zoneID)+1;
|
||||||
|
PtrList<fvMeshSubset> meshParts(nZones);
|
||||||
|
labelList nCellsPerZone(nZones, 0);
|
||||||
|
|
||||||
|
forAll(nCellsPerZone, zoneI)
|
||||||
|
{
|
||||||
|
meshParts.set(zoneI, new fvMeshSubset(mesh));
|
||||||
|
meshParts[zoneI].setLargeCellSubset(zoneID, zoneI);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
|
||||||
|
{
|
||||||
|
label ownType = cellTypes[mesh.faceOwner()[faceI]];
|
||||||
|
label neiType = cellTypes[mesh.faceNeighbour()[faceI]];
|
||||||
|
if
|
||||||
|
(
|
||||||
|
ownType == cellCellStencil::INTERPOLATED
|
||||||
|
&& neiType == cellCellStencil::CALCULATED
|
||||||
|
)
|
||||||
|
{
|
||||||
|
isOwnerInterpolatedFace[faceI] = true;
|
||||||
|
|
||||||
|
const vector& fc = mesh.faceCentres()[faceI];
|
||||||
|
|
||||||
|
for (label zoneI = 0; zoneI < nZones; zoneI++)
|
||||||
|
{
|
||||||
|
if (zoneI != zoneID[mesh.faceOwner()[faceI]])
|
||||||
|
{
|
||||||
|
const fvMesh& partMesh = meshParts[zoneI].subMesh();
|
||||||
|
const labelList& cellMap = meshParts[zoneI].cellMap();
|
||||||
|
label cellI = partMesh.findCell(fc);
|
||||||
|
|
||||||
|
if (cellI != -1)
|
||||||
|
{
|
||||||
|
// Determine weights
|
||||||
|
labelList stencil(partMesh.cellCells()[cellI]);
|
||||||
|
|
||||||
|
stencil.append(cellI);
|
||||||
|
|
||||||
|
label st = stencil.size();
|
||||||
|
|
||||||
|
donorCell[faceI].setSize(st);
|
||||||
|
|
||||||
|
weightCellCells[faceI].setSize(st);
|
||||||
|
|
||||||
|
scalarField weights(st);
|
||||||
|
|
||||||
|
forAll(stencil, i)
|
||||||
|
{
|
||||||
|
scalar d = mag
|
||||||
|
(
|
||||||
|
partMesh.cellCentres()[stencil[i]]
|
||||||
|
- fc
|
||||||
|
);
|
||||||
|
weights[i] = 1.0/d;
|
||||||
|
donorCell[faceI][i] = cellMap[stencil[i]];
|
||||||
|
}
|
||||||
|
weights /= sum(weights);
|
||||||
|
|
||||||
|
weightCellCells[faceI] = weights;
|
||||||
|
|
||||||
|
forAll(stencil, i)
|
||||||
|
{
|
||||||
|
UIntFaces[faceI] +=
|
||||||
|
weightCellCells[faceI][i]
|
||||||
|
*UInterpolator.interpolate
|
||||||
|
(
|
||||||
|
fc,
|
||||||
|
donorCell[faceI][i]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
receptorNeigCell[faceI] = mesh.faceNeighbour()[faceI];
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
ownType == cellCellStencil::CALCULATED
|
||||||
|
&& neiType == cellCellStencil::INTERPOLATED
|
||||||
|
)
|
||||||
|
{
|
||||||
|
isNeiInterpolatedFace[faceI] = true;
|
||||||
|
|
||||||
|
const vector& fc = mesh.faceCentres()[faceI];
|
||||||
|
for (label zoneI = 0; zoneI < nZones; zoneI++)
|
||||||
|
{
|
||||||
|
if (zoneI != zoneID[mesh.faceNeighbour()[faceI]])
|
||||||
|
{
|
||||||
|
const fvMesh& partMesh = meshParts[zoneI].subMesh();
|
||||||
|
const labelList& cellMap = meshParts[zoneI].cellMap();
|
||||||
|
label cellI = partMesh.findCell(fc);
|
||||||
|
|
||||||
|
if (cellI != -1)
|
||||||
|
{
|
||||||
|
// Determine weights
|
||||||
|
labelList stencil(partMesh.cellCells()[cellI]);
|
||||||
|
|
||||||
|
stencil.append(cellI);
|
||||||
|
|
||||||
|
label st = stencil.size();
|
||||||
|
|
||||||
|
donorCell[faceI].setSize(st);
|
||||||
|
|
||||||
|
weightCellCells[faceI].setSize(st);
|
||||||
|
|
||||||
|
scalarField weights(st);
|
||||||
|
|
||||||
|
forAll(stencil, i)
|
||||||
|
{
|
||||||
|
scalar d = mag
|
||||||
|
(
|
||||||
|
partMesh.cellCentres()[stencil[i]]
|
||||||
|
- fc
|
||||||
|
);
|
||||||
|
weights[i] = 1.0/d;
|
||||||
|
donorCell[faceI][i] = cellMap[stencil[i]];
|
||||||
|
}
|
||||||
|
weights /= sum(weights);
|
||||||
|
|
||||||
|
weightCellCells[faceI] = weights;
|
||||||
|
|
||||||
|
forAll(stencil, i)
|
||||||
|
{
|
||||||
|
UIntFaces[faceI] +=
|
||||||
|
weightCellCells[faceI][i]
|
||||||
|
*UInterpolator.interpolate
|
||||||
|
(
|
||||||
|
fc,
|
||||||
|
donorCell[faceI][i]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
receptorNeigCell[faceI] = mesh.faceOwner()[faceI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// contravariant U
|
||||||
|
vectorField U1Contrav(mesh.nInternalFaces(), vector::zero);
|
||||||
|
|
||||||
|
surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf());
|
||||||
|
|
||||||
|
forAll(isNeiInterpolatedFace, faceI)
|
||||||
|
{
|
||||||
|
label cellId = -1;
|
||||||
|
if (isNeiInterpolatedFace[faceI])
|
||||||
|
{
|
||||||
|
cellId = mesh.faceNeighbour()[faceI];
|
||||||
|
}
|
||||||
|
else if (isOwnerInterpolatedFace[faceI])
|
||||||
|
{
|
||||||
|
cellId = mesh.faceOwner()[faceI];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cellId != -1)
|
||||||
|
{
|
||||||
|
const vector& n = faceNormals[faceI];
|
||||||
|
vector n1 = vector::zero;
|
||||||
|
// 2-D cases
|
||||||
|
if (mesh.nSolutionD() == 2)
|
||||||
|
{
|
||||||
|
for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
|
||||||
|
{
|
||||||
|
if (mesh.geometricD()[cmpt] == -1)
|
||||||
|
{
|
||||||
|
switch (cmpt)
|
||||||
|
{
|
||||||
|
case vector::X:
|
||||||
|
{
|
||||||
|
n1 = vector(0, n.z(), -n.y());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case vector::Y:
|
||||||
|
{
|
||||||
|
n1 = vector(n.z(), 0, -n.x());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case vector::Z:
|
||||||
|
{
|
||||||
|
n1 = vector(n.y(), -n.x(), 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mesh.nSolutionD() == 3)
|
||||||
|
{
|
||||||
|
//Determine which is the primary direction
|
||||||
|
if (mag(n.x()) > mag(n.y()) && mag(n.x()) > mag(n.z()))
|
||||||
|
{
|
||||||
|
n1 = vector(n.y(), -n.x(), 0);
|
||||||
|
}
|
||||||
|
else if (mag(n.y()) > mag(n.z()))
|
||||||
|
{
|
||||||
|
n1 = vector(0, n.z(), -n.y());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
n1 = vector(-n.z(), 0, n.x());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
n1 /= mag(n1);
|
||||||
|
|
||||||
|
vector n2 = n ^ n1;
|
||||||
|
n2 /= mag(n2);
|
||||||
|
|
||||||
|
tensor rot =
|
||||||
|
tensor
|
||||||
|
(
|
||||||
|
n.x() ,n.y(), n.z(),
|
||||||
|
n1.x() ,n1.y(), n1.z(),
|
||||||
|
n2.x() ,n2.y(), n2.z()
|
||||||
|
);
|
||||||
|
|
||||||
|
// tensor rot =
|
||||||
|
// tensor
|
||||||
|
// (
|
||||||
|
// n & x ,n & y, n & z,
|
||||||
|
// n1 & x ,n1 & y, n1 & z,
|
||||||
|
// n2 & x ,n2 & y, n2 & z
|
||||||
|
// );
|
||||||
|
|
||||||
|
U1Contrav[faceI].x() =
|
||||||
|
2*transform(rot, UIntFaces[faceI]).x()
|
||||||
|
- transform(rot, HbyA[receptorNeigCell[faceI]]).x();
|
||||||
|
|
||||||
|
U1Contrav[faceI].y() = transform(rot, HbyA[cellId]).y();
|
||||||
|
|
||||||
|
U1Contrav[faceI].z() = transform(rot, HbyA[cellId]).z();
|
||||||
|
|
||||||
|
HbyA[cellId] = transform(inv(rot), U1Contrav[faceI]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,109 @@
|
|||||||
|
volScalarField rAU(1.0/UEqn.A());
|
||||||
|
|
||||||
|
// Option 1: interpolate rAU, do not block out rAU on blocked cells
|
||||||
|
//mesh.interpolate(rAU, false);
|
||||||
|
//surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU));
|
||||||
|
|
||||||
|
// Option 2: do not interpolate rAU but block out rAU
|
||||||
|
//surfaceScalarField rAUf("rAUf", fvc::interpolate(blockedCells*rAU));
|
||||||
|
|
||||||
|
|
||||||
|
// Option 3: do not interpolate rAU but zero out rAUf on faces on holes
|
||||||
|
// But what about:
|
||||||
|
//
|
||||||
|
// H
|
||||||
|
// H I C C C C
|
||||||
|
// H
|
||||||
|
//
|
||||||
|
|
||||||
|
surfaceScalarField faceMask(localMin<scalar>(mesh).interpolate(cellMask));
|
||||||
|
surfaceScalarField rAUf("rAUf", faceMask*fvc::interpolate(rAU));
|
||||||
|
|
||||||
|
volVectorField HbyA("HbyA", U);
|
||||||
|
HbyA = constrainHbyA(rAU*UEqn.H(), U, p);
|
||||||
|
|
||||||
|
//mesh.interpolate(HbyA);
|
||||||
|
if (massFluxInterpolation)
|
||||||
|
{
|
||||||
|
#include "interpolatedFaces.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pimple.nCorrPISO() <= 1)
|
||||||
|
{
|
||||||
|
tUEqn.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA));
|
||||||
|
|
||||||
|
if (ddtCorr)
|
||||||
|
{
|
||||||
|
phiHbyA += rAUf*fvc::ddtCorr(U, Uf);
|
||||||
|
}
|
||||||
|
|
||||||
|
MRF.makeRelative(phiHbyA);
|
||||||
|
|
||||||
|
if (p.needReference())
|
||||||
|
{
|
||||||
|
fvc::makeRelative(phiHbyA, U);
|
||||||
|
adjustPhi(phiHbyA, U, p);
|
||||||
|
fvc::makeAbsolute(phiHbyA, U);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (adjustFringe)
|
||||||
|
{
|
||||||
|
fvc::makeRelative(phiHbyA, U);
|
||||||
|
oversetAdjustPhi(phiHbyA, U);
|
||||||
|
fvc::makeAbsolute(phiHbyA, U);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (runTime.outputTime())
|
||||||
|
{
|
||||||
|
volScalarField
|
||||||
|
(
|
||||||
|
"div(phiHbyA)",
|
||||||
|
fvc::div(phiHbyA)
|
||||||
|
//interpolatedCells*cellMask*fvc::div(phiHbyA)
|
||||||
|
).write();
|
||||||
|
}
|
||||||
|
|
||||||
|
while (pimple.correctNonOrthogonal())
|
||||||
|
{
|
||||||
|
fvScalarMatrix pEqn
|
||||||
|
(
|
||||||
|
fvm::laplacian(rAUf, p) == fvc::div(phiHbyA)
|
||||||
|
);
|
||||||
|
|
||||||
|
pEqn.setReference(pRefCell, pRefValue);
|
||||||
|
|
||||||
|
pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter())));
|
||||||
|
|
||||||
|
if (pimple.finalNonOrthogonalIter())
|
||||||
|
{
|
||||||
|
phi = phiHbyA - pEqn.flux();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "continuityErrs.H"
|
||||||
|
|
||||||
|
// Explicitly relax pressure for momentum corrector
|
||||||
|
p.relax();
|
||||||
|
volVectorField gradP(fvc::grad(p));
|
||||||
|
//mesh.interpolate(gradP);
|
||||||
|
|
||||||
|
// Option 1: leave velocity intact on blocked out cells
|
||||||
|
//U = HbyA - rAU*gradP;
|
||||||
|
|
||||||
|
// Option 2: zero out velocity on blocked out cells
|
||||||
|
U = (HbyA - rAU*cellMask*gradP);
|
||||||
|
U.correctBoundaryConditions();
|
||||||
|
|
||||||
|
fvOptions.correct(U);
|
||||||
|
|
||||||
|
{
|
||||||
|
Uf = fvc::interpolate(U);
|
||||||
|
surfaceVectorField n(mesh.Sf()/mesh.magSf());
|
||||||
|
Uf += n*(phi/mesh.magSf() - (n & Uf));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make the fluxes relative to the mesh motion
|
||||||
|
fvc::makeRelative(phi, U);
|
||||||
@ -0,0 +1,157 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
pimpleDyMFoam.C
|
||||||
|
|
||||||
|
Group
|
||||||
|
grpIncompressibleSolvers grpMovingMeshSolvers
|
||||||
|
|
||||||
|
Description
|
||||||
|
Transient solver for incompressible, flow of Newtonian fluids
|
||||||
|
on a moving mesh using the PIMPLE (merged PISO-SIMPLE) algorithm.
|
||||||
|
|
||||||
|
Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "fvCFD.H"
|
||||||
|
#include "dynamicFvMesh.H"
|
||||||
|
#include "singlePhaseTransportModel.H"
|
||||||
|
#include "turbulentTransportModel.H"
|
||||||
|
#include "pimpleControl.H"
|
||||||
|
#include "fvOptions.H"
|
||||||
|
|
||||||
|
#include "cellCellStencilObject.H"
|
||||||
|
#include "zeroGradientFvPatchFields.H"
|
||||||
|
#include "localMin.H"
|
||||||
|
#include "interpolationCellPoint.H"
|
||||||
|
#include "transform.H"
|
||||||
|
#include "fvMeshSubset.H"
|
||||||
|
#include "oversetAdjustPhi.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::addNote
|
||||||
|
(
|
||||||
|
"Experimental version of pimpleDyMFoam with support for overset meshes"
|
||||||
|
);
|
||||||
|
#include "setRootCase.H"
|
||||||
|
#include "createTime.H"
|
||||||
|
#include "createDynamicFvMesh.H"
|
||||||
|
#include "initContinuityErrs.H"
|
||||||
|
|
||||||
|
pimpleControl pimple(mesh);
|
||||||
|
|
||||||
|
#include "createFields.H"
|
||||||
|
#include "createUf.H"
|
||||||
|
#include "createMRF.H"
|
||||||
|
#include "createFvOptions.H"
|
||||||
|
#include "createControls.H"
|
||||||
|
#include "CourantNo.H"
|
||||||
|
#include "setInitialDeltaT.H"
|
||||||
|
|
||||||
|
turbulence->validate();
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Info<< "\nStarting time loop\n" << endl;
|
||||||
|
|
||||||
|
while (runTime.run())
|
||||||
|
{
|
||||||
|
#include "readControls.H"
|
||||||
|
#include "CourantNo.H"
|
||||||
|
|
||||||
|
#include "setDeltaT.H"
|
||||||
|
|
||||||
|
runTime++;
|
||||||
|
|
||||||
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
|
bool changed = mesh.update();
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
#include "setCellMask.H"
|
||||||
|
#include "setInterpolatedCells.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate absolute flux from the mapped surface velocity
|
||||||
|
phi = mesh.Sf() & Uf;
|
||||||
|
|
||||||
|
if (runTime.outputTime())
|
||||||
|
{
|
||||||
|
volScalarField
|
||||||
|
(
|
||||||
|
"contPhi",
|
||||||
|
interpolatedCells*cellMask*fvc::div(phi)
|
||||||
|
).write();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mesh.changing() && correctPhi)
|
||||||
|
{
|
||||||
|
#include "correctPhi.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make the flux relative to the mesh motion
|
||||||
|
fvc::makeRelative(phi, U);
|
||||||
|
|
||||||
|
if (mesh.changing() && checkMeshCourantNo)
|
||||||
|
{
|
||||||
|
#include "meshCourantNo.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Pressure-velocity PIMPLE corrector loop
|
||||||
|
while (pimple.loop())
|
||||||
|
{
|
||||||
|
#include "UEqn.H"
|
||||||
|
|
||||||
|
// --- Pressure corrector loop
|
||||||
|
while (pimple.correct())
|
||||||
|
{
|
||||||
|
#include "pEqn.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pimple.turbCorr())
|
||||||
|
{
|
||||||
|
laminarTransport.correct();
|
||||||
|
turbulence->correct();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
runTime.write();
|
||||||
|
|
||||||
|
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||||
|
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||||
|
<< nl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
#include "readTimeControls.H"
|
||||||
|
|
||||||
|
correctPhi = pimple.dict().lookupOrDefault("correctPhi", false);
|
||||||
|
|
||||||
|
checkMeshCourantNo = pimple.dict().lookupOrDefault("checkMeshCourantNo", false);
|
||||||
|
|
||||||
|
massFluxInterpolation =
|
||||||
|
pimple.dict().lookupOrDefault("massFluxInterpolation", false);
|
||||||
|
|
||||||
|
ddtCorr = pimple.dict().lookupOrDefault("ddtCorr", true);
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
simpleFoam.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/overSimpleFoam
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I. \
|
||||||
|
-I$(FOAM_SOLVERS)/incompressible/pimpleFoam/overPimpleDyMFoam \
|
||||||
|
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||||
|
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
|
||||||
|
-I$(LIB_SRC)/transportModels \
|
||||||
|
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/sampling/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/overset/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
-lturbulenceModels \
|
||||||
|
-lincompressibleTurbulenceModels \
|
||||||
|
-lincompressibleTransportModels \
|
||||||
|
-lfiniteVolume \
|
||||||
|
-lfvOptions \
|
||||||
|
-lsampling \
|
||||||
|
-ldynamicFvMesh \
|
||||||
|
-ltopoChangerFvMesh \
|
||||||
|
-ldynamicMesh \
|
||||||
|
-loverset
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
// Momentum predictor
|
||||||
|
|
||||||
|
MRF.correctBoundaryVelocity(U);
|
||||||
|
|
||||||
|
tmp<fvVectorMatrix> tUEqn
|
||||||
|
(
|
||||||
|
fvm::div(phi, U)
|
||||||
|
+ MRF.DDt(U)
|
||||||
|
+ turbulence->divDevReff(U)
|
||||||
|
==
|
||||||
|
fvOptions(U)
|
||||||
|
);
|
||||||
|
fvVectorMatrix& UEqn = tUEqn.ref();
|
||||||
|
|
||||||
|
UEqn.relax();
|
||||||
|
|
||||||
|
fvOptions.constrain(UEqn);
|
||||||
|
|
||||||
|
solve(UEqn == -cellMask*fvc::grad(p));
|
||||||
|
|
||||||
|
fvOptions.correct(U);
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Global
|
||||||
|
continuityErrs
|
||||||
|
|
||||||
|
Description
|
||||||
|
Calculates and prints the continuity errors.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
{
|
||||||
|
volScalarField contErr(interpolatedCells*cellMask*fvc::div(phi));
|
||||||
|
|
||||||
|
scalar sumLocalContErr = runTime.deltaTValue()*
|
||||||
|
mag(contErr)().weightedAverage(mesh.V()).value();
|
||||||
|
|
||||||
|
scalar globalContErr = runTime.deltaTValue()*
|
||||||
|
contErr.weightedAverage(mesh.V()).value();
|
||||||
|
cumulativeContErr += globalContErr;
|
||||||
|
|
||||||
|
Info<< "time step continuity errors : sum local = " << sumLocalContErr
|
||||||
|
<< ", global = " << globalContErr
|
||||||
|
<< ", cumulative = " << cumulativeContErr
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
Info<< "Reading field p\n" << endl;
|
||||||
|
volScalarField p
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"p",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "Reading field U\n" << endl;
|
||||||
|
volVectorField U
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"U",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
#include "createPhi.H"
|
||||||
|
|
||||||
|
|
||||||
|
label pRefCell = 0;
|
||||||
|
scalar pRefValue = 0.0;
|
||||||
|
setRefCell(p, simple.dict(), pRefCell, pRefValue);
|
||||||
|
mesh.setFluxRequired(p.name());
|
||||||
|
|
||||||
|
|
||||||
|
singlePhaseTransportModel laminarTransport(U, phi);
|
||||||
|
|
||||||
|
autoPtr<incompressible::turbulenceModel> turbulence
|
||||||
|
(
|
||||||
|
incompressible::turbulenceModel::New(U, phi, laminarTransport)
|
||||||
|
);
|
||||||
|
|
||||||
|
#include "createMRF.H"
|
||||||
|
|
||||||
|
#include "createOversetFields.H"
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
//- Overset specific
|
||||||
|
|
||||||
|
// Add solver-specific interpolations
|
||||||
|
{
|
||||||
|
dictionary oversetDict;
|
||||||
|
oversetDict.add("U", true);
|
||||||
|
oversetDict.add("p", true);
|
||||||
|
oversetDict.add("HbyA", true);
|
||||||
|
oversetDict.add("grad(p)", true);
|
||||||
|
|
||||||
|
const_cast<dictionary&>
|
||||||
|
(
|
||||||
|
mesh.schemesDict()
|
||||||
|
).add
|
||||||
|
(
|
||||||
|
"oversetInterpolationRequired",
|
||||||
|
oversetDict,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mask field for zeroing out contributions on hole cells
|
||||||
|
#include "createCellMask.H"
|
||||||
|
|
||||||
|
#include "createInterpolatedCells.H"
|
||||||
|
|
||||||
|
bool adjustFringe
|
||||||
|
(
|
||||||
|
simple.dict().lookupOrDefault("oversetAdjustPhi", false)
|
||||||
|
);
|
||||||
|
bool massFluxInterpolation
|
||||||
|
(
|
||||||
|
simple.dict().lookupOrDefault("massFluxInterpolation", false)
|
||||||
|
);
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
Info<< "Create dynamic mesh for time = "
|
||||||
|
<< runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
|
autoPtr<dynamicFvMesh> meshPtr
|
||||||
|
(
|
||||||
|
dynamicFvMesh::New
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
dynamicFvMesh::defaultRegion,
|
||||||
|
runTime.timeName(),
|
||||||
|
runTime,
|
||||||
|
IOobject::MUST_READ
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
dynamicFvMesh& mesh = meshPtr();
|
||||||
|
|
||||||
|
// Calculate initial mesh-to-mesh mapping. Note that this should be
|
||||||
|
// done under the hood, e.g. as a MeshObject
|
||||||
|
mesh.update();
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
{
|
||||||
|
surfaceScalarField faceMask(localMin<scalar>(mesh).interpolate(cellMask));
|
||||||
|
|
||||||
|
volScalarField rAU(1.0/UEqn.A());
|
||||||
|
surfaceScalarField rAUf("rAUf", faceMask*fvc::interpolate(rAU));
|
||||||
|
|
||||||
|
volVectorField HbyA("HbyA", U);
|
||||||
|
HbyA = constrainHbyA(rAU*UEqn.H(), U, p);
|
||||||
|
|
||||||
|
//mesh.interpolate(HbyA);
|
||||||
|
if (massFluxInterpolation)
|
||||||
|
{
|
||||||
|
#include "interpolatedFaces.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
tUEqn.clear();
|
||||||
|
|
||||||
|
surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA));
|
||||||
|
|
||||||
|
adjustPhi(phiHbyA, U, p);
|
||||||
|
|
||||||
|
if (adjustFringe)
|
||||||
|
{
|
||||||
|
oversetAdjustPhi(phiHbyA, U);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Non-orthogonal pressure corrector loop
|
||||||
|
while (simple.correctNonOrthogonal())
|
||||||
|
{
|
||||||
|
fvScalarMatrix pEqn
|
||||||
|
(
|
||||||
|
fvm::laplacian(rAUf, p) == fvc::div(phiHbyA)
|
||||||
|
);
|
||||||
|
|
||||||
|
pEqn.setReference(pRefCell, pRefValue);
|
||||||
|
|
||||||
|
pEqn.solve();
|
||||||
|
|
||||||
|
if (simple.finalNonOrthogonalIter())
|
||||||
|
{
|
||||||
|
phi = phiHbyA - pEqn.flux();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "continuityErrs.H"
|
||||||
|
|
||||||
|
// Explicitly relax pressure for momentum corrector
|
||||||
|
p.relax();
|
||||||
|
|
||||||
|
// Momentum corrector
|
||||||
|
volVectorField gradP(fvc::grad(p));
|
||||||
|
//mesh.interpolate(gradP);
|
||||||
|
|
||||||
|
U = HbyA - rAU*cellMask*gradP;
|
||||||
|
U.correctBoundaryConditions();
|
||||||
|
fvOptions.correct(U);
|
||||||
|
}
|
||||||
@ -0,0 +1,125 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
simpleFoam
|
||||||
|
|
||||||
|
Group
|
||||||
|
grpIncompressibleSolvers
|
||||||
|
|
||||||
|
Description
|
||||||
|
Steady-state solver for incompressible flows with turbulence modelling.
|
||||||
|
|
||||||
|
\heading Solver details
|
||||||
|
The solver uses the SIMPLE algorithm to solve the continuity equation:
|
||||||
|
|
||||||
|
\f[
|
||||||
|
\div \vec{U} = 0
|
||||||
|
\f]
|
||||||
|
|
||||||
|
and momentum equation:
|
||||||
|
|
||||||
|
\f[
|
||||||
|
\div \left( \vec{U} \vec{U} \right) - \div \gvec{R}
|
||||||
|
= - \grad p + \vec{S}_U
|
||||||
|
\f]
|
||||||
|
|
||||||
|
Where:
|
||||||
|
\vartable
|
||||||
|
\vec{U} | Velocity
|
||||||
|
p | Pressure
|
||||||
|
\vec{R} | Stress tensor
|
||||||
|
\vec{S}_U | Momentum source
|
||||||
|
\endvartable
|
||||||
|
|
||||||
|
\heading Required fields
|
||||||
|
\plaintable
|
||||||
|
U | Velocity [m/s]
|
||||||
|
p | Kinematic pressure, p/rho [m2/s2]
|
||||||
|
\<turbulence fields\> | As required by user selection
|
||||||
|
\endplaintable
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "fvCFD.H"
|
||||||
|
#include "singlePhaseTransportModel.H"
|
||||||
|
#include "turbulentTransportModel.H"
|
||||||
|
#include "simpleControl.H"
|
||||||
|
#include "fvOptions.H"
|
||||||
|
|
||||||
|
#include "dynamicFvMesh.H"
|
||||||
|
#include "cellCellStencilObject.H"
|
||||||
|
#include "localMin.H"
|
||||||
|
#include "interpolationCellPoint.H"
|
||||||
|
#include "fvMeshSubset.H"
|
||||||
|
#include "transform.H"
|
||||||
|
#include "oversetAdjustPhi.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#define CREATE_MESH createUpdatedDynamicFvMesh.H
|
||||||
|
#include "postProcess.H"
|
||||||
|
|
||||||
|
#include "setRootCase.H"
|
||||||
|
#include "createTime.H"
|
||||||
|
#include "createUpdatedDynamicFvMesh.H"
|
||||||
|
#include "createControl.H"
|
||||||
|
#include "createFields.H"
|
||||||
|
#include "createFvOptions.H"
|
||||||
|
#include "initContinuityErrs.H"
|
||||||
|
|
||||||
|
turbulence->validate();
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Info<< "\nStarting time loop\n" << endl;
|
||||||
|
|
||||||
|
while (simple.loop())
|
||||||
|
{
|
||||||
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
|
// --- Pressure-velocity SIMPLE corrector
|
||||||
|
{
|
||||||
|
#include "UEqn.H"
|
||||||
|
#include "pEqn.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
laminarTransport.correct();
|
||||||
|
turbulence->correct();
|
||||||
|
|
||||||
|
runTime.write();
|
||||||
|
|
||||||
|
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||||
|
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||||
|
<< nl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Global
|
||||||
|
CourantNo
|
||||||
|
|
||||||
|
Description
|
||||||
|
Calculates and outputs the mean and maximum Courant Numbers.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
scalar CoNum = 0.0;
|
||||||
|
scalar meanCoNum = 0.0;
|
||||||
|
|
||||||
|
if (mesh.nInternalFaces())
|
||||||
|
{
|
||||||
|
surfaceScalarField phiMask(localMin<scalar>(mesh).interpolate(cellMask));
|
||||||
|
|
||||||
|
scalarField sumPhi
|
||||||
|
(
|
||||||
|
fvc::surfaceSum(mag(phiMask*phi))().internalField()
|
||||||
|
);
|
||||||
|
|
||||||
|
CoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue();
|
||||||
|
|
||||||
|
meanCoNum =
|
||||||
|
0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaTValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "Courant Number mean: " << meanCoNum
|
||||||
|
<< " max: " << CoNum << endl;
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
interDyMFoam.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/overInterDyMFoam
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I. \
|
||||||
|
-I.. \
|
||||||
|
-I../../VoF \
|
||||||
|
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
|
||||||
|
-I$(LIB_SRC)/transportModels \
|
||||||
|
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
|
||||||
|
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
|
||||||
|
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||||
|
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
|
||||||
|
-I$(LIB_SRC)/transportModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
|
||||||
|
-I$(FOAM_SOLVERS)/incompressible/pimpleFoam/overPimpleDyMFoam \
|
||||||
|
-I$(LIB_SRC)/overset/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
-I$(LIB_SRC)/sampling/lnInclude
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
-limmiscibleIncompressibleTwoPhaseMixture \
|
||||||
|
-lturbulenceModels \
|
||||||
|
-lincompressibleTurbulenceModels \
|
||||||
|
-lfiniteVolume \
|
||||||
|
-ldynamicMesh \
|
||||||
|
-ldynamicFvMesh \
|
||||||
|
-ltopoChangerFvMesh \
|
||||||
|
-loverset \
|
||||||
|
-lfvOptions \
|
||||||
|
-lsampling \
|
||||||
|
-lwaveModels
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
MRF.correctBoundaryVelocity(U);
|
||||||
|
|
||||||
|
fvVectorMatrix UEqn
|
||||||
|
(
|
||||||
|
fvm::ddt(rho, U) + fvm::div(rhoPhi, U)
|
||||||
|
+ MRF.DDt(rho, U)
|
||||||
|
+ turbulence->divDevRhoReff(rho, U)
|
||||||
|
==
|
||||||
|
fvOptions(rho, U)
|
||||||
|
);
|
||||||
|
|
||||||
|
UEqn.relax();
|
||||||
|
|
||||||
|
fvOptions.constrain(UEqn);
|
||||||
|
|
||||||
|
if (pimple.momentumPredictor())
|
||||||
|
{
|
||||||
|
solve
|
||||||
|
(
|
||||||
|
UEqn
|
||||||
|
==
|
||||||
|
cellMask*fvc::reconstruct
|
||||||
|
(
|
||||||
|
(
|
||||||
|
mixture.surfaceTensionForce()
|
||||||
|
- ghf*fvc::snGrad(rho)
|
||||||
|
- fvc::snGrad(p_rgh)
|
||||||
|
) * mesh.magSf()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
fvOptions.correct(U);
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Global
|
||||||
|
continuityErrs
|
||||||
|
|
||||||
|
Description
|
||||||
|
Calculates and prints the continuity errors.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
{
|
||||||
|
volScalarField contErr(interpolatedCells*cellMask*fvc::div(phi));
|
||||||
|
|
||||||
|
scalar sumLocalContErr = runTime.deltaTValue()*
|
||||||
|
mag(contErr)().weightedAverage(mesh.V()).value();
|
||||||
|
|
||||||
|
scalar globalContErr = runTime.deltaTValue()*
|
||||||
|
contErr.weightedAverage(mesh.V()).value();
|
||||||
|
cumulativeContErr += globalContErr;
|
||||||
|
|
||||||
|
Info<< "time step continuity errors : sum local = " << sumLocalContErr
|
||||||
|
<< ", global = " << globalContErr
|
||||||
|
<< ", cumulative = " << cumulativeContErr
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,125 @@
|
|||||||
|
{
|
||||||
|
if (mesh.changing())
|
||||||
|
{
|
||||||
|
volVectorField::Boundary& bfld = U.boundaryFieldRef();
|
||||||
|
forAll(bfld, patchi)
|
||||||
|
{
|
||||||
|
if (bfld[patchi].fixesValue())
|
||||||
|
{
|
||||||
|
bfld[patchi].initEvaluate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
surfaceScalarField::Boundary& phiBfld = phi.boundaryFieldRef();
|
||||||
|
forAll(bfld, patchi)
|
||||||
|
{
|
||||||
|
if (bfld[patchi].fixesValue())
|
||||||
|
{
|
||||||
|
bfld[patchi].evaluate();
|
||||||
|
|
||||||
|
phiBfld[patchi] =
|
||||||
|
bfld[patchi]
|
||||||
|
& mesh.Sf().boundaryField()[patchi];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wordList pcorrTypes
|
||||||
|
(
|
||||||
|
p_rgh.boundaryField().size(),
|
||||||
|
zeroGradientFvPatchScalarField::typeName
|
||||||
|
);
|
||||||
|
|
||||||
|
for (label i=0; i<p_rgh.boundaryField().size(); i++)
|
||||||
|
{
|
||||||
|
if (p_rgh.boundaryField()[i].fixesValue())
|
||||||
|
{
|
||||||
|
pcorrTypes[i] = fixedValueFvPatchScalarField::typeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
volScalarField pcorr
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"pcorr",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
dimensionedScalar("pcorr", p_rgh.dimensions(), 0.0),
|
||||||
|
pcorrTypes
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pcorr.needReference())
|
||||||
|
{
|
||||||
|
fvc::makeRelative(phi, U);
|
||||||
|
adjustPhi(phi, U, pcorr);
|
||||||
|
fvc::makeAbsolute(phi, U);
|
||||||
|
}
|
||||||
|
|
||||||
|
mesh.setFluxRequired(pcorr.name());
|
||||||
|
|
||||||
|
dimensionedScalar rAUf("rAUf", dimTime/rho.dimensions(), 1.0);
|
||||||
|
|
||||||
|
const cellCellStencilObject& overlap = Stencil::New(mesh);
|
||||||
|
const labelList& cellTypes = overlap.cellTypes();
|
||||||
|
const labelIOList& zoneIDs = overlap.zoneID();
|
||||||
|
|
||||||
|
while (pimple.correctNonOrthogonal())
|
||||||
|
{
|
||||||
|
label nZones = gMax(zoneIDs)+1;
|
||||||
|
//label refCellI2 = -1;
|
||||||
|
|
||||||
|
labelList refCells(nZones, -1);
|
||||||
|
labelList refZones(nZones, -1);
|
||||||
|
|
||||||
|
forAll(zoneIDs, cellI)
|
||||||
|
{
|
||||||
|
label zoneId = zoneIDs[cellI];
|
||||||
|
if
|
||||||
|
(
|
||||||
|
refCells[zoneId] == -1
|
||||||
|
&& cellTypes[cellI] == cellCellStencil::CALCULATED
|
||||||
|
&& refZones[zoneId] == -1
|
||||||
|
)
|
||||||
|
{
|
||||||
|
refCells[zoneId] = cellI;
|
||||||
|
refZones[zoneId] = zoneId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fvScalarMatrix pcorrEqn
|
||||||
|
(
|
||||||
|
fvm::laplacian(rAUf, pcorr) == fvc::div(phi)
|
||||||
|
);
|
||||||
|
|
||||||
|
//pcorrEqn.setReference(refCellI2, 0, true);
|
||||||
|
scalarList values(nZones, 0.0);
|
||||||
|
pcorrEqn.setReferences(refCells, values, true);
|
||||||
|
|
||||||
|
const dictionary& d = mesh.solver
|
||||||
|
(
|
||||||
|
pcorr.select
|
||||||
|
(
|
||||||
|
pimple.finalInnerIter()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
//Bypass virtual layer
|
||||||
|
mesh.fvMesh::solve(pcorrEqn, d);
|
||||||
|
|
||||||
|
if (pimple.finalNonOrthogonalIter())
|
||||||
|
{
|
||||||
|
phi -= pcorrEqn.flux();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (runTime.outputTime())
|
||||||
|
{
|
||||||
|
volScalarField("contPhiPcorr", fvc::div(phi)).write();
|
||||||
|
pcorr.write();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
bool correctPhi
|
||||||
|
(
|
||||||
|
pimple.dict().lookupOrDefault<Switch>("correctPhi", true)
|
||||||
|
);
|
||||||
|
|
||||||
|
bool checkMeshCourantNo
|
||||||
|
(
|
||||||
|
pimple.dict().lookupOrDefault<Switch>("checkMeshCourantNo", false)
|
||||||
|
);
|
||||||
|
|
||||||
|
bool moveMeshOuterCorrectors
|
||||||
|
(
|
||||||
|
pimple.dict().lookupOrDefault<Switch>("moveMeshOuterCorrectors", false)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
bool massFluxInterpolation
|
||||||
|
(
|
||||||
|
pimple.dict().lookupOrDefault("massFluxInterpolation", false)
|
||||||
|
);
|
||||||
|
|
||||||
|
bool ddtCorr
|
||||||
|
(
|
||||||
|
pimple.dict().lookupOrDefault("ddtCorr", true)
|
||||||
|
);
|
||||||
@ -0,0 +1,171 @@
|
|||||||
|
#include "createRDeltaT.H"
|
||||||
|
|
||||||
|
Info<< "Reading field p_rgh\n" << endl;
|
||||||
|
volScalarField p_rgh
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"p_rgh",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "Reading field U\n" << endl;
|
||||||
|
volVectorField U
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"U",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
#include "createPhi.H"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//- Overset specific
|
||||||
|
|
||||||
|
// Add solver-specific interpolations
|
||||||
|
{
|
||||||
|
dictionary oversetDict;
|
||||||
|
oversetDict.add("U", true);
|
||||||
|
oversetDict.add("p", true);
|
||||||
|
oversetDict.add("HbyA", true);
|
||||||
|
oversetDict.add("p_rgh", true);
|
||||||
|
oversetDict.add("alpha1", true);
|
||||||
|
oversetDict.add("minGradP", true);
|
||||||
|
|
||||||
|
const_cast<dictionary&>
|
||||||
|
(
|
||||||
|
mesh.schemesDict()
|
||||||
|
).add
|
||||||
|
(
|
||||||
|
"oversetInterpolationRequired",
|
||||||
|
oversetDict,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mask field for zeroing out contributions on hole cells
|
||||||
|
#include "createCellMask.H"
|
||||||
|
|
||||||
|
// Create bool field with interpolated cells
|
||||||
|
#include "createInterpolatedCells.H"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Info<< "Reading transportProperties\n" << endl;
|
||||||
|
immiscibleIncompressibleTwoPhaseMixture mixture(U, phi);
|
||||||
|
|
||||||
|
volScalarField& alpha1(mixture.alpha1());
|
||||||
|
volScalarField& alpha2(mixture.alpha2());
|
||||||
|
|
||||||
|
const dimensionedScalar& rho1 = mixture.rho1();
|
||||||
|
const dimensionedScalar& rho2 = mixture.rho2();
|
||||||
|
|
||||||
|
|
||||||
|
// Need to store rho for ddt(rho, U)
|
||||||
|
volScalarField rho
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"rho",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::READ_IF_PRESENT
|
||||||
|
),
|
||||||
|
alpha1*rho1 + alpha2*rho2
|
||||||
|
);
|
||||||
|
rho.oldTime();
|
||||||
|
|
||||||
|
|
||||||
|
// Mass flux
|
||||||
|
surfaceScalarField rhoPhi
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"rhoPhi",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
fvc::interpolate(rho)*phi
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Construct incompressible turbulence model
|
||||||
|
autoPtr<incompressible::turbulenceModel> turbulence
|
||||||
|
(
|
||||||
|
incompressible::turbulenceModel::New(U, phi, mixture)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
#include "readGravitationalAcceleration.H"
|
||||||
|
#include "readhRef.H"
|
||||||
|
#include "gh.H"
|
||||||
|
|
||||||
|
|
||||||
|
volScalarField p
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"p",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
p_rgh + rho*gh
|
||||||
|
);
|
||||||
|
|
||||||
|
label pRefCell = 0;
|
||||||
|
scalar pRefValue = 0.0;
|
||||||
|
setRefCell
|
||||||
|
(
|
||||||
|
p,
|
||||||
|
p_rgh,
|
||||||
|
pimple.dict(),
|
||||||
|
pRefCell,
|
||||||
|
pRefValue
|
||||||
|
);
|
||||||
|
|
||||||
|
if (p_rgh.needReference())
|
||||||
|
{
|
||||||
|
p += dimensionedScalar
|
||||||
|
(
|
||||||
|
"p",
|
||||||
|
p.dimensions(),
|
||||||
|
pRefValue - getRefCellValue(p, pRefCell)
|
||||||
|
);
|
||||||
|
p_rgh = p - rho*gh;
|
||||||
|
}
|
||||||
|
|
||||||
|
mesh.setFluxRequired(p_rgh.name());
|
||||||
|
mesh.setFluxRequired(alpha1.name());
|
||||||
|
|
||||||
|
// MULES compressed flux is registered in case scalarTransport FO needs it.
|
||||||
|
surfaceScalarField alphaPhiUn
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"alphaPhiUn",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
dimensionedScalar("zero", phi.dimensions(), 0.0)
|
||||||
|
);
|
||||||
|
|
||||||
|
#include "createMRF.H"
|
||||||
@ -0,0 +1,209 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
overInterDyMFoam
|
||||||
|
|
||||||
|
Group
|
||||||
|
grpMultiphaseSolvers grpMovingMeshSolvers
|
||||||
|
|
||||||
|
Description
|
||||||
|
Solver for 2 incompressible, isothermal immiscible fluids using a VOF
|
||||||
|
(volume of fluid) phase-fraction based interface capturing approach,
|
||||||
|
with optional mesh motion and mesh topology changes including adaptive
|
||||||
|
re-meshing.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "fvCFD.H"
|
||||||
|
#include "dynamicFvMesh.H"
|
||||||
|
#include "CMULES.H"
|
||||||
|
#include "EulerDdtScheme.H"
|
||||||
|
#include "localEulerDdtScheme.H"
|
||||||
|
#include "CrankNicolsonDdtScheme.H"
|
||||||
|
#include "subCycle.H"
|
||||||
|
#include "immiscibleIncompressibleTwoPhaseMixture.H"
|
||||||
|
#include "turbulentTransportModel.H"
|
||||||
|
#include "pimpleControl.H"
|
||||||
|
#include "fvOptions.H"
|
||||||
|
#include "CorrectPhi.H"
|
||||||
|
#include "fvcSmooth.H"
|
||||||
|
#include "cellCellStencilObject.H"
|
||||||
|
#include "localMin.H"
|
||||||
|
#include "interpolationCellPoint.H"
|
||||||
|
#include "transform.H"
|
||||||
|
#include "fvMeshSubset.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#include "postProcess.H"
|
||||||
|
|
||||||
|
#include "setRootCase.H"
|
||||||
|
#include "createTime.H"
|
||||||
|
#include "createDynamicFvMesh.H"
|
||||||
|
#include "initContinuityErrs.H"
|
||||||
|
#include "createControl.H"
|
||||||
|
#include "createTimeControls.H"
|
||||||
|
#include "createDyMControls.H"
|
||||||
|
#include "createFields.H"
|
||||||
|
#include "createAlphaFluxes.H"
|
||||||
|
#include "createFvOptions.H"
|
||||||
|
|
||||||
|
volScalarField rAU
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"rAU",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::READ_IF_PRESENT,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1.0)
|
||||||
|
);
|
||||||
|
|
||||||
|
#include "correctPhi.H"
|
||||||
|
#include "createUf.H"
|
||||||
|
|
||||||
|
turbulence->validate();
|
||||||
|
|
||||||
|
if (!LTS)
|
||||||
|
{
|
||||||
|
#include "CourantNo.H"
|
||||||
|
#include "setInitialDeltaT.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "setCellMask.H"
|
||||||
|
#include "setInterpolatedCells.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
Info<< "\nStarting time loop\n" << endl;
|
||||||
|
|
||||||
|
while (runTime.run())
|
||||||
|
{
|
||||||
|
#include "readControls.H"
|
||||||
|
|
||||||
|
if (LTS)
|
||||||
|
{
|
||||||
|
#include "setRDeltaT.H"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#include "CourantNo.H"
|
||||||
|
#include "alphaCourantNo.H"
|
||||||
|
#include "setDeltaT.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
runTime++;
|
||||||
|
|
||||||
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
|
// --- Pressure-velocity PIMPLE corrector loop
|
||||||
|
while (pimple.loop())
|
||||||
|
{
|
||||||
|
if (pimple.firstIter() || moveMeshOuterCorrectors)
|
||||||
|
{
|
||||||
|
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
|
||||||
|
|
||||||
|
mesh.update();
|
||||||
|
|
||||||
|
if (mesh.changing())
|
||||||
|
{
|
||||||
|
Info<< "Execution time for mesh.update() = "
|
||||||
|
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
|
||||||
|
<< " s" << endl;
|
||||||
|
|
||||||
|
// Do not apply previous time-step mesh compression flux
|
||||||
|
// if the mesh topology changed
|
||||||
|
if (mesh.topoChanging())
|
||||||
|
{
|
||||||
|
talphaPhiCorr0.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
gh = (g & mesh.C()) - ghRef;
|
||||||
|
ghf = (g & mesh.Cf()) - ghRef;
|
||||||
|
|
||||||
|
// Update cellMask field for blocking out hole cells
|
||||||
|
#include "setCellMask.H"
|
||||||
|
#include "setInterpolatedCells.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((mesh.changing() && correctPhi) || mesh.topoChanging())
|
||||||
|
{
|
||||||
|
// Calculate absolute flux from the mapped surface velocity
|
||||||
|
// Note: temporary fix until mapped Uf is assessed
|
||||||
|
Uf = fvc::interpolate(U);
|
||||||
|
|
||||||
|
// Calculate absolute flux from the mapped surface velocity
|
||||||
|
phi = mesh.Sf() & Uf;
|
||||||
|
|
||||||
|
#include "correctPhi.H"
|
||||||
|
|
||||||
|
// Make the flux relative to the mesh motion
|
||||||
|
fvc::makeRelative(phi, U);
|
||||||
|
|
||||||
|
mixture.correct();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mesh.changing() && checkMeshCourantNo)
|
||||||
|
{
|
||||||
|
#include "meshCourantNo.H"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "alphaControls.H"
|
||||||
|
#include "alphaEqnSubCycle.H"
|
||||||
|
|
||||||
|
mixture.correct();
|
||||||
|
|
||||||
|
#include "UEqn.H"
|
||||||
|
|
||||||
|
// --- Pressure corrector loop
|
||||||
|
while (pimple.correct())
|
||||||
|
{
|
||||||
|
#include "pEqn.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pimple.turbCorr())
|
||||||
|
{
|
||||||
|
turbulence->correct();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
runTime.write();
|
||||||
|
|
||||||
|
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||||
|
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||||
|
<< nl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
rAU = 1.0/UEqn.A();
|
||||||
|
surfaceScalarField faceMask(localMin<scalar>(mesh).interpolate(cellMask));
|
||||||
|
|
||||||
|
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU));
|
||||||
|
|
||||||
|
volVectorField HbyA("HbyA", U);
|
||||||
|
//HbyA = rAU*UEqn.H();
|
||||||
|
HbyA = constrainHbyA(rAU*UEqn.H(), U, p_rgh);
|
||||||
|
|
||||||
|
if (massFluxInterpolation)
|
||||||
|
{
|
||||||
|
#include "interpolatedFaces.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA));
|
||||||
|
|
||||||
|
if (ddtCorr)
|
||||||
|
{
|
||||||
|
phiHbyA += fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, Uf);
|
||||||
|
}
|
||||||
|
MRF.makeRelative(phiHbyA);
|
||||||
|
|
||||||
|
if (p_rgh.needReference())
|
||||||
|
{
|
||||||
|
fvc::makeRelative(phiHbyA, U);
|
||||||
|
adjustPhi(phiHbyA, U, p_rgh);
|
||||||
|
fvc::makeAbsolute(phiHbyA, U);
|
||||||
|
}
|
||||||
|
|
||||||
|
surfaceScalarField phig
|
||||||
|
(
|
||||||
|
(
|
||||||
|
mixture.surfaceTensionForce()
|
||||||
|
- ghf*fvc::snGrad(rho)
|
||||||
|
)*faceMask*rAUf*mesh.magSf()
|
||||||
|
);
|
||||||
|
|
||||||
|
phiHbyA += phig;
|
||||||
|
|
||||||
|
// Update the pressure BCs to ensure flux consistency
|
||||||
|
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
|
||||||
|
|
||||||
|
while (pimple.correctNonOrthogonal())
|
||||||
|
{
|
||||||
|
fvScalarMatrix p_rghEqn
|
||||||
|
(
|
||||||
|
fvm::laplacian(faceMask*rAUf, p_rgh) == fvc::div(phiHbyA)
|
||||||
|
);
|
||||||
|
|
||||||
|
p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
|
||||||
|
|
||||||
|
p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter())));
|
||||||
|
|
||||||
|
if (pimple.finalNonOrthogonalIter())
|
||||||
|
{
|
||||||
|
phi = phiHbyA - p_rghEqn.flux();
|
||||||
|
|
||||||
|
p_rgh.relax();
|
||||||
|
|
||||||
|
// Reconstruct body forces (-grad(p) and gh etc)
|
||||||
|
volVectorField minGradP
|
||||||
|
(
|
||||||
|
"minGradP",
|
||||||
|
fvc::reconstruct((phig - p_rghEqn.flux())/rAUf)
|
||||||
|
);
|
||||||
|
U = HbyA + rAU*cellMask*minGradP;
|
||||||
|
U.correctBoundaryConditions();
|
||||||
|
fvOptions.correct(U);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "continuityErrs.H"
|
||||||
|
|
||||||
|
{
|
||||||
|
Uf = fvc::interpolate(U);
|
||||||
|
surfaceVectorField n(mesh.Sf()/mesh.magSf());
|
||||||
|
Uf += n*(phi/mesh.magSf() - (n & Uf));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make the fluxes relative to the mesh motion
|
||||||
|
fvc::makeRelative(phi, U);
|
||||||
|
|
||||||
|
p == p_rgh + rho*gh;
|
||||||
|
|
||||||
|
if (p_rgh.needReference())
|
||||||
|
{
|
||||||
|
p += dimensionedScalar
|
||||||
|
(
|
||||||
|
"p",
|
||||||
|
p.dimensions(),
|
||||||
|
pRefValue - getRefCellValue(p, pRefCell)
|
||||||
|
);
|
||||||
|
p_rgh = p - rho*gh;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
#include "readTimeControls.H"
|
||||||
|
|
||||||
|
correctPhi = pimple.dict().lookupOrDefault<Switch>("correctPhi", true);
|
||||||
|
|
||||||
|
checkMeshCourantNo =
|
||||||
|
pimple.dict().lookupOrDefault<Switch>("checkMeshCourantNo", false);
|
||||||
|
|
||||||
|
moveMeshOuterCorrectors =
|
||||||
|
pimple.dict().lookupOrDefault<Switch>("moveMeshOuterCorrectors", false);
|
||||||
|
|
||||||
|
massFluxInterpolation =
|
||||||
|
pimple.dict().lookupOrDefault("massFluxInterpolation", false);
|
||||||
|
|
||||||
|
ddtCorr =
|
||||||
|
pimple.dict().lookupOrDefault("ddtCorr", true);
|
||||||
@ -92,14 +92,14 @@ int main()
|
|||||||
std::cout<< "max = " << pTraits<label>::max << nl;
|
std::cout<< "max = " << pTraits<label>::max << nl;
|
||||||
std::cout<< "umax = " << pTraits<uLabel>::max << nl;
|
std::cout<< "umax = " << pTraits<uLabel>::max << nl;
|
||||||
|
|
||||||
std::cout<< "max_2 = " << pTraits<label>::max/2 << " == "
|
std::cout<< "max_2 = " << pTraits<label>::max/2 << " <=> "
|
||||||
<< (1 << (sizeof(label)*8-2)) << nl;
|
<< (1L << (sizeof(label)*8-2)) << nl;
|
||||||
|
|
||||||
std::cout<< "max_4 = " << pTraits<label>::max/4 << " == "
|
std::cout<< "max_4 = " << pTraits<label>::max/4 << " <=> "
|
||||||
<< (1 << (sizeof(label)*8-3)) << nl;
|
<< (1L << (sizeof(label)*8-3)) << nl;
|
||||||
|
|
||||||
std::cout<< "max_8 = " << pTraits<label>::max/8 << " == "
|
std::cout<< "max_8 = " << pTraits<label>::max/8 << " <=> "
|
||||||
<< (1 << (sizeof(label)*8-4)) << nl;
|
<< (1L << (sizeof(label)*8-4)) << nl;
|
||||||
|
|
||||||
Info<< "End\n" << endl;
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
|||||||
3
applications/test/parallelOverset/Make/files
Normal file
3
applications/test/parallelOverset/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
laplacianDyMFoam.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/correctBoundaryConditions
|
||||||
12
applications/test/parallelOverset/Make/options
Normal file
12
applications/test/parallelOverset/Make/options
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-DFULLDEBUG -g -O0 \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/sampling/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
-I$(LIB_SRC)/overset/lnInclude
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
-lfiniteVolume \
|
||||||
|
-lsampling \
|
||||||
|
-loverset
|
||||||
53
applications/test/parallelOverset/createFields.H
Normal file
53
applications/test/parallelOverset/createFields.H
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
Info<< "Reading field T\n" << endl;
|
||||||
|
|
||||||
|
volScalarField T
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"T",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add overset specific interpolations
|
||||||
|
{
|
||||||
|
dictionary oversetDict;
|
||||||
|
oversetDict.add("T", true);
|
||||||
|
|
||||||
|
const_cast<dictionary&>
|
||||||
|
(
|
||||||
|
mesh.schemesDict()
|
||||||
|
).add
|
||||||
|
(
|
||||||
|
"oversetInterpolationRequired",
|
||||||
|
oversetDict,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Info<< "Reading transportProperties\n" << endl;
|
||||||
|
|
||||||
|
IOdictionary transportProperties
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"transportProperties",
|
||||||
|
runTime.constant(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ_IF_MODIFIED,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
Info<< "Reading diffusivity DT\n" << endl;
|
||||||
|
|
||||||
|
dimensionedScalar DT
|
||||||
|
(
|
||||||
|
transportProperties.lookup("DT")
|
||||||
|
);
|
||||||
49
applications/test/parallelOverset/heatTransfer/0.orig/T
Normal file
49
applications/test/parallelOverset/heatTransfer/0.orig/T
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: dev |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class volScalarField;
|
||||||
|
object T;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
dimensions [0 0 0 1 0 0 0];
|
||||||
|
|
||||||
|
internalField uniform 273;
|
||||||
|
|
||||||
|
boundaryField
|
||||||
|
{
|
||||||
|
//- Set patchGroups for constraint patches
|
||||||
|
#include "${WM_PROJECT_DIR}/etc/caseDicts/setConstraintTypes"
|
||||||
|
|
||||||
|
"(walls|hole)"
|
||||||
|
{
|
||||||
|
type zeroGradient;
|
||||||
|
}
|
||||||
|
|
||||||
|
left1
|
||||||
|
{
|
||||||
|
type fixedValue;
|
||||||
|
value uniform 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
right1
|
||||||
|
{
|
||||||
|
type fixedValue;
|
||||||
|
value uniform 273;
|
||||||
|
}
|
||||||
|
|
||||||
|
overset
|
||||||
|
{
|
||||||
|
type overset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: dev |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class pointVectorField;
|
||||||
|
object pointDisplacement;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
dimensions [0 1 0 0 0 0 0];
|
||||||
|
|
||||||
|
internalField uniform (0 0 0);
|
||||||
|
|
||||||
|
boundaryField
|
||||||
|
{
|
||||||
|
".*"
|
||||||
|
{
|
||||||
|
type uniformFixedValue;
|
||||||
|
uniformValue (0 0 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
"(free|hole)"
|
||||||
|
{
|
||||||
|
patchType overset;
|
||||||
|
type uniformFixedValue;
|
||||||
|
uniformValue (0 0 0);
|
||||||
|
// uniformValue table
|
||||||
|
// (
|
||||||
|
// (0.0 (0 0 0))
|
||||||
|
// (1.0 (0.31 0 0))
|
||||||
|
// (2.0 (0 0 0))
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
39
applications/test/parallelOverset/heatTransfer/0.orig/zoneID
Normal file
39
applications/test/parallelOverset/heatTransfer/0.orig/zoneID
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: dev-OpenCFD.overlap |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class volScalarField;
|
||||||
|
location "0";
|
||||||
|
object zoneID;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
dimensions [0 0 0 0 0 0 0];
|
||||||
|
|
||||||
|
internalField uniform 0;
|
||||||
|
|
||||||
|
boundaryField
|
||||||
|
{
|
||||||
|
//- Set patchGroups for constraint patches
|
||||||
|
#include "${WM_PROJECT_DIR}/etc/caseDicts/setConstraintTypes"
|
||||||
|
|
||||||
|
overset
|
||||||
|
{
|
||||||
|
type overset;
|
||||||
|
}
|
||||||
|
|
||||||
|
".*"
|
||||||
|
{
|
||||||
|
type zeroGradient;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -1,10 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd ${0%/*} || exit 1 # Run from this directory
|
cd ${0%/*} || exit 1 # Run from this directory
|
||||||
|
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
|
||||||
|
|
||||||
# Parse arguments for library compilation
|
cleanCase
|
||||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
rm -f constant/polyMesh/boundary
|
||||||
|
rm -f constant/polyMesh/zoneID
|
||||||
|
|
||||||
wmake $targetType foamToVTK
|
rm -rf 0
|
||||||
wmake $targetType
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
20
applications/test/parallelOverset/heatTransfer/Allrun.pre
Executable file
20
applications/test/parallelOverset/heatTransfer/Allrun.pre
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd ${0%/*} || exit 1 # Run from this directory
|
||||||
|
. $WM_PROJECT_DIR/bin/tools/RunFunctions
|
||||||
|
|
||||||
|
runApplication blockMesh
|
||||||
|
|
||||||
|
# Select cellSets
|
||||||
|
runApplication topoSet
|
||||||
|
|
||||||
|
runApplication subsetMesh box -patch hole -overwrite
|
||||||
|
|
||||||
|
# Select cellSets
|
||||||
|
runApplication -s zoneID topoSet
|
||||||
|
|
||||||
|
restore0Dir
|
||||||
|
|
||||||
|
# Use cellSets to write zoneID
|
||||||
|
runApplication setFields
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: dev |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object dynamicMeshDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
motionSolverLibs ( "libfvMotionSolvers.so" );
|
||||||
|
|
||||||
|
solver displacementLaplacian;
|
||||||
|
|
||||||
|
displacementLaplacianCoeffs
|
||||||
|
{
|
||||||
|
diffusivity uniform 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamicFvMesh dynamicOversetFvMesh;
|
||||||
|
|
||||||
|
dynamicOversetFvMeshCoeffs
|
||||||
|
{
|
||||||
|
// layerRelax 0.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: dev |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
location "constant";
|
||||||
|
object transportProperties;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
DT DT [ 0 2 -1 0 0 0 0 ] 1;
|
||||||
|
|
||||||
|
transportModel Newtonian;
|
||||||
|
|
||||||
|
nu nu [ 0 2 -1 0 0 0 0 ] 1e-05;
|
||||||
|
|
||||||
|
CrossPowerLawCoeffs
|
||||||
|
{
|
||||||
|
nu0 nu0 [ 0 2 -1 0 0 0 0 ] 1e-06;
|
||||||
|
nuInf nuInf [ 0 2 -1 0 0 0 0 ] 1e-06;
|
||||||
|
m m [ 0 0 1 0 0 0 0 ] 1;
|
||||||
|
n n [ 0 0 0 0 0 0 0 ] 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
BirdCarreauCoeffs
|
||||||
|
{
|
||||||
|
nu0 nu0 [ 0 2 -1 0 0 0 0 ] 1e-06;
|
||||||
|
nuInf nuInf [ 0 2 -1 0 0 0 0 ] 1e-06;
|
||||||
|
k k [ 0 0 1 0 0 0 0 ] 0;
|
||||||
|
n n [ 0 0 0 0 0 0 0 ] 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,126 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: 1.5 |
|
||||||
|
| \\ / A nd | Web: http://www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object blockMeshDict;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
convertToMeters 1;
|
||||||
|
|
||||||
|
vertices
|
||||||
|
(
|
||||||
|
( 0.00 0.0 0)
|
||||||
|
( 1.00 0.0 0)
|
||||||
|
( 1.00 1.0 0)
|
||||||
|
( 0.00 1.0 0)
|
||||||
|
( 0.00 0.0 1)
|
||||||
|
( 1.00 0.0 1)
|
||||||
|
( 1.00 1.0 1)
|
||||||
|
( 0.00 1.0 1)
|
||||||
|
|
||||||
|
//- 0 degrees
|
||||||
|
( 0.25 0.25 0)
|
||||||
|
( 0.75 0.25 0)
|
||||||
|
( 0.75 0.75 0)
|
||||||
|
( 0.25 0.75 0)
|
||||||
|
( 0.25 0.25 1)
|
||||||
|
( 0.75 0.25 1)
|
||||||
|
( 0.75 0.75 1)
|
||||||
|
( 0.25 0.75 1)
|
||||||
|
|
||||||
|
|
||||||
|
//- 45 degrees rotated
|
||||||
|
// ( 0.25 0.5 0)
|
||||||
|
// ( 0.5 0.25 0)
|
||||||
|
// ( 0.75 0.5 0)
|
||||||
|
// ( 0.5 0.75 0)
|
||||||
|
// ( 0.25 0.5 1)
|
||||||
|
// ( 0.5 0.25 1)
|
||||||
|
// ( 0.75 0.5 1)
|
||||||
|
// ( 0.5 0.75 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
blocks
|
||||||
|
(
|
||||||
|
hex (0 1 2 3 4 5 6 7) (18 18 1) simpleGrading (1 1 1)
|
||||||
|
|
||||||
|
hex (8 9 10 11 12 13 14 15) movingZone (30 30 1) simpleGrading (1 1 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
edges
|
||||||
|
(
|
||||||
|
);
|
||||||
|
|
||||||
|
boundary
|
||||||
|
(
|
||||||
|
free
|
||||||
|
{
|
||||||
|
type overset;
|
||||||
|
faces
|
||||||
|
(
|
||||||
|
(8 12 15 11)
|
||||||
|
(10 14 13 9)
|
||||||
|
(11 15 14 10)
|
||||||
|
( 9 13 12 8)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
walls
|
||||||
|
{
|
||||||
|
type patch;
|
||||||
|
faces
|
||||||
|
(
|
||||||
|
(3 7 6 2)
|
||||||
|
(1 5 4 0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populated by subsetMesh
|
||||||
|
hole
|
||||||
|
{
|
||||||
|
type patch;
|
||||||
|
faces ();
|
||||||
|
}
|
||||||
|
|
||||||
|
frontAndBack
|
||||||
|
{
|
||||||
|
type empty;
|
||||||
|
faces
|
||||||
|
(
|
||||||
|
(0 3 2 1)
|
||||||
|
(4 5 6 7)
|
||||||
|
( 8 11 10 9)
|
||||||
|
(12 13 14 15)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
left1
|
||||||
|
{
|
||||||
|
type patch;
|
||||||
|
faces
|
||||||
|
(
|
||||||
|
(0 4 7 3)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
right1
|
||||||
|
{
|
||||||
|
type patch;
|
||||||
|
faces
|
||||||
|
(
|
||||||
|
(2 6 5 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: dev |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
location "system";
|
||||||
|
object controlDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Make sure all preprocessing tools know about the 'overset' bc
|
||||||
|
libs ("liboverset.so");
|
||||||
|
|
||||||
|
DebugSwitches
|
||||||
|
{
|
||||||
|
overset 1;
|
||||||
|
inverseDistance 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
application correctBoundaryConditions; //overLaplacianDyMFoam;
|
||||||
|
|
||||||
|
startFrom startTime;
|
||||||
|
|
||||||
|
startTime 0;
|
||||||
|
|
||||||
|
stopAt endTime;
|
||||||
|
|
||||||
|
endTime 1;
|
||||||
|
|
||||||
|
deltaT 0.1;
|
||||||
|
|
||||||
|
writeControl timeStep;
|
||||||
|
|
||||||
|
writeInterval 1;
|
||||||
|
|
||||||
|
purgeWrite 0;
|
||||||
|
|
||||||
|
writeFormat ascii;
|
||||||
|
|
||||||
|
writePrecision 16;
|
||||||
|
|
||||||
|
writeCompression off;
|
||||||
|
|
||||||
|
timeFormat general;
|
||||||
|
|
||||||
|
timePrecision 6;
|
||||||
|
|
||||||
|
runTimeModifiable true;
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: plus |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
note "mesh decomposition control dictionary";
|
||||||
|
object decomposeParDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
numberOfSubdomains 2;
|
||||||
|
|
||||||
|
|
||||||
|
//constraints
|
||||||
|
//{
|
||||||
|
// localOverset
|
||||||
|
// {
|
||||||
|
// //- Keep donor and acceptor on same processor
|
||||||
|
// type localOverset;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
method hierarchical;
|
||||||
|
|
||||||
|
hierarchicalCoeffs
|
||||||
|
{
|
||||||
|
n (1 2 1);
|
||||||
|
delta 0.001;
|
||||||
|
order xyz;
|
||||||
|
}
|
||||||
|
|
||||||
|
manualCoeffs
|
||||||
|
{
|
||||||
|
dataFile "decompositionData";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: dev |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
location "system";
|
||||||
|
object fvSchemes;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
ddtSchemes
|
||||||
|
{
|
||||||
|
default steadyState;
|
||||||
|
}
|
||||||
|
|
||||||
|
gradSchemes
|
||||||
|
{
|
||||||
|
default Gauss linear;
|
||||||
|
grad(T) Gauss linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
divSchemes
|
||||||
|
{
|
||||||
|
default none;
|
||||||
|
div(phi,U) bounded Gauss limitedLinearV 1;
|
||||||
|
div(phi,k) bounded Gauss limitedLinear 1;
|
||||||
|
div(phi,epsilon) bounded Gauss limitedLinear 1;
|
||||||
|
div(phi,R) bounded Gauss limitedLinear 1;
|
||||||
|
div(R) Gauss linear;
|
||||||
|
div(phi,nuTilda) bounded Gauss limitedLinear 1;
|
||||||
|
div((nuEff*dev(T(grad(U))))) Gauss linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
laplacianSchemes
|
||||||
|
{
|
||||||
|
default Gauss linear corrected;
|
||||||
|
laplacian(diffusivity,cellDisplacement) Gauss linear corrected;
|
||||||
|
}
|
||||||
|
|
||||||
|
interpolationSchemes
|
||||||
|
{
|
||||||
|
default linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
snGradSchemes
|
||||||
|
{
|
||||||
|
default corrected;
|
||||||
|
}
|
||||||
|
|
||||||
|
fluxRequired
|
||||||
|
{
|
||||||
|
default no;
|
||||||
|
pcorr ;
|
||||||
|
p ;
|
||||||
|
}
|
||||||
|
|
||||||
|
oversetInterpolation
|
||||||
|
{
|
||||||
|
// Interpolation scheme to use for overset calculation
|
||||||
|
method inverseDistance;
|
||||||
|
|
||||||
|
// The inverseDistance method uses a 'voxel' like search structure.
|
||||||
|
// Optionally specify the extent and number of divisions n.
|
||||||
|
// Note that it will allocate an array of nx*ny*nz. If not specified:
|
||||||
|
// - searchBox : local mesh bounding box
|
||||||
|
// - searchBoxDivisions : root (2D) or cube-root(3D) of number of cells
|
||||||
|
searchBox (0 0 0)(1 1 1);
|
||||||
|
searchBoxDivisions (100 100 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
oversetInterpolationRequired
|
||||||
|
{
|
||||||
|
// Any additional fields that require overset interpolation
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: dev |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
location "system";
|
||||||
|
object fvSolution;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
solvers
|
||||||
|
{
|
||||||
|
T
|
||||||
|
{
|
||||||
|
solver PBiCGStab;
|
||||||
|
preconditioner DILU;
|
||||||
|
|
||||||
|
//solver GAMG;
|
||||||
|
//smoother DILUGaussSeidel;
|
||||||
|
//agglomerator algebraicPair;
|
||||||
|
//processorAgglomerator none;
|
||||||
|
|
||||||
|
tolerance 1e-10;
|
||||||
|
relTol 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cellDisplacement
|
||||||
|
{
|
||||||
|
solver PCG;
|
||||||
|
preconditioner DIC;
|
||||||
|
|
||||||
|
tolerance 1e-06;
|
||||||
|
relTol 0;
|
||||||
|
maxIter 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SIMPLE
|
||||||
|
{
|
||||||
|
nNonOrthogonalCorrectors 0; //2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIMPLE
|
||||||
|
{
|
||||||
|
correctPhi yes;
|
||||||
|
nOuterCorrectors 2;
|
||||||
|
nCorrectors 1;
|
||||||
|
nNonOrthogonalCorrectors 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
relaxationFactors
|
||||||
|
{
|
||||||
|
fields
|
||||||
|
{
|
||||||
|
p 0.3;
|
||||||
|
}
|
||||||
|
equations
|
||||||
|
{
|
||||||
|
U 0.7;
|
||||||
|
k 0.7;
|
||||||
|
omega 0.7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: plus |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object postProcessingDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
functions
|
||||||
|
{
|
||||||
|
processorField1
|
||||||
|
{
|
||||||
|
// Type of functionObject
|
||||||
|
type processorField;
|
||||||
|
|
||||||
|
// Where to load it from (if not already in solver)
|
||||||
|
libs ("libfieldFunctionObjects.so");
|
||||||
|
|
||||||
|
// Function object enabled flag
|
||||||
|
enabled true;
|
||||||
|
|
||||||
|
// When to output the average fields
|
||||||
|
writeControl writeTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: plus |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object postProcessingDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
processorField
|
||||||
|
{
|
||||||
|
// Type of functionObject
|
||||||
|
type processorField;
|
||||||
|
|
||||||
|
// Where to load it from (if not already in solver)
|
||||||
|
libs ("libfieldFunctionObjects.so");
|
||||||
|
|
||||||
|
// Function object enabled flag
|
||||||
|
enabled true;
|
||||||
|
|
||||||
|
// When to output the average fields
|
||||||
|
writeControl timeStep;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: dev |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object setFieldsDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
defaultFieldValues
|
||||||
|
(
|
||||||
|
volScalarFieldValue zoneID 123
|
||||||
|
);
|
||||||
|
|
||||||
|
regions
|
||||||
|
(
|
||||||
|
// Set cell values
|
||||||
|
// (does zerogradient on boundaries)
|
||||||
|
cellToCell
|
||||||
|
{
|
||||||
|
set c0;
|
||||||
|
|
||||||
|
fieldValues
|
||||||
|
(
|
||||||
|
volScalarFieldValue zoneID 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
cellToCell
|
||||||
|
{
|
||||||
|
set c1;
|
||||||
|
|
||||||
|
fieldValues
|
||||||
|
(
|
||||||
|
volScalarFieldValue zoneID 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: dev |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object topoSetDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
actions
|
||||||
|
(
|
||||||
|
{
|
||||||
|
name c0;
|
||||||
|
type cellSet;
|
||||||
|
action new;
|
||||||
|
source regionToCell;
|
||||||
|
sourceInfo
|
||||||
|
{
|
||||||
|
insidePoints ((0.001 0.001 0.001));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
name c1;
|
||||||
|
type cellSet;
|
||||||
|
action new;
|
||||||
|
source cellToCell;
|
||||||
|
sourceInfo
|
||||||
|
{
|
||||||
|
set c0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
name c1;
|
||||||
|
type cellSet;
|
||||||
|
action invert;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Select box to remove from region 1
|
||||||
|
|
||||||
|
{
|
||||||
|
name box;
|
||||||
|
type cellSet;
|
||||||
|
action new;
|
||||||
|
source cellToCell;
|
||||||
|
sourceInfo
|
||||||
|
{
|
||||||
|
set c1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
name box;
|
||||||
|
type cellSet;
|
||||||
|
action subset;
|
||||||
|
source boxToCell;
|
||||||
|
sourceInfo
|
||||||
|
{
|
||||||
|
box (0.4 0.4 -100)(0.6 0.6 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
name box;
|
||||||
|
type cellSet;
|
||||||
|
action invert;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
125
applications/test/parallelOverset/laplacianDyMFoam.C
Normal file
125
applications/test/parallelOverset/laplacianDyMFoam.C
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
laplacianFoam
|
||||||
|
|
||||||
|
Group
|
||||||
|
grpBasicSolvers
|
||||||
|
|
||||||
|
Description
|
||||||
|
Laplace equation solver for a scalar quantity.
|
||||||
|
|
||||||
|
\heading Solver details
|
||||||
|
The solver is applicable to, e.g. for thermal diffusion in a solid. The
|
||||||
|
equation is given by:
|
||||||
|
|
||||||
|
\f[
|
||||||
|
\ddt{T} = \div \left( D_T \grad T \right)
|
||||||
|
\f]
|
||||||
|
|
||||||
|
Where:
|
||||||
|
\vartable
|
||||||
|
T | Scalar field which is solved for, e.g. temperature
|
||||||
|
D_T | Diffusion coefficient
|
||||||
|
\endvartable
|
||||||
|
|
||||||
|
\heading Required fields
|
||||||
|
\plaintable
|
||||||
|
T | Scalar field which is solved for, e.g. temperature
|
||||||
|
\endplaintable
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "fvCFD.H"
|
||||||
|
#include "simpleControl.H"
|
||||||
|
#include "dynamicFvMesh.H"
|
||||||
|
#include "dynamicOversetFvMesh.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
#include "createTime.H"
|
||||||
|
#include "createNamedDynamicFvMesh.H"
|
||||||
|
|
||||||
|
simpleControl simple(mesh);
|
||||||
|
|
||||||
|
#include "createFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Info<< "\nCorrecting boundary conditions on " << T.name() << nl << endl;
|
||||||
|
|
||||||
|
runTime++;
|
||||||
|
|
||||||
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
|
Info<< "Reading : ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||||
|
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||||
|
<< nl << endl;
|
||||||
|
|
||||||
|
mesh.update();
|
||||||
|
|
||||||
|
Info<< "Overset calculation : ExecutionTime = "
|
||||||
|
<< runTime.elapsedCpuTime() << " s"
|
||||||
|
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||||
|
<< nl << endl;
|
||||||
|
|
||||||
|
|
||||||
|
if (false)
|
||||||
|
{
|
||||||
|
// Test correctBoundaryConditions
|
||||||
|
|
||||||
|
// Change the internalField
|
||||||
|
component(T.ref(), mesh.C(), 0);
|
||||||
|
component(T.ref(), mesh.C(), 1);
|
||||||
|
// Interpolate + halo swap
|
||||||
|
T.correctBoundaryConditions();
|
||||||
|
// Check halo swap
|
||||||
|
dynamicOversetFvMesh::checkCoupledBC(T);
|
||||||
|
}
|
||||||
|
if (true)
|
||||||
|
{
|
||||||
|
// Test solving
|
||||||
|
fvScalarMatrix TEqn(fvm::laplacian(DT, T));
|
||||||
|
TEqn.solve();
|
||||||
|
}
|
||||||
|
|
||||||
|
runTime.write();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||||
|
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||||
|
<< nl << endl;
|
||||||
|
|
||||||
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
46
applications/test/parallelOverset/write.H
Normal file
46
applications/test/parallelOverset/write.H
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
if (runTime.outputTime())
|
||||||
|
{
|
||||||
|
volVectorField gradT(fvc::grad(T));
|
||||||
|
|
||||||
|
volScalarField gradTx
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"gradTx",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
gradT.component(vector::X)
|
||||||
|
);
|
||||||
|
|
||||||
|
volScalarField gradTy
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"gradTy",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
gradT.component(vector::Y)
|
||||||
|
);
|
||||||
|
|
||||||
|
volScalarField gradTz
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"gradTz",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
gradT.component(vector::Z)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
runTime.write();
|
||||||
|
}
|
||||||
3
applications/test/wallDistDyM/Make/files
Normal file
3
applications/test/wallDistDyM/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-wallDistDyM.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-wallDistDyM
|
||||||
9
applications/test/wallDistDyM/Make/options
Normal file
9
applications/test/wallDistDyM/Make/options
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
-lfiniteVolume \
|
||||||
|
-lmeshTools \
|
||||||
|
-ldynamicFvMesh
|
||||||
69
applications/test/wallDistDyM/Test-wallDistDyM.C
Normal file
69
applications/test/wallDistDyM/Test-wallDistDyM.C
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Description
|
||||||
|
Calculate and write the distance-to-wall field for a moving mesh.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "dynamicFvMesh.H"
|
||||||
|
#include "wallDist.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#include "setRootCase.H"
|
||||||
|
#include "createTime.H"
|
||||||
|
#include "createDynamicFvMesh.H"
|
||||||
|
|
||||||
|
Info<< "Mesh read in = "
|
||||||
|
<< runTime.cpuTimeIncrement()
|
||||||
|
<< " s\n" << endl << endl;
|
||||||
|
|
||||||
|
// Calculate initial mesh-to-mesh mapping. Note that this should be
|
||||||
|
// done under the hood, e.g. as a MeshObject
|
||||||
|
mesh.update();
|
||||||
|
|
||||||
|
Info<< "Time now = " << runTime.timeName() << endl;
|
||||||
|
|
||||||
|
// Wall-reflection vectors
|
||||||
|
const volVectorField& n = wallDist::New(mesh).n();
|
||||||
|
n.write();
|
||||||
|
|
||||||
|
// Wall distance
|
||||||
|
const volScalarField& y = wallDist::New(mesh).y();
|
||||||
|
y.write();
|
||||||
|
|
||||||
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
|
|||||||
@ -1,7 +1,3 @@
|
|||||||
writePointSet.C
|
|
||||||
writeFuns.C
|
|
||||||
writePatch.C
|
|
||||||
setSet.C
|
setSet.C
|
||||||
|
|
||||||
EXE = $(FOAM_APPBIN)/setSet
|
EXE = $(FOAM_APPBIN)/setSet
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
EXE_INC = \
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
$(COMP_FLAGS)
|
$(COMP_FLAGS)
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -44,8 +44,9 @@ Description
|
|||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "demandDrivenData.H"
|
#include "demandDrivenData.H"
|
||||||
#include "writePatch.H"
|
#include "foamVtkWriteCellSetFaces.H"
|
||||||
#include "writePointSet.H"
|
#include "foamVtkWriteFaceSet.H"
|
||||||
|
#include "foamVtkWritePointSet.H"
|
||||||
#include "IOobjectList.H"
|
#include "IOobjectList.H"
|
||||||
#include "cellZoneSet.H"
|
#include "cellZoneSet.H"
|
||||||
#include "faceZoneSet.H"
|
#include "faceZoneSet.H"
|
||||||
@ -75,104 +76,39 @@ void writeVTK
|
|||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const topoSet& currentSet,
|
const topoSet& currentSet,
|
||||||
const fileName& vtkName
|
const fileName& vtkBaseName
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (isA<faceSet>(currentSet))
|
if (isA<faceSet>(currentSet))
|
||||||
{
|
{
|
||||||
// Faces of set with OpenFOAM faceID as value
|
// Faces of set with OpenFOAM faceID as value
|
||||||
|
vtk::writeFaceSet
|
||||||
faceList setFaces(currentSet.size());
|
|
||||||
labelList faceValues(currentSet.size());
|
|
||||||
label setFacei = 0;
|
|
||||||
|
|
||||||
forAllConstIter(topoSet, currentSet, iter)
|
|
||||||
{
|
|
||||||
setFaces[setFacei] = mesh.faces()[iter.key()];
|
|
||||||
faceValues[setFacei] = iter.key();
|
|
||||||
setFacei++;
|
|
||||||
}
|
|
||||||
|
|
||||||
primitiveFacePatch fp(setFaces, mesh.points());
|
|
||||||
|
|
||||||
writePatch
|
|
||||||
(
|
(
|
||||||
true,
|
mesh,
|
||||||
currentSet.name(),
|
currentSet,
|
||||||
fp,
|
mesh.time().path()/vtkBaseName,
|
||||||
"faceID",
|
vtk::formatType::LEGACY_BINARY
|
||||||
faceValues,
|
|
||||||
mesh.time().path()/vtkName
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (isA<cellSet>(currentSet))
|
else if (isA<cellSet>(currentSet))
|
||||||
{
|
{
|
||||||
// External faces of cellset with OpenFOAM cellID as value
|
// External faces of cellset with OpenFOAM cellID as value
|
||||||
|
vtk::writeCellSetFaces
|
||||||
Map<label> cellFaces(currentSet.size());
|
|
||||||
|
|
||||||
forAllConstIter(cellSet, currentSet, iter)
|
|
||||||
{
|
|
||||||
label celli = iter.key();
|
|
||||||
|
|
||||||
const cell& cFaces = mesh.cells()[celli];
|
|
||||||
|
|
||||||
forAll(cFaces, i)
|
|
||||||
{
|
|
||||||
label facei = cFaces[i];
|
|
||||||
|
|
||||||
if (mesh.isInternalFace(facei))
|
|
||||||
{
|
|
||||||
label otherCelli = mesh.faceOwner()[facei];
|
|
||||||
|
|
||||||
if (otherCelli == celli)
|
|
||||||
{
|
|
||||||
otherCelli = mesh.faceNeighbour()[facei];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!currentSet.found(otherCelli))
|
|
||||||
{
|
|
||||||
cellFaces.insert(facei, celli);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cellFaces.insert(facei, celli);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
faceList setFaces(cellFaces.size());
|
|
||||||
labelList faceValues(cellFaces.size());
|
|
||||||
label setFacei = 0;
|
|
||||||
|
|
||||||
forAllConstIter(Map<label>, cellFaces, iter)
|
|
||||||
{
|
|
||||||
setFaces[setFacei] = mesh.faces()[iter.key()];
|
|
||||||
faceValues[setFacei] = iter(); // Cell ID
|
|
||||||
setFacei++;
|
|
||||||
}
|
|
||||||
|
|
||||||
primitiveFacePatch fp(setFaces, mesh.points());
|
|
||||||
|
|
||||||
writePatch
|
|
||||||
(
|
(
|
||||||
true,
|
mesh,
|
||||||
currentSet.name(),
|
currentSet,
|
||||||
fp,
|
mesh.time().path()/vtkBaseName,
|
||||||
"cellID",
|
vtk::formatType::LEGACY_BINARY
|
||||||
faceValues,
|
|
||||||
mesh.time().path()/vtkName
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (isA<pointSet>(currentSet))
|
else if (isA<pointSet>(currentSet))
|
||||||
{
|
{
|
||||||
writePointSet
|
vtk::writePointSet
|
||||||
(
|
(
|
||||||
true,
|
|
||||||
mesh,
|
mesh,
|
||||||
currentSet,
|
currentSet,
|
||||||
mesh.time().path()/vtkName
|
mesh.time().path()/vtkBaseName,
|
||||||
|
vtk::formatType::LEGACY_BINARY
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -187,58 +123,58 @@ void writeVTK
|
|||||||
void printHelp(Ostream& os)
|
void printHelp(Ostream& os)
|
||||||
{
|
{
|
||||||
os << "Please type 'help', 'list', 'quit', 'time ddd'"
|
os << "Please type 'help', 'list', 'quit', 'time ddd'"
|
||||||
<< " or a set command after prompt." << endl
|
<< " or a set command after prompt." << nl
|
||||||
<< "'list' will show all current cell/face/point sets." << endl
|
<< "'list' will show all current cell/face/point sets." << nl
|
||||||
<< "'time ddd' will change the current time." << endl
|
<< "'time ddd' will change the current time." << nl
|
||||||
<< endl
|
<< nl
|
||||||
<< "A set command should be of the following form" << endl
|
<< "A set command should be of the following form" << nl
|
||||||
<< endl
|
<< nl
|
||||||
<< " cellSet|faceSet|pointSet <setName> <action> <source>"
|
<< " cellSet|faceSet|pointSet <setName> <action> <source>"
|
||||||
<< endl
|
<< nl
|
||||||
<< endl
|
<< nl
|
||||||
<< "The <action> is one of" << endl
|
<< "The <action> is one of" << nl
|
||||||
<< " list - prints the contents of the set" << endl
|
<< " list - prints the contents of the set" << nl
|
||||||
<< " clear - clears the set" << endl
|
<< " clear - clears the set" << nl
|
||||||
<< " invert - inverts the set" << endl
|
<< " invert - inverts the set" << nl
|
||||||
<< " remove - remove the set" << endl
|
<< " remove - remove the set" << nl
|
||||||
<< " new <source> - sets to set to the source set" << endl
|
<< " new <source> - sets to set to the source set" << nl
|
||||||
<< " add <source> - adds all elements from the source set" << endl
|
<< " add <source> - adds all elements from the source set" << nl
|
||||||
<< " delete <source> - deletes ,," << endl
|
<< " delete <source> - deletes ,," << nl
|
||||||
<< " subset <source> - combines current set with the source set"
|
<< " subset <source> - combines current set with the source set"
|
||||||
<< endl
|
<< nl
|
||||||
<< endl
|
<< nl
|
||||||
<< "The sources come in various forms. Type a wrong source"
|
<< "The sources come in various forms. Type a wrong source"
|
||||||
<< " to see all the types available." << endl
|
<< " to see all the types available." << nl
|
||||||
<< endl
|
<< nl
|
||||||
<< "Example: pick up all cells connected by point or face to patch"
|
<< "Example: pick up all cells connected by point or face to patch"
|
||||||
<< " movingWall" << endl
|
<< " movingWall" << nl
|
||||||
<< endl
|
<< nl
|
||||||
<< "Pick up all faces of patch:" << endl
|
<< "Pick up all faces of patch:" << nl
|
||||||
<< " faceSet f0 new patchToFace movingWall" << endl
|
<< " faceSet f0 new patchToFace movingWall" << nl
|
||||||
<< "Add faces 0,1,2:" << endl
|
<< "Add faces 0,1,2:" << nl
|
||||||
<< " faceSet f0 add labelToFace (0 1 2)" << endl
|
<< " faceSet f0 add labelToFace (0 1 2)" << nl
|
||||||
<< "Pick up all points used by faces in faceSet f0:" << endl
|
<< "Pick up all points used by faces in faceSet f0:" << nl
|
||||||
<< " pointSet p0 new faceToPoint f0 all" << endl
|
<< " pointSet p0 new faceToPoint f0 all" << nl
|
||||||
<< "Pick up cell which has any face in f0:" << endl
|
<< "Pick up cell which has any face in f0:" << nl
|
||||||
<< " cellSet c0 new faceToCell f0 any" << endl
|
<< " cellSet c0 new faceToCell f0 any" << nl
|
||||||
<< "Add cells which have any point in p0:" << endl
|
<< "Add cells which have any point in p0:" << nl
|
||||||
<< " cellSet c0 add pointToCell p0 any" << endl
|
<< " cellSet c0 add pointToCell p0 any" << nl
|
||||||
<< "List set:" << endl
|
<< "List set:" << nl
|
||||||
<< " cellSet c0 list" << endl
|
<< " cellSet c0 list" << nl
|
||||||
<< endl
|
<< nl
|
||||||
<< "Zones can be set using zoneSets from corresponding sets:" << endl
|
<< "Zones can be set using zoneSets from corresponding sets:" << nl
|
||||||
<< " cellZoneSet c0Zone new setToCellZone c0" << endl
|
<< " cellZoneSet c0Zone new setToCellZone c0" << nl
|
||||||
<< " faceZoneSet f0Zone new setToFaceZone f0" << endl
|
<< " faceZoneSet f0Zone new setToFaceZone f0" << nl
|
||||||
<< endl
|
<< nl
|
||||||
<< "or if orientation is important:" << endl
|
<< "or if orientation is important:" << nl
|
||||||
<< " faceZoneSet f0Zone new setsToFaceZone f0 c0" << endl
|
<< " faceZoneSet f0Zone new setsToFaceZone f0 c0" << nl
|
||||||
<< endl
|
<< nl
|
||||||
<< "ZoneSets can be manipulated using the general actions:" << endl
|
<< "ZoneSets can be manipulated using the general actions:" << nl
|
||||||
<< " list - prints the contents of the set" << endl
|
<< " list - prints the contents of the set" << nl
|
||||||
<< " clear - clears the set" << endl
|
<< " clear - clears the set" << nl
|
||||||
<< " invert - inverts the set (undefined orientation)"
|
<< " invert - inverts the set (undefined orientation)"
|
||||||
<< endl
|
<< nl
|
||||||
<< " remove - remove the set" << endl
|
<< " remove - remove the set" << nl
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,7 +513,6 @@ bool doCommand
|
|||||||
"VTK"/currentSet.name()/currentSet.name()
|
"VTK"/currentSet.name()/currentSet.name()
|
||||||
+ "_"
|
+ "_"
|
||||||
+ name(mesh.time().timeIndex())
|
+ name(mesh.time().timeIndex())
|
||||||
+ ".vtk"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< " Writing " << currentSet.name()
|
Info<< " Writing " << currentSet.name()
|
||||||
|
|||||||
@ -1,225 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "writeFuns.H"
|
|
||||||
#include "endian.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void Foam::writeFuns::swapWord(int32_t& word32)
|
|
||||||
{
|
|
||||||
char* mem = reinterpret_cast<char*>(&word32);
|
|
||||||
|
|
||||||
char a = mem[0];
|
|
||||||
mem[0] = mem[3];
|
|
||||||
mem[3] = a;
|
|
||||||
|
|
||||||
a = mem[1];
|
|
||||||
mem[1] = mem[2];
|
|
||||||
mem[2] = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::swapWords(const label nWords, int32_t* words32)
|
|
||||||
{
|
|
||||||
for (label i=0; i<nWords; i++)
|
|
||||||
{
|
|
||||||
swapWord(words32[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::write
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const bool binary,
|
|
||||||
List<floatScalar>& fField
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (binary)
|
|
||||||
{
|
|
||||||
#ifdef WM_LITTLE_ENDIAN
|
|
||||||
swapWords(fField.size(), reinterpret_cast<int32_t*>(fField.begin()));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
os.write
|
|
||||||
(
|
|
||||||
reinterpret_cast<char*>(fField.begin()),
|
|
||||||
fField.size()*sizeof(float)
|
|
||||||
);
|
|
||||||
|
|
||||||
os << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
forAll(fField, i)
|
|
||||||
{
|
|
||||||
os << fField[i] << ' ';
|
|
||||||
|
|
||||||
if (i > 0 && (i % 10) == 0)
|
|
||||||
{
|
|
||||||
os << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::write
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const bool binary,
|
|
||||||
DynamicList<floatScalar>& fField
|
|
||||||
)
|
|
||||||
{
|
|
||||||
List<floatScalar>& fld = fField.shrink();
|
|
||||||
write(os, binary, fld);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::write
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const bool binary,
|
|
||||||
labelList& elems
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (binary)
|
|
||||||
{
|
|
||||||
#ifdef WM_LITTLE_ENDIAN
|
|
||||||
swapWords
|
|
||||||
(
|
|
||||||
(sizeof(label)/4)*elems.size(),
|
|
||||||
reinterpret_cast<int32_t*>(elems.begin())
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
os.write
|
|
||||||
(
|
|
||||||
reinterpret_cast<char*>(elems.begin()),
|
|
||||||
elems.size()*sizeof(label)
|
|
||||||
);
|
|
||||||
|
|
||||||
os << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
forAll(elems, i)
|
|
||||||
{
|
|
||||||
os << elems[i] << ' ';
|
|
||||||
|
|
||||||
if (i > 0 && (i % 10) == 0)
|
|
||||||
{
|
|
||||||
os << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::write
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const bool binary,
|
|
||||||
DynamicList<label>& elems
|
|
||||||
)
|
|
||||||
{
|
|
||||||
labelList& fld = elems.shrink();
|
|
||||||
write(os, binary, fld);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::insert(const point& pt, DynamicList<floatScalar>& dest)
|
|
||||||
{
|
|
||||||
dest.append(float(pt.x()));
|
|
||||||
dest.append(float(pt.y()));
|
|
||||||
dest.append(float(pt.z()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::insert(const labelList& source, DynamicList<label>& dest)
|
|
||||||
{
|
|
||||||
forAll(source, i)
|
|
||||||
{
|
|
||||||
dest.append(source[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::insert
|
|
||||||
(
|
|
||||||
const List<scalar>& source,
|
|
||||||
DynamicList<floatScalar>& dest
|
|
||||||
)
|
|
||||||
{
|
|
||||||
forAll(source, i)
|
|
||||||
{
|
|
||||||
dest.append(float(source[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::insert
|
|
||||||
(
|
|
||||||
const labelList& map,
|
|
||||||
const List<scalar>& source,
|
|
||||||
DynamicList<floatScalar>& dest
|
|
||||||
)
|
|
||||||
{
|
|
||||||
forAll(map, i)
|
|
||||||
{
|
|
||||||
dest.append(float(source[map[i]]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::insert
|
|
||||||
(
|
|
||||||
const List<point>& source,
|
|
||||||
DynamicList<floatScalar>& dest
|
|
||||||
)
|
|
||||||
{
|
|
||||||
forAll(source, i)
|
|
||||||
{
|
|
||||||
insert(source[i], dest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Foam::writeFuns::insert
|
|
||||||
(
|
|
||||||
const labelList& map,
|
|
||||||
const List<point>& source,
|
|
||||||
DynamicList<floatScalar>& dest
|
|
||||||
)
|
|
||||||
{
|
|
||||||
forAll(map, i)
|
|
||||||
{
|
|
||||||
insert(source[map[i]], dest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,127 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Class
|
|
||||||
Foam::writeFuns
|
|
||||||
|
|
||||||
Description
|
|
||||||
Various functions for collecting and writing binary data.
|
|
||||||
|
|
||||||
The LITTLE_ENDIAN is based on 32bit words.
|
|
||||||
It is not clear how 64bit labels should be handled, currently they are
|
|
||||||
split into two 32bit words and swapWord applied to these two.
|
|
||||||
|
|
||||||
writeFuns should be a namespace rather than a class.
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
writeFuns.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef writeFuns_H
|
|
||||||
#define writeFuns_H
|
|
||||||
|
|
||||||
#include "labelList.H"
|
|
||||||
#include "floatScalar.H"
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "DynamicList.H"
|
|
||||||
#include "point.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class writeFuns Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
class writeFuns
|
|
||||||
{
|
|
||||||
// Private member functions
|
|
||||||
|
|
||||||
//- Swap halves of word
|
|
||||||
static void swapWord(int32_t& word32);
|
|
||||||
|
|
||||||
//- Swap halves of word
|
|
||||||
static void swapWords(const label nWords, int32_t* words32);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
//- Write floats ascii or binary.
|
|
||||||
// If binary optionally in-place swaps argument
|
|
||||||
static void write(std::ostream&, const bool, DynamicList<floatScalar>&);
|
|
||||||
|
|
||||||
//- Write labels ascii or binary.
|
|
||||||
// If binary optionally in-place swaps argument
|
|
||||||
static void write(std::ostream&, const bool, DynamicList<label>&);
|
|
||||||
|
|
||||||
//- Write floats ascii or binary.
|
|
||||||
// If binary optionally in-place swaps argument
|
|
||||||
static void write(std::ostream&, const bool, List<floatScalar>&);
|
|
||||||
|
|
||||||
//- Write labels ascii or binary.
|
|
||||||
// If binary optionally in-place swaps argument
|
|
||||||
static void write(std::ostream&, const bool, labelList&);
|
|
||||||
|
|
||||||
//- Append point to given DynamicList
|
|
||||||
static void insert(const point&, DynamicList<floatScalar>& dest);
|
|
||||||
|
|
||||||
//- Append elements of labelList to given DynamicList
|
|
||||||
static void insert(const labelList&, DynamicList<label>&);
|
|
||||||
|
|
||||||
//- Append elements of scalarList to given DynamicList
|
|
||||||
static void insert(const List<scalar>&, DynamicList<floatScalar>&);
|
|
||||||
|
|
||||||
//- Append elements of scalarList to given DynamicList using map
|
|
||||||
static void insert
|
|
||||||
(
|
|
||||||
const labelList& map,
|
|
||||||
const List<scalar>& source,
|
|
||||||
DynamicList<floatScalar>&
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Append points to given DynamicList of floats
|
|
||||||
static void insert(const List<point>& source, DynamicList<floatScalar>&);
|
|
||||||
|
|
||||||
//- Append points to given DynamicList of floats using map
|
|
||||||
static void insert
|
|
||||||
(
|
|
||||||
const labelList& map,
|
|
||||||
const List<point>& source,
|
|
||||||
DynamicList<floatScalar>&
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,127 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "writePatch.H"
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "writeFuns.H"
|
|
||||||
#include "primitiveFacePatch.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void writePatch
|
|
||||||
(
|
|
||||||
const bool binary,
|
|
||||||
const word& setName,
|
|
||||||
const primitiveFacePatch& fp,
|
|
||||||
const word& fieldName,
|
|
||||||
labelList& fieldValues,
|
|
||||||
const fileName& fileName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::ofstream pStream(fileName.c_str());
|
|
||||||
|
|
||||||
pStream
|
|
||||||
<< "# vtk DataFile Version 2.0" << std::endl
|
|
||||||
<< setName << std::endl;
|
|
||||||
if (binary)
|
|
||||||
{
|
|
||||||
pStream << "BINARY" << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pStream << "ASCII" << std::endl;
|
|
||||||
}
|
|
||||||
pStream << "DATASET POLYDATA" << std::endl;
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Write topology
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
// Write points and faces as polygons
|
|
||||||
|
|
||||||
pStream << "POINTS " << fp.nPoints() << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> ptField(3*fp.nPoints());
|
|
||||||
|
|
||||||
writeFuns::insert(fp.localPoints(), ptField);
|
|
||||||
|
|
||||||
writeFuns::write(pStream, binary, ptField);
|
|
||||||
|
|
||||||
|
|
||||||
label nFaceVerts = 0;
|
|
||||||
|
|
||||||
forAll(fp.localFaces(), facei)
|
|
||||||
{
|
|
||||||
nFaceVerts += fp.localFaces()[facei].size() + 1;
|
|
||||||
}
|
|
||||||
pStream << "POLYGONS " << fp.size() << ' ' << nFaceVerts
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
|
|
||||||
DynamicList<label> vertLabels(nFaceVerts);
|
|
||||||
|
|
||||||
forAll(fp.localFaces(), facei)
|
|
||||||
{
|
|
||||||
const face& f = fp.localFaces()[facei];
|
|
||||||
|
|
||||||
vertLabels.append(f.size());
|
|
||||||
|
|
||||||
writeFuns::insert(f, vertLabels);
|
|
||||||
}
|
|
||||||
writeFuns::write(pStream, binary, vertLabels);
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Write data
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------
|
|
||||||
|
|
||||||
// Write faceID
|
|
||||||
|
|
||||||
pStream
|
|
||||||
<< "CELL_DATA " << fp.size() << std::endl
|
|
||||||
<< "FIELD attributes 1" << std::endl;
|
|
||||||
|
|
||||||
// Cell ids first
|
|
||||||
pStream << fieldName << " 1 " << fp.size() << " int" << std::endl;
|
|
||||||
|
|
||||||
writeFuns::write(pStream, binary, fieldValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,105 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "writePointSet.H"
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "writeFuns.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void writePointSet
|
|
||||||
(
|
|
||||||
const bool binary,
|
|
||||||
const primitiveMesh& mesh,
|
|
||||||
const topoSet& set,
|
|
||||||
const fileName& fileName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::ofstream pStream(fileName.c_str());
|
|
||||||
|
|
||||||
pStream
|
|
||||||
<< "# vtk DataFile Version 2.0" << std::endl
|
|
||||||
<< set.name() << std::endl;
|
|
||||||
if (binary)
|
|
||||||
{
|
|
||||||
pStream << "BINARY" << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pStream << "ASCII" << std::endl;
|
|
||||||
}
|
|
||||||
pStream << "DATASET POLYDATA" << std::endl;
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Write topology
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
labelList pointLabels(set.toc());
|
|
||||||
|
|
||||||
pointField setPoints(mesh.points(), pointLabels);
|
|
||||||
|
|
||||||
// Write points
|
|
||||||
|
|
||||||
pStream << "POINTS " << pointLabels.size() << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> ptField(3*pointLabels.size());
|
|
||||||
|
|
||||||
writeFuns::insert(setPoints, ptField);
|
|
||||||
|
|
||||||
writeFuns::write(pStream, binary, ptField);
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Write data
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------
|
|
||||||
|
|
||||||
// Write pointID
|
|
||||||
|
|
||||||
pStream
|
|
||||||
<< "POINT_DATA " << pointLabels.size() << std::endl
|
|
||||||
<< "FIELD attributes 1" << std::endl;
|
|
||||||
|
|
||||||
// Cell ids first
|
|
||||||
pStream << "pointID 1 " << pointLabels.size() << " int" << std::endl;
|
|
||||||
|
|
||||||
writeFuns::write(pStream, binary, pointLabels);
|
|
||||||
}
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -173,8 +173,7 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
"name",
|
"name",
|
||||||
"subdir",
|
"subdir",
|
||||||
"define sub-directory name to use for ensight data "
|
"sub-directory name for ensight output (default: 'EnSight')"
|
||||||
"(default: 'EnSight')"
|
|
||||||
);
|
);
|
||||||
argList::addOption
|
argList::addOption
|
||||||
(
|
(
|
||||||
@ -292,7 +291,7 @@ int main(int argc, char *argv[])
|
|||||||
<< mesh.boundaryMesh()[0].name() << ")"
|
<< mesh.boundaryMesh()[0].name() << ")"
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
meshSubsetHelper myMesh(mesh, meshSubsetHelper::ZONE, cellZoneName);
|
meshSubsetHelper meshRef(mesh, meshSubsetHelper::ZONE, cellZoneName);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Open new ensight case file, initialize header etc.
|
// Open new ensight case file, initialize header etc.
|
||||||
@ -306,7 +305,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
|
|
||||||
// Construct the Ensight mesh
|
// Construct the Ensight mesh
|
||||||
ensightMesh ensMesh(myMesh.mesh(), writeOpts);
|
ensightMesh ensMesh(meshRef.mesh(), writeOpts);
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
@ -375,7 +374,7 @@ int main(int argc, char *argv[])
|
|||||||
polyMesh::readUpdateState meshState = mesh.readUpdate();
|
polyMesh::readUpdateState meshState = mesh.readUpdate();
|
||||||
if (meshState != polyMesh::UNCHANGED)
|
if (meshState != polyMesh::UNCHANGED)
|
||||||
{
|
{
|
||||||
myMesh.correct();
|
meshRef.correct();
|
||||||
ensMesh.expire();
|
ensMesh.expire();
|
||||||
ensMesh.correct();
|
ensMesh.correct();
|
||||||
}
|
}
|
||||||
@ -430,7 +429,7 @@ int main(int argc, char *argv[])
|
|||||||
volScalarField vf(fieldObject, mesh);
|
volScalarField vf(fieldObject, mesh);
|
||||||
wrote = ensightOutput::writeField<scalar>
|
wrote = ensightOutput::writeField<scalar>
|
||||||
(
|
(
|
||||||
myMesh.interpolate(vf),
|
meshRef.interpolate(vf),
|
||||||
ensMesh,
|
ensMesh,
|
||||||
os,
|
os,
|
||||||
nodeValues
|
nodeValues
|
||||||
@ -446,7 +445,7 @@ int main(int argc, char *argv[])
|
|||||||
volVectorField vf(fieldObject, mesh);
|
volVectorField vf(fieldObject, mesh);
|
||||||
wrote = ensightOutput::writeField<vector>
|
wrote = ensightOutput::writeField<vector>
|
||||||
(
|
(
|
||||||
myMesh.interpolate(vf),
|
meshRef.interpolate(vf),
|
||||||
ensMesh,
|
ensMesh,
|
||||||
os,
|
os,
|
||||||
nodeValues
|
nodeValues
|
||||||
@ -462,7 +461,7 @@ int main(int argc, char *argv[])
|
|||||||
volSphericalTensorField vf(fieldObject, mesh);
|
volSphericalTensorField vf(fieldObject, mesh);
|
||||||
wrote = ensightOutput::writeField<sphericalTensor>
|
wrote = ensightOutput::writeField<sphericalTensor>
|
||||||
(
|
(
|
||||||
myMesh.interpolate(vf),
|
meshRef.interpolate(vf),
|
||||||
ensMesh,
|
ensMesh,
|
||||||
os,
|
os,
|
||||||
nodeValues
|
nodeValues
|
||||||
@ -478,7 +477,7 @@ int main(int argc, char *argv[])
|
|||||||
volSymmTensorField vf(fieldObject, mesh);
|
volSymmTensorField vf(fieldObject, mesh);
|
||||||
wrote = ensightOutput::writeField<symmTensor>
|
wrote = ensightOutput::writeField<symmTensor>
|
||||||
(
|
(
|
||||||
myMesh.interpolate(vf),
|
meshRef.interpolate(vf),
|
||||||
ensMesh,
|
ensMesh,
|
||||||
os,
|
os,
|
||||||
nodeValues
|
nodeValues
|
||||||
@ -494,7 +493,7 @@ int main(int argc, char *argv[])
|
|||||||
volTensorField vf(fieldObject, mesh);
|
volTensorField vf(fieldObject, mesh);
|
||||||
wrote = ensightOutput::writeField<tensor>
|
wrote = ensightOutput::writeField<tensor>
|
||||||
(
|
(
|
||||||
myMesh.interpolate(vf),
|
meshRef.interpolate(vf),
|
||||||
ensMesh,
|
ensMesh,
|
||||||
os,
|
os,
|
||||||
nodeValues
|
nodeValues
|
||||||
@ -519,7 +518,7 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
wrote = ensightOutput::writeField<scalar>
|
wrote = ensightOutput::writeField<scalar>
|
||||||
(
|
(
|
||||||
myMesh.interpolate<scalar>(df),
|
meshRef.interpolate<scalar>(df),
|
||||||
ensMesh,
|
ensMesh,
|
||||||
os,
|
os,
|
||||||
nodeValues
|
nodeValues
|
||||||
@ -543,7 +542,7 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
wrote = ensightOutput::writeField<vector>
|
wrote = ensightOutput::writeField<vector>
|
||||||
(
|
(
|
||||||
myMesh.interpolate<vector>(df),
|
meshRef.interpolate<vector>(df),
|
||||||
ensMesh,
|
ensMesh,
|
||||||
os,
|
os,
|
||||||
nodeValues
|
nodeValues
|
||||||
@ -567,7 +566,7 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
wrote = ensightOutput::writeField<sphericalTensor>
|
wrote = ensightOutput::writeField<sphericalTensor>
|
||||||
(
|
(
|
||||||
myMesh.interpolate<sphericalTensor>(df),
|
meshRef.interpolate<sphericalTensor>(df),
|
||||||
ensMesh,
|
ensMesh,
|
||||||
os,
|
os,
|
||||||
nodeValues
|
nodeValues
|
||||||
@ -591,7 +590,7 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
wrote = ensightOutput::writeField<symmTensor>
|
wrote = ensightOutput::writeField<symmTensor>
|
||||||
(
|
(
|
||||||
myMesh.interpolate<symmTensor>(df),
|
meshRef.interpolate<symmTensor>(df),
|
||||||
ensMesh,
|
ensMesh,
|
||||||
os,
|
os,
|
||||||
nodeValues
|
nodeValues
|
||||||
@ -615,7 +614,7 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
wrote = ensightOutput::writeField<tensor>
|
wrote = ensightOutput::writeField<tensor>
|
||||||
(
|
(
|
||||||
myMesh.interpolate<tensor>(df),
|
meshRef.interpolate<tensor>(df),
|
||||||
ensMesh,
|
ensMesh,
|
||||||
os,
|
os,
|
||||||
nodeValues
|
nodeValues
|
||||||
|
|||||||
@ -128,8 +128,7 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
"name",
|
"name",
|
||||||
"subdir",
|
"subdir",
|
||||||
"define sub-directory name to use for Ensight data "
|
"sub-directory name for ensight output (default: 'Ensight')"
|
||||||
"(default: \"Ensight\")"
|
|
||||||
);
|
);
|
||||||
argList::addOption
|
argList::addOption
|
||||||
(
|
(
|
||||||
|
|||||||
@ -296,7 +296,7 @@ int main(int argc, char *argv[])
|
|||||||
mkDir(fvPath);
|
mkDir(fvPath);
|
||||||
|
|
||||||
// Mesh wrapper: does subsetting
|
// Mesh wrapper: does subsetting
|
||||||
meshSubsetHelper myMesh(mesh, meshSubsetHelper::SET, cellSetName);
|
meshSubsetHelper meshRef(mesh, meshSubsetHelper::SET, cellSetName);
|
||||||
|
|
||||||
forAll(timeDirs, timeI)
|
forAll(timeDirs, timeI)
|
||||||
{
|
{
|
||||||
@ -308,8 +308,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Check for new polyMesh/ and update mesh, fvMeshSubset and cell
|
// Check for new polyMesh/ and update mesh, fvMeshSubset and cell
|
||||||
// decomposition.
|
// decomposition.
|
||||||
polyMesh::readUpdateState meshState = myMesh.readUpdate();
|
polyMesh::readUpdateState meshState = meshRef.readUpdate();
|
||||||
const fvMesh& mesh = myMesh.mesh();
|
const fvMesh& mesh = meshRef.mesh();
|
||||||
|
|
||||||
// TotalNumFaceNodes
|
// TotalNumFaceNodes
|
||||||
int32_t nFaceNodes = 0;
|
int32_t nFaceNodes = 0;
|
||||||
@ -333,23 +333,23 @@ int main(int argc, char *argv[])
|
|||||||
// Construct the vol fields (on the original mesh if subsetted)
|
// Construct the vol fields (on the original mesh if subsetted)
|
||||||
|
|
||||||
PtrList<const volScalarField> vsf;
|
PtrList<const volScalarField> vsf;
|
||||||
readFields(myMesh, myMesh.baseMesh(), objects, selectedFields, vsf);
|
readFields(meshRef, meshRef.baseMesh(), objects, selectedFields, vsf);
|
||||||
print(" volScalarFields :", Info, vsf);
|
print(" volScalarFields :", Info, vsf);
|
||||||
|
|
||||||
PtrList<const volVectorField> vvf;
|
PtrList<const volVectorField> vvf;
|
||||||
readFields(myMesh, myMesh.baseMesh(), objects, selectedFields, vvf);
|
readFields(meshRef, meshRef.baseMesh(), objects, selectedFields, vvf);
|
||||||
print(" volVectorFields :", Info, vvf);
|
print(" volVectorFields :", Info, vvf);
|
||||||
|
|
||||||
PtrList<const volSphericalTensorField> vSpheretf;
|
PtrList<const volSphericalTensorField> vSphf;
|
||||||
readFields(myMesh, myMesh.baseMesh(), objects, selectedFields, vSpheretf);
|
readFields(meshRef, meshRef.baseMesh(), objects, selectedFields, vSphf);
|
||||||
print(" volSphericalTensorFields :", Info, vSpheretf);
|
print(" volSphericalTensorFields :", Info, vSphf);
|
||||||
|
|
||||||
PtrList<const volSymmTensorField> vSymmtf;
|
PtrList<const volSymmTensorField> vSymf;
|
||||||
readFields(myMesh, myMesh.baseMesh(), objects, selectedFields, vSymmtf);
|
readFields(meshRef, meshRef.baseMesh(), objects, selectedFields, vSymf);
|
||||||
print(" volSymmTensorFields :", Info, vSymmtf);
|
print(" volSymmTensorFields :", Info, vSymf);
|
||||||
|
|
||||||
PtrList<const volTensorField> vtf;
|
PtrList<const volTensorField> vtf;
|
||||||
readFields(myMesh, myMesh.baseMesh(), objects, selectedFields, vtf);
|
readFields(meshRef, meshRef.baseMesh(), objects, selectedFields, vtf);
|
||||||
print(" volTensorFields :", Info, vtf);
|
print(" volTensorFields :", Info, vtf);
|
||||||
|
|
||||||
|
|
||||||
@ -365,8 +365,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
PtrList<const pointScalarField> psf;
|
PtrList<const pointScalarField> psf;
|
||||||
PtrList<const pointVectorField> pvf;
|
PtrList<const pointVectorField> pvf;
|
||||||
//PtrList<const pointSphericalTensorField> pSpheretf;
|
//PtrList<const pointSphericalTensorField> pSphf;
|
||||||
//PtrList<const pointSymmTensorField> pSymmtf;
|
//PtrList<const pointSymmTensorField> pSymf;
|
||||||
//PtrList<const pointTensorField> ptf;
|
//PtrList<const pointTensorField> ptf;
|
||||||
|
|
||||||
|
|
||||||
@ -402,8 +402,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
readFields
|
readFields
|
||||||
(
|
(
|
||||||
myMesh,
|
meshRef,
|
||||||
pointMesh::New(myMesh.baseMesh()),
|
pointMesh::New(meshRef.baseMesh()),
|
||||||
objects,
|
objects,
|
||||||
selectedFields,
|
selectedFields,
|
||||||
psf
|
psf
|
||||||
@ -412,8 +412,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
readFields
|
readFields
|
||||||
(
|
(
|
||||||
myMesh,
|
meshRef,
|
||||||
pointMesh::New(myMesh.baseMesh()),
|
pointMesh::New(meshRef.baseMesh()),
|
||||||
objects,
|
objects,
|
||||||
selectedFields,
|
selectedFields,
|
||||||
pvf
|
pvf
|
||||||
@ -422,28 +422,28 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
//readFields
|
//readFields
|
||||||
//(
|
//(
|
||||||
// myMesh,
|
// meshRef,
|
||||||
// pointMesh::New(myMesh.baseMesh()),
|
// pointMesh::New(meshRef.baseMesh()),
|
||||||
// objects,
|
// objects,
|
||||||
// selectedFields,
|
// selectedFields,
|
||||||
// pSpheretf
|
// pSphf
|
||||||
//);
|
//);
|
||||||
//print(" pointSphericalTensorFields :", Info, pSpheretf);
|
//print(" pointSphericalTensorFields :", Info, pSphf);
|
||||||
//
|
//
|
||||||
//readFields
|
//readFields
|
||||||
//(
|
//(
|
||||||
// myMesh,
|
// meshRef,
|
||||||
// pointMesh::New(myMesh.baseMesh()),
|
// pointMesh::New(meshRef.baseMesh()),
|
||||||
// objects,
|
// objects,
|
||||||
// selectedFields,
|
// selectedFields,
|
||||||
// pSymmtf
|
// pSymf
|
||||||
//);
|
//);
|
||||||
//print(" pointSymmTensorFields :", Info, pSymmtf);
|
//print(" pointSymmTensorFields :", Info, pSymf);
|
||||||
//
|
//
|
||||||
//readFields
|
//readFields
|
||||||
//(
|
//(
|
||||||
// myMesh,
|
// meshRef,
|
||||||
// pointMesh::New(myMesh.baseMesh()),
|
// pointMesh::New(meshRef.baseMesh()),
|
||||||
// objects,
|
// objects,
|
||||||
// selectedFields,
|
// selectedFields,
|
||||||
// ptf
|
// ptf
|
||||||
@ -495,14 +495,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
tecplotWriter::getTecplotNames
|
tecplotWriter::getTecplotNames
|
||||||
(
|
(
|
||||||
vSpheretf,
|
vSphf,
|
||||||
tecplotWriter::CELL_CENTERED,
|
tecplotWriter::CELL_CENTERED,
|
||||||
varNames,
|
varNames,
|
||||||
varLocation
|
varLocation
|
||||||
);
|
);
|
||||||
tecplotWriter::getTecplotNames
|
tecplotWriter::getTecplotNames
|
||||||
(
|
(
|
||||||
vSpheretf,
|
vSphf,
|
||||||
tecplotWriter::CELL_CENTERED,
|
tecplotWriter::CELL_CENTERED,
|
||||||
cellVarNames,
|
cellVarNames,
|
||||||
cellVarLocation
|
cellVarLocation
|
||||||
@ -510,14 +510,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
tecplotWriter::getTecplotNames
|
tecplotWriter::getTecplotNames
|
||||||
(
|
(
|
||||||
vSymmtf,
|
vSymf,
|
||||||
tecplotWriter::CELL_CENTERED,
|
tecplotWriter::CELL_CENTERED,
|
||||||
varNames,
|
varNames,
|
||||||
varLocation
|
varLocation
|
||||||
);
|
);
|
||||||
tecplotWriter::getTecplotNames
|
tecplotWriter::getTecplotNames
|
||||||
(
|
(
|
||||||
vSymmtf,
|
vSymf,
|
||||||
tecplotWriter::CELL_CENTERED,
|
tecplotWriter::CELL_CENTERED,
|
||||||
cellVarNames,
|
cellVarNames,
|
||||||
cellVarLocation
|
cellVarLocation
|
||||||
@ -607,8 +607,8 @@ int main(int argc, char *argv[])
|
|||||||
// Write all fields
|
// Write all fields
|
||||||
writer.writeFields(vsf);
|
writer.writeFields(vsf);
|
||||||
writer.writeFields(vvf);
|
writer.writeFields(vvf);
|
||||||
writer.writeFields(vSpheretf);
|
writer.writeFields(vSphf);
|
||||||
writer.writeFields(vSymmtf);
|
writer.writeFields(vSymf);
|
||||||
writer.writeFields(vtf);
|
writer.writeFields(vtf);
|
||||||
|
|
||||||
writer.writeFields(psf);
|
writer.writeFields(psf);
|
||||||
@ -689,8 +689,8 @@ int main(int argc, char *argv[])
|
|||||||
// Write all fields
|
// Write all fields
|
||||||
writer.writeFields(vsf);
|
writer.writeFields(vsf);
|
||||||
writer.writeFields(vvf);
|
writer.writeFields(vvf);
|
||||||
writer.writeFields(vSpheretf);
|
writer.writeFields(vSphf);
|
||||||
writer.writeFields(vSymmtf);
|
writer.writeFields(vSymf);
|
||||||
writer.writeFields(vtf);
|
writer.writeFields(vtf);
|
||||||
|
|
||||||
writer.writeFields(psf);
|
writer.writeFields(psf);
|
||||||
@ -784,24 +784,24 @@ int main(int argc, char *argv[])
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
forAll(vSpheretf, i)
|
forAll(vSphf, i)
|
||||||
{
|
{
|
||||||
writer.writeField
|
writer.writeField
|
||||||
(
|
(
|
||||||
writer.getFaceField
|
writer.getFaceField
|
||||||
(
|
(
|
||||||
linearInterpolate(vSpheretf[i])(),
|
linearInterpolate(vSphf[i])(),
|
||||||
faceLabels
|
faceLabels
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
forAll(vSymmtf, i)
|
forAll(vSymf, i)
|
||||||
{
|
{
|
||||||
writer.writeField
|
writer.writeField
|
||||||
(
|
(
|
||||||
writer.getFaceField
|
writer.getFaceField
|
||||||
(
|
(
|
||||||
linearInterpolate(vSymmtf[i])(),
|
linearInterpolate(vSymf[i])(),
|
||||||
faceLabels
|
faceLabels
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -837,7 +837,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
fileName patchFileName;
|
fileName patchFileName;
|
||||||
|
|
||||||
if (myMesh.useSubMesh())
|
if (meshRef.useSubMesh())
|
||||||
{
|
{
|
||||||
patchFileName =
|
patchFileName =
|
||||||
fvPath/"boundaryMesh"/cellSetName
|
fvPath/"boundaryMesh"/cellSetName
|
||||||
@ -930,26 +930,26 @@ int main(int argc, char *argv[])
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
forAll(vSpheretf, i)
|
forAll(vSphf, i)
|
||||||
{
|
{
|
||||||
writer.writeField
|
writer.writeField
|
||||||
(
|
(
|
||||||
writer.getPatchField
|
writer.getPatchField
|
||||||
(
|
(
|
||||||
nearCellValue,
|
nearCellValue,
|
||||||
vSpheretf[i],
|
vSphf[i],
|
||||||
patchID
|
patchID
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
forAll(vSymmtf, i)
|
forAll(vSymf, i)
|
||||||
{
|
{
|
||||||
writer.writeField
|
writer.writeField
|
||||||
(
|
(
|
||||||
writer.getPatchField
|
writer.getPatchField
|
||||||
(
|
(
|
||||||
nearCellValue,
|
nearCellValue,
|
||||||
vSymmtf[i],
|
vSymf[i],
|
||||||
patchID
|
patchID
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -1010,7 +1010,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
fileName patchFileName;
|
fileName patchFileName;
|
||||||
|
|
||||||
if (myMesh.useSubMesh())
|
if (meshRef.useSubMesh())
|
||||||
{
|
{
|
||||||
patchFileName =
|
patchFileName =
|
||||||
fvPath/"faceZoneMesh"/cellSetName
|
fvPath/"faceZoneMesh"/cellSetName
|
||||||
@ -1094,24 +1094,24 @@ int main(int argc, char *argv[])
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
forAll(vSpheretf, i)
|
forAll(vSphf, i)
|
||||||
{
|
{
|
||||||
writer.writeField
|
writer.writeField
|
||||||
(
|
(
|
||||||
writer.getFaceField
|
writer.getFaceField
|
||||||
(
|
(
|
||||||
linearInterpolate(vSpheretf[i])(),
|
linearInterpolate(vSphf[i])(),
|
||||||
pp
|
pp
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
forAll(vSymmtf, i)
|
forAll(vSymf, i)
|
||||||
{
|
{
|
||||||
writer.writeField
|
writer.writeField
|
||||||
(
|
(
|
||||||
writer.getFaceField
|
writer.getFaceField
|
||||||
(
|
(
|
||||||
linearInterpolate(vSymmtf[i])(),
|
linearInterpolate(vSymf[i])(),
|
||||||
pp
|
pp
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
foamVtkLagrangianWriter.C
|
||||||
foamToVTK.C
|
foamToVTK.C
|
||||||
|
|
||||||
EXE = $(FOAM_APPBIN)/foamToVTK
|
EXE = $(FOAM_APPBIN)/foamToVTK
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
EXE_INC = \
|
EXE_INC = \
|
||||||
-IfoamToVTK/lnInclude \
|
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||||
|
-I$(LIB_SRC)/conversion/lnInclude \
|
||||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
-I$(LIB_SRC)/meshTools/lnInclude
|
-I$(LIB_SRC)/meshTools/lnInclude
|
||||||
|
|
||||||
EXE_LIBS = \
|
EXE_LIBS = \
|
||||||
-lfoamToVTK \
|
-lconversion \
|
||||||
-ldynamicMesh \
|
-ldynamicMesh \
|
||||||
-llagrangian \
|
-llagrangian \
|
||||||
-lgenericPatchFields
|
-lgenericPatchFields
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,13 +0,0 @@
|
|||||||
surfaceMeshWriter.C
|
|
||||||
internalWriter.C
|
|
||||||
lagrangianWriter.C
|
|
||||||
patchWriter.C
|
|
||||||
writeFuns.C
|
|
||||||
writeFaceSet.C
|
|
||||||
writePointSet.C
|
|
||||||
writeSurfFields.C
|
|
||||||
vtkTopo.C
|
|
||||||
|
|
||||||
writeVTK/writeVTK.C
|
|
||||||
|
|
||||||
LIB = $(FOAM_LIBBIN)/libfoamToVTK
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
EXE_INC = \
|
|
||||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
|
||||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
|
||||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
|
||||||
-I$(LIB_SRC)/meshTools/lnInclude
|
|
||||||
|
|
||||||
LIB_LIBS = \
|
|
||||||
-ldynamicMesh \
|
|
||||||
-llagrangian \
|
|
||||||
-lgenericPatchFields
|
|
||||||
@ -1,165 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "internalWriter.H"
|
|
||||||
#include "writeFuns.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::internalWriter::internalWriter
|
|
||||||
(
|
|
||||||
const vtkMesh& vMesh,
|
|
||||||
const bool binary,
|
|
||||||
const fileName& fName
|
|
||||||
)
|
|
||||||
:
|
|
||||||
vMesh_(vMesh),
|
|
||||||
binary_(binary),
|
|
||||||
fName_(fName),
|
|
||||||
os_(fName.c_str())
|
|
||||||
{
|
|
||||||
const fvMesh& mesh = vMesh_.mesh();
|
|
||||||
const vtkTopo& topo = vMesh_.topo();
|
|
||||||
|
|
||||||
// Write header
|
|
||||||
writeFuns::writeHeader(os_, binary_, mesh.time().caseName());
|
|
||||||
os_ << "DATASET UNSTRUCTURED_GRID" << std::endl;
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Write topology
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
const labelList& addPointCellLabels = topo.addPointCellLabels();
|
|
||||||
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
|
|
||||||
|
|
||||||
os_ << "POINTS " << nTotPoints << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> ptField(3*nTotPoints);
|
|
||||||
|
|
||||||
writeFuns::insert(mesh.points(), ptField);
|
|
||||||
|
|
||||||
const pointField& ctrs = mesh.cellCentres();
|
|
||||||
forAll(addPointCellLabels, api)
|
|
||||||
{
|
|
||||||
writeFuns::insert(ctrs[addPointCellLabels[api]], ptField);
|
|
||||||
}
|
|
||||||
writeFuns::write(os_, binary_, ptField);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Write cells
|
|
||||||
//
|
|
||||||
|
|
||||||
const labelListList& vtkVertLabels = topo.vertLabels();
|
|
||||||
|
|
||||||
// Count total number of vertices referenced.
|
|
||||||
label nFaceVerts = 0;
|
|
||||||
|
|
||||||
forAll(vtkVertLabels, celli)
|
|
||||||
{
|
|
||||||
nFaceVerts += vtkVertLabels[celli].size() + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
os_ << "CELLS " << vtkVertLabels.size() << ' ' << nFaceVerts << std::endl;
|
|
||||||
|
|
||||||
DynamicList<label> vertLabels(nFaceVerts);
|
|
||||||
|
|
||||||
forAll(vtkVertLabels, celli)
|
|
||||||
{
|
|
||||||
const labelList& vtkVerts = vtkVertLabels[celli];
|
|
||||||
|
|
||||||
vertLabels.append(vtkVerts.size());
|
|
||||||
|
|
||||||
writeFuns::insert(vtkVerts, vertLabels);
|
|
||||||
}
|
|
||||||
writeFuns::write(os_, binary_, vertLabels);
|
|
||||||
|
|
||||||
|
|
||||||
const labelList& vtkCellTypes = topo.cellTypes();
|
|
||||||
|
|
||||||
os_ << "CELL_TYPES " << vtkCellTypes.size() << std::endl;
|
|
||||||
|
|
||||||
// Make copy since writing might swap stuff.
|
|
||||||
DynamicList<label> cellTypes(vtkCellTypes.size());
|
|
||||||
|
|
||||||
writeFuns::insert(vtkCellTypes, cellTypes);
|
|
||||||
|
|
||||||
writeFuns::write(os_, binary_, cellTypes);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void Foam::internalWriter::writeCellIDs()
|
|
||||||
{
|
|
||||||
const fvMesh& mesh = vMesh_.mesh();
|
|
||||||
const vtkTopo& topo = vMesh_.topo();
|
|
||||||
const labelList& vtkCellTypes = topo.cellTypes();
|
|
||||||
const labelList& superCells = topo.superCells();
|
|
||||||
|
|
||||||
// Cell ids first
|
|
||||||
os_ << "cellID 1 " << vtkCellTypes.size() << " int" << std::endl;
|
|
||||||
|
|
||||||
labelList cellId(vtkCellTypes.size());
|
|
||||||
label labelI = 0;
|
|
||||||
|
|
||||||
|
|
||||||
if (vMesh_.useSubMesh())
|
|
||||||
{
|
|
||||||
const labelList& cMap = vMesh_.subsetter().cellMap();
|
|
||||||
|
|
||||||
forAll(mesh.cells(), celli)
|
|
||||||
{
|
|
||||||
cellId[labelI++] = cMap[celli];
|
|
||||||
}
|
|
||||||
forAll(superCells, superCelli)
|
|
||||||
{
|
|
||||||
label origCelli = cMap[superCells[superCelli]];
|
|
||||||
|
|
||||||
cellId[labelI++] = origCelli;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
forAll(mesh.cells(), celli)
|
|
||||||
{
|
|
||||||
cellId[labelI++] = celli;
|
|
||||||
}
|
|
||||||
forAll(superCells, superCelli)
|
|
||||||
{
|
|
||||||
label origCelli = superCells[superCelli];
|
|
||||||
|
|
||||||
cellId[labelI++] = origCelli;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writeFuns::write(os_, binary_, cellId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,99 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "internalWriter.H"
|
|
||||||
#include "writeFuns.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
|
||||||
void Foam::internalWriter::write
|
|
||||||
(
|
|
||||||
const UPtrList<const GeometricField<Type, PatchField, GeoMesh>>& flds
|
|
||||||
)
|
|
||||||
{
|
|
||||||
forAll(flds, i)
|
|
||||||
{
|
|
||||||
writeFuns::write(os_, binary_, flds[i], vMesh_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
void Foam::internalWriter::write
|
|
||||||
(
|
|
||||||
const PtrList<const DimensionedField<Type, volMesh>>& flds
|
|
||||||
)
|
|
||||||
{
|
|
||||||
forAll(flds, i)
|
|
||||||
{
|
|
||||||
writeFuns::write(os_, binary_, flds[i], vMesh_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::internalWriter::write
|
|
||||||
(
|
|
||||||
const volPointInterpolation& pInterp,
|
|
||||||
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds
|
|
||||||
)
|
|
||||||
{
|
|
||||||
forAll(flds, i)
|
|
||||||
{
|
|
||||||
writeFuns::write
|
|
||||||
(
|
|
||||||
os_,
|
|
||||||
binary_,
|
|
||||||
flds[i],
|
|
||||||
pInterp.interpolate(flds[i])(),
|
|
||||||
vMesh_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
void Foam::internalWriter::write
|
|
||||||
(
|
|
||||||
const volPointInterpolation& pInterp,
|
|
||||||
const PtrList<const DimensionedField<Type, volMesh>>& flds
|
|
||||||
)
|
|
||||||
{
|
|
||||||
forAll(flds, i)
|
|
||||||
{
|
|
||||||
writeFuns::write
|
|
||||||
(
|
|
||||||
os_,
|
|
||||||
binary_,
|
|
||||||
flds[i],
|
|
||||||
pInterp.interpolate(flds[i])(),
|
|
||||||
vMesh_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,87 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "lagrangianWriter.H"
|
|
||||||
#include "writeFuns.H"
|
|
||||||
#include "Cloud.H"
|
|
||||||
#include "passiveParticle.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::lagrangianWriter::lagrangianWriter
|
|
||||||
(
|
|
||||||
const fvMesh& mesh,
|
|
||||||
const bool binary,
|
|
||||||
const fileName& fName,
|
|
||||||
const word& cloudName,
|
|
||||||
const bool dummyCloud
|
|
||||||
)
|
|
||||||
:
|
|
||||||
mesh_(mesh),
|
|
||||||
binary_(binary),
|
|
||||||
fName_(fName),
|
|
||||||
cloudName_(cloudName),
|
|
||||||
os_(fName.c_str())
|
|
||||||
{
|
|
||||||
// Write header
|
|
||||||
writeFuns::writeHeader(os_, binary_, mesh_.time().caseName());
|
|
||||||
os_ << "DATASET POLYDATA" << std::endl;
|
|
||||||
|
|
||||||
if (dummyCloud)
|
|
||||||
{
|
|
||||||
nParcels_ = 0;
|
|
||||||
|
|
||||||
os_ << "POINTS " << nParcels_ << " float" << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Cloud<passiveParticle> parcels(mesh, cloudName_, false);
|
|
||||||
|
|
||||||
nParcels_ = parcels.size();
|
|
||||||
|
|
||||||
os_ << "POINTS " << nParcels_ << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> partField(3*parcels.size());
|
|
||||||
|
|
||||||
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
|
|
||||||
{
|
|
||||||
writeFuns::insert(elmnt().position(), partField);
|
|
||||||
}
|
|
||||||
writeFuns::write(os_, binary_, partField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void Foam::lagrangianWriter::writeParcelHeader(const label nFields)
|
|
||||||
{
|
|
||||||
os_ << "POINT_DATA " << nParcels_ << std::endl
|
|
||||||
<< "FIELD attributes " << nFields
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,65 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "lagrangianWriter.H"
|
|
||||||
#include "writeFuns.H"
|
|
||||||
#include "IOField.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::lagrangianWriter::writeIOField(const wordList& objects)
|
|
||||||
{
|
|
||||||
forAll(objects, i)
|
|
||||||
{
|
|
||||||
const word& object = objects[i];
|
|
||||||
|
|
||||||
IOobject header
|
|
||||||
(
|
|
||||||
object,
|
|
||||||
mesh_.time().timeName(),
|
|
||||||
cloud::prefix/cloudName_,
|
|
||||||
mesh_,
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
IOField<Type> fld(header);
|
|
||||||
|
|
||||||
os_ << object << ' '
|
|
||||||
<< int(pTraits<Type>::nComponents) << ' '
|
|
||||||
<< fld.size() << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*fld.size());
|
|
||||||
|
|
||||||
writeFuns::insert(fld, fField);
|
|
||||||
|
|
||||||
writeFuns::write(os_, binary_, fField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,136 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "patchWriter.H"
|
|
||||||
#include "writeFuns.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::patchWriter::patchWriter
|
|
||||||
(
|
|
||||||
const fvMesh& mesh,
|
|
||||||
const bool binary,
|
|
||||||
const bool nearCellValue,
|
|
||||||
const fileName& fName,
|
|
||||||
const labelList& patchIDs
|
|
||||||
)
|
|
||||||
:
|
|
||||||
mesh_(mesh),
|
|
||||||
binary_(binary),
|
|
||||||
nearCellValue_(nearCellValue),
|
|
||||||
fName_(fName),
|
|
||||||
patchIDs_(patchIDs),
|
|
||||||
os_(fName.c_str())
|
|
||||||
{
|
|
||||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
|
||||||
|
|
||||||
// Write header
|
|
||||||
if (patchIDs_.size() == 1)
|
|
||||||
{
|
|
||||||
writeFuns::writeHeader(os_, binary_, patches[patchIDs_[0]].name());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writeFuns::writeHeader(os_, binary_, "patches");
|
|
||||||
}
|
|
||||||
os_ << "DATASET POLYDATA" << std::endl;
|
|
||||||
|
|
||||||
// Write topology
|
|
||||||
nPoints_ = 0;
|
|
||||||
nFaces_ = 0;
|
|
||||||
label nFaceVerts = 0;
|
|
||||||
|
|
||||||
forAll(patchIDs_, i)
|
|
||||||
{
|
|
||||||
const polyPatch& pp = patches[patchIDs_[i]];
|
|
||||||
|
|
||||||
nPoints_ += pp.nPoints();
|
|
||||||
nFaces_ += pp.size();
|
|
||||||
|
|
||||||
forAll(pp, facei)
|
|
||||||
{
|
|
||||||
nFaceVerts += pp[facei].size() + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
os_ << "POINTS " << nPoints_ << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> ptField(3*nPoints_);
|
|
||||||
|
|
||||||
forAll(patchIDs_, i)
|
|
||||||
{
|
|
||||||
const polyPatch& pp = patches[patchIDs_[i]];
|
|
||||||
|
|
||||||
writeFuns::insert(pp.localPoints(), ptField);
|
|
||||||
}
|
|
||||||
writeFuns::write(os_, binary_, ptField);
|
|
||||||
|
|
||||||
os_ << "POLYGONS " << nFaces_ << ' ' << nFaceVerts << std::endl;
|
|
||||||
|
|
||||||
DynamicList<label> vertLabels(nFaceVerts);
|
|
||||||
|
|
||||||
label offset = 0;
|
|
||||||
|
|
||||||
forAll(patchIDs_, i)
|
|
||||||
{
|
|
||||||
const polyPatch& pp = patches[patchIDs_[i]];
|
|
||||||
|
|
||||||
forAll(pp, facei)
|
|
||||||
{
|
|
||||||
const face& f = pp.localFaces()[facei];
|
|
||||||
|
|
||||||
vertLabels.append(f.size());
|
|
||||||
writeFuns::insert(f + offset, vertLabels);
|
|
||||||
}
|
|
||||||
offset += pp.nPoints();
|
|
||||||
}
|
|
||||||
writeFuns::write(os_, binary_, vertLabels);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void Foam::patchWriter::writePatchIDs()
|
|
||||||
{
|
|
||||||
DynamicList<floatScalar> fField(nFaces_);
|
|
||||||
|
|
||||||
os_ << "patchID 1 " << nFaces_ << " float" << std::endl;
|
|
||||||
|
|
||||||
forAll(patchIDs_, i)
|
|
||||||
{
|
|
||||||
label patchi = patchIDs_[i];
|
|
||||||
|
|
||||||
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
|
|
||||||
|
|
||||||
if (!isA<emptyPolyPatch>(pp))
|
|
||||||
{
|
|
||||||
writeFuns::insert(scalarField(pp.size(), patchi), fField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writeFuns::write(os_, binary_, fField);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,153 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Class
|
|
||||||
Foam::patchWriter
|
|
||||||
|
|
||||||
Description
|
|
||||||
Write patch fields
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
patchWriter.C
|
|
||||||
patchWriterTemplates.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef patchWriter_H
|
|
||||||
#define patchWriter_H
|
|
||||||
|
|
||||||
#include "pointMesh.H"
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "volFields.H"
|
|
||||||
#include "pointFields.H"
|
|
||||||
#include "indirectPrimitivePatch.H"
|
|
||||||
#include "PrimitivePatchInterpolation.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
class volPointInterpolation;
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class patchWriter Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
class patchWriter
|
|
||||||
{
|
|
||||||
//- Reference to the OpenFOAM mesh (or subset)
|
|
||||||
const fvMesh& mesh_;
|
|
||||||
|
|
||||||
const bool binary_;
|
|
||||||
|
|
||||||
const bool nearCellValue_;
|
|
||||||
|
|
||||||
const fileName fName_;
|
|
||||||
|
|
||||||
const labelList patchIDs_;
|
|
||||||
|
|
||||||
std::ofstream os_;
|
|
||||||
|
|
||||||
label nPoints_;
|
|
||||||
|
|
||||||
label nFaces_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
//- Construct from components
|
|
||||||
patchWriter
|
|
||||||
(
|
|
||||||
const fvMesh&,
|
|
||||||
const bool binary,
|
|
||||||
const bool nearCellValue,
|
|
||||||
const fileName&,
|
|
||||||
const labelList& patchIDs
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
|
||||||
|
|
||||||
std::ofstream& os()
|
|
||||||
{
|
|
||||||
return os_;
|
|
||||||
}
|
|
||||||
|
|
||||||
label nPoints() const
|
|
||||||
{
|
|
||||||
return nPoints_;
|
|
||||||
}
|
|
||||||
|
|
||||||
label nFaces() const
|
|
||||||
{
|
|
||||||
return nFaces_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Write cellIDs
|
|
||||||
void writePatchIDs();
|
|
||||||
|
|
||||||
//- Write volFields
|
|
||||||
template<class Type>
|
|
||||||
void write
|
|
||||||
(
|
|
||||||
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>&
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Write pointFields
|
|
||||||
template<class Type>
|
|
||||||
void write
|
|
||||||
(
|
|
||||||
const UPtrList
|
|
||||||
<
|
|
||||||
const GeometricField<Type, pointPatchField, pointMesh>
|
|
||||||
>&
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Interpolate and write volFields
|
|
||||||
template<class Type>
|
|
||||||
void write
|
|
||||||
(
|
|
||||||
const PrimitivePatchInterpolation<primitivePatch>&,
|
|
||||||
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>&
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#ifdef NoRepository
|
|
||||||
#include "patchWriterTemplates.C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,145 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "patchWriter.H"
|
|
||||||
#include "writeFuns.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::patchWriter::write
|
|
||||||
(
|
|
||||||
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds
|
|
||||||
)
|
|
||||||
{
|
|
||||||
forAll(flds, fieldi)
|
|
||||||
{
|
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldi];
|
|
||||||
|
|
||||||
os_ << fld.name() << ' '
|
|
||||||
<< int(pTraits<Type>::nComponents) << ' '
|
|
||||||
<< nFaces_ << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nFaces_);
|
|
||||||
|
|
||||||
forAll(patchIDs_, j)
|
|
||||||
{
|
|
||||||
label patchi = patchIDs_[j];
|
|
||||||
|
|
||||||
const fvPatchField<Type>& pfld = fld.boundaryField()[patchi];
|
|
||||||
|
|
||||||
if (nearCellValue_)
|
|
||||||
{
|
|
||||||
writeFuns::insert(pfld.patchInternalField()(), fField);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writeFuns::insert(pfld, fField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writeFuns::write(os_, binary_, fField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::patchWriter::write
|
|
||||||
(
|
|
||||||
const UPtrList<const GeometricField<Type, pointPatchField, pointMesh>>& flds
|
|
||||||
)
|
|
||||||
{
|
|
||||||
forAll(flds, fieldi)
|
|
||||||
{
|
|
||||||
const GeometricField<Type, pointPatchField, pointMesh>& fld =
|
|
||||||
flds[fieldi];
|
|
||||||
|
|
||||||
os_ << fld.name() << ' '
|
|
||||||
<< int(pTraits<Type>::nComponents) << ' '
|
|
||||||
<< nPoints_ << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
|
|
||||||
|
|
||||||
forAll(patchIDs_, j)
|
|
||||||
{
|
|
||||||
label patchi = patchIDs_[j];
|
|
||||||
|
|
||||||
const pointPatchField<Type>& pfld = fld.boundaryField()[patchi];
|
|
||||||
|
|
||||||
writeFuns::insert(pfld.patchInternalField()(), fField);
|
|
||||||
}
|
|
||||||
writeFuns::write(os_, binary_, fField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::patchWriter::write
|
|
||||||
(
|
|
||||||
const PrimitivePatchInterpolation<primitivePatch>& pInter,
|
|
||||||
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds
|
|
||||||
)
|
|
||||||
{
|
|
||||||
forAll(flds, fieldi)
|
|
||||||
{
|
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldi];
|
|
||||||
|
|
||||||
os_ << fld.name() << ' '
|
|
||||||
<< int(pTraits<Type>::nComponents) << ' '
|
|
||||||
<< nPoints_ << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
|
|
||||||
|
|
||||||
forAll(patchIDs_, j)
|
|
||||||
{
|
|
||||||
label patchi = patchIDs_[j];
|
|
||||||
|
|
||||||
const fvPatchField<Type>& pfld = fld.boundaryField()[patchi];
|
|
||||||
|
|
||||||
if (nearCellValue_)
|
|
||||||
{
|
|
||||||
writeFuns::insert
|
|
||||||
(
|
|
||||||
pInter.faceToPointInterpolate
|
|
||||||
(
|
|
||||||
pfld.patchInternalField()()
|
|
||||||
)(),
|
|
||||||
fField
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writeFuns::insert
|
|
||||||
(
|
|
||||||
pInter.faceToPointInterpolate(pfld)(),
|
|
||||||
fField
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writeFuns::write(os_, binary_, fField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,137 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Class
|
|
||||||
Foam::vtkMesh
|
|
||||||
|
|
||||||
Description
|
|
||||||
Encapsulation of VTK mesh data. Holds mesh or meshsubset and
|
|
||||||
polyhedral-cell decomposition on it.
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
vtkMesh.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef vtkMesh_H
|
|
||||||
#define vtkMesh_H
|
|
||||||
|
|
||||||
#include "meshSubsetHelper.H"
|
|
||||||
#include "vtkTopo.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class vtkMesh Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
class vtkMesh
|
|
||||||
:
|
|
||||||
public meshSubsetHelper
|
|
||||||
{
|
|
||||||
// Private data
|
|
||||||
|
|
||||||
//- Current decomposition of topology
|
|
||||||
mutable autoPtr<vtkTopo> topoPtr_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
|
||||||
vtkMesh(const vtkMesh&) = delete;
|
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
|
||||||
void operator=(const vtkMesh&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
//- Construct from components
|
|
||||||
vtkMesh(fvMesh& baseMesh, const word& setName = word::null)
|
|
||||||
:
|
|
||||||
meshSubsetHelper(baseMesh, meshSubsetHelper::SET, setName)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
|
||||||
|
|
||||||
// Access
|
|
||||||
|
|
||||||
//- Topology
|
|
||||||
const vtkTopo& topo() const
|
|
||||||
{
|
|
||||||
if (topoPtr_.empty())
|
|
||||||
{
|
|
||||||
topoPtr_.reset(new vtkTopo(mesh()));
|
|
||||||
}
|
|
||||||
return topoPtr_();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//- Number of field cells
|
|
||||||
label nFieldCells() const
|
|
||||||
{
|
|
||||||
return topo().cellTypes().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//- Number of field points
|
|
||||||
label nFieldPoints() const
|
|
||||||
{
|
|
||||||
return mesh().nPoints() + topo().addPointCellLabels().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
|
||||||
|
|
||||||
//- Read mesh, forcing topo update if necessary
|
|
||||||
polyMesh::readUpdateState readUpdate()
|
|
||||||
{
|
|
||||||
polyMesh::readUpdateState meshState
|
|
||||||
= meshSubsetHelper::readUpdate();
|
|
||||||
|
|
||||||
if (meshState != polyMesh::UNCHANGED)
|
|
||||||
{
|
|
||||||
topoPtr_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
return meshState;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,373 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Description
|
|
||||||
Note: bug in vtk displaying wedges? Seems to display ok if we decompose
|
|
||||||
them. Should be thoroughly tested!
|
|
||||||
(they appear rarely in polyhedral meshes, do appear in some cut meshes)
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "vtkTopo.H"
|
|
||||||
#include "polyMesh.H"
|
|
||||||
#include "cellShape.H"
|
|
||||||
#include "cellModeller.H"
|
|
||||||
#include "Swap.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
bool Foam::vtkTopo::decomposePoly = true;
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::vtkTopo::vtkTopo(const polyMesh& mesh)
|
|
||||||
:
|
|
||||||
mesh_(mesh),
|
|
||||||
vertLabels_(),
|
|
||||||
cellTypes_(),
|
|
||||||
addPointCellLabels_(),
|
|
||||||
superCells_()
|
|
||||||
{
|
|
||||||
const cellModel& tet = *(cellModeller::lookup("tet"));
|
|
||||||
const cellModel& pyr = *(cellModeller::lookup("pyr"));
|
|
||||||
const cellModel& prism = *(cellModeller::lookup("prism"));
|
|
||||||
const cellModel& wedge = *(cellModeller::lookup("wedge"));
|
|
||||||
const cellModel& tetWedge = *(cellModeller::lookup("tetWedge"));
|
|
||||||
const cellModel& hex = *(cellModeller::lookup("hex"));
|
|
||||||
|
|
||||||
const cellShapeList& cellShapes = mesh_.cellShapes();
|
|
||||||
|
|
||||||
// Number of additional points needed by the decomposition of polyhedra
|
|
||||||
label nAddPoints = 0;
|
|
||||||
|
|
||||||
// Number of additional cells generated by the decomposition of polyhedra
|
|
||||||
label nAddCells = 0;
|
|
||||||
|
|
||||||
// face owner is needed to determine the face orientation
|
|
||||||
const labelList& owner = mesh.faceOwner();
|
|
||||||
|
|
||||||
// Scan for cells which need to be decomposed and count additional points
|
|
||||||
// and cells
|
|
||||||
if (decomposePoly)
|
|
||||||
{
|
|
||||||
forAll(cellShapes, celli)
|
|
||||||
{
|
|
||||||
const cellModel& model = cellShapes[celli].model();
|
|
||||||
|
|
||||||
if
|
|
||||||
(
|
|
||||||
model != hex
|
|
||||||
&& model != wedge // See above.
|
|
||||||
&& model != prism
|
|
||||||
&& model != pyr
|
|
||||||
&& model != tet
|
|
||||||
&& model != tetWedge
|
|
||||||
)
|
|
||||||
{
|
|
||||||
const cell& cFaces = mesh_.cells()[celli];
|
|
||||||
|
|
||||||
forAll(cFaces, cFacei)
|
|
||||||
{
|
|
||||||
const face& f = mesh_.faces()[cFaces[cFacei]];
|
|
||||||
|
|
||||||
label nQuads = 0;
|
|
||||||
label nTris = 0;
|
|
||||||
f.nTrianglesQuads(mesh_.points(), nTris, nQuads);
|
|
||||||
|
|
||||||
nAddCells += nQuads + nTris;
|
|
||||||
}
|
|
||||||
|
|
||||||
nAddCells--;
|
|
||||||
nAddPoints++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Set size of additional point addressing array
|
|
||||||
// (from added point to original cell)
|
|
||||||
addPointCellLabels_.setSize(nAddPoints);
|
|
||||||
|
|
||||||
// Set size of additional cells mapping array
|
|
||||||
// (from added cell to original cell)
|
|
||||||
superCells_.setSize(nAddCells);
|
|
||||||
|
|
||||||
// List of vertex labels in VTK ordering
|
|
||||||
vertLabels_.setSize(cellShapes.size() + nAddCells);
|
|
||||||
|
|
||||||
// Label of vtk type
|
|
||||||
cellTypes_.setSize(cellShapes.size() + nAddCells);
|
|
||||||
|
|
||||||
// Set counters for additional points and additional cells
|
|
||||||
label addPointi = 0, addCelli = 0;
|
|
||||||
|
|
||||||
forAll(cellShapes, celli)
|
|
||||||
{
|
|
||||||
const cellShape& cellShape = cellShapes[celli];
|
|
||||||
const cellModel& cellModel = cellShape.model();
|
|
||||||
|
|
||||||
labelList& vtkVerts = vertLabels_[celli];
|
|
||||||
|
|
||||||
if (cellModel == tet)
|
|
||||||
{
|
|
||||||
vtkVerts = cellShape;
|
|
||||||
|
|
||||||
cellTypes_[celli] = VTK_TETRA;
|
|
||||||
}
|
|
||||||
else if (cellModel == pyr)
|
|
||||||
{
|
|
||||||
vtkVerts = cellShape;
|
|
||||||
|
|
||||||
cellTypes_[celli] = VTK_PYRAMID;
|
|
||||||
}
|
|
||||||
else if (cellModel == prism)
|
|
||||||
{
|
|
||||||
// VTK has a different node order for VTK_WEDGE
|
|
||||||
// their triangles point outwards!
|
|
||||||
vtkVerts = cellShape;
|
|
||||||
|
|
||||||
Foam::Swap(vtkVerts[1], vtkVerts[2]);
|
|
||||||
Foam::Swap(vtkVerts[4], vtkVerts[5]);
|
|
||||||
|
|
||||||
cellTypes_[celli] = VTK_WEDGE;
|
|
||||||
}
|
|
||||||
else if (cellModel == tetWedge && decomposePoly)
|
|
||||||
{
|
|
||||||
// Treat as squeezed prism (VTK_WEDGE)
|
|
||||||
vtkVerts.setSize(6);
|
|
||||||
vtkVerts[0] = cellShape[0];
|
|
||||||
vtkVerts[1] = cellShape[2];
|
|
||||||
vtkVerts[2] = cellShape[1];
|
|
||||||
vtkVerts[3] = cellShape[3];
|
|
||||||
vtkVerts[4] = cellShape[4];
|
|
||||||
vtkVerts[5] = cellShape[3];
|
|
||||||
|
|
||||||
cellTypes_[celli] = VTK_WEDGE;
|
|
||||||
}
|
|
||||||
else if (cellModel == wedge)
|
|
||||||
{
|
|
||||||
// Treat as squeezed hex
|
|
||||||
vtkVerts.setSize(8);
|
|
||||||
vtkVerts[0] = cellShape[0];
|
|
||||||
vtkVerts[1] = cellShape[1];
|
|
||||||
vtkVerts[2] = cellShape[2];
|
|
||||||
vtkVerts[3] = cellShape[2];
|
|
||||||
vtkVerts[4] = cellShape[3];
|
|
||||||
vtkVerts[5] = cellShape[4];
|
|
||||||
vtkVerts[6] = cellShape[5];
|
|
||||||
vtkVerts[7] = cellShape[6];
|
|
||||||
|
|
||||||
cellTypes_[celli] = VTK_HEXAHEDRON;
|
|
||||||
}
|
|
||||||
else if (cellModel == hex)
|
|
||||||
{
|
|
||||||
vtkVerts = cellShape;
|
|
||||||
|
|
||||||
cellTypes_[celli] = VTK_HEXAHEDRON;
|
|
||||||
}
|
|
||||||
else if (decomposePoly)
|
|
||||||
{
|
|
||||||
// Polyhedral cell. Decompose into tets + pyramids.
|
|
||||||
|
|
||||||
// Mapping from additional point to cell
|
|
||||||
addPointCellLabels_[addPointi] = celli;
|
|
||||||
|
|
||||||
// The new vertex from the cell-centre
|
|
||||||
const label newVertexLabel = mesh_.nPoints() + addPointi;
|
|
||||||
|
|
||||||
// Whether to insert cell in place of original or not.
|
|
||||||
bool substituteCell = true;
|
|
||||||
|
|
||||||
const labelList& cFaces = mesh_.cells()[celli];
|
|
||||||
forAll(cFaces, cFacei)
|
|
||||||
{
|
|
||||||
const face& f = mesh_.faces()[cFaces[cFacei]];
|
|
||||||
const bool isOwner = (owner[cFaces[cFacei]] == celli);
|
|
||||||
|
|
||||||
// Number of triangles and quads in decomposition
|
|
||||||
label nTris = 0;
|
|
||||||
label nQuads = 0;
|
|
||||||
f.nTrianglesQuads(mesh_.points(), nTris, nQuads);
|
|
||||||
|
|
||||||
// Do actual decomposition into triFcs and quadFcs.
|
|
||||||
faceList triFcs(nTris);
|
|
||||||
faceList quadFcs(nQuads);
|
|
||||||
label trii = 0;
|
|
||||||
label quadi = 0;
|
|
||||||
f.trianglesQuads(mesh_.points(), trii, quadi, triFcs, quadFcs);
|
|
||||||
|
|
||||||
forAll(quadFcs, quadI)
|
|
||||||
{
|
|
||||||
label thisCelli;
|
|
||||||
|
|
||||||
if (substituteCell)
|
|
||||||
{
|
|
||||||
thisCelli = celli;
|
|
||||||
substituteCell = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
thisCelli = mesh_.nCells() + addCelli;
|
|
||||||
superCells_[addCelli++] = celli;
|
|
||||||
}
|
|
||||||
|
|
||||||
labelList& addVtkVerts = vertLabels_[thisCelli];
|
|
||||||
|
|
||||||
addVtkVerts.setSize(5);
|
|
||||||
|
|
||||||
const face& quad = quadFcs[quadI];
|
|
||||||
|
|
||||||
// Ensure we have the correct orientation for the
|
|
||||||
// base of the primitive cell shape.
|
|
||||||
// If the cell is face owner, the orientation needs to be
|
|
||||||
// flipped.
|
|
||||||
// At the moment, VTK doesn't actually seem to care if
|
|
||||||
// negative cells are defined, but we'll do it anyhow
|
|
||||||
// (for safety).
|
|
||||||
if (isOwner)
|
|
||||||
{
|
|
||||||
addVtkVerts[0] = quad[3];
|
|
||||||
addVtkVerts[1] = quad[2];
|
|
||||||
addVtkVerts[2] = quad[1];
|
|
||||||
addVtkVerts[3] = quad[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
addVtkVerts[0] = quad[0];
|
|
||||||
addVtkVerts[1] = quad[1];
|
|
||||||
addVtkVerts[2] = quad[2];
|
|
||||||
addVtkVerts[3] = quad[3];
|
|
||||||
}
|
|
||||||
addVtkVerts[4] = newVertexLabel;
|
|
||||||
|
|
||||||
cellTypes_[thisCelli] = VTK_PYRAMID;
|
|
||||||
}
|
|
||||||
|
|
||||||
forAll(triFcs, triI)
|
|
||||||
{
|
|
||||||
label thisCelli;
|
|
||||||
|
|
||||||
if (substituteCell)
|
|
||||||
{
|
|
||||||
thisCelli = celli;
|
|
||||||
substituteCell = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
thisCelli = mesh_.nCells() + addCelli;
|
|
||||||
superCells_[addCelli++] = celli;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
labelList& addVtkVerts = vertLabels_[thisCelli];
|
|
||||||
|
|
||||||
const face& tri = triFcs[triI];
|
|
||||||
|
|
||||||
addVtkVerts.setSize(4);
|
|
||||||
|
|
||||||
// See note above about the orientation.
|
|
||||||
if (isOwner)
|
|
||||||
{
|
|
||||||
addVtkVerts[0] = tri[2];
|
|
||||||
addVtkVerts[1] = tri[1];
|
|
||||||
addVtkVerts[2] = tri[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
addVtkVerts[0] = tri[0];
|
|
||||||
addVtkVerts[1] = tri[1];
|
|
||||||
addVtkVerts[2] = tri[2];
|
|
||||||
}
|
|
||||||
addVtkVerts[3] = newVertexLabel;
|
|
||||||
|
|
||||||
cellTypes_[thisCelli] = VTK_TETRA;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addPointi++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Polyhedral cell - not decomposed
|
|
||||||
cellTypes_[celli] = VTK_POLYHEDRON;
|
|
||||||
|
|
||||||
const labelList& cFaces = mesh_.cells()[celli];
|
|
||||||
|
|
||||||
// space for the number of faces and size of each face
|
|
||||||
label nData = 1 + cFaces.size();
|
|
||||||
|
|
||||||
// count total number of face points
|
|
||||||
forAll(cFaces, cFacei)
|
|
||||||
{
|
|
||||||
const face& f = mesh.faces()[cFaces[cFacei]];
|
|
||||||
nData += f.size(); // space for the face labels
|
|
||||||
}
|
|
||||||
|
|
||||||
vtkVerts.setSize(nData);
|
|
||||||
|
|
||||||
nData = 0;
|
|
||||||
vtkVerts[nData++] = cFaces.size();
|
|
||||||
|
|
||||||
// build face stream
|
|
||||||
forAll(cFaces, cFacei)
|
|
||||||
{
|
|
||||||
const face& f = mesh.faces()[cFaces[cFacei]];
|
|
||||||
const bool isOwner = (owner[cFaces[cFacei]] == celli);
|
|
||||||
|
|
||||||
// number of labels for this face
|
|
||||||
vtkVerts[nData++] = f.size();
|
|
||||||
|
|
||||||
if (isOwner)
|
|
||||||
{
|
|
||||||
forAll(f, fp)
|
|
||||||
{
|
|
||||||
vtkVerts[nData++] = f[fp];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// fairly immaterial if we reverse the list
|
|
||||||
// or use face::reverseFace()
|
|
||||||
forAllReverse(f, fp)
|
|
||||||
{
|
|
||||||
vtkVerts[nData++] = f[fp];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (decomposePoly)
|
|
||||||
{
|
|
||||||
Pout<< " Original cells:" << mesh_.nCells()
|
|
||||||
<< " points:" << mesh_.nPoints()
|
|
||||||
<< " Additional cells:" << superCells_.size()
|
|
||||||
<< " additional points:" << addPointCellLabels_.size()
|
|
||||||
<< nl << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,127 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "writeFaceSet.H"
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "writeFuns.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void Foam::writeFaceSet
|
|
||||||
(
|
|
||||||
const bool binary,
|
|
||||||
const fvMesh& mesh,
|
|
||||||
const faceSet& set,
|
|
||||||
const fileName& fileName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
const faceList& faces = mesh.faces();
|
|
||||||
|
|
||||||
std::ofstream ostr(fileName.c_str());
|
|
||||||
|
|
||||||
writeFuns::writeHeader
|
|
||||||
(
|
|
||||||
ostr,
|
|
||||||
binary,
|
|
||||||
set.name()
|
|
||||||
);
|
|
||||||
|
|
||||||
ostr<< "DATASET POLYDATA" << std::endl;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Write topology
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
// Construct primitivePatch of faces in faceSet.
|
|
||||||
|
|
||||||
faceList setFaces(set.size());
|
|
||||||
labelList setFaceLabels(set.size());
|
|
||||||
label setFacei = 0;
|
|
||||||
|
|
||||||
forAllConstIter(faceSet, set, iter)
|
|
||||||
{
|
|
||||||
setFaceLabels[setFacei] = iter.key();
|
|
||||||
setFaces[setFacei] = faces[iter.key()];
|
|
||||||
setFacei++;
|
|
||||||
}
|
|
||||||
primitiveFacePatch fp(setFaces, mesh.points());
|
|
||||||
|
|
||||||
|
|
||||||
// Write points and faces as polygons
|
|
||||||
|
|
||||||
ostr<< "POINTS " << fp.nPoints() << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> ptField(3*fp.nPoints());
|
|
||||||
|
|
||||||
writeFuns::insert(fp.localPoints(), ptField);
|
|
||||||
|
|
||||||
writeFuns::write(ostr, binary, ptField);
|
|
||||||
|
|
||||||
|
|
||||||
label nFaceVerts = 0;
|
|
||||||
|
|
||||||
forAll(fp.localFaces(), facei)
|
|
||||||
{
|
|
||||||
nFaceVerts += fp.localFaces()[facei].size() + 1;
|
|
||||||
}
|
|
||||||
ostr<< "POLYGONS " << fp.size() << ' ' << nFaceVerts << std::endl;
|
|
||||||
|
|
||||||
|
|
||||||
DynamicList<label> vertLabels(nFaceVerts);
|
|
||||||
|
|
||||||
forAll(fp.localFaces(), facei)
|
|
||||||
{
|
|
||||||
const face& f = fp.localFaces()[facei];
|
|
||||||
|
|
||||||
vertLabels.append(f.size());
|
|
||||||
|
|
||||||
writeFuns::insert(f, vertLabels);
|
|
||||||
}
|
|
||||||
writeFuns::write(ostr, binary, vertLabels);
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Write data
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------
|
|
||||||
|
|
||||||
// Write faceID
|
|
||||||
|
|
||||||
ostr
|
|
||||||
<< "CELL_DATA " << fp.size() << std::endl
|
|
||||||
<< "FIELD attributes 1" << std::endl;
|
|
||||||
|
|
||||||
// Cell ids first
|
|
||||||
ostr<< "faceID 1 " << fp.size() << " int" << std::endl;
|
|
||||||
|
|
||||||
writeFuns::write(ostr, binary, setFaceLabels);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,264 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "writeFuns.H"
|
|
||||||
#include "vtkTopo.H"
|
|
||||||
#include "endian.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void Foam::writeFuns::swapWord(label& word32)
|
|
||||||
{
|
|
||||||
char* mem = reinterpret_cast<char*>(&word32);
|
|
||||||
|
|
||||||
char a = mem[0];
|
|
||||||
mem[0] = mem[3];
|
|
||||||
mem[3] = a;
|
|
||||||
|
|
||||||
a = mem[1];
|
|
||||||
mem[1] = mem[2];
|
|
||||||
mem[2] = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::swapWords(const label nWords, label* words32)
|
|
||||||
{
|
|
||||||
for (label i = 0; i < nWords; i++)
|
|
||||||
{
|
|
||||||
swapWord(words32[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::write
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const bool binary,
|
|
||||||
List<floatScalar>& fField
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (binary)
|
|
||||||
{
|
|
||||||
#ifdef WM_LITTLE_ENDIAN
|
|
||||||
swapWords(fField.size(), reinterpret_cast<label*>(fField.begin()));
|
|
||||||
#endif
|
|
||||||
os.write
|
|
||||||
(
|
|
||||||
reinterpret_cast<char*>(fField.begin()),
|
|
||||||
fField.size()*sizeof(float)
|
|
||||||
);
|
|
||||||
|
|
||||||
os << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
forAll(fField, i)
|
|
||||||
{
|
|
||||||
os << fField[i];
|
|
||||||
|
|
||||||
if (i > 0 && (i % 10) == 0)
|
|
||||||
{
|
|
||||||
os << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os << ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::write
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const bool binary,
|
|
||||||
DynamicList<floatScalar>& fField
|
|
||||||
)
|
|
||||||
{
|
|
||||||
List<floatScalar>& fld = fField.shrink();
|
|
||||||
|
|
||||||
write(os, binary, fld);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::write
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const bool binary,
|
|
||||||
labelList& elems
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (binary)
|
|
||||||
{
|
|
||||||
#ifdef WM_LITTLE_ENDIAN
|
|
||||||
swapWords(elems.size(), reinterpret_cast<label*>(elems.begin()));
|
|
||||||
#endif
|
|
||||||
os.write
|
|
||||||
(
|
|
||||||
reinterpret_cast<char*>(elems.begin()),
|
|
||||||
elems.size()*sizeof(label)
|
|
||||||
);
|
|
||||||
|
|
||||||
os << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
forAll(elems, i)
|
|
||||||
{
|
|
||||||
os << elems[i];
|
|
||||||
|
|
||||||
if (i > 0 && (i % 10) == 0)
|
|
||||||
{
|
|
||||||
os << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os << ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::write
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const bool binary,
|
|
||||||
DynamicList<label>& elems
|
|
||||||
)
|
|
||||||
{
|
|
||||||
labelList& fld = elems.shrink();
|
|
||||||
|
|
||||||
write(os, binary, fld);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::writeHeader
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const bool binary,
|
|
||||||
const std::string& title
|
|
||||||
)
|
|
||||||
{
|
|
||||||
os << "# vtk DataFile Version 2.0" << std::endl
|
|
||||||
<< title << std::endl;
|
|
||||||
|
|
||||||
if (binary)
|
|
||||||
{
|
|
||||||
os << "BINARY" << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os << "ASCII" << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::writeCellDataHeader
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const label nCells,
|
|
||||||
const label nFields
|
|
||||||
)
|
|
||||||
{
|
|
||||||
os << "CELL_DATA " << nCells << std::endl
|
|
||||||
<< "FIELD attributes " << nFields << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::writePointDataHeader
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const label nPoints,
|
|
||||||
const label nFields
|
|
||||||
)
|
|
||||||
{
|
|
||||||
os << "POINT_DATA " << nPoints << std::endl
|
|
||||||
<< "FIELD attributes " << nFields << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::insert(const scalar src, DynamicList<floatScalar>& dest)
|
|
||||||
{
|
|
||||||
dest.append(float(src));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::insert(const vector& src, DynamicList<floatScalar>& dest)
|
|
||||||
{
|
|
||||||
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
|
|
||||||
{
|
|
||||||
dest.append(float(src[cmpt]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::insert
|
|
||||||
(
|
|
||||||
const sphericalTensor& src,
|
|
||||||
DynamicList<floatScalar>& dest
|
|
||||||
)
|
|
||||||
{
|
|
||||||
for (direction cmpt = 0; cmpt < sphericalTensor::nComponents; ++cmpt)
|
|
||||||
{
|
|
||||||
dest.append(float(src[cmpt]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::insert
|
|
||||||
(
|
|
||||||
const symmTensor& src,
|
|
||||||
DynamicList<floatScalar>& dest
|
|
||||||
)
|
|
||||||
{
|
|
||||||
dest.append(float(src.xx()));
|
|
||||||
dest.append(float(src.yy()));
|
|
||||||
dest.append(float(src.zz()));
|
|
||||||
dest.append(float(src.xy()));
|
|
||||||
dest.append(float(src.yz()));
|
|
||||||
dest.append(float(src.xz()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::insert(const tensor& src, DynamicList<floatScalar>& dest)
|
|
||||||
{
|
|
||||||
for (direction cmpt = 0; cmpt < tensor::nComponents; ++cmpt)
|
|
||||||
{
|
|
||||||
dest.append(float(src[cmpt]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::writeFuns::insert(const labelList& src, DynamicList<label>& dest)
|
|
||||||
{
|
|
||||||
dest.append(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,161 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Class
|
|
||||||
Foam::writeFuns
|
|
||||||
|
|
||||||
Description
|
|
||||||
Various functions for collecting and writing binary data.
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
writeFuns.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef writeFuns_H
|
|
||||||
#define writeFuns_H
|
|
||||||
|
|
||||||
#include "floatScalar.H"
|
|
||||||
#include "DynamicList.H"
|
|
||||||
#include "volFieldsFwd.H"
|
|
||||||
#include "pointFieldsFwd.H"
|
|
||||||
#include "vtkMesh.H"
|
|
||||||
#include "volPointInterpolation.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class writeFuns Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
class writeFuns
|
|
||||||
{
|
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
// Swap halves of word.
|
|
||||||
|
|
||||||
static void swapWord(label& word32);
|
|
||||||
static void swapWords(const label nWords, label* words32);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Write ascii or binary. If binary optionally in-place swaps argument
|
|
||||||
|
|
||||||
static void write(std::ostream&, const bool, List<floatScalar>&);
|
|
||||||
static void write(std::ostream&, const bool, DynamicList<floatScalar>&);
|
|
||||||
static void write(std::ostream&, const bool, labelList&);
|
|
||||||
static void write(std::ostream&, const bool, DynamicList<label>&);
|
|
||||||
|
|
||||||
|
|
||||||
// Write header
|
|
||||||
|
|
||||||
static void writeHeader
|
|
||||||
(
|
|
||||||
std::ostream&,
|
|
||||||
const bool isBinary,
|
|
||||||
const std::string& title
|
|
||||||
);
|
|
||||||
static void writeCellDataHeader
|
|
||||||
(
|
|
||||||
std::ostream&,
|
|
||||||
const label nCells,
|
|
||||||
const label nFields
|
|
||||||
);
|
|
||||||
static void writePointDataHeader
|
|
||||||
(
|
|
||||||
std::ostream&,
|
|
||||||
const label nPoints,
|
|
||||||
const label nFields
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Convert to VTK and store
|
|
||||||
|
|
||||||
static void insert(const scalar, DynamicList<floatScalar>&);
|
|
||||||
static void insert(const point&, DynamicList<floatScalar>&);
|
|
||||||
static void insert(const sphericalTensor&, DynamicList<floatScalar>&);
|
|
||||||
static void insert(const symmTensor&, DynamicList<floatScalar>&);
|
|
||||||
static void insert(const tensor&, DynamicList<floatScalar>&);
|
|
||||||
|
|
||||||
|
|
||||||
//- Append elements to DynamicList
|
|
||||||
static void insert(const labelList&, DynamicList<label>&);
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
static void insert(const List<Type>&, DynamicList<floatScalar>&);
|
|
||||||
|
|
||||||
//- Write volField with cell values (including decomposed cells)
|
|
||||||
template<class Type>
|
|
||||||
static void write
|
|
||||||
(
|
|
||||||
std::ostream&,
|
|
||||||
const bool binary,
|
|
||||||
const DimensionedField<Type, volMesh>&,
|
|
||||||
const vtkMesh&
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Write pointField on all mesh points. Interpolate to cell centre
|
|
||||||
// for decomposed cell centres.
|
|
||||||
template<class Type>
|
|
||||||
static void write
|
|
||||||
(
|
|
||||||
std::ostream&,
|
|
||||||
const bool binary,
|
|
||||||
const GeometricField<Type, pointPatchField, pointMesh>&,
|
|
||||||
const vtkMesh&
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Write interpolated field on points and original cell values on
|
|
||||||
// decomposed cell centres.
|
|
||||||
template<class Type>
|
|
||||||
static void write
|
|
||||||
(
|
|
||||||
std::ostream&,
|
|
||||||
const bool binary,
|
|
||||||
const DimensionedField<Type, volMesh>&,
|
|
||||||
const DimensionedField<Type, pointMesh>&,
|
|
||||||
const vtkMesh&
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#ifdef NoRepository
|
|
||||||
#include "writeFunsTemplates.C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,146 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "writeFuns.H"
|
|
||||||
#include "interpolatePointToCell.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
// Store List in dest
|
|
||||||
template<class Type>
|
|
||||||
void Foam::writeFuns::insert
|
|
||||||
(
|
|
||||||
const List<Type>& source,
|
|
||||||
DynamicList<floatScalar>& dest
|
|
||||||
)
|
|
||||||
{
|
|
||||||
forAll(source, i)
|
|
||||||
{
|
|
||||||
insert(source[i], dest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::writeFuns::write
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const bool binary,
|
|
||||||
const DimensionedField<Type, volMesh>& df,
|
|
||||||
const vtkMesh& vMesh
|
|
||||||
)
|
|
||||||
{
|
|
||||||
const fvMesh& mesh = vMesh.mesh();
|
|
||||||
|
|
||||||
const labelList& superCells = vMesh.topo().superCells();
|
|
||||||
|
|
||||||
label nValues = mesh.nCells() + superCells.size();
|
|
||||||
|
|
||||||
os << df.name() << ' '
|
|
||||||
<< int(pTraits<Type>::nComponents) << ' '
|
|
||||||
<< nValues << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues);
|
|
||||||
|
|
||||||
insert(df.field(), fField);
|
|
||||||
|
|
||||||
forAll(superCells, superCelli)
|
|
||||||
{
|
|
||||||
label origCelli = superCells[superCelli];
|
|
||||||
|
|
||||||
insert(df[origCelli], fField);
|
|
||||||
}
|
|
||||||
write(os, binary, fField);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::writeFuns::write
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const bool binary,
|
|
||||||
const GeometricField<Type, pointPatchField, pointMesh>& pvf,
|
|
||||||
const vtkMesh& vMesh
|
|
||||||
)
|
|
||||||
{
|
|
||||||
const fvMesh& mesh = vMesh.mesh();
|
|
||||||
const vtkTopo& topo = vMesh.topo();
|
|
||||||
|
|
||||||
const labelList& addPointCellLabels = topo.addPointCellLabels();
|
|
||||||
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
|
|
||||||
|
|
||||||
os << pvf.name() << ' '
|
|
||||||
<< int(pTraits<Type>::nComponents) << ' '
|
|
||||||
<< nTotPoints << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
|
|
||||||
|
|
||||||
insert(pvf, fField);
|
|
||||||
|
|
||||||
forAll(addPointCellLabels, api)
|
|
||||||
{
|
|
||||||
label origCelli = addPointCellLabels[api];
|
|
||||||
|
|
||||||
insert(interpolatePointToCell(pvf, origCelli), fField);
|
|
||||||
}
|
|
||||||
write(os, binary, fField);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::writeFuns::write
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const bool binary,
|
|
||||||
const DimensionedField<Type, volMesh>& vvf,
|
|
||||||
const DimensionedField<Type, pointMesh>& pvf,
|
|
||||||
const vtkMesh& vMesh
|
|
||||||
)
|
|
||||||
{
|
|
||||||
const fvMesh& mesh = vMesh.mesh();
|
|
||||||
const vtkTopo& topo = vMesh.topo();
|
|
||||||
|
|
||||||
const labelList& addPointCellLabels = topo.addPointCellLabels();
|
|
||||||
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
|
|
||||||
|
|
||||||
os << vvf.name() << ' '
|
|
||||||
<< int(pTraits<Type>::nComponents) << ' '
|
|
||||||
<< nTotPoints << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
|
|
||||||
|
|
||||||
insert(pvf, fField);
|
|
||||||
|
|
||||||
forAll(addPointCellLabels, api)
|
|
||||||
{
|
|
||||||
label origCelli = addPointCellLabels[api];
|
|
||||||
|
|
||||||
insert(vvf[origCelli], fField);
|
|
||||||
}
|
|
||||||
write(os, binary, fField);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,103 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "writePointSet.H"
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "writeFuns.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void writePointSet
|
|
||||||
(
|
|
||||||
const bool binary,
|
|
||||||
const fvMesh& mesh,
|
|
||||||
const pointSet& set,
|
|
||||||
const fileName& fileName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::ofstream ostr(fileName.c_str());
|
|
||||||
|
|
||||||
writeFuns::writeHeader
|
|
||||||
(
|
|
||||||
ostr,
|
|
||||||
binary,
|
|
||||||
set.name()
|
|
||||||
);
|
|
||||||
|
|
||||||
ostr<< "DATASET POLYDATA" << std::endl;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Write topology
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
// Write points
|
|
||||||
|
|
||||||
ostr<< "POINTS " << set.size() << " float" << std::endl;
|
|
||||||
|
|
||||||
DynamicList<floatScalar> ptField(3*set.size());
|
|
||||||
|
|
||||||
writeFuns::insert
|
|
||||||
(
|
|
||||||
UIndirectList<point>(mesh.points(), set.toc())(),
|
|
||||||
ptField
|
|
||||||
);
|
|
||||||
|
|
||||||
writeFuns::write(ostr, binary, ptField);
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Write data
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------
|
|
||||||
|
|
||||||
// Write faceID
|
|
||||||
|
|
||||||
ostr
|
|
||||||
<< "POINT_DATA " << set.size() << std::endl
|
|
||||||
<< "FIELD attributes 1" << std::endl;
|
|
||||||
|
|
||||||
// Cell ids first
|
|
||||||
ostr<< "pointID 1 " << set.size() << " int" << std::endl;
|
|
||||||
|
|
||||||
labelList pointIDs(set.toc());
|
|
||||||
|
|
||||||
writeFuns::write(ostr, binary, pointIDs);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user