mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-07-08 03:07:03 +00:00
code refactor upto pointFields and insertion etc.
This commit is contained in:
@ -56,18 +56,14 @@ containers/Field/Fields.cpp
|
|||||||
containers/List/anyList/anyList.cpp
|
containers/List/anyList/anyList.cpp
|
||||||
containers/pointField/pointFields.cpp
|
containers/pointField/pointFields.cpp
|
||||||
|
|
||||||
#setFieldList/setFieldList.cpp
|
setFieldList/setFieldList.cpp
|
||||||
#setFieldList/setFieldEntry.cpp
|
setFieldList/setFieldEntry.cpp
|
||||||
|
|
||||||
Timer/Timer.cpp
|
Timer/Timer.cpp
|
||||||
Timer/Timers.cpp
|
Timer/Timers.cpp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
structuredData/box/box.cpp
|
structuredData/box/box.cpp
|
||||||
structuredData/line/line.cpp
|
structuredData/line/line.cpp
|
||||||
structuredData/infinitePlane/infinitePlane.cpp
|
structuredData/infinitePlane/infinitePlane.cpp
|
||||||
@ -81,6 +77,10 @@ structuredData/boundaries/boundaryBase/boundaryBase.cpp
|
|||||||
structuredData/boundaries/boundaryExit/boundaryExit.cpp
|
structuredData/boundaries/boundaryExit/boundaryExit.cpp
|
||||||
structuredData/boundaries/boundaryNone/boundaryNone.cpp
|
structuredData/boundaries/boundaryNone/boundaryNone.cpp
|
||||||
structuredData/pointStructure/boundaryList.cpp
|
structuredData/pointStructure/boundaryList.cpp
|
||||||
|
structuredData/pointStructure/selectors/pStructSelector/pStructSelector.cpp
|
||||||
|
structuredData/pointStructure/selectors/selectBox/selectBox.cpp
|
||||||
|
structuredData/pointStructure/selectors/selectRange/selectRange.cpp
|
||||||
|
structuredData/pointStructure/selectors/selectRandom/selectRandom.cpp
|
||||||
|
|
||||||
commandLine/commandLine.cpp
|
commandLine/commandLine.cpp
|
||||||
|
|
||||||
|
@ -158,20 +158,6 @@ public:
|
|||||||
/// Move assignment
|
/// Move assignment
|
||||||
FieldType& operator = (FieldType&&) = default;
|
FieldType& operator = (FieldType&&) = default;
|
||||||
|
|
||||||
/// clone as a uniquePtr
|
|
||||||
INLINE_FUNCTION_H
|
|
||||||
uniquePtr<FieldType> clone() const
|
|
||||||
{
|
|
||||||
return makeUnique<FieldType>(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// clone as a raw pointer
|
|
||||||
INLINE_FUNCTION_H
|
|
||||||
FieldType* clonePtr()const
|
|
||||||
{
|
|
||||||
return new FieldType(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//// - Methods
|
//// - Methods
|
||||||
|
|
||||||
/// return field key
|
/// return field key
|
||||||
@ -185,6 +171,12 @@ public:
|
|||||||
return VectorType::name();
|
return VectorType::name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void fillField(rangeU32 span, const T& val)
|
||||||
|
{
|
||||||
|
this->fill(span, val);
|
||||||
|
}
|
||||||
|
|
||||||
//// - IO operations
|
//// - IO operations
|
||||||
|
|
||||||
bool read(iIstream& is);
|
bool read(iIstream& is);
|
||||||
|
@ -39,8 +39,12 @@ class ListPtr
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
using ListPtrType = ListPtr<T> ;
|
using ListPtrType = ListPtr<T> ;
|
||||||
|
|
||||||
using listType = std::list<T*>;
|
using listType = std::list<T*>;
|
||||||
|
|
||||||
|
using iterator = typename listType::iterator;
|
||||||
|
|
||||||
|
using const_iterator = typename listType::const_iterator;
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
inline static uniquePtr<T> makeSafe(Args&&... args)
|
inline static uniquePtr<T> makeSafe(Args&&... args)
|
||||||
@ -183,7 +187,25 @@ public:
|
|||||||
// - clear the ith element
|
// - clear the ith element
|
||||||
void clear(size_t i);
|
void clear(size_t i);
|
||||||
|
|
||||||
// - clone the object
|
iterator begin()
|
||||||
|
{
|
||||||
|
return list_.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
const_iterator begin()const
|
||||||
|
{
|
||||||
|
return list_.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
iterator end()
|
||||||
|
{
|
||||||
|
return list_.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
const_iterator end()const
|
||||||
|
{
|
||||||
|
return list_.end();
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ Licence:
|
|||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
#include "types.hpp"
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -30,6 +32,9 @@ namespace pFlow
|
|||||||
template<typename Key>
|
template<typename Key>
|
||||||
using Set = std::set<Key,std::less<Key>,std::allocator<Key>>;
|
using Set = std::set<Key,std::less<Key>,std::allocator<Key>>;
|
||||||
|
|
||||||
|
using wordSet = Set<word>;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -351,6 +351,17 @@ void pFlow::VectorSingle<T,MemorySpace>::fill(const T& val)
|
|||||||
pFlow::fill(view_, rangeU32(0 ,size_) ,val);
|
pFlow::fill(view_, rangeU32(0 ,size_) ,val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T, typename MemorySpace>
|
||||||
|
INLINE_FUNCTION_H
|
||||||
|
void pFlow::VectorSingle<T,MemorySpace>::fill
|
||||||
|
(
|
||||||
|
rangeU32 r,
|
||||||
|
const T& val
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pFlow::fill(view_, r, val);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, typename MemorySpace>
|
template<typename T, typename MemorySpace>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H
|
||||||
void pFlow::VectorSingle<T,MemorySpace>::assign
|
void pFlow::VectorSingle<T,MemorySpace>::assign
|
||||||
@ -494,7 +505,7 @@ bool pFlow::VectorSingle<T,MemorySpace>::insertSetElement
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(indices.size() == 0)return true;
|
if(indices.empty())return true;
|
||||||
if(indices.size() != vals.size())return false;
|
if(indices.size() != vals.size())return false;
|
||||||
|
|
||||||
auto maxInd = indices.max();
|
auto maxInd = indices.max();
|
||||||
@ -518,9 +529,7 @@ bool pFlow::VectorSingle<T,MemorySpace>::insertSetElement
|
|||||||
Kokkos::parallel_for(
|
Kokkos::parallel_for(
|
||||||
"VectorSingle::insertSetElement",
|
"VectorSingle::insertSetElement",
|
||||||
policy(0,indices.size()), LAMBDA_HD(int32 i){
|
policy(0,indices.size()), LAMBDA_HD(int32 i){
|
||||||
dVec(ind(i))= dVals(i);}
|
dVec(ind(i))= dVals(i);});
|
||||||
);
|
|
||||||
|
|
||||||
Kokkos::fence();
|
Kokkos::fence();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -532,9 +541,7 @@ bool pFlow::VectorSingle<T,MemorySpace>::insertSetElement
|
|||||||
Kokkos::parallel_for(
|
Kokkos::parallel_for(
|
||||||
"VectorSingle::insertSetElement",
|
"VectorSingle::insertSetElement",
|
||||||
policy(0,indices.size()), LAMBDA_HD(int32 i){
|
policy(0,indices.size()), LAMBDA_HD(int32 i){
|
||||||
dVec(ind(i))= hVals(i);}
|
dVec(ind(i))= hVals(i);});
|
||||||
);
|
|
||||||
|
|
||||||
Kokkos::fence();
|
Kokkos::fence();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -542,6 +549,57 @@ bool pFlow::VectorSingle<T,MemorySpace>::insertSetElement
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T, typename MemorySpace>
|
||||||
|
INLINE_FUNCTION_H
|
||||||
|
bool pFlow::VectorSingle<T,MemorySpace>::insertSetElement
|
||||||
|
(
|
||||||
|
uint32IndexContainer indices,
|
||||||
|
const ViewType1D<T, memory_space> vals
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(indices.empty())return true;
|
||||||
|
if(indices.size() != vals.size())return false;
|
||||||
|
|
||||||
|
auto maxInd = indices.max();
|
||||||
|
|
||||||
|
if(this->empty() || maxInd > size()-1 )
|
||||||
|
{
|
||||||
|
resize(maxInd+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
using policy = Kokkos::RangePolicy<
|
||||||
|
execution_space,
|
||||||
|
Kokkos::IndexType<uint32>>;
|
||||||
|
|
||||||
|
if constexpr( isDeviceAccessible_ )
|
||||||
|
{
|
||||||
|
auto dVec = view_;
|
||||||
|
auto dVals = vals;
|
||||||
|
auto ind = indices.deviceView();
|
||||||
|
|
||||||
|
Kokkos::parallel_for(
|
||||||
|
"VectorSingle::insertSetElement",
|
||||||
|
policy(0,indices.size()), LAMBDA_HD(int32 i){
|
||||||
|
dVec(ind(i))= dVals(i);});
|
||||||
|
Kokkos::fence();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto dVec = view_;
|
||||||
|
auto hVals = vals;
|
||||||
|
auto ind = indices.hostView();
|
||||||
|
|
||||||
|
Kokkos::parallel_for(
|
||||||
|
"VectorSingle::insertSetElement",
|
||||||
|
policy(0,indices.size()), LAMBDA_HD(int32 i){
|
||||||
|
dVec(ind(i))= hVals(i);});
|
||||||
|
Kokkos::fence();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, typename MemorySpace>
|
template<typename T, typename MemorySpace>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H
|
||||||
|
@ -257,6 +257,9 @@ public:
|
|||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H
|
||||||
void fill(const T& val);
|
void fill(const T& val);
|
||||||
|
|
||||||
|
INLINE_FUNCTION_H
|
||||||
|
void fill(rangeU32 r, const T& val);
|
||||||
|
|
||||||
/// Change size of the vector and assign val to vector and
|
/// Change size of the vector and assign val to vector and
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H
|
||||||
void assign(size_t n, const T& val);
|
void assign(size_t n, const T& val);
|
||||||
@ -291,6 +294,11 @@ public:
|
|||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H
|
||||||
bool insertSetElement(uint32IndexContainer indices, const std::vector<T>& vals);
|
bool insertSetElement(uint32IndexContainer indices, const std::vector<T>& vals);
|
||||||
|
|
||||||
|
INLINE_FUNCTION_H
|
||||||
|
bool insertSetElement(
|
||||||
|
uint32IndexContainer indices,
|
||||||
|
const ViewType1D<T, memory_space> vals);
|
||||||
|
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H
|
||||||
bool reorderItems(uint32IndexContainer indices);
|
bool reorderItems(uint32IndexContainer indices);
|
||||||
|
|
||||||
|
@ -21,8 +21,6 @@ Licence:
|
|||||||
#define __VectorSingleMath_hpp__
|
#define __VectorSingleMath_hpp__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -51,8 +49,6 @@ INLINE_FUNCTION_H T max( const VectorSingle<T, MemorySpace>& vec)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ pFlow::boundaryField<T, MemorySpace>::boundaryField
|
|||||||
InternalFieldType& internal
|
InternalFieldType& internal
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
observer(),
|
observer(&boundary, defaultMessage_),
|
||||||
boundary_(boundary),
|
boundary_(boundary),
|
||||||
internal_(internal)
|
internal_(internal)
|
||||||
{}
|
{}
|
||||||
|
@ -49,6 +49,15 @@ protected:
|
|||||||
/// @brief a ref to the internal field
|
/// @brief a ref to the internal field
|
||||||
InternalFieldType& internal_;
|
InternalFieldType& internal_;
|
||||||
|
|
||||||
|
static inline
|
||||||
|
const message defaultMessage_ =
|
||||||
|
(
|
||||||
|
message::CAP_CHANGED+
|
||||||
|
message::SIZE_CHANGED+
|
||||||
|
message::ITEM_INSERT+
|
||||||
|
message::ITEM_DELETE
|
||||||
|
);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TypeInfo("boundaryField<none>");
|
TypeInfo("boundaryField<none>");
|
||||||
@ -79,6 +88,9 @@ public:
|
|||||||
|
|
||||||
bool hearChanges
|
bool hearChanges
|
||||||
(
|
(
|
||||||
|
real t,
|
||||||
|
real dt,
|
||||||
|
uint32 iter,
|
||||||
const message& msg,
|
const message& msg,
|
||||||
const anyList& varList
|
const anyList& varList
|
||||||
) override
|
) override
|
||||||
@ -97,6 +109,12 @@ public:
|
|||||||
return boundary_.capacity();
|
return boundary_.capacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual
|
||||||
|
void fill(const T& val)
|
||||||
|
{
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
uniquePtr<boundaryField> create(
|
uniquePtr<boundaryField> create(
|
||||||
const boundaryBase& boundary,
|
const boundaryBase& boundary,
|
||||||
|
@ -60,6 +60,14 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fill(const T& val)
|
||||||
|
{
|
||||||
|
for(auto& bf: *this)
|
||||||
|
{
|
||||||
|
bf->fill(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,9 @@ public:
|
|||||||
|
|
||||||
bool hearChanges
|
bool hearChanges
|
||||||
(
|
(
|
||||||
|
real t,
|
||||||
|
real dt,
|
||||||
|
uint32 iter,
|
||||||
const message& msg,
|
const message& msg,
|
||||||
const anyList& varList
|
const anyList& varList
|
||||||
) override
|
) override
|
||||||
|
@ -64,7 +64,7 @@ pFlow::internalField<T, MemorySpace>::internalField
|
|||||||
),
|
),
|
||||||
internalPoints_(internal)
|
internalPoints_(internal)
|
||||||
{
|
{
|
||||||
field_.fill(val);
|
fillInternal(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,7 +139,26 @@ public:
|
|||||||
return internalPoints_.isAllActive();
|
return internalPoints_.isAllActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hearChanges(const message& msg, const anyList& varList) override
|
inline
|
||||||
|
void fillInternal(const T& val)
|
||||||
|
{
|
||||||
|
field_.fillField(activeRange(), val);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
bool insertSetElement(uint32IndexContainer indices, const T& val)
|
||||||
|
{
|
||||||
|
return field_.insertSetElement(indices, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hearChanges
|
||||||
|
(
|
||||||
|
real t,
|
||||||
|
real dt,
|
||||||
|
uint32 iter,
|
||||||
|
const message& msg,
|
||||||
|
const anyList& varList
|
||||||
|
) override
|
||||||
{
|
{
|
||||||
notImplementedFunction;
|
notImplementedFunction;
|
||||||
return false;
|
return false;
|
||||||
@ -171,5 +190,6 @@ iOstream& operator<<
|
|||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
||||||
#include "internalField.cpp"
|
#include "internalField.cpp"
|
||||||
|
#include "internalFieldAlgorithms.hpp"
|
||||||
|
|
||||||
#endif // __internalField_hpp__
|
#endif // __internalField_hpp__
|
205
src/phasicFlow/containers/pointField/internalFieldAlgorithms.hpp
Normal file
205
src/phasicFlow/containers/pointField/internalFieldAlgorithms.hpp
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
/*------------------------------- 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 __internalFieldAlgorithms_hpp__
|
||||||
|
#define __internalFieldAlgorithms_hpp__
|
||||||
|
|
||||||
|
namespace pFlow
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class T, class MemorySpace>
|
||||||
|
inline
|
||||||
|
T min(const internalField<T,MemorySpace>& iField)
|
||||||
|
{
|
||||||
|
using exeSpace = typename internalField<T,MemorySpace>::execution_space;
|
||||||
|
|
||||||
|
using policy = Kokkos::RangePolicy<
|
||||||
|
exeSpace,
|
||||||
|
Kokkos::IndexType<uint32> >;
|
||||||
|
|
||||||
|
if constexpr(isDeviceAccessible<exeSpace>())
|
||||||
|
{
|
||||||
|
// this is a device view
|
||||||
|
auto maskD = iField.activePointsMaskDevice();
|
||||||
|
auto aRange = maskD.activeRange();
|
||||||
|
auto filed = iField.field().deviceVectorAll();
|
||||||
|
|
||||||
|
T minElement;
|
||||||
|
|
||||||
|
Kokkos::parallel_reduce(
|
||||||
|
"min(internalField)",
|
||||||
|
policy(aRange.start(), aRange.end() ),
|
||||||
|
LAMBDA_HD(uint32 i, T& minUpdate)
|
||||||
|
{
|
||||||
|
if( maskD(i) )
|
||||||
|
if(filed[i] < minUpdate) minUpdate = filed[i];
|
||||||
|
},
|
||||||
|
Kokkos::Min<T>(minElement));
|
||||||
|
return minElement;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// this is a host view
|
||||||
|
auto maskH = iField.activePointsMaskHost();
|
||||||
|
auto aRange = maskH.activeRange();
|
||||||
|
auto filed = iField.field().deviceVectorAll();
|
||||||
|
T minElement;
|
||||||
|
Kokkos::parallel_reduce(
|
||||||
|
"min(internalField)",
|
||||||
|
policy(aRange.start(), aRange.end()),
|
||||||
|
LAMBDA_HD(uint32 i, T& minUpdate)
|
||||||
|
{
|
||||||
|
if( maskH(i) )
|
||||||
|
if(filed[i] < minUpdate) minUpdate = filed[i];
|
||||||
|
},
|
||||||
|
Kokkos::Min<T>(minElement));
|
||||||
|
|
||||||
|
return minElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, class MemorySpace>
|
||||||
|
inline
|
||||||
|
T max(const internalField<T,MemorySpace>& iField)
|
||||||
|
{
|
||||||
|
using exeSpace = typename internalField<T,MemorySpace>::execution_space;
|
||||||
|
|
||||||
|
using policy = Kokkos::RangePolicy<
|
||||||
|
exeSpace,
|
||||||
|
Kokkos::IndexType<uint32> >;
|
||||||
|
|
||||||
|
if constexpr(isDeviceAccessible<exeSpace>())
|
||||||
|
{
|
||||||
|
// this is a device view
|
||||||
|
auto maskD = iField.activePointsMaskDevice();
|
||||||
|
auto aRange = maskD.activeRange();
|
||||||
|
auto filed = iField.field().deviceVectorAll();
|
||||||
|
|
||||||
|
T maxElement;
|
||||||
|
|
||||||
|
Kokkos::parallel_reduce(
|
||||||
|
"max(internalField)",
|
||||||
|
policy(aRange.start(), aRange.end() ),
|
||||||
|
LAMBDA_HD(uint32 i, T& maxUpdate)
|
||||||
|
{
|
||||||
|
if( maskD(i) )
|
||||||
|
if( maxUpdate <filed[i]) maxUpdate = filed[i];
|
||||||
|
},
|
||||||
|
Kokkos::Max<T>(maxElement));
|
||||||
|
return maxElement;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// this is a host view
|
||||||
|
auto maskH = iField.activePointsMaskHost();
|
||||||
|
auto aRange = maskH.activeRange();
|
||||||
|
auto filed = iField.field().deviceVectorAll();
|
||||||
|
|
||||||
|
T maxElement;
|
||||||
|
|
||||||
|
Kokkos::parallel_reduce(
|
||||||
|
"max(internalField)",
|
||||||
|
policy(aRange.start(), aRange.end() ),
|
||||||
|
LAMBDA_HD(uint32 i, T& maxUpdate)
|
||||||
|
{
|
||||||
|
if( maskH(i) )
|
||||||
|
if( maxUpdate <filed[i]) maxUpdate = filed[i];
|
||||||
|
},
|
||||||
|
Kokkos::Max<T>(maxElement));
|
||||||
|
return maxElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class MemorySpace>
|
||||||
|
inline
|
||||||
|
Pair<T,T> minMax(const internalField<T,MemorySpace>& iField)
|
||||||
|
{
|
||||||
|
using exeSpace = typename internalField<T,MemorySpace>::execution_space;
|
||||||
|
|
||||||
|
using policy = Kokkos::RangePolicy<
|
||||||
|
exeSpace,
|
||||||
|
Kokkos::IndexType<uint32> >;
|
||||||
|
|
||||||
|
if constexpr(isDeviceAccessible<exeSpace>())
|
||||||
|
{
|
||||||
|
// this is a device view
|
||||||
|
auto maskD = iField.activePointsMaskDevice();
|
||||||
|
auto aRange = maskD.activeRange();
|
||||||
|
auto filed = iField.field().deviceVectorAll();
|
||||||
|
|
||||||
|
T minElement;
|
||||||
|
T maxElement;
|
||||||
|
|
||||||
|
Kokkos::parallel_reduce(
|
||||||
|
"minMax(internalField)",
|
||||||
|
policy(aRange.start(), aRange.end() ),
|
||||||
|
LAMBDA_HD(uint32 i, T& minUpdate, T& maxUpdate)
|
||||||
|
{
|
||||||
|
if( maskD(i) )
|
||||||
|
{
|
||||||
|
if(maxUpdate < filed[i]) maxUpdate = filed[i];
|
||||||
|
if(filed[i] < minUpdate) minUpdate = filed[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
Kokkos::Min<T>(minElement),
|
||||||
|
Kokkos::Max<T>(maxElement)
|
||||||
|
);
|
||||||
|
return {minElement, maxElement};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// this is a host view
|
||||||
|
auto maskH = iField.activePointsMaskHost();
|
||||||
|
auto aRange = maskH.activeRange();
|
||||||
|
auto filed = iField.field().deviceVectorAll();
|
||||||
|
|
||||||
|
T minElement;
|
||||||
|
T maxElement;
|
||||||
|
|
||||||
|
Kokkos::parallel_reduce(
|
||||||
|
"minMax(internalField)",
|
||||||
|
policy(aRange.start(), aRange.end() ),
|
||||||
|
LAMBDA_HD(uint32 i, T& minUpdate, T& maxUpdate)
|
||||||
|
{
|
||||||
|
if( maskH(i) )
|
||||||
|
{
|
||||||
|
if(maxUpdate < filed[i]) maxUpdate = filed[i];
|
||||||
|
if(filed[i] < minUpdate) minUpdate = filed[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
Kokkos::Min<T>(minElement),
|
||||||
|
Kokkos::Max<T>(maxElement)
|
||||||
|
);
|
||||||
|
return {minElement, maxElement};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -93,77 +93,26 @@ public:
|
|||||||
const T& defVal,
|
const T& defVal,
|
||||||
const T& val);
|
const T& val);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//// - Methods
|
||||||
|
|
||||||
const auto& internal()const
|
const auto& internal()const
|
||||||
{
|
{
|
||||||
return static_cast<const InternalFieldType&>(*this);
|
return static_cast<const InternalFieldType&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - construct from iIOEntity, pointStructure and a value
|
|
||||||
/*pointField( const pointStructure& pStruct, const T& val, const T& defVal, bool subscribe = true);
|
|
||||||
|
|
||||||
// - construct from another pointField
|
|
||||||
// subscribe to events if true
|
|
||||||
pointField( const pointField& src, bool subscribe);
|
|
||||||
|
|
||||||
|
|
||||||
// - copy construct
|
|
||||||
pointField(const pointField& src);
|
|
||||||
|
|
||||||
// - no move construct
|
|
||||||
pointField(pointField&& src) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
// assignment, only assign the VectorField and preserve other parts of this
|
|
||||||
pointField& operator = (const pointField& rhs);
|
|
||||||
|
|
||||||
// no move assignment
|
|
||||||
pointField& operator = (pointField&&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
inline uniquePtr<pointFieldType> clone() const
|
|
||||||
{
|
|
||||||
return makeUnique<pointFieldType>(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline pointFieldType* clonePtr()const
|
|
||||||
{
|
|
||||||
return new pointFieldType(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//// - Methods
|
|
||||||
|
|
||||||
// - reference to pointStructure
|
// - reference to pointStructure
|
||||||
inline const pointStructure& pStruct()const {
|
inline const pointStructure& pStruct()const {
|
||||||
return pStruct_;
|
return pStruct_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if all points are active
|
void fill(const T& val)
|
||||||
INLINE_FUNCTION_H
|
|
||||||
bool allActive()const {
|
|
||||||
return pStruct_.allActive();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_FUNCTION_H
|
|
||||||
bool isActive(label i)const {
|
|
||||||
return pStruct_.isActive(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& pointFlag()const
|
|
||||||
{
|
{
|
||||||
return pStruct_.pointFlag();
|
InternalFieldType::fillInternal(val);
|
||||||
|
boundaryFieldList_.fill(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
range activeRange()const
|
|
||||||
{
|
|
||||||
return pStruct_.activeRange();
|
|
||||||
}
|
|
||||||
|
|
||||||
// - update the field if any changes occure in pStruct
|
|
||||||
// for now it checks for deleted points
|
|
||||||
bool update(const eventMessage& msg);*/
|
|
||||||
|
|
||||||
|
|
||||||
//// - IO operations
|
//// - IO operations
|
||||||
bool readPointField(iIstream& is, const IOPattern& iop);
|
bool readPointField(iIstream& is, const IOPattern& iop);
|
||||||
|
|
||||||
|
@ -31,6 +31,31 @@ template class pFlow::pointField<pFlow::int8>;
|
|||||||
createBaseBoundary(pFlow::int8, void);
|
createBaseBoundary(pFlow::int8, void);
|
||||||
createBoundary(pFlow::int8, void, exit);
|
createBoundary(pFlow::int8, void, exit);
|
||||||
|
|
||||||
|
|
||||||
|
template class pFlow::pointField<pFlow::uint8, pFlow::HostSpace>;
|
||||||
|
createBaseBoundary(pFlow::uint8, pFlow::HostSpace);
|
||||||
|
createBoundary(pFlow::uint8, pFlow::HostSpace, exit);
|
||||||
|
|
||||||
|
template class pFlow::pointField<pFlow::uint8>;
|
||||||
|
createBaseBoundary(pFlow::uint8, void);
|
||||||
|
createBoundary(pFlow::uint8, void, exit);
|
||||||
|
|
||||||
|
template class pFlow::pointField<pFlow::int32, pFlow::HostSpace>;
|
||||||
|
createBaseBoundary(pFlow::int32, pFlow::HostSpace);
|
||||||
|
createBoundary(pFlow::int32, pFlow::HostSpace, exit);
|
||||||
|
|
||||||
|
template class pFlow::pointField<pFlow::int32>;
|
||||||
|
createBaseBoundary(pFlow::int32, void);
|
||||||
|
createBoundary(pFlow::int32, void, exit);
|
||||||
|
|
||||||
|
template class pFlow::pointField<pFlow::uint32, pFlow::HostSpace>;
|
||||||
|
createBaseBoundary(pFlow::uint32, pFlow::HostSpace);
|
||||||
|
createBoundary(pFlow::uint32, pFlow::HostSpace, exit);
|
||||||
|
|
||||||
|
template class pFlow::pointField<pFlow::uint32>;
|
||||||
|
createBaseBoundary(pFlow::uint32, void);
|
||||||
|
createBoundary(pFlow::uint32, void, exit);
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::real, pFlow::HostSpace>;
|
template class pFlow::pointField<pFlow::real, pFlow::HostSpace>;
|
||||||
createBaseBoundary(pFlow::real, pFlow::HostSpace);
|
createBaseBoundary(pFlow::real, pFlow::HostSpace);
|
||||||
createBoundary(pFlow::real, pFlow::HostSpace, exit);
|
createBoundary(pFlow::real, pFlow::HostSpace, exit);
|
||||||
@ -40,36 +65,25 @@ template class pFlow::pointField<pFlow::real>;
|
|||||||
createBaseBoundary(pFlow::real, void);
|
createBaseBoundary(pFlow::real, void);
|
||||||
createBoundary(pFlow::real, void, exit);
|
createBoundary(pFlow::real, void, exit);
|
||||||
|
|
||||||
|
template class pFlow::pointField<pFlow::realx3, pFlow::HostSpace>;
|
||||||
/*template class pFlow::pointField<pFlow::VectorSingle, pFlow::int8, pFlow::HostSpace>;
|
createBaseBoundary(pFlow::realx3, pFlow::HostSpace);
|
||||||
|
createBoundary(pFlow::realx3, pFlow::HostSpace, exit);
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::int16>;
|
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::int16, pFlow::HostSpace>;
|
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::int32>;
|
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::int32, pFlow::HostSpace>;
|
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::int64>;
|
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::int64, pFlow::HostSpace>;
|
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::uint32>;
|
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::uint32, pFlow::HostSpace>;
|
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::label>;
|
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::label, pFlow::HostSpace>;
|
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::real>;
|
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::real, pFlow::HostSpace>;
|
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::realx3>;
|
|
||||||
|
|
||||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::realx3, pFlow::HostSpace>;*/
|
|
||||||
|
|
||||||
|
|
||||||
|
template class pFlow::pointField<pFlow::realx3>;
|
||||||
|
createBaseBoundary(pFlow::realx3, void);
|
||||||
|
createBoundary(pFlow::realx3, void, exit);
|
||||||
|
|
||||||
|
|
||||||
|
template class pFlow::pointField<pFlow::realx4, pFlow::HostSpace>;
|
||||||
|
createBaseBoundary(pFlow::realx4, pFlow::HostSpace);
|
||||||
|
createBoundary(pFlow::realx4, pFlow::HostSpace, exit);
|
||||||
|
|
||||||
|
|
||||||
|
template class pFlow::pointField<pFlow::realx4>;
|
||||||
|
createBaseBoundary(pFlow::realx4, void);
|
||||||
|
createBoundary(pFlow::realx4, void, exit);
|
||||||
|
|
||||||
|
template class pFlow::pointField<pFlow::word, pFlow::HostSpace>;
|
||||||
|
createBaseBoundary(pFlow::word, pFlow::HostSpace);
|
||||||
|
createBoundary(pFlow::word, pFlow::HostSpace, exit);
|
@ -49,14 +49,11 @@ using uint32PointField_D = pointField_D<uint32>;
|
|||||||
using uint32PointField_H = pointField_H<uint32>;
|
using uint32PointField_H = pointField_H<uint32>;
|
||||||
|
|
||||||
using int64PointField_D = pointField_D<int64>;
|
using int64PointField_D = pointField_D<int64>;
|
||||||
using int63PointField_H = pointField_H<int64>;
|
using int64PointField_H = pointField_H<int64>;
|
||||||
|
|
||||||
using uint64PointField_D = pointField_D<uint64>;
|
using uint64PointField_D = pointField_D<uint64>;
|
||||||
using uint64PointField_H = pointField_H<uint64>;
|
using uint64PointField_H = pointField_H<uint64>;
|
||||||
|
|
||||||
using int32PointField_D = pointField_D<int32>;
|
|
||||||
using int32PointField_H = pointField_H<int32>;
|
|
||||||
|
|
||||||
using realPointField_D = pointField_D<real>;
|
using realPointField_D = pointField_D<real>;
|
||||||
using realPointField_H = pointField_H<real>;
|
using realPointField_H = pointField_H<real>;
|
||||||
|
|
||||||
@ -66,9 +63,7 @@ using realx3PointField_H = pointField_H<realx3>;
|
|||||||
using realx4PointField_D = pointField_D<realx4>;
|
using realx4PointField_D = pointField_D<realx4>;
|
||||||
using realx4PointField_H = pointField_H<realx4>;
|
using realx4PointField_H = pointField_H<realx4>;
|
||||||
|
|
||||||
|
using wordPointField_H = pointField_H<word>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,10 +24,10 @@ Licence:
|
|||||||
|
|
||||||
pFlow::demComponent::demComponent(const word& name, systemControl& control)
|
pFlow::demComponent::demComponent(const word& name, systemControl& control)
|
||||||
:
|
:
|
||||||
componentName_(name),
|
|
||||||
control_(control),
|
control_(control),
|
||||||
time_(control.time()),
|
time_(control.time()),
|
||||||
timers_(name, &control.timers())
|
timers_(name, &control.timers()),
|
||||||
|
componentName_(name)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
pFlow::real pFlow::demComponent::dt()const
|
pFlow::real pFlow::demComponent::dt()const
|
||||||
@ -39,3 +39,8 @@ pFlow::real pFlow::demComponent::currentTime()const
|
|||||||
{
|
{
|
||||||
return time_.currentTime();
|
return time_.currentTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pFlow::uint32 pFlow::demComponent::currentIter() const
|
||||||
|
{
|
||||||
|
return time_.currentIter();
|
||||||
|
}
|
||||||
|
@ -40,13 +40,9 @@ class Time;
|
|||||||
*/
|
*/
|
||||||
class demComponent
|
class demComponent
|
||||||
{
|
{
|
||||||
protected:
|
private:
|
||||||
|
|
||||||
// - Protected data members
|
// - Protected data members
|
||||||
|
|
||||||
/// Name of the DEM component
|
|
||||||
word componentName_;
|
|
||||||
|
|
||||||
/// Reference to systemControl
|
/// Reference to systemControl
|
||||||
systemControl& control_;
|
systemControl& control_;
|
||||||
|
|
||||||
@ -55,6 +51,9 @@ protected:
|
|||||||
/// All timers (if any) of this component
|
/// All timers (if any) of this component
|
||||||
Timers timers_;
|
Timers timers_;
|
||||||
|
|
||||||
|
/// Name of the DEM component
|
||||||
|
word componentName_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Type info
|
/// Type info
|
||||||
@ -103,6 +102,8 @@ public:
|
|||||||
/// Current simulation time
|
/// Current simulation time
|
||||||
real currentTime()const;
|
real currentTime()const;
|
||||||
|
|
||||||
|
uint32 currentIter()const;
|
||||||
|
|
||||||
inline
|
inline
|
||||||
const auto& time()const
|
const auto& time()const
|
||||||
{
|
{
|
||||||
@ -134,7 +135,7 @@ public:
|
|||||||
virtual
|
virtual
|
||||||
bool beforeTimeLoop()
|
bool beforeTimeLoop()
|
||||||
{
|
{
|
||||||
notImplementedFunction
|
notImplementedFunction;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +156,7 @@ public:
|
|||||||
virtual
|
virtual
|
||||||
bool afterTimeLoop()
|
bool afterTimeLoop()
|
||||||
{
|
{
|
||||||
notImplementedFunction
|
notImplementedFunction;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,11 +107,7 @@ protected:
|
|||||||
/// write dictionary to stream - with keyword
|
/// write dictionary to stream - with keyword
|
||||||
bool writeDictionary(iOstream& os, bool withBlock = true)const;
|
bool writeDictionary(iOstream& os, bool withBlock = true)const;
|
||||||
|
|
||||||
/// construct an empty dictionary with keyword and make it global/fileDictionary (if true)
|
|
||||||
dictionary(const word& keyword, bool global);
|
|
||||||
|
|
||||||
/// construct a dictionary with name and read it from file
|
|
||||||
dictionary(const word& keyword, const fileSystem& file);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -122,6 +118,11 @@ public:
|
|||||||
TypeInfo("dictionary");
|
TypeInfo("dictionary");
|
||||||
|
|
||||||
//// - Constructors
|
//// - Constructors
|
||||||
|
/// construct an empty dictionary with keyword and make it global/fileDictionary (if true)
|
||||||
|
dictionary(const word& keyword, bool global);
|
||||||
|
|
||||||
|
/// construct a dictionary with name and read it from file
|
||||||
|
dictionary(const word& keyword, const fileSystem& file);
|
||||||
|
|
||||||
/// cunstructs a null dictionary
|
/// cunstructs a null dictionary
|
||||||
dictionary();
|
dictionary();
|
||||||
|
@ -21,8 +21,9 @@ Licence:
|
|||||||
#include "observer.hpp"
|
#include "observer.hpp"
|
||||||
#include "subscriber.hpp"
|
#include "subscriber.hpp"
|
||||||
|
|
||||||
pFlow::observer::observer():
|
pFlow::observer::observer(message msg):
|
||||||
subscriber_(nullptr)
|
subscriber_(nullptr),
|
||||||
|
message_(msg)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
pFlow::observer::observer
|
pFlow::observer::observer
|
||||||
@ -30,13 +31,33 @@ pFlow::observer::observer
|
|||||||
const subscriber* subscrbr,
|
const subscriber* subscrbr,
|
||||||
message msg
|
message msg
|
||||||
)
|
)
|
||||||
:
|
{
|
||||||
subscriber_(subscrbr),
|
addToSubscriber(subscrbr, msg);
|
||||||
message_(msg)
|
}
|
||||||
|
|
||||||
|
pFlow::observer::~observer()
|
||||||
{
|
{
|
||||||
|
if(subscriber_)
|
||||||
|
subscriber_->unsubscribe(this);
|
||||||
|
invalidateSubscriber();
|
||||||
|
}
|
||||||
|
|
||||||
|
void pFlow::observer::addToSubscriber
|
||||||
|
(
|
||||||
|
const subscriber* subscrbr,
|
||||||
|
message msg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(subscriber_)
|
||||||
|
subscriber_->unsubscribe(this);
|
||||||
|
invalidateSubscriber();
|
||||||
|
|
||||||
|
subscriber_ = subscrbr;
|
||||||
|
message_ = msg;
|
||||||
|
|
||||||
if(subscriber_)
|
if(subscriber_)
|
||||||
{
|
{
|
||||||
if(!subscriber_->subscribe(msg, this))
|
if(!subscriber_->subscribe(message_, this))
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
"error in subscribing an observer"<<endl;
|
"error in subscribing an observer"<<endl;
|
||||||
@ -45,15 +66,12 @@ pFlow::observer::observer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::observer::~observer()
|
|
||||||
{
|
|
||||||
if( subscriber_)
|
|
||||||
subscriber_->unsubscribe(this);
|
|
||||||
invalidateSubscriber();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pFlow::observer::addToSubscriber(const subscriber& subscrbr)
|
bool pFlow::observer::addToSubscriber(const subscriber& subscrbr)
|
||||||
{
|
{
|
||||||
|
if(subscriber_)
|
||||||
|
subscriber_->unsubscribe(this);
|
||||||
|
invalidateSubscriber();
|
||||||
|
|
||||||
subscriber_ = &subscrbr;
|
subscriber_ = &subscrbr;
|
||||||
return subscriber_->subscribe(message_, this);
|
return subscriber_->subscribe(message_, this);
|
||||||
}
|
}
|
@ -39,12 +39,12 @@ protected:
|
|||||||
const subscriber* subscriber_ = nullptr;
|
const subscriber* subscriber_ = nullptr;
|
||||||
|
|
||||||
/// list of events in the message
|
/// list of events in the message
|
||||||
const message message_;
|
message message_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
observer();
|
observer(message msg);
|
||||||
|
|
||||||
observer(
|
observer(
|
||||||
const subscriber* subscrbr,
|
const subscriber* subscrbr,
|
||||||
@ -53,12 +53,20 @@ public:
|
|||||||
virtual
|
virtual
|
||||||
~observer();
|
~observer();
|
||||||
|
|
||||||
|
void subscribe(
|
||||||
|
const subscriber* subscrbr,
|
||||||
|
message msg);
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool subscribed()const
|
bool subscribed()const
|
||||||
{
|
{
|
||||||
return subscriber_!=nullptr;
|
return subscriber_!=nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addToSubscriber(
|
||||||
|
const subscriber* subscrbr,
|
||||||
|
message msg);
|
||||||
|
|
||||||
bool addToSubscriber(const subscriber& subscriber);
|
bool addToSubscriber(const subscriber& subscriber);
|
||||||
|
|
||||||
inline void invalidateSubscriber()
|
inline void invalidateSubscriber()
|
||||||
@ -72,7 +80,12 @@ public:
|
|||||||
return message::numEvents();
|
return message::numEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool hearChanges(const message& msg, const anyList& varList)=0;
|
virtual bool hearChanges(
|
||||||
|
real t,
|
||||||
|
real dt,
|
||||||
|
uint32 iter,
|
||||||
|
const message& msg,
|
||||||
|
const anyList& varList)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
@ -82,6 +82,9 @@ bool pFlow::subscriber::unsubscribe
|
|||||||
|
|
||||||
bool pFlow::subscriber::notify
|
bool pFlow::subscriber::notify
|
||||||
(
|
(
|
||||||
|
real t,
|
||||||
|
real dt,
|
||||||
|
uint32 iter,
|
||||||
const message msg,
|
const message msg,
|
||||||
const anyList& varList
|
const anyList& varList
|
||||||
)
|
)
|
||||||
@ -93,7 +96,14 @@ bool pFlow::subscriber::notify
|
|||||||
{
|
{
|
||||||
for( auto obsvr: observerList_[i] )
|
for( auto obsvr: observerList_[i] )
|
||||||
{
|
{
|
||||||
obsvr->hearChanges(message(i), varList);
|
obsvr->hearChanges
|
||||||
|
(
|
||||||
|
t,
|
||||||
|
dt,
|
||||||
|
iter,
|
||||||
|
message(i),
|
||||||
|
varList
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,12 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool notify(const message msg, const anyList& varList);
|
bool notify(
|
||||||
|
real t,
|
||||||
|
real dt,
|
||||||
|
uint32 iter,
|
||||||
|
const message msg,
|
||||||
|
const anyList& varList);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -62,7 +62,7 @@ pFlow::iOstream& reportAndExit(int errorCode = EXIT_FAILURE);
|
|||||||
notImplementedErrorMessage ((functionName), __FILE__, __LINE__ )
|
notImplementedErrorMessage ((functionName), __FILE__, __LINE__ )
|
||||||
|
|
||||||
/// Report that a function is yet not implemented.
|
/// Report that a function is yet not implemented.
|
||||||
#define notImplementedFunction Not_Implemented(FUNCTION_NAME);
|
#define notImplementedFunction Not_Implemented(FUNCTION_NAME)
|
||||||
|
|
||||||
/// Report an error in file operation with supplied fileName and lineNumber.
|
/// Report an error in file operation with supplied fileName and lineNumber.
|
||||||
#define ioErrorInFile( fileName, lineNumber) \
|
#define ioErrorInFile( fileName, lineNumber) \
|
||||||
|
@ -39,7 +39,7 @@ const inline char* integrationFolder__ = "integration";
|
|||||||
const inline char* settingsFile__ = "settingsDict";
|
const inline char* settingsFile__ = "settingsDict";
|
||||||
const inline char* domainFile__ = "domainDict";
|
const inline char* domainFile__ = "domainDict";
|
||||||
const inline char* insertionFile__ = "particleInsertion";
|
const inline char* insertionFile__ = "particleInsertion";
|
||||||
const inline char* sphereShapeFile__ = "sphereShape";
|
const inline char* shapeFile__ = "shapes";
|
||||||
const inline char* pointStructureFile__ = "pStructure";
|
const inline char* pointStructureFile__ = "pStructure";
|
||||||
const inline char* triSurfaceFile__ = "triSurface";
|
const inline char* triSurfaceFile__ = "triSurface";
|
||||||
const inline char* createParticles__ = "createParticles";
|
const inline char* createParticles__ = "createParticles";
|
||||||
|
@ -18,8 +18,8 @@ Licence:
|
|||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef __uniformRandomInt32_hpp__
|
#ifndef __uniformRandomUint32_hpp__
|
||||||
#define __uniformRandomInt32_hpp__
|
#define __uniformRandomUint32_hpp__
|
||||||
|
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
@ -29,35 +29,35 @@ Licence:
|
|||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
class uniformRandomInt32
|
class uniformRandomUint32
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
std::mt19937_64 engineGen_;
|
std::mt19937_64 engineGen_;
|
||||||
|
|
||||||
std::uniform_int_distribution<int32> distrbution_;
|
std::uniform_int_distribution<uint32> distrbution_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// type info
|
// type info
|
||||||
TypeInfoNV("uniform");
|
TypeInfoNV("uniform");
|
||||||
|
|
||||||
explicit uniformRandomInt32(int32 min, int32 max)
|
explicit uniformRandomUint32(uint32 min, uint32 max)
|
||||||
:
|
:
|
||||||
engineGen_(std::random_device()()),
|
engineGen_(std::random_device()()),
|
||||||
distrbution_(min, max)
|
distrbution_(min, max)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~uniformRandomInt32()= default;
|
~uniformRandomUint32()= default;
|
||||||
|
|
||||||
inline real randomNumber()
|
inline uint32 randomNumber()
|
||||||
{
|
{
|
||||||
return distrbution_(engineGen_);
|
return distrbution_(engineGen_);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int32x3 randomNumber3()
|
inline triple<uint32> randomNumber3()
|
||||||
{
|
{
|
||||||
return int32x3
|
return triple<uint32>
|
||||||
(
|
(
|
||||||
randomNumber(),
|
randomNumber(),
|
||||||
randomNumber(),
|
randomNumber(),
|
||||||
@ -65,9 +65,9 @@ public:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline realx3 operator()()
|
inline triple<uint32> operator()()
|
||||||
{
|
{
|
||||||
return randomNumber();
|
return randomNumber3();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,6 +116,8 @@ bool pFlow::IOfileHeader::implyRead() const
|
|||||||
|
|
||||||
bool pFlow::IOfileHeader::implyWrite() const
|
bool pFlow::IOfileHeader::implyWrite() const
|
||||||
{
|
{
|
||||||
|
if( isExcluded( name() ) ) return false;
|
||||||
|
if( isIncluded( name() ) ) return true;
|
||||||
return isWriteAlways();
|
return isWriteAlways();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +82,18 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual
|
||||||
|
bool isIncluded(const word& objName)const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual
|
||||||
|
bool isExcluded(const word& objName)const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// - path to file name
|
// - path to file name
|
||||||
fileSystem path() const;
|
fileSystem path() const;
|
||||||
|
|
||||||
|
@ -62,6 +62,21 @@ pFlow::repository* pFlow::IOobject::releaseOwner
|
|||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pFlow::IOobject::isIncluded(const word& objName)const
|
||||||
|
{
|
||||||
|
if(owner_)
|
||||||
|
return owner_->isIncluded(objName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool pFlow::IOobject::isExcluded(const word& objName)const
|
||||||
|
{
|
||||||
|
if(owner_)
|
||||||
|
return owner_->isExcluded(objName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool pFlow::IOobject::readObject(bool rdHdr)
|
bool pFlow::IOobject::readObject(bool rdHdr)
|
||||||
{
|
{
|
||||||
if(!implyRead())return true;
|
if(!implyRead())return true;
|
||||||
|
@ -85,6 +85,12 @@ public:
|
|||||||
|
|
||||||
repository* releaseOwner(bool fromOwner = false);
|
repository* releaseOwner(bool fromOwner = false);
|
||||||
|
|
||||||
|
|
||||||
|
bool isIncluded(const word& objName)const override;
|
||||||
|
|
||||||
|
bool isExcluded(const word& objName)const override;
|
||||||
|
|
||||||
|
|
||||||
//// - IO operations
|
//// - IO operations
|
||||||
|
|
||||||
// - read from file
|
// - read from file
|
||||||
|
@ -97,12 +97,14 @@ public:
|
|||||||
|
|
||||||
virtual ~objectFile()=default;
|
virtual ~objectFile()=default;
|
||||||
|
|
||||||
virtual word name() const
|
virtual
|
||||||
|
const word& name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual fileSystem localPath()const
|
virtual
|
||||||
|
const fileSystem& localPath()const
|
||||||
{
|
{
|
||||||
return localPath_;
|
return localPath_;
|
||||||
}
|
}
|
||||||
|
@ -283,6 +283,7 @@ bool pFlow::repository::write
|
|||||||
{
|
{
|
||||||
if(verbose)
|
if(verbose)
|
||||||
{
|
{
|
||||||
|
if(obj.second->implyWrite())
|
||||||
REPORT(1)<< "Writing to " << obj.second->path()<<END_REPORT;
|
REPORT(1)<< "Writing to " << obj.second->path()<<END_REPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +114,23 @@ public:
|
|||||||
bool removeFromRepository(IOobject* io);
|
bool removeFromRepository(IOobject* io);
|
||||||
|
|
||||||
repository* releaseOwner(bool fromOwner = false);
|
repository* releaseOwner(bool fromOwner = false);
|
||||||
|
|
||||||
|
virtual
|
||||||
|
bool isIncluded(const word& objName)const
|
||||||
|
{
|
||||||
|
if(owner_)
|
||||||
|
return owner_->isIncluded(objName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual
|
||||||
|
bool isExcluded(const word& objName)const
|
||||||
|
{
|
||||||
|
if(owner_)
|
||||||
|
return owner_->isExcluded(objName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//// - lookups and queries
|
//// - lookups and queries
|
||||||
|
|
||||||
// - check if name of object exists
|
// - check if name of object exists
|
||||||
|
@ -17,117 +17,7 @@ Licence:
|
|||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
/*
|
|
||||||
|
|
||||||
template<typename T, typename... Args>
|
|
||||||
T& pFlow::repository::emplaceObject(const objectFile& objf, Args&&... args)
|
|
||||||
{
|
|
||||||
|
|
||||||
if( auto [iter2, success2] = objects_.findIf(objf.name()); !success2 )
|
|
||||||
{
|
|
||||||
auto ptr = IOobject::make_object_t<T>(std::forward<Args>(args)...);
|
|
||||||
auto [iter, success] = objects_.emplace(std::piecewise_construct,
|
|
||||||
std::forward_as_tuple(objf.name()),
|
|
||||||
std::forward_as_tuple(objf, this, std::move(ptr) )
|
|
||||||
);
|
|
||||||
|
|
||||||
return iter->second.template getObject<T>();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fatalErrorInFunction<<
|
|
||||||
"IOobject " << objf.name() << " already exists in repository " << name() <<endl;
|
|
||||||
fatalExit;
|
|
||||||
return iter2->second.template getObject<T>();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename... Args>
|
|
||||||
T& pFlow::repository::emplaceObjectOrGet(const objectFile& objf, Args&&... args)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(auto [iter, success] = objects_.findIf(objf.name()); !success )
|
|
||||||
{
|
|
||||||
return emplaceObject<T>(objf, std::forward<Args>(args)... );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// type check
|
|
||||||
if( checkForObjectType<T>( iter->second ) )
|
|
||||||
{
|
|
||||||
return iter->second.template getObject<T>();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fatalErrorInFunction<<
|
|
||||||
" IOobject "<< objf.name() <<" already exist in the repository "<< name() <<
|
|
||||||
". Trying to return the existing object but there is a type mismatch. \n"<<
|
|
||||||
reportTypeError<T>( iter->second );
|
|
||||||
fatalExit;
|
|
||||||
return iter->second.template getObject<T>(); // this is never executed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename... Args>
|
|
||||||
T& pFlow::repository::emplaceReplaceObject(const objectFile& objf, Args&&... args)
|
|
||||||
{
|
|
||||||
|
|
||||||
eraseObject(objf.name());
|
|
||||||
|
|
||||||
auto ptr = IOobject::make_object_t<T>(std::forward<Args>(args)...);
|
|
||||||
auto [iter, success] = objects_.emplace(std::piecewise_construct,
|
|
||||||
std::forward_as_tuple(objf.name()),
|
|
||||||
std::forward_as_tuple(objf, this, std::move(ptr) )
|
|
||||||
);
|
|
||||||
|
|
||||||
return iter->second.template getObject<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T& pFlow::repository::insertReplaceObject(uniquePtr<IOobject>&& ptr )
|
|
||||||
{
|
|
||||||
if( !ptr->owner() )
|
|
||||||
{
|
|
||||||
eraseObject(ptr->name());
|
|
||||||
objectFile objf( ptr() );
|
|
||||||
|
|
||||||
auto [iter, success] = objects_.emplace
|
|
||||||
(
|
|
||||||
std::piecewise_construct,
|
|
||||||
std::forward_as_tuple(ptr->name()),
|
|
||||||
std::forward_as_tuple(objf, this, std::move(ptr))
|
|
||||||
);
|
|
||||||
return iter->second.template getObject<T>();
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
return ptr().getObject<T>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T& pFlow::repository::insertReplaceObject(const objectFile& objf, uniquePtr<IOobject>&& ptr )
|
|
||||||
{
|
|
||||||
if( !ptr->owner() )
|
|
||||||
{
|
|
||||||
eraseObject(objf.name());
|
|
||||||
|
|
||||||
auto [iter, success] = objects_.emplace
|
|
||||||
(
|
|
||||||
std::piecewise_construct,
|
|
||||||
std::forward_as_tuple(objf.name()),
|
|
||||||
std::forward_as_tuple(objf, this, std::move(ptr))
|
|
||||||
);
|
|
||||||
return iter->second.template getObject<T>();
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
return ptr().getObject<T>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <typename Type1>
|
template <typename Type1>
|
||||||
pFlow::word pFlow::repository::reportTypeError(IOobject& object)
|
pFlow::word pFlow::repository::reportTypeError(IOobject& object)
|
||||||
@ -154,15 +44,15 @@ T& pFlow::repository::lookupObject(const word& name)
|
|||||||
|
|
||||||
if( checkType<T>(iter->second) )
|
if( checkType<T>(iter->second) )
|
||||||
{
|
{
|
||||||
return static_cast<T&>(iter->second);
|
return static_cast<T&>(*iter->second);
|
||||||
|
|
||||||
|
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
fatalErrorInFunction <<
|
fatalErrorInFunction <<
|
||||||
reportTypeError<T>(iter->second)<<endl;
|
reportTypeError<T>(*iter->second)<<endl;
|
||||||
fatalExit;
|
fatalExit;
|
||||||
return static_cast<T&>(iter->second);
|
return static_cast<T&>(*iter->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -172,6 +62,6 @@ T& pFlow::repository::lookupObject(const word& name)
|
|||||||
"Object with name " << name << " is not found in repository " << this->name()<<endl <<
|
"Object with name " << name << " is not found in repository " << this->name()<<endl <<
|
||||||
"list of avaiable objest is \n" << objectNames();
|
"list of avaiable objest is \n" << objectNames();
|
||||||
fatalExit;
|
fatalExit;
|
||||||
return iter->second.template getObject<T>();
|
return static_cast<T&>(*iter->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,25 +24,32 @@ Licence:
|
|||||||
#include "error.hpp"
|
#include "error.hpp"
|
||||||
#include "systemControl.hpp"
|
#include "systemControl.hpp"
|
||||||
#include "vocabs.hpp"
|
#include "vocabs.hpp"
|
||||||
|
#include "Lists.hpp"
|
||||||
|
|
||||||
/*bool pFlow::systemControl::readDomainDict()
|
bool pFlow::systemControl::readIncludeExclue
|
||||||
|
(
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if(!domainDict_)
|
if(dict.containsDataEntry("includeObjects"))
|
||||||
{
|
{
|
||||||
domainDict_ = makeUnique<fileDictionary>
|
wordList incld = dict.getVal<wordList>("includeObjects");
|
||||||
(
|
for(auto& nm:incld)
|
||||||
objectFile
|
{
|
||||||
(
|
includeList_.insert(nm);
|
||||||
domainFile__,
|
}
|
||||||
"",
|
}
|
||||||
objectFile::READ_ALWAYS,
|
|
||||||
objectFile::WRITE_NEVER
|
if(dict.containsDataEntry("excludeObjects"))
|
||||||
),
|
{
|
||||||
&settings()
|
wordList excld = dict.getVal<wordList>("excludeObjects");
|
||||||
);
|
for(auto& nm:excld)
|
||||||
|
{
|
||||||
|
excludeList_.insert(nm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::systemControl::getRunName
|
pFlow::word pFlow::systemControl::getRunName
|
||||||
(
|
(
|
||||||
@ -176,7 +183,7 @@ pFlow::systemControl::systemControl
|
|||||||
),
|
),
|
||||||
writeToFileTimer_("Write to file", &timers_)
|
writeToFileTimer_("Write to file", &timers_)
|
||||||
{
|
{
|
||||||
//readDomainDict();
|
readIncludeExclue(settingsDict_());
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::systemControl::systemControl(
|
pFlow::systemControl::systemControl(
|
||||||
@ -250,13 +257,9 @@ pFlow::systemControl::systemControl(
|
|||||||
),
|
),
|
||||||
writeToFileTimer_("Write to file", &timers_)
|
writeToFileTimer_("Write to file", &timers_)
|
||||||
{
|
{
|
||||||
//readDomainDict();
|
readIncludeExclue(settingsDict_());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*pFlow::fileDictionary& pFlow::systemControl::domainDict()
|
|
||||||
{
|
|
||||||
return domainDict_();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
bool pFlow::systemControl::operator ++(int)
|
bool pFlow::systemControl::operator ++(int)
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,7 @@ Licence:
|
|||||||
#include "box.hpp"
|
#include "box.hpp"
|
||||||
#include "Timers.hpp"
|
#include "Timers.hpp"
|
||||||
#include "dynamicLinkLibs.hpp"
|
#include "dynamicLinkLibs.hpp"
|
||||||
|
#include "Set.hpp"
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
@ -79,7 +80,12 @@ protected:
|
|||||||
|
|
||||||
Timer writeToFileTimer_;
|
Timer writeToFileTimer_;
|
||||||
|
|
||||||
//bool readDomainDict();
|
wordSet includeList_;
|
||||||
|
|
||||||
|
wordSet excludeList_;
|
||||||
|
|
||||||
|
|
||||||
|
bool readIncludeExclue(const dictionary& dict);
|
||||||
|
|
||||||
static word getRunName( const fileSystem& path);
|
static word getRunName( const fileSystem& path);
|
||||||
|
|
||||||
@ -189,6 +195,36 @@ public:
|
|||||||
return outFilePrecision_;
|
return outFilePrecision_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool isIncluded(const word& objName)const final
|
||||||
|
{
|
||||||
|
return includeList_.count(objName) == static_cast<size_t>(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool isExcluded(const word& objName)const final
|
||||||
|
{
|
||||||
|
return excludeList_.count(objName) == static_cast<size_t>(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearIncludeExclude()
|
||||||
|
{
|
||||||
|
includeList_.clear();
|
||||||
|
excludeList_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool addInclude(const word& objName)
|
||||||
|
{
|
||||||
|
auto [iter, success] = includeList_.insert(objName);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool addExclude(const word& objName)
|
||||||
|
{
|
||||||
|
auto [ite, success] = excludeList_.insert(objName);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,13 +39,15 @@ bool pFlow::setFieldEntry::checkForTypeAndValueAll()const
|
|||||||
if(
|
if(
|
||||||
!(
|
!(
|
||||||
checkForTypeAndValue<int8>() ||
|
checkForTypeAndValue<int8>() ||
|
||||||
checkForTypeAndValue<int16>() ||
|
checkForTypeAndValue<uint8>() ||
|
||||||
checkForTypeAndValue<int32>() ||
|
checkForTypeAndValue<int32>() ||
|
||||||
checkForTypeAndValue<int64>() ||
|
checkForTypeAndValue<int64>() ||
|
||||||
checkForTypeAndValue<uint32>() ||
|
checkForTypeAndValue<uint32>() ||
|
||||||
checkForTypeAndValue<label>() ||
|
checkForTypeAndValue<uint64>() ||
|
||||||
checkForTypeAndValue<real>() ||
|
checkForTypeAndValue<real>() ||
|
||||||
checkForTypeAndValue<realx3>()
|
checkForTypeAndValue<realx3>() ||
|
||||||
|
checkForTypeAndValue<realx4>() ||
|
||||||
|
checkForTypeAndValue<word>()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -57,40 +59,58 @@ bool pFlow::setFieldEntry::checkForTypeAndValueAll()const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* pFlow::setFieldEntry::setPointFieldDefaultValueNewAll
|
pFlow::uniquePtr<pFlow::IOobject>
|
||||||
|
pFlow::setFieldEntry::setPointFieldDefaultValueNewAll
|
||||||
(
|
(
|
||||||
repository& owner,
|
|
||||||
pointStructure& pStruct,
|
pointStructure& pStruct,
|
||||||
bool verbose
|
bool verbose
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if( void* res = setPointFieldDefaultValueNew<int8> (owner, pStruct, verbose) ; res)
|
uniquePtr<IOobject> Ptr = nullptr;
|
||||||
|
|
||||||
|
if( Ptr = setPointFieldDefaultValueNew<int8>(pStruct, verbose) ; Ptr)
|
||||||
{
|
{
|
||||||
return res;
|
return Ptr;
|
||||||
}else if(void* res = setPointFieldDefaultValueNew<int16>(owner, pStruct, verbose); res)
|
}
|
||||||
|
else if(Ptr = setPointFieldDefaultValueNew<uint8>(pStruct, verbose); Ptr)
|
||||||
{
|
{
|
||||||
return res;
|
return Ptr;
|
||||||
}else if(void* res = setPointFieldDefaultValueNew<int32> (owner, pStruct, verbose); res)
|
}
|
||||||
|
else if(Ptr = setPointFieldDefaultValueNew<int32> (pStruct, verbose); Ptr)
|
||||||
{
|
{
|
||||||
return res;
|
return Ptr;
|
||||||
}else if(void* res = setPointFieldDefaultValueNew<int64> (owner, pStruct, verbose); res)
|
}
|
||||||
|
else if(Ptr = setPointFieldDefaultValueNew<int64> (pStruct, verbose); Ptr)
|
||||||
{
|
{
|
||||||
return res;
|
return Ptr;
|
||||||
}else if(void* res = setPointFieldDefaultValueNew<uint32> (owner, pStruct, verbose); res)
|
}
|
||||||
|
else if(Ptr = setPointFieldDefaultValueNew<uint32> (pStruct, verbose); Ptr)
|
||||||
{
|
{
|
||||||
return res;
|
return Ptr;
|
||||||
}else if(void* res = setPointFieldDefaultValueNew<label>(owner, pStruct, verbose); res)
|
}
|
||||||
|
else if(Ptr = setPointFieldDefaultValueNew<int64>(pStruct, verbose); Ptr)
|
||||||
{
|
{
|
||||||
return res;
|
return Ptr;
|
||||||
}else if(void* res = setPointFieldDefaultValueNew<real>(owner, pStruct, verbose); res)
|
}
|
||||||
|
else if(Ptr = setPointFieldDefaultValueNew<uint64>(pStruct, verbose); Ptr)
|
||||||
{
|
{
|
||||||
return res;
|
return Ptr;
|
||||||
}else if(void* res = setPointFieldDefaultValueNew<realx3>(owner, pStruct, verbose); res)
|
}
|
||||||
|
else if(Ptr = setPointFieldDefaultValueNew<real>(pStruct, verbose); Ptr)
|
||||||
{
|
{
|
||||||
return res;
|
return Ptr;
|
||||||
}else if(void* res = setPointFieldDefaultValueStdNew<word>(owner, pStruct, verbose); res)
|
}
|
||||||
|
else if(Ptr = setPointFieldDefaultValueNew<realx3>(pStruct, verbose); Ptr)
|
||||||
{
|
{
|
||||||
return res;
|
return Ptr;
|
||||||
|
}
|
||||||
|
else if(Ptr = setPointFieldDefaultValueNew<realx4>(pStruct, verbose); Ptr)
|
||||||
|
{
|
||||||
|
return Ptr;
|
||||||
|
}
|
||||||
|
else if(Ptr = setPointFieldDefaultValueNew<word>(pStruct, verbose); Ptr)
|
||||||
|
{
|
||||||
|
return Ptr;
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
@ -100,46 +120,59 @@ void* pFlow::setFieldEntry::setPointFieldDefaultValueNewAll
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* pFlow::setFieldEntry::setPointFieldSelectedAll
|
bool pFlow::setFieldEntry::setPointFieldSelectedAll
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
int32IndexContainer& selected,
|
uint32IndexContainer& selected,
|
||||||
bool verbose
|
bool verbose
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
if( void* res = setPointFieldSelected<int8> (owner, selected, verbose) ; res)
|
if( setPointFieldSelected<int8> (owner, selected, verbose))
|
||||||
{
|
{
|
||||||
return res;
|
return true;
|
||||||
}else if(void* res = setPointFieldSelected<int16>(owner, selected, verbose); res)
|
}
|
||||||
|
else if( setPointFieldSelected<uint8>(owner, selected, verbose))
|
||||||
{
|
{
|
||||||
return res;
|
return true;
|
||||||
}else if(void* res = setPointFieldSelected<int32> (owner, selected, verbose); res)
|
}
|
||||||
|
else if( setPointFieldSelected<int32>(owner, selected, verbose))
|
||||||
{
|
{
|
||||||
return res;
|
return true;
|
||||||
}else if(void* res = setPointFieldSelected<int64> (owner, selected, verbose); res)
|
}
|
||||||
|
else if( setPointFieldSelected<uint32>(owner, selected, verbose))
|
||||||
{
|
{
|
||||||
return res;
|
return true;
|
||||||
}else if(void* res = setPointFieldSelected<uint32> (owner, selected, verbose); res)
|
}
|
||||||
|
else if( setPointFieldSelected<int64>(owner, selected, verbose))
|
||||||
{
|
{
|
||||||
return res;
|
return true;
|
||||||
}else if(void* res = setPointFieldSelected<label>(owner, selected, verbose); res)
|
}
|
||||||
|
else if( setPointFieldSelected<uint64>(owner, selected, verbose))
|
||||||
{
|
{
|
||||||
return res;
|
return true;
|
||||||
}else if(void* res = setPointFieldSelected<real>(owner, selected, verbose); res)
|
}
|
||||||
|
else if( setPointFieldSelected<real>(owner, selected, verbose))
|
||||||
{
|
{
|
||||||
return res;
|
return true;
|
||||||
}else if(void* res = setPointFieldSelected<realx3>(owner, selected, verbose); res)
|
}
|
||||||
|
else if( setPointFieldSelected<realx3>(owner, selected, verbose))
|
||||||
{
|
{
|
||||||
return res;
|
return true;
|
||||||
}else if(void* res = setPointFieldSelectedStd<word>(owner, selected, verbose); res)
|
}
|
||||||
|
else if( setPointFieldSelected<realx4>(owner, selected, verbose))
|
||||||
{
|
{
|
||||||
return res;
|
return true;
|
||||||
}else
|
}
|
||||||
|
else if( setPointFieldSelected<word>(owner, selected, verbose))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
" un-supported data type "<<entry_.firstPart() << " in setField for field " << fieldName() <<endl;
|
" un-supported data type "<<entry_.firstPart() << " in setField for field " << fieldName() <<endl;
|
||||||
return nullptr;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -65,48 +65,34 @@ public:
|
|||||||
bool checkForTypeAndValueAll()const;
|
bool checkForTypeAndValueAll()const;
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void* setPointFieldDefaultValueNew
|
uniquePtr<pointField_H<Type>>
|
||||||
|
setPointFieldDefaultValueNew
|
||||||
(
|
(
|
||||||
repository& owner,
|
|
||||||
pointStructure& pStruct,
|
pointStructure& pStruct,
|
||||||
bool verbose = false
|
bool verbose = false
|
||||||
);
|
);
|
||||||
|
|
||||||
template<typename Type>
|
uniquePtr<IOobject>
|
||||||
void* setPointFieldDefaultValueStdNew
|
setPointFieldDefaultValueNewAll
|
||||||
(
|
(
|
||||||
repository& owner,
|
|
||||||
pointStructure& pStruct,
|
|
||||||
bool verbose = false
|
|
||||||
);
|
|
||||||
|
|
||||||
void* setPointFieldDefaultValueNewAll
|
|
||||||
(
|
|
||||||
repository& owner,
|
|
||||||
pointStructure& pStruct,
|
pointStructure& pStruct,
|
||||||
bool verbose = false
|
bool verbose = false
|
||||||
);
|
);
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void* setPointFieldSelected
|
bool setPointFieldSelected
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
int32IndexContainer& selected,
|
uint32IndexContainer& selected,
|
||||||
bool verbose = false
|
bool verbose = false
|
||||||
);
|
);
|
||||||
|
|
||||||
template <typename Type>
|
|
||||||
void* setPointFieldSelectedStd
|
|
||||||
(
|
|
||||||
repository& owner,
|
|
||||||
int32IndexContainer& selected,
|
|
||||||
bool verbose = false
|
|
||||||
);
|
|
||||||
|
|
||||||
void* setPointFieldSelectedAll
|
|
||||||
|
bool setPointFieldSelectedAll
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
int32IndexContainer& selected,
|
uint32IndexContainer& selected,
|
||||||
bool verbose = false
|
bool verbose = false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ bool pFlow::setFieldEntry::checkForTypeAndValue()const
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void* pFlow::setFieldEntry::setPointFieldDefaultValueNew
|
pFlow::uniquePtr<pFlow::pointField_H<Type>>
|
||||||
|
pFlow::setFieldEntry::setPointFieldDefaultValueNew
|
||||||
(
|
(
|
||||||
repository& owner,
|
|
||||||
pointStructure& pStruct,
|
pointStructure& pStruct,
|
||||||
bool verbose
|
bool verbose
|
||||||
)
|
)
|
||||||
@ -50,13 +50,10 @@ void* pFlow::setFieldEntry::setPointFieldDefaultValueNew
|
|||||||
Type defValue = entry_.secondPartVal<Type>();
|
Type defValue = entry_.secondPartVal<Type>();
|
||||||
|
|
||||||
if(verbose)
|
if(verbose)
|
||||||
REPORT(2)<<"Creating pointField " << Green_Text(fieldName())<< " with default value " << cyanText(defValue)<<
|
REPORT(2)<<"Creating pointField " << Green_Text(fieldName())<< " with default value " << Cyan_Text(defValue)<<
|
||||||
" in repository "<< owner.name() <<END_REPORT;
|
" in repository "<< pStruct.owner()->name() <<END_REPORT;
|
||||||
|
|
||||||
|
auto Ptr = makeUnique<pointField_H<Type>>(
|
||||||
auto& field =
|
|
||||||
owner.emplaceObject<pointField<VectorSingle,Type>>
|
|
||||||
(
|
|
||||||
objectFile
|
objectFile
|
||||||
(
|
(
|
||||||
fieldName(),
|
fieldName(),
|
||||||
@ -65,13 +62,14 @@ void* pFlow::setFieldEntry::setPointFieldDefaultValueNew
|
|||||||
objectFile::WRITE_ALWAYS
|
objectFile::WRITE_ALWAYS
|
||||||
),
|
),
|
||||||
pStruct,
|
pStruct,
|
||||||
|
defValue,
|
||||||
defValue
|
defValue
|
||||||
);
|
);
|
||||||
|
|
||||||
return &field;
|
return Ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
/*template <typename Type>
|
||||||
void* pFlow::setFieldEntry::setPointFieldDefaultValueStdNew
|
void* pFlow::setFieldEntry::setPointFieldDefaultValueStdNew
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
@ -104,17 +102,17 @@ void* pFlow::setFieldEntry::setPointFieldDefaultValueStdNew
|
|||||||
);
|
);
|
||||||
|
|
||||||
return &field;
|
return &field;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void* pFlow::setFieldEntry::setPointFieldSelected
|
bool pFlow::setFieldEntry::setPointFieldSelected
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
int32IndexContainer& selected,
|
uint32IndexContainer& selected,
|
||||||
bool verbose
|
bool verbose
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if( !checkForType<Type>() ) return nullptr;
|
if( !checkForType<Type>() ) return false;
|
||||||
|
|
||||||
|
|
||||||
auto fName = fieldName();
|
auto fName = fieldName();
|
||||||
@ -123,56 +121,34 @@ void* pFlow::setFieldEntry::setPointFieldSelected
|
|||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
"Cannot find "<< fName << " in repository " << owner.name() << ". \n";
|
"Cannot find "<< fName << " in repository " << owner.name() << ". \n";
|
||||||
return nullptr;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type value = entry_.secondPartVal<Type>();
|
Type value = entry_.secondPartVal<Type>();
|
||||||
|
|
||||||
if(verbose)
|
if(verbose)
|
||||||
REPORT(2)<< "Setting selected points of " << Green_Text(fName)
|
REPORT(2)<< "Setting selected points of " << Green_Text(fName)
|
||||||
<< " to value " << cyanText(value) <<END_REPORT;
|
<< " to value " << Cyan_Text(value) <<END_REPORT;
|
||||||
|
|
||||||
|
|
||||||
auto fieldTypeName = owner.lookupObjectTypeName(fName);
|
auto fieldTypeName = owner.lookupObjectTypeName(fName);
|
||||||
|
|
||||||
if( pointField<VectorSingle,Type>::TYPENAME() == fieldTypeName )
|
if( getTypeName<pointField_H<Type>>() == fieldTypeName )
|
||||||
{
|
{
|
||||||
|
|
||||||
auto& field = owner.lookupObject<pointField<VectorSingle,Type>>(fName);
|
auto& field = owner.lookupObject<pointField_H<Type>>(fName);
|
||||||
if(field.insertSetElement(selected, value))
|
if(field.insertSetElement(selected, value))
|
||||||
return &field;
|
return true;
|
||||||
else
|
else
|
||||||
return nullptr;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pointField<VectorSingle,Type, HostSpace>::TYPENAME() == fieldTypeName )
|
|
||||||
{
|
|
||||||
|
|
||||||
auto& field = owner.lookupObject<pointField<VectorSingle,Type,HostSpace>>(fName);
|
|
||||||
if(field.insertSetElement(selected, value))
|
|
||||||
return &field;
|
|
||||||
else
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*if( pointField<VectorDual,Type>::TYPENAME() == fieldTypeName )
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
auto& field = owner.lookupObject<pointField<VectorDual,Type>>(fName);
|
|
||||||
if(field.insertSetElement(selected, value))
|
|
||||||
return &field;
|
|
||||||
else
|
|
||||||
return nullptr;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
fieldTypeName<< " is not a supported field type for setFieldEntry.\n";
|
fieldTypeName<< " is not a supported field type for setFieldEntry.\n";
|
||||||
return nullptr;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
/*template <typename Type>
|
||||||
void* pFlow::setFieldEntry::setPointFieldSelectedStd
|
void* pFlow::setFieldEntry::setPointFieldSelectedStd
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
@ -213,4 +189,4 @@ void* pFlow::setFieldEntry::setPointFieldSelectedStd
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}*/
|
@ -210,8 +210,14 @@ template<>
|
|||||||
inline
|
inline
|
||||||
bool pFlow::dataIO<pFlow::word>::writeData(iOstream& os, span<word> data)
|
bool pFlow::dataIO<pFlow::word>::writeData(iOstream& os, span<word> data)
|
||||||
{
|
{
|
||||||
notImplementedFunction;
|
|
||||||
|
if( ioPattern_.isParallel() )
|
||||||
|
{
|
||||||
|
notImplementedFunction<<
|
||||||
|
"data transfer for type word is not supported in parallel mode!"<<endl;
|
||||||
fatalExit;
|
fatalExit;
|
||||||
|
}
|
||||||
|
|
||||||
/// first gather data from all processors (if any)
|
/// first gather data from all processors (if any)
|
||||||
if(!gatherData( data ) )
|
if(!gatherData( data ) )
|
||||||
{
|
{
|
||||||
@ -220,7 +226,14 @@ bool pFlow::dataIO<pFlow::word>::writeData(iOstream& os, span<word> data)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if( ioPattern_.thisProcWriteData())
|
||||||
|
{
|
||||||
|
return writeDataASCII(os, data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -62,9 +62,9 @@ public:
|
|||||||
const pointStructure& pStruct()const;
|
const pointStructure& pStruct()const;
|
||||||
|
|
||||||
|
|
||||||
virtual const int32Vector& selectedPoinsts()const = 0;
|
virtual const uint32Vector& selectedPoinsts()const = 0;
|
||||||
|
|
||||||
virtual int32Vector& selectedPoinsts() = 0;
|
virtual uint32Vector& selectedPoinsts() = 0;
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -38,7 +38,7 @@ class selectBox
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
int32Vector selectedPoints_;
|
uint32Vector selectedPoints_;
|
||||||
|
|
||||||
box box_;
|
box box_;
|
||||||
|
|
||||||
@ -63,12 +63,12 @@ public:
|
|||||||
|
|
||||||
//// - Methods
|
//// - Methods
|
||||||
|
|
||||||
virtual const int32Vector& selectedPoinsts()const override
|
virtual const uint32Vector& selectedPoinsts()const override
|
||||||
{
|
{
|
||||||
return selectedPoints_;
|
return selectedPoints_;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int32Vector& selectedPoinsts() override
|
virtual uint32Vector& selectedPoinsts() override
|
||||||
{
|
{
|
||||||
return selectedPoints_;
|
return selectedPoints_;
|
||||||
}
|
}
|
||||||
|
@ -21,31 +21,31 @@ Licence:
|
|||||||
|
|
||||||
#include "selectRandom.hpp"
|
#include "selectRandom.hpp"
|
||||||
#include "dictionary.hpp"
|
#include "dictionary.hpp"
|
||||||
#include "uniformRandomInt32.hpp"
|
#include "uniformRandomUint32.hpp"
|
||||||
#include "Set.hpp"
|
#include "Set.hpp"
|
||||||
|
|
||||||
|
|
||||||
bool pFlow::selectRandom::selectAllPointsInRange()
|
bool pFlow::selectRandom::selectAllPointsInRange()
|
||||||
{
|
{
|
||||||
// to reduct allocations
|
// to reduct allocations
|
||||||
int32 maxNum = number_+1;
|
uint32 maxNum = number_+1;
|
||||||
|
|
||||||
selectedPoints_.reserve (maxNum);
|
selectedPoints_.reserve (maxNum);
|
||||||
|
|
||||||
selectedPoints_.clear();
|
selectedPoints_.clear();
|
||||||
|
|
||||||
uniformRandomInt32 intRand (begin_, end_);
|
uniformRandomUint32 intRand (begin_, end_);
|
||||||
|
|
||||||
|
|
||||||
int32 n = 0;
|
uint32 n = 0;
|
||||||
int32 iter = 0;
|
uint32 iter = 0;
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
|
|
||||||
Set<int32> selctedIndices;
|
Set<uint32> selctedIndices;
|
||||||
|
|
||||||
while( iter < number_*100)
|
while( iter < number_*100)
|
||||||
{
|
{
|
||||||
int32 newInd = intRand.randomNumber();
|
uint32 newInd = intRand.randomNumber();
|
||||||
|
|
||||||
if( auto [it, inserted] = selctedIndices.insert(newInd); inserted )
|
if( auto [it, inserted] = selctedIndices.insert(newInd); inserted )
|
||||||
{
|
{
|
||||||
@ -91,7 +91,7 @@ pFlow::selectRandom::selectRandom
|
|||||||
),
|
),
|
||||||
begin_
|
begin_
|
||||||
(
|
(
|
||||||
dict.subDict("selectRandomInfo").getVal<int32>("begin")
|
dict.subDict("selectRandomInfo").getVal<uint32>("begin")
|
||||||
),
|
),
|
||||||
end_
|
end_
|
||||||
(
|
(
|
||||||
@ -102,9 +102,9 @@ pFlow::selectRandom::selectRandom
|
|||||||
dict.subDict("selectRandomInfo").getValOrSet("number", 1)
|
dict.subDict("selectRandomInfo").getValOrSet("number", 1)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
begin_ = max(begin_,1);
|
begin_ = max(begin_,1u);
|
||||||
end_ = min(end_, static_cast<int32>(pStruct.size()));
|
end_ = min(end_, static_cast<uint32>(pStruct.size()));
|
||||||
number_ = max(number_,0);
|
number_ = max(number_,0u);
|
||||||
if(end_-begin_ < number_)
|
if(end_-begin_ < number_)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -37,16 +37,16 @@ class selectRandom
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
int32Vector selectedPoints_;
|
uint32Vector selectedPoints_;
|
||||||
|
|
||||||
// begin index
|
// begin index
|
||||||
int32 begin_;
|
uint32 begin_;
|
||||||
|
|
||||||
// end index
|
// end index
|
||||||
int32 end_;
|
uint32 end_;
|
||||||
|
|
||||||
// stride
|
// stride
|
||||||
int32 number_;
|
uint32 number_;
|
||||||
|
|
||||||
bool selectAllPointsInRange();
|
bool selectAllPointsInRange();
|
||||||
|
|
||||||
@ -69,12 +69,12 @@ public:
|
|||||||
|
|
||||||
//// - Methods
|
//// - Methods
|
||||||
|
|
||||||
virtual const int32Vector& selectedPoinsts()const override
|
virtual const uint32Vector& selectedPoinsts()const override
|
||||||
{
|
{
|
||||||
return selectedPoints_;
|
return selectedPoints_;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int32Vector& selectedPoinsts() override
|
virtual uint32Vector& selectedPoinsts() override
|
||||||
{
|
{
|
||||||
return selectedPoints_;
|
return selectedPoints_;
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,13 @@ Licence:
|
|||||||
void pFlow::selectRange::selectAllPointsInRange()
|
void pFlow::selectRange::selectAllPointsInRange()
|
||||||
{
|
{
|
||||||
// to reduct allocations
|
// to reduct allocations
|
||||||
int32 maxNum = (end_ - begin_)/stride_+2;
|
uint32 maxNum = (end_ - begin_)/stride_+2;
|
||||||
|
|
||||||
selectedPoints_.reserve (maxNum);
|
selectedPoints_.reserve (maxNum);
|
||||||
|
|
||||||
selectedPoints_.clear();
|
selectedPoints_.clear();
|
||||||
|
|
||||||
for(int32 i = begin_; i<end_; i+= stride_)
|
for(uint32 i = begin_; i<end_; i+= stride_)
|
||||||
{
|
{
|
||||||
selectedPoints_.push_back(i);
|
selectedPoints_.push_back(i);
|
||||||
}
|
}
|
||||||
@ -49,20 +49,20 @@ pFlow::selectRange::selectRange
|
|||||||
),
|
),
|
||||||
begin_
|
begin_
|
||||||
(
|
(
|
||||||
dict.subDict("selectRangeInfo").getVal<int32>("begin")
|
dict.subDict("selectRangeInfo").getVal<uint32>("begin")
|
||||||
),
|
),
|
||||||
end_
|
end_
|
||||||
(
|
(
|
||||||
dict.subDict("selectRangeInfo").getValOrSet("end", pStruct.size())
|
dict.subDict("selectRangeInfo").getValOrSet<uint32>("end", pStruct.size())
|
||||||
),
|
),
|
||||||
stride_
|
stride_
|
||||||
(
|
(
|
||||||
dict.subDict("selectRangeInfo").getValOrSet("stride", 1)
|
dict.subDict("selectRangeInfo").getValOrSet<uint32>("stride", 1u)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
begin_ = max(begin_,1);
|
begin_ = max(begin_,1u);
|
||||||
end_ = min(end_, static_cast<int32>(pStruct.size()));
|
end_ = min(end_, static_cast<uint32>(pStruct.size()));
|
||||||
stride_ = max(stride_,1);
|
stride_ = max(stride_,1u);
|
||||||
|
|
||||||
selectAllPointsInRange();
|
selectAllPointsInRange();
|
||||||
}
|
}
|
||||||
|
@ -37,16 +37,16 @@ class selectRange
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
int32Vector selectedPoints_;
|
uint32Vector selectedPoints_;
|
||||||
|
|
||||||
// begin index
|
// begin index
|
||||||
int32 begin_;
|
uint32 begin_;
|
||||||
|
|
||||||
// end index
|
// end index
|
||||||
int32 end_;
|
uint32 end_;
|
||||||
|
|
||||||
// stride
|
// stride
|
||||||
int32 stride_;
|
uint32 stride_;
|
||||||
|
|
||||||
void selectAllPointsInRange();
|
void selectAllPointsInRange();
|
||||||
|
|
||||||
@ -69,12 +69,12 @@ public:
|
|||||||
|
|
||||||
//// - Methods
|
//// - Methods
|
||||||
|
|
||||||
virtual const int32Vector& selectedPoinsts()const override
|
virtual const uint32Vector& selectedPoinsts()const override
|
||||||
{
|
{
|
||||||
return selectedPoints_;
|
return selectedPoints_;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int32Vector& selectedPoinsts() override
|
virtual uint32Vector& selectedPoinsts() override
|
||||||
{
|
{
|
||||||
return selectedPoints_;
|
return selectedPoints_;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user