refactor up to particles.hpp

This commit is contained in:
Hamidreza Norouzi 2024-01-21 13:26:23 -08:00
parent 46bf08fa91
commit 9c86fe8f31
38 changed files with 868 additions and 855 deletions

1
.gitignore vendored
View File

@ -38,7 +38,6 @@ bin/**
lib/**
test*/**
**/**notnow
**/MPIParallel*/**
doc/code-documentation/
doc/DTAGS
# all possible time folders

View File

@ -73,7 +73,7 @@ add_subdirectory(src)
#add_subdirectory(solvers)
#add_subdirectory(utilities)
add_subdirectory(utilities)
#add_subdirectory(DEMSystems)
add_subdirectory(testIO)

View File

@ -1,11 +1,11 @@
add_subdirectory(phasicFlow)
#add_subdirectory(Integration)
add_subdirectory(Integration)
#add_subdirectory(Property)
add_subdirectory(Property)
#add_subdirectory(Particles)
add_subdirectory(Particles)
#add_subdirectory(Interaction)

View File

@ -19,36 +19,107 @@ Licence:
-----------------------------------------------------------------------------*/
#include "AdamsBashforth2.hpp"
#include "pointStructure.hpp"
#include "Time.hpp"
#include "vocabs.hpp"
namespace pFlow
{
/// Range policy for integration kernel (alias)
using rpIntegration = Kokkos::RangePolicy<
DefaultExecutionSpace,
Kokkos::Schedule<Kokkos::Static>,
Kokkos::IndexType<uint32>
>;
bool intAllActive(
real dt,
realx3PointField_D& y,
realx3PointField_D& dy,
realx3PointField_D& dy1)
{
auto d_dy = dy.fieldDevice();
auto d_y = y.fieldDevice();
auto d_dy1= dy1.fieldDevice();
auto activeRng = dy1.activeRange();
Kokkos::parallel_for(
"AdamsBashforth2::correct",
rpIntegration (activeRng.start(), activeRng.end()),
LAMBDA_HD(int32 i){
d_y[i] += dt*(static_cast<real>(1.5) * d_dy[i] - static_cast<real>(0.5) * d_dy1[i]);
d_dy1[i] = d_dy[i];
});
Kokkos::fence();
return true;
}
bool intScattered
(
real dt,
realx3PointField_D& y,
realx3PointField_D& dy,
realx3PointField_D& dy1
)
{
auto d_dy = dy.fieldDevice();
auto d_y = y.fieldDevice();
auto d_dy1 = dy1.fieldDevice();
auto activeRng = dy1.activeRange();
const auto& activeP = dy1.activePointsMaskDevice();
Kokkos::parallel_for(
"AdamsBashforth2::correct",
rpIntegration (activeRng.start(), activeRng.end()),
LAMBDA_HD(int32 i){
if( activeP(i))
{
d_y[i] += dt*(static_cast<real>(1.5) * d_dy[i] - static_cast<real>(0.5) * d_dy1[i]);
d_dy1[i] = d_dy[i];
}
});
Kokkos::fence();
return true;
}
}
//const real AB2_coef[] = { 3.0 / 2.0, 1.0 / 2.0};
pFlow::AdamsBashforth2::AdamsBashforth2
(
const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method
pointStructure& pStruct,
const word& method,
const realx3Field_D& initialValField
)
:
integration(baseName, owner, pStruct, method),
dy1_(
owner.emplaceObject<realx3PointField_D>(
objectFile(
groupNames(baseName,"dy1"),
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS),
pStruct,
zero3))
{
}
integration(baseName, pStruct, method, initialValField),
realx3PointField_D
(
objectFile
(
groupNames(baseName,"dy1"),
pStruct.time().integrationFolder(),
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
pStruct,
zero3
)
{}
bool pFlow::AdamsBashforth2::predict
(
real UNUSED(dt),
realx3Vector_D& UNUSED(y),
realx3Vector_D& UNUSED(dy)
realx3PointField_D& UNUSED(y),
realx3PointField_D& UNUSED(dy)
)
{
@ -58,17 +129,19 @@ bool pFlow::AdamsBashforth2::predict
bool pFlow::AdamsBashforth2::correct
(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy
realx3PointField_D& y,
realx3PointField_D& dy
)
{
if(this->pStruct().allActive())
auto& dy1l = dy1();
if(dy1l.isAllActive())
{
return intAll(dt, y, dy, this->pStruct().activeRange());
return intAllActive(dt, y, dy, dy1l);
}
else
{
return intRange(dt, y, dy, this->pStruct().activePointsMaskD());
return intScattered(dt, y, dy, dy1l);
}
return true;
@ -81,25 +154,3 @@ bool pFlow::AdamsBashforth2::setInitialVals(
return true;
}
bool pFlow::AdamsBashforth2::intAll(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
range activeRng)
{
auto d_dy = dy.deviceVectorAll();
auto d_y = y.deviceVectorAll();
auto d_dy1= dy1_.deviceVectorAll();
Kokkos::parallel_for(
"AdamsBashforth2::correct",
rpIntegration (activeRng.first, activeRng.second),
LAMBDA_HD(int32 i){
d_y[i] += dt*(static_cast<real>(3.0 / 2.0) * d_dy[i] - static_cast<real>(1.0 / 2.0) * d_dy1[i]);
d_dy1[i] = d_dy[i];
});
Kokkos::fence();
return true;
}

View File

@ -36,20 +36,16 @@ namespace pFlow
*/
class AdamsBashforth2
:
public integration
public integration,
public realx3PointField_D
{
protected:
private:
/// dy at t-dt
realx3PointField_D& dy1_;
/// Range policy for integration kernel (alias)
using rpIntegration = Kokkos::RangePolicy<
DefaultExecutionSpace,
Kokkos::Schedule<Kokkos::Static>,
Kokkos::IndexType<int32>
>;
auto& dy1()
{
return static_cast<realx3PointField_D&>(*this);
}
public:
/// Type info
@ -60,17 +56,12 @@ public:
/// Construct from components
AdamsBashforth2(
const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method);
uniquePtr<integration> clone()const override
{
return makeUnique<AdamsBashforth2>(*this);
}
pointStructure& pStruct,
const word& method,
const realx3Field_D& initialValField);
/// Destructor
virtual ~AdamsBashforth2()=default;
~AdamsBashforth2()final = default;
/// Add this to the virtual constructor table
add_vCtor(
@ -80,71 +71,33 @@ public:
// - Methods
/// return integration method
word method()const override
{
return "AdamsBashforth2";
}
bool predict(
real UNUSED(dt),
realx3Vector_D& UNUSED(y),
realx3Vector_D& UNUSED(dy)) override;
realx3PointField_D& UNUSED(y),
realx3PointField_D& UNUSED(dy)) final;
bool correct(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy) override;
realx3PointField_D& y,
realx3PointField_D& dy) final;
bool setInitialVals(
const int32IndexContainer& newIndices,
const realx3Vector& y) override;
const realx3Vector& y) final;
bool needSetInitialVals()const override
bool needSetInitialVals()const final
{
return false;
}
/// Integrate on all points in the active range
bool intAll(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
range activeRng);
/// Integrate on active points in the active range
template<typename activeFunctor>
bool intRange(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
activeFunctor activeP );
};
template<typename activeFunctor>
bool pFlow::AdamsBashforth2::intRange(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
activeFunctor activeP )
{
auto d_dy = dy.deviceVectorAll();
auto d_y = y.deviceVectorAll();
auto d_dy1= dy1_.deviceVectorAll();
auto activeRng = activeP.activeRange();
Kokkos::parallel_for(
"AdamsBashforth2::correct",
rpIntegration (activeRng.first, activeRng.second),
LAMBDA_HD(int32 i){
if( activeP(i))
{
d_y[i] += dt*(static_cast<real>(3.0 / 2.0) * d_dy[i] - static_cast<real>(1.0 / 2.0) * d_dy1[i]);
d_dy1[i] = d_dy[i];
}
});
Kokkos::fence();
return true;
}
} // pFlow

View File

@ -1,13 +1,13 @@
list(APPEND SourceFiles
integration/integration.cpp
AdamsBashforth5/AdamsBashforth5.cpp
AdamsBashforth4/AdamsBashforth4.cpp
AdamsBashforth3/AdamsBashforth3.cpp
AdamsBashforth2/AdamsBashforth2.cpp
AdamsMoulton3/AdamsMoulton3.cpp
AdamsMoulton4/AdamsMoulton4.cpp
AdamsMoulton5/AdamsMoulton5.cpp
#AdamsBashforth5/AdamsBashforth5.cpp
#AdamsBashforth4/AdamsBashforth4.cpp
#AdamsBashforth3/AdamsBashforth3.cpp
#AdamsMoulton3/AdamsMoulton3.cpp
#AdamsMoulton4/AdamsMoulton4.cpp
#AdamsMoulton5/AdamsMoulton5.cpp
)
set(link_libs Kokkos::kokkos phasicFlow)

View File

@ -19,33 +19,35 @@ Licence:
-----------------------------------------------------------------------------*/
#include "integration.hpp"
#include "pointStructure.hpp"
#include "repository.hpp"
pFlow::integration::integration
(
const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method
pointStructure& pStruct,
const word&,
const realx3Field_D&
)
:
owner_(owner),
baseName_(baseName),
pStruct_(pStruct)
{
CONSUME_PARAM(method);
}
owner_(*pStruct.owner()),
pStruct_(pStruct),
baseName_(baseName)
{}
pFlow::uniquePtr<pFlow::integration>
pFlow::integration::create(
pFlow::integration::create
(
const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method)
pointStructure& pStruct,
const word& method,
const realx3Field_D& initialValField
)
{
if( wordvCtorSelector_.search(method) )
{
return wordvCtorSelector_[method] (baseName, owner, pStruct, method);
return wordvCtorSelector_[method] (baseName, pStruct, method, initialValField);
}
else
{

View File

@ -23,14 +23,16 @@ Licence:
#include "virtualConstructor.hpp"
#include "Vectors.hpp"
#include "pointStructure.hpp"
#include "repository.hpp"
#include "pointFields.hpp"
namespace pFlow
{
// - Forward
class repository;
class pointStructure;
/**
* Base class for integrating the first order ODE (IVP)
*
@ -48,19 +50,19 @@ namespace pFlow
*/
class integration
{
protected:
private:
// - Protected data members
/// The owner repository that all fields are storred in
repository& owner_;
/// The base name for integration
const word baseName_;
/// A reference to pointStructure
const pointStructure& pStruct_;
/// The base name for integration
const word baseName_;
public:
/// Type info
@ -72,9 +74,9 @@ public:
/// Construct from components
integration(
const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method);
pointStructure& pStruct,
const word& method,
const realx3Field_D& initialValField);
/// Copy constructor
integration(const integration&) = default;
@ -88,22 +90,22 @@ public:
/// Move assignment
integration& operator = (integration&&) = default;
/// Polymorphic copy/cloning
virtual
uniquePtr<integration> clone()const=0;
/// Destructor
virtual ~integration()=default;
/// Add a virtual constructor
create_vCtor(
create_vCtor
(
integration,
word,
(const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method),
(baseName, owner, pStruct, method) );
(
const word& baseName,
pointStructure& pStruct,
const word& method,
const realx3Field_D& initialValField
),
(baseName, pStruct, method, initialValField)
);
// - Methods
@ -129,13 +131,17 @@ public:
return owner_;
}
/// return integration method
virtual
word method()const = 0 ;
/// Prediction step in integration
virtual
bool predict(real dt, realx3Vector_D& y, realx3Vector_D& dy) = 0;
bool predict(real dt, realx3PointField_D& y, realx3PointField_D& dy) = 0;
/// Correction/main integration step
virtual
bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) = 0;
bool correct(real dt, realx3PointField_D& y, realx3PointField_D& dy) = 0;
/// Set the initial values for new indices
virtual
@ -152,9 +158,9 @@ public:
static
uniquePtr<integration> create(
const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method);
pointStructure& pStruct,
const word& method,
const realx3Field_D& initialValField);
}; // integration

View File

@ -2,14 +2,14 @@
set(SourceFiles
dynamicPointStructure/dynamicPointStructure.cpp
particles/particles.cpp
particles/particleIdHandler.cpp
SphereParticles/sphereShape/sphereShape.cpp
SphereParticles/sphereParticles/sphereParticles.cpp
Insertion/shapeMixture/shapeMixture.cpp
Insertion/insertion/insertion.cpp
Insertion/Insertion/Insertions.cpp
Insertion/insertionRegion/insertionRegion.cpp
Insertion/insertionRegion/timeFlowControl.cpp
#particles/particleIdHandler.cpp
#SphereParticles/sphereShape/sphereShape.cpp
#SphereParticles/sphereParticles/sphereParticles.cpp
#Insertion/shapeMixture/shapeMixture.cpp
#Insertion/insertion/insertion.cpp
#Insertion/Insertion/Insertions.cpp
#Insertion/insertionRegion/insertionRegion.cpp
#Insertion/insertionRegion/timeFlowControl.cpp
)
set(link_libs Kokkos::kokkos phasicFlow Integration Property)

View File

@ -19,57 +19,40 @@ Licence:
-----------------------------------------------------------------------------*/
#include "dynamicPointStructure.hpp"
#include "systemControl.hpp"
pFlow::dynamicPointStructure::dynamicPointStructure
(
Time& time,
const word& integrationMethod
systemControl& control
)
:
time_(time),
integrationMethod_(integrationMethod),
pStruct_(
time_.emplaceObject<pointStructure>(
objectFile(
pointStructureFile__,
"",
objectFile::READ_ALWAYS,
objectFile::WRITE_ALWAYS
)
)
),
velocity_(
time_.emplaceObject<realx3PointField_D>(
objectFile(
"velocity",
"",
objectFile::READ_ALWAYS,
objectFile::WRITE_ALWAYS
),
pStruct(),
zero3
)
)
pointStructure(control),
velocity_
(
objectFile(
"velocity",
"",
objectFile::READ_ALWAYS,
objectFile::WRITE_ALWAYS
),
*this,
zero3
),
integrationMethod_
(
control.settingsDict().getVal<word>("integrationMethod")
)
{
this->subscribe(pStruct());
REPORT(1)<< "Creating integration method "<<
greenText(integrationMethod_)<<" for dynamicPointStructure."<<endREPORT;
Green_Text(integrationMethod_)<<" for dynamicPointStructure."<<END_REPORT;
integrationPos_ = integration::create(
integrationPos_ = integration::create
(
"pStructPosition",
time_.integration(),
pStruct(),
integrationMethod_);
integrationVel_ = integration::create(
"pStructVelocity",
time_.integration(),
pStruct(),
integrationMethod_);
*this,
integrationMethod_,
pointPosition()
);
if( !integrationPos_ )
{
@ -77,6 +60,14 @@ pFlow::dynamicPointStructure::dynamicPointStructure
" error in creating integration object for dynamicPointStructure (position). \n";
fatalExit;
}
integrationVel_ = integration::create
(
"pStructVelocity",
*this,
integrationMethod_,
velocity_.field()
);
if( !integrationVel_ )
{
@ -85,8 +76,10 @@ pFlow::dynamicPointStructure::dynamicPointStructure
fatalExit;
}
WARNING << "Initialization of integrationPos_ and integrationVel_ should be doen!"<<END_WARNING;
if(!integrationPos_->needSetInitialVals()) return;
/*if(!integrationPos_->needSetInitialVals()) return;
@ -107,14 +100,13 @@ pFlow::dynamicPointStructure::dynamicPointStructure
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);
integrationVel_->setInitialVals(indexHD, vel);*/
}
bool pFlow::dynamicPointStructure::predict
@ -123,10 +115,10 @@ bool pFlow::dynamicPointStructure::predict
realx3PointField_D& acceleration
)
{
auto& pos = pStruct().pointPosition();
//auto& pos = pStruct().pointPosition();
if(!integrationPos_().predict(dt, pos.VectorField(), velocity_.VectorField() ))return false;
if(!integrationVel_().predict(dt, velocity_.VectorField(), acceleration.VectorField()))return false;
//if(!integrationPos_().predict(dt, pos.VectorField(), velocity_.VectorField() ))return false;
//if(!integrationVel_().predict(dt, velocity_.VectorField(), acceleration.VectorField()))return false;
return true;
}
@ -137,11 +129,11 @@ bool pFlow::dynamicPointStructure::correct
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;
}
@ -178,7 +170,7 @@ pFlow::uniquePtr<pFlow::int32IndexContainer> pFlow::dynamicPointStructure::inser
}*/
bool pFlow::dynamicPointStructure::update(
/*bool pFlow::dynamicPointStructure::update(
const eventMessage& msg)
{
if( msg.isInsert())
@ -215,4 +207,4 @@ bool pFlow::dynamicPointStructure::update(
}
return true;
}
}*/

View File

@ -30,98 +30,65 @@ Licence:
namespace pFlow
{
class systemControl;
class dynamicPointStructure
:
//public pointStructure
public eventObserver
public pointStructure
{
protected:
private:
Time& time_;
realx3PointField_D velocity_;
word integrationMethod_;
uniquePtr<integration> integrationPos_ = nullptr;
pointStructure& pStruct_;
uniquePtr<integration> integrationVel_ = nullptr;
realx3PointField_D& velocity_;
uniquePtr<integration> integrationPos_;
uniquePtr<integration> integrationVel_;
/// @brief integration method for velocity and position
word integrationMethod_;
public:
TypeInfo("dynamicPointStructure");
dynamicPointStructure(Time& time, const word& integrationMethod);
dynamicPointStructure(const dynamicPointStructure& ps) = default;
dynamicPointStructure(systemControl& control);
dynamicPointStructure(const dynamicPointStructure& ps) = delete;
// - no move construct
// - no move construct
dynamicPointStructure(dynamicPointStructure&&) = delete;
// - copy assignment
//
// should be changed, may causs undefined behavior
//////////////////////////////////////////////////////////////
dynamicPointStructure& operator=(const dynamicPointStructure&) = default;
///
dynamicPointStructure& operator=(const dynamicPointStructure&) = delete;
// - no move assignment
dynamicPointStructure& operator=(dynamicPointStructure&&) = delete;
// - destructor
virtual ~dynamicPointStructure() = default;
~dynamicPointStructure() override = default;
inline pointStructure& pStruct()
{
return pStruct_;
}
inline const pointStructure& pStruct() const
{
return pStruct_;
}
inline const realx3PointField_D& velocity()const
inline
const realx3PointField_D& velocity()const
{
return velocity_;
}
inline auto velocityHostAll()
inline
realx3PointField_D& velocity()
{
return velocity_;
}
/*inline auto velocityHostAll()
{
return velocity_.hostVectorAll();
}
inline auto pointPositionHostAll()
{
return pStruct_.pointPositionHostAll();
}
auto markDeleteOutOfBox(const box& domain)
{
return pStruct_.markDeleteOutOfBox(domain);
}
}*/
bool predict(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;
};
}

View File

@ -24,135 +24,107 @@ Licence:
pFlow::particles::particles
(
systemControl& control,
const word& integrationMethod
systemControl& control
)
:
demParticles(control),
time_(control.time()),
integrationMethod_(integrationMethod),
/*dynPointStruct_(
time_.emplaceObject<dynamicPointStructure>(
objectFile(
pointStructureFile__,
"",
objectFile::READ_ALWAYS,
objectFile::WRITE_ALWAYS
),
control.time(),
integrationMethod
)
),*/
dynPointStruct_(
control.time(),
integrationMethod),
shapeName_(
control.time().emplaceObject<wordPointField>(
objectFile(
"shapeName",
"",
objectFile::READ_ALWAYS,
objectFile::WRITE_ALWAYS,
false
),
pStruct(),
word("NO_NAME_SHAPE")
)
observer(),
demComponent("particles", control),
dynPointStruct_(control),
id_
(
objectFile
(
"id",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
id_(
control.time().emplaceObject<int32PointField_HD>(
objectFile(
"id",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
pStruct(),
static_cast<int32>(-1)
)
dynPointStruct_,
static_cast<uint32>(-1)
),
propertyId_
(
objectFile
(
"propertyId",
"",
objectFile::READ_NEVER,
objectFile::WRITE_NEVER
),
propertyId_(
control.time().emplaceObject<int8PointField_D>(
objectFile(
"propertyId",
"",
objectFile::READ_NEVER,
objectFile::WRITE_NEVER
),
pStruct(),
static_cast<int8>(0)
)
dynPointStruct_,
static_cast<int8>(0)
),
diameter_
(
objectFile
(
"diameter",
"",
objectFile::READ_NEVER,
objectFile::WRITE_ALWAYS
),
diameter_(
control.time().emplaceObject<realPointField_D>(
objectFile(
"diameter",
"",
objectFile::READ_NEVER,
objectFile::WRITE_ALWAYS
),
pStruct(),
static_cast<real>(0.00000000001)
)
dynPointStruct_,
0.00000000001
),
mass_
(
objectFile
(
"mass",
"",
objectFile::READ_NEVER,
objectFile::WRITE_ALWAYS
),
mass_(
control.time().emplaceObject<realPointField_D>(
objectFile(
"mass",
"",
objectFile::READ_NEVER,
objectFile::WRITE_ALWAYS
),
pStruct(),
static_cast<real>(0.0000000001)
)
dynPointStruct_,
0.0000000001
),
accelertion_
(
objectFile
(
"accelertion",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
dynPointStruct_,
zero3
),
contactForce_
(
objectFile
(
"contactForce",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
accelertion_(
control.time().emplaceObject<realx3PointField_D>(
objectFile(
"accelertion",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
pStruct(),
zero3
)
dynPointStruct_,
zero3
),
contactTorque_
(
objectFile
(
"contactTorque",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
contactForce_(
control.time().emplaceObject<realx3PointField_D>(
objectFile(
"contactForce",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
pStruct(),
zero3
)
),
contactTorque_(
control.time().emplaceObject<realx3PointField_D>(
objectFile(
"contactTorque",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
pStruct(),
zero3
)
),
idHandler_(id_)
dynPointStruct_,
zero3
)
{
this->subscribe(pStruct());
WARNING<<"Subscribe particles"<<END_WARNING;
//this->subscribe(pStruct());
}
bool pFlow::particles::beforeIteration()
{
auto domain = this->control().domain();
/*auto domain = this->control().domain();
auto numMarked = dynPointStruct_.markDeleteOutOfBox(domain);
@ -174,12 +146,12 @@ bool pFlow::particles::beforeIteration()
}
this->zeroForce();
this->zeroTorque();
this->zeroTorque();*/
return true;
}
pFlow::uniquePtr<pFlow::List<pFlow::eventObserver*>>
/*pFlow::uniquePtr<pFlow::List<pFlow::eventObserver*>>
pFlow::particles::getFieldObjectList()const
{
auto objListPtr = makeUnique<pFlow::List<pFlow::eventObserver*>>();
@ -199,4 +171,4 @@ pFlow::particles::getFieldObjectList()const
static_cast<eventObserver*>(&shapeName_) );
return objListPtr;
}
}*/

View File

@ -23,66 +23,75 @@ Licence:
#define __particles_hpp__
#include "dynamicPointStructure.hpp"
#include "particleIdHandler.hpp"
#include "demParticles.hpp"
#include "demComponent.hpp"
namespace pFlow
{
class setFieldList;
class particles
:
public eventObserver,
public demParticles
public observer,
public demComponent
{
protected:
private:
// owner repository
Time& time_;
const word integrationMethod_;
// dynamic point structure for particles
/// dynamic point structure for particles center mass
dynamicPointStructure dynPointStruct_;
// - name of shapes - this is managed by particles
wordPointField& shapeName_;
//wordPointField& shapeName_;
// id of particles on host
int32PointField_HD& id_;
int32PointField_D id_;
// property id on device
int8PointField_D& propertyId_;
int8PointField_D propertyId_;
// diameter / boundig sphere size of particles on device
realPointField_D& diameter_;
realPointField_D diameter_;
// mass on device
realPointField_D& mass_;
// mass of particles field
realPointField_D mass_;
// - acceleration on device
realx3PointField_D& accelertion_;
realx3PointField_D accelertion_;
/// contact force field
realx3PointField_D contactForce_;
realx3PointField_D& contactForce_;
realx3PointField_D& contactTorque_;
/// contact torque field
realx3PointField_D contactTorque_;
// - object handling particle id
particleIdHandler idHandler_;
virtual uniquePtr<List<eventObserver*>> getFieldObjectList()const;
void zeroForce()
{
contactForce_.fill(zero3);
WARNING<<"fill contactTorque"<<END_WARNING;
//contactForce_.fill(zero3);
}
void zeroTorque()
{
contactTorque_.fill(zero3);
WARNING<<"fill contactTorque"<<END_WARNING;
//contactTorque_.fill(zero3);
}
protected:
inline auto& dynPointStruct()
{
return dynPointStruct_;
}
inline auto& pointPosition()
{
return dynPointStruct_.pointPosition();
}
inline
auto& velocity()
{
return dynPointStruct_.velocity();
}
public:
@ -90,166 +99,132 @@ public:
// type info
TypeInfo("particles");
particles(systemControl& control, const word& integrationMethod);
explicit particles(systemControl& control);
inline const auto& time()const {
return time_;
}
inline auto& time() {
return time_;
}
inline auto integrationMethod()const
{
return integrationMethod_;
}
inline const auto& dynPointStruct()const
{
return dynPointStruct_;
}
inline auto& dynPointStruct()
{
return dynPointStruct_;
}
inline const auto& pStruct()const{
return dynPointStruct_.pStruct();
}
inline auto& pStruct(){
return dynPointStruct_.pStruct();
}
}
inline auto size()const{
return pStruct().size();
return dynPointStruct_.size();
}
inline auto capacity() const{
return pStruct().capacity();
}
inline auto activePointsMaskD()const{
return pStruct().activePointsMaskD();
}
inline auto numActive()const
{
return pStruct().numActive();
return dynPointStruct_.capacity();
}
inline bool allActive()const{
return pStruct().allActive();
}
inline auto activeRange()const{
return pStruct().activeRange();
}
inline auto activePointsMaskH()const{
return pStruct().activePointsMaskH();
}
inline const auto& pointPosition()const{
return pStruct().pointPosition();
}
inline const auto& position()const
inline auto numActive()const
{
return pStruct().pointPosition();
return dynPointStruct_.numActive();
}
inline bool isAllActive()const
{
return dynPointStruct_.isAllActive();
}
inline const auto& pointVelocity()const{
return dynPointStruct().velocity();
inline
const auto& pointPosition()const
{
return dynPointStruct_.pointPosition();
}
inline const auto& velocity()const{
return dynPointStruct().velocity();
inline
const auto& velocity()const
{
return dynPointStruct_.velocity();
}
inline const auto& id()const{
return id_;
}
inline auto& id(){
return id_;
}
inline const auto& diameter()const{
inline
const auto& diameter()const
{
return diameter_;
}
inline auto& diameter(){
inline
auto& diameter()
{
return diameter_;
}
inline const auto& mass()const{
inline
const auto& mass()const
{
return mass_;
}
inline auto& mass() {
inline auto& mass()
{
return mass_;
}
inline const auto& accelertion()const{
return accelertion_;
}
inline auto& accelertion(){
inline
const auto& accelertion()const
{
return accelertion_;
}
inline
realx3PointField_D& contactForce()
auto& accelertion()
{
return accelertion_;
}
inline
auto& contactForce()
{
return contactForce_;
}
inline
const realx3PointField_D& contactForce() const
const auto& contactForce() const
{
return contactForce_;
}
inline
realx3PointField_D& contactTorque()
auto& contactTorque()
{
return contactTorque_;
}
inline
const realx3PointField_D& contactTorque() const
const auto& contactTorque() const
{
return contactTorque_;
}
inline const auto& propertyId()const{
inline
const auto& propertyId()const
{
return propertyId_;
}
inline auto& propertyId(){
inline
auto& propertyId()
{
return propertyId_;
}
inline const auto& shapeName()const{
/*inline const auto& shapeName()const{
return shapeName_;
}
}*/
inline auto& shapName(){
/*inline auto& shapName(){
return shapeName_;
}
}*/
bool beforeIteration() override;
virtual
/*virtual
bool insertParticles
(
const realx3Vector& position,
const wordVector& shapes,
const setFieldList& setField
) = 0;
) = 0;*/
@ -259,8 +234,8 @@ public:
virtual
const realx3PointField_D& rAcceleration() const = 0;
virtual
const realVector_D& boundingSphere()const = 0;
/*virtual
const realVector_D& boundingSphere()const = 0;*/
virtual
word shapeTypeName()const = 0;

View File

@ -18,55 +18,42 @@ Licence:
-----------------------------------------------------------------------------*/
#include "property.hpp"
#include "dictionary.hpp"
bool pFlow::property::readDictionary
(
const dictionary& dict
)
bool pFlow::property::readDictionary()
{
materials_ = dict.getVal<wordVector>("materials");
materials_ = getVal<wordVector>("materials");
densities_ = dict.getVal<realVector>("densities");
densities_ = getVal<realVector>("densities");
if(materials_.size() != densities_.size() )
{
fatalErrorInFunction<<
" number of elements in material ("<<materials_.size()<<
") is not equal to number of elements in densities ("<<densities_.size()<<
") in dictionary "<< dict.globalName()<<endl;
") in dictionary "<< globalName()<<endl;
return false;
}
if(!makeNameIndex())
{
fatalErrorInFunction<<
" error in dictionary "<< dict.globalName()<<endl;
return false;
}
return true;
}
bool pFlow::property::writeDictionary
(
dictionary& dict
)const
bool pFlow::property::writeDictionary()
{
if(!dict.add("materials", materials_))
if(!add("materials", materials_))
{
fatalErrorInFunction<<
" error in writing materials to dictionary "<< dict.globalName()<<endl;
" error in writing materials to dictionary "<< globalName()<<endl;
return false;
}
if(!dict.add("densities", densities_))
if(!add("densities", densities_))
{
fatalErrorInFunction<<
" error in writing densities to dictionary "<< dict.globalName()<<endl;
" error in writing densities to dictionary "<< globalName()<<endl;
return false;
}
@ -78,7 +65,7 @@ bool pFlow::property::makeNameIndex()
nameIndex_.clear();
uint32 i=0;
for(auto& nm:materials_)
for(auto const& nm:materials_)
{
if(!nameIndex_.insertIf(nm, i++))
{
@ -88,68 +75,77 @@ bool pFlow::property::makeNameIndex()
}
}
nameIndex_.rehash(0);
numMaterials_ = materials_.size();
numMaterials_ = static_cast<uint32>(materials_.size());
return true;
}
pFlow::property::property
(
const word& name,
const wordVector& materials,
const realVector& densities
const realVector& densities,
repository* owner
)
:
fileDictionary
(
objectFile
(
name,
"",
objectFile::READ_NEVER,
objectFile::WRITE_NEVER
),
owner
),
materials_(materials),
densities_(densities)
{
if(!writeDictionary())
{
fatalExit;
}
if(!makeNameIndex())
{
fatalErrorInFunction<<
" error in the input parameters of constructor. \n";
"error in the input parameters of constructor. \n";
fatalExit;
}
}
pFlow::property::property
(
const fileSystem& file
const word& fileName,
repository* owner
)
:
dict_
fileDictionary
(
makeUnique<dictionary>
("property", true)
)
{
iFstream dictStream(file);
if(!dict_().read(dictStream))
{
ioErrorInFile(dictStream.name(), dictStream.lineNumber());
fatalExit;
}
if(!readDictionary(dict_()))
{
fatalExit;
}
}
pFlow::property::property
(
const dictionary& dict
)
:
dict_
(
makeUnique<dictionary>(dict)
objectFile
(
fileName,
"",
objectFile::READ_ALWAYS,
objectFile::WRITE_NEVER
),
owner
)
{
if(!readDictionary(dict_()))
if(!readDictionary())
{
fatalExit;
}
if(!makeNameIndex())
{
fatalErrorInFunction<<
"error in dictionary "<< globalName()<<endl;
fatalExit;
}
}

View File

@ -22,7 +22,7 @@ Licence:
#include "Vectors.hpp"
#include "hashMap.hpp"
#include "fileSystem.hpp"
#include "fileDictionary.hpp"
#include "iFstream.hpp"
namespace pFlow
@ -38,14 +38,13 @@ class dictionary;
* used in the simulation: for walls and particles.
*/
class property
:
public fileDictionary
{
protected:
private:
// - protected data members
/// pointer to the dictionary, if it is constructed from a file/dictionary
uniquePtr<dictionary> dict_ = nullptr;
/// list of name of materials
wordVector materials_;
@ -62,10 +61,10 @@ protected:
// - protected member functions
/// read from dict
bool readDictionary(const dictionary& dict);
bool readDictionary();
/// write to dict
bool writeDictionary(dictionary& dict)const;
bool writeDictionary();
/// creates a mapp
bool makeNameIndex();
@ -73,22 +72,19 @@ protected:
public:
/// Type info
TypeInfoNV("property");
TypeInfo("property");
// - Constructors
/// Emptry constructor, used for reading from a file
property(){}
/// Constructe from materials and densities
property(const wordVector& materials, const realVector& densities);
/// Construct from file
property(const fileSystem& file);
/// Construct from dictionary dict
property(const dictionary& dict);
explicit
property(
const word& fileName,
repository* owner=nullptr);
property(const word& name,
const wordVector& materials,
const realVector& densities,
repository* owner=nullptr);
/// Default copy
property(const property& ) = default;
@ -103,17 +99,11 @@ public:
property& operator= (property&&) = default;
/// Default destructor
~property() = default;
~property() override = default;
// - Methods
/// Return dictionary
inline const auto& dict()const
{
return dict_();
}
/// Return number of materials
inline auto numMaterials()const
{
@ -190,20 +180,6 @@ public:
}
}
//// - IO operatoins
/// Read from dictionary
bool read(const dictionary& dict)
{
return readDictionary(dict);
}
/// Write to dictionary
bool write(dictionary& dict)const
{
return writeDictionary(dict);
}
};
}

View File

@ -34,18 +34,6 @@ dictionary/entry/iEntry.cpp
dictionary/entry/dataEntry.cpp
dictionary/twoPartEntry/twoPartEntry.cpp
containers/Vector/Vectors.cpp
containers/VectorHD/VectorSingles.cpp
containers/Field/Fields.cpp
containers/List/anyList/anyList.cpp
containers/pointField/pointFields.cpp
#setFieldList/setFieldList.cpp
#setFieldList/setFieldEntry.cpp
Timer/Timer.cpp
Timer/Timers.cpp
repository/IOobject/objectFile.cpp
repository/IOobject/IOfileHeader.cpp
repository/IOobject/IOobject.cpp
@ -62,6 +50,24 @@ eventManagement/observer.cpp
demComponent/demComponent.cpp
containers/Vector/Vectors.cpp
containers/VectorHD/VectorSingles.cpp
containers/Field/Fields.cpp
containers/List/anyList/anyList.cpp
containers/pointField/pointFields.cpp
#setFieldList/setFieldList.cpp
#setFieldList/setFieldEntry.cpp
Timer/Timer.cpp
Timer/Timers.cpp
structuredData/box/box.cpp
structuredData/line/line.cpp
structuredData/infinitePlane/infinitePlane.cpp
@ -73,6 +79,7 @@ structuredData/pointStructure/internalPoints.cpp
structuredData/pointStructure/pointStructure.cpp
structuredData/boundaries/boundaryBase/boundaryBase.cpp
structuredData/boundaries/boundaryExit/boundaryExit.cpp
structuredData/boundaries/boundaryNone/boundaryNone.cpp
structuredData/pointStructure/boundaryList.cpp
commandLine/commandLine.cpp

View File

@ -322,7 +322,7 @@ public:
{
return readStdVector(is, vectorField());
}
bool write(iOstream& os)
bool write(iOstream& os)const
{
return writeStdVector(os, vectorField());
}

View File

@ -86,6 +86,21 @@ public:
return field_.hostVector();
}
const FieldType& field()const
{
return field_;
}
const pFlagTypeDevice& activePointsMaskDevice()const
{
return internalPoints_.activePointsMaskDevice();
}
const pFlagTypeHost& activePointsMaskHost()const
{
return internalPoints_.activePointsMaskHost();
}
FieldTypeHost activeValuesHost()const;
inline

View File

@ -41,9 +41,32 @@ pFlow::pointField<T, MemorySpace>::pointField
boundaryFieldList_(pStruct.boundaries(), *this),
pStruct_(pStruct),
defaultValue_(defVal)
{
}
{}
template<class T, class MemorySpace>
pFlow::pointField<T, MemorySpace>::pointField
(
const objectFile& objf,
repository* owner,
pointStructure& pStruct,
const T& defVal
)
:
IOobject
(
objf,
pStruct.ioPattern(),
owner
),
InternalFieldType
(
objf.name(),
pStruct
),
boundaryFieldList_(pStruct.boundaries(), *this),
pStruct_(pStruct),
defaultValue_(defVal)
{}
template<class T, class MemorySpace>
pFlow::pointField<T, MemorySpace>::pointField

View File

@ -81,6 +81,12 @@ public:
pointStructure& pStruct,
const T& defVal);
pointField(
const objectFile& objf,
repository* owner,
pointStructure& pStruct,
const T& defVal);
pointField(
const objectFile& objf,
pointStructure& pStruct,

View File

@ -36,57 +36,39 @@ template<typename T>
using pointField_D = pointField<T>;
using int8PointField_D = pointField<int8>;
using int8PointField_D = pointField_D<int8>;
using int8PointField_H = pointField_H<int8>;
using int8PointField_H = pointField<int8, HostSpace>;
using uint8PointField_D = pointField_D<uint8>;
using uint8PointField_H = pointField_H<uint8>;
using realPointField_D = pointField<real>;
using int32PointField_D = pointField_D<int32>;
using int32PointField_H = pointField_H<int32>;
using realPointField_H = pointField<real, HostSpace>;
using uint32PointField_D = pointField_D<uint32>;
using uint32PointField_H = pointField_H<uint32>;
//using int32PointField_D = pointField<VectorSingle, int32>;
using int64PointField_D = pointField_D<int64>;
using int63PointField_H = pointField_H<int64>;
/*using int32PointField_H = pointField<VectorSingle, int32, HostSpace>;
using uint64PointField_D = pointField_D<uint64>;
using uint64PointField_H = pointField_H<uint64>;
using int64PointField_D = pointField<VectorSingle, int64>;
using int32PointField_D = pointField_D<int32>;
using int32PointField_H = pointField_H<int32>;
using int64PointField_H = pointField<VectorSingle, int64, HostSpace>;
using realPointField_D = pointField_D<real>;
using realPointField_H = pointField_H<real>;
using uint32PointField_D = pointField<VectorSingle, uint32>;
using realx3PointField_D = pointField_D<realx3>;
using realx3PointField_H = pointField_H<realx3>;
using uint32PointField_H = pointField<VectorSingle, uint32, HostSpace>;
using realx4PointField_D = pointField_D<realx4>;
using realx4PointField_H = pointField_H<realx4>;
using labelPointField_D = pointField<VectorSingle, label>;
using labelPointField_H = pointField<VectorSingle, label, HostSpace>;
using realPointField_D = pointField<VectorSingle, real>;
using realPointField_H = pointField<VectorSingle, real, HostSpace>;
using realx3PointField_D = pointField<VectorSingle, realx3> ;
using realx3PointField_H = pointField<VectorSingle, realx3, HostSpace>;
using wordPointField_H = pointField<VectorSingle, word, HostSpace>;
using int8PointField_HD = pointField<VectorDual, int8>;
using int16PointField_HD = pointField<VectorDual, int16>;
using int32PointField_HD = pointField<VectorDual, int32>;
using int64PointField_HD = pointField<VectorDual, int64>;
using uint32PointField_HD = pointField<VectorDual, uint32>;
using labelPointField_HD = pointField<VectorDual, label>;
using realPointField_HD = pointField<VectorDual, real>;
using realx3PointField_HD = pointField<VectorDual, realx3>;
using wordPointField = pointField<Vector, word, vecAllocator<word>>;*/
}

View File

@ -10,7 +10,7 @@ pFlow::fileDictionary::fileDictionary
IOobject
(
of,
IOPattern::IOPattern::AllProcessorsSimilar,
IOPattern::AllProcessorsSimilar,
owner
),
dictionary

View File

@ -58,7 +58,7 @@ public:
// standard input and output streams
};
protected:
private:
IOType ioType_;
@ -72,12 +72,16 @@ protected:
public:
IOPattern( IOType iotype);
IOPattern( IOPattern::IOType iotype);
IOPattern(const IOPattern&)=default;
IOPattern(IOPattern&&) = default;
IOPattern& operator=(const IOPattern&)=default;
IOPattern& operator=(IOPattern&&)=default;
~IOPattern() = default;
inline
@ -123,6 +127,13 @@ public:
return true;
}
inline
bool thisCallWrite()const
{
if(isMasterProcessorOnly()&& !isMaster())return false;
return true;
}
inline
bool thisProcReadData()const
{

View File

@ -36,7 +36,7 @@ pFlow::uniquePtr<pFlow::oFstream> pFlow::IOfileHeader::outStream()const
if(osPtr && owner())
{
auto outPrecision = owner()->outFilePrecision();
osPtr->precision(outPrecision);
osPtr->precision(static_cast<int>(outPrecision));
}
return osPtr;
@ -62,7 +62,7 @@ pFlow::fileSystem pFlow::IOfileHeader::path() const
{
f = localPath();
}
f += name_;
f += name();
return f;
}
@ -146,11 +146,8 @@ bool pFlow::IOfileHeader::writeHeader
) const
{
if(!forceWrite)
{
if(!writeHeader()) return true;
}
if(!forceWrite && !writeHeader()) return true;
writeBanner(os);
os.writeWordEntry("objectType", typeName );

View File

@ -64,60 +64,56 @@ pFlow::repository* pFlow::IOobject::releaseOwner
bool pFlow::IOobject::readObject(bool rdHdr)
{
if( implyRead() )
{
if( rdHdr & ioPattern().thisCallRead())
{
if( auto ptrIS = inStream(); ptrIS )
{
if(!readHeader(ptrIS()))return false;
}
else
{
warningInFunction<<
"could not open file " << path() <<endl;
return false;
}
}
if(ioPattern().thisCallRead())
{
if( auto ptrIS = inStream(); ptrIS )
{
if(!readObject(ptrIS(), rdHdr))return false;
}
else
{
warningInFunction<<
"could not open file " << path() <<endl;
return false;
}
}
}
if(!implyRead())return true;
if( rdHdr && ioPattern().thisCallRead())
{
if( auto ptrIS = inStream(); ptrIS )
{
if(!readHeader(ptrIS()))return false;
}
else
{
warningInFunction<<
"could not open file " << path() <<endl;
return false;
}
}
if(ioPattern().thisCallRead())
{
if( auto ptrIS = inStream(); ptrIS )
{
if(!readObject(ptrIS(), rdHdr))return false;
}
else
{
warningInFunction<<
"could not open file " << path() <<endl;
return false;
}
}
return true;
}
bool pFlow::IOobject::writeObject() const
{
if(implyWrite())
if(implyWrite()&& ioPattern().thisCallWrite())
{
if(ioPattern().thisProcWriteData())
if(auto ptrOS = outStream(); ptrOS )
{
if(auto ptrOS = outStream(); ptrOS )
{
return writeObject(ptrOS());
}
else
{
warningInFunction<<
"error in opening file "<< path() <<endl;
return false;
}
return writeObject(ptrOS());
}
else
{
warningInFunction<<
"error in opening file "<< path() <<endl;
return false;
}
}
return true;
@ -126,11 +122,10 @@ bool pFlow::IOobject::writeObject() const
bool pFlow::IOobject::readObject(iIstream& is, bool rdHdr)
{
if(rdHdr && ioPattern().thisCallRead() )
{
if(!readHeader(is))return false;
}
if(rdHdr &&
ioPattern().thisCallRead() &&
!readHeader(is)) return false;
if(ioPattern().thisCallRead())
{
return read(is, ioPattern());
@ -148,11 +143,9 @@ bool pFlow::IOobject::writeObject(iOstream& os) const
if(this->writeHeader() && ioPattern().thisProcWriteHeader())
writeHeader(os, typeName());
if(ioPattern().thisProcWriteData())
{ //return (object_->write_object_t(os, ioPattern_) && writeSeparator(os));
notImplementedFunction;
//return object_->read_object_t(is, ioPattern_);
return false;
if(ioPattern().thisCallWrite())
{
return write(os, ioPattern() );
}
else
return true;

View File

@ -36,7 +36,7 @@ class IOobject
:
public IOfileHeader
{
protected:
private:
IOPattern ioPattern_;
@ -57,7 +57,7 @@ public:
const IOPattern& iop,
repository* owner);
~IOobject();
~IOobject() override;
// - copy construct
IOobject(const IOobject& src)=delete;

View File

@ -45,16 +45,16 @@ public:
};
protected:
private:
/// Name of the entity
word name_;
/// Read flag
readFlag rFlag_ = READ_NEVER;
readFlag rFlag_ = readFlag::READ_NEVER;
/// Write flag
writeFlag wFlag_ = WRITE_NEVER;
writeFlag wFlag_ = writeFlag::WRITE_NEVER;
/// Local path of entity
fileSystem localPath_ = "";
@ -70,7 +70,7 @@ public:
// constructors
objectFile
explicit objectFile
(
const word& name
);
@ -80,8 +80,8 @@ public:
(
const word& name,
const fileSystem& localPath,
const readFlag& rf = READ_NEVER,
const writeFlag& wf = WRITE_NEVER,
const readFlag& rf = readFlag::READ_NEVER,
const writeFlag& wf = writeFlag::WRITE_NEVER,
bool rwHeader = true
);
@ -122,31 +122,31 @@ public:
inline
bool isReadAlways()const
{
return rFlag_ == READ_ALWAYS;
return rFlag_ == readFlag::READ_ALWAYS;
}
inline
bool isReadNever()const
{
return rFlag_ == READ_NEVER;
return rFlag_ == readFlag::READ_NEVER;
}
inline
bool isReadIfPresent()const
{
return rFlag_ == READ_IF_PRESENT;
return rFlag_ == readFlag::READ_IF_PRESENT;
}
inline
bool isWriteAlways()const
{
return wFlag_ == WRITE_ALWAYS;
return wFlag_ == writeFlag::WRITE_ALWAYS;
}
inline
bool isWriteNever()const
{
return wFlag_ == WRITE_NEVER;
return wFlag_ == writeFlag::WRITE_NEVER;
}
inline

View File

@ -55,12 +55,6 @@ pFlow::Time::Time
geometryRepository_,
geometryFolder__,
this
),
integration_
(
integrationRepository__,
integrationFolder__,
this
)
{
@ -90,12 +84,6 @@ pFlow::Time::Time(
geometryRepository_,
geometryFolder__,
this
),
integration_
(
integrationRepository__,
integrationFolder__,
this
)
{
if(!readDictionary(setiingsDict))
@ -109,6 +97,11 @@ pFlow::fileSystem pFlow::Time::localPath()const
return fileSystem(timeName());
}
pFlow::fileSystem pFlow::Time::integrationFolder() const
{
return integrationFolder__;
}
bool pFlow::Time::write
(
bool verbose

View File

@ -28,7 +28,7 @@ Licence:
#include "timeControl.hpp"
#include "repository.hpp"
#include "fileSystem.hpp"
namespace pFlow
@ -49,10 +49,6 @@ protected:
// - geometry folder/repository
repository geometry_;
// - integration folder/repository
repository integration_;
bool readDictionary(const dictionary& dict);
public:
@ -84,15 +80,7 @@ public:
return geometry_;
}
const repository& integration()const
{
return integration_;
}
repository& integration()
{
return integration_;
}
fileSystem integrationFolder()const;
/// Write to the file with binary format?
bool outFileBinary()const override

View File

@ -18,7 +18,6 @@ Licence:
-----------------------------------------------------------------------------*/
#ifndef __uniquePtr_hpp__
#define __uniquePtr_hpp__
@ -47,7 +46,7 @@ class uniquePtr
{
public:
typedef std::unique_ptr<T,Deleter> uniquePtrType;
using uniquePtrType = std::unique_ptr<T, Deleter>;
// using base constructors
using uniquePtrType::unique_ptr;

View File

@ -0,0 +1,58 @@
/*------------------------------- 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 "boundaryNone.hpp"
pFlow::boundaryNone::boundaryNone
(
const dictionary& dict,
const plane& bplane,
internalPoints& internal
)
:
boundaryBase(dict, bplane, internal)
{}
bool pFlow::boundaryNone::beforeIteratoin
(
uint32 iterNum,
real t
)
{
return true;
}
bool pFlow::boundaryNone::iterate
(
uint32 iterNum,
real t
)
{
return true;
}
bool pFlow::boundaryNone::afterIteration
(
uint32 iterNum,
real t
)
{
return true;
}

View File

@ -0,0 +1,64 @@
/*------------------------------- 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 __boundaryNone_hpp__
#define __boundaryNone_hpp__
#include "boundaryBase.hpp"
namespace pFlow
{
class boundaryNone
:
public boundaryBase
{
public:
TypeInfo("boundary<none>");
boundaryNone(
const dictionary& dict,
const plane& bplane,
internalPoints& internal);
~boundaryNone() override= default;
add_vCtor
(
boundaryBase,
boundaryNone,
dictionary
);
bool beforeIteratoin(uint32 iterNum, real t) override;
bool iterate(uint32 iterNum, real t) override;
bool afterIteration(uint32 iterNum, real t) override;
};
}
#endif

View File

@ -39,6 +39,11 @@ public:
uint32 initialNumberInThis()const override;
bool initialThisDomainActive()const override
{
return true;
}
/*bool updateDomains(
span<realx3> pointPos,
pFlagTypeHost flags) override;*/

View File

@ -97,6 +97,9 @@ public:
virtual
uint32 initialNumberInThis()const = 0;
virtual
bool initialThisDomainActive()const = 0;
virtual
bool initialTransferBlockData(
span<char> src,

View File

@ -172,7 +172,7 @@ public:
INLINE_FUNCTION_HD
bool operator()(uint32 i)
bool operator()(uint32 i)const
{
return isActive(i);
}

View File

@ -42,7 +42,7 @@ protected:
public:
readFromTimeFolder(repository& rep);
explicit readFromTimeFolder(repository& rep);
auto path()const
{
@ -65,9 +65,9 @@ public:
bool pointFieldGetType(word& typeName)const
{
word fieldTYPENAME = pointField_H<T>::TYPENAME();
word fldType{}, space{};
word fldType{};
if( !pFlow::utilities::pointFieldGetType(
if(word space{}; !pFlow::utilities::pointFieldGetType(
fieldTYPENAME, fldType, space) )
{
fatalErrorInFunction<<
@ -81,18 +81,19 @@ public:
}
template<typename T>
bool pointFieldGetCheckType(word fieldName, word& typeName) const
bool pointFieldGetCheckType(word const& fieldName, word& typeName) const
{
word fieldTYPENAME = pointField_H<T>::TYPENAME();
word flType{},fldType{};
word flType{};
if(!pointFieldFileGetType( fieldName, flType))
{
fatalExit;
return false;
}
word fldType{};
if( !pointFieldGetType<T>(fldType) )
{
fatalExit;
@ -112,7 +113,7 @@ public:
}
template<typename T>
pointField_H<T>& createUniformPointField_H(word name, T value)
uniquePtr<pointField_H<T>> createUniformPointField_H(word const& name, T value)
{
if( !checkForPointStructure() )
{
@ -120,29 +121,28 @@ public:
"cannot find " << pointStructureFile__ << " in repository "<< repository_.name()<<endl;
fatalExit;
}
auto& pStruct = repository_.lookupObject<pointStructure>(pointStructureFile__);
word fType;
pointFieldGetType<T>(fType);
word newName = name + fType;
auto& field = repository_.emplaceReplaceObject<pointField_H<T>>(
objectFile(
auto Ptr = makeUnique<pointField_H<T>>
(
objectFile
(
name,
"",
objectFile::READ_NEVER,
objectFile::WRITE_NEVER
),
),
pStruct,
T{},
value
);
return field;
);
return Ptr;
}
template<typename T>
pointField_H<T>& readPointField_H(word name)
uniquePtr<pointField_H<T>> readPointField_H(word const& name)
{
if( !checkForPointStructure() )
{
@ -152,23 +152,25 @@ public:
}
auto& pStruct = repository_.lookupObject<pointStructure>(pointStructureFile__);
auto& field = repository_.emplaceObjectOrGet<pointField_H<T>>(
objectFile(
auto Ptr = makeUnique<pointField_H<T>>
(
objectFile
(
name,
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
),
pStruct,
T{}
);
);
return field;
return Ptr;
}
template<typename T>
pointField_D<T>& readPointField_D(word name)
uniquePtr<pointField_D<T>> readPointField_D(word const& name)
{
if( !checkForPointStructure() )
{
@ -178,18 +180,20 @@ public:
}
auto& pStruct = repository_.lookupObject<pointStructure>(pointStructureFile__);
auto& field = repository_.emplaceObjectOrGet<pointField_H<T>>(
objectFile(
auto Ptr = makeUnique<pointField_D<T>>
(
objectFile
(
name,
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
),
pStruct,
T{}
);
);
return field;
return Ptr;
}
};

View File

@ -72,21 +72,10 @@ int main( int argc, char* argv[] )
// this should be palced in each main
#include "initialize_Control.hpp"
auto objCPDict = IOobject::make<fileDictionary>
(
objectFile
(
"particlesDict",
Control.settings().path(),
objectFile::READ_ALWAYS,
objectFile::WRITE_ALWAYS
),
"particlesDict"
);
fileDictionary cpDict("particlesDict", Control.settings().path());
auto& cpDict = objCPDict().getObject<fileDictionary>();
pointStructure* pStructPtr = nullptr;
uniquePtr<pointStructure> pStructPtr = nullptr;
if(!setOnly)
@ -100,24 +89,11 @@ int main( int argc, char* argv[] )
auto finalPos = pointPosition().getFinalPosition();
auto& pStruct = Control.time().emplaceObject<pointStructure>
(
objectFile
(
pointStructureFile__,
Control.time().path(),
objectFile::READ_NEVER,
objectFile::WRITE_ALWAYS
),
Control,
finalPos
);
pStructPtr = makeUnique<pointStructure>(Control, finalPos);
pStructPtr = &pStruct;
REPORT(1)<< "Created pStruct with "<< pStruct.size() << " points and capacity "<<
pStruct.capacity()<<" . . ."<< END_REPORT;
REPORT(1)<< "Created pStruct with "<< pStructPtr().size() << " points and capacity "<<
pStructPtr().capacity()<<" . . ."<< END_REPORT;
//REPORT(1)<< "Writing pStruct to " << Control.time().path()+ pointStructureFile__<< END_REPORT<<endl<<endl;
@ -130,20 +106,8 @@ int main( int argc, char* argv[] )
}
else
{
auto& pStruct = Control.time().emplaceObject<pointStructure>
(
objectFile
(
pointStructureFile__,
Control.time().path(),
objectFile::READ_NEVER,
objectFile::WRITE_ALWAYS
),
Control
);
pStructPtr = &pStruct;
// read the content of pStruct from 0/pStructure
pStructPtr = makeUnique<pointStructure>(Control);
}

View File

@ -19,6 +19,7 @@ Licence:
-----------------------------------------------------------------------------*/
#include "positionParticles.hpp"
#include "vocabs.hpp"
#include "box.hpp"
#include "cylinder.hpp"
#include "sphere.hpp"
@ -101,7 +102,18 @@ pFlow::positionParticles::positionParticles
}
else
{
region_ = makeUnique<region<box>>( control.domainDict().subDict("globalBox"));
fileDictionary domainDict
(
objectFile
{
domainFile__,
"",
objectFile::READ_ALWAYS,
objectFile::WRITE_NEVER
},
&control.settings()
);
region_ = makeUnique<region<box>>( domainDict.subDict("globalBox"));
}
}