Merge pull request #60 from PhasicFlow/coupling

corrections for coupling
This commit is contained in:
PhasicFlow 2022-12-30 21:01:04 +03:30 committed by GitHub
commit 804e497afc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 164 additions and 114 deletions

View File

@ -21,9 +21,8 @@ Licence:
#include "DEMSystem.hpp" #include "DEMSystem.hpp"
pFlow::coupling::DEMSystem::DEMSystem( pFlow::DEMSystem::DEMSystem(
word demSystemName, word demSystemName,
int32 numDomains,
const std::vector<box>& domains, const std::vector<box>& domains,
int argc, int argc,
char* argv[]) char* argv[])
@ -39,16 +38,17 @@ pFlow::coupling::DEMSystem::DEMSystem(
ControlDict_.saveInterval(), ControlDict_.saveInterval(),
ControlDict_.startTimeName()); ControlDict_.startTimeName());
timers_ = makeUnique<Timers>(demSystemName, &Control_().timers());
} }
pFlow::coupling::DEMSystem::~DEMSystem() pFlow::DEMSystem::~DEMSystem()
{} {}
pFlow::uniquePtr<pFlow::coupling::DEMSystem> pFlow::uniquePtr<pFlow::DEMSystem>
pFlow::coupling::DEMSystem::create( pFlow::DEMSystem::create(
word demSystemName, word demSystemName,
int32 numDomains,
const std::vector<box>& domains, const std::vector<box>& domains,
int argc, int argc,
char* argv[] char* argv[]
@ -56,7 +56,7 @@ pFlow::uniquePtr<pFlow::coupling::DEMSystem>
{ {
if( wordvCtorSelector_.search(demSystemName) ) if( wordvCtorSelector_.search(demSystemName) )
{ {
return wordvCtorSelector_[demSystemName] (demSystemName, numDomains, domains, argc, argv); return wordvCtorSelector_[demSystemName] (demSystemName, domains, argc, argv);
} }
else else
{ {

View File

@ -24,13 +24,14 @@ Licence:
#include <vector> #include <vector>
#include "types.hpp" #include "types.hpp"
#include "span.hpp"
#include "virtualConstructor.hpp" #include "virtualConstructor.hpp"
#include "uniquePtr.hpp" #include "uniquePtr.hpp"
#include "systemControl.hpp" #include "systemControl.hpp"
#include "readControlDict.hpp" #include "readControlDict.hpp"
namespace pFlow::coupling namespace pFlow
{ {
@ -44,6 +45,7 @@ protected:
std::vector<box> domains_; std::vector<box> domains_;
uniquePtr<Timers> timers_;
// methods // methods
auto& Control() auto& Control()
@ -58,7 +60,6 @@ public:
DEMSystem( DEMSystem(
word demSystemName, word demSystemName,
int32 numDomains,
const std::vector<box>& domains, const std::vector<box>& domains,
int argc, int argc,
char* argv[]); char* argv[]);
@ -74,14 +75,12 @@ public:
word, word,
( (
word demSystemName, word demSystemName,
int32 numDomains,
const std::vector<box>& domains, const std::vector<box>& domains,
int argc, int argc,
char* argv[] char* argv[]
), ),
( (
demSystemName, demSystemName,
numDomains,
domains, domains,
argc, argc,
argv argv
@ -97,6 +96,11 @@ public:
return pFlow::usingDouble__; return pFlow::usingDouble__;
} }
Timers& timers()
{
return Control_->timers();
}
virtual virtual
int32 numParInDomain(int32 di)const = 0; int32 numParInDomain(int32 di)const = 0;
@ -104,16 +108,26 @@ public:
std::vector<int32> numParInDomain()const = 0; std::vector<int32> numParInDomain()const = 0;
virtual virtual
bool iterate(int32 n, real timeToWrite, word timeName) = 0; span<const int32> parIndexInDomain(int32 di)const = 0;
virtual
bool changeDomainsSizeUpdateParticles(const std::vector<box>& domains) = 0;
virtual
bool updateParticles() = 0;
virtual virtual
real maxBounndingSphereSize()const = 0; real maxBounndingSphereSize()const = 0;
virtual
bool iterate(int32 n, real timeToWrite, word timeName) = 0;
static static
uniquePtr<DEMSystem> uniquePtr<DEMSystem>
create( create(
word demSystemName, word demSystemName,
int32 numDomains,
const std::vector<box>& domains, const std::vector<box>& domains,
int argc, int argc,
char* argv[]); char* argv[]);

View File

@ -21,30 +21,34 @@ Licence:
#include "domainDistribute.hpp" #include "domainDistribute.hpp"
void pFlow::domainDistribute::clcDomains(const std::vector<box>& domains)
pFlow::coupling::domainDistribute::domainDistribute(
int32 numDomains,
const Vector<box>& domains_,
real maxBoundingBox)
:
numDomains_(numDomains),
extDomains_("extDomains", numDomains),
particlesInDomains_("particlesInDomains", numDomains),
numParInDomain_("numParInDomain", numDomains, 0),
maxBoundingBoxSize_(maxBoundingBox)
{ {
realx3 dl = domainExtension_ * maxBoundingBoxSize_; realx3 dl = domainExtension_ * maxBoundingBoxSize_;
for(int32 i=0; i<numDomains_; i++) for(int32 i=0; i<numDomains_; i++)
{ {
extDomains_[i] = extendBox(domains_[i], dl); extDomains_[i] = extendBox(domains[i], dl);
} }
} }
bool pFlow::coupling::domainDistribute::locateParticles(
pFlow::domainDistribute::domainDistribute(
const Vector<box>& domains,
real maxBoundingBox)
:
numDomains_(domains.size()),
extDomains_("extDomains", numDomains_),
particlesInDomains_("particlesInDomains", numDomains_),
numParInDomain_("numParInDomain", numDomains_, 0),
maxBoundingBoxSize_(maxBoundingBox)
{
clcDomains(domains);
}
bool pFlow::domainDistribute::locateParticles(
ViewType1D<realx3,HostSpace> points, includeMask mask) ViewType1D<realx3,HostSpace> points, includeMask mask)
{ {
range active = mask.activeRange(); range active = mask.activeRange();
auto numInDomain = numParInDomain_.deviceVectorAll(); auto numInDomain = numParInDomain_.deviceVectorAll();
auto numDomains = numDomains_; auto numDomains = numDomains_;
@ -98,4 +102,17 @@ bool pFlow::coupling::domainDistribute::locateParticles(
return true; return true;
}
bool pFlow::domainDistribute::changeDomainsSize(
const std::vector<box>& domains)
{
if(domains.size()!= numDomains_)
{
fatalErrorInFunction<<"number of new domians differs"<<endl;
return false;
} }
clcDomains(domains);
return true;
}

View File

@ -26,7 +26,7 @@ Licence:
#include "VectorSingles.hpp" #include "VectorSingles.hpp"
#include "pointStructure.hpp" #include "pointStructure.hpp"
namespace pFlow::coupling namespace pFlow
{ {
class domainDistribute class domainDistribute
@ -46,20 +46,17 @@ protected:
real maxBoundingBoxSize_; real maxBoundingBoxSize_;
int32 lastUpdateIter_ = 0;
int32 updateInterval_ = 1;
real domainExtension_ = 1.0; real domainExtension_ = 1.0;
using includeMask = typename pointStructure::activePointsHost; using includeMask = typename pointStructure::activePointsHost;
void clcDomains(const std::vector<box>& domains);
public: public:
domainDistribute( domainDistribute(
int32 numDomains, const Vector<box>& domains,
const Vector<box>& domains_, real maxBoundingBox);
real maxBoundinBox);
~domainDistribute()=default; ~domainDistribute()=default;
@ -77,6 +74,18 @@ public:
return numParInDomain_[di]; return numParInDomain_[di];
} }
span<const int32> particlesInDomain(int32 di)const
{
return
span<const int32>(
particlesInDomains_[di].hostVectorAll().data(),
numParInDomain_[di]
);
}
bool changeDomainsSize(const std::vector<box>& domains);
//template<typename includeMask> //template<typename includeMask>
bool locateParticles( bool locateParticles(
ViewType1D<realx3,HostSpace> points, includeMask mask); ViewType1D<realx3,HostSpace> points, includeMask mask);

View File

@ -21,14 +21,13 @@ Licence:
#include "sphereDEMSystem.hpp" #include "sphereDEMSystem.hpp"
pFlow::coupling::sphereDEMSystem::sphereDEMSystem( pFlow::sphereDEMSystem::sphereDEMSystem(
word demSystemName, word demSystemName,
int32 numDomains,
const std::vector<box>& domains, const std::vector<box>& domains,
int argc, int argc,
char* argv[]) char* argv[])
: :
DEMSystem(demSystemName, numDomains, domains, argc, argv) DEMSystem(demSystemName, domains, argc, argv)
{ {
REPORT(0)<<"Initializing host/device execution spaces . . . \n"; REPORT(0)<<"Initializing host/device execution spaces . . . \n";
@ -51,19 +50,6 @@ pFlow::coupling::sphereDEMSystem::sphereDEMSystem(
particles_ = makeUnique<sphereParticles>(Control(), Property()); particles_ = makeUnique<sphereParticles>(Control(), Property());
//REPORT(0)<<"\nCreating particle insertion for spheres. . ."<<endREPORT;
/*insertion_ =
Control().caseSetup().emplaceObject<sphereInsertion>(
objectFile(
insertionFile__,
"",
objectFile::READ_ALWAYS,
objectFile::WRITE_ALWAYS
),
sphParticles,
sphParticles.shapes()
);*/
REPORT(0)<<"\nCreating interaction model for sphere-sphere contact and sphere-wall contact . . ."<<endREPORT; REPORT(0)<<"\nCreating interaction model for sphere-sphere contact and sphere-wall contact . . ."<<endREPORT;
interaction_ = interaction::create( interaction_ = interaction::create(
Control(), Control(),
@ -73,11 +59,11 @@ pFlow::coupling::sphereDEMSystem::sphereDEMSystem(
real minD, maxD; real minD, maxD;
particles_->boundingSphereMinMax(minD, maxD); particles_->boundingSphereMinMax(minD, maxD);
particleDistribution_ = makeUnique<domainDistribute>(numDomains, domains, maxD); particleDistribution_ = makeUnique<domainDistribute>(domains, maxD);
} }
pFlow::coupling::sphereDEMSystem::~sphereDEMSystem() pFlow::sphereDEMSystem::~sphereDEMSystem()
{ {
interaction_.reset(); interaction_.reset();
insertion_.reset(); insertion_.reset();
@ -93,13 +79,13 @@ pFlow::coupling::sphereDEMSystem::~sphereDEMSystem()
pFlow::int32 pFlow::int32
pFlow::coupling::sphereDEMSystem::numParInDomain(int32 di)const pFlow::sphereDEMSystem::numParInDomain(int32 di)const
{ {
return particleDistribution_().numParInDomain(di); return particleDistribution_().numParInDomain(di);
} }
std::vector<pFlow::int32> std::vector<pFlow::int32>
pFlow::coupling::sphereDEMSystem::numParInDomain()const pFlow::sphereDEMSystem::numParInDomain()const
{ {
const auto& distribute = particleDistribution_(); const auto& distribute = particleDistribution_();
int32 numDomains = distribute.numDomains(); int32 numDomains = distribute.numDomains();
@ -112,8 +98,31 @@ std::vector<pFlow::int32>
return nums; return nums;
} }
pFlow::span<const pFlow::int32>
pFlow::sphereDEMSystem::parIndexInDomain(int32 di)const
{
return particleDistribution_->particlesInDomain(di);
}
bool pFlow::coupling::sphereDEMSystem::iterate( bool pFlow::sphereDEMSystem::changeDomainsSizeUpdateParticles(
const std::vector<box>& domains)
{
if( !particleDistribution_->changeDomainsSize(domains))
return false;
// should update list of particles here
//************************************************************************************************
notImplementedFunction;
return false;
}
bool pFlow::sphereDEMSystem::updateParticles()
{
notImplementedFunction;
return false;
}
bool pFlow::sphereDEMSystem::iterate(
int32 n, int32 n,
real timeToWrite, real timeToWrite,
word timeName) word timeName)
@ -122,7 +131,7 @@ bool pFlow::coupling::sphereDEMSystem::iterate(
} }
pFlow::real pFlow::real
pFlow::coupling::sphereDEMSystem::maxBounndingSphereSize()const pFlow::sphereDEMSystem::maxBounndingSphereSize()const
{ {
real minD, maxD; real minD, maxD;
particles_->boundingSphereMinMax(minD, maxD); particles_->boundingSphereMinMax(minD, maxD);

View File

@ -31,7 +31,7 @@ Licence:
#include "domainDistribute.hpp" #include "domainDistribute.hpp"
namespace pFlow::coupling namespace pFlow
{ {
class sphereDEMSystem class sphereDEMSystem
@ -81,7 +81,6 @@ public:
sphereDEMSystem( sphereDEMSystem(
word demSystemName, word demSystemName,
int32 numDomains,
const std::vector<box>& domains, const std::vector<box>& domains,
int argc, int argc,
char* argv[]); char* argv[]);
@ -101,14 +100,16 @@ public:
int32 numParInDomain(int32 di)const override; int32 numParInDomain(int32 di)const override;
std::vector<int32> numParInDomain()const override; std::vector<int32> numParInDomain()const override;
span<const int32> parIndexInDomain(int32 di)const override;
bool changeDomainsSizeUpdateParticles(const std::vector<box>& domains) override;
bool updateParticles() override;
virtual
bool iterate(int32 n, real timeToWrite, word timeName) override; bool iterate(int32 n, real timeToWrite, word timeName) override;
virtual
real maxBounndingSphereSize()const override; real maxBounndingSphereSize()const override;
}; };

View File

@ -133,25 +133,25 @@ public:
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
T& operator[](int32 i) T& operator[](int32 i)
{ {
data_[i]; return data_[i];
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
const T& operator[](int32 i)const const T& operator[](int32 i)const
{ {
data_[i]; return data_[i];
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
T& operator[](label i) T& operator[](label i)
{ {
data_[i]; return data_[i];
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
const T& operator[](label i)const const T& operator[](label i)const
{ {
data_[i]; return data_[i];
} }
}; };