change for predictor-corrector and adams-moulton3
This commit is contained in:
parent
db0da79a72
commit
490577dcd2
|
@ -74,6 +74,13 @@ bool pFlow::AdamsBashforth2::correct
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pFlow::AdamsBashforth2::setInitialVals(
|
||||||
|
const int32IndexContainer& newIndices,
|
||||||
|
const realx3Vector& y)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool pFlow::AdamsBashforth2::intAll(
|
bool pFlow::AdamsBashforth2::intAll(
|
||||||
real dt,
|
real dt,
|
||||||
realx3Vector_D& y,
|
realx3Vector_D& y,
|
||||||
|
|
|
@ -68,6 +68,20 @@ public:
|
||||||
|
|
||||||
bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) override;
|
bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) override;
|
||||||
|
|
||||||
|
bool setInitialVals(
|
||||||
|
const int32IndexContainer& newIndices,
|
||||||
|
const realx3Vector& y) override;
|
||||||
|
|
||||||
|
bool needSetInitialVals()const override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uniquePtr<integration> clone()const override
|
||||||
|
{
|
||||||
|
return makeUnique<AdamsBashforth2>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
bool intAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng);
|
bool intAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng);
|
||||||
|
|
||||||
template<typename activeFunctor>
|
template<typename activeFunctor>
|
||||||
|
|
|
@ -60,7 +60,7 @@ pFlow::AdamsBashforth3::AdamsBashforth3
|
||||||
AB3History({zero3,zero3})))
|
AB3History({zero3,zero3})))
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::AdamsBashforth3::predict
|
bool pFlow::AdamsBashforth3::predict
|
||||||
|
@ -94,6 +94,13 @@ bool pFlow::AdamsBashforth3::correct
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pFlow::AdamsBashforth3::setInitialVals(
|
||||||
|
const int32IndexContainer& newIndices,
|
||||||
|
const realx3Vector& y)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool pFlow::AdamsBashforth3::intAll(
|
bool pFlow::AdamsBashforth3::intAll(
|
||||||
real dt,
|
real dt,
|
||||||
realx3Vector_D& y,
|
realx3Vector_D& y,
|
||||||
|
|
|
@ -117,6 +117,20 @@ public:
|
||||||
realx3Vector_D & y,
|
realx3Vector_D & y,
|
||||||
realx3Vector_D& dy) override;
|
realx3Vector_D& dy) override;
|
||||||
|
|
||||||
|
bool setInitialVals(
|
||||||
|
const int32IndexContainer& newIndices,
|
||||||
|
const realx3Vector& y) override;
|
||||||
|
|
||||||
|
bool needSetInitialVals()const override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uniquePtr<integration> clone()const override
|
||||||
|
{
|
||||||
|
return makeUnique<AdamsBashforth3>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
bool intAll(real dt,
|
bool intAll(real dt,
|
||||||
realx3Vector_D& y,
|
realx3Vector_D& y,
|
||||||
realx3Vector_D& dy,
|
realx3Vector_D& dy,
|
||||||
|
|
|
@ -76,6 +76,13 @@ bool pFlow::AdamsBashforth4::correct
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pFlow::AdamsBashforth4::setInitialVals(
|
||||||
|
const int32IndexContainer& newIndices,
|
||||||
|
const realx3Vector& y)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool pFlow::AdamsBashforth4::intAll(
|
bool pFlow::AdamsBashforth4::intAll(
|
||||||
real dt,
|
real dt,
|
||||||
realx3Vector_D& y,
|
realx3Vector_D& y,
|
||||||
|
|
|
@ -122,6 +122,20 @@ public:
|
||||||
realx3Vector_D & y,
|
realx3Vector_D & y,
|
||||||
realx3Vector_D& dy) override;
|
realx3Vector_D& dy) override;
|
||||||
|
|
||||||
|
bool setInitialVals(
|
||||||
|
const int32IndexContainer& newIndices,
|
||||||
|
const realx3Vector& y) override;
|
||||||
|
|
||||||
|
bool needSetInitialVals()const override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uniquePtr<integration> clone()const override
|
||||||
|
{
|
||||||
|
return makeUnique<AdamsBashforth4>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
bool intAll(real dt,
|
bool intAll(real dt,
|
||||||
realx3Vector_D& y,
|
realx3Vector_D& y,
|
||||||
realx3Vector_D& dy,
|
realx3Vector_D& dy,
|
||||||
|
|
|
@ -76,6 +76,13 @@ bool pFlow::AdamsBashforth5::correct
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pFlow::AdamsBashforth5::setInitialVals(
|
||||||
|
const int32IndexContainer& newIndices,
|
||||||
|
const realx3Vector& y)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool pFlow::AdamsBashforth5::intAll(
|
bool pFlow::AdamsBashforth5::intAll(
|
||||||
real dt,
|
real dt,
|
||||||
realx3Vector_D& y,
|
realx3Vector_D& y,
|
||||||
|
|
|
@ -120,6 +120,20 @@ public:
|
||||||
realx3Vector_D & y,
|
realx3Vector_D & y,
|
||||||
realx3Vector_D& dy) override;
|
realx3Vector_D& dy) override;
|
||||||
|
|
||||||
|
bool setInitialVals(
|
||||||
|
const int32IndexContainer& newIndices,
|
||||||
|
const realx3Vector& y) override;
|
||||||
|
|
||||||
|
bool needSetInitialVals()const override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uniquePtr<integration> clone()const override
|
||||||
|
{
|
||||||
|
return makeUnique<AdamsBashforth5>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
bool intAll(real dt,
|
bool intAll(real dt,
|
||||||
realx3Vector_D& y,
|
realx3Vector_D& y,
|
||||||
realx3Vector_D& dy,
|
realx3Vector_D& dy,
|
||||||
|
|
|
@ -0,0 +1,175 @@
|
||||||
|
/*------------------------------- phasicFlow ---------------------------------
|
||||||
|
O C enter of
|
||||||
|
O O E ngineering and
|
||||||
|
O O M ultiscale modeling of
|
||||||
|
OOOOOOO F luid flow
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Copyright (C): www.cemf.ir
|
||||||
|
email: hamid.r.norouzi AT gmail.com
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Licence:
|
||||||
|
This file is part of phasicFlow code. It is a free software for simulating
|
||||||
|
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||||
|
the terms of GNU General Public License v3 or any other later versions.
|
||||||
|
|
||||||
|
phasicFlow is distributed to help others in their research in the field of
|
||||||
|
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "AdamsMoulton3.H"
|
||||||
|
|
||||||
|
//const real AB2_coef[] = { 3.0 / 2.0, 1.0 / 2.0};
|
||||||
|
|
||||||
|
pFlow::AdamsMoulton3::AdamsMoulton3
|
||||||
|
(
|
||||||
|
const word& baseName,
|
||||||
|
repository& owner,
|
||||||
|
const pointStructure& pStruct,
|
||||||
|
const word& method
|
||||||
|
)
|
||||||
|
:
|
||||||
|
integration(baseName, owner, pStruct, method),
|
||||||
|
y0_(
|
||||||
|
owner.emplaceObject<realx3PointField_D>(
|
||||||
|
objectFile(
|
||||||
|
groupNames(baseName,"y0"),
|
||||||
|
"",
|
||||||
|
objectFile::READ_IF_PRESENT,
|
||||||
|
objectFile::WRITE_ALWAYS),
|
||||||
|
pStruct,
|
||||||
|
zero3,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
),
|
||||||
|
dy0_(
|
||||||
|
owner.emplaceObject<realx3PointField_D>(
|
||||||
|
objectFile(
|
||||||
|
groupNames(baseName,"dy0"),
|
||||||
|
"",
|
||||||
|
objectFile::READ_IF_PRESENT,
|
||||||
|
objectFile::WRITE_ALWAYS),
|
||||||
|
pStruct,
|
||||||
|
zero3
|
||||||
|
)
|
||||||
|
),
|
||||||
|
dy1_(
|
||||||
|
owner.emplaceObject<realx3PointField_D>(
|
||||||
|
objectFile(
|
||||||
|
groupNames(baseName,"dy1"),
|
||||||
|
"",
|
||||||
|
objectFile::READ_IF_PRESENT,
|
||||||
|
objectFile::WRITE_ALWAYS),
|
||||||
|
pStruct,
|
||||||
|
zero3
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pFlow::AdamsMoulton3::predict
|
||||||
|
(
|
||||||
|
real dt,
|
||||||
|
realx3Vector_D& y,
|
||||||
|
realx3Vector_D& dy
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(this->pStruct().allActive())
|
||||||
|
{
|
||||||
|
return predictAll(dt, y, dy, this->pStruct().activeRange());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return predictRange(dt, y, dy, this->pStruct().activePointsMaskD());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pFlow::AdamsMoulton3::correct
|
||||||
|
(
|
||||||
|
real dt,
|
||||||
|
realx3Vector_D& y,
|
||||||
|
realx3Vector_D& dy
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(this->pStruct().allActive())
|
||||||
|
{
|
||||||
|
return intAll(dt, y, dy, this->pStruct().activeRange());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return intRange(dt, y, dy, this->pStruct().activePointsMaskD());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pFlow::AdamsMoulton3::setInitialVals(
|
||||||
|
const int32IndexContainer& newIndices,
|
||||||
|
const realx3Vector& y)
|
||||||
|
{
|
||||||
|
y0_.insertSetElement(newIndices, y);
|
||||||
|
//output<< "y0_ "<< y0_<<endl<<endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pFlow::AdamsMoulton3::predictAll(
|
||||||
|
real dt,
|
||||||
|
realx3Vector_D& y,
|
||||||
|
realx3Vector_D& dy,
|
||||||
|
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();
|
||||||
|
|
||||||
|
Kokkos::parallel_for(
|
||||||
|
"AdamsMoulton3::predict",
|
||||||
|
rpIntegration (activeRng.first, activeRng.second),
|
||||||
|
LAMBDA_HD(int32 i){
|
||||||
|
d_dy0[i] = d_dy[i];
|
||||||
|
d_y[i] = d_y0[i] + dt*(static_cast<real>(3.0 / 2.0) * d_dy[i] - static_cast<real>(1.0 / 2.0) * d_dy1[i]);
|
||||||
|
|
||||||
|
});
|
||||||
|
Kokkos::fence();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pFlow::AdamsMoulton3::intAll(
|
||||||
|
real dt,
|
||||||
|
realx3Vector_D& y,
|
||||||
|
realx3Vector_D& dy,
|
||||||
|
range activeRng)
|
||||||
|
{
|
||||||
|
|
||||||
|
auto d_dy = dy.deviceVectorAll();
|
||||||
|
auto d_y = y.deviceVectorAll();
|
||||||
|
|
||||||
|
auto d_dy0 = dy0_.deviceVectorAll();
|
||||||
|
auto d_y0 = y0_.deviceVectorAll();
|
||||||
|
auto d_dy1 = dy1_.deviceVectorAll();
|
||||||
|
|
||||||
|
Kokkos::parallel_for(
|
||||||
|
"AdamsMoulton3::correct",
|
||||||
|
rpIntegration (activeRng.first, activeRng.second),
|
||||||
|
LAMBDA_HD(int32 i){
|
||||||
|
auto corrct_y = d_y0[i] + dt*(
|
||||||
|
static_cast<real>(5.0/12.0)*d_dy[i]
|
||||||
|
+ static_cast<real>(8.0/12.0)*d_dy0[i]
|
||||||
|
- static_cast<real>(1.0/12.0)*d_dy1[i]);
|
||||||
|
d_y[i] = corrct_y;
|
||||||
|
d_y0[i] = corrct_y;
|
||||||
|
d_dy1[i]= d_dy0[i];
|
||||||
|
});
|
||||||
|
Kokkos::fence();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,179 @@
|
||||||
|
/*------------------------------- phasicFlow ---------------------------------
|
||||||
|
O C enter of
|
||||||
|
O O E ngineering and
|
||||||
|
O O M ultiscale modeling of
|
||||||
|
OOOOOOO F luid flow
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Copyright (C): www.cemf.ir
|
||||||
|
email: hamid.r.norouzi AT gmail.com
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Licence:
|
||||||
|
This file is part of phasicFlow code. It is a free software for simulating
|
||||||
|
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||||
|
the terms of GNU General Public License v3 or any other later versions.
|
||||||
|
|
||||||
|
phasicFlow is distributed to help others in their research in the field of
|
||||||
|
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef __AdamsMoulton3_H__
|
||||||
|
#define __AdamsMoulton3_H__
|
||||||
|
|
||||||
|
|
||||||
|
#include "integration.H"
|
||||||
|
#include "pointFields.H"
|
||||||
|
|
||||||
|
namespace pFlow
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
class AdamsMoulton3
|
||||||
|
:
|
||||||
|
public integration
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
realx3PointField_D& y0_;
|
||||||
|
|
||||||
|
realx3PointField_D& dy0_;
|
||||||
|
|
||||||
|
realx3PointField_D& dy1_;
|
||||||
|
|
||||||
|
using rpIntegration = Kokkos::RangePolicy<
|
||||||
|
DefaultExecutionSpace,
|
||||||
|
Kokkos::Schedule<Kokkos::Static>,
|
||||||
|
Kokkos::IndexType<int32>
|
||||||
|
>;
|
||||||
|
public:
|
||||||
|
|
||||||
|
// type info
|
||||||
|
TypeName("AdamsMoulton3");
|
||||||
|
|
||||||
|
//// - Constructors
|
||||||
|
AdamsMoulton3(
|
||||||
|
const word& baseName,
|
||||||
|
repository& owner,
|
||||||
|
const pointStructure& pStruct,
|
||||||
|
const word& method);
|
||||||
|
|
||||||
|
virtual ~AdamsMoulton3()=default;
|
||||||
|
|
||||||
|
// - add a virtual constructor
|
||||||
|
add_vCtor(
|
||||||
|
integration,
|
||||||
|
AdamsMoulton3,
|
||||||
|
word);
|
||||||
|
|
||||||
|
|
||||||
|
//// - Methods
|
||||||
|
bool predict(real dt, realx3Vector_D& y, realx3Vector_D& dy) override;
|
||||||
|
|
||||||
|
bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) override;
|
||||||
|
|
||||||
|
bool setInitialVals(
|
||||||
|
const int32IndexContainer& newIndices,
|
||||||
|
const realx3Vector& y) override;
|
||||||
|
|
||||||
|
bool needSetInitialVals()const override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uniquePtr<integration> clone()const override
|
||||||
|
{
|
||||||
|
return makeUnique<AdamsMoulton3>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool predictAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng);
|
||||||
|
|
||||||
|
template<typename activeFunctor>
|
||||||
|
bool predictRange(real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP);
|
||||||
|
|
||||||
|
bool intAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng);
|
||||||
|
|
||||||
|
template<typename activeFunctor>
|
||||||
|
bool intRange(real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<typename activeFunctor>
|
||||||
|
bool AdamsMoulton3::predictRange(
|
||||||
|
real dt,
|
||||||
|
realx3Vector_D& y,
|
||||||
|
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 activeRng = activeP.activeRange();
|
||||||
|
|
||||||
|
Kokkos::parallel_for(
|
||||||
|
"AdamsMoulton3::predictRange",
|
||||||
|
rpIntegration (activeRng.first, activeRng.second),
|
||||||
|
LAMBDA_HD(int32 i){
|
||||||
|
if(activeP(i))
|
||||||
|
{
|
||||||
|
d_dy0[i] = d_dy[i];
|
||||||
|
d_y[i] = d_y0[i] +
|
||||||
|
dt*
|
||||||
|
(
|
||||||
|
static_cast<real>(3.0 / 2.0) * d_dy[i]
|
||||||
|
- static_cast<real>(1.0 / 2.0) * d_dy1[i]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Kokkos::fence();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename activeFunctor>
|
||||||
|
bool pFlow::AdamsMoulton3::intRange(
|
||||||
|
real dt,
|
||||||
|
realx3Vector_D& y,
|
||||||
|
realx3Vector_D& dy,
|
||||||
|
activeFunctor activeP )
|
||||||
|
{
|
||||||
|
|
||||||
|
auto d_dy = dy.deviceVectorAll();
|
||||||
|
auto d_y = y.deviceVectorAll();
|
||||||
|
|
||||||
|
auto d_dy0 = dy0_.deviceVectorAll();
|
||||||
|
auto d_y0 = y0_.deviceVectorAll();
|
||||||
|
auto d_dy1 = dy1_.deviceVectorAll();
|
||||||
|
|
||||||
|
auto activeRng = activeP.activeRange();
|
||||||
|
|
||||||
|
Kokkos::parallel_for(
|
||||||
|
"AdamsMoulton3::correct",
|
||||||
|
rpIntegration (activeRng.first, activeRng.second),
|
||||||
|
LAMBDA_HD(int32 i){
|
||||||
|
if( activeP(i))
|
||||||
|
{
|
||||||
|
auto corrct_y = d_y0[i] + dt*(
|
||||||
|
static_cast<real>(5.0/12.0)*d_dy[i]
|
||||||
|
+ static_cast<real>(8.0/12.0)*d_dy0[i]
|
||||||
|
- static_cast<real>(1.0/12.0)*d_dy1[i]);
|
||||||
|
d_y[i] = corrct_y;
|
||||||
|
d_y0[i] = corrct_y;
|
||||||
|
d_dy1[i]= d_dy0[i];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Kokkos::fence();
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // pFlow
|
||||||
|
|
||||||
|
#endif //__integration_H__
|
|
@ -5,6 +5,7 @@ AdamsBashforth5/AdamsBashforth5.C
|
||||||
AdamsBashforth4/AdamsBashforth4.C
|
AdamsBashforth4/AdamsBashforth4.C
|
||||||
AdamsBashforth3/AdamsBashforth3.C
|
AdamsBashforth3/AdamsBashforth3.C
|
||||||
AdamsBashforth2/AdamsBashforth2.C
|
AdamsBashforth2/AdamsBashforth2.C
|
||||||
|
AdamsMoulton3/AdamsMoulton3.C
|
||||||
)
|
)
|
||||||
|
|
||||||
set(link_libs Kokkos::kokkos phasicFlow)
|
set(link_libs Kokkos::kokkos phasicFlow)
|
||||||
|
|
|
@ -78,6 +78,14 @@ public:
|
||||||
|
|
||||||
virtual bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) = 0;
|
virtual bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) = 0;
|
||||||
|
|
||||||
|
virtual bool setInitialVals(
|
||||||
|
const int32IndexContainer& newIndices,
|
||||||
|
const realx3Vector& y) = 0;
|
||||||
|
|
||||||
|
virtual bool needSetInitialVals()const = 0;
|
||||||
|
|
||||||
|
virtual uniquePtr<integration> clone()const=0;
|
||||||
|
|
||||||
const word& baseName()const
|
const word& baseName()const
|
||||||
{
|
{
|
||||||
return baseName_;
|
return baseName_;
|
||||||
|
|
|
@ -162,7 +162,9 @@ public:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
//output<<" ContactSearch::broadSearch::PP fater.\n";
|
||||||
|
|
||||||
|
//output<<" ContactSearch::broadSearch::PW before.\n";
|
||||||
if(wallMapping_)
|
if(wallMapping_)
|
||||||
{
|
{
|
||||||
sphereWallTimer_.start();
|
sphereWallTimer_.start();
|
||||||
|
@ -171,6 +173,8 @@ public:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
//output<<" ContactSearch::broadSearch::PW after.\n";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,11 +302,13 @@ public:
|
||||||
performedSearch_ = false;
|
performedSearch_ = false;
|
||||||
|
|
||||||
if( !performSearch() ) return true;
|
if( !performSearch() ) return true;
|
||||||
|
//Info<<"NBS::broadSearch(PairsContainer& pairs, range activeRange, bool force=false) before build"<<endInfo;
|
||||||
build(activeRange);
|
build(activeRange);
|
||||||
|
//Info<<"NBS::broadSearch(PairsContainer& pairs, range activeRange, bool force=false) after build"<<endInfo;
|
||||||
|
|
||||||
|
//Info<<"NBS::broadSearch(PairsContainer& pairs, range activeRange, bool force=false) before findPairs"<<endInfo;
|
||||||
findPairs(pairs);
|
findPairs(pairs);
|
||||||
|
//Info<<"NBS::broadSearch(PairsContainer& pairs, range activeRange, bool force=false) after findPairs"<<endInfo;
|
||||||
performedSearch_ = true;
|
performedSearch_ = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ while( m > -1 )
|
||||||
{
|
{
|
||||||
auto ln = n;
|
auto ln = n;
|
||||||
auto lm = m;
|
auto lm = m;
|
||||||
|
//output<<"lm "<< lm <<" ln "<< ln << " i j k "<< int32x3(i,j,k)<<endl;
|
||||||
if(lm>ln) Swap(lm,ln);
|
if(lm>ln) Swap(lm,ln);
|
||||||
if( auto res = pairs.insert(lm,ln); res <0)
|
if( auto res = pairs.insert(lm,ln); res <0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -134,19 +134,26 @@ public:
|
||||||
|
|
||||||
bool iterate() override
|
bool iterate() override
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//Info<<"before contact search"<<endInfo;
|
||||||
if(this->contactSearch_)
|
if(this->contactSearch_)
|
||||||
{
|
{
|
||||||
|
|
||||||
if( this->contactSearch_().ppEnterBroadSearch())
|
if( this->contactSearch_().ppEnterBroadSearch())
|
||||||
{
|
{
|
||||||
|
//Info<<" before ppEnterBroadSearch"<<endInfo;
|
||||||
ppContactList_().beforeBroadSearch();
|
ppContactList_().beforeBroadSearch();
|
||||||
|
//Info<<" after ppEnterBroadSearch"<<endInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this->contactSearch_().pwEnterBroadSearch())
|
if(this->contactSearch_().pwEnterBroadSearch())
|
||||||
{
|
{
|
||||||
|
//Info<<" before pwEnterBroadSearch"<<endInfo;
|
||||||
pwContactList_().beforeBroadSearch();
|
pwContactList_().beforeBroadSearch();
|
||||||
|
//Info<<" after pwEnterBroadSearch"<<endInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Info<<" before broadSearch"<<endInfo;
|
||||||
if( !contactSearch_().broadSearch(
|
if( !contactSearch_().broadSearch(
|
||||||
ppContactList_(),
|
ppContactList_(),
|
||||||
pwContactList_()) )
|
pwContactList_()) )
|
||||||
|
@ -156,26 +163,37 @@ public:
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Info<<" before broadSearch"<<endInfo;
|
||||||
|
|
||||||
|
|
||||||
if(this->contactSearch_().ppPerformedBroadSearch())
|
if(this->contactSearch_().ppPerformedBroadSearch())
|
||||||
{
|
{
|
||||||
|
//Info<<" before afterBroadSearch"<<endInfo;
|
||||||
ppContactList_().afterBroadSearch();
|
ppContactList_().afterBroadSearch();
|
||||||
|
//Info<<" after afterBroadSearch"<<endInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this->contactSearch_().pwPerformedBroadSearch())
|
if(this->contactSearch_().pwPerformedBroadSearch())
|
||||||
{
|
{
|
||||||
|
//Info<<" before pwContactList_().afterBroadSearch()"<<endInfo;
|
||||||
pwContactList_().afterBroadSearch();
|
pwContactList_().afterBroadSearch();
|
||||||
|
//Info<<" after pwContactList_().afterBroadSearch()"<<endInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Info<<"after contact search"<<endInfo;
|
||||||
|
|
||||||
if( sphParticles_.numActive()<=0)return true;
|
if( sphParticles_.numActive()<=0)return true;
|
||||||
|
//Info<<"before sphereSphereInteraction "<<endInfo;
|
||||||
ppInteractionTimer_.start();
|
ppInteractionTimer_.start();
|
||||||
sphereSphereInteraction();
|
sphereSphereInteraction();
|
||||||
ppInteractionTimer_.end();
|
ppInteractionTimer_.end();
|
||||||
|
//Info<<"after sphereSphereInteraction "<<endInfo;
|
||||||
|
|
||||||
|
//Info<<"before sphereWallInteraction "<<endInfo;
|
||||||
pwInteractionTimer_.start();
|
pwInteractionTimer_.start();
|
||||||
sphereWallInteraction();
|
sphereWallInteraction();
|
||||||
pwInteractionTimer_.end();
|
pwInteractionTimer_.end();
|
||||||
|
//Info<<"after sphereWallInteraction "<<endInfo;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,8 +83,15 @@ bool pFlow::sphereParticles::beforeIteration()
|
||||||
particles::beforeIteration();
|
particles::beforeIteration();
|
||||||
|
|
||||||
intPredictTimer_.start();
|
intPredictTimer_.start();
|
||||||
|
|
||||||
|
//Info<<"before dyn predict"<<endInfo;
|
||||||
dynPointStruct_.predict(this->dt(), accelertion_);
|
dynPointStruct_.predict(this->dt(), accelertion_);
|
||||||
|
//Info<<"after dyn predict"<<endInfo;
|
||||||
|
|
||||||
|
//Info<<"before revel predict"<<endInfo;
|
||||||
rVelIntegration_().predict(this->dt(),rVelocity_, rAcceleration_);
|
rVelIntegration_().predict(this->dt(),rVelocity_, rAcceleration_);
|
||||||
|
//Info<<"after rvel predict"<<endInfo;
|
||||||
|
|
||||||
intPredictTimer_.end();
|
intPredictTimer_.end();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -93,7 +100,9 @@ bool pFlow::sphereParticles::beforeIteration()
|
||||||
|
|
||||||
bool pFlow::sphereParticles::iterate()
|
bool pFlow::sphereParticles::iterate()
|
||||||
{
|
{
|
||||||
|
|
||||||
accelerationTimer_.start();
|
accelerationTimer_.start();
|
||||||
|
//Info<<"before accelerationTimer_ "<<endInfo;
|
||||||
pFlow::sphereParticlesKernels::acceleration(
|
pFlow::sphereParticlesKernels::acceleration(
|
||||||
control().g(),
|
control().g(),
|
||||||
mass().deviceVectorAll(),
|
mass().deviceVectorAll(),
|
||||||
|
@ -107,8 +116,11 @@ bool pFlow::sphereParticles::iterate()
|
||||||
accelerationTimer_.end();
|
accelerationTimer_.end();
|
||||||
|
|
||||||
intCorrectTimer_.start();
|
intCorrectTimer_.start();
|
||||||
|
//Info<<"before correct dyn "<<endInfo;
|
||||||
dynPointStruct_.correct(this->dt(), accelertion_);
|
dynPointStruct_.correct(this->dt(), accelertion_);
|
||||||
|
//Info<<"after correct dyn "<<endInfo;
|
||||||
rVelIntegration_().correct(this->dt(), rVelocity_, rAcceleration_);
|
rVelIntegration_().correct(this->dt(), rVelocity_, rAcceleration_);
|
||||||
|
//Info<<"after correct rvel "<<endInfo;
|
||||||
intCorrectTimer_.end();
|
intCorrectTimer_.end();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -285,6 +297,28 @@ pFlow::sphereParticles::sphereParticles(
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(rVelIntegration_->needSetInitialVals())
|
||||||
|
{
|
||||||
|
|
||||||
|
auto [minInd, maxInd] = pStruct().activeRange();
|
||||||
|
int32IndexContainer indexHD(minInd, maxInd);
|
||||||
|
|
||||||
|
auto n = indexHD.size();
|
||||||
|
auto index = indexHD.indicesHost();
|
||||||
|
|
||||||
|
realx3Vector rvel(n,RESERVE());
|
||||||
|
const auto hrVel = rVelocity_.hostVector();
|
||||||
|
|
||||||
|
for(auto i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
rvel.push_back( hrVel[index(i)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Report(2)<< "Initializing the required vectors for rotational velocity integratoin\n "<<endReport;
|
||||||
|
rVelIntegration_->setInitialVals(indexHD, rvel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if(!initializeParticles())
|
if(!initializeParticles())
|
||||||
{
|
{
|
||||||
|
@ -293,6 +327,32 @@ pFlow::sphereParticles::sphereParticles(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pFlow::sphereParticles::update(const eventMessage& msg)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(rVelIntegration_->needSetInitialVals())
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
auto indexHD = pStruct().insertedPointIndex();
|
||||||
|
|
||||||
|
auto n = indexHD.size();
|
||||||
|
auto index = indexHD.indicesHost();
|
||||||
|
|
||||||
|
realx3Vector rvel(n,RESERVE());
|
||||||
|
const auto hrVel = rVelocity_.hostVector();
|
||||||
|
|
||||||
|
for(auto i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
rvel.push_back( hrVel[index(i)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
rVelIntegration_->setInitialVals(indexHD, rvel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool pFlow::sphereParticles::insertParticles
|
bool pFlow::sphereParticles::insertParticles
|
||||||
(
|
(
|
||||||
|
@ -312,7 +372,7 @@ bool pFlow::sphereParticles::insertParticles
|
||||||
|
|
||||||
auto exclusionListAllPtr = getFieldObjectList();
|
auto exclusionListAllPtr = getFieldObjectList();
|
||||||
|
|
||||||
auto newInsertedPtr = pStruct().insertPoints( position, exclusionListAllPtr());
|
auto newInsertedPtr = pStruct().insertPoints( position, setField, time(), exclusionListAllPtr());
|
||||||
|
|
||||||
if(!newInsertedPtr)
|
if(!newInsertedPtr)
|
||||||
{
|
{
|
||||||
|
@ -337,10 +397,6 @@ bool pFlow::sphereParticles::insertParticles
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto sfEntry:setField)
|
|
||||||
{
|
|
||||||
if(!sfEntry.setPointFieldSelectedAll( time(), newInserted, false ))return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto activeR = this->activeRange();
|
auto activeR = this->activeRange();
|
||||||
|
|
||||||
|
|
|
@ -157,11 +157,8 @@ public:
|
||||||
shapes_.diameterMinMax(minDiam, maxDiam);
|
shapes_.diameterMinMax(minDiam, maxDiam);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool update(const eventMessage& msg) override
|
bool update(const eventMessage& msg) override;
|
||||||
{
|
|
||||||
CONSUME_PARAM(msg);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
realx3PointField_D& rAcceleration() override
|
realx3PointField_D& rAcceleration() override
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,26 +47,28 @@ pFlow::dynamicPointStructure::dynamicPointStructure
|
||||||
objectFile::READ_ALWAYS,
|
objectFile::READ_ALWAYS,
|
||||||
objectFile::WRITE_ALWAYS
|
objectFile::WRITE_ALWAYS
|
||||||
),
|
),
|
||||||
pStruct_,
|
pStruct(),
|
||||||
zero3
|
zero3
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
this->subscribe(pStruct());
|
||||||
|
|
||||||
Report(1)<< "Creating integration method "<<
|
Report(1)<< "Creating integration method "<<
|
||||||
greenText(integrationMethod_)<<" for dynamicPointStructure."<<endReport;
|
greenText(integrationMethod_)<<" for dynamicPointStructure."<<endReport;
|
||||||
|
|
||||||
integrationPos_ = integration::create(
|
integrationPos_ = integration::create(
|
||||||
"pStructPosition",
|
"pStructPosition",
|
||||||
time_.integration(),
|
time_.integration(),
|
||||||
pStruct_,
|
pStruct(),
|
||||||
integrationMethod_);
|
integrationMethod_);
|
||||||
|
|
||||||
integrationVel_ = integration::create(
|
integrationVel_ = integration::create(
|
||||||
"pStructVelocity",
|
"pStructVelocity",
|
||||||
time_.integration(),
|
time_.integration(),
|
||||||
pStruct_,
|
pStruct(),
|
||||||
integrationMethod_);
|
integrationMethod_);
|
||||||
|
|
||||||
if( !integrationPos_ )
|
if( !integrationPos_ )
|
||||||
|
@ -83,6 +85,36 @@ pFlow::dynamicPointStructure::dynamicPointStructure
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!integrationPos_->needSetInitialVals()) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
auto [minInd, maxInd] = pStruct().activeRange();
|
||||||
|
int32IndexContainer indexHD(minInd, maxInd);
|
||||||
|
|
||||||
|
auto n = indexHD.size();
|
||||||
|
auto index = indexHD.indicesHost();
|
||||||
|
|
||||||
|
realx3Vector pos(n,RESERVE());
|
||||||
|
realx3Vector vel(n,RESERVE());
|
||||||
|
const auto hVel = velocity().hostVector();
|
||||||
|
const auto hPos = pStruct().pointPosition().hostVector();
|
||||||
|
|
||||||
|
for(auto i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
pos.push_back( hPos[index(i)]);
|
||||||
|
vel.push_back( hVel[index(i)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//output<< "pos "<< pos<<endl;
|
||||||
|
//output<< "vel "<< vel<<endl;
|
||||||
|
|
||||||
|
Report(2)<< "Initializing the required vectors for position integratoin "<<endReport;
|
||||||
|
integrationPos_->setInitialVals(indexHD, pos);
|
||||||
|
|
||||||
|
Report(2)<< "Initializing the required vectors for velocity integratoin\n "<<endReport;
|
||||||
|
integrationVel_->setInitialVals(indexHD, vel);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::dynamicPointStructure::predict
|
bool pFlow::dynamicPointStructure::predict
|
||||||
|
@ -91,7 +123,7 @@ bool pFlow::dynamicPointStructure::predict
|
||||||
realx3PointField_D& acceleration
|
realx3PointField_D& acceleration
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
auto& pos = pStruct_.pointPosition();
|
auto& pos = pStruct().pointPosition();
|
||||||
|
|
||||||
if(!integrationPos_().predict(dt, pos.VectorField(), velocity_.VectorField() ))return false;
|
if(!integrationPos_().predict(dt, pos.VectorField(), velocity_.VectorField() ))return false;
|
||||||
if(!integrationVel_().predict(dt, velocity_.VectorField(), acceleration.VectorField()))return false;
|
if(!integrationVel_().predict(dt, velocity_.VectorField(), acceleration.VectorField()))return false;
|
||||||
|
@ -105,11 +137,82 @@ bool pFlow::dynamicPointStructure::correct
|
||||||
realx3PointField_D& acceleration
|
realx3PointField_D& acceleration
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
auto& pos = pStruct_.pointPosition();
|
auto& pos = pStruct().pointPosition();
|
||||||
|
|
||||||
if(!integrationPos_().correct(dt, pos.VectorField(), velocity_.VectorField() ))return false;
|
if(!integrationPos_().correct(dt, pos.VectorField(), velocity_.VectorField() ))return false;
|
||||||
|
|
||||||
if(!integrationVel_().correct(dt, velocity_.VectorField(), acceleration.VectorField()))return false;
|
if(!integrationVel_().correct(dt, velocity_.VectorField(), acceleration.VectorField()))return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*FUNCTION_H
|
||||||
|
pFlow::uniquePtr<pFlow::int32IndexContainer> pFlow::dynamicPointStructure::insertPoints
|
||||||
|
(
|
||||||
|
const realx3Vector& pos,
|
||||||
|
const List<eventObserver*>& exclusionList
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto newIndicesPtr = pointStructure::insertPoints(pos, exclusionList);
|
||||||
|
|
||||||
|
// no new point is inserted
|
||||||
|
if( !newIndicesPtr ) return newIndicesPtr;
|
||||||
|
|
||||||
|
if(!integrationPos_().needSetInitialVals()) return newIndicesPtr;
|
||||||
|
|
||||||
|
auto hVel = velocity_.hostVector();
|
||||||
|
auto n = newIndicesPtr().size();
|
||||||
|
auto index = newIndicesPtr().indicesHost();
|
||||||
|
|
||||||
|
realx3Vector velVec(n, RESERVE());
|
||||||
|
for(auto i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
velVec.push_back( hVel[ index(i) ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
integrationPos_->setInitialVals(newIndicesPtr(), pos );
|
||||||
|
integrationVel_->setInitialVals(newIndicesPtr(), velVec );
|
||||||
|
|
||||||
|
return newIndicesPtr;
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
bool pFlow::dynamicPointStructure::update(
|
||||||
|
const eventMessage& msg)
|
||||||
|
{
|
||||||
|
if( msg.isInsert())
|
||||||
|
{
|
||||||
|
|
||||||
|
if(!integrationPos_->needSetInitialVals())return true;
|
||||||
|
|
||||||
|
const auto indexHD = pStruct().insertedPointIndex();
|
||||||
|
|
||||||
|
|
||||||
|
auto n = indexHD.size();
|
||||||
|
|
||||||
|
if(n==0) return true;
|
||||||
|
|
||||||
|
auto index = indexHD.indicesHost();
|
||||||
|
|
||||||
|
realx3Vector pos(n,RESERVE());
|
||||||
|
realx3Vector vel(n,RESERVE());
|
||||||
|
const auto hVel = velocity().hostVector();
|
||||||
|
const auto hPos = pStruct().pointPosition().hostVector();
|
||||||
|
|
||||||
|
for(auto i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
pos.push_back( hPos[index(i)]);
|
||||||
|
vel.push_back( hVel[index(i)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
integrationPos_->setInitialVals(indexHD, pos);
|
||||||
|
|
||||||
|
integrationVel_->setInitialVals(indexHD, vel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
|
@ -31,12 +31,15 @@ namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
class dynamicPointStructure
|
class dynamicPointStructure
|
||||||
|
:
|
||||||
|
//public pointStructure
|
||||||
|
public eventObserver
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Time& time_;
|
Time& time_;
|
||||||
|
|
||||||
const word integrationMethod_;
|
word integrationMethod_;
|
||||||
|
|
||||||
pointStructure& pStruct_;
|
pointStructure& pStruct_;
|
||||||
|
|
||||||
|
@ -52,8 +55,36 @@ public:
|
||||||
|
|
||||||
dynamicPointStructure(Time& time, const word& integrationMethod);
|
dynamicPointStructure(Time& time, const word& integrationMethod);
|
||||||
|
|
||||||
|
dynamicPointStructure(const dynamicPointStructure& ps) = default;
|
||||||
|
|
||||||
|
/*dynamicPointStructure(const dynamicPointStructure& ps):
|
||||||
|
pointStructure(ps),
|
||||||
|
time_(ps.time_),
|
||||||
|
integrationMethod_(ps.integrationMethod_),
|
||||||
|
velocity_(ps.velocity_),
|
||||||
|
integrationPos_(ps.integrationPos_->clone()),
|
||||||
|
integrationVel_(ps.integrationVel_->clone())
|
||||||
|
{
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
// - no move construct
|
||||||
|
dynamicPointStructure(dynamicPointStructure&&) = delete;
|
||||||
|
|
||||||
|
// - copy assignment
|
||||||
|
//
|
||||||
|
// should be changed, may causs undefined behavior
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
dynamicPointStructure& operator=(const dynamicPointStructure&) = default;
|
||||||
|
|
||||||
|
// - no move assignment
|
||||||
|
dynamicPointStructure& operator=(dynamicPointStructure&&) = delete;
|
||||||
|
|
||||||
|
// - destructor
|
||||||
virtual ~dynamicPointStructure() = default;
|
virtual ~dynamicPointStructure() = default;
|
||||||
|
|
||||||
|
|
||||||
inline pointStructure& pStruct()
|
inline pointStructure& pStruct()
|
||||||
{
|
{
|
||||||
return pStruct_;
|
return pStruct_;
|
||||||
|
@ -79,6 +110,19 @@ public:
|
||||||
bool correct(real dt, realx3PointField_D& acceleration);
|
bool correct(real dt, realx3PointField_D& acceleration);
|
||||||
|
|
||||||
|
|
||||||
|
// - update data structure by inserting/setting new points
|
||||||
|
// Notifies all the fields in the registered list of data structure
|
||||||
|
// and exclude the fields that re in the exclusionList
|
||||||
|
// retrun nullptr if it fails
|
||||||
|
/*FUNCTION_H
|
||||||
|
virtual uniquePtr<int32IndexContainer> insertPoints(
|
||||||
|
const realx3Vector& pos,
|
||||||
|
const List<eventObserver*>& exclusionList={nullptr}
|
||||||
|
)override;*/
|
||||||
|
|
||||||
|
bool update(const eventMessage& msg) override;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,21 @@ pFlow::particles::particles
|
||||||
demParticles(control),
|
demParticles(control),
|
||||||
time_(control.time()),
|
time_(control.time()),
|
||||||
integrationMethod_(integrationMethod),
|
integrationMethod_(integrationMethod),
|
||||||
|
/*dynPointStruct_(
|
||||||
|
time_.emplaceObject<dynamicPointStructure>(
|
||||||
|
objectFile(
|
||||||
|
pointStructureFile__,
|
||||||
|
"",
|
||||||
|
objectFile::READ_ALWAYS,
|
||||||
|
objectFile::WRITE_ALWAYS
|
||||||
|
),
|
||||||
|
control.time(),
|
||||||
|
integrationMethod
|
||||||
|
)
|
||||||
|
),*/
|
||||||
dynPointStruct_(
|
dynPointStruct_(
|
||||||
control.time(),
|
control.time(),
|
||||||
integrationMethod
|
integrationMethod),
|
||||||
),
|
|
||||||
shapeName_(
|
shapeName_(
|
||||||
control.time().emplaceObject<wordPointField>(
|
control.time().emplaceObject<wordPointField>(
|
||||||
objectFile(
|
objectFile(
|
||||||
|
|
|
@ -559,6 +559,8 @@ public:
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H
|
||||||
bool insertSetElement(const int32IndexContainer& indices, const Vector<T>& vals)
|
bool insertSetElement(const int32IndexContainer& indices, const Vector<T>& vals)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//Info<<"start of insertSetElement vecotsingle"<<endInfo;
|
||||||
if(indices.size() == 0)return true;
|
if(indices.size() == 0)return true;
|
||||||
if(indices.size() != vals.size())return false;
|
if(indices.size() != vals.size())return false;
|
||||||
|
|
||||||
|
@ -569,38 +571,27 @@ public:
|
||||||
resize(maxInd+1);
|
resize(maxInd+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr (isHostAccessible_)
|
|
||||||
{
|
hostViewType1D<const T> hVecVals( vals.data(), vals.size());
|
||||||
// TODO: remove const_cast
|
deviceViewType1D<T> dVecVals("dVecVals", indices.size());
|
||||||
hostViewType1D<T> dVecVals( const_cast<T*>(vals.data()), vals.size());
|
|
||||||
|
|
||||||
|
copy(dVecVals, hVecVals);
|
||||||
|
|
||||||
pFlow::algorithms::KOKKOS::fillSelected<T, int32, execution_space>(
|
using policy = Kokkos::RangePolicy<
|
||||||
deviceVectorAll().data(),
|
execution_space,
|
||||||
indices.hostView().data(),
|
Kokkos::IndexType<int32> >;
|
||||||
dVecVals.data(),
|
auto dVec = deviceVectorAll();
|
||||||
indices.size());
|
auto dIndex = indices.deviceView();
|
||||||
|
|
||||||
|
Kokkos::parallel_for(
|
||||||
|
"insertSetElement",
|
||||||
|
policy(0,indices.size()), LAMBDA_HD(int32 i){
|
||||||
|
dVec(dIndex(i))= dVecVals(i);
|
||||||
|
});
|
||||||
|
Kokkos::fence();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
|
|
||||||
// TODO: remove const_cast
|
|
||||||
hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
|
|
||||||
deviceViewType1D<T> dVecVals("dVecVals", indices.size());
|
|
||||||
copy(dVecVals, hVecVals);
|
|
||||||
|
|
||||||
|
|
||||||
pFlow::algorithms::KOKKOS::fillSelected<T, int32, execution_space>(
|
|
||||||
deviceVectorAll().data(),
|
|
||||||
indices.deviceView().data(),
|
|
||||||
dVecVals.data(),
|
|
||||||
indices.size());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H
|
||||||
|
|
|
@ -57,36 +57,50 @@ bool pFlow::setFieldEntry::checkForTypeAndValueAll()const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::setFieldEntry::setPointFieldDefaultValueNewAll
|
void* pFlow::setFieldEntry::setPointFieldDefaultValueNewAll
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
pointStructure& pStruct,
|
pointStructure& pStruct,
|
||||||
bool verbose
|
bool verbose
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if(
|
if( void* res = setPointFieldDefaultValueNew<int8> (owner, pStruct, verbose) ; res)
|
||||||
!(
|
{
|
||||||
setPointFieldDefaultValueNew<int8> (owner, pStruct, verbose) ||
|
return res;
|
||||||
setPointFieldDefaultValueNew<int16>(owner, pStruct, verbose) ||
|
}else if(void* res = setPointFieldDefaultValueNew<int16>(owner, pStruct, verbose); res)
|
||||||
setPointFieldDefaultValueNew<int32> (owner, pStruct, verbose) ||
|
{
|
||||||
setPointFieldDefaultValueNew<int64> (owner, pStruct, verbose) ||
|
return res;
|
||||||
setPointFieldDefaultValueNew<uint32> (owner, pStruct, verbose) ||
|
}else if(void* res = setPointFieldDefaultValueNew<int32> (owner, pStruct, verbose); res)
|
||||||
setPointFieldDefaultValueNew<label>(owner, pStruct, verbose) ||
|
{
|
||||||
setPointFieldDefaultValueNew<real>(owner, pStruct, verbose) ||
|
return res;
|
||||||
setPointFieldDefaultValueNew<realx3>(owner, pStruct, verbose) ||
|
}else if(void* res = setPointFieldDefaultValueNew<int64> (owner, pStruct, verbose); res)
|
||||||
setPointFieldDefaultValueStdNew<word>(owner, pStruct, verbose)
|
{
|
||||||
)
|
return res;
|
||||||
)
|
}else if(void* res = setPointFieldDefaultValueNew<uint32> (owner, pStruct, verbose); res)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}else if(void* res = setPointFieldDefaultValueNew<label>(owner, pStruct, verbose); res)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}else if(void* res = setPointFieldDefaultValueNew<real>(owner, pStruct, verbose); res)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}else if(void* res = setPointFieldDefaultValueNew<realx3>(owner, pStruct, verbose); res)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}else if(void* res = setPointFieldDefaultValueStdNew<word>(owner, pStruct, verbose); res)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}else
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
" un-supported data type "<<entry_.firstPart() << " in setField for field " << fieldName() <<endl;
|
" un-supported data type "<<entry_.firstPart() << " in setField for field " << fieldName() <<endl;
|
||||||
return false;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::setFieldEntry::setPointFieldSelectedAll
|
void* pFlow::setFieldEntry::setPointFieldSelectedAll
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
int32IndexContainer& selected,
|
int32IndexContainer& selected,
|
||||||
|
@ -94,25 +108,38 @@ bool pFlow::setFieldEntry::setPointFieldSelectedAll
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(
|
if( void* res = setPointFieldSelected<int8> (owner, selected, verbose) ; res)
|
||||||
!(
|
{
|
||||||
setPointFieldSelected<int8> (owner, selected, verbose) ||
|
return res;
|
||||||
setPointFieldSelected<int16>(owner, selected, verbose) ||
|
}else if(void* res = setPointFieldSelected<int16>(owner, selected, verbose); res)
|
||||||
setPointFieldSelected<int32> (owner, selected, verbose) ||
|
{
|
||||||
setPointFieldSelected<int64> (owner, selected, verbose) ||
|
return res;
|
||||||
setPointFieldSelected<uint32> (owner, selected, verbose) ||
|
}else if(void* res = setPointFieldSelected<int32> (owner, selected, verbose); res)
|
||||||
setPointFieldSelected<label>(owner, selected, verbose) ||
|
{
|
||||||
setPointFieldSelected<real>(owner, selected, verbose) ||
|
return res;
|
||||||
setPointFieldSelected<realx3>(owner, selected, verbose) ||
|
}else if(void* res = setPointFieldSelected<int64> (owner, selected, verbose); res)
|
||||||
setPointFieldSelectedStd<word>(owner, selected, verbose)
|
{
|
||||||
)
|
return res;
|
||||||
)
|
}else if(void* res = setPointFieldSelected<uint32> (owner, selected, verbose); res)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}else if(void* res = setPointFieldSelected<label>(owner, selected, verbose); res)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}else if(void* res = setPointFieldSelected<real>(owner, selected, verbose); res)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}else if(void* res = setPointFieldSelected<realx3>(owner, selected, verbose); res)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}else if(void* res = setPointFieldSelectedStd<word>(owner, selected, verbose); res)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}else
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
" un-supported data type "<<entry_.firstPart() << " in setField for field " << fieldName() <<endl;
|
" un-supported data type "<<entry_.firstPart() << " in setField for field " << fieldName() <<endl;
|
||||||
return false;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public:
|
||||||
bool checkForTypeAndValueAll()const;
|
bool checkForTypeAndValueAll()const;
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
bool setPointFieldDefaultValueNew
|
void* setPointFieldDefaultValueNew
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
pointStructure& pStruct,
|
pointStructure& pStruct,
|
||||||
|
@ -73,14 +73,14 @@ public:
|
||||||
);
|
);
|
||||||
|
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
bool setPointFieldDefaultValueStdNew
|
void* setPointFieldDefaultValueStdNew
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
pointStructure& pStruct,
|
pointStructure& pStruct,
|
||||||
bool verbose = false
|
bool verbose = false
|
||||||
);
|
);
|
||||||
|
|
||||||
bool setPointFieldDefaultValueNewAll
|
void* setPointFieldDefaultValueNewAll
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
pointStructure& pStruct,
|
pointStructure& pStruct,
|
||||||
|
@ -88,7 +88,7 @@ public:
|
||||||
);
|
);
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
bool setPointFieldSelected
|
void* setPointFieldSelected
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
int32IndexContainer& selected,
|
int32IndexContainer& selected,
|
||||||
|
@ -96,14 +96,14 @@ public:
|
||||||
);
|
);
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
bool setPointFieldSelectedStd
|
void* setPointFieldSelectedStd
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
int32IndexContainer& selected,
|
int32IndexContainer& selected,
|
||||||
bool verbose = false
|
bool verbose = false
|
||||||
);
|
);
|
||||||
|
|
||||||
bool setPointFieldSelectedAll
|
void* setPointFieldSelectedAll
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
int32IndexContainer& selected,
|
int32IndexContainer& selected,
|
||||||
|
|
|
@ -37,7 +37,7 @@ bool pFlow::setFieldEntry::checkForTypeAndValue()const
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
bool pFlow::setFieldEntry::setPointFieldDefaultValueNew
|
void* pFlow::setFieldEntry::setPointFieldDefaultValueNew
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
pointStructure& pStruct,
|
pointStructure& pStruct,
|
||||||
|
@ -45,7 +45,7 @@ bool pFlow::setFieldEntry::setPointFieldDefaultValueNew
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
if( !checkForType<Type>() ) return false;
|
if( !checkForType<Type>() ) return nullptr;
|
||||||
|
|
||||||
Type defValue = entry_.secondPartVal<Type>();
|
Type defValue = entry_.secondPartVal<Type>();
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ bool pFlow::setFieldEntry::setPointFieldDefaultValueNew
|
||||||
" in repository "<< owner.name() <<endReport;
|
" in repository "<< owner.name() <<endReport;
|
||||||
|
|
||||||
|
|
||||||
|
auto& field =
|
||||||
owner.emplaceObject<pointField<VectorSingle,Type>>
|
owner.emplaceObject<pointField<VectorSingle,Type>>
|
||||||
(
|
(
|
||||||
objectFile
|
objectFile
|
||||||
|
@ -67,11 +68,11 @@ bool pFlow::setFieldEntry::setPointFieldDefaultValueNew
|
||||||
defValue
|
defValue
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return &field;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
bool pFlow::setFieldEntry::setPointFieldDefaultValueStdNew
|
void* pFlow::setFieldEntry::setPointFieldDefaultValueStdNew
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
pointStructure& pStruct,
|
pointStructure& pStruct,
|
||||||
|
@ -79,7 +80,7 @@ bool pFlow::setFieldEntry::setPointFieldDefaultValueStdNew
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
if( !checkForType<Type>() ) return false;
|
if( !checkForType<Type>() ) return nullptr;
|
||||||
|
|
||||||
Type defValue = entry_.secondPartVal<Type>();
|
Type defValue = entry_.secondPartVal<Type>();
|
||||||
|
|
||||||
|
@ -88,6 +89,7 @@ bool pFlow::setFieldEntry::setPointFieldDefaultValueStdNew
|
||||||
" in repository "<< owner.name() <<endReport;
|
" in repository "<< owner.name() <<endReport;
|
||||||
|
|
||||||
// by default we perform operations on host
|
// by default we perform operations on host
|
||||||
|
auto& field =
|
||||||
owner.emplaceObject<pointField<Vector,Type, vecAllocator<Type>>>
|
owner.emplaceObject<pointField<Vector,Type, vecAllocator<Type>>>
|
||||||
(
|
(
|
||||||
objectFile
|
objectFile
|
||||||
|
@ -101,18 +103,18 @@ bool pFlow::setFieldEntry::setPointFieldDefaultValueStdNew
|
||||||
defValue
|
defValue
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return &field;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
bool pFlow::setFieldEntry::setPointFieldSelected
|
void* pFlow::setFieldEntry::setPointFieldSelected
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
int32IndexContainer& selected,
|
int32IndexContainer& selected,
|
||||||
bool verbose
|
bool verbose
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if( !checkForType<Type>() ) return false;
|
if( !checkForType<Type>() ) return nullptr;
|
||||||
|
|
||||||
|
|
||||||
auto fName = fieldName();
|
auto fName = fieldName();
|
||||||
|
@ -121,7 +123,7 @@ bool pFlow::setFieldEntry::setPointFieldSelected
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
"Cannot find "<< fName << " in repository " << owner.name() << ". \n";
|
"Cannot find "<< fName << " in repository " << owner.name() << ". \n";
|
||||||
return false;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type value = entry_.secondPartVal<Type>();
|
Type value = entry_.secondPartVal<Type>();
|
||||||
|
@ -137,31 +139,40 @@ bool pFlow::setFieldEntry::setPointFieldSelected
|
||||||
{
|
{
|
||||||
|
|
||||||
auto& field = owner.lookupObject<pointField<VectorSingle,Type>>(fName);
|
auto& field = owner.lookupObject<pointField<VectorSingle,Type>>(fName);
|
||||||
return field.insertSetElement(selected, value);
|
if(field.insertSetElement(selected, value))
|
||||||
|
return &field;
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pointField<VectorSingle,Type, HostSpace>::TYPENAME() == fieldTypeName )
|
if( pointField<VectorSingle,Type, HostSpace>::TYPENAME() == fieldTypeName )
|
||||||
{
|
{
|
||||||
|
|
||||||
auto& field = owner.lookupObject<pointField<VectorSingle,Type,HostSpace>>(fName);
|
auto& field = owner.lookupObject<pointField<VectorSingle,Type,HostSpace>>(fName);
|
||||||
return field.insertSetElement(selected, value);
|
if(field.insertSetElement(selected, value))
|
||||||
|
return &field;
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pointField<VectorDual,Type>::TYPENAME() == fieldTypeName )
|
if( pointField<VectorDual,Type>::TYPENAME() == fieldTypeName )
|
||||||
{
|
{
|
||||||
|
|
||||||
auto& field = owner.lookupObject<pointField<VectorDual,Type>>(fName);
|
auto& field = owner.lookupObject<pointField<VectorDual,Type>>(fName);
|
||||||
return field.insertSetElement(selected, value);
|
if(field.insertSetElement(selected, value))
|
||||||
|
return &field;
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
fieldTypeName<< " is not a supported field type for setFieldEntry.\n";
|
fieldTypeName<< " is not a supported field type for setFieldEntry.\n";
|
||||||
return false;
|
return nullptr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
bool pFlow::setFieldEntry::setPointFieldSelectedStd
|
void* pFlow::setFieldEntry::setPointFieldSelectedStd
|
||||||
(
|
(
|
||||||
repository& owner,
|
repository& owner,
|
||||||
int32IndexContainer& selected,
|
int32IndexContainer& selected,
|
||||||
|
@ -169,7 +180,7 @@ bool pFlow::setFieldEntry::setPointFieldSelectedStd
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
if( !checkForType<Type>() ) return false;
|
if( !checkForType<Type>() ) return nullptr;
|
||||||
|
|
||||||
|
|
||||||
auto fName = fieldName();
|
auto fName = fieldName();
|
||||||
|
@ -178,7 +189,7 @@ bool pFlow::setFieldEntry::setPointFieldSelectedStd
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
" Cannot find "<< fName << " in repository " << owner.name() << ". \n";
|
" Cannot find "<< fName << " in repository " << owner.name() << ". \n";
|
||||||
return false;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -194,9 +205,11 @@ bool pFlow::setFieldEntry::setPointFieldSelectedStd
|
||||||
if( pointField<Vector, Type, vecAllocator<Type>>::TYPENAME() == fieldTypeName )
|
if( pointField<Vector, Type, vecAllocator<Type>>::TYPENAME() == fieldTypeName )
|
||||||
{
|
{
|
||||||
auto& field = owner.lookupObject<pointField<Vector,Type, vecAllocator<Type>>>(fName);
|
auto& field = owner.lookupObject<pointField<Vector,Type, vecAllocator<Type>>>(fName);
|
||||||
return field.insertSetElement(selected, value);
|
if(field.insertSetElement(selected, value))
|
||||||
|
return &field;
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
return false;
|
|
||||||
}
|
}
|
|
@ -21,6 +21,7 @@ Licence:
|
||||||
|
|
||||||
#include "pointStructure.H"
|
#include "pointStructure.H"
|
||||||
#include "pointStructureKernels.H"
|
#include "pointStructureKernels.H"
|
||||||
|
#include "setFieldList.H"
|
||||||
#include "error.H"
|
#include "error.H"
|
||||||
#include "iOstream.H"
|
#include "iOstream.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
|
@ -298,10 +299,13 @@ FUNCTION_H
|
||||||
pFlow::uniquePtr<pFlow::int32IndexContainer> pFlow::pointStructure::insertPoints
|
pFlow::uniquePtr<pFlow::int32IndexContainer> pFlow::pointStructure::insertPoints
|
||||||
(
|
(
|
||||||
const realx3Vector& pos,
|
const realx3Vector& pos,
|
||||||
|
const setFieldList& setField,
|
||||||
|
repository& owner,
|
||||||
const List<eventObserver*>& exclusionList
|
const List<eventObserver*>& exclusionList
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
auto numNew = pos.size();
|
auto numNew = pos.size();
|
||||||
if( numNew==0)
|
if( numNew==0)
|
||||||
{
|
{
|
||||||
|
@ -312,27 +316,53 @@ pFlow::uniquePtr<pFlow::int32IndexContainer> pFlow::pointStructure::insertPoints
|
||||||
|
|
||||||
if(!newPointsPtr)return nullptr;
|
if(!newPointsPtr)return nullptr;
|
||||||
|
|
||||||
auto oldSize = size();
|
auto oldSize = size();
|
||||||
auto oldCapacity = capacity();
|
auto oldCapacity = capacity();
|
||||||
auto oldRange = activeRange();
|
auto oldRange = activeRange();
|
||||||
|
|
||||||
tobeInsertedIndex_ = newPointsPtr();
|
tobeInsertedIndex_ = newPointsPtr();
|
||||||
|
|
||||||
// set the position of new points
|
// set the position of new points
|
||||||
if(!pointPosition_.insertSetElement(newPointsPtr(), pos))return nullptr;
|
|
||||||
|
if(!pointPosition_.insertSetElement(
|
||||||
if(!pointFlag_.insertSetElement( newPointsPtr(), static_cast<int8>(PointFlag::ACTIVE)))return nullptr;
|
newPointsPtr(),
|
||||||
|
pos)
|
||||||
|
)return nullptr;
|
||||||
|
|
||||||
|
if(!pointFlag_.insertSetElement(
|
||||||
|
newPointsPtr(),
|
||||||
|
static_cast<int8>(PointFlag::ACTIVE))
|
||||||
|
)return nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setNumMaxPoints();
|
setNumMaxPoints();
|
||||||
auto minInd = newPointsPtr().min();
|
auto minInd = newPointsPtr().min();
|
||||||
auto maxInd = newPointsPtr().max();
|
auto maxInd = newPointsPtr().max();
|
||||||
|
|
||||||
|
|
||||||
|
List<eventObserver*> localExlusion(exclusionList);
|
||||||
|
|
||||||
|
for(auto sfEntry:setField)
|
||||||
|
{
|
||||||
|
if(void* fieldPtr =
|
||||||
|
sfEntry.setPointFieldSelectedAll(
|
||||||
|
owner,
|
||||||
|
newPointsPtr(),
|
||||||
|
false );
|
||||||
|
fieldPtr)
|
||||||
|
|
||||||
|
localExlusion.push_back(
|
||||||
|
static_cast<eventObserver*>(fieldPtr)
|
||||||
|
);
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// changes the active rage based on the new inserted points
|
// changes the active rage based on the new inserted points
|
||||||
activeRange_ = { min(activeRange_.first, minInd ),
|
activeRange_ = { min(activeRange_.first, minInd ),
|
||||||
max(activeRange_.second, maxInd+1)};
|
max(activeRange_.second, maxInd+1)};
|
||||||
|
|
||||||
|
|
||||||
numActivePoints_ += numNew;
|
numActivePoints_ += numNew;
|
||||||
|
|
||||||
eventMessage msg(eventMessage::INSERT);
|
eventMessage msg(eventMessage::INSERT);
|
||||||
|
@ -347,7 +377,7 @@ pFlow::uniquePtr<pFlow::int32IndexContainer> pFlow::pointStructure::insertPoints
|
||||||
msg.add(eventMessage::CAP_CHANGED);
|
msg.add(eventMessage::CAP_CHANGED);
|
||||||
|
|
||||||
// notify all the registered objects except the exclusionList
|
// notify all the registered objects except the exclusionList
|
||||||
if( !this->notify(msg, exclusionList) ) return nullptr;
|
if( !this->notify(msg, localExlusion) ) return nullptr;
|
||||||
|
|
||||||
return newPointsPtr;
|
return newPointsPtr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,8 @@ namespace pFlow
|
||||||
|
|
||||||
//forward
|
//forward
|
||||||
class box;
|
class box;
|
||||||
|
class setFieldList;
|
||||||
|
class repository;
|
||||||
|
|
||||||
class pointStructure
|
class pointStructure
|
||||||
:
|
:
|
||||||
|
@ -319,6 +321,8 @@ public:
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
virtual uniquePtr<int32IndexContainer> insertPoints(
|
virtual uniquePtr<int32IndexContainer> insertPoints(
|
||||||
const realx3Vector& pos,
|
const realx3Vector& pos,
|
||||||
|
const setFieldList& setField,
|
||||||
|
repository& owner,
|
||||||
const List<eventObserver*>& exclusionList={nullptr}
|
const List<eventObserver*>& exclusionList={nullptr}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue