Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
andy
2013-08-14 15:55:06 +01:00
40 changed files with 527 additions and 223 deletions

View File

@ -101,7 +101,7 @@ int main(int argc, char *argv[])
while (pimple.loop()) while (pimple.loop())
{ {
#include "rhoEqn.H" #include "rhoEqn.H"
#include "gammaPsi.H" #include "alphavPsi.H"
#include "UEqn.H" #include "UEqn.H"
// --- Pressure corrector loop // --- Pressure corrector loop

View File

@ -4,8 +4,8 @@
p = p =
( (
rho rho
- gamma2*rhol0 - alphal*rhol0
- ((gamma*psiv + gamma2*psil) - psi)*pSat - ((alphav*psiv + alphal*psil) - psi)*pSat
)/psi; )/psi;
} }
@ -52,13 +52,13 @@
rho == max(rho0 + psi*p, rhoMin); rho == max(rho0 + psi*p, rhoMin);
#include "gammaPsi.H" #include "alphavPsi.H"
p = p =
( (
rho rho
- gamma2*rhol0 - alphal*rhol0
- ((gamma*psiv + gamma2*psil) - psi)*pSat - ((alphav*psiv + alphal*psil) - psi)*pSat
)/psi; )/psi;
p.correctBoundaryConditions(); p.correctBoundaryConditions();

View File

@ -12,53 +12,6 @@
mesh 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; Info<< "Reading field U\n" << endl;
volVectorField U volVectorField U
( (
@ -77,6 +30,10 @@
threePhaseMixture threePhaseProperties(U, phi); threePhaseMixture threePhaseProperties(U, phi);
volScalarField& alpha1(threePhaseProperties.alpha1());
volScalarField& alpha2(threePhaseProperties.alpha2());
volScalarField& alpha3(threePhaseProperties.alpha3());
const dimensionedScalar& rho1 = threePhaseProperties.rho1(); const dimensionedScalar& rho1 = threePhaseProperties.rho1();
const dimensionedScalar& rho2 = threePhaseProperties.rho2(); const dimensionedScalar& rho2 = threePhaseProperties.rho2();
const dimensionedScalar& rho3 = threePhaseProperties.rho3(); const dimensionedScalar& rho3 = threePhaseProperties.rho3();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -62,9 +62,64 @@ Foam::threePhaseMixture::threePhaseMixture
) )
), ),
phase1Name_("phase1"), phase1Name_(wordList(lookup("phases"))[0]),
phase2Name_("phase2"), phase2Name_(wordList(lookup("phases"))[1]),
phase3Name_("phase3"), phase3Name_(wordList(lookup("phases"))[2]),
alpha1_
(
IOobject
(
IOobject::groupName("alpha", phase1Name_),
U.time().timeName(),
U.mesh(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
U.mesh()
),
alpha2_
(
IOobject
(
IOobject::groupName("alpha", phase2Name_),
U.time().timeName(),
U.mesh(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
U.mesh()
),
alpha3_
(
IOobject
(
IOobject::groupName("alpha", phase3Name_),
U.time().timeName(),
U.mesh(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
U.mesh()
),
U_(U),
phi_(phi),
nu_
(
IOobject
(
"nu",
U.time().timeName(),
U.db()
),
U.mesh(),
dimensionedScalar("nu", dimensionSet(0, 2, -1, 0, 0), 0),
calculatedFvPatchScalarField::typeName
),
nuModel1_ nuModel1_
( (
@ -99,28 +154,9 @@ Foam::threePhaseMixture::threePhaseMixture
rho1_(nuModel1_->viscosityProperties().lookup("rho")), rho1_(nuModel1_->viscosityProperties().lookup("rho")),
rho2_(nuModel2_->viscosityProperties().lookup("rho")), rho2_(nuModel2_->viscosityProperties().lookup("rho")),
rho3_(nuModel3_->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
)
{ {
alpha3_ == 1.0 - alpha1_ - alpha2_;
calcNu(); calcNu();
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -60,6 +60,15 @@ class threePhaseMixture
word phase2Name_; word phase2Name_;
word phase3Name_; word phase3Name_;
volScalarField alpha1_;
volScalarField alpha2_;
volScalarField alpha3_;
const volVectorField& U_;
const surfaceScalarField& phi_;
volScalarField nu_;
autoPtr<viscosityModel> nuModel1_; autoPtr<viscosityModel> nuModel1_;
autoPtr<viscosityModel> nuModel2_; autoPtr<viscosityModel> nuModel2_;
autoPtr<viscosityModel> nuModel3_; autoPtr<viscosityModel> nuModel3_;
@ -68,15 +77,6 @@ class threePhaseMixture
dimensionedScalar rho2_; dimensionedScalar rho2_;
dimensionedScalar rho3_; dimensionedScalar rho3_;
const volVectorField& U_;
const surfaceScalarField& phi_;
const volScalarField& alpha1_;
const volScalarField& alpha2_;
const volScalarField& alpha3_;
volScalarField nu_;
// Private Member Functions // Private Member Functions
@ -103,22 +103,49 @@ public:
// Member Functions // Member Functions
//- Return const-access to phase1 viscosityModel const word phase1Name() const
const viscosityModel& nuModel1() const
{ {
return nuModel1_(); return phase1Name_;
} }
//- Return const-access to phase2 viscosityModel const word phase2Name() const
const viscosityModel& nuModel2() const
{ {
return nuModel2_(); return phase2Name_;
} }
//- Return const-access to phase3 viscosityModel const word phase3Name() const
const viscosityModel& nuModel3() const
{ {
return nuModel3_(); return phase3Name_;
}
const volScalarField& alpha1() const
{
return alpha1_;
}
volScalarField& alpha1()
{
return alpha1_;
}
const volScalarField& alpha2() const
{
return alpha2_;
}
volScalarField& alpha2()
{
return alpha2_;
}
const volScalarField& alpha3() const
{
return alpha3_;
}
volScalarField& alpha3()
{
return alpha3_;
} }
//- Return const-access to phase1 density //- Return const-access to phase1 density
@ -139,21 +166,6 @@ public:
return rho3_; return rho3_;
}; };
const volScalarField& alpha1() const
{
return alpha1_;
}
const volScalarField& alpha2() const
{
return alpha2_;
}
const volScalarField& alpha3() const
{
return alpha3_;
}
//- Return the velocity //- Return the velocity
const volVectorField& U() const const volVectorField& U() const
{ {
@ -166,6 +178,24 @@ public:
return phi_; return phi_;
} }
//- 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 the dynamic laminar viscosity //- Return the dynamic laminar viscosity
tmp<volScalarField> mu() const; tmp<volScalarField> mu() const;

View File

@ -2,11 +2,13 @@ EXE_INC = \
/* -DFULLDEBUG -g -O0 */ \ /* -DFULLDEBUG -g -O0 */ \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude -I$(LIB_SRC)/lagrangian/basic/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools \ -lmeshTools \
-lsampling \
-lgenericPatchFields \ -lgenericPatchFields \
-llagrangian -llagrangian

View File

@ -33,6 +33,7 @@ License
#include "ensightBinaryStream.H" #include "ensightBinaryStream.H"
#include "ensightAsciiStream.H" #include "ensightAsciiStream.H"
#include "globalIndex.H" #include "globalIndex.H"
#include "ensightPTraits.H"
using namespace Foam; using namespace Foam;
@ -198,7 +199,7 @@ void writePatchField
ensightCaseFile.setf(ios_base::left); ensightCaseFile.setf(ios_base::left);
ensightCaseFile ensightCaseFile
<< pTraits<Type>::typeName << ensightPTraits<Type>::typeName
<< " per element: 1 " << " per element: 1 "
<< setw(15) << pfName << setw(15) << pfName
<< (' ' + prepend + "****." + pfName).c_str() << (' ' + prepend + "****." + pfName).c_str()
@ -230,7 +231,7 @@ void writePatchField
if (Pstream::master()) if (Pstream::master())
{ {
ensightFile.write(pTraits<Type>::typeName); ensightFile.write(ensightPTraits<Type>::typeName);
} }
if (patchi >= 0) if (patchi >= 0)
@ -341,14 +342,14 @@ void ensightField
ensightCaseFile.setf(ios_base::left); ensightCaseFile.setf(ios_base::left);
ensightCaseFile ensightCaseFile
<< pTraits<Type>::typeName << ensightPTraits<Type>::typeName
<< " per element: 1 " << " per element: 1 "
<< setw(15) << vf.name() << setw(15) << vf.name()
<< (' ' + prepend + "****." + vf.name()).c_str() << (' ' + prepend + "****." + vf.name()).c_str()
<< nl; << nl;
} }
ensightFile.write(pTraits<Type>::typeName); ensightFile.write(ensightPTraits<Type>::typeName);
ensightFile.writePartHeader(1); ensightFile.writePartHeader(1);
} }
@ -555,14 +556,14 @@ void ensightPointField
ensightCaseFile.setf(ios_base::left); ensightCaseFile.setf(ios_base::left);
ensightCaseFile ensightCaseFile
<< pTraits<Type>::typeName << ensightPTraits<Type>::typeName
<< " per node: 1 " << " per node: 1 "
<< setw(15) << pf.name() << setw(15) << pf.name()
<< (' ' + prepend + "****." + pf.name()).c_str() << (' ' + prepend + "****." + pf.name()).c_str()
<< nl; << nl;
} }
ensightFile.write(pTraits<Type>::typeName); ensightFile.write(ensightPTraits<Type>::typeName);
ensightFile.writePartHeader(1); ensightFile.writePartHeader(1);
} }

View File

@ -112,7 +112,7 @@ void fieldInterpolator::interpolate()
{ {
instant timej = instant(ti_.value() + (j + 1)*deltaT); instant timej = instant(ti_.value() + (j + 1)*deltaT);
runTime_.setTime(timej.name(), 0); runTime_.setTime(instant(timej.name()), 0);
Info<< timej.name(); Info<< timej.name();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -296,7 +296,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
buf[nChar++] = c; buf[nChar++] = c;
// get everything that could resemble a number and let // get everything that could resemble a number and let
// strtod() determine the validity // readScalar determine the validity
while while
( (
is_.get(c) is_.get(c)
@ -348,24 +348,25 @@ Foam::Istream& Foam::ISstream::read(token& t)
} }
else else
{ {
char *endptr = NULL;
if (asLabel) if (asLabel)
{ {
long longVal(strtol(buf, &endptr, 10)); label labelVal;
t = label(longVal); if (readLabel(buf, labelVal))
// return as a scalar if doesn't fit in a label
if (*endptr || t.labelToken() != longVal)
{ {
t = scalar(strtod(buf, &endptr)); t = labelVal;
} }
} else
else {
{ // Maybe too big? Try as scalar
scalar scalarVal(strtod(buf, &endptr)); scalar scalarVal;
t = scalarVal; if (readScalar(buf, scalarVal))
{
t = scalarVal;
}
else
{
t.setBad();
}
// --------------------------------------- // ---------------------------------------
// this would also be possible if desired: // this would also be possible if desired:
// --------------------------------------- // ---------------------------------------
@ -380,12 +381,20 @@ Foam::Istream& Foam::ISstream::read(token& t)
// t = labelVal; // t = labelVal;
// } // }
// } // }
}
// not everything converted: bad format or trailing junk }
if (*endptr) }
else
{ {
t.setBad(); scalar scalarVal;
if (readScalar(buf, scalarVal))
{
t = scalarVal;
}
else
{
t.setBad();
}
} }
} }
} }

View File

@ -170,7 +170,7 @@ Foam::polyMesh::polyMesh(const IOobject& io)
IOobject IOobject
( (
"owner", "owner",
time().findInstance(meshDir(), "faces"), faces_.instance(),
meshSubDir, meshSubDir,
*this, *this,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
@ -182,7 +182,7 @@ Foam::polyMesh::polyMesh(const IOobject& io)
IOobject IOobject
( (
"neighbour", "neighbour",
time().findInstance(meshDir(), "faces"), faces_.instance(),
meshSubDir, meshSubDir,
*this, *this,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -58,6 +58,14 @@ static const doubleScalar doubleScalarSMALL = 1.0e-15;
static const doubleScalar doubleScalarVSMALL = 1.0e-300; static const doubleScalar doubleScalarVSMALL = 1.0e-300;
static const doubleScalar doubleScalarROOTVSMALL = 1.0e-150; static const doubleScalar doubleScalarROOTVSMALL = 1.0e-150;
//- Read whole of buf as a scalar. Return true if succesful.
inline bool readScalar(const char* buf, doubleScalar& s)
{
char* endPtr;
s = strtod(buf, &endPtr);
return (*endPtr == '\0');
}
#define Scalar doubleScalar #define Scalar doubleScalar
#define ScalarVGREAT doubleScalarVGREAT #define ScalarVGREAT doubleScalarVGREAT

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -58,6 +58,14 @@ static const floatScalar floatScalarSMALL = 1.0e-6;
static const floatScalar floatScalarVSMALL = 1.0e-37; static const floatScalar floatScalarVSMALL = 1.0e-37;
static const floatScalar floatScalarROOTVSMALL = 1.0e-18; static const floatScalar floatScalarROOTVSMALL = 1.0e-18;
//- Read whole of buf as a scalar. Return true if succesful.
inline bool readScalar(const char* buf, floatScalar& s)
{
char* endPtr;
s = strtof(buf, &endPtr);
return (*endPtr == '\0');
}
#define Scalar floatScalar #define Scalar floatScalar
#define ScalarVGREAT floatScalarVGREAT #define ScalarVGREAT floatScalarVGREAT

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -54,6 +54,7 @@ word name(const int);
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
int readInt(Istream&); int readInt(Istream&);
bool readInt(const char*, int&);
Istream& operator>>(Istream&, int&); Istream& operator>>(Istream&, int&);
Ostream& operator<<(Ostream&, const int); Ostream& operator<<(Ostream&, const int);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -88,6 +88,15 @@ int Foam::readInt(Istream& is)
} }
bool Foam::readInt(const char* buf, int& s)
{
char *endptr = NULL;
long l = strtol(buf, &endptr, 10);
s = int(l);
return (*endptr == 0);
}
Foam::Ostream& Foam::operator<<(Ostream& os, const int i) Foam::Ostream& Foam::operator<<(Ostream& os, const int i)
{ {
os.write(label(i)); os.write(label(i));

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -72,6 +72,11 @@ namespace Foam
return readInt(is); return readInt(is);
} }
inline bool readLabel(const char* buf, label& s)
{
return readInt(buf, s);
}
} // End namespace Foam } // End namespace Foam
@ -96,6 +101,11 @@ namespace Foam
return readLong(is); return readLong(is);
} }
inline bool readLabel(const char* buf, label& s)
{
return readLong(buf, s);
}
} // End namespace Foam } // End namespace Foam
@ -122,6 +132,11 @@ namespace Foam
return readLongLong(is); return readLongLong(is);
} }
inline bool readLabel(const char* buf, label& s)
{
return readLongLong(buf, s);
}
} // End namespace Foam } // End namespace Foam
#endif #endif

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -53,6 +53,7 @@ word name(const long);
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
long readLong(Istream&); long readLong(Istream&);
bool readLong(const char*, long&);
Istream& operator>>(Istream&, long&); Istream& operator>>(Istream&, long&);
Ostream& operator<<(Ostream&, const long); Ostream& operator<<(Ostream&, const long);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -85,6 +85,13 @@ long Foam::readLong(Istream& is)
return val; return val;
} }
bool Foam::readLong(const char* buf, long& s)
{
char *endptr = NULL;
s = strtol(buf, &endptr, 10);
return (*endptr == 0);
}
Foam::Ostream& Foam::operator<<(Ostream& os, const long l) Foam::Ostream& Foam::operator<<(Ostream& os, const long l)
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -53,6 +53,7 @@ word name(long long);
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
long long readLongLong(Istream&); long long readLongLong(Istream&);
bool readLongLong(const char*, long long&);
Istream& operator>>(Istream&, long long&); Istream& operator>>(Istream&, long long&);
Ostream& operator<<(Ostream&, const long long); Ostream& operator<<(Ostream&, const long long);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -87,6 +87,14 @@ long long Foam::readLongLong(Istream& is)
} }
bool Foam::readLongLong(const char* buf, long long& s)
{
char *endptr = NULL;
s = strtoll(buf, &endptr, 10);
return (*endptr == 0);
}
Foam::Ostream& Foam::operator<<(Ostream& os, const long long l) Foam::Ostream& Foam::operator<<(Ostream& os, const long long l)
{ {
long long val = l; long long val = l;

View File

@ -1152,7 +1152,12 @@ Foam::mappedPatchBase::mappedPatchBase
samplePatch_(mpb.samplePatch_), samplePatch_(mpb.samplePatch_),
offsetMode_(mpb.offsetMode_), offsetMode_(mpb.offsetMode_),
offset_(mpb.offset_), offset_(mpb.offset_),
offsets_(mpb.offsets_, mapAddressing), offsets_
(
offsetMode_ == NONUNIFORM
? vectorField(mpb.offsets_, mapAddressing)
: vectorField(0)
),
distance_(mpb.distance_), distance_(mpb.distance_),
sameRegion_(mpb.sameRegion_), sameRegion_(mpb.sameRegion_),
mapPtr_(NULL), mapPtr_(NULL),

View File

@ -376,7 +376,7 @@ void Foam::searchableSurfaceCollection::boundingSpheres
forAll(subCentres, i) forAll(subCentres, i)
{ {
centres[coordI++] = transform_[surfI].globalPosition centres[coordI] = transform_[surfI].globalPosition
( (
cmptMultiply cmptMultiply
( (
@ -384,7 +384,8 @@ void Foam::searchableSurfaceCollection::boundingSpheres
scale_[surfI] scale_[surfI]
) )
); );
radiusSqr[coordI++] = maxScale*subRadiusSqr[i]; radiusSqr[coordI] = maxScale*subRadiusSqr[i];
coordI++;
} }
} }
} }

View File

@ -261,16 +261,16 @@ public:
// bounding boxes. The bounds are hints to the surface as for // bounding boxes. The bounds are hints to the surface as for
// the range of queries it can expect. faceMap/pointMap can be // the range of queries it can expect. faceMap/pointMap can be
// set if the surface has done any redistribution. // set if the surface has done any redistribution.
virtual void distribute //virtual void distribute
( //(
const List<treeBoundBox>& bbs, // const List<treeBoundBox>& bbs,
const bool keepNonLocal, // const bool keepNonLocal,
autoPtr<mapDistribute>& faceMap, // autoPtr<mapDistribute>& faceMap,
autoPtr<mapDistribute>& pointMap // autoPtr<mapDistribute>& pointMap
) //)
{ //{
subGeom_[0].distribute(bbs, keepNonLocal, faceMap, pointMap); // subGeom_[0].distribute(bbs, keepNonLocal, faceMap, pointMap);
} //}
//- WIP. Store element-wise field. //- WIP. Store element-wise field.
virtual void setField(const labelList& values) virtual void setField(const labelList& values)

View File

@ -43,6 +43,7 @@ surfWriters = sampledSurface/writers
$(surfWriters)/surfaceWriter.C $(surfWriters)/surfaceWriter.C
$(surfWriters)/dx/dxSurfaceWriter.C $(surfWriters)/dx/dxSurfaceWriter.C
$(surfWriters)/ensight/ensightSurfaceWriter.C $(surfWriters)/ensight/ensightSurfaceWriter.C
$(surfWriters)/ensight/ensightPTraits.C
$(surfWriters)/foamFile/foamFileSurfaceWriter.C $(surfWriters)/foamFile/foamFileSurfaceWriter.C
$(surfWriters)/nastran/nastranSurfaceWriter.C $(surfWriters)/nastran/nastranSurfaceWriter.C
$(surfWriters)/proxy/proxySurfaceWriter.C $(surfWriters)/proxy/proxySurfaceWriter.C

View File

@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "ensightPTraits.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* const Foam::ensightPTraits<Foam::scalar>::typeName =
Foam::pTraits<Foam::scalar>::typeName;
const char* const Foam::ensightPTraits<Foam::vector>::typeName =
Foam::pTraits<Foam::vector>::typeName;
const char* const Foam::ensightPTraits<Foam::sphericalTensor>::typeName =
Foam::pTraits<Foam::scalar>::typeName;
const char* const Foam::ensightPTraits<Foam::symmTensor>::typeName =
"tensor symm";
const char* const Foam::ensightPTraits<Foam::tensor>::typeName =
Foam::pTraits<Foam::tensor>::typeName;
// ************************************************************************* //

View File

@ -0,0 +1,108 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::ensightPTraits
Description
Conversion of OpenFOAM pTraits into the Ensight equivalent
\*---------------------------------------------------------------------------*/
#ifndef ensightPTraits_H
#define ensightPTraits_H
#include "pTraits.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class ensightPTraits Declaration
\*---------------------------------------------------------------------------*/
template<class PrimitiveType>
class ensightPTraits
{
public:
// Static data members
static const char* const typeName;
};
template<>
class ensightPTraits<scalar>
{
public:
static const char* const typeName;
};
template<>
class ensightPTraits<vector>
{
public:
static const char* const typeName;
};
template<>
class ensightPTraits<sphericalTensor>
{
public:
static const char* const typeName;
};
template<>
class ensightPTraits<symmTensor>
{
public:
static const char* const typeName;
};
template<>
class ensightPTraits<tensor>
{
public:
static const char* const typeName;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,6 +29,7 @@ License
#include "OSspecific.H" #include "OSspecific.H"
#include "IOmanip.H" #include "IOmanip.H"
#include "ensightPartFaces.H" #include "ensightPartFaces.H"
#include "ensightPTraits.H"
#include "makeSurfaceWriterMethods.H" #include "makeSurfaceWriterMethods.H"
@ -89,7 +90,7 @@ void Foam::ensightSurfaceWriter::writeTemplate
<< "model: 1 " << osGeom.name().name() << nl << "model: 1 " << osGeom.name().name() << nl
<< nl << nl
<< "VARIABLE" << nl << "VARIABLE" << nl
<< pTraits<Type>::typeName << " per " << ensightPTraits<Type>::typeName << " per "
<< word(isNodeValues ? "node:" : "element:") << setw(10) << 1 << word(isNodeValues ? "node:" : "element:") << setw(10) << 1
<< " " << fieldName << " " << fieldName
<< " " << surfaceName.c_str() << ".***." << fieldName << nl << " " << surfaceName.c_str() << ".***." << fieldName << nl
@ -107,7 +108,7 @@ void Foam::ensightSurfaceWriter::writeTemplate
osGeom << ensPart; osGeom << ensPart;
// Write field // Write field
osField.writeKeyword(pTraits<Type>::typeName); osField.writeKeyword(ensightPTraits<Type>::typeName);
ensPart.writeField(osField, values, isNodeValues); ensPart.writeField(osField, values, isNodeValues);
} }

View File

@ -52,12 +52,8 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
// Print patch names as comment // Print patch names as comment
forAll(myPatches, patchI) forAll(myPatches, patchI)
{ {
const surfacePatch& patch = myPatches[patchI]; os << "# " << patchI << " "
<< myPatches[patchI].name() << nl;
if (patch.size() > 0)
{
os << "# " << patchI << " " << patch.name() << nl;
}
} }
os << "#" << nl; os << "#" << nl;
@ -81,29 +77,25 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
forAll(myPatches, patchI) forAll(myPatches, patchI)
{ {
const surfacePatch& patch = myPatches[patchI];
// Print all faces belonging to this patch // Print all faces belonging to this patch
if (patch.size() > 0)
os << "g " << myPatches[patchI].name() << nl;
for
(
label patchFaceI = 0;
patchFaceI < myPatches[patchI].size();
patchFaceI++
)
{ {
os << "g " << patch.name() << nl; const label faceI = faceMap[faceIndex++];
for os << "f "
( << operator[](faceI)[0] + 1 << ' '
label patchFaceI = 0; << operator[](faceI)[1] + 1 << ' '
patchFaceI < patch.size(); << operator[](faceI)[2] + 1
patchFaceI++ //<< " # " << operator[](faceI).region()
) << nl;
{
const label faceI = faceMap[faceIndex++];
os << "f "
<< operator[](faceI)[0] + 1 << ' '
<< operator[](faceI)[1] + 1 << ' '
<< operator[](faceI)[2] + 1
//<< " # " << operator[](faceI).region()
<< nl;
}
} }
} }
} }

View File

@ -31,20 +31,20 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::triSurface::writeSTLASCII(Ostream& os) const void Foam::triSurface::writeSTLASCII(const bool writeSorted, Ostream& os) const
{ {
labelList faceMap; labelList faceMap;
surfacePatchList myPatches(calcPatches(faceMap)); surfacePatchList myPatches(calcPatches(faceMap));
label faceIndex = 0; if (writeSorted)
forAll(myPatches, patchI)
{ {
// Print all faces belonging to this region label faceIndex = 0;
const surfacePatch& patch = myPatches[patchI]; forAll(myPatches, patchI)
if (patch.size() > 0)
{ {
// Print all faces belonging to this region
const surfacePatch& patch = myPatches[patchI];
os << "solid " << patch.name() << endl; os << "solid " << patch.name() << endl;
for for
@ -80,6 +80,63 @@ void Foam::triSurface::writeSTLASCII(Ostream& os) const
os << "endsolid " << patch.name() << endl; os << "endsolid " << patch.name() << endl;
} }
} }
else
{
// Get patch (=compact region) per face
labelList patchIDs(size());
forAll(myPatches, patchI)
{
label faceI = myPatches[patchI].start();
forAll(myPatches[patchI], i)
{
patchIDs[faceMap[faceI++]] = patchI;
}
}
label currentPatchI = -1;
forAll(*this, faceI)
{
if (currentPatchI != patchIDs[faceI])
{
if (currentPatchI != -1)
{
// Have already valid patch. Close it.
os << "endsolid " << myPatches[currentPatchI].name()
<< nl;
}
currentPatchI = patchIDs[faceI];
os << "solid " << myPatches[currentPatchI].name() << nl;
}
const vector& n = faceNormals()[faceI];
os << " facet normal "
<< n.x() << ' ' << n.y() << ' ' << n.z() << nl
<< " outer loop" << endl;
const labelledTri& f = (*this)[faceI];
const point& pa = points()[f[0]];
const point& pb = points()[f[1]];
const point& pc = points()[f[2]];
os << " vertex "
<< pa.x() << ' ' << pa.y() << ' ' << pa.z() << nl
<< " vertex "
<< pb.x() << ' ' << pb.y() << ' ' << pb.z() << nl
<< " vertex "
<< pc.x() << ' ' << pc.y() << ' ' << pc.z() << nl
<< " endloop" << nl
<< " endfacet" << endl;
}
if (currentPatchI != -1)
{
os << "endsolid " << myPatches[currentPatchI].name()
<< nl;
}
}
} }

View File

@ -448,7 +448,7 @@ void Foam::triSurface::write
} }
else if (ext == "stl") else if (ext == "stl")
{ {
return writeSTLASCII(OFstream(name)()); return writeSTLASCII(sort, OFstream(name)());
} }
else if (ext == "stlb") else if (ext == "stlb")
{ {

View File

@ -138,7 +138,7 @@ class triSurface
//- Write to Ostream in ASCII STL format. //- Write to Ostream in ASCII STL format.
// Each region becomes 'solid' 'endsolid' block. // Each region becomes 'solid' 'endsolid' block.
void writeSTLASCII(Ostream&) const; void writeSTLASCII(const bool writeSorted, Ostream&) const;
//- Write to std::ostream in BINARY STL format //- Write to std::ostream in BINARY STL format
void writeSTLBINARY(std::ostream&) const; void writeSTLBINARY(std::ostream&) const;

View File

@ -14,7 +14,7 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
flange.obj flange.stl
{ {
name flange; name flange;
type triSurfaceMesh; type triSurfaceMesh;

View File

@ -10,7 +10,7 @@ FoamFile
version 2.0; version 2.0;
format ascii; format ascii;
class volScalarField; class volScalarField;
object alpha1; object alpha.air;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -5,9 +5,9 @@ cd ${0%/*} || exit 1 # run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions . $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh runApplication blockMesh
cp 0/alpha1.org 0/alpha1 cp 0/alpha.air.org 0/alpha.air
cp 0/alpha2.org 0/alpha2 cp 0/alpha.other.org 0/alpha.other
cp 0/alpha3.org 0/alpha3 cp 0/alpha.water.org 0/alpha.water
runApplication setFields runApplication setFields
runApplication `getApplication` runApplication `getApplication`

View File

@ -44,6 +44,7 @@ FoamFile
defaultFaces defaultFaces
{ {
type empty; type empty;
inGroups 1(empty);
nFaces 4536; nFaces 4536;
startFace 4640; startFace 4640;
} }

View File

@ -15,24 +15,23 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Air phases (air other water);
phase1
air
{ {
transportModel Newtonian; transportModel Newtonian;
nu nu [0 2 -1 0 0 0 0] 1.48e-05; nu nu [0 2 -1 0 0 0 0] 1.48e-05;
rho rho [1 -3 0 0 0 0 0] 1; rho rho [1 -3 0 0 0 0 0] 1;
} }
// Other Liquid other
phase2
{ {
transportModel Newtonian; transportModel Newtonian;
nu nu [0 2 -1 0 0 0 0] 1e-6; nu nu [0 2 -1 0 0 0 0] 1e-6;
rho rho [1 -3 0 0 0 0 0] 1010; rho rho [1 -3 0 0 0 0 0] 1010;
} }
// Water water
phase3
{ {
transportModel Newtonian; transportModel Newtonian;
nu nu [0 2 -1 0 0 0 0] 1e-6; nu nu [0 2 -1 0 0 0 0] 1e-6;

View File

@ -53,7 +53,7 @@ fluxRequired
default no; default no;
p_rgh; p_rgh;
pcorr; pcorr;
"alpha."; "alpha.*";
} }

View File

@ -17,7 +17,7 @@ FoamFile
solvers solvers
{ {
"alpha." "alpha.*"
{ {
nAlphaCorr 1; nAlphaCorr 1;
nAlphaSubCycles 2; nAlphaSubCycles 2;

View File

@ -17,9 +17,9 @@ FoamFile
defaultFieldValues defaultFieldValues
( (
volScalarFieldValue alpha1 0 volScalarFieldValue alpha.air 0
volScalarFieldValue alpha2 1 volScalarFieldValue alpha.other 1
volScalarFieldValue alpha3 0 volScalarFieldValue alpha.water 0
); );
regions regions
@ -29,9 +29,9 @@ regions
box (0 0 -1) (0.1461 0.292 1); box (0 0 -1) (0.1461 0.292 1);
fieldValues fieldValues
( (
volScalarFieldValue alpha1 0 volScalarFieldValue alpha.air 0
volScalarFieldValue alpha2 0 volScalarFieldValue alpha.other 0
volScalarFieldValue alpha3 1 volScalarFieldValue alpha.water 1
); );
} }
boxToCell boxToCell
@ -39,9 +39,9 @@ regions
box (0.1461 0.05 -1) (1 1 1); box (0.1461 0.05 -1) (1 1 1);
fieldValues fieldValues
( (
volScalarFieldValue alpha1 1 volScalarFieldValue alpha.air 1
volScalarFieldValue alpha2 0 volScalarFieldValue alpha.other 0
volScalarFieldValue alpha3 0 volScalarFieldValue alpha.water 0
); );
} }
); );