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

This commit is contained in:
Henry
2011-07-04 12:06:18 +01:00
17 changed files with 176 additions and 52 deletions

View File

@ -57,6 +57,10 @@ Description
#include <netinet/in.h>
#ifdef USE_RANDOM
# include <climits>
#endif
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::POSIX, 0);
@ -68,16 +72,19 @@ pid_t Foam::pid()
return ::getpid();
}
pid_t Foam::ppid()
{
return ::getppid();
}
pid_t Foam::pgid()
{
return ::getpgrp();
}
bool Foam::env(const word& envName)
{
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
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();
// 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

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Random.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -37,11 +38,6 @@ namespace Foam
# error "The random number generator may not work!"
#endif
#ifdef USE_RANDOM
# include <climits>
#else
# include <cstdlib>
#endif
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -57,22 +53,13 @@ Random::Random(const label seed)
Seed = 1;
}
# ifdef USE_RANDOM
srandom((unsigned int)Seed);
# else
srand48(Seed);
# endif
osRandomSeed(Seed);
}
int Random::bit()
{
# ifdef USE_RANDOM
if (random() > INT_MAX/2)
# else
if (lrand48() > INT_MAX/2)
# endif
if (osRandomInteger() > INT_MAX/2)
{
return 1;
}
@ -85,11 +72,7 @@ int Random::bit()
scalar Random::scalar01()
{
# ifdef USE_RANDOM
return (scalar)random()/INT_MAX;
# else
return drand48();
# endif
return osRandomDouble();
}
@ -140,11 +123,7 @@ tensor Random::tensor01()
label Random::integer(const label lower, const label upper)
{
# ifdef USE_RANDOM
return lower + (random() % (upper+1-lower));
# else
return lower + (lrand48() % (upper+1-lower));
# endif
return lower + (osRandomInteger() % (upper+1-lower));
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "cachedRandom.H"
#include <cstdlib>
#include "OSspecific.H"
#if INT_MAX != 2147483647
# error "INT_MAX != 2147483647"
@ -37,7 +37,7 @@ Foam::scalar Foam::cachedRandom::scalar01()
{
if (sampleI_ < 0)
{
return drand48();
return osRandomDouble();
}
if (sampleI_ == samples_.size() - 1)
@ -76,7 +76,7 @@ Foam::cachedRandom::cachedRandom(const label seed, const label count)
}
// Initialise samples
srand48(seed_);
osRandomSeed(seed_);
forAll(samples_, i)
{
samples_[i] = drand48();
@ -98,7 +98,7 @@ Foam::cachedRandom::cachedRandom(const cachedRandom& cr, const bool reset)
) << "Copy constructor called, but samples not being cached. "
<< "This may lead to non-repeatable behaviour" << endl;
srand48(seed_);
osRandomSeed(seed_);
}
else if (reset)
{

View File

@ -214,7 +214,8 @@ void Foam::PairSpringSliderDashpot<CloudType>::evaluatePair
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_)
{
fN_AB +=

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -76,7 +76,8 @@ void Foam::WallLocalSpringSliderDashpot<CloudType>::evaluateWall
typename CloudType::parcelType& p,
const point& site,
const WallSiteData<vector>& data,
scalar pREff
scalar pREff,
bool cohesion
) const
{
// wall patch index
@ -88,14 +89,18 @@ void Foam::WallLocalSpringSliderDashpot<CloudType>::evaluateWall
scalar alpha = alpha_[wPI];
scalar b = b_[wPI];
scalar mu = mu_[wPI];
scalar cohesionEnergyDensity = cohesionEnergyDensity_[wPI];
cohesion = cohesion && cohesion_[wPI];
vector r_PW = p.position() - site;
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;
@ -105,6 +110,16 @@ void Foam::WallLocalSpringSliderDashpot<CloudType>::evaluateWall
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;
vector USlip_PW =
@ -168,6 +183,8 @@ Foam::WallLocalSpringSliderDashpot<CloudType>::WallLocalSpringSliderDashpot
alpha_(),
b_(),
mu_(),
cohesionEnergyDensity_(),
cohesion_(),
patchMap_(),
maxEstarIndex_(-1),
collisionResolutionSteps_
@ -212,6 +229,8 @@ Foam::WallLocalSpringSliderDashpot<CloudType>::WallLocalSpringSliderDashpot
alpha_.setSize(nWallPatches);
b_.setSize(nWallPatches);
mu_.setSize(nWallPatches);
cohesionEnergyDensity_.setSize(nWallPatches);
cohesion_.setSize(nWallPatches);
scalar maxEstar = -GREAT;
@ -238,6 +257,13 @@ Foam::WallLocalSpringSliderDashpot<CloudType>::WallLocalSpringSliderDashpot
mu_[wPI] = readScalar(patchCoeffDict.lookup("mu"));
cohesionEnergyDensity_[wPI] = readScalar
(
patchCoeffDict.lookup("cohesionEnergyDensity")
);
cohesion_[wPI] = (mag(cohesionEnergyDensity_[wPI]) > VSMALL);
if (Estar_[wPI] > maxEstar)
{
maxEstarIndex_ = wPI;
@ -325,20 +351,22 @@ void Foam::WallLocalSpringSliderDashpot<CloudType>::evaluateWall
p,
flatSitePoints[siteI],
flatSiteData[siteI],
pREff
pREff,
true
);
}
forAll(sharpSitePoints, siteI)
{
// Treating sharp sites like flat sites
// Treating sharp sites like flat sites, except suppress cohesion
evaluateWall
(
p,
sharpSitePoints[siteI],
sharpSiteData[siteI],
pREff
pREff,
false
);
}
}

View File

@ -65,6 +65,12 @@ class WallLocalSpringSliderDashpot
//- Coefficient of friction in for tangential sliding
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
labelList patchMap_;
@ -115,7 +121,8 @@ class WallLocalSpringSliderDashpot
typename CloudType::parcelType& p,
const point& site,
const WallSiteData<vector>& data,
scalar pREff
scalar pREff,
bool cohesion
) const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -77,16 +77,19 @@ void Foam::WallSpringSliderDashpot<CloudType>::evaluateWall
const point& site,
const WallSiteData<vector>& data,
scalar pREff,
scalar kN
scalar kN,
bool cohesion
) const
{
vector r_PW = p.position() - site;
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);
@ -94,6 +97,16 @@ void Foam::WallSpringSliderDashpot<CloudType>::evaluateWall
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;
vector USlip_PW =
@ -157,6 +170,11 @@ Foam::WallSpringSliderDashpot<CloudType>::WallSpringSliderDashpot
alpha_(readScalar(this->coeffDict().lookup("alpha"))),
b_(readScalar(this->coeffDict().lookup("b"))),
mu_(readScalar(this->coeffDict().lookup("mu"))),
cohesionEnergyDensity_
(
readScalar(this->coeffDict().lookup("cohesionEnergyDensity"))
),
cohesion_(false),
collisionResolutionSteps_
(
readScalar
@ -183,6 +201,8 @@ Foam::WallSpringSliderDashpot<CloudType>::WallSpringSliderDashpot
Estar_ = 1/((1 - sqr(pNu))/pE + (1 - 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],
flatSiteData[siteI],
pREff,
kN
kN,
cohesion_
);
}
forAll(sharpSitePoints, siteI)
{
// Treating sharp sites like flat sites
// Treating sharp sites like flat sites, except suppress cohesion
evaluateWall
(
@ -280,7 +301,8 @@ void Foam::WallSpringSliderDashpot<CloudType>::evaluateWall
sharpSitePoints[siteI],
sharpSiteData[siteI],
pREff,
kN
kN,
false
);
}
}

View File

@ -65,6 +65,12 @@ class WallSpringSliderDashpot
//- Coefficient of friction in for tangential sliding
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
// harmonic approximation of the collision period
scalar collisionResolutionSteps_;
@ -110,7 +116,8 @@ class WallSpringSliderDashpot
const point& site,
const WallSiteData<vector>& data,
scalar pREff,
scalar kN
scalar kN,
bool cohesion
) const;

View File

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

View File

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

View File

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

View File

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

View File

@ -8,3 +8,6 @@ runApplication setSet -batch wallFilmRegion.setSet
mv log.setSet log.wallFilmRegion.setSet
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 \
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
paraFoam -touch
paraFoam -touch -region wallFilmRegion

View File

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