diff --git a/src/Integration/AdamsBashforth2/AdamsBashforth2.cpp b/src/Integration/AdamsBashforth2/AdamsBashforth2.cpp index 4c6a05cc..01fc695a 100644 --- a/src/Integration/AdamsBashforth2/AdamsBashforth2.cpp +++ b/src/Integration/AdamsBashforth2/AdamsBashforth2.cpp @@ -35,20 +35,20 @@ using rpIntegration = Kokkos::RangePolicy< bool intAllActive( real dt, - realx3PointField_D& y, + realx3Field_D& y, realx3PointField_D& dy, realx3PointField_D& dy1) { - auto d_dy = dy.fieldDevice(); - auto d_y = y.fieldDevice(); - auto d_dy1= dy1.fieldDevice(); + auto d_dy = dy.deviceView(); + auto d_y = y.deviceView(); + auto d_dy1= dy1.deviceView(); auto activeRng = dy1.activeRange(); Kokkos::parallel_for( "AdamsBashforth2::correct", rpIntegration (activeRng.start(), activeRng.end()), - LAMBDA_HD(int32 i){ + LAMBDA_HD(uint32 i){ d_y[i] += dt*(static_cast(1.5) * d_dy[i] - static_cast(0.5) * d_dy1[i]); d_dy1[i] = d_dy[i]; }); @@ -60,22 +60,22 @@ bool intAllActive( bool intScattered ( real dt, - realx3PointField_D& y, + realx3Field_D& y, realx3PointField_D& dy, realx3PointField_D& dy1 ) { - auto d_dy = dy.fieldDevice(); - auto d_y = y.fieldDevice(); - auto d_dy1 = dy1.fieldDevice(); + auto d_dy = dy.deviceView(); + auto d_y = y.deviceView(); + auto d_dy1 = dy1.deviceView(); auto activeRng = dy1.activeRange(); const auto& activeP = dy1.activePointsMaskDevice(); Kokkos::parallel_for( "AdamsBashforth2::correct", rpIntegration (activeRng.start(), activeRng.end()), - LAMBDA_HD(int32 i){ + LAMBDA_HD(uint32 i){ if( activeP(i)) { d_y[i] += dt*(static_cast(1.5) * d_dy[i] - static_cast(0.5) * d_dy1[i]); @@ -122,16 +122,30 @@ bool pFlow::AdamsBashforth2::predict realx3PointField_D& UNUSED(dy) ) { - return true; } +bool pFlow::AdamsBashforth2::predict +( + real dt, + realx3Field_D &y, + realx3PointField_D &dy +) +{ + return true; +} + bool pFlow::AdamsBashforth2::correct ( real dt, realx3PointField_D& y, realx3PointField_D& dy ) +{ + return correct(dt, y.field(), dy); +} + +bool pFlow::AdamsBashforth2::correct(real dt, realx3Field_D &y, realx3PointField_D &dy) { auto& dy1l = dy1(); @@ -143,8 +157,7 @@ bool pFlow::AdamsBashforth2::correct { return intScattered(dt, y, dy, dy1l); } - - return true; + return false; } bool pFlow::AdamsBashforth2::setInitialVals( diff --git a/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp b/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp index 54e1c421..863bd8a1 100644 --- a/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp +++ b/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp @@ -81,12 +81,23 @@ public: real UNUSED(dt), realx3PointField_D& UNUSED(y), realx3PointField_D& UNUSED(dy)) final; + + bool predict( + real dt, + realx3Field_D& y, + realx3PointField_D& dy) final; bool correct( real dt, realx3PointField_D& y, realx3PointField_D& dy) final; + bool correct( + real dt, + realx3Field_D& y, + realx3PointField_D& dy); + + bool setInitialVals( const int32IndexContainer& newIndices, const realx3Vector& y) final; diff --git a/src/Integration/AdamsBashforth3/AdamsBashforth3.cpp b/src/Integration/AdamsBashforth3/AdamsBashforth3.cpp index 040a9e40..f8ec6b5a 100644 --- a/src/Integration/AdamsBashforth3/AdamsBashforth3.cpp +++ b/src/Integration/AdamsBashforth3/AdamsBashforth3.cpp @@ -89,9 +89,9 @@ bool pFlow::AdamsBashforth3::intAll( realx3Vector_D& dy, range activeRng) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); - auto d_history = history_.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); + auto d_history = history_.deviceViewAll(); Kokkos::parallel_for( "AdamsBashforth3::correct", diff --git a/src/Integration/AdamsBashforth3/AdamsBashforth3.hpp b/src/Integration/AdamsBashforth3/AdamsBashforth3.hpp index 6bd47b11..279fdcda 100644 --- a/src/Integration/AdamsBashforth3/AdamsBashforth3.hpp +++ b/src/Integration/AdamsBashforth3/AdamsBashforth3.hpp @@ -160,9 +160,9 @@ bool pFlow::AdamsBashforth3::intRange( realx3Vector_D& dy, activeFunctor activeP ) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); - auto d_history = history_.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); + auto d_history = history_.deviceViewAll(); auto activeRng = activeP.activeRange(); Kokkos::parallel_for( diff --git a/src/Integration/AdamsBashforth4/AdamsBashforth4.cpp b/src/Integration/AdamsBashforth4/AdamsBashforth4.cpp index 547de93f..23bad29b 100644 --- a/src/Integration/AdamsBashforth4/AdamsBashforth4.cpp +++ b/src/Integration/AdamsBashforth4/AdamsBashforth4.cpp @@ -89,9 +89,9 @@ bool pFlow::AdamsBashforth4::intAll( realx3Vector_D& dy, range activeRng) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); - auto d_history = history_.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); + auto d_history = history_.deviceViewAll(); Kokkos::parallel_for( "AdamsBashforth4::correct", diff --git a/src/Integration/AdamsBashforth4/AdamsBashforth4.hpp b/src/Integration/AdamsBashforth4/AdamsBashforth4.hpp index 4f4a2914..cf1f50d8 100644 --- a/src/Integration/AdamsBashforth4/AdamsBashforth4.hpp +++ b/src/Integration/AdamsBashforth4/AdamsBashforth4.hpp @@ -165,9 +165,9 @@ bool pFlow::AdamsBashforth4::intRange( realx3Vector_D& dy, activeFunctor activeP ) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); - auto d_history = history_.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); + auto d_history = history_.deviceViewAll(); auto activeRng = activeP.activeRange(); Kokkos::parallel_for( diff --git a/src/Integration/AdamsBashforth5/AdamsBashforth5.cpp b/src/Integration/AdamsBashforth5/AdamsBashforth5.cpp index 580f0c06..7b87a4a3 100644 --- a/src/Integration/AdamsBashforth5/AdamsBashforth5.cpp +++ b/src/Integration/AdamsBashforth5/AdamsBashforth5.cpp @@ -89,9 +89,9 @@ bool pFlow::AdamsBashforth5::intAll( realx3Vector_D& dy, range activeRng) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); - auto d_history = history_.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); + auto d_history = history_.deviceViewAll(); Kokkos::parallel_for( "AdamsBashforth5::correct", diff --git a/src/Integration/AdamsBashforth5/AdamsBashforth5.hpp b/src/Integration/AdamsBashforth5/AdamsBashforth5.hpp index 99261588..16b55927 100644 --- a/src/Integration/AdamsBashforth5/AdamsBashforth5.hpp +++ b/src/Integration/AdamsBashforth5/AdamsBashforth5.hpp @@ -165,9 +165,9 @@ bool pFlow::AdamsBashforth5::intRange( realx3Vector_D& dy, activeFunctor activeP ) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); - auto d_history = history_.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); + auto d_history = history_.deviceViewAll(); auto activeRng = activeP.activeRange(); Kokkos::parallel_for( diff --git a/src/Integration/AdamsMoulton3/AdamsMoulton3.cpp b/src/Integration/AdamsMoulton3/AdamsMoulton3.cpp index cb819c7c..4fb030bf 100644 --- a/src/Integration/AdamsMoulton3/AdamsMoulton3.cpp +++ b/src/Integration/AdamsMoulton3/AdamsMoulton3.cpp @@ -124,11 +124,11 @@ bool pFlow::AdamsMoulton3::predictAll( range activeRng) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); - auto d_y0 = y0_.deviceVectorAll(); - auto d_dy0 = dy0_.deviceVectorAll(); - auto d_dy1= dy1_.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); + auto d_y0 = y0_.deviceViewAll(); + auto d_dy0 = dy0_.deviceViewAll(); + auto d_dy1= dy1_.deviceViewAll(); Kokkos::parallel_for( "AdamsMoulton3::predict", @@ -150,12 +150,12 @@ bool pFlow::AdamsMoulton3::intAll( range activeRng) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); - auto d_dy0 = dy0_.deviceVectorAll(); - auto d_y0 = y0_.deviceVectorAll(); - auto d_dy1 = dy1_.deviceVectorAll(); + auto d_dy0 = dy0_.deviceViewAll(); + auto d_y0 = y0_.deviceViewAll(); + auto d_dy1 = dy1_.deviceViewAll(); Kokkos::parallel_for( "AdamsMoulton3::correct", diff --git a/src/Integration/AdamsMoulton3/AdamsMoulton3.hpp b/src/Integration/AdamsMoulton3/AdamsMoulton3.hpp index 349d62b2..3193a819 100644 --- a/src/Integration/AdamsMoulton3/AdamsMoulton3.hpp +++ b/src/Integration/AdamsMoulton3/AdamsMoulton3.hpp @@ -144,11 +144,11 @@ bool AdamsMoulton3::predictRange( realx3Vector_D& dy, activeFunctor activeP) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); - auto d_y0 = y0_.deviceVectorAll(); - auto d_dy0 = dy0_.deviceVectorAll(); - auto d_dy1= dy1_.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); + auto d_y0 = y0_.deviceViewAll(); + auto d_dy0 = dy0_.deviceViewAll(); + auto d_dy1= dy1_.deviceViewAll(); auto activeRng = activeP.activeRange(); @@ -182,12 +182,12 @@ bool pFlow::AdamsMoulton3::intRange( activeFunctor activeP) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); - auto d_dy0 = dy0_.deviceVectorAll(); - auto d_y0 = y0_.deviceVectorAll(); - auto d_dy1 = dy1_.deviceVectorAll(); + auto d_dy0 = dy0_.deviceViewAll(); + auto d_y0 = y0_.deviceViewAll(); + auto d_dy1 = dy1_.deviceViewAll(); auto activeRng = activeP.activeRange(); diff --git a/src/Integration/AdamsMoulton4/AdamsMoulton4.cpp b/src/Integration/AdamsMoulton4/AdamsMoulton4.cpp index ec735ac8..3cdbbc8f 100644 --- a/src/Integration/AdamsMoulton4/AdamsMoulton4.cpp +++ b/src/Integration/AdamsMoulton4/AdamsMoulton4.cpp @@ -135,13 +135,13 @@ bool pFlow::AdamsMoulton4::predictAll( range activeRng) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); - auto d_y0 = y0_.deviceVectorAll(); - auto d_dy0 = dy0_.deviceVectorAll(); - auto d_dy1 = dy1_.deviceVectorAll(); - auto d_dy2 = dy2_.deviceVectorAll(); + auto d_y0 = y0_.deviceViewAll(); + auto d_dy0 = dy0_.deviceViewAll(); + auto d_dy1 = dy1_.deviceViewAll(); + auto d_dy2 = dy2_.deviceViewAll(); Kokkos::parallel_for( "AdamsMoulton4::predict", @@ -165,13 +165,13 @@ bool pFlow::AdamsMoulton4::intAll( range activeRng) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); - auto d_dy0 = dy0_.deviceVectorAll(); - auto d_y0 = y0_.deviceVectorAll(); - auto d_dy1 = dy1_.deviceVectorAll(); - auto d_dy2 = dy2_.deviceVectorAll(); + auto d_dy0 = dy0_.deviceViewAll(); + auto d_y0 = y0_.deviceViewAll(); + auto d_dy1 = dy1_.deviceViewAll(); + auto d_dy2 = dy2_.deviceViewAll(); Kokkos::parallel_for( "AdamsMoulton4::correct", diff --git a/src/Integration/AdamsMoulton4/AdamsMoulton4.hpp b/src/Integration/AdamsMoulton4/AdamsMoulton4.hpp index c0da0f62..3950798a 100644 --- a/src/Integration/AdamsMoulton4/AdamsMoulton4.hpp +++ b/src/Integration/AdamsMoulton4/AdamsMoulton4.hpp @@ -147,13 +147,13 @@ bool AdamsMoulton4::predictRange( realx3Vector_D& dy, activeFunctor activeP ) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); - auto d_y0 = y0_.deviceVectorAll(); - auto d_dy0 = dy0_.deviceVectorAll(); - auto d_dy1 = dy1_.deviceVectorAll(); - auto d_dy2 = dy2_.deviceVectorAll(); + auto d_y0 = y0_.deviceViewAll(); + auto d_dy0 = dy0_.deviceViewAll(); + auto d_dy1 = dy1_.deviceViewAll(); + auto d_dy2 = dy2_.deviceViewAll(); auto activeRng = activeP.activeRange(); @@ -185,13 +185,13 @@ bool pFlow::AdamsMoulton4::intRange( activeFunctor activeP ) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); - auto d_dy0 = dy0_.deviceVectorAll(); - auto d_y0 = y0_.deviceVectorAll(); - auto d_dy1 = dy1_.deviceVectorAll(); - auto d_dy2 = dy2_.deviceVectorAll(); + auto d_dy0 = dy0_.deviceViewAll(); + auto d_y0 = y0_.deviceViewAll(); + auto d_dy1 = dy1_.deviceViewAll(); + auto d_dy2 = dy2_.deviceViewAll(); auto activeRng = activeP.activeRange(); diff --git a/src/Integration/AdamsMoulton5/AdamsMoulton5.cpp b/src/Integration/AdamsMoulton5/AdamsMoulton5.cpp index c3f62f18..37629649 100644 --- a/src/Integration/AdamsMoulton5/AdamsMoulton5.cpp +++ b/src/Integration/AdamsMoulton5/AdamsMoulton5.cpp @@ -145,14 +145,14 @@ bool pFlow::AdamsMoulton5::predictAll( range activeRng) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); - auto d_y0 = y0_.deviceVectorAll(); - auto d_dy0 = dy0_.deviceVectorAll(); - auto d_dy1 = dy1_.deviceVectorAll(); - auto d_dy2 = dy2_.deviceVectorAll(); - auto d_dy3 = dy3_.deviceVectorAll(); + auto d_y0 = y0_.deviceViewAll(); + auto d_dy0 = dy0_.deviceViewAll(); + auto d_dy1 = dy1_.deviceViewAll(); + auto d_dy2 = dy2_.deviceViewAll(); + auto d_dy3 = dy3_.deviceViewAll(); Kokkos::parallel_for( "AdamsMoulton5::predict", @@ -178,14 +178,14 @@ bool pFlow::AdamsMoulton5::intAll( range activeRng) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); - auto d_dy0 = dy0_.deviceVectorAll(); - auto d_y0 = y0_.deviceVectorAll(); - auto d_dy1 = dy1_.deviceVectorAll(); - auto d_dy2 = dy2_.deviceVectorAll(); - auto d_dy3 = dy3_.deviceVectorAll(); + auto d_dy0 = dy0_.deviceViewAll(); + auto d_y0 = y0_.deviceViewAll(); + auto d_dy1 = dy1_.deviceViewAll(); + auto d_dy2 = dy2_.deviceViewAll(); + auto d_dy3 = dy3_.deviceViewAll(); Kokkos::parallel_for( "AdamsMoulton5::correct", diff --git a/src/Integration/AdamsMoulton5/AdamsMoulton5.hpp b/src/Integration/AdamsMoulton5/AdamsMoulton5.hpp index 2e381d4a..451ff81f 100644 --- a/src/Integration/AdamsMoulton5/AdamsMoulton5.hpp +++ b/src/Integration/AdamsMoulton5/AdamsMoulton5.hpp @@ -150,14 +150,14 @@ bool AdamsMoulton5::predictRange( realx3Vector_D& dy, activeFunctor activeP ) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); - auto d_y0 = y0_.deviceVectorAll(); - auto d_dy0 = dy0_.deviceVectorAll(); - auto d_dy1 = dy1_.deviceVectorAll(); - auto d_dy2 = dy2_.deviceVectorAll(); - auto d_dy3 = dy3_.deviceVectorAll(); + auto d_y0 = y0_.deviceViewAll(); + auto d_dy0 = dy0_.deviceViewAll(); + auto d_dy1 = dy1_.deviceViewAll(); + auto d_dy2 = dy2_.deviceViewAll(); + auto d_dy3 = dy3_.deviceViewAll(); auto activeRng = activeP.activeRange(); @@ -189,14 +189,14 @@ bool pFlow::AdamsMoulton5::intRange( activeFunctor activeP ) { - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); + auto d_dy = dy.deviceViewAll(); + auto d_y = y.deviceViewAll(); - auto d_dy0 = dy0_.deviceVectorAll(); - auto d_y0 = y0_.deviceVectorAll(); - auto d_dy1 = dy1_.deviceVectorAll(); - auto d_dy2 = dy2_.deviceVectorAll(); - auto d_dy3 = dy3_.deviceVectorAll(); + auto d_dy0 = dy0_.deviceViewAll(); + auto d_y0 = y0_.deviceViewAll(); + auto d_dy1 = dy1_.deviceViewAll(); + auto d_dy2 = dy2_.deviceViewAll(); + auto d_dy3 = dy3_.deviceViewAll(); auto activeRng = activeP.activeRange(); diff --git a/src/Integration/integration/integration.hpp b/src/Integration/integration/integration.hpp index 334e328e..4769c3ec 100644 --- a/src/Integration/integration/integration.hpp +++ b/src/Integration/integration/integration.hpp @@ -139,10 +139,16 @@ public: virtual 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 virtual 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 virtual bool setInitialVals( diff --git a/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp b/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp index 517c4e86..03373f87 100644 --- a/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp +++ b/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp @@ -219,11 +219,11 @@ bool pFlow::sphereParticles::initInertia() auto aPointsMask = dynPointStruct().activePointsMaskDevice(); auto aRange = aPointsMask.activeRange(); - auto field_shapeIndex = shapeIndex().fieldDevice(); - auto field_diameter = diameter_.fieldDevice(); - auto field_mass = mass_.fieldDevice(); - auto field_propId = propertyId_.fieldDevice(); - auto field_I = I_.fieldDevice(); + auto field_shapeIndex = shapeIndex().deviceView(); + auto field_diameter = diameter_.deviceView(); + auto field_mass = mass_.deviceView(); + auto field_propId = propertyId_.deviceView(); + auto field_I = I_.deviceView(); // get info from spheres shape realVector_D d("diameter", spheres_.boundingDiameter()); @@ -231,10 +231,10 @@ bool pFlow::sphereParticles::initInertia() uint32Vector_D propId("propId", spheres_.shapePropertyIds()); realVector_D I("I", spheres_.Inertia()); - auto d_d = d.deviceVector(); - auto d_mass = mass.deviceVector(); - auto d_propId = propId.deviceVector(); - auto d_I = I.deviceVector(); + auto d_d = d.deviceView(); + auto d_mass = mass.deviceView(); + auto d_propId = propId.deviceView(); + auto d_I = I.deviceView(); Kokkos::parallel_for( "particles::initInertia", @@ -385,7 +385,7 @@ pFlow::sphereParticles::sphereParticles( auto index = indexHD.indicesHost(); realx3Vector rvel(n,RESERVE()); - const auto hrVel = rVelocity_.hostVector(); + const auto hrVel = rVelocity_.hostView(); for(auto i=0; i("acceleration"); + return predict(dt(), acc); +}*/ - //if(!integrationPos_().predict(dt, pos.VectorField(), velocity_.VectorField() ))return false; - //if(!integrationVel_().predict(dt, velocity_.VectorField(), acceleration.VectorField()))return false; +/*bool pFlow::dynamicPointStructure::iterate() +{ + pointStructure::iterate(); + auto& acc = time().lookupObject("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; } @@ -100,9 +112,9 @@ bool pFlow::dynamicPointStructure::correct { //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; } @@ -121,7 +133,7 @@ pFlow::uniquePtr pFlow::dynamicPointStructure::inser if(!integrationPos_().needSetInitialVals()) return newIndicesPtr; - auto hVel = velocity_.hostVector(); + auto hVel = velocity_.hostView(); auto n = newIndicesPtr().size(); auto index = newIndicesPtr().indicesHost(); @@ -158,8 +170,8 @@ pFlow::uniquePtr pFlow::dynamicPointStructure::inser realx3Vector pos(n,RESERVE()); realx3Vector vel(n,RESERVE()); - const auto hVel = velocity().hostVector(); - const auto hPos = pStruct().pointPosition().hostVector(); + const auto hVel = velocity().hostView(); + const auto hPos = pStruct().pointPosition().hostView(); for(auto i=0; i hVecVals( const_cast(vals.data()), vals.size()); - //fillSelected(hostVector(), indices.hostView(), hVecVals, indices.size()); + //fillSelected(hostView(), indices.hostView(), hVecVals, indices.size()); pFlow::algorithms::KOKKOS::fillSelected( - hostVectorAll().data(), + hostViewAll().data(), indices.hostView().data(), hVecVals.data(), indices.size()); @@ -648,9 +648,9 @@ public: Kokkos::deep_copy(dVecVals, hVecVals); - //fillSelected(deviceVector(), indices.deviceView(), dVecVals, indices.size()); + //fillSelected(deviceView(), indices.deviceView(), dVecVals, indices.size()); pFlow::algorithms::KOKKOS::fillSelected( - deviceVectorAll().data(), + deviceViewAll().data(), indices.deviceView().data(), dVecVals.data(), indices.size()); @@ -683,7 +683,7 @@ public: if constexpr (std::is_same::value ) { hostViewType1D hVecInd( const_cast(indices.data()), indices.size()); - fillSelected( hostVectorAll(), hVecInd, indices.size(), val); + fillSelected( hostViewAll(), hVecInd, indices.size(), val); modifyOnHost(); syncViews(minInd, maxInd+1); @@ -696,7 +696,7 @@ public: hostViewType1D hVecInd( const_cast(indices.data()), indices.size()); deviceViewType1D dVecInd("dVecInd", indices.size()); Kokkos::deep_copy(dVecInd, hVecInd); - fillSelected(deviceVectorAll(), dVecInd, indices.size(), val); + fillSelected(deviceViewAll(), dVecInd, indices.size(), val); modifyOnDevice(); @@ -734,7 +734,7 @@ public: hostViewType1D hVecInd( const_cast(indices.data()), indices.size()); hostViewType1D hVecVals( const_cast(vals.data()), vals.size()); - fillSelected(hostVectorAll(), hVecInd, hVecVals, indices.size()); + fillSelected(hostViewAll(), hVecInd, hVecVals, indices.size()); modifyOnHost(); @@ -752,7 +752,7 @@ public: Kokkos::deep_copy(dVecVals, hVecVals); Kokkos::deep_copy(dVecInd, hVecInd); - fillSelected(deviceVectorAll(), dVecInd, dVecVals, indices.size()); + fillSelected(deviceViewAll(), dVecInd, dVecVals, indices.size()); modifyOnDevice(); @@ -858,7 +858,7 @@ public: { if(empty())return; - Kokkos::deep_copy(deviceVector(), hostVector()); + Kokkos::deep_copy(deviceView(), hostView()); dualView_.clear_sync_state(); } @@ -866,7 +866,7 @@ public: void copyHostToDevice(int32 start, int32 end, bool setUpdated = true) { if(empty())return; - Kokkos::deep_copy(deviceVector(start, end), hostVector(start, end)); + Kokkos::deep_copy(deviceView(start, end), hostView(start, end)); if(setUpdated) dualView_.clear_sync_state(); } @@ -876,7 +876,7 @@ public: INLINE_FUNCTION_H void copyDeviceToHost() { if(empty())return; - Kokkos::deep_copy(hostVector(), deviceVector()); + Kokkos::deep_copy(hostView(), deviceView()); dualView_.clear_sync_state(); } @@ -884,7 +884,7 @@ public: void copyDeviceToHost(int32 start, int32 end, bool setUpdated = true) { if(empty())return; - Kokkos::deep_copy(hostVector(start, end), deviceVector(start, end)); + Kokkos::deep_copy(hostView(start, end), deviceView(start, end)); if(setUpdated) dualView_.clear_sync_state(); } @@ -962,12 +962,12 @@ public: if(hostRequiresSync()) // device is updated { //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 { //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); } diff --git a/src/phasicFlow/containers/VectorHD/VectorDualAlgorithms.hpp b/src/phasicFlow/containers/VectorHD/VectorDualAlgorithms.hpp index a1191675..603ae29a 100644 --- a/src/phasicFlow/containers/VectorHD/VectorDualAlgorithms.hpp +++ b/src/phasicFlow/containers/VectorHD/VectorDualAlgorithms.hpp @@ -39,11 +39,11 @@ int64 count(const VectorDual& vec, const T& val) { if constexpr (std::is_same::value) { - return count( vec.hostVectorAll(), static_cast(0), vec.size(), val); + return count( vec.hostViewAll(), static_cast(0), vec.size(), val); } else { - return count( vec.deviceVectorAll(), static_cast(0), vec.size(), val); + return count( vec.deviceViewAll(), static_cast(0), vec.size(), val); } return -1; @@ -63,11 +63,11 @@ int64 min(const VectorDual& vec) { if constexpr (std::is_same::value) { - return min( vec.hostVectorAll(), static_cast(0), vec.size()); + return min( vec.hostViewAll(), static_cast(0), vec.size()); } else { - return min( vec.deviceVectorAll(), static_cast(0), vec.size()); + return min( vec.deviceViewAll(), static_cast(0), vec.size()); } return 0.0; @@ -87,11 +87,11 @@ int64 max(const VectorDual& vec) { if constexpr (std::is_same::value) { - return max( vec.hostVectorAll(), static_cast(0), vec.size()); + return max( vec.hostViewAll(), static_cast(0), vec.size()); } else { - return max( vec.deviceVectorAll(), static_cast(0), vec.size()); + return max( vec.deviceViewAll(), static_cast(0), vec.size()); } return 0.0; diff --git a/src/phasicFlow/containers/VectorHD/VectorSingle.cpp b/src/phasicFlow/containers/VectorHD/VectorSingle.cpp index b469f2b8..0fe5d251 100644 --- a/src/phasicFlow/containers/VectorHD/VectorSingle.cpp +++ b/src/phasicFlow/containers/VectorHD/VectorSingle.cpp @@ -182,7 +182,7 @@ pFlow::VectorSingle::VectorSingle : VectorSingle(name, src.capacity(), src.size(), RESERVE()) { - copy(deviceVector(), src.deviceVector()); + copy(deviceView(), src.deviceView()); } template @@ -213,13 +213,6 @@ pFlow::uniquePtr> return makeUnique( this->name(), *this); } -template -INLINE_FUNCTION_H -pFlow::VectorSingle* - pFlow::VectorSingle::clonePtr()const -{ - return new VectorSingle(this->name(), *this); -} template INLINE_FUNCTION_H @@ -239,21 +232,23 @@ pFlow::VectorSingle::VectorField()const template INLINE_FUNCTION_H -auto pFlow::VectorSingle::deviceVectorAll() const +auto pFlow::VectorSingle::deviceViewAll() const { return view_; } template INLINE_FUNCTION_H -auto pFlow::VectorSingle::deviceVector()const +auto pFlow::VectorSingle::deviceView()const { - return Kokkos::subview(view_, Kokkos::make_pair(0,int(size_))); + return Kokkos::subview( + view_, + Kokkos::make_pair(0u,static_cast(size_))); } template INLINE_FUNCTION_H -auto pFlow::VectorSingle::hostVectorAll()const +auto pFlow::VectorSingle::hostViewAll()const { auto hView = Kokkos::create_mirror_view(view_); copy(hView, view_); @@ -262,10 +257,10 @@ auto pFlow::VectorSingle::hostVectorAll()const template INLINE_FUNCTION_H -auto pFlow::VectorSingle::hostVector()const +auto pFlow::VectorSingle::hostView()const { - auto hView = Kokkos::create_mirror_view(deviceVector()); - copy(hView, deviceVector()); + auto hView = Kokkos::create_mirror_view(deviceView()); + copy(hView, deviceView()); return hView; } @@ -402,7 +397,7 @@ void pFlow::VectorSingle::assign // - unmanaged view in the host hostViewType1D temp(src.data(), srcSize ); - copy(deviceVector(), temp); + copy(deviceView(), temp); } template @@ -429,7 +424,7 @@ void pFlow::VectorSingle::assign(const VectorTypeHost& src) { setSize(srcSize); } - copy(deviceVector(), src.hostVector()); + copy(deviceView(), src.hostView()); } template @@ -528,7 +523,7 @@ bool pFlow::VectorSingle::insertSetElement Kokkos::parallel_for( "VectorSingle::insertSetElement", - policy(0,indices.size()), LAMBDA_HD(int32 i){ + policy(0,indices.size()), LAMBDA_HD(uint32 i){ dVec(ind(i))= dVals(i);}); Kokkos::fence(); @@ -540,7 +535,7 @@ bool pFlow::VectorSingle::insertSetElement Kokkos::parallel_for( "VectorSingle::insertSetElement", - policy(0,indices.size()), LAMBDA_HD(int32 i){ + policy(0,indices.size()), LAMBDA_HD(uint32 i){ dVec(ind(i))= hVals(i);}); Kokkos::fence(); @@ -579,7 +574,7 @@ bool pFlow::VectorSingle::insertSetElement Kokkos::parallel_for( "VectorSingle::insertSetElement", - policy(0,indices.size()), LAMBDA_HD(int32 i){ + policy(0,indices.size()), LAMBDA_HD(uint32 i){ dVec(ind(i))= dVals(i);}); Kokkos::fence(); @@ -592,7 +587,7 @@ bool pFlow::VectorSingle::insertSetElement Kokkos::parallel_for( "VectorSingle::insertSetElement", - policy(0,indices.size()), LAMBDA_HD(int32 i){ + policy(0,indices.size()), LAMBDA_HD(uint32 i){ dVec(ind(i))= hVals(i);}); Kokkos::fence(); @@ -665,7 +660,7 @@ bool pFlow::VectorSingle::reorderItems(uint32IndexContainer indic Kokkos::fence(); } - copy(deviceVector(), sortedView); + copy(deviceView(), sortedView); return true; } \ No newline at end of file diff --git a/src/phasicFlow/containers/VectorHD/VectorSingle.hpp b/src/phasicFlow/containers/VectorHD/VectorSingle.hpp index 64793c5e..f0185cb9 100644 --- a/src/phasicFlow/containers/VectorHD/VectorSingle.hpp +++ b/src/phasicFlow/containers/VectorHD/VectorSingle.hpp @@ -178,10 +178,7 @@ public: INLINE_FUNCTION_H uniquePtr clone() const; - /// Clone as a pointer (perform deep copy) - INLINE_FUNCTION_H - VectorSingle* clonePtr()const; - + //// - Methods /// Return *this @@ -192,22 +189,22 @@ public: INLINE_FUNCTION_H const VectorType& VectorField()const; - /// Device vector range [0,capcity) + /// Device view range [0,capcity) INLINE_FUNCTION_H - auto deviceVectorAll() const; + auto deviceViewAll() const; - /// Device vector range [0, size) + /// Device view range [0, size) 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 - 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 - auto hostVector()const; + auto hostView()const; /// Name of the vector INLINE_FUNCTION_H @@ -403,7 +400,7 @@ public: FUNCTION_H bool write(iOstream& os, const IOPattern& iop)const { - auto hVec = hostVector(); + auto hVec = hostView(); auto sp = span( const_cast(hVec.data()), hVec.size()); return writeSpan(os, sp, iop); @@ -413,7 +410,7 @@ public: FUNCTION_H bool write(iOstream& os)const { - auto hVec = hostVector(); + auto hVec = hostView(); auto sp = span( const_cast(hVec.data()), hVec.size()); return writeSpan(os, sp); @@ -424,7 +421,7 @@ public: FUNCTION_H bool write(iOstream& os, const IOPattern& iop, const HostMask& mask)const { - auto hVec = hostVector(); + auto hVec = hostView(); auto numActive = mask.numActive(); std::vector finalField; @@ -518,5 +515,5 @@ inline iOstream& operator << (iOstream& os, const VectorSingle& INLINE_FUNCTION_H bool append(const VectorSingle& Vec) { - return append(Vec.deviceVector(), Vec.size()); + return append(Vec.deviceView(), Vec.size()); }*/ \ No newline at end of file diff --git a/src/phasicFlow/containers/VectorHD/VectorSingleAlgorithms.hpp b/src/phasicFlow/containers/VectorHD/VectorSingleAlgorithms.hpp index 893e6c1e..831390d4 100644 --- a/src/phasicFlow/containers/VectorHD/VectorSingleAlgorithms.hpp +++ b/src/phasicFlow/containers/VectorHD/VectorSingleAlgorithms.hpp @@ -28,14 +28,14 @@ template INLINE_FUNCTION_H size_t count(const VectorSingle& vec, const T& val) { - return count( vec.deviceVectorAll(), 0, vec.size(), val); + return count( vec.deviceViewAll(), 0, vec.size(), val); } template INLINE_FUNCTION_H T min( const VectorSingle& vec) { return min( - vec.deviceVectorAll(), + vec.deviceViewAll(), 0, vec.size() ); } @@ -44,7 +44,7 @@ template INLINE_FUNCTION_H T max( const VectorSingle& vec) { return min( - vec.deviceVectorAll(), + vec.deviceViewAll(), 0, vec.size() ); } diff --git a/src/phasicFlow/containers/pointField/internalField.cpp b/src/phasicFlow/containers/pointField/internalField.cpp index 3f0ed1cc..d75c6d5f 100644 --- a/src/phasicFlow/containers/pointField/internalField.cpp +++ b/src/phasicFlow/containers/pointField/internalField.cpp @@ -73,7 +73,7 @@ typename pFlow::internalField::FieldTypeHost pFlow::internalField::activeValuesHost() const { auto maskH = internalPoints_.activePointsMaskHost(); - auto fieldH = field_.hostVector(); + auto fieldH = field_.hostView(); FieldTypeHost aField ( @@ -105,13 +105,6 @@ bool pFlow::internalField::write const IOPattern& iop )const { - if( internalPoints_.isAllActive() ) - { - return field_.write(os, iop); - } - else - { - auto aField = activeValuesHost(); - return aField.write(os, iop); - } + auto aField = activeValuesHost(); + return aField.write(os, iop); } \ No newline at end of file diff --git a/src/phasicFlow/containers/pointField/internalField.hpp b/src/phasicFlow/containers/pointField/internalField.hpp index 21213743..d92fff0f 100644 --- a/src/phasicFlow/containers/pointField/internalField.hpp +++ b/src/phasicFlow/containers/pointField/internalField.hpp @@ -75,22 +75,30 @@ public: const internalPoints& internal, const T& val); - - auto fieldDevice()const + inline + 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 { return field_; } + inline + FieldType& field() + { + return field_; + } + const pFlagTypeDevice& activePointsMaskDevice()const { return internalPoints_.activePointsMaskDevice(); diff --git a/src/phasicFlow/containers/pointField/internalFieldAlgorithms.hpp b/src/phasicFlow/containers/pointField/internalFieldAlgorithms.hpp index 2f1f85df..8f94bfb6 100644 --- a/src/phasicFlow/containers/pointField/internalFieldAlgorithms.hpp +++ b/src/phasicFlow/containers/pointField/internalFieldAlgorithms.hpp @@ -39,7 +39,7 @@ T min(const internalField& iField) // this is a device view auto maskD = iField.activePointsMaskDevice(); auto aRange = maskD.activeRange(); - auto filed = iField.field().deviceVectorAll(); + auto filed = iField.field().deviceViewAll(); T minElement; @@ -59,7 +59,7 @@ T min(const internalField& iField) // this is a host view auto maskH = iField.activePointsMaskHost(); auto aRange = maskH.activeRange(); - auto filed = iField.field().deviceVectorAll(); + auto filed = iField.field().deviceViewAll(); T minElement; Kokkos::parallel_reduce( "min(internalField)", @@ -90,7 +90,7 @@ T max(const internalField& iField) // this is a device view auto maskD = iField.activePointsMaskDevice(); auto aRange = maskD.activeRange(); - auto filed = iField.field().deviceVectorAll(); + auto filed = iField.field().deviceViewAll(); T maxElement; @@ -110,7 +110,7 @@ T max(const internalField& iField) // this is a host view auto maskH = iField.activePointsMaskHost(); auto aRange = maskH.activeRange(); - auto filed = iField.field().deviceVectorAll(); + auto filed = iField.field().deviceViewAll(); T maxElement; @@ -143,7 +143,7 @@ Pair minMax(const internalField& iField) // this is a device view auto maskD = iField.activePointsMaskDevice(); auto aRange = maskD.activeRange(); - auto filed = iField.field().deviceVectorAll(); + auto filed = iField.field().deviceViewAll(); T minElement; T maxElement; @@ -170,7 +170,7 @@ Pair minMax(const internalField& iField) // this is a host view auto maskH = iField.activePointsMaskHost(); auto aRange = maskH.activeRange(); - auto filed = iField.field().deviceVectorAll(); + auto filed = iField.field().deviceViewAll(); T minElement; T maxElement; diff --git a/src/phasicFlow/containers/pointField/pointFieldAlgorithms.hpp b/src/phasicFlow/containers/pointField/pointFieldAlgorithms.hpp index 022e35f1..ce3765d2 100644 --- a/src/phasicFlow/containers/pointField/pointFieldAlgorithms.hpp +++ b/src/phasicFlow/containers/pointField/pointFieldAlgorithms.hpp @@ -109,15 +109,15 @@ T maxActive(const pointField& pField) { if(len < sizeToSerial__ ) // serial execution instead of lunching parallel execution return maxActive_serial( - pField.deviceVectorAll(), - pField.pointFlag().hostVectorAll(), + pField.deviceViewAll(), + pField.pointFlag().hostViewAll(), static_cast(0), len ); else return maxActiveH( - pField.deviceVectorAll(), - pField.pointFlag().hostVectorAll(), + pField.deviceViewAll(), + pField.pointFlag().hostViewAll(), static_cast(0), len ); @@ -125,8 +125,8 @@ T maxActive(const pointField& pField) else { return maxActiveD( - pField.deviceVectorAll(), - pField.pointFlag().deviceVectorAll(), + pField.deviceViewAll(), + pField.pointFlag().deviceViewAll(), static_cast(0), len ); @@ -148,23 +148,23 @@ T maxActive(const pointField& pField) { if( len < sizeToSerial__) return maxActive_serial( - pField.hostVectorAll(), - pField.pointFlag().hostVectorAll(), + pField.hostViewAll(), + pField.pointFlag().hostViewAll(), static_cast(0), len ); else return maxActiveH( - pField.hostVectorAll(), - pField.pointFlag().hostVectorAll(), + pField.hostViewAll(), + pField.pointFlag().hostViewAll(), static_cast(0), len ); }else { return maxActiveD( - pField.deviceVectorAll(), - pField.pointFlag().deviceVectorAll(), + pField.deviceViewAll(), + pField.pointFlag().deviceViewAll(), static_cast(0), len ); diff --git a/src/phasicFlow/ranges/stridedRange.hpp b/src/phasicFlow/ranges/stridedRange.hpp index 0f7eb10f..02df31d2 100644 --- a/src/phasicFlow/ranges/stridedRange.hpp +++ b/src/phasicFlow/ranges/stridedRange.hpp @@ -25,6 +25,7 @@ Licence: #include "typeInfo.hpp" #include "dictionary.hpp" +#include "streams.hpp" namespace pFlow { @@ -108,8 +109,9 @@ public: inline bool isMember(T val, T epsilon = 0)const { + 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,end_))return true; return false; @@ -147,6 +149,22 @@ public: } }; +template<> +inline +bool stridedRange::isMember(real val, real epsilon)const + { + + if(!isInRange(val)) return false; + real dist = val-begin_; + if(abs( + (dist-(static_cast((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__ diff --git a/src/phasicFlow/repository/Time/baseTimeControl.cpp b/src/phasicFlow/repository/Time/baseTimeControl.cpp index 54d8ea45..413736c0 100644 --- a/src/phasicFlow/repository/Time/baseTimeControl.cpp +++ b/src/phasicFlow/repository/Time/baseTimeControl.cpp @@ -21,7 +21,6 @@ Licence: #include "baseTimeControl.hpp" - pFlow::baseTimeControl::baseTimeControl ( const dictionary &dict, @@ -46,7 +45,7 @@ pFlow::baseTimeControl::baseTimeControl word intervalWord = intervalPrefix.size()==0? word("interval"): intervalPrefix+"Interval"; - if(isTimeStep_) + if(!isTimeStep_) { auto startTime = (dict.getValOrSet("startTime", defStartTime)); auto endTime = (dict.getValOrSet("endTime", largeValue)); @@ -72,7 +71,7 @@ bool pFlow::baseTimeControl::timeEvent(uint32 iter, real t, real dt) const } else { - return rRange_.isMember(t, 0.51*dt); + return rRange_.isMember(t, 0.55*dt); } return false; } diff --git a/src/phasicFlow/repository/Time/timeControl.cpp b/src/phasicFlow/repository/Time/timeControl.cpp index d9182701..701130e8 100644 --- a/src/phasicFlow/repository/Time/timeControl.cpp +++ b/src/phasicFlow/repository/Time/timeControl.cpp @@ -174,7 +174,7 @@ void pFlow::timeControl::checkForOutputToFile() bool pFlow::timeControl::timersReportTime()const { if(currentIter_<=1)return false; - return timersReportInterval_.isMember(currentTime_, dt_); + return timersReportInterval_.isMember(currentTime_, 0.55*dt_); } bool pFlow::timeControl::sortTime()const diff --git a/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.cpp b/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.cpp index d79b8ee0..cc11e502 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.cpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.cpp @@ -41,33 +41,39 @@ Licence: }*/ -pFlow::boundaryBase::boundaryBase +void pFlow::boundaryBase::setNewIndices ( - const dictionary& dict, - const plane& bplane, - internalPoints& internal + deviceViewType1D newIndices ) -: - subscriber(dict.name()), - boundaryPlane_(bplane), - indexList_(groupNames(dict.name(),"indexList")), - neighborLength_(dict.getVal("neighborLength")), - internal_(internal), - mirrorProcessoNo_(dict.getVal("mirrorProcessorNo")), - name_(dict.name()), - type_(dict.getVal("type")) { + auto newSize = newIndices.size(); + setSize(static_cast(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("neighborLength")), + internal_(internal), + mirrorProcessoNo_(dict.getVal("mirrorProcessorNo")), + name_(dict.name()), + type_(dict.getVal("type")) +{ } void pFlow::boundaryBase::setSize(uint32 newSize) { indexList_.resize(newSize); - - if( indexList_.capacity() <= newSize+1 ) + /*if( indexList_.capacity() <= newSize+1 ) { indexList_.reserve(newSize+1); - } + }*/ + //INFORMATION<<"new size of boundary "<< name_<<" "<< indexList_.size()< newIndices); + public: TypeInfo("boundaryBase"); @@ -164,10 +168,10 @@ public: return indexList_; } - auto& indexList() + /*auto& indexList() { return indexList_; - } + }*/ pointFieldAccessType thisPoints(); diff --git a/src/phasicFlow/structuredData/boundaries/boundaryExit/boundaryExit.cpp b/src/phasicFlow/structuredData/boundaries/boundaryExit/boundaryExit.cpp index e8f005e8..9c0706d4 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryExit/boundaryExit.cpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryExit/boundaryExit.cpp @@ -65,6 +65,7 @@ bool pFlow::boundaryExit::beforeIteration auto points = thisPoints(); uint32 numDeleted = 0; auto p = boundaryPlane().infPlane(); + Kokkos::parallel_reduce ( @@ -85,6 +86,7 @@ bool pFlow::boundaryExit::beforeIteration numDeleted ); + // no point is deleted if(numDeleted == 0 ) { @@ -111,7 +113,7 @@ bool pFlow::boundaryExit::beforeIteration deviceScatteredFieldAccess deleteIndices( numDeleted, deleteList, - indexList().deviceVectorAll()); + indexList().deviceViewAll()); // tell internal to remove these points from its list if(!internal().deletePoints(deleteIndices)) @@ -124,13 +126,13 @@ bool pFlow::boundaryExit::beforeIteration // delete these indices from your list if(numDeleted == s ) { - indexList().resize(0u); + setSize(0u); } else { - uint newSize = s-numDeleted; + uint32 newSize = s-numDeleted; deviceViewType1D newIndices("newIndices", newSize); - auto oldIndices = indexList().deviceVectorAll(); + auto oldIndices = indexList().deviceViewAll(); Kokkos::parallel_for( "fillIndices", @@ -144,13 +146,10 @@ bool pFlow::boundaryExit::beforeIteration } ); Kokkos::fence(); - copy(oldIndices, newIndices); - indexList().resize(newSize); + setNewIndices(newIndices); } - // notify your observers - - WARNING<<"notify observers in boundary exit "<activePointsHost(); - return aPoints.write(os); - } + auto aPoints = this->activePointsHost(); + return aPoints.write(os); } FUNCTION_H @@ -259,15 +253,8 @@ bool pFlow::internalPoints::write const IOPattern& iop )const { - if( pFlagsD_.isAllActive()) - { - return pointPosition_.write(os, iop); - } - else - { - auto aPoints = activePointsHost(); - return aPoints.write(os,iop); - } + auto aPoints = activePointsHost(); + return aPoints.write(os,iop); } @@ -288,7 +275,7 @@ bool pFlow::internalPoints::evaluateinternalPoints() 0, numPoints_, static_cast(internalPoints::ACTIVE), - pointFlag_.deviceVectorAll(), + pointFlag_.deviceViewAll(), minActive, maxActive ); diff --git a/src/phasicFlow/structuredData/pointStructure/internalPoints.hpp b/src/phasicFlow/structuredData/pointStructure/internalPoints.hpp index 17413878..5a0d81a0 100644 --- a/src/phasicFlow/structuredData/pointStructure/internalPoints.hpp +++ b/src/phasicFlow/structuredData/pointStructure/internalPoints.hpp @@ -121,13 +121,13 @@ public: INLINE_FUNCTION_H auto pointPositionHost()const { - return pointPosition_.hostVector(); + return pointPosition_.hostView(); } INLINE_FUNCTION_H auto pointPositionDevice()const { - return pointPosition_.deviceVector(); + return pointPosition_.deviceView(); } PointsTypeHost activePointsHost()const; diff --git a/src/phasicFlow/structuredData/pointStructure/pointFlag.hpp b/src/phasicFlow/structuredData/pointStructure/pointFlag.hpp index 911ea654..f39b702d 100644 --- a/src/phasicFlow/structuredData/pointStructure/pointFlag.hpp +++ b/src/phasicFlow/structuredData/pointStructure/pointFlag.hpp @@ -33,14 +33,14 @@ class pointFlag { enum Flag: uint8 { - DELETED = 1, //10000000 - INTERNAL = 2, //00000001 - LEFT = 4, //00000010 - RIGHT = 8, //00000100 - BOTTOM = 16, //00001000 - TOP = 32, //00010000 - REAR = 64, //00100000 - FRONT = 128 //01000000 + DELETED = 1, //00000001 + INTERNAL = 2, //00000010 + LEFT = 4, //00000100 + RIGHT = 8, //00001000 + BOTTOM = 16, //00010000 + TOP = 32, //00100000 + REAR = 64, //01000000 + FRONT = 128 //10000000 }; using execution_space = ExecutionSpace; @@ -184,12 +184,7 @@ public: return flags_[i] > DELETED; } - INLINE_FUNCTION_HD - bool isBoundary(uint32 i)const - { - return flags_[i] > INTERNAL; - } - + INLINE_FUNCTION_HD bool isBoundary(uint8 flg)const { @@ -200,38 +195,38 @@ public: INLINE_FUNCTION_HD bool isLeft(uint8 flg)const { - return (flg&LEFT) == LEFT; + return flg&LEFT; } INLINE_FUNCTION_HD bool isRight(uint8 flg)const { - return (flg&&RIGHT) == RIGHT; + return flg&RIGHT; } INLINE_FUNCTION_HD bool isBottom(uint8 flg)const { - return (flg&&BOTTOM) == BOTTOM; + return flg&BOTTOM; } INLINE_FUNCTION_HD bool isTop(uint8 flg)const { - return (flg&&TOP) == TOP; + return flg&TOP; } INLINE_FUNCTION_HD bool isRear(uint8 flg)const { - return (flg&&REAR) == REAR; + return flg&REAR; } INLINE_FUNCTION_HD bool isFront(uint8 flg)const { - return (flg&&FRONT) == FRONT; + return flg&FRONT; } template diff --git a/src/phasicFlow/structuredData/pointStructure/pointFlagKernels.hpp b/src/phasicFlow/structuredData/pointStructure/pointFlagKernels.hpp index 46a26828..88e3d145 100644 --- a/src/phasicFlow/structuredData/pointStructure/pointFlagKernels.hpp +++ b/src/phasicFlow/structuredData/pointStructure/pointFlagKernels.hpp @@ -20,6 +20,8 @@ Licence: #ifndef __pointFlagKernels_hpp__ #define __pointFlagKernels_hpp__ +#include "streams.hpp" + template pFlow::uint32 pFlow::pointFlag::markOutOfBoxDelete ( @@ -353,9 +355,9 @@ void pFlow::pointFlag::fillNeighborsLists uint32 end = activeRange().end(); ViewType1D nElems("nElems",6); - + fill(nElems, 0, 6, static_cast(0)); - + if(start::fillNeighborsLists rpMark(start,end), CLASS_LAMBDA_HD(uint32 i){ - uint32 flg = flags_(i); - + uint8 flg = flags_(i); if(this->isBoundary(flg)) { 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->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->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->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->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->isFront(flg))frontList[Kokkos::atomic_fetch_add(&nElems[5],1)] = i; } }); Kokkos::fence(); diff --git a/src/phasicFlow/structuredData/pointStructure/pointStructure.cpp b/src/phasicFlow/structuredData/pointStructure/pointStructure.cpp index dcba001d..f73481ef 100644 --- a/src/phasicFlow/structuredData/pointStructure/pointStructure.cpp +++ b/src/phasicFlow/structuredData/pointStructure/pointStructure.cpp @@ -166,6 +166,12 @@ pFlow::pointStructure::pointStructure( bool pFlow::pointStructure::beforeIteration() { + if( !boundaries_.beforeIteration(currentIter(), currentTime(), dt()) ) + { + fatalErrorInFunction<< + "Unable to perform beforeIteration for boundaries"<0) { - auto verDeviceVec = vertices_.deviceVectorAll(); + auto verDeviceVec = vertices_.deviceViewAll(); Kokkos::parallel_reduce( "triSurface::calcMaxIndex", diff --git a/src/phasicFlow/structuredData/trisurfaceStructure/triSurface.hpp b/src/phasicFlow/structuredData/trisurfaceStructure/triSurface.hpp index 0583b353..1ab89bbf 100644 --- a/src/phasicFlow/structuredData/trisurfaceStructure/triSurface.hpp +++ b/src/phasicFlow/structuredData/trisurfaceStructure/triSurface.hpp @@ -175,9 +175,9 @@ public: { return triangleAccessor( numPoints(), - points_.deviceVectorAll(), + points_.deviceViewAll(), numTriangles(), - vertices_.deviceVectorAll() + vertices_.deviceViewAll() ); } @@ -203,12 +203,12 @@ public: const realx3* pointsData_D()const { - return points_.deviceVectorAll().data(); + return points_.deviceViewAll().data(); } realx3* pointsData_D() { - return points_.deviceVectorAll().data(); + return points_.deviceViewAll().data(); } const int32x3Vector_D& vertices() const @@ -223,12 +223,12 @@ public: int32x3* verticesData_D() { - return vertices_.deviceVectorAll().data(); + return vertices_.deviceViewAll().data(); } const int32x3* verticesData_D()const { - return vertices_.deviceVectorAll().data(); + return vertices_.deviceViewAll().data(); } void clear() diff --git a/src/phasicFlow/structuredData/trisurfaceStructure/triSurfaceKernels.hpp b/src/phasicFlow/structuredData/trisurfaceStructure/triSurfaceKernels.hpp index f9cba450..fbb1d7d6 100644 --- a/src/phasicFlow/structuredData/trisurfaceStructure/triSurfaceKernels.hpp +++ b/src/phasicFlow/structuredData/trisurfaceStructure/triSurfaceKernels.hpp @@ -32,9 +32,9 @@ INLINE_FUNCTION_H bool calculateArea(const realx3Field_D& points, const int32x3Field_D& vertices, realField_D& area) { auto numTri = vertices.size(); - auto areaD = area.deviceVectorAll(); - auto pointsD = points.deviceVectorAll(); - auto verticesD = vertices.deviceVectorAll(); + auto areaD = area.deviceViewAll(); + auto pointsD = points.deviceViewAll(); + auto verticesD = vertices.deviceViewAll(); Kokkos::parallel_for( "pFlow::triSurfaceKernels::calculateArea", diff --git a/src/setHelpers/setProperty.hpp b/src/setHelpers/setProperty.hpp index ee2e1896..a35a1026 100644 --- a/src/setHelpers/setProperty.hpp +++ b/src/setHelpers/setProperty.hpp @@ -18,12 +18,11 @@ Licence: -----------------------------------------------------------------------------*/ - #ifndef __setProperty_hpp__ #define __setProperty_hpp__ REPORT(0)<<"\nReading proprties . . . "< create(systemControl& control, const dictionary & dict); + uniquePtr + create(systemControl& control, const dictionary & dict); }; diff --git a/utilities/particlesPhasicFlow/positionRandom/positionRandom.cpp b/utilities/particlesPhasicFlow/positionRandom/positionRandom.cpp index d0053791..750509f3 100755 --- a/utilities/particlesPhasicFlow/positionRandom/positionRandom.cpp +++ b/utilities/particlesPhasicFlow/positionRandom/positionRandom.cpp @@ -69,8 +69,8 @@ bool pFlow::positionRandom::positionOnePass(int32 pass, int32 startNum) SearchType search( box(minP, maxP), diameter_, - positionHD.deviceVectorAll(), - diameter.deviceVectorAll()); + positionHD.deviceViewAll(), + diameter.deviceViewAll()); ContainerType pairs(3*startNum); @@ -250,7 +250,7 @@ pFlow::int32 pFlow::findCollisions( { auto allPairs = pairs.getPairs(); auto num = pairs.capacity(); - auto dFlags = flags.deviceVector(); + auto dFlags = flags.deviceView(); int32 numCollisions = 0;