Merge pull request #155 from PhasicFlow/develop

Develop
This commit is contained in:
PhasicFlow 2025-02-01 22:18:23 +03:30 committed by GitHub
commit d909301f32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
47 changed files with 580 additions and 384 deletions

View File

@ -77,6 +77,11 @@ public:
return true;
}
bool isActive()const override
{
return false;
}
static
uniquePtr<boundaryIntegration> create(
const boundaryBase& boundary,

View File

@ -7,11 +7,11 @@ pFlow::boundaryIntegrationList::boundaryIntegrationList(
integration &intgrtn
)
:
ListPtr<boundaryIntegration>(6),
boundaryListPtr<boundaryIntegration>(),
boundaries_(pStruct.boundaries())
{
for(uint32 i=0; i<6; i++)
ForAllBoundariesPtr(i, this)
{
this->set(
i,
@ -19,25 +19,23 @@ pFlow::boundaryIntegrationList::boundaryIntegrationList(
boundaries_[i],
pStruct,
method,
intgrtn
)
);
intgrtn
)
);
}
}
bool pFlow::boundaryIntegrationList::correct(real dt, realx3PointField_D &y, realx3PointField_D &dy)
{
for(auto& bndry:*this)
ForAllActiveBoundariesPtr(i,this)
{
if(!bndry->correct(dt, y, dy))
if(!boundaryPtr(i)->correct(dt, y, dy))
{
fatalErrorInFunction<<"Error in correcting boundary "<<
bndry->boundaryName()<<endl;
boundaryPtr(i)->boundaryName()<<endl;
return false;
}
}
}
return true;
}
@ -46,14 +44,15 @@ bool pFlow::boundaryIntegrationList::correctPStruct(
pointStructure &pStruct,
const realx3PointField_D &vel)
{
for(auto& bndry:*this)
ForAllActiveBoundariesPtr(i,this)
{
if(!bndry->correctPStruct(dt, vel))
if(!boundaryPtr(i)->correctPStruct(dt, vel))
{
fatalErrorInFunction<<"Error in correcting boundary "<<
bndry->boundaryName()<<" in pointStructure."<<endl;
boundaryPtr(i)->boundaryName()<<" in pointStructure."<<endl;
return false;
}
}
return true;
}

View File

@ -4,7 +4,7 @@
#include "boundaryList.hpp"
#include "ListPtr.hpp"
#include "boundaryListPtr.hpp"
#include "boundaryIntegration.hpp"
@ -15,7 +15,7 @@ class integration;
class boundaryIntegrationList
:
public ListPtr<boundaryIntegration>
public boundaryListPtr<boundaryIntegration>
{
private:

View File

@ -98,6 +98,11 @@ public:
return true;
}
bool isActive()const override
{
return false;
}
static uniquePtr<boundaryContactSearch> create(
const dictionary &dict,
const boundaryBase &boundary,

View File

@ -1,3 +1,23 @@
/*------------------------------- 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 "boundaryContactSearchList.hpp"
#include "boundaryList.hpp"
@ -5,7 +25,7 @@ void pFlow::boundaryContactSearchList::setList(
const dictionary &dict,
const contactSearch &cSearch)
{
for(auto i=0; i<boundaries_.size(); i++)
ForAllBoundariesPtr(i, this)
{
this->set
(
@ -20,7 +40,7 @@ pFlow::boundaryContactSearchList::boundaryContactSearchList(
const boundaryList& bndrs,
const contactSearch &cSearch)
:
ListPtr(bndrs.size()),
boundaryListPtr(),
boundaries_(bndrs)
{
setList(dict, cSearch);

View File

@ -1,4 +1,24 @@
#include "ListPtr.hpp"
/*------------------------------- 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 "boundaryListPtr.hpp"
#include "boundaryContactSearch.hpp"
namespace pFlow
@ -9,7 +29,7 @@ class contactSearch;
class boundaryContactSearchList
:
public ListPtr<boundaryContactSearch>
public boundaryListPtr<boundaryContactSearch>
{
private:

View File

@ -74,6 +74,11 @@ public:
csPairContainerType &ppPairs,
csPairContainerType &pwPairs,
bool force = false) override;
bool isActive()const override
{
return true;
}
};
}

View File

@ -152,8 +152,6 @@ public:
return false;
}
bool hearChanges
(
real t,
@ -170,6 +168,11 @@ public:
return true;
}
bool isActive()const override
{
return false;
}
static
uniquePtr<BoundaryGrainInteractionType> create(
const boundaryBase& boundary,

View File

@ -7,11 +7,11 @@ pFlow::boundaryGrainInteractionList<CFModel, gMModel>::boundaryGrainInteractionL
const gMModel &geomMotion
)
:
ListPtr<boundaryGrainInteraction<CFModel,gMModel>>(6),
boundaryListPtr<boundaryGrainInteraction<CFModel,gMModel>>(),
boundaries_(grnPrtcls.pStruct().boundaries())
{
//gSettings::sleepMiliSeconds(1000*pFlowProcessors().localRank());
for(uint32 i=0; i<6; i++)
ForAllBoundariesPtr(i, this)
{
this->set(
i,

View File

@ -3,7 +3,7 @@
#include "boundaryList.hpp"
#include "ListPtr.hpp"
#include "boundaryListPtr.hpp"
#include "boundaryGrainInteraction.hpp"
@ -14,7 +14,7 @@ namespace pFlow
template<typename contactForceModel,typename geometryMotionModel>
class boundaryGrainInteractionList
:
public ListPtr<boundaryGrainInteraction<contactForceModel,geometryMotionModel>>
public boundaryListPtr<boundaryGrainInteraction<contactForceModel,geometryMotionModel>>
{
private:

View File

@ -78,13 +78,15 @@ public:
~periodicBoundaryGrainInteraction()override = default;
bool grainGrainInteraction(
real dt,
const ContactForceModel& cfModel,
uint32 step)override;
bool isActive()const override
{
return true;
}
};

View File

@ -110,7 +110,7 @@ public:
return geometryMotion_;
}
ContactListType& ppPairs()
ContactListType& ppPairs()
{
return ppPairs_();
}
@ -170,6 +170,11 @@ public:
return true;
}
bool isActive()const override
{
return false;
}
static
uniquePtr<BoundarySphereInteractionType> create(
const boundaryBase& boundary,

View File

@ -7,11 +7,11 @@ pFlow::boundarySphereInteractionList<CFModel, gMModel>::boundarySphereInteractio
const gMModel &geomMotion
)
:
ListPtr<boundarySphereInteraction<CFModel,gMModel>>(6),
boundaryListPtr<boundarySphereInteraction<CFModel,gMModel>>(),
boundaries_(sphPrtcls.pStruct().boundaries())
{
//gSettings::sleepMiliSeconds(1000*pFlowProcessors().localRank());
for(uint32 i=0; i<6; i++)
ForAllActiveBoundariesPtr(i, this)
{
this->set(
i,

View File

@ -3,7 +3,7 @@
#include "boundaryList.hpp"
#include "ListPtr.hpp"
#include "boundaryListPtr.hpp"
#include "boundarySphereInteraction.hpp"
@ -14,7 +14,7 @@ namespace pFlow
template<typename contactForceModel,typename geometryMotionModel>
class boundarySphereInteractionList
:
public ListPtr<boundarySphereInteraction<contactForceModel,geometryMotionModel>>
public boundaryListPtr<boundarySphereInteraction<contactForceModel,geometryMotionModel>>
{
private:

View File

@ -76,15 +76,17 @@ public:
boundaryBase
);
~periodicBoundarySphereInteraction()override = default;
~periodicBoundarySphereInteraction()override = default;
bool sphereSphereInteraction(
real dt,
const ContactForceModel& cfModel,
uint32 step)override;
bool isActive()const override
{
return true;
}
};

View File

@ -145,11 +145,6 @@ pFlow::sphereInteraction<cFM,gMM, cLT>::sphereInteraction
{
fatalExit;
}
for(uint32 i=0; i<6; i++)
{
activeBoundaries_[i] = boundaryInteraction_[i].ppPairsAllocated();
}
}
template<typename cFM,typename gMM,template <class, class, class> class cLT>
@ -193,15 +188,14 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
{
contactListMangementBoundaryTimer_.start();
ComputationTimer().start();
for(uint32 i=0; i<6u; i++)
ForAllActiveBoundaries(i, boundaryInteraction_)
{
if(activeBoundaries_[i])
{
auto& BI = boundaryInteraction_[i];
BI.ppPairs().beforeBroadSearch();
BI.pwPairs().beforeBroadSearch();
}
auto& BI = boundaryInteraction_[i];
BI.ppPairs().beforeBroadSearch();
BI.pwPairs().beforeBroadSearch();
}
ComputationTimer().end();
contactListMangementBoundaryTimer_.pause();
}
@ -219,22 +213,19 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
fatalExit;
}
for(uint32 i=0; i<6u; i++)
ForAllActiveBoundaries(i, boundaryInteraction_)
{
if(activeBoundaries_[i])
auto& BI = boundaryInteraction_[i];
if(!contactSearchRef.boundaryBroadSearch(
i,
ti,
BI.ppPairs(),
BI.pwPairs())
)
{
auto& BI = boundaryInteraction_[i];
if(!contactSearchRef.boundaryBroadSearch(
i,
ti,
BI.ppPairs(),
BI.pwPairs())
)
{
fatalErrorInFunction<<
"failed to perform broadSearch for boundary index "<<i<<endl;
return false;
}
fatalErrorInFunction<<
"failed to perform broadSearch for boundary index "<<i<<endl;
return false;
}
}
ComputationTimer().end();
@ -253,15 +244,14 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
{
contactListMangementBoundaryTimer_.resume();
ComputationTimer().start();
for(uint32 i=0; i<6u; i++)
ForAllActiveBoundaries(i, boundaryInteraction_ )
{
if(activeBoundaries_[i])
{
auto& BI = boundaryInteraction_[i];
BI.ppPairs().afterBroadSearch();
BI.pwPairs().afterBroadSearch();
}
auto& BI = boundaryInteraction_[i];
BI.ppPairs().afterBroadSearch();
BI.pwPairs().afterBroadSearch();
}
ComputationTimer().end();
contactListMangementBoundaryTimer_.end();
}
@ -274,7 +264,7 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
ComputationTimer().start();
while(requireStep.anyElement(true) && step <= 10)
{
for(uint32 i=0; i<6u; i++)
ForAllBoundaries(i, boundaryInteraction_)
{
if(requireStep[i] )
{
@ -313,7 +303,7 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
const auto& cfModel = this->forceModel_();
while( requireStep.anyElement(true) && step < 20 )
{
for(uint32 i=0; i<6u; i++)
ForAllBoundaries(i, boundaryInteraction_)
{
if(requireStep[i])
{

View File

@ -65,6 +65,11 @@ public:
return true;
}
bool isActive()const override
{
return false;
}
static
uniquePtr<boundaryGrainParticles> create(
const boundaryBase &boundary,

View File

@ -5,10 +5,10 @@ pFlow::boundaryGrainParticlesList::boundaryGrainParticlesList(
grainParticles &prtcls
)
:
ListPtr(bndrs.size()),
boundaryListPtr(),
boundaries_(bndrs)
{
for(auto i=0; i<boundaries_.size(); i++)
ForAllBoundariesPtr(i, this)
{
this->set
(
@ -16,4 +16,5 @@ pFlow::boundaryGrainParticlesList::boundaryGrainParticlesList(
boundaryGrainParticles::create(boundaries_[i], prtcls)
);
}
}

View File

@ -3,7 +3,7 @@
#ifndef __boundaryGrainParticlesList_hpp__
#define __boundaryGrainParticlesList_hpp__
#include "ListPtr.hpp"
#include "boundaryListPtr.hpp"
#include "boundaryList.hpp"
#include "boundaryGrainParticles.hpp"
@ -12,7 +12,7 @@ namespace pFlow
class boundaryGrainParticlesList
:
public ListPtr<boundaryGrainParticles>
public boundaryListPtr<boundaryGrainParticles>
{
private:

View File

@ -316,9 +316,10 @@ bool pFlow::grainParticles::iterate()
accelertion().deviceViewAll(),
rAcceleration().deviceViewAll()
);
for(auto& bndry:boundaryGrainParticles_)
ForAllActiveBoundaries(i,boundaryGrainParticles_)
{
bndry->acceleration(ti, g);
boundaryGrainParticles_[i].acceleration(ti, g);
}
accelerationTimer_.end();

View File

@ -65,6 +65,11 @@ public:
return true;
}
bool isActive()const override
{
return false;
}
static
uniquePtr<boundarySphereParticles> create(
const boundaryBase &boundary,

View File

@ -5,10 +5,10 @@ pFlow::boundarySphereParticlesList::boundarySphereParticlesList(
sphereParticles &prtcls
)
:
ListPtr(bndrs.size()),
boundaryListPtr(),
boundaries_(bndrs)
{
for(auto i=0; i<boundaries_.size(); i++)
ForAllBoundariesPtr(i, this)
{
this->set
(

View File

@ -3,7 +3,7 @@
#ifndef __boundarySphereParticlesList_hpp__
#define __boundarySphereParticlesList_hpp__
#include "ListPtr.hpp"
#include "boundaryListPtr.hpp"
#include "boundaryList.hpp"
#include "boundarySphereParticles.hpp"
@ -12,7 +12,7 @@ namespace pFlow
class boundarySphereParticlesList
:
public ListPtr<boundarySphereParticles>
public boundaryListPtr<boundarySphereParticles>
{
private:

View File

@ -552,10 +552,11 @@ bool pFlow::sphereParticles::iterate()
accelertion().deviceViewAll(),
rAcceleration().deviceViewAll()
);
for(auto& bndry:boundarySphereParticles_)
ForAllActiveBoundaries(i,boundarySphereParticles_)
{
bndry->acceleration(ti, g);
boundarySphereParticles_[i].acceleration(ti, g);
}
accelerationTimer_.end();
intCorrectTimer_.start();

View File

@ -1,87 +0,0 @@
list(APPEND SourceFiles
types/basicTypes/bTypesFunctions.cpp
types/basicTypes/Logical.cpp
types/types.cpp
globals/error.cpp
streams/token/tokenIO.cpp
streams/token/token.cpp
streams/iStream/IOstream.cpp
streams/iStream/iIstream.cpp
streams/iStream/iOstream.cpp
streams/Stream/Istream.cpp
streams/Stream/Ostream.cpp
streams/Fstream/iFstream.cpp
streams/Fstream/oFstream.cpp
streams/Fstream/fileStream.cpp
streams/TStream/iTstream.cpp
streams/TStream/oTstream.cpp
streams/streams.cpp
dictionary/dictionary.cpp
dictionary/entry/iEntry.cpp
dictionary/entry/dataEntry.cpp
dictionary/twoPartEntry/twoPartEntry.cpp
fileSystem/fileSystem.cpp
commandLine/commandLine.cpp
random/randomReal/randomReal.cpp
random/randomReal/randomReals.cpp
Timer/Timer.cpp
Timer/Timers.cpp
repository/Time/Time.cpp
repository/Time/timeControl.cpp
repository/systemControl/systemControl.cpp
repository/systemControl/dynamicLinkLibs.cpp
repository/repository/repository.cpp
repository/IOobject/objectFile.cpp
repository/IOobject/IOobject.cpp
repository/IOobject/IOfileHeader.cpp
structuredData/box/box.cpp
structuredData/cells/cells.cpp
structuredData/cylinder/cylinder.cpp
structuredData/sphere/sphere.cpp
structuredData/iBox/iBoxs.cpp
structuredData/line/line.cpp
structuredData/zAxis/zAxis.cpp
structuredData/pointStructure/pointStructure.cpp
structuredData/pointStructure/mortonIndexing.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
structuredData/trisurfaceStructure/triSurface.cpp
structuredData/trisurfaceStructure/multiTriSurface.cpp
structuredData/trisurfaceStructure/stlFile.cpp
structuredData/peakableRegion/sphereRegion/sphereRegion.cpp
structuredData/peakableRegion/cylinderRegion/cylinderRegion.cpp
structuredData/peakableRegion/boxRegion/boxRegion.cpp
structuredData/peakableRegion/peakableRegion/peakableRegion.cpp
structuredData/peakableRegion/peakableRegions.cpp
containers/Vector/Vectors.cpp
containers/Field/Fields.cpp
containers/symArrayHD/symArrays.cpp
containers/triSurfaceField/triSurfaceFields.cpp
containers/bitsetHD/bitsetHDs.cpp
containers/indexContainer/indexContainer.cpp
setFieldList/setFieldList.cpp
setFieldList/setFieldEntry.cpp
eventSubscriber/eventSubscriber.cpp
eventSubscriber/eventObserver.cpp)
set(link_libs Kokkos::kokkos tbb)
pFlow_add_library_install(phasicFlow SourceFiles link_libs)
target_include_directories(phasicFlow PUBLIC ./Kokkos ./algorithms ./globals)

View File

@ -184,6 +184,12 @@ public:
return;
}
bool isActive()const override
{
return false;
}
static
uniquePtr<boundaryField> create(
const boundaryBase& boundary,

View File

@ -22,7 +22,7 @@ Licence:
#include "boundaryField.hpp"
#include "boundaryList.hpp"
#include "ListPtr.hpp"
#include "boundaryListPtr.hpp"
namespace pFlow
@ -31,7 +31,7 @@ namespace pFlow
template< class T, class MemorySpace = void >
class boundaryFieldList
:
public ListPtr< boundaryField<T, MemorySpace> >
public boundaryListPtr< boundaryField<T, MemorySpace> >
{
public:
@ -50,10 +50,10 @@ public:
boundaryFieldList(const boundaryList& boundaries, InternalFieldType& internal)
:
ListPtr<BoundaryFieldType>(boundaries.size()),
boundaryListPtr<BoundaryFieldType>(),
boundaries_(boundaries)
{
for(auto i=0; i<boundaries.size(); i++)
ForAllBoundaries(i, *this)
{
this->set
(
@ -68,26 +68,18 @@ public:
if( direction == DataDirection::SlaveToMaster
&& slaveToMasterUpdateIter_ == iter) return;
// first step
uint32 i=0;
for(auto b:*this)
ForAllBoundaries(i,*this)
{
if(i==0 )
{
//pOutput<<"request for update boundaries for field "<< b->name()<<endl;
i++;
}
b->updateBoundary(1, direction);
this->boundaryPtr(i)->updateBoundary(1, direction);
}
// second step
for(auto b:*this)
ForAllBoundaries(i,*this)
{
b->updateBoundary(2, direction);
this->boundaryPtr(i)->updateBoundary(1, direction);
}
if(direction == DataDirection::SlaveToMaster)
{
slaveToMasterUpdateIter_ = iter;
@ -96,9 +88,9 @@ public:
void fill(const T& val)
{
for(auto& bf: *this)
ForAllBoundaries(i, *this)
{
bf->fill(val);
this->boundaryPtr(i)->fill(val);
}
}

View File

@ -81,6 +81,11 @@ public:
return true;
}
bool isActive()const override
{
return false;
}
};
}

View File

@ -147,6 +147,9 @@ public:
}
const Time& time()const;
virtual
bool isActive()const = 0;
};

View File

@ -81,6 +81,10 @@ public:
return true;
}
bool isActive()const override
{
return false;
}
};
}

View File

@ -26,60 +26,65 @@ Licence:
namespace pFlow {
///
/// @class span
/// @brief Represents a view into a contiguous sequence of elements.
///
/// `span` provides a lightweight way to work with arrays and other contiguous
/// sequences without the overhead of copying. This will word on both GPU and CPU
template<typename T>
class span
{
public:
using iterator = T*;
using iterator = T*;
using constIterator = const T*;
using reference = T&;
using constReference = const T&;
using constIterator = const T*;
using reference = T&;
using constReference = const T&;
using valueType = T;
using pointer = T*;
using constPointer = const T*;
using valueType = T;
using pointer = T*;
using constPointer = const T*;
protected:
private:
T* data_ = nullptr;
uint32 size_ = 0;
mutable T* data_ = nullptr;
index size_ = 0;
public:
TypeInfoTemplateNV11("span", T);
/// Constructor
/// Constructor with no arguments
INLINE_FUNCTION_HD
span() = default;
/// Constructor that takes a pointer to the beginning of the data and the size of the span
INLINE_FUNCTION_HD
span(T* data, uint32 size)
: data_(data), size_(size)
{}
/// copy
/// copy constructor
INLINE_FUNCTION_HD
span(const span&) = default;
/// assignment
/// copy assignment operator
INLINE_FUNCTION_HD
span& operator=(const span&) = default;
/// move
/// move constructor
INLINE_FUNCTION_HD
span(span&&) = default;
/// assignment
/// move assignment operator
INLINE_FUNCTION_HD
span& operator=(span&) = default;
@ -90,6 +95,7 @@ public:
return size_ == 0;
}
/// Returns a pointer to the beginning of the data
INLINE_FUNCTION_HD
T* data() const
{
@ -98,7 +104,7 @@ public:
/// Returns the number of elements in the span
INLINE_FUNCTION_HD
uint32 size() const
index size() const
{
return size_;
}
@ -110,7 +116,7 @@ public:
return data_;
}
/// Returns an iterator to the beginning of the span
/// Returns an iterator to the beginning of the span (const version)
INLINE_FUNCTION_HD
constIterator cbegin() const
{
@ -124,93 +130,59 @@ public:
return data_ + size_;
}
/// Returns an iterator to one past the end of the span
/// Returns an iterator to one past the end of the span (const version)
INLINE_FUNCTION_HD
constIterator cend() const
{
return data_ + size_;
}
/// Returns a reference to the element at the specified index
INLINE_FUNCTION_HD
T& operator[](uint32 i)
T& operator[](index i)
{
return data_[i];
return data_[i];
}
/// Returns a const reference to the element at the specified index
INLINE_FUNCTION_HD
const T& operator[](uint32 i)const
T& operator[](index i)const
{
return data_[i];
}
INLINE_FUNCTION_HD
T& operator[](int32 i)
{
return data_[i];
}
INLINE_FUNCTION_HD
const T& operator[](int32 i)const
{
return data_[i];
return data_[i];
}
};
/*template<typename T, typename... properties, template<class, class...> class Container>
size_t makeSpan(Container<T, properties...>& container)
{
return span<T>(container.data(), container.size());
}
template<typename T, typename... properties, template<class, class...> class Container>
size_t makeSpan(const Container<T, properties...>& container)
{
return span<T>(
const_cast<T*>(container.data()),
container.size());
}*/
/// Creates a span of char from a span of any type.
///
/// This helper function reinterprets the underlying memory of the given span
/// as a span of char.
template<typename T>
inline
span<char> charSpan(span<T> s)
{
auto el = sizeof(T);
return span<char>(
reinterpret_cast<char*>(s.data()),
s.size()*el);
auto el = sizeof(T);
return span<char>(
reinterpret_cast<char*>(s.data()),
s.size()*el);
}
/// Creates a span of const char from a span of const any type.
///
/// This helper function reinterprets the underlying memory of the given span
/// as a span of const char.
template<typename T>
inline
span<const char> charSpan(span<const T> s)
{
auto el = sizeof(T);
return span<const char>(
reinterpret_cast<const char*>(s.data()),
s.size()*el);
auto el = sizeof(T);
return span<const char>(
reinterpret_cast<const char*>(s.data()),
s.size()*el);
}
/*template<typename T, template<class> class Container>
span<T> makeSpan(Container<T>& container)
{
return span<T>(container.data(), container.size());
}
template<typename T, template<class> class Container>
span<T> makeSpan(const Container<T>& container)
{
return span<T>(
const_cast<T*>(container.data()),
container.size());
}*/
} // pFlow
#endif //__span_hpp__
#endif //__span_hpp__

View File

@ -25,15 +25,12 @@ Licence:
#include "message.hpp"
pFlow::subscriber::subscriber(const subscriber & src)
:
subName_(src.subName_)
{
}
pFlow::subscriber::subscriber(subscriber && src)
:
observerList_(std::move(src.observerList_)),
subName_(std::move(src.subName_))
observerList_(std::move(src.observerList_))
{
for(size_t i=0; i<observerList_.size(); i++)
@ -47,13 +44,13 @@ pFlow::subscriber::subscriber(subscriber && src)
pFlow::subscriber &pFlow::subscriber::operator=(const subscriber & rhs)
{
this->subName_ = rhs.subName_;
//this->subName_ = rhs.subName_;
return *this;
}
pFlow::subscriber &pFlow::subscriber::operator=(subscriber && rhs)
{
this->subName_ = std::move(rhs.subName_);
//this->subName_ = std::move(rhs.subName_);
this->observerList_ = std::move(rhs.observerList_);
for(size_t i=0; i<observerList_.size(); i++)

View File

@ -39,15 +39,13 @@ class subscriber
private:
// - list of subsribed objectd that recieve updage messages
mutable std::array<List<observer*>,message::numEvents()> observerList_;
mutable std::vector<List<observer*>> observerList_{message::numEvents()};
word subName_;
//word subName_;
public:
subscriber(const word& name)
:
subName_(name)
{}
/// Copy constructor, only copies the name, not the list
@ -82,9 +80,9 @@ public:
const message msg,
const anyList& varList);
const word& subscriberName()const
word subscriberName()const
{
return subName_;
return "subscriber"; //subName_;
}
};

View File

@ -32,41 +32,35 @@ Licence:
static pFlow::Ostream& errorStream = pFlow::pOutput;
pFlow::iOstream&
fatalErrorMessage(const char* fileName, int linNumber)
pFlow::fatalErrorMessage(const char* fileName, int lineNumber)
{
errorStream << "\n>>> Fatal error in phasicFlow\n"
<< "Error occured in source file " << Red_Text(fileName)
<< " at line " << Red_Text(linNumber) << '\n';
errorStream << "\nError occured in file ("<<lineNumber<<"):" <<Red_Text(fileName)<<'\n';
return errorStream;
}
pFlow::iOstream&
fatalErrorInMessage(const char* fnName, const char* fileName, int linNumber)
pFlow::fatalErrorInMessage(const char* fnName, const char* fileName, int lineNumber)
{
errorStream << "\n>>> Fatal error in phasicFlow\n"
<< " Error is issued in function " << Red_Text(fnName)
<< ", located in file " << Red_Text(fileName) << " at line "
<< Red_Text(linNumber) << '\n';
errorStream << "\nError occured in file ("<<lineNumber<<"):" <<Red_Text(fileName)<<'\n'<<
"Function: "<<Red_Text(fnName)<<'\n';
return errorStream;
}
pFlow::iOstream&
notImplementedErrorMessage(
pFlow::notImplementedErrorMessage(
const char* fnName,
const char* fileName,
int lineNumber
)
{
errorStream << "\n>>> Fatal error in phasicFlow\n";
errorStream << " Function " << Red_Text(fnName)
errorStream << "\n Function " << Yellow_Text(fnName)
<< " has not been implemented yet!\n"
<< " File " << Yellow_Text(fileName) << " at line "
<< Yellow_Text(lineNumber) << '\n';
<< " Look into file ("<<lineNumber<<"):" <<fileName<<'\n';
return errorStream;
}
pFlow::iOstream&
ioErrorMessage(
pFlow::ioErrorMessage(
const char* fileName,
int fileLineNumber,
const char* fnName,
@ -84,7 +78,7 @@ ioErrorMessage(
}
pFlow::iOstream&
ioErrorMessage(
pFlow::ioErrorMessage(
const pFlow::word& fileName,
int fileLineNumber,
const char* fnName,
@ -98,7 +92,7 @@ ioErrorMessage(
}
pFlow::iOstream&
warningMessage(const char* fnName, const char* fileName, int linNumber)
pFlow::warningMessage(const char* fnName, const char* fileName, int linNumber)
{
errorStream << "\n>>> Warning in phasicFlow\n"
<< " Warning is issued in function " << Yellow_Text(fnName)
@ -108,7 +102,7 @@ warningMessage(const char* fnName, const char* fileName, int linNumber)
}
pFlow::iOstream&
reportAndExit(int errorCode)
pFlow::reportAndExit(int errorCode)
{
errorStream << "\n>>> phasicFlow is exiting . . ." << pFlow::endl;
fatalExitPhasicFlow(errorCode);
@ -116,7 +110,7 @@ reportAndExit(int errorCode)
}
int
fatalExitPhasicFlow(int errorCode)
pFlow::fatalExitPhasicFlow(int errorCode)
{
// Kokkos should be finalized first
Kokkos::finalize();

View File

@ -27,7 +27,7 @@ Licence:
namespace pFlow
{
class iOstream;
}
//- Decleartions
@ -66,35 +66,37 @@ warningMessage(const char* fnName, const char* fileName, int linNumber);
pFlow::iOstream&
reportAndExit(int errorCode = EXIT_FAILURE);
}
/// Report a fatal error and exit the applicaiton
#define fatalError fatalErrorMessage(__FILE__, __LINE__)
#define fatalError pFlow::fatalErrorMessage(__FILE__, __LINE__)
/// Report a fatal error and supplied function name and exit the application
#define fatalErrorIn(functionName) \
fatalErrorInMessage((functionName), __FILE__, __LINE__)
pFlow::fatalErrorInMessage((functionName), __FILE__, __LINE__)
/// Report a fatal error and function name and exit the application
#define fatalErrorInFunction fatalErrorIn(FUNCTION_NAME)
/// Report that a function is yet not implemented with supplied function name.
#define Not_Implemented(functionName) \
notImplementedErrorMessage((functionName), __FILE__, __LINE__)
pFlow::notImplementedErrorMessage((functionName), __FILE__, __LINE__)
/// Report that a function is yet not implemented.
#define notImplementedFunction Not_Implemented(FUNCTION_NAME)
/// Report an error in file operation with supplied fileName and lineNumber.
#define ioErrorInFile(fileName, lineNumber) \
ioErrorMessage(fileName, lineNumber, FUNCTION_NAME, __FILE__, __LINE__)
pFlow::ioErrorMessage(fileName, lineNumber, FUNCTION_NAME, __FILE__, __LINE__)
/// Report a warning with supplied function name
#define warningIn(functionName) \
warningMessage((functionName), __FILE__, __LINE__)
pFlow::warningMessage((functionName), __FILE__, __LINE__)
/// Report a warning
#define warningInFunction warningIn(FUNCTION_NAME)
/// Fatal exit
#define fatalExit reportAndExit()
#define fatalExit pFlow::reportAndExit()
#endif

View File

@ -60,7 +60,7 @@ private:
fileSystem localPath_ = "";
/// Number of bytes used for writing/reading real variable (used for binray)
int numBytesForReal_ = numBytesForReal__;
int numBytesForReal_ = sizeof(real);
/// Does the objectFile read & write the header?
bool readWriteHeader_ = true;

View File

@ -1,4 +1,3 @@
#ifndef __boundariesMask_hpp__
#define __boundariesMask_hpp__

View File

@ -119,7 +119,7 @@ bool pFlow::boundaryBase::removeIndices
if( !this->notify(iter, t, dt, msgBndry, aList) )
{
fatalErrorInFunction<<"Error in notify operation in boundary "<<
name_ <<endl;
name() <<endl;
return false;
}
@ -233,16 +233,16 @@ pFlow::boundaryBase::boundaryBase(
indexList_(groupNames("indexList", dict.name())),
indexListHost_(groupNames("hostIndexList", dict.name())),
neighborLength_(dict.getVal<real>("neighborLength")),
// updateInetrval_(dict.getVal<uint32>("updateInterval")),
boundaryExtntionLengthRatio_(dict.getVal<real>("boundaryExtntionLengthRatio")),
internal_(internal),
boundaries_(bndrs),
thisBoundaryIndex_(thisIndex),
neighborProcessorNo_(dict.getVal<int32>("neighborProcessorNo")),
isBoundaryMaster_(thisProcessorNo() >= neighborProcessorNo()),
name_(dict.name()),
type_(dict.getVal<word>("type"))
type_(makeUnique<word>(dict.getVal<word>("type")))
{
isBoundaryMaster_ = thisProcessorNo() >= neighborProcessorNo();
unSyncLists();
}

View File

@ -31,6 +31,14 @@ Licence:
namespace pFlow
{
static
inline const std::array<word,6> boundaryNames_ =
{
"left", "right",
"bottom", "top",
"rear", "front"
};
// forward
class internalPoints;
@ -61,16 +69,18 @@ private:
/// list of particles indieces on host
mutable uint32Vector_H indexListHost_;
/// device and host list are sync
mutable bool listsSync_ = false;
/// The length defined for creating neighbor list
real neighborLength_;
/// device and host list are sync
mutable bool listsSync_ = false;
bool updateTime_ = false;
bool iterBeforeUpdate_ = false;
bool isBoundaryMaster_;
/// the extra boundary extension beyound actual limits of boundary
real boundaryExtntionLengthRatio_;
@ -85,11 +95,7 @@ private:
int neighborProcessorNo_;
bool isBoundaryMaster_;
word name_;
word type_;
uniquePtr<word> type_;
protected:
@ -251,13 +257,13 @@ public:
inline
const word& type()const
{
return type_;
return type_();
}
inline
const word& name()const
{
return name_;
return boundaryNames_[thisBoundaryIndex_];
}
inline
@ -406,6 +412,12 @@ public:
return 0u;
}
inline
bool isActive()const
{
return true;
}
/// - static create
static
uniquePtr<boundaryBase> create

View File

@ -39,7 +39,8 @@ pFlow::boundaryList::setExtendedDomain()
boundary(3).boundaryExtensionLength() +
boundary(5).boundaryExtensionLength();
extendedDomain_ = pStruct_.simDomain().extendThisDomain(lowerExt, upperExt);
extendedDomain_ = makeUnique<domain>(
pStruct_.simDomain().extendThisDomain(lowerExt, upperExt));
}
bool
@ -66,7 +67,7 @@ pFlow::boundaryList::updateNeighborLists()
dist[4] = boundary(4).neighborLength();
dist[5] = boundary(5).neighborLength();
pStruct_.updateFlag(extendedDomain_, dist);
pStruct_.updateFlag(extendedDomain_(), dist);
const auto& maskD = pStruct_.activePointsMaskDevice();
boundary(0).setSize(maskD.leftSize());
@ -88,8 +89,8 @@ pFlow::boundaryList::updateNeighborLists()
return true;
}
pFlow::boundaryList::boundaryList(pointStructure& pStruct)
: ListPtr<boundaryBase>(pStruct.simDomain().sizeOfBoundaries()),
pFlow::boundaryList::boundaryList(pointStructure& pStruct):
boundaryListPtr<boundaryBase>(),
pStruct_(pStruct)
{
const dictionary& dict= pStruct_.simDomain().thisBoundariesDict();
@ -143,7 +144,7 @@ pFlow::boundaryList::createBoundaries()
if (listSet_)
return true;
for (auto i = 0; i < pStruct_.simDomain().sizeOfBoundaries(); i++)
ForAllBoundaries(i, *this)
{
this->set(
i,
@ -155,7 +156,9 @@ pFlow::boundaryList::createBoundaries()
i
)
);
}
listSet_ = true;
setExtendedDomain();
return true;
@ -197,7 +200,24 @@ pFlow::boundaryList::beforeIteration(const timeInfo& ti, bool force)
while(callAgain.anyElement(true) && step <= 10u)
{
for(size_t i=0; i<6ul; i++)
ForAllBoundaries(i,*this)
{
if(callAgain[i])
{
if(! boundary(i).beforeIteration(
step,
ti,
boundaryUpdate_,
iterBeforeBoundaryUpdate_,
callAgain[i]))
{
fatalErrorInFunction<<"error in performing beforeIteration for boundary"<<
boundary(i).name()<<" at step "<< step<<endl;
return false;
}
}
}
/*for(size_t i=0; i<6ul; i++)
{
if(callAgain[i])
@ -214,21 +234,28 @@ pFlow::boundaryList::beforeIteration(const timeInfo& ti, bool force)
return false;
}
}
}
}*/
step++;
}
for (auto bdry : *this)
ForAllBoundaries(i,*this)
{
boundary(i).updataBoundaryData(1);
}
/*for (auto bdry : *this)
{
bdry->updataBoundaryData(1);
}
}*/
for (auto bdry : *this)
ForAllBoundaries(i,*this)
{
boundary(i).updataBoundaryData(2);
}
/*for (auto bdry : *this)
{
bdry->updataBoundaryData(2);
}
}*/
return true;
}
@ -236,7 +263,16 @@ pFlow::boundaryList::beforeIteration(const timeInfo& ti, bool force)
bool
pFlow::boundaryList::iterate(const timeInfo& ti, bool force)
{
for (auto& bdry : *this)
ForAllBoundaries(i, *this)
{
if (!boundary(i).iterate(ti))
{
fatalErrorInFunction << "Error in iterate in boundary "
<< boundary(i).name() << endl;
return false;
}
}
/*for (auto& bdry : *this)
{
if (!bdry->iterate(ti))
{
@ -244,7 +280,7 @@ pFlow::boundaryList::iterate(const timeInfo& ti, bool force)
<< bdry->name() << endl;
return false;
}
}
}*/
return true;
}
@ -257,7 +293,7 @@ pFlow::boundaryList::afterIteration(const timeInfo& ti, bool force)
int step = 1;
while(callAgain.anyElement(true)&& step <=10)
{
for(size_t i=0; i<6; i++)
ForAllBoundaries(i,*this)
{
if(callAgain[i])
{

View File

@ -22,7 +22,7 @@ Licence:
#include "domain.hpp"
#include "boundaryBase.hpp"
#include "ListPtr.hpp"
#include "boundaryListPtr.hpp"
#include "timeInfo.hpp"
#include "boundariesMask.hpp"
@ -34,13 +34,11 @@ class pointStructure;
class boundaryList
:
public ListPtr<boundaryBase>
public boundaryListPtr<boundaryBase>
{
private:
//// - data members
pointStructure& pStruct_;
uint32 neighborListUpdateInterval_;
uint32 updateInterval_;
@ -53,12 +51,14 @@ private:
bool iterBeforeBoundaryUpdate_;
domain extendedDomain_;
box internalDomainBox_;
bool listSet_ = false;
pointStructure& pStruct_;
uniquePtr<domain> extendedDomain_;
box internalDomainBox_;
void setExtendedDomain();
bool resetLists();
@ -94,13 +94,13 @@ public:
inline
auto& boundary(size_t i)
{
return ListPtr<boundaryBase>::operator[](i);
return boundaryListPtr<boundaryBase>::operator[](i);
}
inline
const auto& boundary(size_t i)const
{
return ListPtr<boundaryBase>::operator[](i);
return boundaryListPtr<boundaryBase>::operator[](i);
}
inline
@ -112,13 +112,13 @@ public:
inline
const auto& extendedDomain()const
{
return extendedDomain_;
return extendedDomain_();
}
inline
const auto& extendedDomainBox()const
{
return extendedDomain_.domainBox();
return extendedDomain_->domainBox();
}
box internalDomainBox()const;

View File

@ -0,0 +1,186 @@
/*------------------------------- 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 __boundaryListPtr_hpp__
#define __boundaryListPtr_hpp__
#include <bitset>
#include <array>
#include "uniquePtr.hpp"
#include "error.h"
#include "iOstream.hpp"
namespace pFlow
{
template<typename BoundaryType>
class boundaryListPtr
{
private:
std::array<BoundaryType*,6> boundaries_;
std::bitset<6> activeBoundaries_=0B000000;
public:
boundaryListPtr():
boundaries_({nullptr, nullptr, nullptr, nullptr, nullptr, nullptr})
{}
void set(size_t i, uniquePtr<BoundaryType>&& ptr )
{
if( i > boundaries_.size() )
{
fatalErrorInFunction<<
"Out of range access of boundaryListPtr members. List size is "<<
size() << "and you are accessing "<< i << "\n";
fatalExit;
}
if(boundaries_[i]) delete boundaries_[i];
boundaries_[i] = ptr.release();
if(boundaries_[i])
{
// query if this boundary active or not
activeBoundaries_.set(i,boundaries_[i]->isActive());
}
}
~boundaryListPtr()
{
clear();
}
void clear()
{
for(auto& bndry:boundaries_)
{
if(bndry != nullptr)
{
delete bndry;
bndry = nullptr;
}
}
activeBoundaries_.reset();
}
// - access to ith element
inline
BoundaryType& operator[](size_t i)
{
if(boundaries_[i]== nullptr)
{
fatalErrorInFunction<<"Accessing nullptr element"<<endl;
fatalExit;
}
return *boundaries_[i];
}
// - const access to ith element
// fatalexit if out of range or nullptr
inline
const BoundaryType& operator[](size_t i) const
{
if(boundaries_[i]== nullptr)
{
fatalErrorInFunction<<"Accessing nullptr element"<<endl;
fatalExit;
}
return *boundaries_[i];
}
inline
BoundaryType* boundaryPtr(size_t i)
{
if(boundaries_[i]== nullptr)
{
fatalErrorInFunction<<"Accessing nullptr element"<<endl;
fatalExit;
}
return boundaries_[i];
}
inline
const BoundaryType* boundaryPtr(size_t i)const
{
if(boundaries_[i]== nullptr)
{
fatalErrorInFunction<<"Accessing nullptr element"<<endl;
fatalExit;
}
return boundaries_[i];
}
inline constexpr
size_t size()const
{
return 6ul;
}
inline
size_t firstActive()const
{
if(activeBoundaries_[0]) return 0ul;
if(activeBoundaries_[1]) return 1ul;
if(activeBoundaries_[2]) return 2ul;
if(activeBoundaries_[3]) return 3ul;
if(activeBoundaries_[4]) return 4ul;
if(activeBoundaries_[5]) return 5ul;
return 6ul;
}
inline
size_t nextActive(size_t i)const
{
if(i>=5ul) return 6ul;
if(activeBoundaries_[i+1])
return i+1;
else
return nextActive(i+1);
}
inline
bool allActive()const
{
return activeBoundaries_.all();
}
inline
bool anyActive()const
{
return activeBoundaries_.any();
}
inline
bool noneActive()const
{
return activeBoundaries_.none();
}
};
}
#define ForAllBoundaries(i,bndryList) for(size_t i = 0ul; i<(bndryList).size(); i++)
#define ForAllBoundariesPtr(i,bndryList) for(size_t i = 0ul; i<bndryList->size(); i++)
#define ForAllActiveBoundaries(i,bndryList) for(size_t i = bndryList.firstActive(); i<bndryList.size(); i=bndryList.nextActive(i))
#define ForAllActiveBoundariesPtr(i,bndryList) for(size_t i = bndryList->firstActive(); i<bndryList->size(); i=bndryList->nextActive(i))
#endif //__boundaryListPtr_hpp__

View File

@ -277,7 +277,7 @@ equal(const uint32& s1, const uint32& s2)
}
/// Are two words equal (host only)?
INLINE_FUNCTION
inline
bool
equal(const word& s1, const word& s2)
{

View File

@ -29,20 +29,22 @@ namespace pFlow
{
#ifdef pFlow_Build_Double
#define useDouble 1
inline const char* floatingPointType__ = "double";
inline const bool usingDouble__ = true;
#define UseDouble 1
inline const char* floatingPointType__ = "double";
inline const bool usingDouble__ = true;
#else
#define useDouble 0
inline const char* floatingPointType__ = "float";
inline const bool usingDouble__ = false;
#define UseDouble 0
inline const char* floatingPointType__ = "float";
inline const bool usingDouble__ = false;
#endif
// scalars
#if useDouble
using real = double;
#if UseDouble
using real = double;
#else
using real = float;
using real = float;
#endif
using int8 = signed char;
@ -57,21 +59,27 @@ using uint32 = unsigned int;
using uint64 = unsigned long long int;
using id_t = uint32;
using size_t = std::size_t;
using word = std::string;
using timeValue = double;
inline const int numBytesForReal__ = sizeof(real);
#ifdef pFlow_Build_Index64
#define Index64 1
using index = std::size_t;
inline const char* IndexType__ = "std::size_t";
#else
#define Index64 0
using index = uint32;
inline const char* IndexType__ = "uint32";
#endif
inline word
floatingPointDescription()
{
return word("In this build, ") + word(floatingPointType__) +
word(" is used for floating point operations.");
word(" is used for floating point operations and ") +
IndexType__ + "for indexing.";
}
} // end of pFlow

View File

@ -114,13 +114,13 @@ struct triple
triple<T>& operator=(triple<T>&& src) = default;
/// clone
INLINE_FUNCTION
inline
uniquePtr<triple<T>> clone() const
{
return makeUnique<triple<T>>(*this);
}
INLINE_FUNCTION
inline
triple<T>* clonePtr() const
{
return new triple<T>(*this);

View File

@ -103,13 +103,13 @@ INLINE_FUNCTION_HD bool
operator>=(const triple<T>& opr1, const triple<T>& opr2);
template<typename T>
INLINE_FUNCTION iOstream&
inline iOstream&
operator<<(iOstream& str, const triple<T>& ov);
template<typename T>
INLINE_FUNCTION iIstream&
inline iIstream&
operator>>(iIstream& str, triple<T>& iv);
template<typename T>
INLINE_FUNCTION void
inline void
readIstream(iIstream& str, triple<T>& iv);

View File

@ -287,8 +287,8 @@ pFlow::operator>=(const triple<T>& opr1, const triple<T>& opr2)
}
template<typename T>
INLINE_FUNCTION pFlow::iOstream&
pFlow::operator<<(iOstream& str, const triple<T>& ov)
inline pFlow::iOstream&
pFlow::operator<<(iOstream& str, const triple<T>& ov)
{
str << token::BEGIN_LIST << ov.x_ << token::SPACE << ov.y_ << token::SPACE
<< ov.z_ << token::END_LIST;
@ -299,8 +299,8 @@ INLINE_FUNCTION pFlow::iOstream&
}
template<typename T>
INLINE_FUNCTION pFlow::iIstream&
pFlow::operator>>(iIstream& str, triple<T>& iv)
inline pFlow::iIstream&
pFlow::operator>>(iIstream& str, triple<T>& iv)
{
str.readBegin("triple<T>");
@ -316,7 +316,7 @@ INLINE_FUNCTION pFlow::iIstream&
}
template<typename T>
INLINE_FUNCTION void
inline void
pFlow::readIstream(iIstream& str, triple<T>& iv)
{
str.readBegin("triple<T>");