sphereParticles tested on CPU, iteration, write to file, particle deletion

This commit is contained in:
Hamidreza Norouzi 2024-01-29 07:57:19 -08:00
parent c0ee29e39c
commit 182e156786
48 changed files with 424 additions and 371 deletions

View File

@ -35,20 +35,20 @@ using rpIntegration = Kokkos::RangePolicy<
bool intAllActive( bool intAllActive(
real dt, real dt,
realx3PointField_D& y, realx3Field_D& y,
realx3PointField_D& dy, realx3PointField_D& dy,
realx3PointField_D& dy1) realx3PointField_D& dy1)
{ {
auto d_dy = dy.fieldDevice(); auto d_dy = dy.deviceView();
auto d_y = y.fieldDevice(); auto d_y = y.deviceView();
auto d_dy1= dy1.fieldDevice(); auto d_dy1= dy1.deviceView();
auto activeRng = dy1.activeRange(); auto activeRng = dy1.activeRange();
Kokkos::parallel_for( Kokkos::parallel_for(
"AdamsBashforth2::correct", "AdamsBashforth2::correct",
rpIntegration (activeRng.start(), activeRng.end()), rpIntegration (activeRng.start(), activeRng.end()),
LAMBDA_HD(int32 i){ LAMBDA_HD(uint32 i){
d_y[i] += dt*(static_cast<real>(1.5) * d_dy[i] - static_cast<real>(0.5) * d_dy1[i]); d_y[i] += dt*(static_cast<real>(1.5) * d_dy[i] - static_cast<real>(0.5) * d_dy1[i]);
d_dy1[i] = d_dy[i]; d_dy1[i] = d_dy[i];
}); });
@ -60,22 +60,22 @@ bool intAllActive(
bool intScattered bool intScattered
( (
real dt, real dt,
realx3PointField_D& y, realx3Field_D& y,
realx3PointField_D& dy, realx3PointField_D& dy,
realx3PointField_D& dy1 realx3PointField_D& dy1
) )
{ {
auto d_dy = dy.fieldDevice(); auto d_dy = dy.deviceView();
auto d_y = y.fieldDevice(); auto d_y = y.deviceView();
auto d_dy1 = dy1.fieldDevice(); auto d_dy1 = dy1.deviceView();
auto activeRng = dy1.activeRange(); auto activeRng = dy1.activeRange();
const auto& activeP = dy1.activePointsMaskDevice(); const auto& activeP = dy1.activePointsMaskDevice();
Kokkos::parallel_for( Kokkos::parallel_for(
"AdamsBashforth2::correct", "AdamsBashforth2::correct",
rpIntegration (activeRng.start(), activeRng.end()), rpIntegration (activeRng.start(), activeRng.end()),
LAMBDA_HD(int32 i){ LAMBDA_HD(uint32 i){
if( activeP(i)) if( activeP(i))
{ {
d_y[i] += dt*(static_cast<real>(1.5) * d_dy[i] - static_cast<real>(0.5) * d_dy1[i]); d_y[i] += dt*(static_cast<real>(1.5) * d_dy[i] - static_cast<real>(0.5) * d_dy1[i]);
@ -122,16 +122,30 @@ bool pFlow::AdamsBashforth2::predict
realx3PointField_D& UNUSED(dy) realx3PointField_D& UNUSED(dy)
) )
{ {
return true; return true;
} }
bool pFlow::AdamsBashforth2::predict
(
real dt,
realx3Field_D &y,
realx3PointField_D &dy
)
{
return true;
}
bool pFlow::AdamsBashforth2::correct bool pFlow::AdamsBashforth2::correct
( (
real dt, real dt,
realx3PointField_D& y, realx3PointField_D& y,
realx3PointField_D& dy realx3PointField_D& dy
) )
{
return correct(dt, y.field(), dy);
}
bool pFlow::AdamsBashforth2::correct(real dt, realx3Field_D &y, realx3PointField_D &dy)
{ {
auto& dy1l = dy1(); auto& dy1l = dy1();
@ -143,8 +157,7 @@ bool pFlow::AdamsBashforth2::correct
{ {
return intScattered(dt, y, dy, dy1l); return intScattered(dt, y, dy, dy1l);
} }
return false;
return true;
} }
bool pFlow::AdamsBashforth2::setInitialVals( bool pFlow::AdamsBashforth2::setInitialVals(

View File

@ -81,12 +81,23 @@ public:
real UNUSED(dt), real UNUSED(dt),
realx3PointField_D& UNUSED(y), realx3PointField_D& UNUSED(y),
realx3PointField_D& UNUSED(dy)) final; realx3PointField_D& UNUSED(dy)) final;
bool predict(
real dt,
realx3Field_D& y,
realx3PointField_D& dy) final;
bool correct( bool correct(
real dt, real dt,
realx3PointField_D& y, realx3PointField_D& y,
realx3PointField_D& dy) final; realx3PointField_D& dy) final;
bool correct(
real dt,
realx3Field_D& y,
realx3PointField_D& dy);
bool setInitialVals( bool setInitialVals(
const int32IndexContainer& newIndices, const int32IndexContainer& newIndices,
const realx3Vector& y) final; const realx3Vector& y) final;

View File

@ -89,9 +89,9 @@ bool pFlow::AdamsBashforth3::intAll(
realx3Vector_D& dy, realx3Vector_D& dy,
range activeRng) range activeRng)
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_history = history_.deviceVectorAll(); auto d_history = history_.deviceViewAll();
Kokkos::parallel_for( Kokkos::parallel_for(
"AdamsBashforth3::correct", "AdamsBashforth3::correct",

View File

@ -160,9 +160,9 @@ bool pFlow::AdamsBashforth3::intRange(
realx3Vector_D& dy, realx3Vector_D& dy,
activeFunctor activeP ) activeFunctor activeP )
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_history = history_.deviceVectorAll(); auto d_history = history_.deviceViewAll();
auto activeRng = activeP.activeRange(); auto activeRng = activeP.activeRange();
Kokkos::parallel_for( Kokkos::parallel_for(

View File

@ -89,9 +89,9 @@ bool pFlow::AdamsBashforth4::intAll(
realx3Vector_D& dy, realx3Vector_D& dy,
range activeRng) range activeRng)
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_history = history_.deviceVectorAll(); auto d_history = history_.deviceViewAll();
Kokkos::parallel_for( Kokkos::parallel_for(
"AdamsBashforth4::correct", "AdamsBashforth4::correct",

View File

@ -165,9 +165,9 @@ bool pFlow::AdamsBashforth4::intRange(
realx3Vector_D& dy, realx3Vector_D& dy,
activeFunctor activeP ) activeFunctor activeP )
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_history = history_.deviceVectorAll(); auto d_history = history_.deviceViewAll();
auto activeRng = activeP.activeRange(); auto activeRng = activeP.activeRange();
Kokkos::parallel_for( Kokkos::parallel_for(

View File

@ -89,9 +89,9 @@ bool pFlow::AdamsBashforth5::intAll(
realx3Vector_D& dy, realx3Vector_D& dy,
range activeRng) range activeRng)
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_history = history_.deviceVectorAll(); auto d_history = history_.deviceViewAll();
Kokkos::parallel_for( Kokkos::parallel_for(
"AdamsBashforth5::correct", "AdamsBashforth5::correct",

View File

@ -165,9 +165,9 @@ bool pFlow::AdamsBashforth5::intRange(
realx3Vector_D& dy, realx3Vector_D& dy,
activeFunctor activeP ) activeFunctor activeP )
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_history = history_.deviceVectorAll(); auto d_history = history_.deviceViewAll();
auto activeRng = activeP.activeRange(); auto activeRng = activeP.activeRange();
Kokkos::parallel_for( Kokkos::parallel_for(

View File

@ -124,11 +124,11 @@ bool pFlow::AdamsMoulton3::predictAll(
range activeRng) range activeRng)
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_y0 = y0_.deviceVectorAll(); auto d_y0 = y0_.deviceViewAll();
auto d_dy0 = dy0_.deviceVectorAll(); auto d_dy0 = dy0_.deviceViewAll();
auto d_dy1= dy1_.deviceVectorAll(); auto d_dy1= dy1_.deviceViewAll();
Kokkos::parallel_for( Kokkos::parallel_for(
"AdamsMoulton3::predict", "AdamsMoulton3::predict",
@ -150,12 +150,12 @@ bool pFlow::AdamsMoulton3::intAll(
range activeRng) range activeRng)
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_dy0 = dy0_.deviceVectorAll(); auto d_dy0 = dy0_.deviceViewAll();
auto d_y0 = y0_.deviceVectorAll(); auto d_y0 = y0_.deviceViewAll();
auto d_dy1 = dy1_.deviceVectorAll(); auto d_dy1 = dy1_.deviceViewAll();
Kokkos::parallel_for( Kokkos::parallel_for(
"AdamsMoulton3::correct", "AdamsMoulton3::correct",

View File

@ -144,11 +144,11 @@ bool AdamsMoulton3::predictRange(
realx3Vector_D& dy, realx3Vector_D& dy,
activeFunctor activeP) activeFunctor activeP)
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_y0 = y0_.deviceVectorAll(); auto d_y0 = y0_.deviceViewAll();
auto d_dy0 = dy0_.deviceVectorAll(); auto d_dy0 = dy0_.deviceViewAll();
auto d_dy1= dy1_.deviceVectorAll(); auto d_dy1= dy1_.deviceViewAll();
auto activeRng = activeP.activeRange(); auto activeRng = activeP.activeRange();
@ -182,12 +182,12 @@ bool pFlow::AdamsMoulton3::intRange(
activeFunctor activeP) activeFunctor activeP)
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_dy0 = dy0_.deviceVectorAll(); auto d_dy0 = dy0_.deviceViewAll();
auto d_y0 = y0_.deviceVectorAll(); auto d_y0 = y0_.deviceViewAll();
auto d_dy1 = dy1_.deviceVectorAll(); auto d_dy1 = dy1_.deviceViewAll();
auto activeRng = activeP.activeRange(); auto activeRng = activeP.activeRange();

View File

@ -135,13 +135,13 @@ bool pFlow::AdamsMoulton4::predictAll(
range activeRng) range activeRng)
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_y0 = y0_.deviceVectorAll(); auto d_y0 = y0_.deviceViewAll();
auto d_dy0 = dy0_.deviceVectorAll(); auto d_dy0 = dy0_.deviceViewAll();
auto d_dy1 = dy1_.deviceVectorAll(); auto d_dy1 = dy1_.deviceViewAll();
auto d_dy2 = dy2_.deviceVectorAll(); auto d_dy2 = dy2_.deviceViewAll();
Kokkos::parallel_for( Kokkos::parallel_for(
"AdamsMoulton4::predict", "AdamsMoulton4::predict",
@ -165,13 +165,13 @@ bool pFlow::AdamsMoulton4::intAll(
range activeRng) range activeRng)
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_dy0 = dy0_.deviceVectorAll(); auto d_dy0 = dy0_.deviceViewAll();
auto d_y0 = y0_.deviceVectorAll(); auto d_y0 = y0_.deviceViewAll();
auto d_dy1 = dy1_.deviceVectorAll(); auto d_dy1 = dy1_.deviceViewAll();
auto d_dy2 = dy2_.deviceVectorAll(); auto d_dy2 = dy2_.deviceViewAll();
Kokkos::parallel_for( Kokkos::parallel_for(
"AdamsMoulton4::correct", "AdamsMoulton4::correct",

View File

@ -147,13 +147,13 @@ bool AdamsMoulton4::predictRange(
realx3Vector_D& dy, realx3Vector_D& dy,
activeFunctor activeP ) activeFunctor activeP )
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_y0 = y0_.deviceVectorAll(); auto d_y0 = y0_.deviceViewAll();
auto d_dy0 = dy0_.deviceVectorAll(); auto d_dy0 = dy0_.deviceViewAll();
auto d_dy1 = dy1_.deviceVectorAll(); auto d_dy1 = dy1_.deviceViewAll();
auto d_dy2 = dy2_.deviceVectorAll(); auto d_dy2 = dy2_.deviceViewAll();
auto activeRng = activeP.activeRange(); auto activeRng = activeP.activeRange();
@ -185,13 +185,13 @@ bool pFlow::AdamsMoulton4::intRange(
activeFunctor activeP ) activeFunctor activeP )
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_dy0 = dy0_.deviceVectorAll(); auto d_dy0 = dy0_.deviceViewAll();
auto d_y0 = y0_.deviceVectorAll(); auto d_y0 = y0_.deviceViewAll();
auto d_dy1 = dy1_.deviceVectorAll(); auto d_dy1 = dy1_.deviceViewAll();
auto d_dy2 = dy2_.deviceVectorAll(); auto d_dy2 = dy2_.deviceViewAll();
auto activeRng = activeP.activeRange(); auto activeRng = activeP.activeRange();

View File

@ -145,14 +145,14 @@ bool pFlow::AdamsMoulton5::predictAll(
range activeRng) range activeRng)
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_y0 = y0_.deviceVectorAll(); auto d_y0 = y0_.deviceViewAll();
auto d_dy0 = dy0_.deviceVectorAll(); auto d_dy0 = dy0_.deviceViewAll();
auto d_dy1 = dy1_.deviceVectorAll(); auto d_dy1 = dy1_.deviceViewAll();
auto d_dy2 = dy2_.deviceVectorAll(); auto d_dy2 = dy2_.deviceViewAll();
auto d_dy3 = dy3_.deviceVectorAll(); auto d_dy3 = dy3_.deviceViewAll();
Kokkos::parallel_for( Kokkos::parallel_for(
"AdamsMoulton5::predict", "AdamsMoulton5::predict",
@ -178,14 +178,14 @@ bool pFlow::AdamsMoulton5::intAll(
range activeRng) range activeRng)
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_dy0 = dy0_.deviceVectorAll(); auto d_dy0 = dy0_.deviceViewAll();
auto d_y0 = y0_.deviceVectorAll(); auto d_y0 = y0_.deviceViewAll();
auto d_dy1 = dy1_.deviceVectorAll(); auto d_dy1 = dy1_.deviceViewAll();
auto d_dy2 = dy2_.deviceVectorAll(); auto d_dy2 = dy2_.deviceViewAll();
auto d_dy3 = dy3_.deviceVectorAll(); auto d_dy3 = dy3_.deviceViewAll();
Kokkos::parallel_for( Kokkos::parallel_for(
"AdamsMoulton5::correct", "AdamsMoulton5::correct",

View File

@ -150,14 +150,14 @@ bool AdamsMoulton5::predictRange(
realx3Vector_D& dy, realx3Vector_D& dy,
activeFunctor activeP ) activeFunctor activeP )
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_y0 = y0_.deviceVectorAll(); auto d_y0 = y0_.deviceViewAll();
auto d_dy0 = dy0_.deviceVectorAll(); auto d_dy0 = dy0_.deviceViewAll();
auto d_dy1 = dy1_.deviceVectorAll(); auto d_dy1 = dy1_.deviceViewAll();
auto d_dy2 = dy2_.deviceVectorAll(); auto d_dy2 = dy2_.deviceViewAll();
auto d_dy3 = dy3_.deviceVectorAll(); auto d_dy3 = dy3_.deviceViewAll();
auto activeRng = activeP.activeRange(); auto activeRng = activeP.activeRange();
@ -189,14 +189,14 @@ bool pFlow::AdamsMoulton5::intRange(
activeFunctor activeP ) activeFunctor activeP )
{ {
auto d_dy = dy.deviceVectorAll(); auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceVectorAll(); auto d_y = y.deviceViewAll();
auto d_dy0 = dy0_.deviceVectorAll(); auto d_dy0 = dy0_.deviceViewAll();
auto d_y0 = y0_.deviceVectorAll(); auto d_y0 = y0_.deviceViewAll();
auto d_dy1 = dy1_.deviceVectorAll(); auto d_dy1 = dy1_.deviceViewAll();
auto d_dy2 = dy2_.deviceVectorAll(); auto d_dy2 = dy2_.deviceViewAll();
auto d_dy3 = dy3_.deviceVectorAll(); auto d_dy3 = dy3_.deviceViewAll();
auto activeRng = activeP.activeRange(); auto activeRng = activeP.activeRange();

View File

@ -139,10 +139,16 @@ public:
virtual virtual
bool predict(real dt, realx3PointField_D& y, realx3PointField_D& dy) = 0; bool predict(real dt, realx3PointField_D& y, realx3PointField_D& dy) = 0;
virtual
bool predict(real dt, realx3Field_D& y, realx3PointField_D& dy) = 0;
/// Correction/main integration step /// Correction/main integration step
virtual virtual
bool correct(real dt, realx3PointField_D& y, realx3PointField_D& dy) = 0; bool correct(real dt, realx3PointField_D& y, realx3PointField_D& dy) = 0;
virtual
bool correct(real dt, realx3Field_D& y, realx3PointField_D& dy) = 0;
/// Set the initial values for new indices /// Set the initial values for new indices
virtual virtual
bool setInitialVals( bool setInitialVals(

View File

@ -219,11 +219,11 @@ bool pFlow::sphereParticles::initInertia()
auto aPointsMask = dynPointStruct().activePointsMaskDevice(); auto aPointsMask = dynPointStruct().activePointsMaskDevice();
auto aRange = aPointsMask.activeRange(); auto aRange = aPointsMask.activeRange();
auto field_shapeIndex = shapeIndex().fieldDevice(); auto field_shapeIndex = shapeIndex().deviceView();
auto field_diameter = diameter_.fieldDevice(); auto field_diameter = diameter_.deviceView();
auto field_mass = mass_.fieldDevice(); auto field_mass = mass_.deviceView();
auto field_propId = propertyId_.fieldDevice(); auto field_propId = propertyId_.deviceView();
auto field_I = I_.fieldDevice(); auto field_I = I_.deviceView();
// get info from spheres shape // get info from spheres shape
realVector_D d("diameter", spheres_.boundingDiameter()); realVector_D d("diameter", spheres_.boundingDiameter());
@ -231,10 +231,10 @@ bool pFlow::sphereParticles::initInertia()
uint32Vector_D propId("propId", spheres_.shapePropertyIds()); uint32Vector_D propId("propId", spheres_.shapePropertyIds());
realVector_D I("I", spheres_.Inertia()); realVector_D I("I", spheres_.Inertia());
auto d_d = d.deviceVector(); auto d_d = d.deviceView();
auto d_mass = mass.deviceVector(); auto d_mass = mass.deviceView();
auto d_propId = propId.deviceVector(); auto d_propId = propId.deviceView();
auto d_I = I.deviceVector(); auto d_I = I.deviceView();
Kokkos::parallel_for( Kokkos::parallel_for(
"particles::initInertia", "particles::initInertia",
@ -385,7 +385,7 @@ pFlow::sphereParticles::sphereParticles(
auto index = indexHD.indicesHost(); auto index = indexHD.indicesHost();
realx3Vector rvel(n,RESERVE()); realx3Vector rvel(n,RESERVE());
const auto hrVel = rVelocity_.hostVector(); const auto hrVel = rVelocity_.hostView();
for(auto i=0; i<n; i++) for(auto i=0; i<n; i++)
{ {
@ -464,7 +464,7 @@ bool pFlow::sphereParticles::beforeIteration()
rVelIntegration_().predict(dt(),rVelocity_, rAcceleration_); rVelIntegration_().predict(dt(),rVelocity_, rAcceleration_);
intPredictTimer_.end(); intPredictTimer_.end();
WARNING<<"pFlow::sphereParticles::beforeIteration()"<<END_WARNING; //WARNING<<"pFlow::sphereParticles::beforeIteration()"<<END_WARNING;
return true; return true;
} }
@ -475,13 +475,13 @@ bool pFlow::sphereParticles::iterate()
accelerationTimer_.start(); accelerationTimer_.start();
pFlow::sphereParticlesKernels::acceleration( pFlow::sphereParticlesKernels::acceleration(
control().g(), control().g(),
mass().fieldDevice(), mass().deviceView(),
contactForce().fieldDevice(), contactForce().deviceView(),
I().fieldDevice(), I().deviceView(),
contactTorque().fieldDevice(), contactTorque().deviceView(),
dynPointStruct().activePointsMaskDevice(), dynPointStruct().activePointsMaskDevice(),
accelertion().fieldDevice(), accelertion().deviceView(),
rAcceleration().fieldDevice() rAcceleration().deviceView()
); );
accelerationTimer_.end(); accelerationTimer_.end();

View File

@ -78,16 +78,28 @@ pFlow::dynamicPointStructure::dynamicPointStructure
} }
bool pFlow::dynamicPointStructure::predict /*bool pFlow::dynamicPointStructure::beforeIteration()
(
real dt,
realx3PointField_D& acceleration
)
{ {
//auto& pos = pStruct().pointPosition(); pointStructure::beforeIteration();
auto& acc = time().lookupObject<realx3PointField_D>("acceleration");
return predict(dt(), acc);
}*/
//if(!integrationPos_().predict(dt, pos.VectorField(), velocity_.VectorField() ))return false; /*bool pFlow::dynamicPointStructure::iterate()
//if(!integrationVel_().predict(dt, velocity_.VectorField(), acceleration.VectorField()))return false; {
pointStructure::iterate();
auto& acc = time().lookupObject<realx3PointField_D>("acceleration");
return correct(dt(), acc);
}*/
bool pFlow::dynamicPointStructure::predict(
real dt,
realx3PointField_D &acceleration)
{
if(!integrationPos_().predict(dt, pointPosition(), velocity_ ))return false;
if(!integrationVel_().predict(dt, velocity_, acceleration))return false;
return true; return true;
} }
@ -100,9 +112,9 @@ bool pFlow::dynamicPointStructure::correct
{ {
//auto& pos = pStruct().pointPosition(); //auto& pos = pStruct().pointPosition();
//if(!integrationPos_().correct(dt, pos.VectorField(), velocity_.VectorField() ))return false; if(!integrationPos_().correct(dt, pointPosition(), velocity_) )return false;
//if(!integrationVel_().correct(dt, velocity_.VectorField(), acceleration.VectorField()))return false; if(!integrationVel_().correct(dt, velocity_, acceleration))return false;
return true; return true;
} }
@ -121,7 +133,7 @@ pFlow::uniquePtr<pFlow::int32IndexContainer> pFlow::dynamicPointStructure::inser
if(!integrationPos_().needSetInitialVals()) return newIndicesPtr; if(!integrationPos_().needSetInitialVals()) return newIndicesPtr;
auto hVel = velocity_.hostVector(); auto hVel = velocity_.hostView();
auto n = newIndicesPtr().size(); auto n = newIndicesPtr().size();
auto index = newIndicesPtr().indicesHost(); auto index = newIndicesPtr().indicesHost();
@ -158,8 +170,8 @@ pFlow::uniquePtr<pFlow::int32IndexContainer> pFlow::dynamicPointStructure::inser
realx3Vector pos(n,RESERVE()); realx3Vector pos(n,RESERVE());
realx3Vector vel(n,RESERVE()); realx3Vector vel(n,RESERVE());
const auto hVel = velocity().hostVector(); const auto hVel = velocity().hostView();
const auto hPos = pStruct().pointPosition().hostVector(); const auto hPos = pStruct().pointPosition().hostView();
for(auto i=0; i<n; i++) for(auto i=0; i<n; i++)
{ {

View File

@ -80,10 +80,14 @@ public:
return velocity_; return velocity_;
} }
/*inline auto velocityHostAll() /// In the time loop before iterate
{ //bool beforeIteration() override;
return velocity_.hostVectorAll();
}*/ /// @brief This is called in time loop. Perform the main calculations
/// when the component should evolve along time.
//bool iterate() override;
bool predict(real dt, realx3PointField_D& acceleration); bool predict(real dt, realx3PointField_D& acceleration);

View File

@ -259,8 +259,8 @@ public:
dualView_.clear_sync_state(); dualView_.clear_sync_state();
} }
Kokkos::deep_copy(hostVector(), src.hostVector()); Kokkos::deep_copy(hostView(), src.hostView());
Kokkos::deep_copy(deviceVector(), src.deviceVector()); Kokkos::deep_copy(deviceView(), src.deviceView());
} }
// copy construct with new name // copy construct with new name
@ -280,8 +280,8 @@ public:
dualView_.clear_sync_state(); dualView_.clear_sync_state();
} }
Kokkos::deep_copy(hostVector(), src.hostVector()); Kokkos::deep_copy(hostView(), src.hostView());
Kokkos::deep_copy(deviceVector(), src.deviceVector()); Kokkos::deep_copy(deviceView(), src.deviceView());
} }
// - copy assignment // - copy assignment
@ -332,53 +332,53 @@ public:
} }
// - Device vector // - Device vector
INLINE_FUNCTION_H deviceViewType& deviceVectorAll(){ INLINE_FUNCTION_H deviceViewType& deviceViewAll(){
return dualView_.d_view; return dualView_.d_view;
} }
// - Device vector // - Device vector
INLINE_FUNCTION_H const deviceViewType& deviceVectorAll() const { INLINE_FUNCTION_H const deviceViewType& deviceViewAll() const {
return dualView_.d_view; return dualView_.d_view;
} }
// - Host vector // - Host vector
INLINE_FUNCTION_H hostViewType& hostVectorAll(){ INLINE_FUNCTION_H hostViewType& hostViewAll(){
return dualView_.h_view; return dualView_.h_view;
} }
// - Host Vector // - Host Vector
INLINE_FUNCTION_H const hostViewType& hostVectorAll() const { INLINE_FUNCTION_H const hostViewType& hostViewAll() const {
return dualView_.h_view; return dualView_.h_view;
} }
INLINE_FUNCTION_H deviceViewType& deviceVector(){ INLINE_FUNCTION_H deviceViewType& deviceView(){
updateSubViews(); updateSubViews();
return deviceSubView_; return deviceSubView_;
} }
INLINE_FUNCTION_H const deviceViewType& deviceVector() const{ INLINE_FUNCTION_H const deviceViewType& deviceView() const{
updateSubViews(); updateSubViews();
return deviceSubView_; return deviceSubView_;
} }
INLINE_FUNCTION_H hostViewType& hostVector(){ INLINE_FUNCTION_H hostViewType& hostView(){
updateSubViews(); updateSubViews();
return hostSubView_; return hostSubView_;
} }
INLINE_FUNCTION_H const hostViewType& hostVector()const{ INLINE_FUNCTION_H const hostViewType& hostView()const{
updateSubViews(); updateSubViews();
return hostSubView_; return hostSubView_;
} }
INLINE_FUNCTION_H INLINE_FUNCTION_H
hostViewType hostVector(int32 start, int32 end)const hostViewType hostView(int32 start, int32 end)const
{ {
return Kokkos::subview(dualView_.h_view, Kokkos::make_pair(start,end)); return Kokkos::subview(dualView_.h_view, Kokkos::make_pair(start,end));
} }
INLINE_FUNCTION_H INLINE_FUNCTION_H
deviceViewType deviceVector(int32 start, int32 end)const deviceViewType deviceView(int32 start, int32 end)const
{ {
return Kokkos::subview(dualView_.d_view, Kokkos::make_pair(start,end)); return Kokkos::subview(dualView_.d_view, Kokkos::make_pair(start,end));
} }
@ -455,22 +455,22 @@ public:
INLINE_FUNCTION_H void fill(const T& val) INLINE_FUNCTION_H void fill(const T& val)
{ {
if(empty())return; if(empty())return;
Kokkos::deep_copy(deviceVector(),val); Kokkos::deep_copy(deviceView(),val);
Kokkos::deep_copy(hostVector(),val); Kokkos::deep_copy(hostView(),val);
dualView_.clear_sync_state(); dualView_.clear_sync_state();
} }
INLINE_FUNCTION_H void fillHost(const T& val) INLINE_FUNCTION_H void fillHost(const T& val)
{ {
if(empty())return; if(empty())return;
Kokkos::deep_copy(hostVector(),val); Kokkos::deep_copy(hostView(),val);
modifyOnHost(); modifyOnHost();
} }
INLINE_FUNCTION_H void fillDevice(const T& val) INLINE_FUNCTION_H void fillDevice(const T& val)
{ {
if(empty())return; if(empty())return;
Kokkos::deep_copy(deviceVector(),val); Kokkos::deep_copy(deviceView(),val);
modifyOnDevice(); modifyOnDevice();
} }
@ -556,7 +556,7 @@ public:
size_t newSize = indices.size(); size_t newSize = indices.size();
deviceViewType sortedView("sortedView", newSize); deviceViewType sortedView("sortedView", newSize);
auto dVec = deviceVectorAll(); auto dVec = deviceViewAll();
auto d_indices = indices.deviceView(); auto d_indices = indices.deviceView();
@ -570,7 +570,7 @@ public:
Kokkos::fence(); Kokkos::fence();
setSize(newSize); setSize(newSize);
copy(deviceVector(), sortedView); copy(deviceView(), sortedView);
modifyOnDevice(); modifyOnDevice();
syncViews(); syncViews();
} }
@ -586,10 +586,10 @@ public:
{ {
resize(maxInd+1); resize(maxInd+1);
} }
fillSelected(hostVectorAll(), indices.hostView(), indices.size(), val); fillSelected(hostViewAll(), indices.hostView(), indices.size(), val);
auto dIndices = indices.deviceView(); auto dIndices = indices.deviceView();
auto dVals = deviceVectorAll(); auto dVals = deviceViewAll();
Kokkos::parallel_for( Kokkos::parallel_for(
"fillSelected", "fillSelected",
@ -627,10 +627,10 @@ public:
{ {
hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size()); hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
//fillSelected(hostVector(), indices.hostView(), hVecVals, indices.size()); //fillSelected(hostView(), indices.hostView(), hVecVals, indices.size());
pFlow::algorithms::KOKKOS::fillSelected<T, int32, DefaultHostExecutionSpace>( pFlow::algorithms::KOKKOS::fillSelected<T, int32, DefaultHostExecutionSpace>(
hostVectorAll().data(), hostViewAll().data(),
indices.hostView().data(), indices.hostView().data(),
hVecVals.data(), hVecVals.data(),
indices.size()); indices.size());
@ -648,9 +648,9 @@ public:
Kokkos::deep_copy(dVecVals, hVecVals); Kokkos::deep_copy(dVecVals, hVecVals);
//fillSelected(deviceVector(), indices.deviceView(), dVecVals, indices.size()); //fillSelected(deviceView(), indices.deviceView(), dVecVals, indices.size());
pFlow::algorithms::KOKKOS::fillSelected<T, int32, execution_space>( pFlow::algorithms::KOKKOS::fillSelected<T, int32, execution_space>(
deviceVectorAll().data(), deviceViewAll().data(),
indices.deviceView().data(), indices.deviceView().data(),
dVecVals.data(), dVecVals.data(),
indices.size()); indices.size());
@ -683,7 +683,7 @@ public:
if constexpr (std::is_same<side,HostSide>::value ) if constexpr (std::is_same<side,HostSide>::value )
{ {
hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size()); hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
fillSelected( hostVectorAll(), hVecInd, indices.size(), val); fillSelected( hostViewAll(), hVecInd, indices.size(), val);
modifyOnHost(); modifyOnHost();
syncViews(minInd, maxInd+1); syncViews(minInd, maxInd+1);
@ -696,7 +696,7 @@ public:
hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size()); hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
deviceViewType1D<int32> dVecInd("dVecInd", indices.size()); deviceViewType1D<int32> dVecInd("dVecInd", indices.size());
Kokkos::deep_copy(dVecInd, hVecInd); Kokkos::deep_copy(dVecInd, hVecInd);
fillSelected(deviceVectorAll(), dVecInd, indices.size(), val); fillSelected(deviceViewAll(), dVecInd, indices.size(), val);
modifyOnDevice(); modifyOnDevice();
@ -734,7 +734,7 @@ public:
hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size()); hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size()); hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
fillSelected(hostVectorAll(), hVecInd, hVecVals, indices.size()); fillSelected(hostViewAll(), hVecInd, hVecVals, indices.size());
modifyOnHost(); modifyOnHost();
@ -752,7 +752,7 @@ public:
Kokkos::deep_copy(dVecVals, hVecVals); Kokkos::deep_copy(dVecVals, hVecVals);
Kokkos::deep_copy(dVecInd, hVecInd); Kokkos::deep_copy(dVecInd, hVecInd);
fillSelected(deviceVectorAll(), dVecInd, dVecVals, indices.size()); fillSelected(deviceViewAll(), dVecInd, dVecVals, indices.size());
modifyOnDevice(); modifyOnDevice();
@ -858,7 +858,7 @@ public:
{ {
if(empty())return; if(empty())return;
Kokkos::deep_copy(deviceVector(), hostVector()); Kokkos::deep_copy(deviceView(), hostView());
dualView_.clear_sync_state(); dualView_.clear_sync_state();
} }
@ -866,7 +866,7 @@ public:
void copyHostToDevice(int32 start, int32 end, bool setUpdated = true) void copyHostToDevice(int32 start, int32 end, bool setUpdated = true)
{ {
if(empty())return; if(empty())return;
Kokkos::deep_copy(deviceVector(start, end), hostVector(start, end)); Kokkos::deep_copy(deviceView(start, end), hostView(start, end));
if(setUpdated) if(setUpdated)
dualView_.clear_sync_state(); dualView_.clear_sync_state();
} }
@ -876,7 +876,7 @@ public:
INLINE_FUNCTION_H void copyDeviceToHost() INLINE_FUNCTION_H void copyDeviceToHost()
{ {
if(empty())return; if(empty())return;
Kokkos::deep_copy(hostVector(), deviceVector()); Kokkos::deep_copy(hostView(), deviceView());
dualView_.clear_sync_state(); dualView_.clear_sync_state();
} }
@ -884,7 +884,7 @@ public:
void copyDeviceToHost(int32 start, int32 end, bool setUpdated = true) void copyDeviceToHost(int32 start, int32 end, bool setUpdated = true)
{ {
if(empty())return; if(empty())return;
Kokkos::deep_copy(hostVector(start, end), deviceVector(start, end)); Kokkos::deep_copy(hostView(start, end), deviceView(start, end));
if(setUpdated) if(setUpdated)
dualView_.clear_sync_state(); dualView_.clear_sync_state();
} }
@ -962,12 +962,12 @@ public:
if(hostRequiresSync()) // device is updated if(hostRequiresSync()) // device is updated
{ {
//const auto dVec = Kokkos::subview(dualView_.d_view, Kokkos::make_pair(0,int(size_))); //const auto dVec = Kokkos::subview(dualView_.d_view, Kokkos::make_pair(0,int(size_)));
Kokkos::deep_copy(mirror,deviceVector()); Kokkos::deep_copy(mirror,deviceView());
} }
else // either host is updated or both sides are syncronized else // either host is updated or both sides are syncronized
{ {
//const auto hVec = Kokkos::subview(dualView_.h_view, Kokkos::make_pair(0,int(size_))); //const auto hVec = Kokkos::subview(dualView_.h_view, Kokkos::make_pair(0,int(size_)));
Kokkos::deep_copy(mirror,hostVector()); Kokkos::deep_copy(mirror,hostView());
} }
return vecToFile.write(os); return vecToFile.write(os);
} }

View File

@ -39,11 +39,11 @@ int64 count(const VectorDual<T,MemorySpace>& vec, const T& val)
{ {
if constexpr (std::is_same<side,HostSide>::value) if constexpr (std::is_same<side,HostSide>::value)
{ {
return count( vec.hostVectorAll(), static_cast<size_t>(0), vec.size(), val); return count( vec.hostViewAll(), static_cast<size_t>(0), vec.size(), val);
} }
else else
{ {
return count( vec.deviceVectorAll(), static_cast<size_t>(0), vec.size(), val); return count( vec.deviceViewAll(), static_cast<size_t>(0), vec.size(), val);
} }
return -1; return -1;
@ -63,11 +63,11 @@ int64 min(const VectorDual<T,MemorySpace>& vec)
{ {
if constexpr (std::is_same<side,HostSide>::value) if constexpr (std::is_same<side,HostSide>::value)
{ {
return min( vec.hostVectorAll(), static_cast<size_t>(0), vec.size()); return min( vec.hostViewAll(), static_cast<size_t>(0), vec.size());
} }
else else
{ {
return min( vec.deviceVectorAll(), static_cast<size_t>(0), vec.size()); return min( vec.deviceViewAll(), static_cast<size_t>(0), vec.size());
} }
return 0.0; return 0.0;
@ -87,11 +87,11 @@ int64 max(const VectorDual<T,MemorySpace>& vec)
{ {
if constexpr (std::is_same<side,HostSide>::value) if constexpr (std::is_same<side,HostSide>::value)
{ {
return max( vec.hostVectorAll(), static_cast<size_t>(0), vec.size()); return max( vec.hostViewAll(), static_cast<size_t>(0), vec.size());
} }
else else
{ {
return max( vec.deviceVectorAll(), static_cast<size_t>(0), vec.size()); return max( vec.deviceViewAll(), static_cast<size_t>(0), vec.size());
} }
return 0.0; return 0.0;

View File

@ -182,7 +182,7 @@ pFlow::VectorSingle<T,MemorySpace>::VectorSingle
: :
VectorSingle(name, src.capacity(), src.size(), RESERVE()) VectorSingle(name, src.capacity(), src.size(), RESERVE())
{ {
copy(deviceVector(), src.deviceVector()); copy(deviceView(), src.deviceView());
} }
template<typename T, typename MemorySpace> template<typename T, typename MemorySpace>
@ -213,13 +213,6 @@ pFlow::uniquePtr<pFlow::VectorSingle<T,MemorySpace>>
return makeUnique<VectorSingle>( this->name(), *this); return makeUnique<VectorSingle>( this->name(), *this);
} }
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
pFlow::VectorSingle<T,MemorySpace>*
pFlow::VectorSingle<T,MemorySpace>::clonePtr()const
{
return new VectorSingle(this->name(), *this);
}
template<typename T, typename MemorySpace> template<typename T, typename MemorySpace>
INLINE_FUNCTION_H INLINE_FUNCTION_H
@ -239,21 +232,23 @@ pFlow::VectorSingle<T,MemorySpace>::VectorField()const
template<typename T, typename MemorySpace> template<typename T, typename MemorySpace>
INLINE_FUNCTION_H INLINE_FUNCTION_H
auto pFlow::VectorSingle<T,MemorySpace>::deviceVectorAll() const auto pFlow::VectorSingle<T,MemorySpace>::deviceViewAll() const
{ {
return view_; return view_;
} }
template<typename T, typename MemorySpace> template<typename T, typename MemorySpace>
INLINE_FUNCTION_H INLINE_FUNCTION_H
auto pFlow::VectorSingle<T,MemorySpace>::deviceVector()const auto pFlow::VectorSingle<T,MemorySpace>::deviceView()const
{ {
return Kokkos::subview(view_, Kokkos::make_pair(0,int(size_))); return Kokkos::subview(
view_,
Kokkos::make_pair(0u,static_cast<uint32>(size_)));
} }
template<typename T, typename MemorySpace> template<typename T, typename MemorySpace>
INLINE_FUNCTION_H INLINE_FUNCTION_H
auto pFlow::VectorSingle<T,MemorySpace>::hostVectorAll()const auto pFlow::VectorSingle<T,MemorySpace>::hostViewAll()const
{ {
auto hView = Kokkos::create_mirror_view(view_); auto hView = Kokkos::create_mirror_view(view_);
copy(hView, view_); copy(hView, view_);
@ -262,10 +257,10 @@ auto pFlow::VectorSingle<T,MemorySpace>::hostVectorAll()const
template<typename T, typename MemorySpace> template<typename T, typename MemorySpace>
INLINE_FUNCTION_H INLINE_FUNCTION_H
auto pFlow::VectorSingle<T,MemorySpace>::hostVector()const auto pFlow::VectorSingle<T,MemorySpace>::hostView()const
{ {
auto hView = Kokkos::create_mirror_view(deviceVector()); auto hView = Kokkos::create_mirror_view(deviceView());
copy(hView, deviceVector()); copy(hView, deviceView());
return hView; return hView;
} }
@ -402,7 +397,7 @@ void pFlow::VectorSingle<T,MemorySpace>::assign
// - unmanaged view in the host // - unmanaged view in the host
hostViewType1D<const T> temp(src.data(), srcSize ); hostViewType1D<const T> temp(src.data(), srcSize );
copy(deviceVector(), temp); copy(deviceView(), temp);
} }
template<typename T, typename MemorySpace> template<typename T, typename MemorySpace>
@ -429,7 +424,7 @@ void pFlow::VectorSingle<T,MemorySpace>::assign(const VectorTypeHost& src)
{ {
setSize(srcSize); setSize(srcSize);
} }
copy(deviceVector(), src.hostVector()); copy(deviceView(), src.hostView());
} }
template<typename T, typename MemorySpace> template<typename T, typename MemorySpace>
@ -528,7 +523,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(uint32 i){
dVec(ind(i))= dVals(i);}); dVec(ind(i))= dVals(i);});
Kokkos::fence(); Kokkos::fence();
@ -540,7 +535,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(uint32 i){
dVec(ind(i))= hVals(i);}); dVec(ind(i))= hVals(i);});
Kokkos::fence(); Kokkos::fence();
@ -579,7 +574,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(uint32 i){
dVec(ind(i))= dVals(i);}); dVec(ind(i))= dVals(i);});
Kokkos::fence(); Kokkos::fence();
@ -592,7 +587,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(uint32 i){
dVec(ind(i))= hVals(i);}); dVec(ind(i))= hVals(i);});
Kokkos::fence(); Kokkos::fence();
@ -665,7 +660,7 @@ bool pFlow::VectorSingle<T,MemorySpace>::reorderItems(uint32IndexContainer indic
Kokkos::fence(); Kokkos::fence();
} }
copy(deviceVector(), sortedView); copy(deviceView(), sortedView);
return true; return true;
} }

View File

@ -178,10 +178,7 @@ public:
INLINE_FUNCTION_H INLINE_FUNCTION_H
uniquePtr<VectorSingle> clone() const; uniquePtr<VectorSingle> clone() const;
/// Clone as a pointer (perform deep copy)
INLINE_FUNCTION_H
VectorSingle* clonePtr()const;
//// - Methods //// - Methods
/// Return *this /// Return *this
@ -192,22 +189,22 @@ public:
INLINE_FUNCTION_H INLINE_FUNCTION_H
const VectorType& VectorField()const; const VectorType& VectorField()const;
/// Device vector range [0,capcity) /// Device view range [0,capcity)
INLINE_FUNCTION_H INLINE_FUNCTION_H
auto deviceVectorAll() const; auto deviceViewAll() const;
/// Device vector range [0, size) /// Device view range [0, size)
INLINE_FUNCTION_H INLINE_FUNCTION_H
auto deviceVector()const; auto deviceView()const;
/// Return a vector accessible on Host in range [0,capacity) /// Return a view accessible on Host in range [0,capacity)
INLINE_FUNCTION_H INLINE_FUNCTION_H
auto hostVectorAll()const; auto hostViewAll()const;
/// Return a vector accessible on Host in range [0,size) /// Return a view accessible on Host in range [0,size)
INLINE_FUNCTION_H INLINE_FUNCTION_H
auto hostVector()const; auto hostView()const;
/// Name of the vector /// Name of the vector
INLINE_FUNCTION_H INLINE_FUNCTION_H
@ -403,7 +400,7 @@ public:
FUNCTION_H FUNCTION_H
bool write(iOstream& os, const IOPattern& iop)const bool write(iOstream& os, const IOPattern& iop)const
{ {
auto hVec = hostVector(); auto hVec = hostView();
auto sp = span<T>( const_cast<T*>(hVec.data()), hVec.size()); auto sp = span<T>( const_cast<T*>(hVec.data()), hVec.size());
return writeSpan(os, sp, iop); return writeSpan(os, sp, iop);
@ -413,7 +410,7 @@ public:
FUNCTION_H FUNCTION_H
bool write(iOstream& os)const bool write(iOstream& os)const
{ {
auto hVec = hostVector(); auto hVec = hostView();
auto sp = span<T>( const_cast<T*>(hVec.data()), hVec.size()); auto sp = span<T>( const_cast<T*>(hVec.data()), hVec.size());
return writeSpan(os, sp); return writeSpan(os, sp);
@ -424,7 +421,7 @@ public:
FUNCTION_H FUNCTION_H
bool write(iOstream& os, const IOPattern& iop, const HostMask& mask)const bool write(iOstream& os, const IOPattern& iop, const HostMask& mask)const
{ {
auto hVec = hostVector(); auto hVec = hostView();
auto numActive = mask.numActive(); auto numActive = mask.numActive();
std::vector<T> finalField; std::vector<T> finalField;
@ -518,5 +515,5 @@ inline iOstream& operator << (iOstream& os, const VectorSingle<T, MemorySpace>&
INLINE_FUNCTION_H INLINE_FUNCTION_H
bool append(const VectorSingle& Vec) bool append(const VectorSingle& Vec)
{ {
return append(Vec.deviceVector(), Vec.size()); return append(Vec.deviceView(), Vec.size());
}*/ }*/

View File

@ -28,14 +28,14 @@ template<typename T, typename MemorySpace>
INLINE_FUNCTION_H INLINE_FUNCTION_H
size_t count(const VectorSingle<T,MemorySpace>& vec, const T& val) size_t count(const VectorSingle<T,MemorySpace>& vec, const T& val)
{ {
return count( vec.deviceVectorAll(), 0, vec.size(), val); return count( vec.deviceViewAll(), 0, vec.size(), val);
} }
template<class T, class MemorySpace> template<class T, class MemorySpace>
INLINE_FUNCTION_H T min( const VectorSingle<T,MemorySpace>& vec) INLINE_FUNCTION_H T min( const VectorSingle<T,MemorySpace>& vec)
{ {
return min( return min(
vec.deviceVectorAll(), vec.deviceViewAll(),
0, vec.size() 0, vec.size()
); );
} }
@ -44,7 +44,7 @@ template<class T, class MemorySpace>
INLINE_FUNCTION_H T max( const VectorSingle<T, MemorySpace>& vec) INLINE_FUNCTION_H T max( const VectorSingle<T, MemorySpace>& vec)
{ {
return min( return min(
vec.deviceVectorAll(), vec.deviceViewAll(),
0, vec.size() 0, vec.size()
); );
} }

View File

@ -73,7 +73,7 @@ typename pFlow::internalField<T, MemorySpace>::FieldTypeHost
pFlow::internalField<T, MemorySpace>::activeValuesHost() const pFlow::internalField<T, MemorySpace>::activeValuesHost() const
{ {
auto maskH = internalPoints_.activePointsMaskHost(); auto maskH = internalPoints_.activePointsMaskHost();
auto fieldH = field_.hostVector(); auto fieldH = field_.hostView();
FieldTypeHost aField FieldTypeHost aField
( (
@ -105,13 +105,6 @@ bool pFlow::internalField<T, MemorySpace>::write
const IOPattern& iop const IOPattern& iop
)const )const
{ {
if( internalPoints_.isAllActive() ) auto aField = activeValuesHost();
{ return aField.write(os, iop);
return field_.write(os, iop);
}
else
{
auto aField = activeValuesHost();
return aField.write(os, iop);
}
} }

View File

@ -75,22 +75,30 @@ public:
const internalPoints& internal, const internalPoints& internal,
const T& val); const T& val);
inline
auto fieldDevice()const auto deviceView()const
{ {
return field_.deviceVector(); return field_.deviceView();
} }
auto fieldHost()const inline
auto hostView()const
{ {
return field_.hostVector(); return field_.hostView();
} }
inline
const FieldType& field()const const FieldType& field()const
{ {
return field_; return field_;
} }
inline
FieldType& field()
{
return field_;
}
const pFlagTypeDevice& activePointsMaskDevice()const const pFlagTypeDevice& activePointsMaskDevice()const
{ {
return internalPoints_.activePointsMaskDevice(); return internalPoints_.activePointsMaskDevice();

View File

@ -39,7 +39,7 @@ T min(const internalField<T,MemorySpace>& iField)
// this is a device view // this is a device view
auto maskD = iField.activePointsMaskDevice(); auto maskD = iField.activePointsMaskDevice();
auto aRange = maskD.activeRange(); auto aRange = maskD.activeRange();
auto filed = iField.field().deviceVectorAll(); auto filed = iField.field().deviceViewAll();
T minElement; T minElement;
@ -59,7 +59,7 @@ T min(const internalField<T,MemorySpace>& iField)
// this is a host view // this is a host view
auto maskH = iField.activePointsMaskHost(); auto maskH = iField.activePointsMaskHost();
auto aRange = maskH.activeRange(); auto aRange = maskH.activeRange();
auto filed = iField.field().deviceVectorAll(); auto filed = iField.field().deviceViewAll();
T minElement; T minElement;
Kokkos::parallel_reduce( Kokkos::parallel_reduce(
"min(internalField)", "min(internalField)",
@ -90,7 +90,7 @@ T max(const internalField<T,MemorySpace>& iField)
// this is a device view // this is a device view
auto maskD = iField.activePointsMaskDevice(); auto maskD = iField.activePointsMaskDevice();
auto aRange = maskD.activeRange(); auto aRange = maskD.activeRange();
auto filed = iField.field().deviceVectorAll(); auto filed = iField.field().deviceViewAll();
T maxElement; T maxElement;
@ -110,7 +110,7 @@ T max(const internalField<T,MemorySpace>& iField)
// this is a host view // this is a host view
auto maskH = iField.activePointsMaskHost(); auto maskH = iField.activePointsMaskHost();
auto aRange = maskH.activeRange(); auto aRange = maskH.activeRange();
auto filed = iField.field().deviceVectorAll(); auto filed = iField.field().deviceViewAll();
T maxElement; T maxElement;
@ -143,7 +143,7 @@ Pair<T,T> minMax(const internalField<T,MemorySpace>& iField)
// this is a device view // this is a device view
auto maskD = iField.activePointsMaskDevice(); auto maskD = iField.activePointsMaskDevice();
auto aRange = maskD.activeRange(); auto aRange = maskD.activeRange();
auto filed = iField.field().deviceVectorAll(); auto filed = iField.field().deviceViewAll();
T minElement; T minElement;
T maxElement; T maxElement;
@ -170,7 +170,7 @@ Pair<T,T> minMax(const internalField<T,MemorySpace>& iField)
// this is a host view // this is a host view
auto maskH = iField.activePointsMaskHost(); auto maskH = iField.activePointsMaskHost();
auto aRange = maskH.activeRange(); auto aRange = maskH.activeRange();
auto filed = iField.field().deviceVectorAll(); auto filed = iField.field().deviceViewAll();
T minElement; T minElement;
T maxElement; T maxElement;

View File

@ -109,15 +109,15 @@ T maxActive(const pointField<VectorSingle, T, MemorySpace>& pField)
{ {
if(len < sizeToSerial__ ) // serial execution instead of lunching parallel execution if(len < sizeToSerial__ ) // serial execution instead of lunching parallel execution
return maxActive_serial( return maxActive_serial(
pField.deviceVectorAll(), pField.deviceViewAll(),
pField.pointFlag().hostVectorAll(), pField.pointFlag().hostViewAll(),
static_cast<size_t>(0), static_cast<size_t>(0),
len len
); );
else else
return maxActiveH( return maxActiveH(
pField.deviceVectorAll(), pField.deviceViewAll(),
pField.pointFlag().hostVectorAll(), pField.pointFlag().hostViewAll(),
static_cast<size_t>(0), static_cast<size_t>(0),
len len
); );
@ -125,8 +125,8 @@ T maxActive(const pointField<VectorSingle, T, MemorySpace>& pField)
else else
{ {
return maxActiveD( return maxActiveD(
pField.deviceVectorAll(), pField.deviceViewAll(),
pField.pointFlag().deviceVectorAll(), pField.pointFlag().deviceViewAll(),
static_cast<size_t>(0), static_cast<size_t>(0),
len len
); );
@ -148,23 +148,23 @@ T maxActive(const pointField<VectorDual, T, MemorySpace>& pField)
{ {
if( len < sizeToSerial__) if( len < sizeToSerial__)
return maxActive_serial( return maxActive_serial(
pField.hostVectorAll(), pField.hostViewAll(),
pField.pointFlag().hostVectorAll(), pField.pointFlag().hostViewAll(),
static_cast<size_t>(0), static_cast<size_t>(0),
len len
); );
else else
return maxActiveH( return maxActiveH(
pField.hostVectorAll(), pField.hostViewAll(),
pField.pointFlag().hostVectorAll(), pField.pointFlag().hostViewAll(),
static_cast<size_t>(0), static_cast<size_t>(0),
len len
); );
}else }else
{ {
return maxActiveD( return maxActiveD(
pField.deviceVectorAll(), pField.deviceViewAll(),
pField.pointFlag().deviceVectorAll(), pField.pointFlag().deviceViewAll(),
static_cast<size_t>(0), static_cast<size_t>(0),
len len
); );

View File

@ -25,6 +25,7 @@ Licence:
#include "typeInfo.hpp" #include "typeInfo.hpp"
#include "dictionary.hpp" #include "dictionary.hpp"
#include "streams.hpp"
namespace pFlow namespace pFlow
{ {
@ -108,8 +109,9 @@ public:
inline inline
bool isMember(T val, T epsilon = 0)const bool isMember(T val, T epsilon = 0)const
{ {
if(!isInRange(val)) return false; if(!isInRange(val)) return false;
if(abs(mod(val-begin_,stride_))<= epsilon) return true; if(T dist = val-begin_; abs(dist%stride_)<= epsilon) return true;
if(equal(val,begin_))return true; if(equal(val,begin_))return true;
if(equal(val,end_))return true; if(equal(val,end_))return true;
return false; return false;
@ -147,6 +149,22 @@ public:
} }
}; };
template<>
inline
bool stridedRange<real>::isMember(real val, real epsilon)const
{
if(!isInRange(val)) return false;
real dist = val-begin_;
if(abs(
(dist-(static_cast<uint64>((dist+0.01*epsilon)/stride_)*stride_))
)<= epsilon) return true;
if(equal(val,begin_))return true;
if(equal(val,end_))return true;
return false;
}
} }
#endif //__stridedRange_hpp__ #endif //__stridedRange_hpp__

View File

@ -21,7 +21,6 @@ Licence:
#include "baseTimeControl.hpp" #include "baseTimeControl.hpp"
pFlow::baseTimeControl::baseTimeControl pFlow::baseTimeControl::baseTimeControl
( (
const dictionary &dict, const dictionary &dict,
@ -46,7 +45,7 @@ pFlow::baseTimeControl::baseTimeControl
word intervalWord = intervalPrefix.size()==0? word("interval"): intervalPrefix+"Interval"; word intervalWord = intervalPrefix.size()==0? word("interval"): intervalPrefix+"Interval";
if(isTimeStep_) if(!isTimeStep_)
{ {
auto startTime = (dict.getValOrSet<real>("startTime", defStartTime)); auto startTime = (dict.getValOrSet<real>("startTime", defStartTime));
auto endTime = (dict.getValOrSet<real>("endTime", largeValue)); auto endTime = (dict.getValOrSet<real>("endTime", largeValue));
@ -72,7 +71,7 @@ bool pFlow::baseTimeControl::timeEvent(uint32 iter, real t, real dt) const
} }
else else
{ {
return rRange_.isMember(t, 0.51*dt); return rRange_.isMember(t, 0.55*dt);
} }
return false; return false;
} }

View File

@ -174,7 +174,7 @@ void pFlow::timeControl::checkForOutputToFile()
bool pFlow::timeControl::timersReportTime()const bool pFlow::timeControl::timersReportTime()const
{ {
if(currentIter_<=1)return false; if(currentIter_<=1)return false;
return timersReportInterval_.isMember(currentTime_, dt_); return timersReportInterval_.isMember(currentTime_, 0.55*dt_);
} }
bool pFlow::timeControl::sortTime()const bool pFlow::timeControl::sortTime()const

View File

@ -41,33 +41,39 @@ Licence:
}*/ }*/
pFlow::boundaryBase::boundaryBase void pFlow::boundaryBase::setNewIndices
( (
const dictionary& dict, deviceViewType1D<uint32> newIndices
const plane& bplane,
internalPoints& internal
) )
:
subscriber(dict.name()),
boundaryPlane_(bplane),
indexList_(groupNames(dict.name(),"indexList")),
neighborLength_(dict.getVal<real>("neighborLength")),
internal_(internal),
mirrorProcessoNo_(dict.getVal<uint32>("mirrorProcessorNo")),
name_(dict.name()),
type_(dict.getVal<word>("type"))
{ {
auto newSize = newIndices.size();
setSize(static_cast<uint32>(newSize));
copy(indexList_.deviceView(), newIndices);
}
pFlow::boundaryBase::boundaryBase(
const dictionary &dict,
const plane &bplane,
internalPoints &internal)
: subscriber(dict.name()),
boundaryPlane_(bplane),
indexList_(groupNames(dict.name(), "indexList")),
neighborLength_(dict.getVal<real>("neighborLength")),
internal_(internal),
mirrorProcessoNo_(dict.getVal<uint32>("mirrorProcessorNo")),
name_(dict.name()),
type_(dict.getVal<word>("type"))
{
} }
void pFlow::boundaryBase::setSize(uint32 newSize) void pFlow::boundaryBase::setSize(uint32 newSize)
{ {
indexList_.resize(newSize); indexList_.resize(newSize);
/*if( indexList_.capacity() <= newSize+1 )
if( indexList_.capacity() <= newSize+1 )
{ {
indexList_.reserve(newSize+1); indexList_.reserve(newSize+1);
} }*/
//INFORMATION<<"new size of boundary "<< name_<<" "<< indexList_.size()<<END_INFO;
} }
typename pFlow::boundaryBase::pointFieldAccessType typename pFlow::boundaryBase::pointFieldAccessType
@ -77,8 +83,8 @@ pFlow::boundaryBase::thisPoints()
return pointFieldAccessType return pointFieldAccessType
( (
indexList_.size(), indexList_.size(),
indexList_.deviceVectorAll(), indexList_.deviceViewAll(),
internal_.pointPosition().deviceVectorAll() internal_.pointPosition().deviceViewAll()
); );
} }

View File

@ -65,6 +65,10 @@ private:
word type_; word type_;
protected:
void setNewIndices(deviceViewType1D<uint32> newIndices);
public: public:
TypeInfo("boundaryBase"); TypeInfo("boundaryBase");
@ -164,10 +168,10 @@ public:
return indexList_; return indexList_;
} }
auto& indexList() /*auto& indexList()
{ {
return indexList_; return indexList_;
} }*/
pointFieldAccessType thisPoints(); pointFieldAccessType thisPoints();

View File

@ -65,6 +65,7 @@ bool pFlow::boundaryExit::beforeIteration
auto points = thisPoints(); auto points = thisPoints();
uint32 numDeleted = 0; uint32 numDeleted = 0;
auto p = boundaryPlane().infPlane(); auto p = boundaryPlane().infPlane();
Kokkos::parallel_reduce Kokkos::parallel_reduce
( (
@ -85,6 +86,7 @@ bool pFlow::boundaryExit::beforeIteration
numDeleted numDeleted
); );
// no point is deleted // no point is deleted
if(numDeleted == 0 ) if(numDeleted == 0 )
{ {
@ -111,7 +113,7 @@ bool pFlow::boundaryExit::beforeIteration
deviceScatteredFieldAccess<uint32> deleteIndices( deviceScatteredFieldAccess<uint32> deleteIndices(
numDeleted, numDeleted,
deleteList, deleteList,
indexList().deviceVectorAll()); indexList().deviceViewAll());
// tell internal to remove these points from its list // tell internal to remove these points from its list
if(!internal().deletePoints(deleteIndices)) if(!internal().deletePoints(deleteIndices))
@ -124,13 +126,13 @@ bool pFlow::boundaryExit::beforeIteration
// delete these indices from your list // delete these indices from your list
if(numDeleted == s ) if(numDeleted == s )
{ {
indexList().resize(0u); setSize(0u);
} }
else else
{ {
uint newSize = s-numDeleted; uint32 newSize = s-numDeleted;
deviceViewType1D<uint32> newIndices("newIndices", newSize); deviceViewType1D<uint32> newIndices("newIndices", newSize);
auto oldIndices = indexList().deviceVectorAll(); auto oldIndices = indexList().deviceViewAll();
Kokkos::parallel_for( Kokkos::parallel_for(
"fillIndices", "fillIndices",
@ -144,13 +146,10 @@ bool pFlow::boundaryExit::beforeIteration
} }
); );
Kokkos::fence(); Kokkos::fence();
copy(oldIndices, newIndices); setNewIndices(newIndices);
indexList().resize(newSize);
} }
// notify your observers //TODO: notify observers about changes
WARNING<<"notify observers in boundary exit "<<END_WARNING;
return true; return true;
} }

View File

@ -53,12 +53,12 @@ bool pFlow::boundaryList::updateLists()
boundary(5).setSize( maskD.frontSize() ); boundary(5).setSize( maskD.frontSize() );
pStruct_.fillNeighborsLists( pStruct_.fillNeighborsLists(
boundary(0).indexList().deviceVectorAll(), boundary(0).indexList().deviceViewAll(),
boundary(1).indexList().deviceVectorAll(), boundary(1).indexList().deviceViewAll(),
boundary(2).indexList().deviceVectorAll(), boundary(2).indexList().deviceViewAll(),
boundary(3).indexList().deviceVectorAll(), boundary(3).indexList().deviceViewAll(),
boundary(4).indexList().deviceVectorAll(), boundary(4).indexList().deviceViewAll(),
boundary(5).indexList().deviceVectorAll()); boundary(5).indexList().deviceViewAll());
return true; return true;
} }
@ -124,8 +124,6 @@ bool pFlow::boundaryList::beforeIteration
fatalErrorInFunction; fatalErrorInFunction;
return false; return false;
} }
WARNING<<"Maybe notification about the update list "<<END_WARNING;
} }
for(auto& bdry:*this) for(auto& bdry:*this)

View File

@ -135,8 +135,9 @@ bool pFlow::internalPoints::deletePoints
"Error in deleting points from internal points"<<endl; "Error in deleting points from internal points"<<endl;
return false; return false;
} }
WARNING<<"Notify the observersin in internalPoints"<<END_WARNING;
pFlagSync_ = false; pFlagSync_ = false;
WARNING<<"Notify the observersin in internalPoints"<<END_WARNING;
return true; return true;
} }
@ -151,7 +152,7 @@ pFlow::uint32 pFlow::internalPoints::updateFlag
return pFlagsD_.markPointRegions return pFlagsD_.markPointRegions
( (
dm, dm,
pointPosition_.deviceVectorAll(), pointPosition_.deviceViewAll(),
dist[0], dist[0],
dist[1], dist[1],
dist[2], dist[2],
@ -213,15 +214,8 @@ bool pFlow::internalPoints::write
iOstream& os iOstream& os
)const )const
{ {
if( pFlagsD_.isAllActive()) auto aPoints = this->activePointsHost();
{ return aPoints.write(os);
return pointPosition_.write(os);
}
else
{
auto aPoints = this->activePointsHost();
return aPoints.write(os);
}
} }
FUNCTION_H FUNCTION_H
@ -259,15 +253,8 @@ bool pFlow::internalPoints::write
const IOPattern& iop const IOPattern& iop
)const )const
{ {
if( pFlagsD_.isAllActive()) auto aPoints = activePointsHost();
{ return aPoints.write(os,iop);
return pointPosition_.write(os, iop);
}
else
{
auto aPoints = activePointsHost();
return aPoints.write(os,iop);
}
} }
@ -288,7 +275,7 @@ bool pFlow::internalPoints::evaluateinternalPoints()
0, 0,
numPoints_, numPoints_,
static_cast<int8>(internalPoints::ACTIVE), static_cast<int8>(internalPoints::ACTIVE),
pointFlag_.deviceVectorAll(), pointFlag_.deviceViewAll(),
minActive, minActive,
maxActive maxActive
); );

View File

@ -121,13 +121,13 @@ public:
INLINE_FUNCTION_H INLINE_FUNCTION_H
auto pointPositionHost()const auto pointPositionHost()const
{ {
return pointPosition_.hostVector(); return pointPosition_.hostView();
} }
INLINE_FUNCTION_H INLINE_FUNCTION_H
auto pointPositionDevice()const auto pointPositionDevice()const
{ {
return pointPosition_.deviceVector(); return pointPosition_.deviceView();
} }
PointsTypeHost activePointsHost()const; PointsTypeHost activePointsHost()const;

View File

@ -33,14 +33,14 @@ class pointFlag
{ {
enum Flag: uint8 enum Flag: uint8
{ {
DELETED = 1, //10000000 DELETED = 1, //00000001
INTERNAL = 2, //00000001 INTERNAL = 2, //00000010
LEFT = 4, //00000010 LEFT = 4, //00000100
RIGHT = 8, //00000100 RIGHT = 8, //00001000
BOTTOM = 16, //00001000 BOTTOM = 16, //00010000
TOP = 32, //00010000 TOP = 32, //00100000
REAR = 64, //00100000 REAR = 64, //01000000
FRONT = 128 //01000000 FRONT = 128 //10000000
}; };
using execution_space = ExecutionSpace; using execution_space = ExecutionSpace;
@ -184,12 +184,7 @@ public:
return flags_[i] > DELETED; return flags_[i] > DELETED;
} }
INLINE_FUNCTION_HD
bool isBoundary(uint32 i)const
{
return flags_[i] > INTERNAL;
}
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
bool isBoundary(uint8 flg)const bool isBoundary(uint8 flg)const
{ {
@ -200,38 +195,38 @@ public:
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
bool isLeft(uint8 flg)const bool isLeft(uint8 flg)const
{ {
return (flg&LEFT) == LEFT; return flg&LEFT;
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
bool isRight(uint8 flg)const bool isRight(uint8 flg)const
{ {
return (flg&&RIGHT) == RIGHT; return flg&RIGHT;
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
bool isBottom(uint8 flg)const bool isBottom(uint8 flg)const
{ {
return (flg&&BOTTOM) == BOTTOM; return flg&BOTTOM;
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
bool isTop(uint8 flg)const bool isTop(uint8 flg)const
{ {
return (flg&&TOP) == TOP; return flg&TOP;
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
bool isRear(uint8 flg)const bool isRear(uint8 flg)const
{ {
return (flg&&REAR) == REAR; return flg&REAR;
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
bool isFront(uint8 flg)const bool isFront(uint8 flg)const
{ {
return (flg&&FRONT) == FRONT; return flg&FRONT;
} }
template<typename ExeSpace> template<typename ExeSpace>

View File

@ -20,6 +20,8 @@ Licence:
#ifndef __pointFlagKernels_hpp__ #ifndef __pointFlagKernels_hpp__
#define __pointFlagKernels_hpp__ #define __pointFlagKernels_hpp__
#include "streams.hpp"
template<typename ExecutionSpace> template<typename ExecutionSpace>
pFlow::uint32 pFlow::pointFlag<ExecutionSpace>::markOutOfBoxDelete pFlow::uint32 pFlow::pointFlag<ExecutionSpace>::markOutOfBoxDelete
( (
@ -353,9 +355,9 @@ void pFlow::pointFlag<ExecutionSpace>::fillNeighborsLists
uint32 end = activeRange().end(); uint32 end = activeRange().end();
ViewType1D<uint32, memory_space> nElems("nElems",6); ViewType1D<uint32, memory_space> nElems("nElems",6);
fill(nElems, 0, 6, static_cast<uint32>(0)); fill(nElems, 0, 6, static_cast<uint32>(0));
if(start<end) if(start<end)
{ {
Kokkos::parallel_for( Kokkos::parallel_for(
@ -363,16 +365,15 @@ void pFlow::pointFlag<ExecutionSpace>::fillNeighborsLists
rpMark(start,end), rpMark(start,end),
CLASS_LAMBDA_HD(uint32 i){ CLASS_LAMBDA_HD(uint32 i){
uint32 flg = flags_(i); uint8 flg = flags_(i);
if(this->isBoundary(flg)) if(this->isBoundary(flg))
{ {
if(this->isLeft(flg)) leftList[Kokkos::atomic_fetch_add(&nElems[0],1)] = i; if(this->isLeft(flg)) leftList[Kokkos::atomic_fetch_add(&nElems[0],1)] = i;
if(this->isRight(flg)) rightList[Kokkos::atomic_fetch_add(&nElems[1],1)] = i; if(this->isRight(flg))rightList[Kokkos::atomic_fetch_add(&nElems[1],1)] = i;
if(this->isBottom(flg)) bottomList[Kokkos::atomic_fetch_add(&nElems[2],1)] = i; if(this->isBottom(flg))bottomList[Kokkos::atomic_fetch_add(&nElems[2],1)] = i;
if(this->isTop(flg)) topList[Kokkos::atomic_fetch_add(&nElems[3],1)] = i; if(this->isTop(flg))topList[Kokkos::atomic_fetch_add(&nElems[3],1)] = i;
if(this->isRear(flg)) rearList[Kokkos::atomic_fetch_add(&nElems[4],1)] = i; if(this->isRear(flg))rearList[Kokkos::atomic_fetch_add(&nElems[4],1)] = i;
if(this->isFront(flg)) frontList[Kokkos::atomic_fetch_add(&nElems[5],1)] = i; if(this->isFront(flg))frontList[Kokkos::atomic_fetch_add(&nElems[5],1)] = i;
} }
}); });
Kokkos::fence(); Kokkos::fence();

View File

@ -166,6 +166,12 @@ pFlow::pointStructure::pointStructure(
bool pFlow::pointStructure::beforeIteration() bool pFlow::pointStructure::beforeIteration()
{ {
if( !boundaries_.beforeIteration(currentIter(), currentTime(), dt()) )
{
fatalErrorInFunction<<
"Unable to perform beforeIteration for boundaries"<<endl;
return false;
}
return true; return true;
} }
@ -206,5 +212,6 @@ bool pFlow::pointStructure::write
const IOPattern& iop const IOPattern& iop
)const )const
{ {
output<<"bool pFlow::pointStructure::write bool pFlow::pointStructure::write bool pFlow::pointStructure::write"<<endl;
return internalPoints::write(os, iop); return internalPoints::write(os, iop);
} }

View File

@ -31,7 +31,7 @@ void pFlow::selectBox::selectAllPointsInBox()
); );
selectedPoints_.clear(); selectedPoints_.clear();
auto pPos = pStruct().pointPosition().hostVector(); auto pPos = pStruct().pointPosition().hostView();
ForAll(i , pPos) ForAll(i , pPos)
{ {

View File

@ -115,11 +115,11 @@ bool pFlow::multiTriSurface::addTriSurface
vertices_.resize(vNewSize); vertices_.resize(vNewSize);
area_.resize(vNewSize); area_.resize(vNewSize);
auto verVec = vertices_.deviceVectorAll(); auto verVec = vertices_.deviceViewAll();
auto areaVec = area_.deviceVectorAll(); auto areaVec = area_.deviceViewAll();
auto newVerVec = newVertices.deviceVectorAll(); auto newVerVec = newVertices.deviceViewAll();
auto newArea = newAreas.deviceVectorAll(); auto newArea = newAreas.deviceViewAll();
auto maxIdx = maxIndex(); auto maxIdx = maxIndex();

View File

@ -85,7 +85,7 @@ pFlow::int32 pFlow::triSurface::calcMaxIndex()const
if(vertices_.size()>0) if(vertices_.size()>0)
{ {
auto verDeviceVec = vertices_.deviceVectorAll(); auto verDeviceVec = vertices_.deviceViewAll();
Kokkos::parallel_reduce( Kokkos::parallel_reduce(
"triSurface::calcMaxIndex", "triSurface::calcMaxIndex",

View File

@ -175,9 +175,9 @@ public:
{ {
return triangleAccessor( return triangleAccessor(
numPoints(), numPoints(),
points_.deviceVectorAll(), points_.deviceViewAll(),
numTriangles(), numTriangles(),
vertices_.deviceVectorAll() vertices_.deviceViewAll()
); );
} }
@ -203,12 +203,12 @@ public:
const realx3* pointsData_D()const const realx3* pointsData_D()const
{ {
return points_.deviceVectorAll().data(); return points_.deviceViewAll().data();
} }
realx3* pointsData_D() realx3* pointsData_D()
{ {
return points_.deviceVectorAll().data(); return points_.deviceViewAll().data();
} }
const int32x3Vector_D& vertices() const const int32x3Vector_D& vertices() const
@ -223,12 +223,12 @@ public:
int32x3* verticesData_D() int32x3* verticesData_D()
{ {
return vertices_.deviceVectorAll().data(); return vertices_.deviceViewAll().data();
} }
const int32x3* verticesData_D()const const int32x3* verticesData_D()const
{ {
return vertices_.deviceVectorAll().data(); return vertices_.deviceViewAll().data();
} }
void clear() void clear()

View File

@ -32,9 +32,9 @@ INLINE_FUNCTION_H
bool calculateArea(const realx3Field_D& points, const int32x3Field_D& vertices, realField_D& area) bool calculateArea(const realx3Field_D& points, const int32x3Field_D& vertices, realField_D& area)
{ {
auto numTri = vertices.size(); auto numTri = vertices.size();
auto areaD = area.deviceVectorAll(); auto areaD = area.deviceViewAll();
auto pointsD = points.deviceVectorAll(); auto pointsD = points.deviceViewAll();
auto verticesD = vertices.deviceVectorAll(); auto verticesD = vertices.deviceViewAll();
Kokkos::parallel_for( Kokkos::parallel_for(
"pFlow::triSurfaceKernels::calculateArea", "pFlow::triSurfaceKernels::calculateArea",

View File

@ -18,12 +18,11 @@ Licence:
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#ifndef __setProperty_hpp__ #ifndef __setProperty_hpp__
#define __setProperty_hpp__ #define __setProperty_hpp__
REPORT(0)<<"\nReading proprties . . . "<<END_REPORT; REPORT(0)<<"\nReading proprties . . . "<<END_REPORT;
auto proprties = pFlow::property(Control.caseSetup().path()+pFlow::propertyFile__); auto proprties = property(propertyFile__, &Control.caseSetup());
#endif #endif // __setProperty_hpp__

View File

@ -174,8 +174,8 @@ int main( int argc, char* argv[] )
REPORT(0)<< "Converting shapeName field to shapeIndex field"<<END_REPORT; REPORT(0)<< "Converting shapeName field to shapeIndex field"<<END_REPORT;
auto shapeName_D = shapeName.fieldDevice(); auto shapeName_D = shapeName.deviceView();
auto shapeIndex_D = shapeIndex.fieldDevice(); auto shapeIndex_D = shapeIndex.deviceView();
REPORT(1)<<"List of shape names in "<<shapes.globalName()<< REPORT(1)<<"List of shape names in "<<shapes.globalName()<<
" is: "<<Green_Text(shapes.shapeNameList())<<END_REPORT; " is: "<<Green_Text(shapes.shapeNameList())<<END_REPORT;

View File

@ -151,7 +151,8 @@ public:
virtual realx3Vector getFinalPosition(); virtual realx3Vector getFinalPosition();
static static
uniquePtr<positionParticles> create(systemControl& control, const dictionary & dict); uniquePtr<positionParticles>
create(systemControl& control, const dictionary & dict);
}; };

View File

@ -69,8 +69,8 @@ bool pFlow::positionRandom::positionOnePass(int32 pass, int32 startNum)
SearchType search( SearchType search(
box(minP, maxP), box(minP, maxP),
diameter_, diameter_,
positionHD.deviceVectorAll(), positionHD.deviceViewAll(),
diameter.deviceVectorAll()); diameter.deviceViewAll());
ContainerType pairs(3*startNum); ContainerType pairs(3*startNum);
@ -250,7 +250,7 @@ pFlow::int32 pFlow::findCollisions(
{ {
auto allPairs = pairs.getPairs(); auto allPairs = pairs.getPairs();
auto num = pairs.capacity(); auto num = pairs.capacity();
auto dFlags = flags.deviceVector(); auto dFlags = flags.deviceView();
int32 numCollisions = 0; int32 numCollisions = 0;