corrections for coupling
This commit is contained in:
parent
853d50e96f
commit
7e858a116f
|
@ -21,9 +21,8 @@ Licence:
|
|||
#include "DEMSystem.hpp"
|
||||
|
||||
|
||||
pFlow::coupling::DEMSystem::DEMSystem(
|
||||
pFlow::DEMSystem::DEMSystem(
|
||||
word demSystemName,
|
||||
int32 numDomains,
|
||||
const std::vector<box>& domains,
|
||||
int argc,
|
||||
char* argv[])
|
||||
|
@ -39,16 +38,17 @@ pFlow::coupling::DEMSystem::DEMSystem(
|
|||
ControlDict_.saveInterval(),
|
||||
ControlDict_.startTimeName());
|
||||
|
||||
timers_ = makeUnique<Timers>(demSystemName, &Control_().timers());
|
||||
|
||||
}
|
||||
|
||||
pFlow::coupling::DEMSystem::~DEMSystem()
|
||||
pFlow::DEMSystem::~DEMSystem()
|
||||
{}
|
||||
|
||||
|
||||
pFlow::uniquePtr<pFlow::coupling::DEMSystem>
|
||||
pFlow::coupling::DEMSystem::create(
|
||||
pFlow::uniquePtr<pFlow::DEMSystem>
|
||||
pFlow::DEMSystem::create(
|
||||
word demSystemName,
|
||||
int32 numDomains,
|
||||
const std::vector<box>& domains,
|
||||
int argc,
|
||||
char* argv[]
|
||||
|
@ -56,7 +56,7 @@ pFlow::uniquePtr<pFlow::coupling::DEMSystem>
|
|||
{
|
||||
if( wordvCtorSelector_.search(demSystemName) )
|
||||
{
|
||||
return wordvCtorSelector_[demSystemName] (demSystemName, numDomains, domains, argc, argv);
|
||||
return wordvCtorSelector_[demSystemName] (demSystemName, domains, argc, argv);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -24,13 +24,14 @@ Licence:
|
|||
#include <vector>
|
||||
|
||||
#include "types.hpp"
|
||||
#include "span.hpp"
|
||||
#include "virtualConstructor.hpp"
|
||||
#include "uniquePtr.hpp"
|
||||
#include "systemControl.hpp"
|
||||
#include "readControlDict.hpp"
|
||||
|
||||
|
||||
namespace pFlow::coupling
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
|
@ -44,6 +45,7 @@ protected:
|
|||
|
||||
std::vector<box> domains_;
|
||||
|
||||
uniquePtr<Timers> timers_;
|
||||
|
||||
// methods
|
||||
auto& Control()
|
||||
|
@ -58,7 +60,6 @@ public:
|
|||
|
||||
DEMSystem(
|
||||
word demSystemName,
|
||||
int32 numDomains,
|
||||
const std::vector<box>& domains,
|
||||
int argc,
|
||||
char* argv[]);
|
||||
|
@ -74,14 +75,12 @@ public:
|
|||
word,
|
||||
(
|
||||
word demSystemName,
|
||||
int32 numDomains,
|
||||
const std::vector<box>& domains,
|
||||
int argc,
|
||||
char* argv[]
|
||||
),
|
||||
(
|
||||
demSystemName,
|
||||
numDomains,
|
||||
domains,
|
||||
argc,
|
||||
argv
|
||||
|
@ -97,6 +96,11 @@ public:
|
|||
return pFlow::usingDouble__;
|
||||
}
|
||||
|
||||
Timers& timers()
|
||||
{
|
||||
return Control_->timers();
|
||||
}
|
||||
|
||||
virtual
|
||||
int32 numParInDomain(int32 di)const = 0;
|
||||
|
||||
|
@ -104,16 +108,26 @@ public:
|
|||
std::vector<int32> numParInDomain()const = 0;
|
||||
|
||||
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
|
||||
real maxBounndingSphereSize()const = 0;
|
||||
|
||||
virtual
|
||||
bool iterate(int32 n, real timeToWrite, word timeName) = 0;
|
||||
|
||||
|
||||
|
||||
static
|
||||
uniquePtr<DEMSystem>
|
||||
create(
|
||||
word demSystemName,
|
||||
int32 numDomains,
|
||||
const std::vector<box>& domains,
|
||||
int argc,
|
||||
char* argv[]);
|
||||
|
|
|
@ -21,81 +21,98 @@ Licence:
|
|||
#include "domainDistribute.hpp"
|
||||
|
||||
|
||||
|
||||
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)
|
||||
void pFlow::domainDistribute::clcDomains(const std::vector<box>& domains)
|
||||
{
|
||||
|
||||
realx3 dl = domainExtension_ * maxBoundingBoxSize_;
|
||||
|
||||
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)
|
||||
{
|
||||
range active = mask.activeRange();
|
||||
auto numInDomain = numParInDomain_.deviceVectorAll();
|
||||
auto numDomains = numDomains_;
|
||||
|
||||
using policy = Kokkos::RangePolicy<
|
||||
DefaultHostExecutionSpace,
|
||||
Kokkos::IndexType<int32> >;
|
||||
|
||||
Kokkos::parallel_for("locateParticles",
|
||||
policy(active.first, active.second),
|
||||
LAMBDA_HD(int32 i){
|
||||
if(mask(i))
|
||||
{
|
||||
for(int32 di=0; di<numDomains; di++)
|
||||
{
|
||||
if(extDomains_[i].isInside(points[i]))
|
||||
Kokkos::atomic_add(&numInDomain[di],1);
|
||||
}
|
||||
}
|
||||
});
|
||||
Kokkos::fence();
|
||||
|
||||
|
||||
for(int32 i=0; i<numDomains_; i++)
|
||||
{
|
||||
range active = mask.activeRange();
|
||||
auto numInDomain = numParInDomain_.deviceVectorAll();
|
||||
auto numDomains = numDomains_;
|
||||
particlesInDomains_[i].resize(numParInDomain_[i]);
|
||||
}
|
||||
|
||||
using policy = Kokkos::RangePolicy<
|
||||
DefaultHostExecutionSpace,
|
||||
Kokkos::IndexType<int32> >;
|
||||
numParInDomain_.fill(0);
|
||||
|
||||
Kokkos::parallel_for("locateParticles",
|
||||
policy(active.first, active.second),
|
||||
LAMBDA_HD(int32 i){
|
||||
if(mask(i))
|
||||
auto particlesInDomainsPtr = particlesInDomains_.data();
|
||||
|
||||
Kokkos::parallel_for("locateParticles",
|
||||
policy(active.first, active.second),
|
||||
LAMBDA_HD(int32 i){
|
||||
if(mask(i))
|
||||
{
|
||||
for(int32 di=0; di<numDomains; di++)
|
||||
{
|
||||
for(int32 di=0; di<numDomains; di++)
|
||||
if(extDomains_[i].isInside(points[i]))
|
||||
{
|
||||
if(extDomains_[i].isInside(points[i]))
|
||||
Kokkos::atomic_add(&numInDomain[di],1);
|
||||
|
||||
particlesInDomainsPtr[di][numInDomain[di]] = i;
|
||||
Kokkos::atomic_add(&numInDomain[di],1);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
Kokkos::fence();
|
||||
|
||||
|
||||
for(int32 i=0; i<numDomains_; i++)
|
||||
{
|
||||
particlesInDomains_[i].resize(numParInDomain_[i]);
|
||||
}
|
||||
|
||||
numParInDomain_.fill(0);
|
||||
|
||||
auto particlesInDomainsPtr = particlesInDomains_.data();
|
||||
|
||||
Kokkos::parallel_for("locateParticles",
|
||||
policy(active.first, active.second),
|
||||
LAMBDA_HD(int32 i){
|
||||
if(mask(i))
|
||||
{
|
||||
for(int32 di=0; di<numDomains; di++)
|
||||
{
|
||||
if(extDomains_[i].isInside(points[i]))
|
||||
{
|
||||
|
||||
particlesInDomainsPtr[di][numInDomain[di]] = i;
|
||||
Kokkos::atomic_add(&numInDomain[di],1);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Kokkos::fence();
|
||||
}
|
||||
});
|
||||
Kokkos::fence();
|
||||
|
||||
|
||||
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;
|
||||
}
|
|
@ -26,7 +26,7 @@ Licence:
|
|||
#include "VectorSingles.hpp"
|
||||
#include "pointStructure.hpp"
|
||||
|
||||
namespace pFlow::coupling
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class domainDistribute
|
||||
|
@ -46,20 +46,17 @@ protected:
|
|||
|
||||
real maxBoundingBoxSize_;
|
||||
|
||||
int32 lastUpdateIter_ = 0;
|
||||
|
||||
int32 updateInterval_ = 1;
|
||||
|
||||
real domainExtension_ = 1.0;
|
||||
|
||||
using includeMask = typename pointStructure::activePointsHost;
|
||||
|
||||
void clcDomains(const std::vector<box>& domains);
|
||||
|
||||
public:
|
||||
|
||||
domainDistribute(
|
||||
int32 numDomains,
|
||||
const Vector<box>& domains_,
|
||||
real maxBoundinBox);
|
||||
const Vector<box>& domains,
|
||||
real maxBoundingBox);
|
||||
|
||||
~domainDistribute()=default;
|
||||
|
||||
|
@ -77,6 +74,18 @@ public:
|
|||
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>
|
||||
bool locateParticles(
|
||||
ViewType1D<realx3,HostSpace> points, includeMask mask);
|
||||
|
|
|
@ -21,14 +21,13 @@ Licence:
|
|||
#include "sphereDEMSystem.hpp"
|
||||
|
||||
|
||||
pFlow::coupling::sphereDEMSystem::sphereDEMSystem(
|
||||
pFlow::sphereDEMSystem::sphereDEMSystem(
|
||||
word demSystemName,
|
||||
int32 numDomains,
|
||||
const std::vector<box>& domains,
|
||||
int argc,
|
||||
char* argv[])
|
||||
:
|
||||
DEMSystem(demSystemName, numDomains, domains, argc, argv)
|
||||
DEMSystem(demSystemName, domains, argc, argv)
|
||||
{
|
||||
|
||||
REPORT(0)<<"Initializing host/device execution spaces . . . \n";
|
||||
|
@ -51,19 +50,6 @@ pFlow::coupling::sphereDEMSystem::sphereDEMSystem(
|
|||
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;
|
||||
interaction_ = interaction::create(
|
||||
Control(),
|
||||
|
@ -73,11 +59,11 @@ pFlow::coupling::sphereDEMSystem::sphereDEMSystem(
|
|||
real 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();
|
||||
insertion_.reset();
|
||||
|
@ -93,13 +79,13 @@ pFlow::coupling::sphereDEMSystem::~sphereDEMSystem()
|
|||
|
||||
|
||||
pFlow::int32
|
||||
pFlow::coupling::sphereDEMSystem::numParInDomain(int32 di)const
|
||||
pFlow::sphereDEMSystem::numParInDomain(int32 di)const
|
||||
{
|
||||
return particleDistribution_().numParInDomain(di);
|
||||
}
|
||||
|
||||
std::vector<pFlow::int32>
|
||||
pFlow::coupling::sphereDEMSystem::numParInDomain()const
|
||||
pFlow::sphereDEMSystem::numParInDomain()const
|
||||
{
|
||||
const auto& distribute = particleDistribution_();
|
||||
int32 numDomains = distribute.numDomains();
|
||||
|
@ -112,8 +98,31 @@ std::vector<pFlow::int32>
|
|||
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,
|
||||
real timeToWrite,
|
||||
word timeName)
|
||||
|
@ -122,7 +131,7 @@ bool pFlow::coupling::sphereDEMSystem::iterate(
|
|||
}
|
||||
|
||||
pFlow::real
|
||||
pFlow::coupling::sphereDEMSystem::maxBounndingSphereSize()const
|
||||
pFlow::sphereDEMSystem::maxBounndingSphereSize()const
|
||||
{
|
||||
real minD, maxD;
|
||||
particles_->boundingSphereMinMax(minD, maxD);
|
||||
|
|
|
@ -31,7 +31,7 @@ Licence:
|
|||
#include "domainDistribute.hpp"
|
||||
|
||||
|
||||
namespace pFlow::coupling
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class sphereDEMSystem
|
||||
|
@ -81,7 +81,6 @@ public:
|
|||
|
||||
sphereDEMSystem(
|
||||
word demSystemName,
|
||||
int32 numDomains,
|
||||
const std::vector<box>& domains,
|
||||
int argc,
|
||||
char* argv[]);
|
||||
|
@ -100,15 +99,17 @@ public:
|
|||
|
||||
|
||||
int32 numParInDomain(int32 di)const override;
|
||||
|
||||
|
||||
std::vector<int32> numParInDomain()const override;
|
||||
|
||||
|
||||
virtual
|
||||
|
||||
span<const int32> parIndexInDomain(int32 di)const override;
|
||||
|
||||
bool changeDomainsSizeUpdateParticles(const std::vector<box>& domains) override;
|
||||
|
||||
bool updateParticles() override;
|
||||
|
||||
bool iterate(int32 n, real timeToWrite, word timeName) override;
|
||||
|
||||
virtual
|
||||
real maxBounndingSphereSize()const override;
|
||||
|
||||
};
|
||||
|
|
|
@ -133,25 +133,25 @@ public:
|
|||
INLINE_FUNCTION_HD
|
||||
T& operator[](int32 i)
|
||||
{
|
||||
data_[i];
|
||||
return data_[i];
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
const T& operator[](int32 i)const
|
||||
{
|
||||
data_[i];
|
||||
return data_[i];
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
T& operator[](label i)
|
||||
{
|
||||
data_[i];
|
||||
return data_[i];
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
const T& operator[](label i)const
|
||||
{
|
||||
data_[i];
|
||||
return data_[i];
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue