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

This commit is contained in:
laurence
2013-06-04 14:39:29 +01:00
5 changed files with 170 additions and 13 deletions

View File

@ -32,7 +32,7 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
export WM_PROJECT=OpenFOAM 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 # USER EDITABLE PART: Changes made here may be lost with the next upgrade

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
@ -25,6 +25,7 @@ License
#include "cachedRandom.H" #include "cachedRandom.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "PstreamReduceOps.H"
// * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * 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) void Foam::cachedRandom::operator=(const cachedRandom& cr)
{ {
seed_ = cr.seed_; seed_ = cr.seed_;

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
@ -121,6 +121,7 @@ public:
// Evaluation // Evaluation
// Random numbers
//- Return a sample whose components lie in the range 0-1 //- Return a sample whose components lie in the range 0-1
template<class Type> template<class Type>
Type sample01(); Type sample01();
@ -134,6 +135,21 @@ public:
void randomise01(Type& value); 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 // Operators
//- Assignment operator //- Assignment operator
@ -160,6 +176,22 @@ scalar cachedRandom::position<scalar>
const scalar& end 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 } // 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) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "cachedRandom.H" #include "cachedRandom.H"
#include "Pstream.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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>());
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -64,6 +64,11 @@ Foam::scalar Foam::tetOverlapVolume::tetTetOverlapVol
tetPointRef::sumVolOp volInside; tetPointRef::sumVolOp volInside;
tetPointRef::dummyOp outside; tetPointRef::dummyOp outside;
if ((tetA.tet().mag() < SMALL) || (tetB.tet().mag() < SMALL))
{
return 0.0;
}
// face0 // face0
plane pl0(tetB[1], tetB[3], tetB[2]); plane pl0(tetB[1], tetB[3], tetB[2]);
tetA.tet().sliceWithPlane(pl0, cutInside, outside); tetA.tet().sliceWithPlane(pl0, cutInside, outside);