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())
{
#include "rhoEqn.H"
#include "gammaPsi.H"
#include "alphavPsi.H"
#include "UEqn.H"
// --- Pressure corrector loop

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -62,9 +62,64 @@ Foam::threePhaseMixture::threePhaseMixture
)
),
phase1Name_("phase1"),
phase2Name_("phase2"),
phase3Name_("phase3"),
phase1Name_(wordList(lookup("phases"))[0]),
phase2Name_(wordList(lookup("phases"))[1]),
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_
(
@ -99,28 +154,9 @@ Foam::threePhaseMixture::threePhaseMixture
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
)
rho3_(nuModel3_->viscosityProperties().lookup("rho"))
{
alpha3_ == 1.0 - alpha1_ - alpha2_;
calcNu();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,6 +58,14 @@ static const doubleScalar doubleScalarSMALL = 1.0e-15;
static const doubleScalar doubleScalarVSMALL = 1.0e-300;
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 ScalarVGREAT doubleScalarVGREAT

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,6 +58,14 @@ static const floatScalar floatScalarSMALL = 1.0e-6;
static const floatScalar floatScalarVSMALL = 1.0e-37;
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 ScalarVGREAT floatScalarVGREAT

View File

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

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
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)
{
os.write(label(i));

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -85,6 +85,13 @@ long Foam::readLong(Istream& is)
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)
{

View File

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

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
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)
{
long long val = l;

View File

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

View File

@ -376,7 +376,7 @@ void Foam::searchableSurfaceCollection::boundingSpheres
forAll(subCentres, i)
{
centres[coordI++] = transform_[surfI].globalPosition
centres[coordI] = transform_[surfI].globalPosition
(
cmptMultiply
(
@ -384,7 +384,8 @@ void Foam::searchableSurfaceCollection::boundingSpheres
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
// the range of queries it can expect. faceMap/pointMap can be
// set if the surface has done any redistribution.
virtual void distribute
(
const List<treeBoundBox>& bbs,
const bool keepNonLocal,
autoPtr<mapDistribute>& faceMap,
autoPtr<mapDistribute>& pointMap
)
{
subGeom_[0].distribute(bbs, keepNonLocal, faceMap, pointMap);
}
//virtual void distribute
//(
// const List<treeBoundBox>& bbs,
// const bool keepNonLocal,
// autoPtr<mapDistribute>& faceMap,
// autoPtr<mapDistribute>& pointMap
//)
//{
// subGeom_[0].distribute(bbs, keepNonLocal, faceMap, pointMap);
//}
//- WIP. Store element-wise field.
virtual void setField(const labelList& values)

View File

@ -43,6 +43,7 @@ surfWriters = sampledSurface/writers
$(surfWriters)/surfaceWriter.C
$(surfWriters)/dx/dxSurfaceWriter.C
$(surfWriters)/ensight/ensightSurfaceWriter.C
$(surfWriters)/ensight/ensightPTraits.C
$(surfWriters)/foamFile/foamFileSurfaceWriter.C
$(surfWriters)/nastran/nastranSurfaceWriter.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
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,6 +29,7 @@ License
#include "OSspecific.H"
#include "IOmanip.H"
#include "ensightPartFaces.H"
#include "ensightPTraits.H"
#include "makeSurfaceWriterMethods.H"
@ -89,7 +90,7 @@ void Foam::ensightSurfaceWriter::writeTemplate
<< "model: 1 " << osGeom.name().name() << nl
<< nl
<< "VARIABLE" << nl
<< pTraits<Type>::typeName << " per "
<< ensightPTraits<Type>::typeName << " per "
<< word(isNodeValues ? "node:" : "element:") << setw(10) << 1
<< " " << fieldName
<< " " << surfaceName.c_str() << ".***." << fieldName << nl
@ -107,7 +108,7 @@ void Foam::ensightSurfaceWriter::writeTemplate
osGeom << ensPart;
// Write field
osField.writeKeyword(pTraits<Type>::typeName);
osField.writeKeyword(ensightPTraits<Type>::typeName);
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
forAll(myPatches, patchI)
{
const surfacePatch& patch = myPatches[patchI];
if (patch.size() > 0)
{
os << "# " << patchI << " " << patch.name() << nl;
}
os << "# " << patchI << " "
<< myPatches[patchI].name() << nl;
}
os << "#" << nl;
@ -81,17 +77,14 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
forAll(myPatches, patchI)
{
const surfacePatch& patch = myPatches[patchI];
// Print all faces belonging to this patch
if (patch.size() > 0)
{
os << "g " << patch.name() << nl;
os << "g " << myPatches[patchI].name() << nl;
for
(
label patchFaceI = 0;
patchFaceI < patch.size();
patchFaceI < myPatches[patchI].size();
patchFaceI++
)
{
@ -106,7 +99,6 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
}
}
}
}
else
{
// Get patch (=compact region) per face

View File

@ -31,20 +31,20 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::triSurface::writeSTLASCII(Ostream& os) const
void Foam::triSurface::writeSTLASCII(const bool writeSorted, Ostream& os) const
{
labelList faceMap;
surfacePatchList myPatches(calcPatches(faceMap));
if (writeSorted)
{
label faceIndex = 0;
forAll(myPatches, patchI)
{
// Print all faces belonging to this region
const surfacePatch& patch = myPatches[patchI];
if (patch.size() > 0)
{
os << "solid " << patch.name() << endl;
for
@ -80,6 +80,63 @@ void Foam::triSurface::writeSTLASCII(Ostream& os) const
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")
{
return writeSTLASCII(OFstream(name)());
return writeSTLASCII(sort, OFstream(name)());
}
else if (ext == "stlb")
{

View File

@ -138,7 +138,7 @@ class triSurface
//- Write to Ostream in ASCII STL format.
// 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
void writeSTLBINARY(std::ostream&) const;

View File

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

View File

@ -10,7 +10,7 @@ FoamFile
version 2.0;
format ascii;
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
runApplication blockMesh
cp 0/alpha1.org 0/alpha1
cp 0/alpha2.org 0/alpha2
cp 0/alpha3.org 0/alpha3
cp 0/alpha.air.org 0/alpha.air
cp 0/alpha.other.org 0/alpha.other
cp 0/alpha.water.org 0/alpha.water
runApplication setFields
runApplication `getApplication`

View File

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

View File

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

View File

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

View File

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

View File

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