change of selctors, cmake config for float compilation
This commit is contained in:
parent
fb3763004d
commit
77408f16af
|
@ -20,6 +20,7 @@ option(USE_STD_PARALLEL_ALG "Use TTB std parallel algorithms" ON)
|
||||||
option(pFlow_Build_Serial "Build phasicFlow and backends for serial execution" OFF)
|
option(pFlow_Build_Serial "Build phasicFlow and backends for serial execution" OFF)
|
||||||
option(pFlow_Build_OpenMP "Build phasicFlow and backends for OpenMP execution" OFF)
|
option(pFlow_Build_OpenMP "Build phasicFlow and backends for OpenMP execution" OFF)
|
||||||
option(pFlow_Build_Cuda "Build phasicFlow and backends for Cuda execution" OFF)
|
option(pFlow_Build_Cuda "Build phasicFlow and backends for Cuda execution" OFF)
|
||||||
|
option(pFlow_Build_Double "Build phasicFlow with double precision variables" ON)
|
||||||
|
|
||||||
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build using shared libraries" FORCE)
|
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build using shared libraries" FORCE)
|
||||||
|
|
||||||
|
|
|
@ -6,3 +6,4 @@
|
||||||
#cmakedefine pFlow_Build_OpenMP
|
#cmakedefine pFlow_Build_OpenMP
|
||||||
#cmakedefine pFlow_Build_Cuda
|
#cmakedefine pFlow_Build_Cuda
|
||||||
#cmakedefine USE_STD_PARALLEL_ALG
|
#cmakedefine USE_STD_PARALLEL_ALG
|
||||||
|
#cmakedefine pFlow_Build_Double
|
|
@ -51,8 +51,9 @@ structuredData/line/line.C
|
||||||
structuredData/zAxis/zAxis.C
|
structuredData/zAxis/zAxis.C
|
||||||
structuredData/pointStructure/pointStructure.C
|
structuredData/pointStructure/pointStructure.C
|
||||||
structuredData/pointStructure/selectors/pStructSelector/pStructSelector.C
|
structuredData/pointStructure/selectors/pStructSelector/pStructSelector.C
|
||||||
structuredData/pointStructure/selectors/boxAll/boxAll.C
|
structuredData/pointStructure/selectors/selectBox/selectBox.C
|
||||||
structuredData/pointStructure/selectors/rangeAll/rangeAll.C
|
structuredData/pointStructure/selectors/selectRange/selectRange.C
|
||||||
|
structuredData/pointStructure/selectors/selectRandom/selectRandom.C
|
||||||
structuredData/trisurfaceStructure/triSurface.C
|
structuredData/trisurfaceStructure/triSurface.C
|
||||||
structuredData/trisurfaceStructure/multiTriSurface.C
|
structuredData/trisurfaceStructure/multiTriSurface.C
|
||||||
structuredData/trisurfaceStructure/stlFile.C
|
structuredData/trisurfaceStructure/stlFile.C
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*------------------------------- phasicFlow ---------------------------------
|
||||||
|
O C enter of
|
||||||
|
O O E ngineering and
|
||||||
|
O O M ultiscale modeling of
|
||||||
|
OOOOOOO F luid flow
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Copyright (C): www.cemf.ir
|
||||||
|
email: hamid.r.norouzi AT gmail.com
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Licence:
|
||||||
|
This file is part of phasicFlow code. It is a free software for simulating
|
||||||
|
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||||
|
the terms of GNU General Public License v3 or any other later versions.
|
||||||
|
|
||||||
|
phasicFlow is distributed to help others in their research in the field of
|
||||||
|
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef __uniformRandomInt32_H__
|
||||||
|
#define __uniformRandomInt32_H__
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
|
||||||
|
#include "types.H"
|
||||||
|
#include "typeInfo.H"
|
||||||
|
|
||||||
|
namespace pFlow
|
||||||
|
{
|
||||||
|
|
||||||
|
class uniformRandomInt32
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
std::mt19937_64 engineGen_;
|
||||||
|
|
||||||
|
std::uniform_int_distribution<int32> distrbution_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// type info
|
||||||
|
TypeNameNV("uniform");
|
||||||
|
|
||||||
|
explicit uniformRandomInt32(int32 min, int32 max)
|
||||||
|
:
|
||||||
|
engineGen_(std::random_device()()),
|
||||||
|
distrbution_(min, max)
|
||||||
|
{}
|
||||||
|
|
||||||
|
~uniformRandomInt32()= default;
|
||||||
|
|
||||||
|
inline real randomNumber()
|
||||||
|
{
|
||||||
|
return distrbution_(engineGen_);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int32x3 randomNumber3()
|
||||||
|
{
|
||||||
|
return int32x3
|
||||||
|
(
|
||||||
|
randomNumber(),
|
||||||
|
randomNumber(),
|
||||||
|
randomNumber()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline realx3 operator()()
|
||||||
|
{
|
||||||
|
return randomNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -19,10 +19,10 @@ Licence:
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#include "boxAll.H"
|
#include "selectBox.H"
|
||||||
|
|
||||||
|
|
||||||
void pFlow::boxAll::selectAllPointsInBox()
|
void pFlow::selectBox::selectAllPointsInBox()
|
||||||
{
|
{
|
||||||
// to reduct allocations
|
// to reduct allocations
|
||||||
selectedPoints_.reserve
|
selectedPoints_.reserve
|
||||||
|
@ -39,7 +39,7 @@ void pFlow::boxAll::selectAllPointsInBox()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::boxAll::boxAll
|
pFlow::selectBox::selectBox
|
||||||
(
|
(
|
||||||
const pointStructure& pStruct,
|
const pointStructure& pStruct,
|
||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
|
@ -51,7 +51,7 @@ pFlow::boxAll::boxAll
|
||||||
),
|
),
|
||||||
box_
|
box_
|
||||||
(
|
(
|
||||||
dict.subDict("boxAllInfo")
|
dict.subDict("selectBoxInfo")
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
selectAllPointsInBox();
|
selectAllPointsInBox();
|
|
@ -19,8 +19,8 @@ Licence:
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __boxAll_H__
|
#ifndef __selectBox_H__
|
||||||
#define __boxAll_H__
|
#define __selectBox_H__
|
||||||
|
|
||||||
#include "pStructSelector.H"
|
#include "pStructSelector.H"
|
||||||
#include "pointStructure.H"
|
#include "pointStructure.H"
|
||||||
|
@ -32,7 +32,7 @@ namespace pFlow
|
||||||
|
|
||||||
class dictionary;
|
class dictionary;
|
||||||
|
|
||||||
class boxAll
|
class selectBox
|
||||||
:
|
:
|
||||||
public pStructSelector
|
public pStructSelector
|
||||||
{
|
{
|
||||||
|
@ -47,19 +47,19 @@ protected:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// - type info
|
// - type info
|
||||||
TypeName("boxAll");
|
TypeName("selectBox");
|
||||||
|
|
||||||
|
|
||||||
boxAll(const pointStructure& pStruct, const dictionary& dict);
|
selectBox(const pointStructure& pStruct, const dictionary& dict);
|
||||||
|
|
||||||
add_vCtor
|
add_vCtor
|
||||||
(
|
(
|
||||||
pStructSelector,
|
pStructSelector,
|
||||||
boxAll,
|
selectBox,
|
||||||
dictionary
|
dictionary
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual ~boxAll() = default;
|
virtual ~selectBox() = default;
|
||||||
|
|
||||||
//// - Methods
|
//// - Methods
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
/*------------------------------- phasicFlow ---------------------------------
|
||||||
|
O C enter of
|
||||||
|
O O E ngineering and
|
||||||
|
O O M ultiscale modeling of
|
||||||
|
OOOOOOO F luid flow
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Copyright (C): www.cemf.ir
|
||||||
|
email: hamid.r.norouzi AT gmail.com
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Licence:
|
||||||
|
This file is part of phasicFlow code. It is a free software for simulating
|
||||||
|
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||||
|
the terms of GNU General Public License v3 or any other later versions.
|
||||||
|
|
||||||
|
phasicFlow is distributed to help others in their research in the field of
|
||||||
|
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "selectRandom.H"
|
||||||
|
#include "dictionary.H"
|
||||||
|
#include "uniformRandomInt32.H"
|
||||||
|
#include "Set.H"
|
||||||
|
|
||||||
|
|
||||||
|
bool pFlow::selectRandom::selectAllPointsInRange()
|
||||||
|
{
|
||||||
|
// to reduct allocations
|
||||||
|
int32 maxNum = number_+1;
|
||||||
|
|
||||||
|
selectedPoints_.reserve (maxNum);
|
||||||
|
|
||||||
|
selectedPoints_.clear();
|
||||||
|
|
||||||
|
uniformRandomInt32 intRand (begin_, end_);
|
||||||
|
|
||||||
|
|
||||||
|
int32 n = 0;
|
||||||
|
int32 iter = 0;
|
||||||
|
bool finished = false;
|
||||||
|
|
||||||
|
Set<int32> selctedIndices;
|
||||||
|
|
||||||
|
while( iter < number_*100)
|
||||||
|
{
|
||||||
|
int32 newInd = intRand.randomNumber();
|
||||||
|
|
||||||
|
if( auto [it, inserted] = selctedIndices.insert(newInd); inserted )
|
||||||
|
{
|
||||||
|
n++;
|
||||||
|
|
||||||
|
if(n == number_)
|
||||||
|
{
|
||||||
|
finished = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(finished)
|
||||||
|
{
|
||||||
|
for(auto& ind:selctedIndices)
|
||||||
|
{
|
||||||
|
selectedPoints_.push_back(ind);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
fatalErrorInFunction<< "Could not find random indices in the range."<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::selectRandom::selectRandom
|
||||||
|
(
|
||||||
|
const pointStructure& pStruct,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
pStructSelector
|
||||||
|
(
|
||||||
|
pStruct, dict
|
||||||
|
),
|
||||||
|
begin_
|
||||||
|
(
|
||||||
|
dict.subDict("selectRandomInfo").getVal<int32>("begin")
|
||||||
|
),
|
||||||
|
end_
|
||||||
|
(
|
||||||
|
dict.subDict("selectRandomInfo").getValOrSet("end", pStruct.size())
|
||||||
|
),
|
||||||
|
number_
|
||||||
|
(
|
||||||
|
dict.subDict("selectRandomInfo").getValOrSet("number", 1)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
begin_ = max(begin_,1);
|
||||||
|
end_ = min(end_, static_cast<int32>(pStruct.size()));
|
||||||
|
number_ = max(number_,0);
|
||||||
|
if(end_-begin_ < number_)
|
||||||
|
{
|
||||||
|
|
||||||
|
warningInFunction<< "In dictionary " << dict.globalName()<<
|
||||||
|
" number is greater than the interval defined by begine and end ["<<
|
||||||
|
begin_<<" "<<end_<<"), resetting it to "<<end_-begin_<<endl;
|
||||||
|
|
||||||
|
number_ = end_-begin_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!selectAllPointsInRange())
|
||||||
|
{
|
||||||
|
fatalExit;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*------------------------------- phasicFlow ---------------------------------
|
||||||
|
O C enter of
|
||||||
|
O O E ngineering and
|
||||||
|
O O M ultiscale modeling of
|
||||||
|
OOOOOOO F luid flow
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Copyright (C): www.cemf.ir
|
||||||
|
email: hamid.r.norouzi AT gmail.com
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Licence:
|
||||||
|
This file is part of phasicFlow code. It is a free software for simulating
|
||||||
|
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||||
|
the terms of GNU General Public License v3 or any other later versions.
|
||||||
|
|
||||||
|
phasicFlow is distributed to help others in their research in the field of
|
||||||
|
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __selectRandom_H__
|
||||||
|
#define __selectRandom_H__
|
||||||
|
|
||||||
|
#include "pStructSelector.H"
|
||||||
|
#include "pointStructure.H"
|
||||||
|
|
||||||
|
|
||||||
|
namespace pFlow
|
||||||
|
{
|
||||||
|
|
||||||
|
class dictionary;
|
||||||
|
|
||||||
|
class selectRandom
|
||||||
|
:
|
||||||
|
public pStructSelector
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
int32Vector selectedPoints_;
|
||||||
|
|
||||||
|
// begin index
|
||||||
|
int32 begin_;
|
||||||
|
|
||||||
|
// end index
|
||||||
|
int32 end_;
|
||||||
|
|
||||||
|
// stride
|
||||||
|
int32 number_;
|
||||||
|
|
||||||
|
bool selectAllPointsInRange();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// - type info
|
||||||
|
TypeName("selectRandom");
|
||||||
|
|
||||||
|
|
||||||
|
selectRandom(const pointStructure& pStruct, const dictionary& dict);
|
||||||
|
|
||||||
|
add_vCtor
|
||||||
|
(
|
||||||
|
pStructSelector,
|
||||||
|
selectRandom,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
|
||||||
|
virtual ~selectRandom() = default;
|
||||||
|
|
||||||
|
//// - Methods
|
||||||
|
|
||||||
|
virtual const int32Vector& selectedPoinsts()const override
|
||||||
|
{
|
||||||
|
return selectedPoints_;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int32Vector& selectedPoinsts() override
|
||||||
|
{
|
||||||
|
return selectedPoints_;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // pFlow
|
||||||
|
|
||||||
|
|
||||||
|
#endif //__pStructSelector_H__
|
|
@ -19,10 +19,10 @@ Licence:
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#include "rangeAll.H"
|
#include "selectRange.H"
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
|
|
||||||
void pFlow::rangeAll::selectAllPointsInRange()
|
void pFlow::selectRange::selectAllPointsInRange()
|
||||||
{
|
{
|
||||||
// to reduct allocations
|
// to reduct allocations
|
||||||
int32 maxNum = (end_ - begin_)/stride_+2;
|
int32 maxNum = (end_ - begin_)/stride_+2;
|
||||||
|
@ -37,7 +37,7 @@ void pFlow::rangeAll::selectAllPointsInRange()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::rangeAll::rangeAll
|
pFlow::selectRange::selectRange
|
||||||
(
|
(
|
||||||
const pointStructure& pStruct,
|
const pointStructure& pStruct,
|
||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
|
@ -49,15 +49,15 @@ pFlow::rangeAll::rangeAll
|
||||||
),
|
),
|
||||||
begin_
|
begin_
|
||||||
(
|
(
|
||||||
dict.subDict("rangeAllInfo").getVal<int32>("begin")
|
dict.subDict("selectRangeInfo").getVal<int32>("begin")
|
||||||
),
|
),
|
||||||
end_
|
end_
|
||||||
(
|
(
|
||||||
dict.subDict("rangeAllInfo").getValOrSet("end", pStruct.size())
|
dict.subDict("selectRangeInfo").getValOrSet("end", pStruct.size())
|
||||||
),
|
),
|
||||||
stride_
|
stride_
|
||||||
(
|
(
|
||||||
dict.subDict("rangeAllInfo").getValOrSet("stride", 1)
|
dict.subDict("selectRangeInfo").getValOrSet("stride", 1)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
begin_ = max(begin_,1);
|
begin_ = max(begin_,1);
|
|
@ -19,8 +19,8 @@ Licence:
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __rangeAll_H__
|
#ifndef __selectRange_H__
|
||||||
#define __rangeAll_H__
|
#define __selectRange_H__
|
||||||
|
|
||||||
#include "pStructSelector.H"
|
#include "pStructSelector.H"
|
||||||
#include "pointStructure.H"
|
#include "pointStructure.H"
|
||||||
|
@ -31,7 +31,7 @@ namespace pFlow
|
||||||
|
|
||||||
class dictionary;
|
class dictionary;
|
||||||
|
|
||||||
class rangeAll
|
class selectRange
|
||||||
:
|
:
|
||||||
public pStructSelector
|
public pStructSelector
|
||||||
{
|
{
|
||||||
|
@ -53,19 +53,19 @@ protected:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// - type info
|
// - type info
|
||||||
TypeName("rangeAll");
|
TypeName("selectRange");
|
||||||
|
|
||||||
|
|
||||||
rangeAll(const pointStructure& pStruct, const dictionary& dict);
|
selectRange(const pointStructure& pStruct, const dictionary& dict);
|
||||||
|
|
||||||
add_vCtor
|
add_vCtor
|
||||||
(
|
(
|
||||||
pStructSelector,
|
pStructSelector,
|
||||||
rangeAll,
|
selectRange,
|
||||||
dictionary
|
dictionary
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual ~rangeAll() = default;
|
virtual ~selectRange() = default;
|
||||||
|
|
||||||
//// - Methods
|
//// - Methods
|
||||||
|
|
|
@ -23,11 +23,16 @@ Licence:
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "phasicFlowConfig.H"
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
#define useDouble 1
|
#ifdef pFlow_Build_Double
|
||||||
|
#define useDouble 1
|
||||||
|
#else
|
||||||
|
#define useDouble 0
|
||||||
|
#endif
|
||||||
|
|
||||||
// scalars
|
// scalars
|
||||||
#if useDouble
|
#if useDouble
|
||||||
|
@ -36,7 +41,7 @@ namespace pFlow
|
||||||
using real = float;
|
using real = float;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using int8 = signed char;
|
using int8 = signed char;
|
||||||
|
|
||||||
using int16 = short int;
|
using int16 = short int;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue