Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
commit
a0097c43a9
@ -32,7 +32,7 @@
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
export WM_PROJECT=OpenFOAM
|
||||
export WM_PROJECT_VERSION=dev-cvMesh-foghorn
|
||||
export WM_PROJECT_VERSION=dev
|
||||
|
||||
################################################################################
|
||||
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
|
||||
|
@ -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
|
||||
@ -25,6 +25,7 @@ License
|
||||
|
||||
#include "cachedRandom.H"
|
||||
#include "OSspecific.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -142,6 +143,78 @@ Foam::scalar Foam::cachedRandom::position
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::label Foam::cachedRandom::globalSample01()
|
||||
{
|
||||
scalar value = -GREAT;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = scalar01();
|
||||
}
|
||||
|
||||
reduce(value, maxOp<scalar>());
|
||||
|
||||
return round(value);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::cachedRandom::globalSample01()
|
||||
{
|
||||
scalar value = -GREAT;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = scalar01();
|
||||
}
|
||||
|
||||
reduce(value, maxOp<scalar>());
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::label Foam::cachedRandom::globalPosition
|
||||
(
|
||||
const label& start,
|
||||
const label& end
|
||||
)
|
||||
{
|
||||
label value = labelMin;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = round(scalar01()*(end - start));
|
||||
}
|
||||
|
||||
reduce(value, maxOp<label>());
|
||||
|
||||
return start + value;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::cachedRandom::globalPosition
|
||||
(
|
||||
const scalar& start,
|
||||
const scalar& end
|
||||
)
|
||||
{
|
||||
scalar value = -GREAT;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = scalar01()*(end - start);
|
||||
}
|
||||
|
||||
reduce(value, maxOp<scalar>());
|
||||
|
||||
return start + value;
|
||||
}
|
||||
|
||||
|
||||
void Foam::cachedRandom::operator=(const cachedRandom& cr)
|
||||
{
|
||||
seed_ = cr.seed_;
|
||||
|
@ -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
|
||||
@ -121,17 +121,33 @@ public:
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Return a sample whose components lie in the range 0-1
|
||||
template<class Type>
|
||||
Type sample01();
|
||||
// Random numbers
|
||||
//- Return a sample whose components lie in the range 0-1
|
||||
template<class Type>
|
||||
Type sample01();
|
||||
|
||||
//- Return a sample between start and end
|
||||
template<class Type>
|
||||
Type position(const Type& start, const Type& end);
|
||||
//- Return a sample between start and end
|
||||
template<class Type>
|
||||
Type position(const Type& start, const Type& end);
|
||||
|
||||
//- Randomise value in the range 0-1
|
||||
template<class Type>
|
||||
void randomise01(Type& value);
|
||||
//- Randomise value in the range 0-1
|
||||
template<class Type>
|
||||
void randomise01(Type& value);
|
||||
|
||||
|
||||
// Global random numbers - consistent across all processors
|
||||
|
||||
//- Return a sample whose components lie in the range 0-1
|
||||
template<class Type>
|
||||
Type globalSample01();
|
||||
|
||||
//- Return a sample between start and end
|
||||
template<class Type>
|
||||
Type globalPosition(const Type& start, const Type& end);
|
||||
|
||||
//- Randomise value in the range 0-1
|
||||
template<class Type>
|
||||
void globalRandomise01(Type& value);
|
||||
|
||||
|
||||
// Operators
|
||||
@ -160,6 +176,22 @@ scalar cachedRandom::position<scalar>
|
||||
const scalar& end
|
||||
);
|
||||
|
||||
template<>
|
||||
label cachedRandom::globalSample01<label>();
|
||||
|
||||
template<>
|
||||
scalar cachedRandom::globalSample01<scalar>();
|
||||
|
||||
template<>
|
||||
label cachedRandom::globalPosition<label>(const label& start, const label& end);
|
||||
|
||||
template<>
|
||||
scalar cachedRandom::globalPosition<scalar>
|
||||
(
|
||||
const scalar& start,
|
||||
const scalar& end
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
@ -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
|
||||
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "cachedRandom.H"
|
||||
#include "Pstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -61,4 +62,50 @@ void Foam::cachedRandom::randomise01(Type& value)
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::cachedRandom::globalSample01()
|
||||
{
|
||||
Type value = -GREAT*pTraits<Type>::one;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = sample01<Type>();
|
||||
}
|
||||
|
||||
reduce(value, maxOp<Type>());
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::cachedRandom::globalPosition(const Type& start, const Type& end)
|
||||
{
|
||||
Type value = -GREAT*pTraits<Type>::one;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = position<Type>(start, end);
|
||||
}
|
||||
|
||||
reduce(value, maxOp<Type>());
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::cachedRandom::globalRandomise01(Type& value)
|
||||
{
|
||||
value = -GREAT*pTraits<Type>::one;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = sample01<Type>();
|
||||
}
|
||||
|
||||
reduce(value, maxOp<Type>());
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -64,6 +64,11 @@ Foam::scalar Foam::tetOverlapVolume::tetTetOverlapVol
|
||||
tetPointRef::sumVolOp volInside;
|
||||
tetPointRef::dummyOp outside;
|
||||
|
||||
if ((tetA.tet().mag() < SMALL) || (tetB.tet().mag() < SMALL))
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// face0
|
||||
plane pl0(tetB[1], tetB[3], tetB[2]);
|
||||
tetA.tet().sliceWithPlane(pl0, cutInside, outside);
|
||||
|
Loading…
Reference in New Issue
Block a user