mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -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
|
||||||
|
|||||||
@ -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_;
|
||||||
|
|||||||
@ -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,17 +121,33 @@ public:
|
|||||||
|
|
||||||
// Evaluation
|
// Evaluation
|
||||||
|
|
||||||
//- Return a sample whose components lie in the range 0-1
|
// Random numbers
|
||||||
template<class Type>
|
//- Return a sample whose components lie in the range 0-1
|
||||||
Type sample01();
|
template<class Type>
|
||||||
|
Type sample01();
|
||||||
|
|
||||||
//- Return a sample between start and end
|
//- Return a sample between start and end
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Type position(const Type& start, const Type& end);
|
Type position(const Type& start, const Type& end);
|
||||||
|
|
||||||
//- Randomise value in the range 0-1
|
//- Randomise value in the range 0-1
|
||||||
template<class Type>
|
template<class Type>
|
||||||
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
|
||||||
@ -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
|
||||||
|
|||||||
@ -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>());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user