Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
andy
2009-11-12 13:29:10 +00:00
242 changed files with 11486 additions and 2033 deletions

View File

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

View File

@ -0,0 +1,14 @@
EXE_INC = \
-I../simpleFoam \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lincompressibleRASModels \
-lincompressibleTransportModels \
-lfiniteVolume \
-lmeshTools

View File

@ -0,0 +1,47 @@
// Construct the Momentum equation
tmp<fvVectorMatrix> UEqn
(
fvm::div(phi, U)
- fvm::Sp(fvc::div(phi), U)
+ turbulence->divDevReff(U)
);
UEqn().relax();
// Include the porous media resistance and solve the momentum equation
// either implicit in the tensorial resistance or transport using by
// including the spherical part of the resistance in the momentum diagonal
tmp<volScalarField> trAU;
tmp<volTensorField> trTU;
if (pressureImplicitPorosity)
{
tmp<volTensorField> tTU = tensor(I)*UEqn().A();
pZones.addResistance(UEqn(), tTU());
trTU = inv(tTU());
trTU().rename("rAU");
volVectorField gradp = fvc::grad(p);
for (int UCorr=0; UCorr<nUCorr; UCorr++)
{
U = trTU() & (UEqn().H() - gradp);
}
U.correctBoundaryConditions();
}
else
{
pZones.addResistance(UEqn());
eqnResidual = solve
(
UEqn() == -fvc::grad(p)
). initialResidual();
maxResidual = max(eqnResidual, maxResidual);
trAU = 1.0/UEqn().A();
trAU().rename("rAU");
}

View File

@ -0,0 +1,64 @@
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, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue);
singlePhaseTransportModel laminarTransport(U, phi);
autoPtr<incompressible::RASModel> turbulence
(
incompressible::RASModel::New(U, phi, laminarTransport)
);
porousZones pZones(mesh);
Switch pressureImplicitPorosity(false);
int nUCorr = 0;
if (pZones.size())
{
// nUCorrectors for pressureImplicitPorosity
if (mesh.solutionDict().subDict("SIMPLE").found("nUCorrectors"))
{
nUCorr = readInt
(
mesh.solutionDict().subDict("SIMPLE").lookup("nUCorrectors")
);
}
if (nUCorr > 0)
{
pressureImplicitPorosity = true;
}
}

View File

@ -0,0 +1,59 @@
if (pressureImplicitPorosity)
{
U = trTU()&UEqn().H();
}
else
{
U = trAU()*UEqn().H();
}
UEqn.clear();
phi = fvc::interpolate(U) & mesh.Sf();
adjustPhi(phi, U, p);
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
tmp<fvScalarMatrix> tpEqn;
if (pressureImplicitPorosity)
{
tpEqn = (fvm::laplacian(trTU(), p) == fvc::div(phi));
}
else
{
tpEqn = (fvm::laplacian(trAU(), p) == fvc::div(phi));
}
tpEqn().setReference(pRefCell, pRefValue);
// retain the residual from the first iteration
if (nonOrth == 0)
{
eqnResidual = tpEqn().solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
}
else
{
tpEqn().solve();
}
if (nonOrth == nNonOrthCorr)
{
phi -= tpEqn().flux();
}
}
#include "continuityErrs.H"
// Explicitly relax pressure for momentum corrector
p.relax();
if (pressureImplicitPorosity)
{
U -= trTU()&fvc::grad(p);
}
else
{
U -= trAU()*fvc::grad(p);
}
U.correctBoundaryConditions();

View File

@ -0,0 +1,85 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
porousSimpleFoam
Description
Steady-state solver for incompressible, turbulent flow with
implicit or explicit porosity treatment
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "RASModel.H"
#include "porousZones.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"
#include "initContinuityErrs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;
#include "readSIMPLEControls.H"
#include "initConvergenceCheck.H"
p.storePrevIter();
// Pressure-velocity SIMPLE corrector
{
#include "UEqn.H"
#include "pEqn.H"
}
turbulence->correct();
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
#include "convergenceCheck.H"
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,6 @@
incompressibleThreePhaseMixture/threePhaseMixture.C
threePhaseInterfaceProperties/threePhaseInterfaceProperties.C
interMixingFoam.C
EXE = $(FOAM_APPBIN)/interMixingFoam

View File

@ -0,0 +1,17 @@
INTERFOAM = $(FOAM_SOLVERS)/multiphase/interFoam
EXE_INC = \
-I$(INTERFOAM) \
-IincompressibleThreePhaseMixture \
-IthreePhaseInterfaceProperties \
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/transportModels
EXE_LIBS = \
-linterfaceProperties \
-lincompressibleTransportModels \
-lincompressibleRASModels \
-lincompressibleLESModels \
-lfiniteVolume

View File

@ -0,0 +1,164 @@
{
word alphaScheme("div(phi,alpha)");
word alpharScheme("div(phirb,alpha)");
surfaceScalarField phir
(
IOobject
(
"phir",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
interface.cAlpha()*mag(phi/mesh.magSf())*interface.nHatf()
);
for (int gCorr=0; gCorr<nAlphaCorr; gCorr++)
{
// Create the limiter to be used for all phase-fractions
scalarField allLambda(mesh.nFaces(), 1.0);
// Split the limiter into a surfaceScalarField
slicedSurfaceScalarField lambda
(
IOobject
(
"lambda",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh,
dimless,
allLambda
);
// Create the complete convection flux for alpha1
surfaceScalarField phiAlpha1 =
fvc::flux
(
phi,
alpha1,
alphaScheme
)
+ fvc::flux
(
-fvc::flux(-phir, alpha2, alpharScheme),
alpha1,
alpharScheme
)
+ fvc::flux
(
-fvc::flux(-phir, alpha3, alpharScheme),
alpha1,
alpharScheme
);
// Create the bounded (upwind) flux for alpha1
surfaceScalarField phiAlpha1BD =
upwind<scalar>(mesh, phi).flux(alpha1);
// Calculate the flux correction for alpha1
phiAlpha1 -= phiAlpha1BD;
// Calculate the limiter for alpha1
MULES::limiter
(
allLambda,
oneField(),
alpha1,
phiAlpha1BD,
phiAlpha1,
zeroField(),
zeroField(),
1,
0,
3
);
// Create the complete flux for alpha2
surfaceScalarField phiAlpha2 =
fvc::flux
(
phi,
alpha2,
alphaScheme
)
+ fvc::flux
(
-fvc::flux(phir, alpha1, alpharScheme),
alpha2,
alpharScheme
);
// Create the bounded (upwind) flux for alpha2
surfaceScalarField phiAlpha2BD =
upwind<scalar>(mesh, phi).flux(alpha2);
// Calculate the flux correction for alpha2
phiAlpha2 -= phiAlpha2BD;
// Further limit the limiter for alpha2
MULES::limiter
(
allLambda,
oneField(),
alpha2,
phiAlpha2BD,
phiAlpha2,
zeroField(),
zeroField(),
1,
0,
3
);
// Construct the limited fluxes
phiAlpha1 = phiAlpha1BD + lambda*phiAlpha1;
phiAlpha2 = phiAlpha2BD + lambda*phiAlpha2;
// Solve for alpha1
solve(fvm::ddt(alpha1) + fvc::div(phiAlpha1));
// Create the diffusion coefficients for alpha2<->alpha3
volScalarField Dc23 = D23*max(alpha3, scalar(0))*pos(alpha2);
volScalarField Dc32 = D23*max(alpha2, scalar(0))*pos(alpha3);
// Add the diffusive flux for alpha3->alpha2
phiAlpha2 -= fvc::interpolate(Dc32)*mesh.magSf()*fvc::snGrad(alpha1);
// Solve for alpha2
fvScalarMatrix alpha2Eqn
(
fvm::ddt(alpha2)
+ fvc::div(phiAlpha2)
- fvm::laplacian(Dc23 + Dc32, alpha2)
);
alpha2Eqn.solve();
// Construct the complete mass flux
rhoPhi =
phiAlpha1*(rho1 - rho3)
+ (phiAlpha2 + alpha2Eqn.flux())*(rho2 - rho3)
+ phi*rho3;
alpha3 = 1.0 - alpha1 - alpha2;
}
Info<< "Air phase volume fraction = "
<< alpha1.weightedAverage(mesh.V()).value()
<< " Min(alpha1) = " << min(alpha1).value()
<< " Max(alpha1) = " << max(alpha1).value()
<< endl;
Info<< "Liquid phase volume fraction = "
<< alpha2.weightedAverage(mesh.V()).value()
<< " Min(alpha2) = " << min(alpha2).value()
<< " Max(alpha2) = " << max(alpha2).value()
<< endl;
}

View File

@ -0,0 +1,43 @@
label nAlphaCorr
(
readLabel(piso.lookup("nAlphaCorr"))
);
label nAlphaSubCycles
(
readLabel(piso.lookup("nAlphaSubCycles"))
);
if (nAlphaSubCycles > 1)
{
surfaceScalarField rhoPhiSum = 0.0*rhoPhi;
dimensionedScalar totalDeltaT = runTime.deltaT();
for
(
subCycle<volScalarField> alphaSubCycle(alpha1, nAlphaSubCycles);
!(++alphaSubCycle).end();
)
{
# include "alphaEqns.H"
rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi;
}
rhoPhi = rhoPhiSum;
}
else
{
# include "alphaEqns.H"
}
interface.correct();
{
volScalarField rhoNew = alpha1*rho1 + alpha2*rho2 + alpha3*rho3;
//solve(fvm::ddt(rho) + fvc::div(rhoPhi));
//Info<< "density error = "
// << max((mag(rho - rhoNew)/mag(rhoNew))().internalField()) << endl;
rho == rhoNew;
}

View File

@ -0,0 +1,132 @@
Info<< "Reading field p\n" << endl;
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field alpha1\n" << endl;
volScalarField alpha1
(
IOobject
(
"alpha1",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field alpha2\n" << endl;
volScalarField alpha2
(
IOobject
(
"alpha2",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field alpha3\n" << endl;
volScalarField alpha3
(
IOobject
(
"alpha3",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
alpha3 == 1.0 - alpha1 - alpha2;
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
# include "createPhi.H"
threePhaseMixture threePhaseProperties(U, phi);
const dimensionedScalar& rho1 = threePhaseProperties.rho1();
const dimensionedScalar& rho2 = threePhaseProperties.rho2();
const dimensionedScalar& rho3 = threePhaseProperties.rho3();
dimensionedScalar D23(threePhaseProperties.lookup("D23"));
// Need to store rho for ddt(rho, U)
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT
),
alpha1*rho1 + alpha2*rho2 + alpha3*rho3,
alpha1.boundaryField().types()
);
rho.oldTime();
// Mass flux
// Initialisation does not matter because rhoPhi is reset after the
// alpha solution before it is used in the U equation.
surfaceScalarField rhoPhi
(
IOobject
(
"rho*phi",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho1*phi
);
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue);
// Construct interface from alpha distribution
threePhaseInterfaceProperties interface(threePhaseProperties);
// Construct incompressible turbulence model
autoPtr<incompressible::turbulenceModel> turbulence
(
incompressible::turbulenceModel::New(U, phi, threePhaseProperties)
);

View File

@ -0,0 +1,204 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
threePhaseMixture
\*---------------------------------------------------------------------------*/
#include "threePhaseMixture.H"
#include "addToRunTimeSelectionTable.H"
#include "surfaceFields.H"
#include "fvc.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
//- Calculate and return the laminar viscosity
void Foam::threePhaseMixture::calcNu()
{
// Average kinematic viscosity calculated from dynamic viscosity
nu_ = mu()/(alpha1_*rho1_ + alpha2_*rho2_ + alpha3_*rho3_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::threePhaseMixture::threePhaseMixture
(
const volVectorField& U,
const surfaceScalarField& phi
)
:
transportModel(U, phi),
phase1Name_("phase1"),
phase2Name_("phase2"),
phase3Name_("phase3"),
nuModel1_
(
viscosityModel::New
(
"nu1",
subDict(phase1Name_),
U,
phi
)
),
nuModel2_
(
viscosityModel::New
(
"nu2",
subDict(phase2Name_),
U,
phi
)
),
nuModel3_
(
viscosityModel::New
(
"nu3",
subDict(phase2Name_),
U,
phi
)
),
rho1_(nuModel1_->viscosityProperties().lookup("rho")),
rho2_(nuModel2_->viscosityProperties().lookup("rho")),
rho3_(nuModel3_->viscosityProperties().lookup("rho")),
U_(U),
phi_(phi),
alpha1_(U_.db().lookupObject<const volScalarField> ("alpha1")),
alpha2_(U_.db().lookupObject<const volScalarField> ("alpha2")),
alpha3_(U_.db().lookupObject<const volScalarField> ("alpha3")),
nu_
(
IOobject
(
"nu",
U_.time().timeName(),
U_.db()
),
U_.mesh(),
dimensionedScalar("nu", dimensionSet(0, 2, -1, 0, 0), 0),
calculatedFvPatchScalarField::typeName
)
{
calcNu();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::threePhaseMixture::mu() const
{
return tmp<volScalarField>
(
new volScalarField
(
"mu",
alpha1_*rho1_*nuModel1_->nu()
+ alpha2_*rho2_*nuModel2_->nu()
+ alpha3_*rho3_*nuModel3_->nu()
)
);
}
Foam::tmp<Foam::surfaceScalarField> Foam::threePhaseMixture::muf() const
{
surfaceScalarField alpha1f = fvc::interpolate(alpha1_);
surfaceScalarField alpha2f = fvc::interpolate(alpha2_);
surfaceScalarField alpha3f = fvc::interpolate(alpha3_);
return tmp<surfaceScalarField>
(
new surfaceScalarField
(
"mu",
alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
+ alpha2f*rho2_*fvc::interpolate(nuModel2_->nu())
+ alpha3f*rho3_*fvc::interpolate(nuModel3_->nu())
)
);
}
Foam::tmp<Foam::surfaceScalarField> Foam::threePhaseMixture::nuf() const
{
surfaceScalarField alpha1f = fvc::interpolate(alpha1_);
surfaceScalarField alpha2f = fvc::interpolate(alpha2_);
surfaceScalarField alpha3f = fvc::interpolate(alpha3_);
return tmp<surfaceScalarField>
(
new surfaceScalarField
(
"nu",
(
alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
+ alpha2f*rho2_*fvc::interpolate(nuModel2_->nu())
+ alpha3f*rho3_*fvc::interpolate(nuModel3_->nu())
)/(alpha1f*rho1_ + alpha2f*rho2_ + alpha3f*rho3_)
)
);
}
bool Foam::threePhaseMixture::read()
{
if (transportModel::read())
{
if
(
nuModel1_().read(*this)
&& nuModel2_().read(*this)
&& nuModel3_().read(*this)
)
{
nuModel1_->viscosityProperties().lookup("rho") >> rho1_;
nuModel2_->viscosityProperties().lookup("rho") >> rho2_;
nuModel3_->viscosityProperties().lookup("rho") >> rho3_;
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,197 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
threePhaseMixture
Description
SourceFiles
threePhaseMixture.C
\*---------------------------------------------------------------------------*/
#ifndef threePhaseMixture_H
#define threePhaseMixture_H
#include "incompressible/transportModel/transportModel.H"
#include "incompressible/viscosityModels/viscosityModel/viscosityModel.H"
#include "dimensionedScalar.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class threePhaseMixture Declaration
\*---------------------------------------------------------------------------*/
class threePhaseMixture
:
public transportModel
{
// Private data
word phase1Name_;
word phase2Name_;
word phase3Name_;
autoPtr<viscosityModel> nuModel1_;
autoPtr<viscosityModel> nuModel2_;
autoPtr<viscosityModel> nuModel3_;
dimensionedScalar rho1_;
dimensionedScalar rho2_;
dimensionedScalar rho3_;
const volVectorField& U_;
const surfaceScalarField& phi_;
const volScalarField& alpha1_;
const volScalarField& alpha2_;
const volScalarField& alpha3_;
volScalarField nu_;
// Private Member Functions
//- Calculate and return the laminar viscosity
void calcNu();
public:
// Constructors
//- Construct from components
threePhaseMixture
(
const volVectorField& U,
const surfaceScalarField& phi
);
// Destructor
~threePhaseMixture()
{}
// Member Functions
//- Return const-access to phase1 viscosityModel
const viscosityModel& nuModel1() const
{
return nuModel1_();
}
//- Return const-access to phase2 viscosityModel
const viscosityModel& nuModel2() const
{
return nuModel2_();
}
//- Return const-access to phase3 viscosityModel
const viscosityModel& nuModel3() const
{
return nuModel3_();
}
//- Return const-access to phase1 density
const dimensionedScalar& rho1() const
{
return rho1_;
}
//- Return const-access to phase2 density
const dimensionedScalar& rho2() const
{
return rho2_;
};
//- Return const-access to phase3 density
const dimensionedScalar& rho3() const
{
return rho3_;
};
const volScalarField& alpha1() const
{
return alpha1_;
}
const volScalarField& alpha2() const
{
return alpha2_;
}
const volScalarField& alpha3() const
{
return alpha3_;
}
//- Return the velocity
const volVectorField& U() const
{
return U_;
}
//- Return the dynamic laminar viscosity
tmp<volScalarField> mu() const;
//- Return the face-interpolated dynamic laminar viscosity
tmp<surfaceScalarField> muf() const;
//- Return the kinematic laminar viscosity
tmp<volScalarField> nu() const
{
return nu_;
}
//- Return the face-interpolated dynamic laminar viscosity
tmp<surfaceScalarField> nuf() const;
//- Correct the laminar viscosity
void correct()
{
calcNu();
}
//- Read base transportProperties dictionary
bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,102 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Application
interMixingFoam
Description
Solver for 3 incompressible fluids, two of which are miscible,
using a VOF method to capture the interface.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "MULES.H"
#include "subCycle.H"
#include "threePhaseMixture.H"
#include "threePhaseInterfaceProperties.H"
#include "turbulenceModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "readGravitationalAcceleration.H"
#include "readPISOControls.H"
#include "initContinuityErrs.H"
#include "createFields.H"
#include "readTimeControls.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
#include "correctPhi.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
#include "readPISOControls.H"
#include "readTimeControls.H"
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
threePhaseProperties.correct();
#include "alphaEqnsSubCycle.H"
#define twoPhaseProperties threePhaseProperties
#include "UEqn.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
#include "pEqn.H"
}
#include "continuityErrs.H"
turbulence->correct();
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "\n end \n";
return(0);
}
// ************************************************************************* //

View File

@ -0,0 +1,209 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Application
threePhaseInterfaceProperties
Description
Properties to aid interFoam :
1. Correct the alpha boundary condition for dynamic contact angle.
2. Calculate interface curvature.
\*---------------------------------------------------------------------------*/
#include "threePhaseInterfaceProperties.H"
#include "alphaContactAngleFvPatchScalarField.H"
#include "mathematicalConstants.H"
#include "surfaceInterpolate.H"
#include "fvcDiv.H"
#include "fvcGrad.H"
// * * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * //
const Foam::scalar Foam::threePhaseInterfaceProperties::convertToRad =
Foam::constant::mathematical::pi/180.0;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Correction for the boundary condition on the unit normal nHat on
// walls to produce the correct contact angle.
// The dynamic contact angle is calculated from the component of the
// velocity on the direction of the interface, parallel to the wall.
void Foam::threePhaseInterfaceProperties::correctContactAngle
(
surfaceVectorField::GeometricBoundaryField& nHatb
) const
{
const volScalarField::GeometricBoundaryField& alpha1 =
mixture_.alpha1().boundaryField();
const volScalarField::GeometricBoundaryField& alpha2 =
mixture_.alpha2().boundaryField();
const volScalarField::GeometricBoundaryField& alpha3 =
mixture_.alpha3().boundaryField();
const volVectorField::GeometricBoundaryField& U =
mixture_.U().boundaryField();
const fvMesh& mesh = mixture_.U().mesh();
const fvBoundaryMesh& boundary = mesh.boundary();
forAll(boundary, patchi)
{
if (isA<alphaContactAngleFvPatchScalarField>(alpha1[patchi]))
{
const alphaContactAngleFvPatchScalarField& a2cap =
refCast<const alphaContactAngleFvPatchScalarField>
(alpha2[patchi]);
const alphaContactAngleFvPatchScalarField& a3cap =
refCast<const alphaContactAngleFvPatchScalarField>
(alpha3[patchi]);
scalarField twoPhaseAlpha2 = max(a2cap, scalar(0));
scalarField twoPhaseAlpha3 = max(a3cap, scalar(0));
scalarField sumTwoPhaseAlpha =
twoPhaseAlpha2 + twoPhaseAlpha3 + SMALL;
twoPhaseAlpha2 /= sumTwoPhaseAlpha;
twoPhaseAlpha3 /= sumTwoPhaseAlpha;
fvsPatchVectorField& nHatp = nHatb[patchi];
scalarField theta =
convertToRad
*(
twoPhaseAlpha2*(180 - a2cap.theta(U[patchi], nHatp))
+ twoPhaseAlpha3*(180 - a3cap.theta(U[patchi], nHatp))
);
vectorField nf = boundary[patchi].nf();
// Reset nHatPatch to correspond to the contact angle
scalarField a12 = nHatp & nf;
scalarField b1 = cos(theta);
scalarField b2(nHatp.size());
forAll(b2, facei)
{
b2[facei] = cos(acos(a12[facei]) - theta[facei]);
}
scalarField det = 1.0 - a12*a12;
scalarField a = (b1 - a12*b2)/det;
scalarField b = (b2 - a12*b1)/det;
nHatp = a*nf + b*nHatp;
nHatp /= (mag(nHatp) + deltaN_.value());
}
}
}
void Foam::threePhaseInterfaceProperties::calculateK()
{
const volScalarField& alpha1 = mixture_.alpha1();
const fvMesh& mesh = alpha1.mesh();
const surfaceVectorField& Sf = mesh.Sf();
// Cell gradient of alpha
volVectorField gradAlpha = fvc::grad(alpha1);
// Interpolated face-gradient of alpha
surfaceVectorField gradAlphaf = fvc::interpolate(gradAlpha);
// Face unit interface normal
surfaceVectorField nHatfv = gradAlphaf/(mag(gradAlphaf) + deltaN_);
correctContactAngle(nHatfv.boundaryField());
// Face unit interface normal flux
nHatf_ = nHatfv & Sf;
// Simple expression for curvature
K_ = -fvc::div(nHatf_);
// Complex expression for curvature.
// Correction is formally zero but numerically non-zero.
//volVectorField nHat = gradAlpha/(mag(gradAlpha) + deltaN_);
//nHat.boundaryField() = nHatfv.boundaryField();
//K_ = -fvc::div(nHatf_) + (nHat & fvc::grad(nHatfv) & nHat);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::threePhaseInterfaceProperties::threePhaseInterfaceProperties
(
const threePhaseMixture& mixture
)
:
mixture_(mixture),
cAlpha_
(
readScalar
(
mixture.U().mesh().solutionDict().subDict("PISO").lookup("cAlpha")
)
),
sigma12_(mixture.lookup("sigma12")),
sigma13_(mixture.lookup("sigma13")),
deltaN_
(
"deltaN",
1e-8/pow(average(mixture.U().mesh().V()), 1.0/3.0)
),
nHatf_
(
(
fvc::interpolate(fvc::grad(mixture.alpha1()))
/(mag(fvc::interpolate(fvc::grad(mixture.alpha1()))) + deltaN_)
) & mixture.alpha1().mesh().Sf()
),
K_
(
IOobject
(
"K",
mixture.alpha1().time().timeName(),
mixture.alpha1().mesh()
),
-fvc::div(nHatf_)
)
{
calculateK();
}
// ************************************************************************* //

View File

@ -0,0 +1,157 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
threePhaseInterfaceProperties
Description
Properties to aid interFoam :
1. Correct the alpha boundary condition for dynamic contact angle.
2. Calculate interface curvature.
SourceFiles
threePhaseInterfaceProperties.C
\*---------------------------------------------------------------------------*/
#ifndef threePhaseInterfaceProperties_H
#define threePhaseInterfaceProperties_H
#include "threePhaseMixture.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class threePhaseInterfaceProperties Declaration
\*---------------------------------------------------------------------------*/
class threePhaseInterfaceProperties
{
// Private data
const threePhaseMixture& mixture_;
//- Compression coefficient
scalar cAlpha_;
//- Surface tension 1-2
dimensionedScalar sigma12_;
//- Surface tension 1-3
dimensionedScalar sigma13_;
//- Stabilisation for normalisation of the interface normal
const dimensionedScalar deltaN_;
surfaceScalarField nHatf_;
volScalarField K_;
// Private Member Functions
//- Disallow default bitwise copy construct and assignment
threePhaseInterfaceProperties(const threePhaseInterfaceProperties&);
void operator=(const threePhaseInterfaceProperties&);
//- Correction for the boundary condition on the unit normal nHat on
// walls to produce the correct contact dynamic angle
// calculated from the component of U parallel to the wall
void correctContactAngle
(
surfaceVectorField::GeometricBoundaryField& nHat
) const;
//- Re-calculate the interface curvature
void calculateK();
public:
//- Conversion factor for degrees into radians
static const scalar convertToRad;
// Constructors
//- Construct from volume fraction field alpha and IOdictionary
threePhaseInterfaceProperties(const threePhaseMixture& mixture);
// Member Functions
scalar cAlpha() const
{
return cAlpha_;
}
const dimensionedScalar& deltaN() const
{
return deltaN_;
}
const surfaceScalarField& nHatf() const
{
return nHatf_;
}
const volScalarField& K() const
{
return K_;
}
tmp<volScalarField> sigma() const
{
volScalarField limitedAlpha2 = max(mixture_.alpha2(), scalar(0));
volScalarField limitedAlpha3 = max(mixture_.alpha3(), scalar(0));
return
(limitedAlpha2*sigma12_ + limitedAlpha3*sigma13_)
/(limitedAlpha2 + limitedAlpha3 + SMALL);
}
tmp<volScalarField> sigmaK() const
{
return sigma()*K_;
}
void correct()
{
calculateK();
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -32,6 +32,9 @@ Description
#include "CompactListList.H" #include "CompactListList.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "OStringStream.H"
#include "IStringStream.H"
#include "faceList.H"
using namespace Foam; using namespace Foam;
@ -40,7 +43,29 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
{
// null construct
CompactListList<label> cll1; CompactListList<label> cll1;
Info<< "cll1:" << cll1 << endl;
// Resize and assign row by row
labelList row0(2, 0);
labelList row1(3, 1);
labelList rowSizes(2);
rowSizes[0] = row0.size();
rowSizes[1] = row1.size();
cll1.resize(rowSizes);
cll1[0].assign(row0); //note: operator= will not work since UList
cll1[1].assign(row1);
Info<< "cll1:" << cll1 << endl;
forAll(cll1.m(), i)
{
Info<< "i:" << i << " whichRow:" << cll1.whichRow(i) << endl;
}
}
List<List<label> > lll(5); List<List<label> > lll(5);
lll[0].setSize(3, 0); lll[0].setSize(3, 0);
@ -60,14 +85,21 @@ int main(int argc, char *argv[])
Info<< endl; Info<< endl;
Info<< "cll2(2, 3) = " << cll2(2, 3) << nl << endl;
cll2(2, 3) = 999;
Info<< "cll2(2, 3) = " << cll2(2, 3) << nl << endl; Info<< "cll2(2, 3) = " << cll2(2, 3) << nl << endl;
Info<< "cll2 as List<List<label > > " << List<List<label > >(cll2) << endl; Info<< "cll2 as List<List<label > > " << cll2()
<< endl;
cll2.setSize(3); cll2.setSize(3);
Info<< "cll2 = " << cll2 << endl; Info<< "cll2 = " << cll2 << endl;
cll2.setSize(0);
Info<< "cll2 = " << cll2 << endl;
List<label> rowSizes(5); List<label> rowSizes(5);
rowSizes[0] = 2; rowSizes[0] = 2;
@ -87,6 +119,39 @@ int main(int argc, char *argv[])
Info<< "cll3 = " << cll3 << endl; Info<< "cll3 = " << cll3 << endl;
Info<< "cll4 = " << cll4 << endl; Info<< "cll4 = " << cll4 << endl;
{
// IO
OStringStream ostr;
ostr << cll4;
IStringStream istr(ostr.str());
CompactListList<label> cll5(istr);
Info<< "cll5 = " << cll5 << endl;
}
{
// IO
cll4.clear();
OStringStream ostr;
ostr << cll4;
IStringStream istr(ostr.str());
CompactListList<label> cll5(istr);
Info<< "cll5 = " << cll5 << endl;
}
{
faceList fcs(2);
fcs[0] = face(labelList(1, 111));
fcs[1] = face(labelList(2, 222));
CompactListList<label, face> compactFcs(fcs);
Info<< "comactFcs:" << compactFcs << endl;
faceList fcs2 = compactFcs();
Info<< "fcs2:" << fcs2 << endl;
}
return 0; return 0;
} }

View File

@ -40,6 +40,7 @@ using namespace Foam;
int main() int main()
{ {
HASHTABLE_CLASS<double> table1(13); HASHTABLE_CLASS<double> table1(13);
HASHTABLE_CLASS<double>::iterator iter;
table1.insert("aaa", 1.0); table1.insert("aaa", 1.0);
table1.insert("aba", 2.0); table1.insert("aba", 2.0);
@ -52,8 +53,12 @@ int main()
table1.insert("adx", 9.0); table1.insert("adx", 9.0);
table1.insert("aec", 10.0); table1.insert("aec", 10.0);
// erase by key
table1.erase("aaw"); table1.erase("aaw");
table1.erase("abs");
// erase by iterator
iter = table1.find("abs");
table1.erase(iter);
Info<< "\ntable1 toc: " << table1.toc() << endl; Info<< "\ntable1 toc: " << table1.toc() << endl;
Info<< "\ntable1 sortedToc: " << table1.sortedToc() << endl; Info<< "\ntable1 sortedToc: " << table1.sortedToc() << endl;

View File

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

View File

@ -0,0 +1,2 @@
/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
/* EXE_LIBS = -lfiniteVolume */

View File

@ -0,0 +1,87 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Test speeds for some HashTable operations
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "HashTable.H"
#include "HashPtrTable.H"
#include "Map.H"
#include "StaticHashTable.H"
#include "HashTbl.H"
#include "cpuTime.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
const label nLoops = 30;
const label nBase = 100000;
const label nSize = nLoops * nBase;
cpuTime timer;
// ie, a
// Map<label> map(2 * nSize);
// HashTable<label, label, Hash<label> > map(2 * nSize);
// StaticHashTable<label, label, Hash<label> > map(2 * nSize);
HashTbl<label, label, Hash<label> > map(2 * nSize);
Info<< "Constructed map of size: " << nSize
<< " (size " << map.size() << " capacity " << map.capacity() << ") "
<< " " << timer.cpuTimeIncrement() << " s\n\n";
for (label i = 0; i < nSize; i++)
{
map.insert(i, i);
}
Info<< "Inserted " << nSize << " elements"
<< " (size " << map.size() << " capacity " << map.capacity() << ") "
<< timer.cpuTimeIncrement() << " s\n";
label elemI = 0;
for (label iLoop = 0; iLoop < nLoops; iLoop++)
{
for (label i = 0; i < nBase; i++)
{
map.erase(elemI++);
}
map.shrink();
Info<< "loop " << iLoop << " - Erased " << nBase << " elements"
<< " (size " << map.size() << " capacity " << map.capacity() << ") "
<< timer.cpuTimeIncrement() << " s\n";
}
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,4 @@
globalIndex.C
globalIndexTest.C
EXE = $(FOAM_USER_APPBIN)/globalIndexTest

View File

@ -0,0 +1 @@
EXE_INC = /* -DFULLDEBUG -g -O0 */

View File

@ -0,0 +1,171 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
globalIndexTest
Description
Simple demonstration and test application for the globalIndex class.
\*---------------------------------------------------------------------------*/
#include "globalIndex.H"
#include "argList.H"
#include "Time.H"
#include "polyMesh.H"
#include "IOstreams.H"
#include "OStringStream.H"
#include "IStringStream.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createPolyMesh.H"
// Global numbering of cells (proc0 elements first, then proc1, etc.)
globalIndex globalNumbering(mesh.nCells());
if (globalNumbering.localSize() != mesh.nCells())
{
FatalErrorIn(args.executable())
<< "Problem." << abort(FatalError);
}
if (!Pstream::parRun())
{
WarningIn(args.executable())
<< "globalIndex class is only useful in parallel code."
<< endl;
}
// convert from local to global and back.
for (label cellI = 0; cellI < mesh.nCells(); cellI++)
{
// to global index
label globalCellI = globalNumbering.toGlobal(cellI);
// and back
label procI = globalNumbering.whichProcID(globalCellI);
label localCellI = globalNumbering.toLocal(globalCellI);
if (procI != Pstream::myProcNo() || localCellI != cellI)
{
FatalErrorIn(args.executable())
<< "Problem. cellI:" << cellI << " localCellI:" << localCellI
<< " procI:" << procI << abort(FatalError);
}
if (!globalNumbering.isLocal(globalCellI))
{
FatalErrorIn(args.executable())
<< "Problem. cellI:" << cellI << " globalCellI:" << globalCellI
<< " not local" << abort(FatalError);
}
}
// Try whichProcID on a few borderline cases.
if (mesh.nCells() < 1)
{
FatalErrorIn(args.executable())
<< "Test needs to be run on a case with at least one"
<< " cell per processor." << abort(FatalError);
}
if (Pstream::myProcNo() > 0)
{
// We already checked that toGlobal(0) maps back correctly to myProcNo
// so now check that the index one before maps to the previous processor
label prevProcCellI = globalNumbering.toGlobal(0)-1;
label procI = globalNumbering.whichProcID(prevProcCellI);
if (procI != Pstream::myProcNo()-1)
{
FatalErrorIn(args.executable())
<< "Problem. global:" << prevProcCellI
<< " expected on processor:" << Pstream::myProcNo()-1
<< " but is calculated to be on procI:" << procI
<< abort(FatalError);
}
if (globalNumbering.isLocal(prevProcCellI))
{
FatalErrorIn(args.executable())
<< "Problem. globalCellI:" << prevProcCellI
<< " calculated as local" << abort(FatalError);
}
if (!globalNumbering.isLocal(procI, prevProcCellI))
{
FatalErrorIn(args.executable())
<< "Problem. globalCellI:" << prevProcCellI
<< " not calculated as local on processor:" << procI
<< abort(FatalError);
}
}
if (Pstream::myProcNo() < Pstream::nProcs()-1)
{
label nextProcCellI = globalNumbering.toGlobal(mesh.nCells()-1)+1;
label procI = globalNumbering.whichProcID(nextProcCellI);
if (procI != Pstream::myProcNo()+1)
{
FatalErrorIn(args.executable())
<< "Problem. global:" << nextProcCellI
<< " expected on processor:" << Pstream::myProcNo()+1
<< " but is calculated to be on procI:" << procI
<< abort(FatalError);
}
if (globalNumbering.isLocal(nextProcCellI))
{
FatalErrorIn(args.executable())
<< "Problem. globalCellI:" << nextProcCellI
<< " calculated as local" << abort(FatalError);
}
if (!globalNumbering.isLocal(procI, nextProcCellI))
{
FatalErrorIn(args.executable())
<< "Problem. globalCellI:" << nextProcCellI
<< " not calculated as local on processor:" << procI
<< abort(FatalError);
}
}
return 0;
}
// ************************************************************************* //

View File

@ -283,11 +283,11 @@ void printHelp(Ostream& os)
<< " cellSet c0 list" << endl << " cellSet c0 list" << endl
<< endl << endl
<< "Zones can be set using zoneSets from corresponding sets:" << endl << "Zones can be set using zoneSets from corresponding sets:" << endl
<< " cellZoneSet c0Zone new setToZone c0" << endl << " cellZoneSet c0Zone new setToCellZone c0" << endl
<< " faceZoneSet f0Zone new setToZone f0" << endl << " faceZoneSet f0Zone new setToFaceZone f0" << endl
<< endl << endl
<< "or if orientation is important:" << endl << "or if orientation is important:" << endl
<< " faceZoneSet f0Zone new setsToZone f0 c0" << endl << " faceZoneSet f0Zone new setsToFaceZone f0 c0" << endl
<< endl << endl
<< "ZoneSets can be manipulated using the general actions:" << endl << "ZoneSets can be manipulated using the general actions:" << endl
<< " list - prints the contents of the set" << endl << " list - prints the contents of the set" << endl

View File

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

View File

@ -0,0 +1,6 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-lfiniteVolume

View File

@ -0,0 +1,142 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
singleCellMesh
Description
Removes all but one cells of the mesh. Used to generate mesh and fields
that can be used for boundary-only data.
Might easily result in illegal mesh though so only look at boundaries
in paraview.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "fvMesh.H"
#include "volFields.H"
#include "Time.H"
#include "ReadFields.H"
#include "singleCellFvMesh.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class GeoField>
void interpolateFields
(
const singleCellFvMesh& scMesh,
const PtrList<GeoField>& flds
)
{
forAll(flds, i)
{
tmp<GeoField> scFld = scMesh.interpolate(flds[i]);
GeoField* scFldPtr = scFld.ptr();
scFldPtr->writeOpt() = IOobject::AUTO_WRITE;
scFldPtr->store();
}
}
// Main program:
int main(int argc, char *argv[])
{
Foam::argList::validOptions.insert("overwrite", "");
# include "addTimeOptions.H"
# include "setRootCase.H"
# include "createTime.H"
// Get times list
instantList Times = runTime.times();
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
# include "createMesh.H"
const word oldInstance = mesh.pointsInstance();
bool overwrite = args.optionFound("overwrite");
// Read objects in time directory
IOobjectList objects(mesh, runTime.timeName());
// Read vol fields.
PtrList<volScalarField> vsFlds;
ReadFields(mesh, objects, vsFlds);
PtrList<volVectorField> vvFlds;
ReadFields(mesh, objects, vvFlds);
PtrList<volSphericalTensorField> vstFlds;
ReadFields(mesh, objects, vstFlds);
PtrList<volSymmTensorField> vsymtFlds;
ReadFields(mesh, objects, vsymtFlds);
PtrList<volTensorField> vtFlds;
ReadFields(mesh, objects, vtFlds);
if (!overwrite)
{
runTime++;
}
// Create the mesh
singleCellFvMesh scMesh
(
IOobject
(
mesh.name(),
mesh.polyMesh::instance(),
runTime,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh
);
// Map and store the fields on the scMesh.
interpolateFields(scMesh, vsFlds);
interpolateFields(scMesh, vvFlds);
interpolateFields(scMesh, vstFlds);
interpolateFields(scMesh, vsymtFlds);
interpolateFields(scMesh, vtFlds);
// Write
Info<< "Writing mesh to time " << runTime.timeName() << endl;
scMesh.write();
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -162,11 +162,14 @@ int main(int argc, char *argv[])
// Addressing on faces only in mesh vertices. // Addressing on faces only in mesh vertices.
primitiveFacePatch fPatch primitiveFacePatch fPatch
(
faceList
( (
UIndirectList<face> UIndirectList<face>
( (
mesh.faces(), mesh.faces(),
faces faces
)
), ),
mesh.points() mesh.points()
); );

View File

@ -0,0 +1,6 @@
#!/bin/sh
if [ "$TEC_360_2009" ]
then
wmake
fi

View File

@ -0,0 +1,5 @@
tecplotWriter.C
vtkMesh.C
foamToTecplot360.C
EXE = $(FOAM_APPBIN)/foamToTecplot360

View File

@ -0,0 +1,14 @@
EXE_INC = \
-I$(TEC_360_2009)/include \
/* -I../tecio/tecsrc/lnInclude/ */ \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
$(TEC_360_2009)/lib/tecio64.a \
/* -L$(FOAM_USER_LIBBIN) -ltecio */ \
-llagrangian \
-lfiniteVolume \
-lmeshTools

View File

@ -0,0 +1,87 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "readFields.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class GeoField>
void readFields
(
const vtkMesh& vMesh,
const typename GeoField::Mesh& mesh,
const IOobjectList& objects,
const HashSet<word>& selectedFields,
PtrList<GeoField>& fields
)
{
// Search list of objects for volScalarFields
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
// Construct the vol scalar fields
label nFields = fields.size();
fields.setSize(nFields + fieldObjects.size());
for
(
IOobjectList::iterator iter = fieldObjects.begin();
iter != fieldObjects.end();
++iter
)
{
if (selectedFields.empty() || selectedFields.found(iter()->name()))
{
fields.set
(
nFields,
vMesh.interpolate
(
GeoField
(
*iter(),
mesh
)
)
);
nFields++;
}
}
fields.setSize(nFields);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,71 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
Foam::readFields
Description
SourceFiles
readFields.C
\*---------------------------------------------------------------------------*/
#ifndef readFields_H
#define readFields_H
#include "fvMesh.H"
#include "PtrList.H"
#include "IOobjectList.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Read the fields and optionally subset and put on the pointer list
template<class GeoField>
void readFields
(
const vtkMesh& vMesh,
const typename GeoField::Mesh& mesh,
const IOobjectList& objects,
const HashSet<word>& selectedFields,
PtrList<GeoField>& fields
);
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "readFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,517 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "tecplotWriter.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::tecplotWriter::tecplotWriter(const Time& runTime)
:
runTime_(runTime)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::tecplotWriter::writeInit
(
const word& name,
const string& varNames,
const fileName& fName,
INTEGER4 tecplotFileType
) const
{
Pout<< endl
<< endl
<< "Name:" << name
<< " varNames:" << varNames
<< " to file:" << fName
<< " of type:" << tecplotFileType
<< endl;
INTEGER4 IsDouble = 0; //float
INTEGER4 Debug = 0; //nodebug
if
(
!TECINI112
(
const_cast<char*>(name.c_str()), /* Data Set Title */
const_cast<char*>(varNames.c_str()), /* Variable List */
const_cast<char*>(fName.c_str()), /* File Name */
const_cast<char*>(runTime_.path().c_str()), /* Scratch Directory */
&tecplotFileType,
&Debug,
&IsDouble
)
)
{
// FatalErrorIn("tecplotWriter::writeInit(..) const")
// << "Error in TECINI112." << exit(FatalError);
}
}
void Foam::tecplotWriter::writePolyhedralZone
(
const word& zoneName,
const INTEGER4 strandID,
const fvMesh& mesh,
const List<INTEGER4>& varLocArray,
INTEGER4 nFaceNodes
) const
{
/* Call TECZNE112 */
INTEGER4 NumNodes = mesh.nPoints(); /* number of unique nodes */
INTEGER4 NumElems = mesh.nCells(); /* number of elements */
INTEGER4 NumFaces = mesh.nFaces(); /* number of unique faces */
INTEGER4 ICellMax = 0; /* Not Used, set to zero */
INTEGER4 JCellMax = 0; /* Not Used, set to zero */
INTEGER4 KCellMax = 0; /* Not Used, set to zero */
double SolTime = runTime_.value(); /* solution time */
INTEGER4 StrandID = 1; /* static zone */
INTEGER4 ParentZone = 0; /* no parent zone */
INTEGER4 IsBlock = 1; /* block format */
INTEGER4 NFConns = 0; /* not used for FEPolyhedron
* zones
*/
INTEGER4 FNMode = 0; /* not used for FEPolyhedron
* zones
*/
Pout<< "zoneName:" << zoneName
//<< " varLocArray:" << varLocArray
<< " solTime:" << SolTime
<< endl;
INTEGER4 *PassiveVarArray = NULL;
INTEGER4 *VarShareArray = NULL;
INTEGER4 ShrConn = 0;
INTEGER4 NumBConns = 0; /* No Boundary Connections */
INTEGER4 NumBItems = 0; /* No Boundary Items */
INTEGER4 ZoneType = ZoneType_FEPolyhedron;
if
(
!TECZNE112
(
const_cast<char*>(zoneName.c_str()),
&ZoneType,
&NumNodes,
&NumElems,
&NumFaces,
&ICellMax,
&JCellMax,
&KCellMax,
&SolTime,
&StrandID,
&ParentZone,
&IsBlock,
&NFConns,
&FNMode,
&nFaceNodes,
&NumBConns,
&NumBItems,
PassiveVarArray,
const_cast<INTEGER4*>(varLocArray.begin()),
VarShareArray,
&ShrConn
)
)
{
// FatalErrorIn("tecplotWriter::writePolyhedralZone(..) const")
// << "Error in TECZNE112." << exit(FatalError);
}
}
void Foam::tecplotWriter::writePolygonalZone
(
const word& zoneName,
INTEGER4 strandID,
const indirectPrimitivePatch& pp,
const List<INTEGER4>& varLocArray
) const
{
/* Call TECZNE112 */
INTEGER4 NumNodes = pp.nPoints(); /* number of unique nodes */
INTEGER4 NumElems = pp.size(); /* number of elements */
INTEGER4 NumFaces = pp.nEdges(); /* number of unique faces */
INTEGER4 ICellMax = 0; /* Not Used, set to zero */
INTEGER4 JCellMax = 0; /* Not Used, set to zero */
INTEGER4 KCellMax = 0; /* Not Used, set to zero */
double SolTime = runTime_.value(); /* solution time */
INTEGER4 ParentZone = 0; /* no parent zone */
INTEGER4 IsBlock = 1; /* block format */
INTEGER4 NFConns = 0; /* not used for FEPolyhedron
* zones
*/
INTEGER4 FNMode = 0; /* not used for FEPolyhedron
* zones
*/
INTEGER4 NumFaceNodes = 2*pp.nEdges();
Pout<< "zoneName:" << zoneName
<< " strandID:" << strandID
//<< " varLocArray:" << varLocArray
<< " solTime:" << SolTime
<< endl;
INTEGER4 *PassiveVarArray = NULL;
INTEGER4 *VarShareArray = NULL;
INTEGER4 ShrConn = 0;
INTEGER4 NumBConns = 0; /* No Boundary Connections */
INTEGER4 NumBItems = 0; /* No Boundary Items */
INTEGER4 ZoneType = ZoneType_FEPolygon;
if
(
!TECZNE112
(
const_cast<char*>(zoneName.c_str()),
&ZoneType,
&NumNodes,
&NumElems,
&NumFaces,
&ICellMax,
&JCellMax,
&KCellMax,
&SolTime,
&strandID,
&ParentZone,
&IsBlock,
&NFConns,
&FNMode,
&NumFaceNodes,
&NumBConns,
&NumBItems,
PassiveVarArray,
const_cast<INTEGER4*>(varLocArray.begin()),
VarShareArray,
&ShrConn
)
)
{
// FatalErrorIn("tecplotWriter::writePolygonalZone(..) const")
// << "Error in TECZNE112." << exit(FatalError);
}
}
void Foam::tecplotWriter::writeOrderedZone
(
const word& zoneName,
INTEGER4 strandID,
const label n,
const List<INTEGER4>& varLocArray
) const
{
/* Call TECZNE112 */
INTEGER4 IMax = n; /* number of unique nodes */
INTEGER4 JMax = 1; /* number of elements */
INTEGER4 KMax = 1; /* number of unique faces */
INTEGER4 ICellMax = 0; /* Not Used, set to zero */
INTEGER4 JCellMax = 0; /* Not Used, set to zero */
INTEGER4 KCellMax = 0; /* Not Used, set to zero */
double SolTime = runTime_.value(); /* solution time */
INTEGER4 ParentZone = 0; /* no parent zone */
INTEGER4 IsBlock = 1; /* block format */
INTEGER4 NFConns = 0; /* not used for FEPolyhedron
* zones
*/
INTEGER4 FNMode = 0; /* not used for FEPolyhedron
* zones
*/
INTEGER4 NumFaceNodes = 1;
INTEGER4 NumBConns = 1; /* No Boundary Connections */
INTEGER4 NumBItems = 1; /* No Boundary Items */
Pout<< "zoneName:" << zoneName
<< " strandID:" << strandID
//<< " varLocArray:" << varLocArray
<< " solTime:" << SolTime
<< endl;
INTEGER4 *PassiveVarArray = NULL;
INTEGER4 *VarShareArray = NULL;
INTEGER4 ShrConn = 0;
INTEGER4 ZoneType = ZoneType_Ordered;
if
(
!TECZNE112
(
const_cast<char*>(zoneName.c_str()),
&ZoneType,
&IMax,
&JMax,
&KMax,
&ICellMax,
&JCellMax,
&KCellMax,
&SolTime,
&strandID,
&ParentZone,
&IsBlock,
&NFConns,
&FNMode,
&NumFaceNodes,
&NumBConns,
&NumBItems,
PassiveVarArray,
const_cast<INTEGER4*>(varLocArray.begin()),
VarShareArray,
&ShrConn
)
)
{
// FatalErrorIn("tecplotWriter::writePolygonalZone(..) const")
// << "Error in TECZNE112." << exit(FatalError);
}
}
void Foam::tecplotWriter::writeConnectivity(const fvMesh& mesh) const
{
List<INTEGER4> FaceNodeCounts(mesh.nFaces());
forAll(mesh.faces(), faceI)
{
const face& f = mesh.faces()[faceI];
FaceNodeCounts[faceI] = INTEGER4(f.size());
}
INTEGER4 nFaceNodes = 0;
forAll(mesh.faces(), faceI)
{
nFaceNodes += mesh.faces()[faceI].size();
}
List<INTEGER4> FaceNodes(nFaceNodes);
label nodeI = 0;
forAll(mesh.faces(), faceI)
{
const face& f = mesh.faces()[faceI];
forAll(f, fp)
{
FaceNodes[nodeI++] = INTEGER4(f[fp]+1);
}
}
List<INTEGER4> FaceLeftElems(mesh.nFaces());
forAll(mesh.faceOwner(), faceI)
{
FaceLeftElems[faceI] = mesh.faceOwner()[faceI]+1;
}
List<INTEGER4> FaceRightElems(mesh.nFaces());
forAll(mesh.faceNeighbour(), faceI)
{
FaceRightElems[faceI] = mesh.faceNeighbour()[faceI]+1;
}
for
(
label faceI = mesh.nInternalFaces();
faceI < mesh.nFaces();
faceI++
)
{
FaceRightElems[faceI] = 0;
}
if
(
!TECPOLY112
(
FaceNodeCounts.begin(), /* The face node counts array */
FaceNodes.begin(), /* The face nodes array */
FaceLeftElems.begin(), /* The left elements array */
FaceRightElems.begin(), /* The right elements array */
NULL, /* No boundary connection counts */
NULL, /* No boundary connection elements */
NULL /* No boundary connection zones */
)
)
{
// FatalErrorIn("tecplotWriter::writeConnectivity(const fvMesh&) const")
// << "Error in TECPOLY112." << exit(FatalError);
}
}
void Foam::tecplotWriter::writeConnectivity
(
const indirectPrimitivePatch& pp
) const
{
INTEGER4 NumFaces = pp.nEdges(); /* number of unique faces */
INTEGER4 NumFaceNodes = 2*pp.nEdges();
// All faces (=edges) have 2 nodes
List<INTEGER4> FaceNodeCounts(NumFaces, 2);
List<INTEGER4> FaceNodes(NumFaceNodes);
label nodeI = 0;
forAll(pp.edges(), edgeI)
{
edge e = pp.edges()[edgeI];
if (e[0] > e[1])
{
e = e.reverseEdge();
}
FaceNodes[nodeI++] = INTEGER4(e[0]+1);
FaceNodes[nodeI++] = INTEGER4(e[1]+1);
}
/* Define the right and left elements of each face.
*
* The last step for writing out the polyhedral data is to
* define the right and left neighboring elements for each
* face. The neighboring elements can be determined using the
* right-hand rule. For each face, place your right-hand along
* the face which your fingers pointing the direction of
* incrementing node numbers (i.e. from node 1 to node 2).
* Your right thumb will point towards the right element; the
* element on the other side of your hand is the left element.
*
* The number zero is used to indicate that there isn't an
* element on that side of the face.
*
* Because of the way we numbered the nodes and faces, the
* right element for every face is the element itself
* (element 1) and the left element is "no-neighboring element"
* (element 0).
*/
List<INTEGER4> FaceLeftElems(NumFaces);
List<INTEGER4> FaceRightElems(NumFaces);
const labelListList& edgeFaces = pp.edgeFaces();
forAll(edgeFaces, edgeI)
{
const labelList& eFaces = edgeFaces[edgeI];
if (eFaces.size() == 1)
{
FaceLeftElems[edgeI] = 0;
FaceRightElems[edgeI] = eFaces[0]+1;
}
else if (eFaces.size() == 2)
{
edge e = pp.edges()[edgeI];
if (e[0] > e[1])
{
e = e.reverseEdge();
}
const face& f0 = pp.localFaces()[eFaces[0]];
// The face that uses the vertices of e in increasing order
// is the left face.
label fp = findIndex(f0, e[0]);
bool f0IsLeft = (f0.nextLabel(fp) == e[1]);
if (f0IsLeft)
{
FaceLeftElems[edgeI] = eFaces[0]+1;
FaceRightElems[edgeI] = eFaces[1]+1;
}
else
{
FaceLeftElems[edgeI] = eFaces[1]+1;
FaceRightElems[edgeI] = eFaces[0]+1;
}
}
else
{
// non-manifold. Treat as if open.
FaceLeftElems[edgeI] = 0;
FaceRightElems[edgeI] = eFaces[0]+1;
}
}
/* Write the face map (created above) using TECPOLY112. */
if
(
!TECPOLY112
(
FaceNodeCounts.begin(), /* The face node counts array */
FaceNodes.begin(), /* The face nodes array */
FaceLeftElems.begin(), /* The left elements array */
FaceRightElems.begin(), /* The right elements array */
NULL, /* No boundary connection counts */
NULL, /* No boundary connection elements */
NULL /* No boundary connection zones */
)
)
{
// FatalErrorIn("tecplotWriter::writeConnectivity(..) const")
// << "Error in TECPOLY112." << exit(FatalError);
}
}
void Foam::tecplotWriter::writeEnd() const
{
Pout<< "writeEnd" << endl;
if (!TECEND112())
{
// FatalErrorIn("tecplotWriter::writeEnd() const")
// << "Error in TECEND112." << exit(FatalError);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,179 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::tecplotWriter
Description
Write binary tecplot files using tecio.
SourceFiles
tecplotWriter.C
tecplotWriterTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef tecplotWriter_H
#define tecplotWriter_H
#include "TECIO.h"
#include "Time.H"
#include "indirectPrimitivePatch.H"
#include "volFields.H"
#include "surfaceFields.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class fvMesh;
/*---------------------------------------------------------------------------*\
Class tecplotWriter Declaration
\*---------------------------------------------------------------------------*/
class tecplotWriter
{
const Time& runTime_;
public:
// Constructors
//- Construct from components
tecplotWriter(const Time&);
// Member Functions
void writeInit
(
const word& name,
const string& varNames,
const fileName&,
INTEGER4 tecplotFileType
) const;
//- Write mesh as polyhedral zone
void writePolyhedralZone
(
const word& zoneName,
const INTEGER4 strandID,
const fvMesh& mesh,
const List<INTEGER4>& varLocArray,
INTEGER4 nFaceNodes
) const;
//- Write surface as polygonal zone
void writePolygonalZone
(
const word& zoneName,
const INTEGER4 strandID,
const indirectPrimitivePatch& pp,
const List<INTEGER4>& varLocArray
) const;
//- Write unordered data (or rather 1D ordered)
void writeOrderedZone
(
const word& zoneName,
INTEGER4 strandID,
const label n,
const List<INTEGER4>& varLocArray
) const;
//- Write mesh
void writeConnectivity(const fvMesh& mesh) const;
//- Write surface
void writeConnectivity(const indirectPrimitivePatch& pp) const;
void writeEnd() const;
//- Write generic Field
template<class Type>
void writeField(const Field<Type>& fld) const;
//- Get either fvPatchField or patchInternalField
template<class Type>
tmp<Field<Type> > getPatchField
(
const bool nearCellValue,
const GeometricField<Type, fvPatchField, volMesh>& vfld,
const label patchI
) const;
//- Get mixed field: fvsPatchField for boundary faces and
// internalField for internal faces.
template<class Type>
tmp<Field<Type> > getFaceField
(
const GeometricField<Type, fvsPatchField, surfaceMesh>&,
const labelList& faceLabels
) const;
template<class GeoField>
static wordList getNames(const PtrList<GeoField>&);
template<class Type>
static void getTecplotNames
(
const wordList& names,
const INTEGER4 loc,
string& varNames,
DynamicList<INTEGER4>& varLocation
);
template<class GeoField>
static void getTecplotNames
(
const PtrList<GeoField>& flds,
const INTEGER4 loc,
string& varNames,
DynamicList<INTEGER4>& varLocation
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "tecplotWriterTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,199 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "tecplotWriter.H"
extern "C"
{
#include "MASTER.h"
#include "GLOBAL.h"
}
#include "fvc.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::tecplotWriter::writeField(const Field<Type>& fld) const
{
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
{
scalarField cmptFld(fld.component(cmpt));
// Convert to float
Field<float> floats(cmptFld.size());
forAll(cmptFld, i)
{
floats[i] = float(cmptFld[i]);
}
INTEGER4 size = INTEGER4(floats.size());
INTEGER4 IsDouble = 0; //float
//Pout<< "Writing component:" << cmpt << " of size:" << size
// << " floats." << endl;
if (!TECDAT112(&size, floats.begin(), &IsDouble))
{
// FatalErrorIn("tecplotWriter::writeField(..) const")
// << "Error in TECDAT112." << exit(FatalError);
}
}
}
template<class Type>
Foam::tmp<Field<Type> > Foam::tecplotWriter::getPatchField
(
const bool nearCellValue,
const GeometricField<Type, fvPatchField, volMesh>& vfld,
const label patchI
) const
{
if (nearCellValue)
{
return vfld.boundaryField()[patchI].patchInternalField();
}
else
{
return vfld.boundaryField()[patchI];
}
}
template<class Type>
Foam::tmp<Field<Type> > Foam::tecplotWriter::getFaceField
(
const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld,
const labelList& faceLabels
) const
{
const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh();
tmp<Field<Type> > tfld(new Field<Type>(faceLabels.size()));
Field<Type>& fld = tfld();
forAll(faceLabels, i)
{
label faceI = faceLabels[i];
label patchI = patches.whichPatch(faceI);
if (patchI == -1)
{
fld[i] = sfld[faceI];
}
else
{
label localFaceI = faceI - patches[patchI].start();
fld[i] = sfld.boundaryField()[patchI][localFaceI];
}
}
return tfld;
}
template<class GeoField>
Foam::wordList Foam::tecplotWriter::getNames
(
const PtrList<GeoField>& flds
)
{
wordList names(flds.size());
forAll(flds, i)
{
names[i] = flds[i].name();
}
return names;
}
template<class Type>
void Foam::tecplotWriter::getTecplotNames
(
const wordList& names,
const INTEGER4 loc,
string& varNames,
DynamicList<INTEGER4>& varLocation
)
{
forAll(names, i)
{
if (!varNames.empty())
{
varNames += " ";
}
label nCmpts = pTraits<Type>::nComponents;
if (nCmpts == 1)
{
varNames += names[i];
varLocation.append(loc);
}
else
{
for
(
direction cmpt = 0;
cmpt < nCmpts;
cmpt++
)
{
string fldName =
(cmpt != 0 ? " " : string::null)
+ names[i]
+ "_"
+ pTraits<Type>::componentNames[cmpt];
varNames += fldName;
varLocation.append(loc);
}
}
}
}
template<class GeoField>
void Foam::tecplotWriter::getTecplotNames
(
const PtrList<GeoField>& flds,
const INTEGER4 loc,
string& varNames,
DynamicList<INTEGER4>& varLocation
)
{
getTecplotNames<typename GeoField::value_type>
(
getNames(flds),
loc,
varNames,
varLocation
);
}
// ************************************************************************* //

View File

@ -0,0 +1,84 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "vtkMesh.H"
#include "fvMeshSubset.H"
#include "Time.H"
#include "cellSet.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::vtkMesh::vtkMesh
(
fvMesh& baseMesh,
const word& setName
)
:
baseMesh_(baseMesh),
subsetter_(baseMesh),
setName_(setName)
{
if (setName.size())
{
// Read cellSet using whole mesh
cellSet currentSet(baseMesh_, setName_);
// Set current subset
subsetter_.setLargeCellSubset(currentSet);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate()
{
polyMesh::readUpdateState meshState = baseMesh_.readUpdate();
if (meshState != polyMesh::UNCHANGED)
{
// Note: since fvMeshSubset has no movePoints() functionality reconstruct
// the subset even if only movement.
// topoPtr_.clear();
if (setName_.size())
{
Info<< "Subsetting mesh based on cellSet " << setName_ << endl;
// Read cellSet using whole mesh
cellSet currentSet(baseMesh_, setName_);
subsetter_.setLargeCellSubset(currentSet);
}
}
return meshState;
}
// ************************************************************************* //

View File

@ -0,0 +1,179 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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 "fvMeshSubset.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class Time;
/*---------------------------------------------------------------------------*\
Class vtkMesh Declaration
\*---------------------------------------------------------------------------*/
class vtkMesh
{
// Private data
//- Reference to mesh
fvMesh& baseMesh_;
//- Subsetting engine + sub-fvMesh
fvMeshSubset subsetter_;
//- Current cellSet (or empty)
const word setName_;
// //- Current decomposition of topology
// mutable autoPtr<vtkTopo> topoPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
vtkMesh(const vtkMesh&);
//- Disallow default bitwise assignment
void operator=(const vtkMesh&);
public:
// Constructors
//- Construct from components
vtkMesh(fvMesh& baseMesh, const word& setName = "");
// Member Functions
// Access
//- whole mesh
const fvMesh& baseMesh() const
{
return baseMesh_;
}
const fvMeshSubset& subsetter() const
{
return subsetter_;
}
//- Check if running subMesh
bool useSubMesh() const
{
return setName_.size();
}
// //- topology
// const vtkTopo& topo() const
// {
// if (topoPtr_.empty())
// {
// topoPtr_.reset(new vtkTopo(mesh()));
// }
// return topoPtr_();
// }
//- Access either mesh or submesh
const fvMesh& mesh() const
{
if (useSubMesh())
{
return subsetter_.subMesh();
}
else
{
return baseMesh_;
}
}
// //- Number of field cells
// label nFieldCells() const
// {
// return topo().vertLabels().size();
// }
//
// //- Number of field points
// label nFieldPoints() const
// {
// return mesh().nPoints() + topo().addPointCellLabels().size();
// }
// Edit
//- Read mesh
polyMesh::readUpdateState readUpdate();
//- Map volume field (does in fact do very little interpolation;
// just copied from fvMeshSubset)
template<class GeoField>
tmp<GeoField> interpolate(const GeoField& fld) const
{
if (useSubMesh())
{
tmp<GeoField> subFld = subsetter_.interpolate(fld);
subFld().rename(fld.name());
return subFld;
}
else
{
return fld;
}
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -83,12 +83,13 @@ Usage
Combine all patches into a single file Combine all patches into a single file
@param -excludePatches \<patchNames\>\n @param -excludePatches \<patchNames\>\n
Specify patches to exclude. For example, Specify patches (wildcards) to exclude. For example,
@verbatim @verbatim
-excludePatches "( inlet_1 inlet_2 )" -excludePatches '( inlet_1 inlet_2 "proc.*")'
@endverbatim @endverbatim
The quoting is required to avoid shell expansions and to pass the The quoting is required to avoid shell expansions and to pass the
information as a single argument. information as a single argument. The double quotes denote a regular
expression.
@param -useTimeName \n @param -useTimeName \n
use the time index in the VTK file name instead of the time index use the time index in the VTK file name instead of the time index
@ -140,6 +141,7 @@ Note
#include "faceZoneMesh.H" #include "faceZoneMesh.H"
#include "Cloud.H" #include "Cloud.H"
#include "passiveParticle.H" #include "passiveParticle.H"
#include "stringListOps.H"
#include "vtkMesh.H" #include "vtkMesh.H"
#include "readFields.H" #include "readFields.H"
@ -192,7 +194,7 @@ void print(Ostream& os, const wordList& flds)
labelList getSelectedPatches labelList getSelectedPatches
( (
const polyBoundaryMesh& patches, const polyBoundaryMesh& patches,
const HashSet<word>& excludePatches const List<wordRe>& excludePatches //HashSet<word>& excludePatches
) )
{ {
DynamicList<label> patchIDs(patches.size()); DynamicList<label> patchIDs(patches.size());
@ -205,14 +207,19 @@ labelList getSelectedPatches
if if
( (
isA<emptyPolyPatch>(pp) isType<emptyPolyPatch>(pp)
|| (Pstream::parRun() && isA<processorPolyPatch>(pp)) || (Pstream::parRun() && isType<processorPolyPatch>(pp))
) )
{ {
Info<< " discarding empty/processor patch " << patchI Info<< " discarding empty/processor patch " << patchI
<< " " << pp.name() << endl; << " " << pp.name() << endl;
} }
else if (!excludePatches.found(pp.name())) else if (findStrings(excludePatches, pp.name()))
{
Info<< " excluding patch " << patchI
<< " " << pp.name() << endl;
}
else
{ {
patchIDs.append(patchI); patchIDs.append(patchI);
Info<< " patch " << patchI << " " << pp.name() << endl; Info<< " patch " << patchI << " " << pp.name() << endl;
@ -224,6 +231,8 @@ labelList getSelectedPatches
// Main program: // Main program:
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -283,7 +292,7 @@ int main(int argc, char *argv[])
bool allPatches = args.optionFound("allPatches"); bool allPatches = args.optionFound("allPatches");
HashSet<word> excludePatches; List<wordRe> excludePatches;
if (args.optionFound("excludePatches")) if (args.optionFound("excludePatches"))
{ {
args.optionLookup("excludePatches")() >> excludePatches; args.optionLookup("excludePatches")() >> excludePatches;
@ -771,7 +780,7 @@ int main(int argc, char *argv[])
{ {
const polyPatch& pp = patches[patchI]; const polyPatch& pp = patches[patchI];
if (!excludePatches.found(pp.name())) if (!findStrings(excludePatches, pp.name()))
{ {
mkDir(fvPath/pp.name()); mkDir(fvPath/pp.name());

View File

@ -1,21 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
set -x
if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ]
then
case "$ParaView_VERSION" in
3*)
wmake libso vtkPV3Foam
(
cd PV3FoamReader
mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1
cd Make/$WM_OPTIONS
cmake ../..
make
)
;;
esac
fi
# ----------------------------------------------------------------- end-of-file

View File

@ -0,0 +1,16 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
set -x
if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ]
then
case "$ParaView_VERSION" in
3*)
wmake libso vtkPV3Readers
PV3blockMeshReader/Allwmake
PV3FoamReader/Allwmake
;;
esac
fi
# ----------------------------------------------------------------- end-of-file

View File

@ -2,6 +2,9 @@
cd ${0%/*} || exit 1 # run from this directory cd ${0%/*} || exit 1 # run from this directory
set -x set -x
# deal with client/server vs combined plugins
rm -f $FOAM_LIBBIN/libPV3FoamReader* 2>/dev/null
rm -rf PV3FoamReader/Make rm -rf PV3FoamReader/Make
wclean libso vtkPV3Foam wclean libso vtkPV3Foam

View File

@ -0,0 +1,21 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
set -x
if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ]
then
case "$ParaView_VERSION" in
3*)
wmake libso vtkPV3Foam
(
cd PV3FoamReader
mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1
cd Make/$WM_OPTIONS
cmake ../..
make
)
;;
esac
fi
# ----------------------------------------------------------------- end-of-file

View File

@ -7,7 +7,7 @@
# the pqReader.xml file contains xml defining readers with their # the pqReader.xml file contains xml defining readers with their
# file extensions and descriptions. # file extensions and descriptions.
cmake_minimum_required(VERSION 2.4) CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
FIND_PACKAGE(ParaView REQUIRED) FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE}) INCLUDE(${PARAVIEW_USE_FILE})
@ -33,19 +33,46 @@ SET(
"Single output directory for building all libraries." "Single output directory for building all libraries."
) )
# Build the server-side plugin
#
# Defined combined plugin
#
# Extend the auto-generated panel
QT4_WRAP_CPP(MOC_SRCS pqPV3FoamReaderPanel.h)
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
CLASS_NAME pqPV3FoamReaderPanel
XML_NAME PV3FoamReader # name of SourceProxy in *SM.xml
XML_GROUP sources
)
ADD_PARAVIEW_PLUGIN( ADD_PARAVIEW_PLUGIN(
PV3FoamReader_SM "1.0" PV3FoamReader_SM "1.0"
SERVER_MANAGER_XML PV3FoamReader_SM.xml SERVER_MANAGER_XML PV3FoamReader_SM.xml
SERVER_MANAGER_SOURCES vtkPV3FoamReader.cxx SERVER_MANAGER_SOURCES vtkPV3FoamReader.cxx
GUI_INTERFACES ${IFACES}
GUI_SOURCES pqPV3FoamReaderPanel.cxx
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
GUI_RESOURCE_FILES PV3FoamReader.xml
) )
# Build the client-side plugin # #
ADD_PARAVIEW_PLUGIN( # # Define the server-side portion of the reader plugin
PV3FoamReader # #
"1.0" # ADD_PARAVIEW_PLUGIN(
GUI_RESOURCES PV3FoamReader.qrc # PV3FoamReader_SM "1.0"
) # SERVER_MANAGER_XML PV3FoamReader_SM.xml
# SERVER_MANAGER_SOURCES vtkPV3FoamReader.cxx
# )
# #
# # Define the client-side portion of the reader plugin
# #
# ADD_PARAVIEW_PLUGIN(
# PV3FoamReader "1.0"
# GUI_RESOURCES PV3FoamReader.qrc
# )
#
TARGET_LINK_LIBRARIES( TARGET_LINK_LIBRARIES(
PV3FoamReader_SM PV3FoamReader_SM

View File

@ -16,6 +16,21 @@
</Documentation> </Documentation>
</StringVectorProperty> </StringVectorProperty>
<!-- Cache Mesh check-box -->
<IntVectorProperty
name="UiCacheMesh"
command="SetCacheMesh"
number_of_elements="1"
is_internal="1"
default_values="1"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Cache the fvMesh in memory.
</Documentation>
</IntVectorProperty>
<!-- Send discrete time info to the animation panel --> <!-- Send discrete time info to the animation panel -->
<DoubleVectorProperty <DoubleVectorProperty
name="TimestepValues" name="TimestepValues"
@ -72,10 +87,11 @@
<!-- Show Patch Names check-box --> <!-- Show Patch Names check-box -->
<IntVectorProperty <IntVectorProperty
name="ShowPatchNames" name="UiShowPatchNames"
command="SetShowPatchNames" command="SetShowPatchNames"
number_of_elements="1" number_of_elements="1"
default_values="0" default_values="0"
is_internal="1"
animateable="0"> animateable="0">
<BooleanDomain name="bool"/> <BooleanDomain name="bool"/>
<Documentation> <Documentation>
@ -83,21 +99,7 @@
</Documentation> </Documentation>
</IntVectorProperty> </IntVectorProperty>
<!-- Cache Mesh check-box --> <!-- Force GUI update check box -->
<IntVectorProperty
name="CacheMesh"
command="SetCacheMesh"
number_of_elements="1"
default_values="1"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Cache the fvMesh in memory.
</Documentation>
</IntVectorProperty>
<!-- Update GUI check box -->
<IntVectorProperty <IntVectorProperty
name="UpdateGUI" name="UpdateGUI"
command="SetUpdateGUI" command="SetUpdateGUI"
@ -204,6 +206,14 @@
</RequiredProperties> </RequiredProperties>
</ArraySelectionDomain> </ArraySelectionDomain>
</StringVectorProperty> </StringVectorProperty>
<Hints>
<Property name="FileName" show="0"/>
<Property name="UiCacheMesh" show="0"/>
<Property name="UiShowPatchNames" show="0"/>
</Hints>
</SourceProxy> </SourceProxy>
</ProxyGroup> </ProxyGroup>
</ServerManagerConfiguration> </ServerManagerConfiguration>

View File

@ -0,0 +1,135 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "pqPV3FoamReaderPanel.h"
// QT
#include <QGridLayout>
#include <QCheckBox>
#include <QLabel>
#include <QLayout>
#include <QString>
#include <QtDebug>
// Paraview<->QT UI
#include "pqAnimationScene.h"
#include "pqApplicationCore.h"
#include "pqPipelineRepresentation.h"
#include "pqServerManagerModel.h"
#include "pqView.h"
// Paraview Server Manager
#include "vtkSMDoubleVectorProperty.h"
#include "vtkSMIntVectorProperty.h"
#include "vtkSMProperty.h"
#include "vtkSMSourceProxy.h"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
pqPV3FoamReaderPanel::pqPV3FoamReaderPanel
(
pqProxy *proxy,
QWidget *p
)
:
pqAutoGeneratedObjectPanel(proxy, p),
sourceProxy_(vtkSMSourceProxy::SafeDownCast(this->proxy()))
{
// create first sublayout (at top of the panel)
QGridLayout *sect1 = new QGridLayout();
this->PanelLayout->addLayout(sect1, 0, 0, 1, -1);
// checkbox for caching mesh
CacheMesh_ = new QCheckBox("Cache Mesh");
CacheMesh_->setChecked(true);
// checkbox for caching mesh
ShowPatchNames_ = new QCheckBox("Show Patch Names");
ShowPatchNames_->setChecked(false);
connect
(
CacheMesh_,
SIGNAL(stateChanged(int)),
this,
SLOT(CacheMeshToggled())
);
connect
(
ShowPatchNames_,
SIGNAL(stateChanged(int)),
this,
SLOT(ShowPatchNamesToggled())
);
sect1->addWidget(CacheMesh_);
sect1->addWidget(ShowPatchNames_);
// immediate update on the Server Manager side
vtkSMIntVectorProperty::SafeDownCast
(
sourceProxy_->GetProperty("UiCacheMesh")
)->SetImmediateUpdate(true);
vtkSMIntVectorProperty::SafeDownCast
(
sourceProxy_->GetProperty("UiShowPatchNames")
)->SetImmediateUpdate(true);
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void pqPV3FoamReaderPanel::CacheMeshToggled()
{
vtkSMIntVectorProperty::SafeDownCast
(
sourceProxy_->GetProperty("UiCacheMesh")
)->SetElement(0, CacheMesh_->isChecked());
}
void pqPV3FoamReaderPanel::ShowPatchNamesToggled()
{
vtkSMIntVectorProperty::SafeDownCast
(
sourceProxy_->GetProperty("UiShowPatchNames")
)->SetElement(0, ShowPatchNames_->isChecked());
// update the active view
if (this->view())
{
this->view()->render();
}
// OR: update all views
// pqApplicationCore::instance()->render();
}
// ************************************************************************* //

View File

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
pqPV3FoamReaderPanel
Description
GUI modifications for the ParaView reader panel
A custom panel for the PV3FoamReader.
SourceFiles
pqPV3FoamReaderPanel.cxx
\*---------------------------------------------------------------------------*/
#ifndef pqPV3FoamReaderPanel_h
#define pqPV3FoamReaderPanel_h
#include "pqAutoGeneratedObjectPanel.h"
// Forward declaration of QT classes
class QCheckBox;
class QLineEdit;
class QTimer;
class QToolButton;
// Forward declaration of ParaView classes
class vtkSMSourceProxy;
/*---------------------------------------------------------------------------*\
Class pqPV3FoamReaderPanel Declaration
\*---------------------------------------------------------------------------*/
class pqPV3FoamReaderPanel
:
public pqAutoGeneratedObjectPanel
{
// Private data
Q_OBJECT;
typedef pqAutoGeneratedObjectPanel Superclass;
//- Server Manager Source Proxy
vtkSMSourceProxy* sourceProxy_;
//- CacheMesh checkbox
QCheckBox* CacheMesh_;
//- Show Patch Names checkbox
QCheckBox* ShowPatchNames_;
protected slots:
void CacheMeshToggled();
void ShowPatchNamesToggled();
public:
// Constructors
//- Construct from components
pqPV3FoamReaderPanel(pqProxy*, QWidget*);
//- Destructor
// virtual ~pqPV3FoamReaderPanel();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,18 +1,28 @@
/*========================================================================= /*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
Program: Visualization Toolkit OpenFOAM is free software; you can redistribute it and/or modify it
Module: $RCSfile: vtkPV3FoamReader.cxx,v $ under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
All rights reserved. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
See Copyright.txt or http://www.kitware.com/Copyright.htm for details. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
This software is distributed WITHOUT ANY WARRANTY; without even You should have received a copy of the GNU General Public License
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR along with OpenFOAM; if not, write to the Free Software Foundation,
PURPOSE. See the above copyright notice for more information. Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=========================================================================*/
\*---------------------------------------------------------------------------*/
#include "vtkPV3FoamReader.h" #include "vtkPV3FoamReader.h"
#include "pqApplicationCore.h" #include "pqApplicationCore.h"
@ -33,10 +43,15 @@
// Foam includes // Foam includes
#include "vtkPV3Foam.H" #include "vtkPV3Foam.H"
#undef EXPERIMENTAL_TIME_CACHING
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
vtkCxxRevisionMacro(vtkPV3FoamReader, "$Revision: 1.5$"); vtkCxxRevisionMacro(vtkPV3FoamReader, "$Revision: 1.5$");
vtkStandardNewMacro(vtkPV3FoamReader); vtkStandardNewMacro(vtkPV3FoamReader);
#undef EXPERIMENTAL_TIME_CACHING
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
vtkPV3FoamReader::vtkPV3FoamReader() vtkPV3FoamReader::vtkPV3FoamReader()
{ {
@ -109,11 +124,18 @@ vtkPV3FoamReader::vtkPV3FoamReader()
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
vtkPV3FoamReader::~vtkPV3FoamReader() vtkPV3FoamReader::~vtkPV3FoamReader()
{ {
vtkDebugMacro(<<"Deconstructor"); vtkDebugMacro(<<"Deconstructor");
if (foamData_)
{
// remove patch names
updatePatchNamesView(false);
delete foamData_; delete foamData_;
}
if (FileName) if (FileName)
{ {
@ -140,6 +162,8 @@ vtkPV3FoamReader::~vtkPV3FoamReader()
} }
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
// Do everything except set the output info // Do everything except set the output info
int vtkPV3FoamReader::RequestInformation int vtkPV3FoamReader::RequestInformation
( (
@ -396,13 +420,35 @@ int vtkPV3FoamReader::RequestData
} }
void vtkPV3FoamReader::SetShowPatchNames(const int val)
{
if (ShowPatchNames != val)
{
ShowPatchNames = val;
updatePatchNamesView(ShowPatchNames);
}
}
void vtkPV3FoamReader::updatePatchNamesView(const bool show) void vtkPV3FoamReader::updatePatchNamesView(const bool show)
{ {
pqApplicationCore* appCore = pqApplicationCore::instance(); pqApplicationCore* appCore = pqApplicationCore::instance();
// need to check this, since our destructor calls this
if (!appCore)
{
return;
}
// Server manager model for querying items in the server manager // Server manager model for querying items in the server manager
pqServerManagerModel* smModel = appCore->getServerManagerModel(); pqServerManagerModel* smModel = appCore->getServerManagerModel();
if (!smModel || !foamData_)
{
return;
}
// Get all the pqRenderView instances // Get all the pqRenderView instances
QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>(); QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>();
@ -414,6 +460,8 @@ void vtkPV3FoamReader::updatePatchNamesView(const bool show)
show show
); );
} }
// use refresh here?
} }

View File

@ -1,25 +1,52 @@
/*========================================================================= /*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
Program: Visualization Toolkit OpenFOAM is free software; you can redistribute it and/or modify it
Module: $RCSfile: vtkPV3FoamReader.h,v $ under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
All rights reserved. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
See Copyright.txt or http://www.kitware.com/Copyright.htm for details. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
This software is distributed WITHOUT ANY WARRANTY; without even You should have received a copy of the GNU General Public License
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR along with OpenFOAM; if not, write to the Free Software Foundation,
PURPOSE. See the above copyright notice for more information. Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=========================================================================*/ Class
// .NAME vtkPV3FoamReader - reads a dataset in OpenFOAM format vtkPV3FoamReader
// .SECTION Description
// vtkPV3FoamReader creates an multiblock dataset.
// It uses the OpenFOAM infrastructure (fvMesh, etc) to
// handle mesh and field data.
#ifndef __vtkPV3FoamReader_h Description
#define __vtkPV3FoamReader_h reads a dataset in OpenFOAM format
vtkPV3blockMeshReader creates an multiblock dataset.
It uses the OpenFOAM infrastructure (fvMesh, etc) to handle mesh and
field data.
SourceFiles
vtkPV3blockMeshReader.cxx
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamReader_h
#define vtkPV3FoamReader_h
// VTK includes
#include "vtkMultiBlockDataSetAlgorithm.h"
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
// VTK forward declarations
class vtkDataArraySelection;
class vtkCallbackCommand;
// Foam forward declarations // Foam forward declarations
namespace Foam namespace Foam
@ -27,13 +54,10 @@ namespace Foam
class vtkPV3Foam; class vtkPV3Foam;
} }
// VTK includes
#include "vtkMultiBlockDataSetAlgorithm.h"
// VTK forward declarations
class vtkDataArraySelection;
class vtkCallbackCommand;
/*---------------------------------------------------------------------------*\
Class vtkPV3FoamReader Declaration
\*---------------------------------------------------------------------------*/
class VTK_IO_EXPORT vtkPV3FoamReader class VTK_IO_EXPORT vtkPV3FoamReader
: :
@ -54,16 +78,16 @@ public:
vtkSetStringMacro(FileName); vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName); vtkGetStringMacro(FileName);
// Description:
// GUI update control
vtkSetMacro(UpdateGUI, int);
vtkGetMacro(UpdateGUI, int);
// Description: // Description:
// FOAM mesh caching control // FOAM mesh caching control
vtkSetMacro(CacheMesh, int); vtkSetMacro(CacheMesh, int);
vtkGetMacro(CacheMesh, int); vtkGetMacro(CacheMesh, int);
// Description:
// GUI update control
vtkSetMacro(UpdateGUI, int);
vtkGetMacro(UpdateGUI, int);
// Description: // Description:
// FOAM extrapolate internal values onto the patches // FOAM extrapolate internal values onto the patches
vtkSetMacro(ExtrapolatePatches, int); vtkSetMacro(ExtrapolatePatches, int);
@ -80,7 +104,7 @@ public:
// Description: // Description:
// FOAM display patch names control // FOAM display patch names control
vtkSetMacro(ShowPatchNames, int); virtual void SetShowPatchNames(int);
vtkGetMacro(ShowPatchNames, int); vtkGetMacro(ShowPatchNames, int);
// Description: // Description:

View File

@ -1,18 +1,20 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(ParaView_DIR)/VTK \ -I$(ParaView_DIR)/VTK \
-I$(ParaView_INST_DIR) \ -I$(ParaView_INST_DIR) \
-I$(ParaView_INST_DIR)/VTK \ -I$(ParaView_INST_DIR)/VTK \
-I$(ParaView_INST_DIR)/VTK/Common \ -I$(ParaView_INST_DIR)/VTK/Common \
-I$(ParaView_INST_DIR)/VTK/Filtering \ -I$(ParaView_INST_DIR)/VTK/Filtering \
-I$(ParaView_INST_DIR)/VTK/Rendering \ -I$(ParaView_INST_DIR)/VTK/Rendering \
-I../../vtkPV3Readers/lnInclude \
-I../PV3FoamReader -I../PV3FoamReader
LIB_LIBS = \ LIB_LIBS = \
-lvtkPV3Readers \
-lmeshTools \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields \ -lgenericPatchFields \
-llagrangian \ -llagrangian \
-lmeshTools \
$(GLIBS) $(GLIBS)

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