Merge branch 'master' into cvm

This commit is contained in:
graham
2011-07-04 12:16:13 +01:00
23 changed files with 258 additions and 136 deletions

View File

@ -57,6 +57,10 @@ Description
#include <netinet/in.h> #include <netinet/in.h>
#ifdef USE_RANDOM
# include <climits>
#endif
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::POSIX, 0); defineTypeNameAndDebug(Foam::POSIX, 0);
@ -68,16 +72,19 @@ pid_t Foam::pid()
return ::getpid(); return ::getpid();
} }
pid_t Foam::ppid() pid_t Foam::ppid()
{ {
return ::getppid(); return ::getppid();
} }
pid_t Foam::pgid() pid_t Foam::pgid()
{ {
return ::getpgrp(); return ::getpgrp();
} }
bool Foam::env(const word& envName) bool Foam::env(const word& envName)
{ {
return ::getenv(envName.c_str()) != NULL; return ::getenv(envName.c_str()) != NULL;
@ -890,7 +897,6 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
} }
// Remove a file, returning true if successful otherwise false // Remove a file, returning true if successful otherwise false
bool Foam::rm(const fileName& file) bool Foam::rm(const fileName& file)
{ {
@ -1221,4 +1227,34 @@ Foam::fileNameList Foam::dlLoaded()
} }
void Foam::osRandomSeed(const label seed)
{
#ifdef USE_RANDOM
srandom((unsigned int)seed);
#else
srand48(seed);
#endif
}
Foam::label Foam::osRandomInteger()
{
#ifdef USE_RANDOM
return random();
#else
return lrand48();
#endif
}
Foam::scalar Foam::osRandomDouble()
{
#ifdef USE_RANDOM
return (scalar)random();
#else
return drand48();
#endif
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -200,6 +200,18 @@ bool dlSymFound(void* handle, const std::string& symbol);
fileNameList dlLoaded(); fileNameList dlLoaded();
// Low level random numbers. Use Random class instead.
//- Seed random number generator.
void osRandomSeed(const label seed);
//- Return random integer (uniform distribution between 0 and 2^31)
label osRandomInteger();
//- Return random double precision (uniform distribution between 0 and 1)
scalar osRandomDouble();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

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) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "Random.H" #include "Random.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -37,11 +38,6 @@ namespace Foam
# error "The random number generator may not work!" # error "The random number generator may not work!"
#endif #endif
#ifdef USE_RANDOM
# include <climits>
#else
# include <cstdlib>
#endif
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -57,22 +53,13 @@ Random::Random(const label seed)
Seed = 1; Seed = 1;
} }
# ifdef USE_RANDOM osRandomSeed(Seed);
srandom((unsigned int)Seed);
# else
srand48(Seed);
# endif
} }
int Random::bit() int Random::bit()
{ {
# ifdef USE_RANDOM if (osRandomInteger() > INT_MAX/2)
if (random() > INT_MAX/2)
# else
if (lrand48() > INT_MAX/2)
# endif
{ {
return 1; return 1;
} }
@ -85,11 +72,7 @@ int Random::bit()
scalar Random::scalar01() scalar Random::scalar01()
{ {
# ifdef USE_RANDOM return osRandomDouble();
return (scalar)random()/INT_MAX;
# else
return drand48();
# endif
} }
@ -140,11 +123,7 @@ tensor Random::tensor01()
label Random::integer(const label lower, const label upper) label Random::integer(const label lower, const label upper)
{ {
# ifdef USE_RANDOM return lower + (osRandomInteger() % (upper+1-lower));
return lower + (random() % (upper+1-lower));
# else
return lower + (lrand48() % (upper+1-lower));
# 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) 2010-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "cachedRandom.H" #include "cachedRandom.H"
#include <cstdlib> #include "OSspecific.H"
#if INT_MAX != 2147483647 #if INT_MAX != 2147483647
# error "INT_MAX != 2147483647" # error "INT_MAX != 2147483647"
@ -37,7 +37,7 @@ Foam::scalar Foam::cachedRandom::scalar01()
{ {
if (sampleI_ < 0) if (sampleI_ < 0)
{ {
return drand48(); return osRandomDouble();
} }
if (sampleI_ == samples_.size() - 1) if (sampleI_ == samples_.size() - 1)
@ -76,7 +76,7 @@ Foam::cachedRandom::cachedRandom(const label seed, const label count)
} }
// Initialise samples // Initialise samples
srand48(seed_); osRandomSeed(seed_);
forAll(samples_, i) forAll(samples_, i)
{ {
samples_[i] = drand48(); samples_[i] = drand48();
@ -98,7 +98,7 @@ Foam::cachedRandom::cachedRandom(const cachedRandom& cr, const bool reset)
) << "Copy constructor called, but samples not being cached. " ) << "Copy constructor called, but samples not being cached. "
<< "This may lead to non-repeatable behaviour" << endl; << "This may lead to non-repeatable behaviour" << endl;
srand48(seed_); osRandomSeed(seed_);
} }
else if (reset) else if (reset)
{ {

View File

@ -59,10 +59,7 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
fixedValueFvPatchScalarField(p, iF), totalPressureFvPatchScalarField(p, iF),
phiName_("phi"),
rhoName_("rho"),
p0_(p.size(), 0.0),
fanCurve_(), fanCurve_(),
direction_(ffdOut) direction_(ffdOut)
{} {}
@ -76,10 +73,7 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
fixedValueFvPatchScalarField(ptf, p, iF, mapper), totalPressureFvPatchScalarField(ptf, p, iF, mapper),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_),
p0_(ptf.p0_, mapper),
fanCurve_(ptf.fanCurve_), fanCurve_(ptf.fanCurve_),
direction_(ptf.direction_) direction_(ptf.direction_)
{} {}
@ -92,10 +86,7 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF), totalPressureFvPatchScalarField(p, iF),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
p0_("p0", dict, p.size()),
fanCurve_(dict), fanCurve_(dict),
direction_(fanFlowDirectionNames_.read(dict.lookup("direction"))) direction_(fanFlowDirectionNames_.read(dict.lookup("direction")))
{ {
@ -109,10 +100,7 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
const fanPressureFvPatchScalarField& pfopsf const fanPressureFvPatchScalarField& pfopsf
) )
: :
fixedValueFvPatchScalarField(pfopsf), totalPressureFvPatchScalarField(pfopsf),
phiName_(pfopsf.phiName_),
rhoName_(pfopsf.rhoName_),
p0_(pfopsf.p0_),
fanCurve_(pfopsf.fanCurve_), fanCurve_(pfopsf.fanCurve_),
direction_(pfopsf.direction_) direction_(pfopsf.direction_)
{} {}
@ -124,10 +112,7 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
fixedValueFvPatchScalarField(pfopsf, iF), totalPressureFvPatchScalarField(pfopsf, iF),
phiName_(pfopsf.phiName_),
rhoName_(pfopsf.rhoName_),
p0_(pfopsf.p0_),
fanCurve_(pfopsf.fanCurve_), fanCurve_(pfopsf.fanCurve_),
direction_(pfopsf.direction_) direction_(pfopsf.direction_)
{} {}
@ -144,7 +129,7 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs()
// Retrieve flux field // Retrieve flux field
const surfaceScalarField& phi = const surfaceScalarField& phi =
db().lookupObject<surfaceScalarField>(phiName_); db().lookupObject<surfaceScalarField>(phiName());
const fvsPatchField<scalar>& phip = const fvsPatchField<scalar>& phip =
patch().patchField<surfaceScalarField, scalar>(phi); patch().patchField<surfaceScalarField, scalar>(phi);
@ -161,7 +146,7 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs()
else if (phi.dimensions() == dimVelocity*dimArea*dimDensity) else if (phi.dimensions() == dimVelocity*dimArea*dimDensity)
{ {
const scalarField& rhop = const scalarField& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_); patch().lookupPatchField<volScalarField, scalar>(rhoName());
aveFlowRate = dir*gSum(phip/rhop)/gSum(patch().magSf()); aveFlowRate = dir*gSum(phip/rhop)/gSum(patch().magSf());
} }
else else
@ -174,51 +159,23 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs()
<< exit(FatalError); << exit(FatalError);
} }
// Normal flow through fan
if (aveFlowRate >= 0.0)
{
// Pressure drop for this flow rate // Pressure drop for this flow rate
const scalar pdFan = fanCurve_(aveFlowRate); const scalar pdFan = fanCurve_(max(aveFlowRate, 0.0));
operator==(p0_ - dir*pdFan); totalPressureFvPatchScalarField::updateCoeffs
} (
// Reverse flow p0() - dir*pdFan,
else patch().lookupPatchField<volVectorField, vector>(UName())
{ );
// Assume that fan has stalled if flow reversed
// i.e. apply dp for zero flow rate
const scalar pdFan = fanCurve_(0);
// Flow speed across patch
scalarField Up = phip/(patch().magSf());
// Pressure drop associated withback flow = dynamic pressure
scalarField pdBackFlow = 0.5*magSqr(Up);
if (phi.dimensions() == dimVelocity*dimArea*dimDensity)
{
const scalarField& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
pdBackFlow /= rhop;
}
operator==(p0_ - dir*(pdBackFlow + pdFan));
}
fixedValueFvPatchScalarField::updateCoeffs();
} }
void Foam::fanPressureFvPatchScalarField::write(Ostream& os) const void Foam::fanPressureFvPatchScalarField::write(Ostream& os) const
{ {
fvPatchScalarField::write(os); totalPressureFvPatchScalarField::write(os);
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
fanCurve_.write(os); fanCurve_.write(os);
os.writeKeyword("direction") os.writeKeyword("direction")
<< fanFlowDirectionNames_[direction_] << token::END_STATEMENT << nl; << fanFlowDirectionNames_[direction_] << token::END_STATEMENT << nl;
p0_.writeEntry("p0", os);
writeEntry("value", os);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::fanPressureFvPatchScalarField Foam::fanPressureFvPatchScalarField
Description Description
Assigns pressure inlet or outlet condition for a fan. Assigns pressure inlet or outlet total pressure condition for a fan.
User specifies: User specifies:
- pressure drop vs volumetric flow rate table (fan curve) file name; - pressure drop vs volumetric flow rate table (fan curve) file name;
@ -56,8 +56,8 @@ Description
\endverbatim \endverbatim
See Also See Also
Foam::interpolationTable and Foam::totalPressureFvPatchScalarField and
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField Foam::interpolationTable
SourceFiles SourceFiles
fanPressureFvPatchScalarField.C fanPressureFvPatchScalarField.C
@ -67,8 +67,7 @@ SourceFiles
#ifndef fanPressureFvPatchScalarField_H #ifndef fanPressureFvPatchScalarField_H
#define fanPressureFvPatchScalarField_H #define fanPressureFvPatchScalarField_H
#include "fvPatchFields.H" #include "totalPressureFvPatchScalarField.H"
#include "fixedValueFvPatchFields.H"
#include "interpolationTable.H" #include "interpolationTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -82,19 +81,10 @@ namespace Foam
class fanPressureFvPatchScalarField class fanPressureFvPatchScalarField
: :
public fixedValueFvPatchScalarField public totalPressureFvPatchScalarField
{ {
// Private data // Private data
//- Name of the flux transporting the field
word phiName_;
//- Name of the density field
word rhoName_;
//- Total pressure
scalarField p0_;
//- Tabulated fan curve //- Tabulated fan curve
interpolationTable<scalar> fanCurve_; interpolationTable<scalar> fanCurve_;

View File

@ -112,7 +112,7 @@ void Foam::rotatingTotalPressureFvPatchScalarField::updateCoeffs()
+ rotationVelocity + rotationVelocity
); );
totalPressureFvPatchScalarField::updateCoeffs(Up); totalPressureFvPatchScalarField::updateCoeffs(p0(), Up);
} }

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) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -153,7 +153,11 @@ void Foam::totalPressureFvPatchScalarField::rmap
} }
void Foam::totalPressureFvPatchScalarField::updateCoeffs(const vectorField& Up) void Foam::totalPressureFvPatchScalarField::updateCoeffs
(
const scalarField& p0p,
const vectorField& Up
)
{ {
if (updated()) if (updated())
{ {
@ -165,7 +169,7 @@ void Foam::totalPressureFvPatchScalarField::updateCoeffs(const vectorField& Up)
if (psiName_ == "none" && rhoName_ == "none") if (psiName_ == "none" && rhoName_ == "none")
{ {
operator==(p0_ - 0.5*(1.0 - pos(phip))*magSqr(Up)); operator==(p0p - 0.5*(1.0 - pos(phip))*magSqr(Up));
} }
else if (rhoName_ == "none") else if (rhoName_ == "none")
{ {
@ -178,7 +182,7 @@ void Foam::totalPressureFvPatchScalarField::updateCoeffs(const vectorField& Up)
operator== operator==
( (
p0_ p0p
/pow /pow
( (
(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up)), (1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up)),
@ -188,7 +192,7 @@ void Foam::totalPressureFvPatchScalarField::updateCoeffs(const vectorField& Up)
} }
else else
{ {
operator==(p0_/(1.0 + 0.5*psip*(1.0 - pos(phip))*magSqr(Up))); operator==(p0p/(1.0 + 0.5*psip*(1.0 - pos(phip))*magSqr(Up)));
} }
} }
else if (psiName_ == "none") else if (psiName_ == "none")
@ -196,7 +200,7 @@ void Foam::totalPressureFvPatchScalarField::updateCoeffs(const vectorField& Up)
const fvPatchField<scalar>& rho = const fvPatchField<scalar>& rho =
patch().lookupPatchField<volScalarField, scalar>(rhoName_); patch().lookupPatchField<volScalarField, scalar>(rhoName_);
operator==(p0_ - 0.5*rho*(1.0 - pos(phip))*magSqr(Up)); operator==(p0p - 0.5*rho*(1.0 - pos(phip))*magSqr(Up));
} }
else else
{ {
@ -220,7 +224,11 @@ void Foam::totalPressureFvPatchScalarField::updateCoeffs(const vectorField& Up)
void Foam::totalPressureFvPatchScalarField::updateCoeffs() void Foam::totalPressureFvPatchScalarField::updateCoeffs()
{ {
updateCoeffs(patch().lookupPatchField<volVectorField, vector>(UName_)); updateCoeffs
(
p0(),
patch().lookupPatchField<volVectorField, vector>(UName())
);
} }

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) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -157,6 +157,45 @@ public:
return UName_; return UName_;
} }
//- Return the name of the flux field
const word& phiName() const
{
return phiName_;
}
//- Return reference to the name of the flux field
// to allow adjustment
word& phiName()
{
return phiName_;
}
//- Return the name of the density field
const word& rhoName() const
{
return rhoName_;
}
//- Return reference to the name of the density field
// to allow adjustment
word& rhoName()
{
return rhoName_;
}
//- Return the name of the compressibility field
const word& psiName() const
{
return psiName_;
}
//- Return reference to the name of the compressibility field
// to allow adjustment
word& psiName()
{
return psiName_;
}
//- Return the heat capacity ratio //- Return the heat capacity ratio
scalar gamma() const scalar gamma() const
{ {
@ -201,8 +240,12 @@ public:
// Evaluation functions // Evaluation functions
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
// using the given patch velocity field // using the given patch total pressure and velocity fields
virtual void updateCoeffs(const vectorField& Up); virtual void updateCoeffs
(
const scalarField& p0p,
const vectorField& Up
);
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
virtual void updateCoeffs(); virtual void updateCoeffs();

View File

@ -214,7 +214,8 @@ void Foam::PairSpringSliderDashpot<CloudType>::evaluatePair
rHat_AB rHat_AB
*(kN*pow(normalOverlapMag, b_) - etaN*(U_AB & rHat_AB)); *(kN*pow(normalOverlapMag, b_) - etaN*(U_AB & rHat_AB));
// Cohesion force // Cohesion force, energy density multiplied by the area of
// particle-particle overlap
if (cohesion_) if (cohesion_)
{ {
fN_AB += fN_AB +=

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) 2008-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -76,7 +76,8 @@ void Foam::WallLocalSpringSliderDashpot<CloudType>::evaluateWall
typename CloudType::parcelType& p, typename CloudType::parcelType& p,
const point& site, const point& site,
const WallSiteData<vector>& data, const WallSiteData<vector>& data,
scalar pREff scalar pREff,
bool cohesion
) const ) const
{ {
// wall patch index // wall patch index
@ -88,14 +89,18 @@ void Foam::WallLocalSpringSliderDashpot<CloudType>::evaluateWall
scalar alpha = alpha_[wPI]; scalar alpha = alpha_[wPI];
scalar b = b_[wPI]; scalar b = b_[wPI];
scalar mu = mu_[wPI]; scalar mu = mu_[wPI];
scalar cohesionEnergyDensity = cohesionEnergyDensity_[wPI];
cohesion = cohesion && cohesion_[wPI];
vector r_PW = p.position() - site; vector r_PW = p.position() - site;
vector U_PW = p.U() - data.wallData(); vector U_PW = p.U() - data.wallData();
scalar normalOverlapMag = max(pREff - mag(r_PW), 0.0); scalar r_PW_mag = mag(r_PW);
vector rHat_PW = r_PW/(mag(r_PW) + VSMALL); scalar normalOverlapMag = max(pREff - r_PW_mag, 0.0);
vector rHat_PW = r_PW/(r_PW_mag + VSMALL);
scalar kN = (4.0/3.0)*sqrt(pREff)*Estar; scalar kN = (4.0/3.0)*sqrt(pREff)*Estar;
@ -105,6 +110,16 @@ void Foam::WallLocalSpringSliderDashpot<CloudType>::evaluateWall
rHat_PW rHat_PW
*(kN*pow(normalOverlapMag, b) - etaN*(U_PW & rHat_PW)); *(kN*pow(normalOverlapMag, b) - etaN*(U_PW & rHat_PW));
// Cohesion force, energy density multiplied by the area of wall/particle
// overlap
if (cohesion)
{
fN_PW +=
-cohesionEnergyDensity
*mathematical::pi*(sqr(pREff) - sqr(r_PW_mag))
*rHat_PW;
}
p.f() += fN_PW; p.f() += fN_PW;
vector USlip_PW = vector USlip_PW =
@ -168,6 +183,8 @@ Foam::WallLocalSpringSliderDashpot<CloudType>::WallLocalSpringSliderDashpot
alpha_(), alpha_(),
b_(), b_(),
mu_(), mu_(),
cohesionEnergyDensity_(),
cohesion_(),
patchMap_(), patchMap_(),
maxEstarIndex_(-1), maxEstarIndex_(-1),
collisionResolutionSteps_ collisionResolutionSteps_
@ -212,6 +229,8 @@ Foam::WallLocalSpringSliderDashpot<CloudType>::WallLocalSpringSliderDashpot
alpha_.setSize(nWallPatches); alpha_.setSize(nWallPatches);
b_.setSize(nWallPatches); b_.setSize(nWallPatches);
mu_.setSize(nWallPatches); mu_.setSize(nWallPatches);
cohesionEnergyDensity_.setSize(nWallPatches);
cohesion_.setSize(nWallPatches);
scalar maxEstar = -GREAT; scalar maxEstar = -GREAT;
@ -238,6 +257,13 @@ Foam::WallLocalSpringSliderDashpot<CloudType>::WallLocalSpringSliderDashpot
mu_[wPI] = readScalar(patchCoeffDict.lookup("mu")); mu_[wPI] = readScalar(patchCoeffDict.lookup("mu"));
cohesionEnergyDensity_[wPI] = readScalar
(
patchCoeffDict.lookup("cohesionEnergyDensity")
);
cohesion_[wPI] = (mag(cohesionEnergyDensity_[wPI]) > VSMALL);
if (Estar_[wPI] > maxEstar) if (Estar_[wPI] > maxEstar)
{ {
maxEstarIndex_ = wPI; maxEstarIndex_ = wPI;
@ -325,20 +351,22 @@ void Foam::WallLocalSpringSliderDashpot<CloudType>::evaluateWall
p, p,
flatSitePoints[siteI], flatSitePoints[siteI],
flatSiteData[siteI], flatSiteData[siteI],
pREff pREff,
true
); );
} }
forAll(sharpSitePoints, siteI) forAll(sharpSitePoints, siteI)
{ {
// Treating sharp sites like flat sites // Treating sharp sites like flat sites, except suppress cohesion
evaluateWall evaluateWall
( (
p, p,
sharpSitePoints[siteI], sharpSitePoints[siteI],
sharpSiteData[siteI], sharpSiteData[siteI],
pREff pREff,
false
); );
} }
} }

View File

@ -65,6 +65,12 @@ class WallLocalSpringSliderDashpot
//- Coefficient of friction in for tangential sliding //- Coefficient of friction in for tangential sliding
scalarList mu_; scalarList mu_;
//- Cohesion energy density [J/m^3]
scalarList cohesionEnergyDensity_;
// Switch cohesion on and off
boolList cohesion_;
//- Mapping the patch index to the model data //- Mapping the patch index to the model data
labelList patchMap_; labelList patchMap_;
@ -115,7 +121,8 @@ class WallLocalSpringSliderDashpot
typename CloudType::parcelType& p, typename CloudType::parcelType& p,
const point& site, const point& site,
const WallSiteData<vector>& data, const WallSiteData<vector>& data,
scalar pREff scalar pREff,
bool cohesion
) const; ) const;

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) 2008-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -77,16 +77,19 @@ void Foam::WallSpringSliderDashpot<CloudType>::evaluateWall
const point& site, const point& site,
const WallSiteData<vector>& data, const WallSiteData<vector>& data,
scalar pREff, scalar pREff,
scalar kN scalar kN,
bool cohesion
) const ) const
{ {
vector r_PW = p.position() - site; vector r_PW = p.position() - site;
vector U_PW = p.U() - data.wallData(); vector U_PW = p.U() - data.wallData();
scalar normalOverlapMag = max(pREff - mag(r_PW), 0.0); scalar r_PW_mag = mag(r_PW);
vector rHat_PW = r_PW/(mag(r_PW) + VSMALL); scalar normalOverlapMag = max(pREff - r_PW_mag, 0.0);
vector rHat_PW = r_PW/(r_PW_mag + VSMALL);
scalar etaN = alpha_*sqrt(p.mass()*kN)*pow025(normalOverlapMag); scalar etaN = alpha_*sqrt(p.mass()*kN)*pow025(normalOverlapMag);
@ -94,6 +97,16 @@ void Foam::WallSpringSliderDashpot<CloudType>::evaluateWall
rHat_PW rHat_PW
*(kN*pow(normalOverlapMag, b_) - etaN*(U_PW & rHat_PW)); *(kN*pow(normalOverlapMag, b_) - etaN*(U_PW & rHat_PW));
// Cohesion force, energy density multiplied by the area of wall/particle
// overlap
if (cohesion)
{
fN_PW +=
-cohesionEnergyDensity_
*mathematical::pi*(sqr(pREff) - sqr(r_PW_mag))
*rHat_PW;
}
p.f() += fN_PW; p.f() += fN_PW;
vector USlip_PW = vector USlip_PW =
@ -157,6 +170,11 @@ Foam::WallSpringSliderDashpot<CloudType>::WallSpringSliderDashpot
alpha_(readScalar(this->coeffDict().lookup("alpha"))), alpha_(readScalar(this->coeffDict().lookup("alpha"))),
b_(readScalar(this->coeffDict().lookup("b"))), b_(readScalar(this->coeffDict().lookup("b"))),
mu_(readScalar(this->coeffDict().lookup("mu"))), mu_(readScalar(this->coeffDict().lookup("mu"))),
cohesionEnergyDensity_
(
readScalar(this->coeffDict().lookup("cohesionEnergyDensity"))
),
cohesion_(false),
collisionResolutionSteps_ collisionResolutionSteps_
( (
readScalar readScalar
@ -183,6 +201,8 @@ Foam::WallSpringSliderDashpot<CloudType>::WallSpringSliderDashpot
Estar_ = 1/((1 - sqr(pNu))/pE + (1 - sqr(nu))/E); Estar_ = 1/((1 - sqr(pNu))/pE + (1 - sqr(nu))/E);
Gstar_ = 1/(2*((2 + pNu - sqr(pNu))/pE + (2 + nu - sqr(nu))/E)); Gstar_ = 1/(2*((2 + pNu - sqr(pNu))/pE + (2 + nu - sqr(nu))/E));
cohesion_ = (mag(cohesionEnergyDensity_) > VSMALL);
} }
@ -266,13 +286,14 @@ void Foam::WallSpringSliderDashpot<CloudType>::evaluateWall
flatSitePoints[siteI], flatSitePoints[siteI],
flatSiteData[siteI], flatSiteData[siteI],
pREff, pREff,
kN kN,
cohesion_
); );
} }
forAll(sharpSitePoints, siteI) forAll(sharpSitePoints, siteI)
{ {
// Treating sharp sites like flat sites // Treating sharp sites like flat sites, except suppress cohesion
evaluateWall evaluateWall
( (
@ -280,7 +301,8 @@ void Foam::WallSpringSliderDashpot<CloudType>::evaluateWall
sharpSitePoints[siteI], sharpSitePoints[siteI],
sharpSiteData[siteI], sharpSiteData[siteI],
pREff, pREff,
kN kN,
false
); );
} }
} }

View File

@ -65,6 +65,12 @@ class WallSpringSliderDashpot
//- Coefficient of friction in for tangential sliding //- Coefficient of friction in for tangential sliding
scalar mu_; scalar mu_;
//- Cohesion energy density [J/m^3]
scalar cohesionEnergyDensity_;
// Switch cohesion on and off
bool cohesion_;
//- The number of steps over which to resolve the minimum //- The number of steps over which to resolve the minimum
// harmonic approximation of the collision period // harmonic approximation of the collision period
scalar collisionResolutionSteps_; scalar collisionResolutionSteps_;
@ -110,7 +116,8 @@ class WallSpringSliderDashpot
const point& site, const point& site,
const WallSiteData<vector>& data, const WallSiteData<vector>& data,
scalar pREff, scalar pREff,
scalar kN scalar kN,
bool cohesion
) const; ) const;

View File

@ -27,6 +27,7 @@ License
#include "dictionary.H" #include "dictionary.H"
#include "Time.H" #include "Time.H"
#include "IOobjectList.H" #include "IOobjectList.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -123,14 +124,26 @@ void Foam::partialWrite::write()
else else
{ {
// Delete all but marked objects // Delete all but marked objects
fileName dbDir;
if (isA<polyMesh>(obr_))
{
dbDir = dynamic_cast<const polyMesh&>(obr_).dbDir();
}
IOobjectList objects(obr_, obr_.time().timeName()); IOobjectList objects(obr_, obr_.time().timeName());
forAllConstIter(HashPtrTable<IOobject>, objects, iter) forAllConstIter(HashPtrTable<IOobject>, objects, iter)
{ {
if (!objectNames_.found(iter()->name())) if (!objectNames_.found(iter()->name()))
{ {
const fileName f = obr_.time().timePath()/iter()->name(); const fileName f =
//Pout<< " rm " << f << endl; obr_.time().timePath()
/dbDir
/iter()->name();
if (debug)
{
Pout<< " rm " << f << endl;
}
rm(f); rm(f);
} }
} }

View File

@ -32,4 +32,8 @@ decomposePar -region panelRegion > log.decomposParPanelRegion.log 2>&1
runParallel `getApplication` 6 runParallel `getApplication` 6
paraFoam -touch
paraFoam -touch -region panelRegion
# ----------------------------------------------------------------- end-of-file # ----------------------------------------------------------------- end-of-file

View File

@ -112,6 +112,7 @@ subModels
alpha 0.12; alpha 0.12;
b 1.5; b 1.5;
mu 0.43; mu 0.43;
cohesionEnergyDensity 0;
} }
frontAndBack frontAndBack
{ {
@ -120,6 +121,7 @@ subModels
alpha 0.12; alpha 0.12;
b 1.5; b 1.5;
mu 0.1; mu 0.1;
cohesionEnergyDensity 0;
} }
}; };
} }

View File

@ -121,6 +121,7 @@ subModels
alpha 0.12; alpha 0.12;
b 1.5; b 1.5;
mu 0.43; mu 0.43;
cohesionEnergyDensity 0;
} }
frontAndBack frontAndBack
{ {
@ -129,6 +130,7 @@ subModels
alpha 0.12; alpha 0.12;
b 1.5; b 1.5;
mu 0.1; mu 0.1;
cohesionEnergyDensity 0;
} }
}; };
} }

View File

@ -8,3 +8,6 @@ runApplication setSet -batch wallFilmRegion.setSet
mv log.setSet log.wallFilmRegion.setSet mv log.setSet log.wallFilmRegion.setSet
runApplication extrudeToRegionMesh -overwrite runApplication extrudeToRegionMesh -overwrite
paraFoam -touch
paraFoam -touch -region wallFilmRegion

View File

@ -32,3 +32,6 @@ cp -r system/wallFilmRegion.org system/wallFilmRegion
find ./0 -maxdepth 1 -type f -exec \ find ./0 -maxdepth 1 -type f -exec \
sed -i "s/wallFilm/\"(region0_to.*)\"/g" {} \; sed -i "s/wallFilm/\"(region0_to.*)\"/g" {} \;
paraFoam -touch
paraFoam -touch -region wallFilmRegion

View File

@ -10,3 +10,5 @@ mv log.setSet log.wallFilmRegion.setSet
runApplication extrudeToRegionMesh -overwrite runApplication extrudeToRegionMesh -overwrite
paraFoam -touch
paraFoam -touch -region wallFilmRegion

View File

@ -14,3 +14,6 @@ runApplication setSet -region wallFilmRegion -batch createWallFilmRegionPatches.
mv log.setSet log.createWallFilmRegionPatches.setSet mv log.setSet log.createWallFilmRegionPatches.setSet
runApplication createPatch -region wallFilmRegion -overwrite runApplication createPatch -region wallFilmRegion -overwrite
paraFoam -touch
paraFoam -touch -region wallFilmRegion