mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-22 16:28:30 +00:00
Particle insertion is added with anyList
- collision check is not active yet. - variable velocity is not active yet. - events and messages are not active yet.
This commit is contained in:
@ -1,19 +1,18 @@
|
||||
|
||||
set(SourceFiles
|
||||
dynamicPointStructure/dynamicPointStructure.cpp
|
||||
particles/baseShapeNames.cpp
|
||||
particles/shape.cpp
|
||||
particles/shape/baseShapeNames.cpp
|
||||
particles/shape/shape.cpp
|
||||
particles/particles.cpp
|
||||
particles/particleIdHandler.cpp
|
||||
particles/regularParticleHandler.cpp
|
||||
particles/particleIdHandler/particleIdHandler.cpp
|
||||
particles/regularParticleIdHandler/regularParticleIdHandler.cpp
|
||||
SphereParticles/sphereShape/sphereShape.cpp
|
||||
SphereParticles/sphereParticles/sphereParticles.cpp
|
||||
SphereParticles/sphereParticles/sphereParticlesKernels.cpp
|
||||
#Insertion/shapeMixture/shapeMixture.cpp
|
||||
#Insertion/insertion/insertion.cpp
|
||||
#Insertion/Insertion/Insertions.cpp
|
||||
#Insertion/insertionRegion/insertionRegion.cpp
|
||||
#Insertion/insertionRegion/timeFlowControl.cpp
|
||||
Insertion/insertionRegion/insertionRegion.cpp
|
||||
Insertion/insertion/insertion.cpp
|
||||
Insertion/shapeMixture/shapeMixture.cpp
|
||||
Insertion/Insertion/Insertions.cpp
|
||||
)
|
||||
|
||||
set(link_libs Kokkos::kokkos phasicFlow Integration Property)
|
||||
|
@ -18,7 +18,7 @@ Licence:
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
template<typename ShapeType>
|
||||
/*template<typename ShapeType>
|
||||
bool pFlow::Insertion<ShapeType>::readInsertionDict
|
||||
(
|
||||
const dictionary& dict
|
||||
@ -65,6 +65,33 @@ bool pFlow::Insertion<ShapeType>::writeInsertionDict
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
template<typename ShapeType>
|
||||
bool
|
||||
pFlow::Insertion<ShapeType>::setInsertionRegions()
|
||||
{
|
||||
regions_.clear();
|
||||
|
||||
if( !this->isActive() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
wordList regionDicNames = this->dictionaryKeywords();
|
||||
|
||||
for(const auto& name:regionDicNames)
|
||||
{
|
||||
REPORT(2)<<"reading insertion region "<< Green_Text(name)<<END_REPORT;
|
||||
|
||||
regions_.push_back(makeUnique<InsertionRegion<ShapeType>>(
|
||||
name,
|
||||
*this,
|
||||
shapes_));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
template<typename ShapeType>
|
||||
@ -75,11 +102,14 @@ pFlow::Insertion<ShapeType>::Insertion(
|
||||
insertion(prtcl),
|
||||
shapes_(shapes)
|
||||
{
|
||||
|
||||
|
||||
if(!setInsertionRegions())
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename ShapeType>
|
||||
/*template<typename ShapeType>
|
||||
pFlow::Insertion<ShapeType>::Insertion(
|
||||
fileSystem file,
|
||||
particles& prtcl,
|
||||
@ -95,13 +125,14 @@ pFlow::Insertion<ShapeType>::Insertion(
|
||||
file<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
template<typename ShapeType>
|
||||
bool pFlow::Insertion<ShapeType>::insertParticles
|
||||
(
|
||||
real currentTime,
|
||||
uint32 iter,
|
||||
real t,
|
||||
real dt
|
||||
)
|
||||
{
|
||||
@ -112,21 +143,21 @@ bool pFlow::Insertion<ShapeType>::insertParticles
|
||||
{
|
||||
bool insertionOccured = false;
|
||||
auto& rgn = regions_[i];
|
||||
if( rgn.insertionTime(currentTime, dt) )
|
||||
if( rgn.insertionTime(iter, t, dt) )
|
||||
{
|
||||
|
||||
realx3Vector pos;
|
||||
wordVector shapes;
|
||||
if( rgn.insertParticles(currentTime, dt, shapes, pos, insertionOccured) )
|
||||
if( rgn.insertParticles(iter, t, dt, shapes, pos, insertionOccured) )
|
||||
{
|
||||
|
||||
if(insertionOccured)
|
||||
{
|
||||
REPORT(0)<<"\nParticle insertion from "<< greenText(rgn.name())<<endREPORT;
|
||||
REPORT(1)<< cyanText(pos.size()) << " new particles is being inserted at Time: "<<
|
||||
cyanText(currentTime) <<" s."<<endREPORT;
|
||||
REPORT(0)<<"\nParticle insertion from "<< Green_Text(rgn.name())<<END_REPORT;
|
||||
REPORT(1)<< Cyan_Text(pos.size()) << " new particles is being inserted at Time: "<<
|
||||
Cyan_Text(t) <<" s."<<END_REPORT;
|
||||
|
||||
if(!particles_.insertParticles(pos, shapes, rgn.setFields()))
|
||||
if(!Particles().insertParticles(pos, shapes, rgn.setFieldList()))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" Cannot add "<< pos.size() << " particles from region "<< rgn.name() <<
|
||||
@ -134,7 +165,7 @@ bool pFlow::Insertion<ShapeType>::insertParticles
|
||||
return false;
|
||||
}
|
||||
REPORT(1)<<"Total number of particles inserted from this region is "<<
|
||||
cyanText(rgn.totalInserted())<<'\n'<<endREPORT;
|
||||
Cyan_Text(rgn.totalInserted())<<'\n'<<END_REPORT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -146,9 +177,15 @@ bool pFlow::Insertion<ShapeType>::insertParticles
|
||||
{
|
||||
if(insertionOccured)
|
||||
{
|
||||
yWARNING<< "\n fewer number of particles are inserted from region "<< rgn.name() <<
|
||||
" than expected. You may stop the simulation to change settings."<<endyWARNING;
|
||||
continue;
|
||||
WARNING<< "\n fewer number of particles are inserted from region "<< rgn.name() <<
|
||||
" than expected. You may stop the simulation to change settings."<<END_WARNING;
|
||||
if(!Particles().insertParticles(pos, shapes, rgn.setFieldList()))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" Cannot add "<< pos.size() << " particles from region "<< rgn.name() <<
|
||||
" to particles. \n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -166,7 +203,7 @@ bool pFlow::Insertion<ShapeType>::insertParticles
|
||||
}
|
||||
|
||||
|
||||
template<typename ShapeType>
|
||||
/*template<typename ShapeType>
|
||||
bool pFlow::Insertion<ShapeType>::read
|
||||
(
|
||||
iIstream& is
|
||||
@ -217,4 +254,4 @@ bool pFlow::Insertion<ShapeType>::write
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
@ -2,30 +2,28 @@
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
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
|
||||
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
|
||||
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 __Insertion_hpp__
|
||||
#define __Insertion_hpp__
|
||||
|
||||
|
||||
#include "insertion.hpp"
|
||||
#include "ListPtr.hpp"
|
||||
#include "InsertionRegion.hpp"
|
||||
#include "ListPtr.hpp"
|
||||
#include "insertion.hpp"
|
||||
#include "particles.hpp"
|
||||
|
||||
namespace pFlow
|
||||
@ -34,57 +32,56 @@ namespace pFlow
|
||||
/**
|
||||
* This class manages all the insertion regions for particles insertion
|
||||
* in the simulation.
|
||||
*
|
||||
*
|
||||
* Any number of insertion regions can be defined in a simulation. The
|
||||
* data for particle insertion is provided in particleInsertion file, which
|
||||
* looks like this. A list of insertion regions (class insertionRegion) can be defined in this file.
|
||||
* For more information see file insertionRegion.hpp.
|
||||
* data for particle insertion is provided in particleInsertion file, which
|
||||
* looks like this. A list of insertion regions (class insertionRegion) can be
|
||||
defined in this file.
|
||||
* For more information see file insertionRegion.hpp.
|
||||
* \verbatim
|
||||
active yes;
|
||||
|
||||
region1
|
||||
{
|
||||
// the data for insertionRegion
|
||||
// the data for insertionRegion
|
||||
}
|
||||
|
||||
region2
|
||||
{
|
||||
// Data for insertionRegion
|
||||
// Data for insertionRegion
|
||||
}
|
||||
\endverbatim
|
||||
*/
|
||||
template<typename ShapeType>
|
||||
class Insertion
|
||||
:
|
||||
public insertion
|
||||
class Insertion : public insertion
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
const ShapeType& shapes_;
|
||||
const ShapeType& shapes_;
|
||||
|
||||
// - insertion regions
|
||||
ListPtr<InsertionRegion<ShapeType>> regions_;
|
||||
// - insertion regions
|
||||
ListPtr<InsertionRegion<ShapeType>> regions_;
|
||||
|
||||
|
||||
bool readInsertionDict(const dictionary& dict);
|
||||
bool setInsertionRegions();
|
||||
|
||||
bool writeInsertionDict(dictionary& dict)const;
|
||||
// bool readInsertionDict(const dictionary& dict);
|
||||
|
||||
// bool writeInsertionDict(dictionary& dict)const;
|
||||
|
||||
public:
|
||||
|
||||
TypeInfoTemplateNV("Insertion",ShapeType);
|
||||
TypeInfoTemplateNV11("Insertion", ShapeType);
|
||||
|
||||
Insertion(particles& prtcl, const ShapeType& shapes);
|
||||
|
||||
Insertion(fileSystem file, particles& prtcl, const ShapeType& shapes);
|
||||
// Insertion(fileSystem file, particles& prtcl, const ShapeType& shapes);
|
||||
|
||||
bool insertParticles(uint32 iter, real t, real dt);
|
||||
|
||||
bool insertParticles(real currentTime, real dt);
|
||||
|
||||
virtual bool read(iIstream& is) override;
|
||||
|
||||
virtual bool write(iOstream& os)const override;
|
||||
/*virtual bool read(iIstream& is) override;
|
||||
|
||||
virtual bool write(iOstream& os)const override;*/
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -39,21 +39,21 @@ bool pFlow::InsertionRegion<ShapeType>::checkForContact
|
||||
template<typename ShapeType>
|
||||
pFlow::InsertionRegion<ShapeType>::InsertionRegion
|
||||
(
|
||||
const dictionary& dict,
|
||||
const word& name,
|
||||
const insertion& instn,
|
||||
const ShapeType& shapes
|
||||
)
|
||||
:
|
||||
insertionRegion(dict),
|
||||
insertionRegion(name, instn),
|
||||
shapes_(shapes)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
template<typename ShapeType>
|
||||
bool pFlow::InsertionRegion<ShapeType>::insertParticles
|
||||
(
|
||||
real currentTime,
|
||||
uint32 iter,
|
||||
real t,
|
||||
real dt,
|
||||
wordVector& names,
|
||||
realx3Vector& pos,
|
||||
@ -62,9 +62,9 @@ bool pFlow::InsertionRegion<ShapeType>::insertParticles
|
||||
{
|
||||
insertionOccured = false;
|
||||
|
||||
if(!insertionTime( currentTime, dt)) return true;
|
||||
if(!insertionTime(iter, t, dt)) return true;
|
||||
|
||||
size_t newNum = numberToBeInserted(currentTime);
|
||||
uint32 newNum = numberToBeInserted(iter, t, dt);
|
||||
|
||||
if(newNum == 0) return true;
|
||||
|
||||
@ -73,43 +73,49 @@ bool pFlow::InsertionRegion<ShapeType>::insertParticles
|
||||
names.clear();
|
||||
pos.clear();
|
||||
|
||||
realVector diams(newNum, RESERVE());
|
||||
realVector diams("diams", newNum, 0, RESERVE());
|
||||
|
||||
mixture_->getNextShapeNameN(newNum, names);
|
||||
|
||||
if(!shapes_.shapeToDiameter(names,diams))
|
||||
for(uint32 i=0; i<newNum; i++)
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error occured in insertion region "<< name() <<
|
||||
" while converting shapes to diameter. \n";
|
||||
return false;
|
||||
uint32 idx;
|
||||
shapes_.shapeNameToIndex(names[i], idx);
|
||||
diams[i] = shapes_.boundingDiameter(idx);
|
||||
}
|
||||
|
||||
size_t n = 0;
|
||||
uint32 idx;
|
||||
auto& mix = mixture();
|
||||
auto& pReg = pRegion();
|
||||
word name = mix.getNextShapeName();
|
||||
shapes_.shapeNameToIndex(name, idx);
|
||||
real d = shapes_.boundingDiameter(idx);
|
||||
|
||||
for(label iter=0; iter< 10*newNum ; ++iter)
|
||||
for(uint32 i=0; i< 100*newNum ; ++i)
|
||||
{
|
||||
if( !(n < newNum) )
|
||||
{
|
||||
addToNumInserted(newNum);
|
||||
insertionOccured = true;
|
||||
return true;
|
||||
}
|
||||
realx3 p = pRegion_().peek();
|
||||
real d = diams[pos.size()];
|
||||
|
||||
realx3 p = pReg.peek();
|
||||
if( !checkForContact(pos, diams, p, d) )
|
||||
{
|
||||
names.push_back(name);
|
||||
pos.push_back(p);
|
||||
diams.push_back(d);
|
||||
n++;
|
||||
|
||||
if( n == newNum )
|
||||
{
|
||||
addToNumInserted(newNum);
|
||||
insertionOccured = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
name = mix.getNextShapeName();
|
||||
shapes_.shapeNameToIndex(name, idx);
|
||||
d = shapes_.boundingDiameter(idx);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fatalErrorInFunction<<
|
||||
" Cannot insert "<< newNum << " new particles from region "<< name()<<". \n"
|
||||
" pFlow could position only "<< n<< " particles in this region. \n";
|
||||
addToNumInserted(n);
|
||||
insertionOccured = false;
|
||||
insertionOccured = true;
|
||||
return false;
|
||||
|
||||
}
|
@ -2,17 +2,17 @@
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
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
|
||||
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
|
||||
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.
|
||||
|
||||
@ -21,93 +21,70 @@ Licence:
|
||||
#ifndef __InsertionRegion_hpp__
|
||||
#define __InsertionRegion_hpp__
|
||||
|
||||
|
||||
#include "insertionRegion.hpp"
|
||||
#include "dictionary.hpp"
|
||||
#include "insertionRegion.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
/**
|
||||
* This manages insertion of particles from a region based on the ShapeType
|
||||
*
|
||||
*
|
||||
*/
|
||||
template<typename ShapeType>
|
||||
class InsertionRegion
|
||||
:
|
||||
public insertionRegion
|
||||
class InsertionRegion
|
||||
: public insertionRegion
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
/// Ref to Shapes
|
||||
const ShapeType& shapes_;
|
||||
const ShapeType& shapes_;
|
||||
|
||||
static bool checkForContact(
|
||||
const realx3Vector& pos,
|
||||
const realVector& diams,
|
||||
const realx3& p,
|
||||
const real& d);
|
||||
static bool checkForContact(
|
||||
const realx3Vector& pos,
|
||||
const realVector& diams,
|
||||
const realx3& p,
|
||||
const real& d
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
/// Type info
|
||||
TypeInfoTemplateNV("insertionRegion", ShapeType);
|
||||
TypeInfoTemplateNV11("insertionRegion", ShapeType);
|
||||
|
||||
// - Constructors
|
||||
|
||||
/// Construct from dictionary
|
||||
InsertionRegion(const dictionary& dict, const ShapeType& shapes);
|
||||
/// Construct from dictionary
|
||||
InsertionRegion(
|
||||
const word& name,
|
||||
const insertion& instn,
|
||||
const ShapeType& shapes
|
||||
);
|
||||
|
||||
/// Copy
|
||||
InsertionRegion(const InsertionRegion<ShapeType>& ) = default;
|
||||
|
||||
/// Move
|
||||
InsertionRegion(InsertionRegion<ShapeType>&&) = default;
|
||||
|
||||
/// Copy assignment
|
||||
InsertionRegion<ShapeType>& operator=(const InsertionRegion<ShapeType>& ) = default;
|
||||
|
||||
/// Copy assignment
|
||||
InsertionRegion<ShapeType>& operator=(InsertionRegion<ShapeType>&&) = default;
|
||||
|
||||
/// Clone
|
||||
auto clone()const
|
||||
{
|
||||
return makeUnique<InsertionRegion<ShapeType>>(*this);
|
||||
}
|
||||
|
||||
/// Clone ptr
|
||||
auto clonePtr()const
|
||||
{
|
||||
return new InsertionRegion<ShapeType>(*this);
|
||||
}
|
||||
~InsertionRegion() = default;
|
||||
|
||||
// - Methods
|
||||
|
||||
/// Insert particles at currentTime
|
||||
/// Check if currentTime is the right moment for
|
||||
/// particle insertion. Fill the vectors name, pos and signal
|
||||
/// if particle insertion occured or not.
|
||||
bool insertParticles
|
||||
(
|
||||
real currentTime,
|
||||
real dt,
|
||||
wordVector& names,
|
||||
realx3Vector& pos,
|
||||
bool& insertionOccured
|
||||
);
|
||||
|
||||
//bool read(const dictionary& dict);
|
||||
/// Insert particles at current time t
|
||||
/// Check if currentTime is the right moment for
|
||||
/// particle insertion. Fill the vectors name, pos and signal
|
||||
/// if particle insertion occured or not.
|
||||
bool insertParticles(
|
||||
uint32 iter,
|
||||
real t,
|
||||
real dt,
|
||||
wordVector& names,
|
||||
realx3Vector& pos,
|
||||
bool& insertionOccured
|
||||
);
|
||||
|
||||
//bool write(dictionary& dict)const;
|
||||
// bool read(const dictionary& dict);
|
||||
|
||||
// bool write(dictionary& dict)const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
||||
#include "InsertionRegion.cpp"
|
||||
|
||||
#endif
|
||||
|
@ -2,73 +2,96 @@
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
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
|
||||
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
|
||||
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 "particles.hpp"
|
||||
#include "dictionary.hpp"
|
||||
#include "insertion.hpp"
|
||||
#include "particles.hpp"
|
||||
#include "streams.hpp"
|
||||
#include "systemControl.hpp"
|
||||
#include "vocabs.hpp"
|
||||
|
||||
bool pFlow::insertion::readInsertionDict
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
pFlow::insertion::insertion(particles& prtcl)
|
||||
: fileDictionary(
|
||||
objectFile(
|
||||
insertionFile__,
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
&prtcl.control().caseSetup()
|
||||
),
|
||||
particles_(prtcl)
|
||||
{
|
||||
readInsertionDict(*this);
|
||||
}
|
||||
|
||||
bool
|
||||
pFlow::insertion::read(iIstream& is, const IOPattern& iop)
|
||||
{
|
||||
if (fileDictionary::read(is, iop))
|
||||
{
|
||||
readFromFile_ = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
pFlow::insertion::readInsertionDict(const dictionary& dict)
|
||||
{
|
||||
active_ = dict.getVal<Logical>("active");
|
||||
|
||||
if(active_)
|
||||
REPORT(1)<< "Particle insertion mechanism is "<<
|
||||
yellowText("active")<<" in the simulation."<<endREPORT;
|
||||
if (active_)
|
||||
{
|
||||
REPORT(1) << "Particle insertion mechanism is " << Yellow_Text("active")
|
||||
<< " in the simulation." << END_REPORT;
|
||||
}
|
||||
else
|
||||
REPORT(1)<< "Particle insertion mechanism is "<<
|
||||
yellowText("not active")<<" in the simulation."<<endREPORT;
|
||||
|
||||
|
||||
{
|
||||
REPORT(1) << "Particle insertion mechanism is "
|
||||
<< Yellow_Text("not active") << " in the simulation."
|
||||
<< END_REPORT;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
bool pFlow::insertion::writeInsertionDict
|
||||
(
|
||||
dictionary& dict
|
||||
dictionary& dict
|
||||
)const
|
||||
{
|
||||
if(!dict.add("active", active_) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing active to dictionary "<<dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
if(!dict.add("active", active_) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing active to dictionary
|
||||
"<<dict.globalName()<<endl; return false;
|
||||
}
|
||||
|
||||
if(!dict.add("checkForCollision", checkForCollision_) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing checkForCollision to dictionary "<<dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
if(!dict.add("checkForCollision", checkForCollision_) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing checkForCollision to
|
||||
dictionary
|
||||
"<<dict.globalName()<<endl; return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pFlow::insertion::insertion
|
||||
(
|
||||
particles& prtcl
|
||||
)
|
||||
:
|
||||
particles_(prtcl)
|
||||
{}
|
||||
return true;
|
||||
}*/
|
@ -2,56 +2,59 @@
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
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
|
||||
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
|
||||
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 __insertion_hpp__
|
||||
#define __insertion_hpp__
|
||||
|
||||
#include "types.hpp"
|
||||
#include "virtualConstructor.hpp"
|
||||
#include "fileDictionary.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
// forward
|
||||
class particles;
|
||||
class dictionary;
|
||||
|
||||
/**
|
||||
* Base class for particle insertion
|
||||
*/
|
||||
class insertion
|
||||
class insertion : public fileDictionary
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Is insertion active
|
||||
Logical active_ = "No";
|
||||
private:
|
||||
|
||||
/// Is insertion active
|
||||
Logical active_ = "No";
|
||||
|
||||
/// Check for collision? It is not active now
|
||||
Logical checkForCollision_ = "No";
|
||||
Logical checkForCollision_ = "No";
|
||||
|
||||
/// Ref to particles
|
||||
particles& particles_;
|
||||
/// if increase velocity in case particles are failed
|
||||
/// to be inserted due to collision
|
||||
Logical increaseVelocity_ = "No";
|
||||
|
||||
/// Ref to particles
|
||||
particles& particles_;
|
||||
|
||||
bool readFromFile_ = false;
|
||||
|
||||
/// Read from dictionary
|
||||
bool readInsertionDict(const dictionary& dict);
|
||||
bool readInsertionDict(const dictionary& dict);
|
||||
|
||||
/// Write to dictionary
|
||||
bool writeInsertionDict(dictionary& dict)const;
|
||||
// bool writeInsertionDict(dictionary& dict)const;
|
||||
|
||||
public:
|
||||
|
||||
@ -59,24 +62,47 @@ public:
|
||||
TypeInfo("insertion");
|
||||
|
||||
/// Construct from component
|
||||
insertion(particles& prtcl);
|
||||
explicit insertion(particles& prtcl);
|
||||
|
||||
/// Destructor
|
||||
virtual ~insertion() = default;
|
||||
/// Destructor
|
||||
~insertion() override = default;
|
||||
|
||||
/// is Insertion active
|
||||
bool isActive()const {
|
||||
/// is Insertion active
|
||||
inline bool isActive() const
|
||||
{
|
||||
return active_();
|
||||
}
|
||||
|
||||
/// read from iIstream
|
||||
inline bool checkForCollision() const
|
||||
{
|
||||
return checkForCollision_();
|
||||
}
|
||||
|
||||
inline particles& Particles()
|
||||
{
|
||||
return particles_;
|
||||
}
|
||||
|
||||
inline const particles& Particles() const
|
||||
{
|
||||
return particles_;
|
||||
}
|
||||
|
||||
inline bool readFromFile() const
|
||||
{
|
||||
return readFromFile_;
|
||||
}
|
||||
|
||||
/// read from stream
|
||||
bool read(iIstream& is, const IOPattern& iop) override;
|
||||
|
||||
/*/// read from iIstream
|
||||
virtual bool read(iIstream& is) = 0;
|
||||
|
||||
/// write to iOstream
|
||||
virtual bool write(iOstream& os)const = 0;
|
||||
|
||||
|
||||
virtual bool write(iOstream& os)const = 0;*/
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -2,138 +2,180 @@
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
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
|
||||
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
|
||||
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 "insertionRegion.hpp"
|
||||
#include "dictionary.hpp"
|
||||
#include "insertion.hpp"
|
||||
#include "particles.hpp"
|
||||
#include "twoPartEntry.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
bool pFlow::insertionRegion::readInsertionRegion
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
namespace pFlow
|
||||
{
|
||||
template<typename T>
|
||||
bool
|
||||
setOneEntry(const twoPartEntry& tpEntry, anyList& varList)
|
||||
{
|
||||
if (getTypeName<T>() != tpEntry.firstPart())
|
||||
return false;
|
||||
|
||||
name_ = dict.name();
|
||||
type_ = dict.getVal<word>("type");
|
||||
|
||||
pRegion_ = peakableRegion::create(type_, dict.subDict(type_+"Info"));
|
||||
|
||||
mixture_ = makeUnique<shapeMixture>(dict.subDict("mixture"));
|
||||
T val = tpEntry.secondPartVal<T>();
|
||||
varList.emplaceBack(tpEntry.keyword(), val);
|
||||
|
||||
addToNumInserted(mixture_().totalInserted());
|
||||
return true;
|
||||
}
|
||||
|
||||
if( !dict.containsDictionay("setFields"))
|
||||
bool
|
||||
readOneEtrty(const dataEntry& entry, anyList& varList)
|
||||
{
|
||||
twoPartEntry stField(entry);
|
||||
|
||||
if (!(setOneEntry<real>(stField, varList) ||
|
||||
setOneEntry<realx3>(stField, varList) ||
|
||||
setOneEntry<realx4>(stField, varList) ||
|
||||
setOneEntry<int8>(stField, varList) ||
|
||||
setOneEntry<uint8>(stField, varList) ||
|
||||
setOneEntry<uint32>(stField, varList) ||
|
||||
setOneEntry<uint64>(stField, varList) ||
|
||||
setOneEntry<int32>(stField, varList) ||
|
||||
setOneEntry<int64>(stField, varList)))
|
||||
{
|
||||
output<<"\n insertion region "<< name_ << " does not contain setFields dictionary."
|
||||
" An empty dictoiinary is created for it. \n";
|
||||
setFields_ = makeUnique<setFieldList>( dictionary("setFields") );
|
||||
fatalErrorInFunction << "un-supported data type " << stField.firstPart()
|
||||
<< endl;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
pFlow::insertionRegion::readInsertionRegion(const dictionary& dict)
|
||||
{
|
||||
type_ = dict.getVal<word>("regionType");
|
||||
|
||||
rate_ = dict.getVal<real>("rate");
|
||||
|
||||
pRegion_ = peakableRegion::create(type_, dict.subDict(type_ + "Info"));
|
||||
|
||||
mixture_ = makeUnique<shapeMixture>(
|
||||
dict.subDict("mixture"),
|
||||
insertion_.Particles().getShapes().shapeNameList()
|
||||
);
|
||||
|
||||
numInserted_ = mixture_().totalInserted();
|
||||
|
||||
if (dict.containsDictionay("setFields"))
|
||||
{
|
||||
setFields_ = makeUnique<setFieldList>( dict.subDict("setFields") );
|
||||
setFieldDict_ =
|
||||
makeUnique<dictionary>("setFields", dict, dict.subDict("setFields"));
|
||||
}
|
||||
|
||||
for(auto& sfEntry:setFields_())
|
||||
if (setFieldDict_)
|
||||
{
|
||||
if(!sfEntry.checkForTypeAndValueAll())
|
||||
if (!readSetFieldDict())
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in setFields dictionary "<< dict.globalName()<<endl;
|
||||
fatalErrorInFunction << "Error in reading dictionary "
|
||||
<< setFieldDict_().globalName() << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::insertionRegion::writeInsertionRegion
|
||||
(
|
||||
dictionary& dict
|
||||
) const
|
||||
bool
|
||||
pFlow::insertionRegion::writeInsertionRegion(dictionary& dict) const
|
||||
{
|
||||
|
||||
if(!dict.add("type", type_)) return false;
|
||||
|
||||
if (!dict.add("type", type_))
|
||||
return false;
|
||||
|
||||
if(pRegion_)
|
||||
if (pRegion_)
|
||||
{
|
||||
auto& prDict = dict.subDictOrCreate(type_+"Info");
|
||||
if(!pRegion_().write(prDict)) return false;
|
||||
auto& prDict = dict.subDictOrCreate(type_ + "Info");
|
||||
if (!pRegion_().write(prDict))
|
||||
return false;
|
||||
}
|
||||
|
||||
if(mixture_)
|
||||
if (mixture_)
|
||||
{
|
||||
auto& mixDict = dict.subDictOrCreate("mixture");
|
||||
if(!mixture_().write(mixDict)) return false;
|
||||
if (!mixture_().write(mixDict))
|
||||
return false;
|
||||
}
|
||||
|
||||
if(setFields_)
|
||||
/*if(setFields_)
|
||||
{
|
||||
auto& sfDict = dict.subDictOrCreate("setFields");
|
||||
setFields_().write(sfDict);
|
||||
auto& sfDict = dict.subDictOrCreate("setFields");
|
||||
setFields_().write(sfDict);
|
||||
}*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
pFlow::insertionRegion::readSetFieldDict()
|
||||
{
|
||||
wordList Keys = setFieldDict_().dataEntryKeywords();
|
||||
|
||||
for (const auto& key : Keys)
|
||||
{
|
||||
if (!readOneEtrty(setFieldDict_().dataEntryRef(key), setFieldList_))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pFlow::insertionRegion::insertionRegion
|
||||
(
|
||||
const dictionary& dict
|
||||
pFlow::insertionRegion::insertionRegion(
|
||||
const word& name,
|
||||
const insertion& instn
|
||||
)
|
||||
:
|
||||
timeFlowControl(dict)
|
||||
: name_(name),
|
||||
dict_(instn.subDict(name)),
|
||||
insertion_(instn),
|
||||
tControl_(dict_, "insertion")
|
||||
{
|
||||
|
||||
if(!readInsertionRegion(dict))
|
||||
if (!readInsertionRegion(dict_))
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
pFlow::insertionRegion::insertionRegion
|
||||
(
|
||||
const insertionRegion& src
|
||||
)
|
||||
:
|
||||
timeFlowControl(src),
|
||||
name_(src.name_),
|
||||
type_(src.type_),
|
||||
pRegion_( src.pRegion_? src.pRegion_->clone(): nullptr),
|
||||
mixture_( src.mixture_? src.mixture_->clone(): nullptr),
|
||||
setFields_( src.setFields_? src.setFields_->clone(): nullptr)
|
||||
{}
|
||||
|
||||
pFlow::insertionRegion& pFlow::insertionRegion::operator=
|
||||
(
|
||||
const insertionRegion& src
|
||||
)
|
||||
pFlow::uint32
|
||||
pFlow::insertionRegion::numberToBeInserted(uint32 iter, real t, real dt)
|
||||
{
|
||||
if (!tControl_.isInRange(iter, t, dt))
|
||||
return 0u;
|
||||
|
||||
if(&src == this)return *this;
|
||||
timeFlowControl::operator=(src);
|
||||
|
||||
name_ = src.name_;
|
||||
type_ = src.type_;
|
||||
pRegion_ = (src.pRegion_? src.pRegion_->clone(): nullptr);
|
||||
mixture_ = (src.mixture_? src.mixture_->clone(): nullptr);
|
||||
setFields_ = (src.setFields_? src.setFields_->clone(): nullptr);
|
||||
|
||||
return *this;
|
||||
if (tControl_.isTimeStep())
|
||||
{
|
||||
return static_cast<uint32>(
|
||||
(iter - tControl_.startIter() + tControl_.iInterval()) * dt * rate_ -
|
||||
numInserted_
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return static_cast<uint32>(
|
||||
(t - tControl_.startTime() + tControl_.rInterval()) * rate_ -
|
||||
numInserted_
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,17 +2,17 @@
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
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
|
||||
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
|
||||
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.
|
||||
|
||||
@ -21,52 +21,54 @@ Licence:
|
||||
#ifndef __insertionRegion_hpp__
|
||||
#define __insertionRegion_hpp__
|
||||
|
||||
#include "timeFlowControl.hpp"
|
||||
#include "anyList.hpp"
|
||||
#include "baseTimeControl.hpp"
|
||||
#include "peakableRegion.hpp"
|
||||
#include "shapeMixture.hpp"
|
||||
#include "peakableRegions.hpp"
|
||||
#include "setFieldList.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class dictionary;
|
||||
class insertion;
|
||||
|
||||
/**
|
||||
* This class defines all the necessary enteties for defining an insertion
|
||||
* region.
|
||||
*
|
||||
* Insertion region information are supplied through a dictionary in a file.
|
||||
* region.
|
||||
*
|
||||
* Insertion region information are supplied through a dictionary in a file.
|
||||
* For example:
|
||||
\verbatim
|
||||
{
|
||||
type cylinderRegion; // type of insertion region
|
||||
rate 15000; // insertion rate (particles/s)
|
||||
startTime 0; // (s)
|
||||
endTime 0.5; // (s)
|
||||
interval 0.025; // (s)
|
||||
type cylinderRegion; // type of insertion region
|
||||
rate 15000; // insertion rate (particles/s)
|
||||
startTime 0; // (s)
|
||||
endTime 0.5; // (s)
|
||||
interval 0.025; // (s)
|
||||
|
||||
cylinderRegionInfo
|
||||
{
|
||||
radius 0.09; // radius of cylinder (m)
|
||||
p1 (0.0 0.0 0.10); // (m,m,m)
|
||||
p2 (0.0 0.0 0.11); // (m,m,m)
|
||||
}
|
||||
|
||||
setFields
|
||||
{
|
||||
velocity realx3 (0.0 0.0 -0.6); // initial velocity of inserted particles
|
||||
}
|
||||
|
||||
mixture
|
||||
{
|
||||
lightSphere 1; // mixture composition of inserted particles
|
||||
}
|
||||
cylinderRegionInfo
|
||||
{
|
||||
radius 0.09; // radius of cylinder (m)
|
||||
p1 (0.0 0.0 0.10); // (m,m,m)
|
||||
p2 (0.0 0.0 0.11); // (m,m,m)
|
||||
}
|
||||
|
||||
setFields
|
||||
{
|
||||
velocity realx3 (0.0 0.0 -0.6); // initial velocity of inserted
|
||||
particles
|
||||
}
|
||||
|
||||
mixture
|
||||
{
|
||||
lightSphere 1; // mixture composition of inserted particles
|
||||
}
|
||||
} \endverbatim
|
||||
*
|
||||
*
|
||||
* More information on the above dictionary entries can be found in
|
||||
* the table below.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* | Parameter | Type | Description | Optional [default value] |
|
||||
* |----| :---: | ---- | ---- |
|
||||
* | type | word | type of the insertion region with name ### | No |
|
||||
@ -75,31 +77,51 @@ class dictionary;
|
||||
* | endTime | real | end of insertion (s) | No |
|
||||
* | interval | real | time interval between successive insertions (s) | No |
|
||||
* | ###Info | dictionary | data for insertion region | No |
|
||||
* | setFields | dictionary | set field for inserted particles (s) | Yes [empty dictionray] |
|
||||
* | setFields | dictionary | set field for inserted particles (s) | Yes [empty
|
||||
dictionray] |
|
||||
* | mixture | dictionary | mixture of particles to be inserted (s) | No |
|
||||
*
|
||||
*
|
||||
*/
|
||||
class insertionRegion
|
||||
:
|
||||
public timeFlowControl
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
/// name of the region
|
||||
word name_;
|
||||
/// name of this region
|
||||
const word name_;
|
||||
|
||||
/// insertion region dictionary
|
||||
const dictionary& dict_;
|
||||
|
||||
/// ref to pointStructure
|
||||
const insertion& insertion_;
|
||||
|
||||
/// @brief time control for insertion events
|
||||
baseTimeControl tControl_;
|
||||
|
||||
/// rate of insertion
|
||||
real rate_;
|
||||
|
||||
/// number of inserted particles
|
||||
uint32 numInserted_ = 0;
|
||||
|
||||
/// type of insertion region
|
||||
word type_;
|
||||
word type_;
|
||||
|
||||
/// peakable region of points
|
||||
uniquePtr<peakableRegion> pRegion_ = nullptr;
|
||||
uniquePtr<peakableRegion> pRegion_ = nullptr;
|
||||
|
||||
/// mixture of shapes
|
||||
uniquePtr<shapeMixture> mixture_ = nullptr;
|
||||
/// mixture of shapes
|
||||
uniquePtr<shapeMixture> mixture_ = nullptr;
|
||||
|
||||
/// setFields for insertion region
|
||||
uniquePtr<setFieldList> setFields_ = nullptr;
|
||||
/// @brief dictionary for set field
|
||||
uniquePtr<dictionary> setFieldDict_ = nullptr;
|
||||
|
||||
/// list of (filedName type value) for the fields
|
||||
anyList setFieldList_;
|
||||
|
||||
private:
|
||||
|
||||
// - private methods
|
||||
|
||||
/// read from dictionary
|
||||
bool readInsertionRegion(const dictionary& dict);
|
||||
@ -107,6 +129,7 @@ protected:
|
||||
/// write to dictionary
|
||||
bool writeInsertionRegion(dictionary& dict) const;
|
||||
|
||||
bool readSetFieldDict();
|
||||
|
||||
public:
|
||||
|
||||
@ -115,58 +138,83 @@ public:
|
||||
|
||||
// - Constructors
|
||||
|
||||
/// Construct from a dictionary
|
||||
insertionRegion(const dictionary& dict);
|
||||
/// Construct from a dictionary
|
||||
insertionRegion(const word& name, const insertion& instn);
|
||||
|
||||
/// Copy
|
||||
insertionRegion(const insertionRegion& src);
|
||||
/// Destructor
|
||||
~insertionRegion() = default;
|
||||
|
||||
/// Move
|
||||
insertionRegion(insertionRegion&&) = default;
|
||||
// - Methods
|
||||
|
||||
/// Copy assignment
|
||||
insertionRegion& operator=(const insertionRegion&);
|
||||
/// Const ref to name of the region
|
||||
const auto& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
/// Move assignment
|
||||
insertionRegion& operator=(insertionRegion&&) = default;
|
||||
/// return type of insertion region
|
||||
const auto& type() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
~insertionRegion() = default;
|
||||
const auto& Insertion() const
|
||||
{
|
||||
return insertion_;
|
||||
}
|
||||
|
||||
inline bool insertionTime(uint32 iter, real t, real dt) const
|
||||
{
|
||||
return tControl_.timeEvent(iter, t, dt);
|
||||
}
|
||||
|
||||
// - Methods
|
||||
uint32 numberToBeInserted(uint32 iter, real t, real dt);
|
||||
|
||||
/// Const ref to setFields
|
||||
const auto& setFields()const
|
||||
{
|
||||
return setFields_();
|
||||
}
|
||||
inline uint32 addToNumInserted(uint32 newInserted)
|
||||
{
|
||||
return numInserted_ += newInserted;
|
||||
}
|
||||
|
||||
/// Const ref to name of the region
|
||||
const auto& name()const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
inline uint32 totalInserted() const
|
||||
{
|
||||
return numInserted_;
|
||||
}
|
||||
|
||||
auto& mixture()
|
||||
{
|
||||
return mixture_();
|
||||
}
|
||||
|
||||
auto& pRegion()
|
||||
{
|
||||
return pRegion_();
|
||||
}
|
||||
|
||||
const auto& setFieldList() const
|
||||
{
|
||||
return setFieldList_;
|
||||
}
|
||||
// - IO operation
|
||||
|
||||
/// read from dictionary
|
||||
bool read(const dictionary& dict)
|
||||
{
|
||||
if(!timeFlowControl::read(dict))return false;
|
||||
/// read from dictionary
|
||||
/*bool read(const dictionary& dict)
|
||||
{
|
||||
if (!timeFlowControl::read(dict))
|
||||
return false;
|
||||
|
||||
return readInsertionRegion(dict);
|
||||
}
|
||||
return readInsertionRegion(dict);
|
||||
}
|
||||
|
||||
/// write to dictionary
|
||||
bool write(dictionary& dict)const
|
||||
{
|
||||
if(!timeFlowControl::write(dict)) return false;
|
||||
/// write to dictionary
|
||||
bool write(dictionary& dict) const
|
||||
{
|
||||
if (!timeFlowControl::write(dict))
|
||||
return false;
|
||||
|
||||
return writeInsertionRegion(dict);
|
||||
}
|
||||
return writeInsertionRegion(dict);
|
||||
}*/
|
||||
};
|
||||
|
||||
} //pFlow
|
||||
} // pFlow
|
||||
|
||||
#endif //__insertionRegion_hpp__
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*------------------------------- 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 "timeFlowControl.hpp"
|
||||
#include "dictionary.hpp"
|
||||
|
||||
size_t pFlow::timeFlowControl::numberToBeInserted(real currentTime)
|
||||
{
|
||||
if(currentTime<startTime_)return 0;
|
||||
if(currentTime>endTime_) return 0;
|
||||
|
||||
return static_cast<size_t>
|
||||
(
|
||||
(currentTime - startTime_ + interval_)*rate_ - numInserted_
|
||||
);
|
||||
}
|
||||
|
||||
bool pFlow::timeFlowControl::readTimeFlowControl
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
rate_ = dict.getVal<real>("rate");
|
||||
startTime_ = dict.getVal<real>("startTime");
|
||||
endTime_ = dict.getVal<real>("endTime");
|
||||
interval_ = dict.getVal<real>("interval");
|
||||
numInserted_=0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::timeFlowControl::writeTimeFlowControl
|
||||
(
|
||||
dictionary& dict
|
||||
) const
|
||||
{
|
||||
if(!dict.add("rate", rate_)) return false;
|
||||
if(!dict.add("startTime", startTime_)) return false;
|
||||
if(!dict.add("endTime", endTime_)) return false;
|
||||
if(!dict.add("interval", interval_)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
pFlow::timeFlowControl::timeFlowControl
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
|
||||
if(!readTimeFlowControl(dict))
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::timeFlowControl::insertionTime( real currentTime, real dt)
|
||||
{
|
||||
if(currentTime < startTime_) return false;
|
||||
|
||||
if(currentTime > endTime_) return false;
|
||||
if( mod(abs(currentTime-startTime_),interval_)/dt < 1 ) return true;
|
||||
|
||||
return false;
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
/*------------------------------- 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 __timeFlowControl_hpp__
|
||||
#define __timeFlowControl_hpp__
|
||||
|
||||
#include "types.hpp"
|
||||
#include "streams.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class dictionary;
|
||||
|
||||
/**
|
||||
* Time control for particle insertion
|
||||
*/
|
||||
class timeFlowControl
|
||||
{
|
||||
protected:
|
||||
|
||||
/// start time of insertion
|
||||
real startTime_;
|
||||
|
||||
/// end time of insertion
|
||||
real endTime_;
|
||||
|
||||
/// time interval between each insertion
|
||||
real interval_;
|
||||
|
||||
/// rate of insertion
|
||||
real rate_;
|
||||
|
||||
/// number of inserted particles
|
||||
size_t numInserted_ = 0;
|
||||
|
||||
|
||||
/// Read dictionary
|
||||
bool readTimeFlowControl(const dictionary& dict);
|
||||
|
||||
/// Write to dictionary
|
||||
bool writeTimeFlowControl(dictionary& dict) const;
|
||||
|
||||
/// Return number of particles to be inserted at time currentTime
|
||||
size_t numberToBeInserted(real currentTime);
|
||||
|
||||
/// Add to numInserted
|
||||
inline
|
||||
size_t addToNumInserted(size_t newInserted)
|
||||
{
|
||||
return numInserted_ += newInserted;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/// Construct from dictionary
|
||||
timeFlowControl(const dictionary& dict);
|
||||
|
||||
/// Is currentTime the insertion moment?
|
||||
bool insertionTime( real currentTime, real dt);
|
||||
|
||||
/// Total number inserted so far
|
||||
size_t totalInserted()const
|
||||
{
|
||||
return numInserted_;
|
||||
}
|
||||
|
||||
/// Read from dictionary
|
||||
bool read(const dictionary& dict)
|
||||
{
|
||||
return readTimeFlowControl(dict);
|
||||
}
|
||||
|
||||
/// Write to dictionary
|
||||
bool write(dictionary& dict)const
|
||||
{
|
||||
return writeTimeFlowControl(dict);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //__timeFlowControl_hpp__
|
@ -2,150 +2,167 @@
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
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
|
||||
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
|
||||
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 "shapeMixture.hpp"
|
||||
#include "dictionary.hpp"
|
||||
|
||||
|
||||
pFlow::shapeMixture::shapeMixture
|
||||
(
|
||||
const dictionary & dict
|
||||
pFlow::shapeMixture::shapeMixture(
|
||||
const dictionary& dict,
|
||||
const wordList& validNames
|
||||
)
|
||||
{
|
||||
if( !read(dict))
|
||||
if (!read(dict))
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
for (const auto& rN : names_)
|
||||
{
|
||||
bool found = false;
|
||||
for (const auto& vN : validNames)
|
||||
{
|
||||
if (rN == vN)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
fatalErrorInFunction
|
||||
<< "Shape name " << rN << " provided in mixture dictionary "
|
||||
<< dict.globalName() << " is invalid. \n Valid names are "
|
||||
<< validNames << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pFlow::word pFlow::shapeMixture::getNextShapeName()
|
||||
pFlow::word
|
||||
pFlow::shapeMixture::getNextShapeName()
|
||||
{
|
||||
|
||||
ForAll(i, names_)
|
||||
{
|
||||
if(current_[i]< number_[i])
|
||||
if (current_[i] < number_[i])
|
||||
{
|
||||
current_[i]++;
|
||||
numberInserted_[i]++;
|
||||
return names_[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fill(current_, static_cast<uint32>(0));
|
||||
return getNextShapeName();
|
||||
}
|
||||
|
||||
void pFlow::shapeMixture::getNextShapeNameN
|
||||
(
|
||||
size_t n,
|
||||
wordVector& names
|
||||
)
|
||||
void
|
||||
pFlow::shapeMixture::getNextShapeNameN(size_t n, wordVector& names)
|
||||
{
|
||||
names.clear();
|
||||
|
||||
|
||||
for(label i=0; i<n; ++i)
|
||||
for (size_t i = 0u; i < n; ++i)
|
||||
{
|
||||
names.push_back( getNextShapeName() );
|
||||
names.push_back(getNextShapeName());
|
||||
}
|
||||
}
|
||||
|
||||
bool pFlow::shapeMixture::read(const dictionary& dict)
|
||||
bool
|
||||
pFlow::shapeMixture::read(const dictionary& dict)
|
||||
{
|
||||
|
||||
bool containNumberIneserted = false;
|
||||
|
||||
|
||||
auto shNames = dict.dataEntryKeywords();
|
||||
|
||||
for (auto nm = shNames.begin(); nm != shNames.end(); )
|
||||
for (auto nm = shNames.begin(); nm != shNames.end();)
|
||||
{
|
||||
if ( *nm == "numberInserted")
|
||||
{
|
||||
nm = shNames.erase(nm);
|
||||
containNumberIneserted = true;
|
||||
}
|
||||
else
|
||||
++nm;
|
||||
}
|
||||
if (*nm == "numberInserted")
|
||||
{
|
||||
nm = shNames.erase(nm);
|
||||
containNumberIneserted = true;
|
||||
}
|
||||
else
|
||||
++nm;
|
||||
}
|
||||
|
||||
for(const auto& nm:shNames)
|
||||
{
|
||||
names_.push_back(nm);
|
||||
uint32 num = dict.getVal<uint32>(nm);
|
||||
if( num <= 0 )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" number inserte in front of "<< nm << " is invalid: "<< num<<endl<<
|
||||
" in dictionary "<<dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
number_.push_back( num );
|
||||
}
|
||||
for (const auto& nm : shNames)
|
||||
{
|
||||
names_.push_back(nm);
|
||||
uint32 num = dict.getVal<uint32>(nm);
|
||||
if (num <= 0)
|
||||
{
|
||||
fatalErrorInFunction << " number inserte in front of " << nm
|
||||
<< " is invalid: " << num << endl
|
||||
<< " in dictionary " << dict.globalName()
|
||||
<< endl;
|
||||
return false;
|
||||
}
|
||||
number_.push_back(num);
|
||||
}
|
||||
|
||||
if(containNumberIneserted)
|
||||
{
|
||||
numberInserted_ = dict.getVal<uint32Vector>("numberInserted");
|
||||
}
|
||||
else
|
||||
{
|
||||
numberInserted_ = uint32Vector(size(), static_cast<uint32>(0));
|
||||
}
|
||||
if (containNumberIneserted)
|
||||
{
|
||||
numberInserted_ = dict.getVal<uint32Vector>("numberInserted");
|
||||
}
|
||||
else
|
||||
{
|
||||
numberInserted_ =
|
||||
uint32Vector(numberInserted_.name(), size(), static_cast<uint32>(0));
|
||||
}
|
||||
|
||||
if(numberInserted_.size() != names_.size() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" number of elements in numberInserted ("<<numberInserted_.size()<<
|
||||
") is not equal to the number of shape names: "<< names_<<endl;
|
||||
return false;
|
||||
}
|
||||
if (numberInserted_.size() != names_.size())
|
||||
{
|
||||
fatalErrorInFunction
|
||||
<< " number of elements in numberInserted ("
|
||||
<< numberInserted_.size()
|
||||
<< ") is not equal to the number of shape names: " << names_ << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
current_.clear();
|
||||
ForAll(i, numberInserted_)
|
||||
{
|
||||
current_.push_back(numberInserted_[i]%number_[i]);
|
||||
}
|
||||
current_.clear();
|
||||
ForAll(i, numberInserted_)
|
||||
{
|
||||
current_.push_back(numberInserted_[i] % number_[i]);
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::shapeMixture::write
|
||||
(
|
||||
dictionary& dict
|
||||
) const
|
||||
bool
|
||||
pFlow::shapeMixture::write(dictionary& dict) const
|
||||
{
|
||||
|
||||
ForAll(i, names_)
|
||||
{
|
||||
if(!dict.add(names_[i],number_[i]))
|
||||
if (!dict.add(names_[i], number_[i]))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing "<< names_[i] << " to dictionary "<<dict.globalName()<<endl;
|
||||
fatalErrorInFunction << " error in writing " << names_[i]
|
||||
<< " to dictionary " << dict.globalName()
|
||||
<< endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!dict.add("numberInserted", numberInserted_))
|
||||
if (!dict.add("numberInserted", numberInserted_))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing numberInserted to dictionary "<< dict.globalName()<<endl;
|
||||
fatalErrorInFunction
|
||||
<< " error in writing numberInserted to dictionary "
|
||||
<< dict.globalName() << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -21,8 +21,8 @@ Licence:
|
||||
#ifndef __shapeMixture_hpp__
|
||||
#define __shapeMixture_hpp__
|
||||
|
||||
|
||||
#include "Vectors.hpp"
|
||||
#include "Lists.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
@ -46,19 +46,19 @@ class dictionary;
|
||||
*/
|
||||
class shapeMixture
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
/// List of shape names
|
||||
wordVector names_;
|
||||
wordVector names_{"shapeNames"};
|
||||
|
||||
/// Number composition
|
||||
uint32Vector number_;
|
||||
uint32Vector number_{"number"};
|
||||
|
||||
/// Number of inserted particles of each shape
|
||||
uint32Vector numberInserted_;
|
||||
uint32Vector numberInserted_{"numberInserted"};
|
||||
|
||||
/// Current number of inserted
|
||||
uint32Vector current_;
|
||||
uint32Vector current_{"currentInserted"};
|
||||
|
||||
public:
|
||||
|
||||
@ -68,7 +68,7 @@ public:
|
||||
// - Constrcutors
|
||||
|
||||
/// Construct from dictionary
|
||||
shapeMixture(const dictionary & dict);
|
||||
shapeMixture(const dictionary & dict, const wordList& validNames);
|
||||
|
||||
/// Copy
|
||||
shapeMixture(const shapeMixture&) = default;
|
||||
@ -88,13 +88,6 @@ public:
|
||||
return makeUnique<shapeMixture>(*this);
|
||||
}
|
||||
|
||||
/// Polymorphic copy
|
||||
shapeMixture* clonePtr()const
|
||||
{
|
||||
return new shapeMixture(*this);
|
||||
}
|
||||
|
||||
|
||||
/// Destructor
|
||||
~shapeMixture() = default;
|
||||
|
||||
|
@ -198,7 +198,7 @@ bool pFlow::sphereParticles::initializeParticles()
|
||||
|
||||
}*/
|
||||
|
||||
bool pFlow::sphereParticles::initInertia()
|
||||
bool pFlow::sphereParticles::initializeParticles()
|
||||
{
|
||||
|
||||
using exeSpace = typename realPointField_D::execution_space;
|
||||
@ -255,6 +255,55 @@ bool pFlow::sphereParticles::initInertia()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
pFlow::sphereParticles::getParticlesInfoFromShape(
|
||||
const wordVector& shapeNames,
|
||||
uint32Vector& propIds,
|
||||
realVector& diams,
|
||||
realVector& m,
|
||||
realVector& Is,
|
||||
uint32Vector& shIndex
|
||||
)
|
||||
{
|
||||
auto numNew = static_cast<uint32>(shapeNames.size());
|
||||
|
||||
propIds.clear();
|
||||
propIds.reserve(numNew);
|
||||
|
||||
diams.clear();
|
||||
diams.reserve(numNew);
|
||||
|
||||
m.clear();
|
||||
m.reserve(numNew);
|
||||
|
||||
Is.clear();
|
||||
Is.reserve(numNew);
|
||||
|
||||
shIndex.clear();
|
||||
shIndex.reserve(numNew);
|
||||
|
||||
|
||||
for(const auto& name:shapeNames)
|
||||
{
|
||||
uint32 indx;
|
||||
if(spheres_.shapeNameToIndex(name,indx))
|
||||
{
|
||||
shIndex.push_back(indx);
|
||||
Is.push_back( spheres_.Inertia(indx));
|
||||
m.push_back(spheres_.mass(indx));
|
||||
diams.push_back(spheres_.boundingDiameter(indx));
|
||||
propIds.push_back( spheres_.propertyId(indx));
|
||||
}
|
||||
else
|
||||
{
|
||||
fatalErrorInFunction<<"Shape name "<< name <<
|
||||
"does not exist. The list is "<<spheres_.shapeNameList()<<endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pFlow::sphereParticles::sphereParticles(
|
||||
systemControl &control,
|
||||
@ -364,7 +413,7 @@ pFlow::sphereParticles::sphereParticles(
|
||||
|
||||
WARNING<<"setFields for rVelIntegration_"<<END_WARNING;
|
||||
|
||||
if(!initInertia())
|
||||
if(!initializeParticles())
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
fatalExit;
|
||||
@ -504,6 +553,59 @@ bool pFlow::sphereParticles::iterate()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::sphereParticles::insertParticles
|
||||
(
|
||||
const realx3Vector &position,
|
||||
const wordVector &shapesNames,
|
||||
const anyList &setVarList
|
||||
)
|
||||
{
|
||||
anyList newVarList(setVarList);
|
||||
|
||||
realVector mass("mass");
|
||||
realVector I("I");
|
||||
realVector diameter("diameter");
|
||||
uint32Vector propId("propId");
|
||||
uint32Vector shapeIdx("shapeIdx");
|
||||
|
||||
if(!getParticlesInfoFromShape(
|
||||
shapesNames,
|
||||
propId,
|
||||
diameter,
|
||||
mass,
|
||||
I,
|
||||
shapeIdx))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
newVarList.emplaceBack(
|
||||
mass_.name()+"Vector",
|
||||
std::move(mass));
|
||||
|
||||
newVarList.emplaceBack(
|
||||
I_.name()+"Vector",
|
||||
std::move(I));
|
||||
|
||||
newVarList.emplaceBack(
|
||||
diameter_.name()+"Vector",
|
||||
std::move(diameter));
|
||||
|
||||
newVarList.emplaceBack(
|
||||
propertyId_.name()+"Vector",
|
||||
std::move(propId));
|
||||
|
||||
newVarList.emplaceBack(
|
||||
shapeIndex().name()+"Vector",
|
||||
std::move(shapeIdx));
|
||||
|
||||
if(!dynPointStruct().insertPoints(position, newVarList))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pFlow::word pFlow::sphereParticles::shapeTypeName()const
|
||||
{
|
||||
|
@ -2,189 +2,195 @@
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
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
|
||||
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
|
||||
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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
/**
|
||||
/**
|
||||
* @class pFlow::sphereParticles
|
||||
*
|
||||
* @brief Class for managing spherical particles
|
||||
*
|
||||
*
|
||||
* @brief Class for managing spherical particles
|
||||
*
|
||||
* This is a top-level class that contains the essential components for
|
||||
* defining spherical prticles in a DEM simulation.
|
||||
*/
|
||||
|
||||
#ifndef __sphereParticles_hpp__
|
||||
#define __sphereParticles_hpp__
|
||||
#define __sphereParticles_hpp__
|
||||
|
||||
#include "systemControl.hpp"
|
||||
#include "particles.hpp"
|
||||
#include "sphereShape.hpp"
|
||||
#include "property.hpp"
|
||||
#include "indexContainer.hpp"
|
||||
|
||||
|
||||
#include "particles.hpp"
|
||||
#include "property.hpp"
|
||||
#include "sphereShape.hpp"
|
||||
#include "systemControl.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class sphereParticles
|
||||
:
|
||||
public particles
|
||||
class sphereParticles : public particles
|
||||
{
|
||||
public:
|
||||
|
||||
using ShapeType = sphereShape;
|
||||
|
||||
private:
|
||||
|
||||
/// reference to shapes
|
||||
ShapeType spheres_;
|
||||
/// reference to shapes
|
||||
ShapeType spheres_;
|
||||
|
||||
/// property id on device
|
||||
uint32PointField_D propertyId_;
|
||||
uint32PointField_D propertyId_;
|
||||
|
||||
/// diameter / boundig sphere size of particles on device
|
||||
realPointField_D diameter_;
|
||||
realPointField_D diameter_;
|
||||
|
||||
/// mass of particles field
|
||||
realPointField_D mass_;
|
||||
/// mass of particles field
|
||||
realPointField_D mass_;
|
||||
|
||||
/// pointField of inertial of particles
|
||||
realPointField_D I_;
|
||||
/// pointField of inertial of particles
|
||||
realPointField_D I_;
|
||||
|
||||
/// pointField of rotational Velocity of particles on device
|
||||
realx3PointField_D rVelocity_;
|
||||
/// pointField of rotational Velocity of particles on device
|
||||
realx3PointField_D rVelocity_;
|
||||
|
||||
/// pointField of rotational acceleration of particles on device
|
||||
realx3PointField_D rAcceleration_;
|
||||
/// pointField of rotational acceleration of particles on device
|
||||
realx3PointField_D rAcceleration_;
|
||||
|
||||
/// rotational velocity integrator
|
||||
uniquePtr<integration> rVelIntegration_ = nullptr;
|
||||
/// rotational velocity integrator
|
||||
uniquePtr<integration> rVelIntegration_ = nullptr;
|
||||
|
||||
/// timer for acceleration computations
|
||||
Timer accelerationTimer_;
|
||||
/// timer for acceleration computations
|
||||
Timer accelerationTimer_;
|
||||
|
||||
/// timer for integration computations (prediction step)
|
||||
Timer intPredictTimer_;
|
||||
Timer intPredictTimer_;
|
||||
|
||||
/// timer for integration computations (correction step)
|
||||
Timer intCorrectTimer_;
|
||||
Timer intCorrectTimer_;
|
||||
|
||||
bool initInertia();
|
||||
|
||||
|
||||
private:
|
||||
bool initializeParticles();
|
||||
|
||||
bool getParticlesInfoFromShape(
|
||||
const wordVector& shapeNames,
|
||||
uint32Vector& propIds,
|
||||
realVector& diams,
|
||||
realVector& m,
|
||||
realVector& Is,
|
||||
uint32Vector& shIndex
|
||||
);
|
||||
/*bool initializeParticles();
|
||||
|
||||
bool insertSphereParticles(
|
||||
const wordVector& names,
|
||||
const int32IndexContainer& indices,
|
||||
bool setId = true);
|
||||
const wordVector& names,
|
||||
const int32IndexContainer& indices,
|
||||
bool setId = true);
|
||||
|
||||
virtual uniquePtr<List<eventObserver*>> getFieldObjectList()const override;
|
||||
*/
|
||||
|
||||
public:
|
||||
|
||||
/// construct from systemControl and property
|
||||
sphereParticles(
|
||||
systemControl &control,
|
||||
const property& prop);
|
||||
/// construct from systemControl and property
|
||||
sphereParticles(systemControl& control, const property& prop);
|
||||
|
||||
|
||||
~sphereParticles()override=default;
|
||||
~sphereParticles() override = default;
|
||||
|
||||
/**
|
||||
* Insert new particles in position with specified shapes
|
||||
*
|
||||
* This function is involked by inserted object to insert new set of particles
|
||||
* into the simulation.
|
||||
* \param position position of new particles
|
||||
*
|
||||
* This function is involked by inserted object to insert new set of
|
||||
* particles into the simulation. \param position position of new particles
|
||||
* \param shape shape of new particles
|
||||
* \param setField initial value of the selected fields for new particles
|
||||
*/
|
||||
/*bool insertParticles
|
||||
(
|
||||
const realx3Vector& position,
|
||||
const wordVector& shapes,
|
||||
const setFieldList& setField
|
||||
const realx3Vector& position,
|
||||
const wordVector& shapes,
|
||||
const setFieldList& setField
|
||||
) override ;*/
|
||||
|
||||
/// const reference to shapes object
|
||||
const auto& spheres()const
|
||||
/// const reference to shapes object
|
||||
const auto& spheres() const
|
||||
{
|
||||
return spheres_;
|
||||
}
|
||||
|
||||
/// const reference to inertia pointField
|
||||
const auto& I()const
|
||||
const auto& I() const
|
||||
{
|
||||
return I_;
|
||||
}
|
||||
|
||||
/// reference to inertia pointField
|
||||
/// reference to inertia pointField
|
||||
auto& I()
|
||||
{
|
||||
return I_;
|
||||
}
|
||||
|
||||
const auto& rVelocity()const
|
||||
{
|
||||
|
||||
const auto& rVelocity() const
|
||||
{
|
||||
return rVelocity_;
|
||||
}
|
||||
|
||||
auto& rVelocity()
|
||||
{
|
||||
{
|
||||
return rVelocity_;
|
||||
}
|
||||
|
||||
bool hearChanges
|
||||
(
|
||||
real t,
|
||||
real dt,
|
||||
uint32 iter,
|
||||
const message& msg,
|
||||
const anyList& varList
|
||||
bool hearChanges(
|
||||
real t,
|
||||
real dt,
|
||||
uint32 iter,
|
||||
const message& msg,
|
||||
const anyList& varList
|
||||
) override
|
||||
{
|
||||
notImplementedFunction;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const uint32PointField_D& propertyId()const override
|
||||
const uint32PointField_D& propertyId() const override
|
||||
{
|
||||
return propertyId_;
|
||||
}
|
||||
|
||||
|
||||
const realPointField_D& diameter()const override
|
||||
|
||||
const realPointField_D& diameter() const override
|
||||
{
|
||||
return diameter_;
|
||||
}
|
||||
|
||||
|
||||
const realPointField_D& mass()const override
|
||||
const realPointField_D& mass() const override
|
||||
{
|
||||
return mass_;
|
||||
}
|
||||
|
||||
/// before iteration step
|
||||
|
||||
/// before iteration step
|
||||
bool beforeIteration() override;
|
||||
|
||||
/// iterate particles
|
||||
bool iterate() override;
|
||||
/// iterate particles
|
||||
bool iterate() override;
|
||||
|
||||
bool insertParticles(
|
||||
const realx3Vector& position,
|
||||
const wordVector& shapesNames,
|
||||
const anyList& setVarList
|
||||
) override;
|
||||
|
||||
|
||||
realx3PointField_D& rAcceleration() override
|
||||
{
|
||||
return rAcceleration_;
|
||||
@ -194,20 +200,19 @@ public:
|
||||
{
|
||||
return rAcceleration_;
|
||||
}
|
||||
|
||||
const realPointField_D& boundingSphere()const override
|
||||
|
||||
const realPointField_D& boundingSphere() const override
|
||||
{
|
||||
return diameter();
|
||||
}
|
||||
|
||||
word shapeTypeName()const override;
|
||||
|
||||
const shape& getShapes()const override;
|
||||
word shapeTypeName() const override;
|
||||
|
||||
|
||||
void boundingSphereMinMax(real & minDiam, real& maxDiam)const override;
|
||||
|
||||
}; //sphereParticles
|
||||
const shape& getShapes() const override;
|
||||
|
||||
void boundingSphereMinMax(real& minDiam, real& maxDiam) const override;
|
||||
|
||||
}; // sphereParticles
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
@ -78,20 +78,6 @@ pFlow::dynamicPointStructure::dynamicPointStructure
|
||||
|
||||
}
|
||||
|
||||
/*bool pFlow::dynamicPointStructure::beforeIteration()
|
||||
{
|
||||
pointStructure::beforeIteration();
|
||||
auto& acc = time().lookupObject<realx3PointField_D>("acceleration");
|
||||
return predict(dt(), acc);
|
||||
}*/
|
||||
|
||||
/*bool pFlow::dynamicPointStructure::iterate()
|
||||
{
|
||||
pointStructure::iterate();
|
||||
auto& acc = time().lookupObject<realx3PointField_D>("acceleration");
|
||||
return correct(dt(), acc);
|
||||
|
||||
}*/
|
||||
|
||||
bool pFlow::dynamicPointStructure::beforeIteration()
|
||||
{
|
||||
@ -137,74 +123,3 @@ bool pFlow::dynamicPointStructure::correct
|
||||
|
||||
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_.hostView();
|
||||
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().hostView();
|
||||
const auto hPos = pStruct().pointPosition().hostView();
|
||||
|
||||
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;
|
||||
}*/
|
@ -87,11 +87,10 @@ public:
|
||||
/// when the component should evolve along time.
|
||||
bool iterate() override;
|
||||
|
||||
|
||||
|
||||
|
||||
/// prediction step (if any), is called in beforeIteration
|
||||
bool predict(real dt, realx3PointField_D& acceleration);
|
||||
|
||||
/// correction step, is called in iterate
|
||||
bool correct(real dt, realx3PointField_D& acceleration);
|
||||
|
||||
};
|
||||
|
@ -1,47 +0,0 @@
|
||||
/*------------------------------- 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 __demParticles_hpp__
|
||||
#define __demParticles_hpp__
|
||||
|
||||
#include "demComponent.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
class demParticles
|
||||
:
|
||||
public demComponent
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
demParticles(systemControl& control):
|
||||
demComponent("particles", control)
|
||||
{}
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -20,25 +20,69 @@ Licence:
|
||||
|
||||
#include "particleIdHandler.hpp"
|
||||
|
||||
pFlow::particleIdHandler::particleIdHandler(uint32PointField_D &id)
|
||||
pFlow::particleIdHandler::particleIdHandler(pointStructure& pStruct)
|
||||
:
|
||||
id_(id)
|
||||
uint32PointField_D
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"id",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct,
|
||||
static_cast<uint32>(-1),
|
||||
static_cast<uint32>(-1)
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
pFlow::uniquePtr<pFlow::particleIdHandler>
|
||||
pFlow::particleIdHandler::create(uint32PointField_D &id)
|
||||
bool
|
||||
pFlow::particleIdHandler::hearChanges(
|
||||
real t,
|
||||
real dt,
|
||||
uint32 iter,
|
||||
const message& msg,
|
||||
const anyList& varList
|
||||
)
|
||||
{
|
||||
if(msg.equivalentTo(message::ITEM_INSERT))
|
||||
{
|
||||
const word eventName = message::eventName(message::ITEM_INSERT);
|
||||
|
||||
const auto& indices = varList.getObject<uint32IndexContainer>(
|
||||
eventName);
|
||||
|
||||
uint32 numNew = indices.size();
|
||||
if(numNew == 0u)return true;
|
||||
|
||||
auto idRange = getIdRange(numNew);
|
||||
uint32Vector newId("newId",numNew,numNew,RESERVE());
|
||||
fillSequence(newId, idRange.first);
|
||||
output<< "id "<< idRange<<endl;
|
||||
return this->field().insertSetElement(indices, newId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return uint32PointField_D::hearChanges(t,dt,iter, msg,varList);
|
||||
}
|
||||
}
|
||||
|
||||
pFlow::uniquePtr<pFlow::particleIdHandler>
|
||||
pFlow::particleIdHandler::create(pointStructure& pStruct)
|
||||
{
|
||||
word idHType = angleBracketsNames(
|
||||
"particleIdHandler",
|
||||
pFlowProcessors().localRunTypeName());
|
||||
|
||||
|
||||
if( pointFieldvCtorSelector_.search(idHType) )
|
||||
if( pointStructurevCtorSelector_.search(idHType) )
|
||||
{
|
||||
REPORT(1)<<"Creating particle id handler "<<
|
||||
Green_Text(idHType)<<END_REPORT;
|
||||
return pointFieldvCtorSelector_[idHType] (id);
|
||||
return pointStructurevCtorSelector_[idHType] (pStruct);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -47,7 +91,7 @@ pFlow::uniquePtr<pFlow::particleIdHandler>
|
||||
fatalError << "Ctor Selector "<< idHType << " dose not exist. \n"
|
||||
<<"Avaiable ones are: \n\n"
|
||||
,
|
||||
pointFieldvCtorSelector_
|
||||
pointStructurevCtorSelector_
|
||||
);
|
||||
fatalExit;
|
||||
}
|
@ -28,34 +28,26 @@ namespace pFlow
|
||||
{
|
||||
|
||||
class particleIdHandler
|
||||
:
|
||||
public uint32PointField_D
|
||||
{
|
||||
private:
|
||||
|
||||
uint32PointField_D& id_;
|
||||
|
||||
protected:
|
||||
|
||||
auto& id()
|
||||
{
|
||||
return id_;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo("particleIdHandler");
|
||||
/// class info
|
||||
ClassInfo("particleIdHandler");
|
||||
|
||||
explicit particleIdHandler(uint32PointField_D & id);
|
||||
explicit particleIdHandler(pointStructure& pStruct);
|
||||
|
||||
create_vCtor
|
||||
(
|
||||
particleIdHandler,
|
||||
pointField,
|
||||
(uint32PointField_D & id),
|
||||
(id)
|
||||
pointStructure,
|
||||
(pointStructure& pStruct),
|
||||
(pStruct)
|
||||
);
|
||||
|
||||
virtual
|
||||
~particleIdHandler()=default;
|
||||
~particleIdHandler()override=default;
|
||||
|
||||
virtual
|
||||
Pair<uint32, uint32> getIdRange(uint32 nNewParticles)=0;
|
||||
@ -63,9 +55,20 @@ public:
|
||||
virtual
|
||||
bool initialIdCheck()=0;
|
||||
|
||||
// heat change for possible insertion of particles
|
||||
// overrdie from internalField
|
||||
bool hearChanges
|
||||
(
|
||||
real t,
|
||||
real dt,
|
||||
uint32 iter,
|
||||
const message& msg,
|
||||
const anyList& varList
|
||||
) override;
|
||||
|
||||
static
|
||||
uniquePtr<particleIdHandler> create(
|
||||
uint32PointField_D & id);
|
||||
pointStructure& pStruct);
|
||||
|
||||
};
|
||||
|
@ -2,119 +2,111 @@
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
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
|
||||
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
|
||||
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 "particles.hpp"
|
||||
|
||||
|
||||
pFlow::particles::particles
|
||||
(
|
||||
systemControl &control
|
||||
)
|
||||
:
|
||||
observer(defaultMessage_),
|
||||
demComponent("particles", control),
|
||||
dynPointStruct_(control),
|
||||
id_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"id",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
dynPointStruct_,
|
||||
static_cast<uint32>(-1),
|
||||
static_cast<uint32>(-1)
|
||||
),
|
||||
shapeIndex_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"shapeIndex",
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
dynPointStruct_,
|
||||
0
|
||||
),
|
||||
accelertion_
|
||||
(
|
||||
objectFile(
|
||||
"accelertion",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS),
|
||||
dynPointStruct_,
|
||||
zero3
|
||||
),
|
||||
contactForce_(
|
||||
objectFile(
|
||||
"contactForce",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS),
|
||||
dynPointStruct_,
|
||||
zero3),
|
||||
contactTorque_(
|
||||
objectFile(
|
||||
"contactTorque",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS),
|
||||
dynPointStruct_,
|
||||
zero3),
|
||||
idHandler_(particleIdHandler::create(id_))
|
||||
pFlow::particles::particles(systemControl& control)
|
||||
: observer(defaultMessage_),
|
||||
demComponent("particles", control),
|
||||
dynPointStruct_(control),
|
||||
/*id_(
|
||||
objectFile(
|
||||
"id",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
dynPointStruct_,
|
||||
static_cast<uint32>(-1),
|
||||
static_cast<uint32>(-1)
|
||||
),*/
|
||||
shapeIndex_(
|
||||
objectFile(
|
||||
"shapeIndex",
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
dynPointStruct_,
|
||||
0
|
||||
),
|
||||
accelertion_(
|
||||
objectFile(
|
||||
"accelertion",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
dynPointStruct_,
|
||||
zero3
|
||||
),
|
||||
contactForce_(
|
||||
objectFile(
|
||||
"contactForce",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
dynPointStruct_,
|
||||
zero3
|
||||
),
|
||||
contactTorque_(
|
||||
objectFile(
|
||||
"contactTorque",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
dynPointStruct_,
|
||||
zero3
|
||||
),
|
||||
idHandler_(particleIdHandler::create(dynPointStruct_))
|
||||
{
|
||||
this->addToSubscriber(dynPointStruct_);
|
||||
|
||||
idHandler_().initialIdCheck();
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::particles::beforeIteration()
|
||||
bool
|
||||
pFlow::particles::beforeIteration()
|
||||
{
|
||||
|
||||
zeroForce();
|
||||
zeroTorque();
|
||||
|
||||
return dynPointStruct_.beforeIteration();
|
||||
}
|
||||
|
||||
bool pFlow::particles::iterate()
|
||||
bool
|
||||
pFlow::particles::iterate()
|
||||
{
|
||||
return dynPointStruct_.iterate();
|
||||
}
|
||||
|
||||
bool pFlow::particles::afterIteration()
|
||||
bool
|
||||
pFlow::particles::afterIteration()
|
||||
{
|
||||
return dynPointStruct_.afterIteration();
|
||||
}
|
||||
|
||||
void pFlow::particles::boundingSphereMinMax
|
||||
(
|
||||
real &minDiam,
|
||||
real &maxDiam
|
||||
) const
|
||||
void
|
||||
pFlow::particles::boundingSphereMinMax(real& minDiam, real& maxDiam) const
|
||||
{
|
||||
auto& shp = getShapes();
|
||||
|
||||
minDiam = shp.minBoundingSphere();
|
||||
maxDiam = shp.maxBoundingSphere();
|
||||
}
|
||||
}
|
||||
|
@ -1,66 +1,63 @@
|
||||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
/*------------------------------- 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.
|
||||
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 __particles_hpp__
|
||||
#define __particles_hpp__
|
||||
|
||||
#include "dynamicPointStructure.hpp"
|
||||
#include "demComponent.hpp"
|
||||
#include "shape.hpp"
|
||||
#include "dynamicPointStructure.hpp"
|
||||
#include "particleIdHandler.hpp"
|
||||
#include "shape.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class particles
|
||||
:
|
||||
public observer,
|
||||
public demComponent
|
||||
: public observer
|
||||
, public demComponent
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
/// dynamic point structure for particles center mass
|
||||
dynamicPointStructure dynPointStruct_;
|
||||
dynamicPointStructure dynPointStruct_;
|
||||
|
||||
/// id of particles on host
|
||||
uint32PointField_D id_;
|
||||
|
||||
|
||||
uint32PointField_D shapeIndex_;
|
||||
/// shape index of each particle
|
||||
uint32PointField_D shapeIndex_;
|
||||
|
||||
/// acceleration on device
|
||||
realx3PointField_D accelertion_;
|
||||
realx3PointField_D accelertion_;
|
||||
|
||||
/// contact force field
|
||||
realx3PointField_D contactForce_;
|
||||
realx3PointField_D contactForce_;
|
||||
|
||||
/// contact torque field
|
||||
realx3PointField_D contactTorque_;
|
||||
realx3PointField_D contactTorque_;
|
||||
|
||||
/// handling new ids for new particles
|
||||
uniquePtr<particleIdHandler> idHandler_ = nullptr;
|
||||
|
||||
static inline
|
||||
const message defaultMessage_{message::DEFAULT};
|
||||
|
||||
|
||||
/// messages for this objects
|
||||
static inline const message defaultMessage_{ message::DEFAULT };
|
||||
|
||||
protected:
|
||||
|
||||
void zeroForce()
|
||||
{
|
||||
@ -72,8 +69,6 @@ private:
|
||||
contactTorque_.fill(zero3);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
inline auto& dynPointStruct()
|
||||
{
|
||||
return dynPointStruct_;
|
||||
@ -81,17 +76,15 @@ protected:
|
||||
|
||||
inline auto& pointPosition()
|
||||
{
|
||||
return dynPointStruct_.pointPosition();
|
||||
return dynPointStruct_.pointPosition();
|
||||
}
|
||||
|
||||
/*inline
|
||||
auto& velocity()
|
||||
inline auto& idHandler()
|
||||
{
|
||||
return dynPointStruct_.velocity();
|
||||
}*/
|
||||
|
||||
inline
|
||||
auto& shapeIndex()
|
||||
return idHandler_();
|
||||
}
|
||||
|
||||
inline auto& shapeIndex()
|
||||
{
|
||||
return shapeIndex_;
|
||||
}
|
||||
@ -103,148 +96,123 @@ public:
|
||||
|
||||
explicit particles(systemControl& control);
|
||||
|
||||
|
||||
inline
|
||||
const auto& dynPointStruct()const
|
||||
inline const auto& dynPointStruct() const
|
||||
{
|
||||
return dynPointStruct_;
|
||||
}
|
||||
|
||||
inline
|
||||
const pointStructure& pStruct()const
|
||||
inline const pointStructure& pStruct() const
|
||||
{
|
||||
return dynPointStruct_;
|
||||
}
|
||||
|
||||
inline
|
||||
const auto& simDomain()const
|
||||
inline const auto& simDomain() const
|
||||
{
|
||||
return dynPointStruct_.simDomain();
|
||||
}
|
||||
|
||||
inline
|
||||
const auto& thisDomain()const
|
||||
inline const auto& thisDomain() const
|
||||
{
|
||||
return dynPointStruct_.thisDomain();
|
||||
}
|
||||
|
||||
inline
|
||||
const auto& extendedDomain()const
|
||||
inline const auto& extendedDomain() const
|
||||
{
|
||||
return dynPointStruct_.extendedDomain();
|
||||
}
|
||||
|
||||
inline auto size()const{
|
||||
inline auto size() const
|
||||
{
|
||||
return dynPointStruct_.size();
|
||||
}
|
||||
|
||||
inline auto capacity() const{
|
||||
inline auto capacity() const
|
||||
{
|
||||
return dynPointStruct_.capacity();
|
||||
}
|
||||
|
||||
inline auto numActive()const
|
||||
|
||||
inline auto numActive() const
|
||||
{
|
||||
return dynPointStruct_.numActive();
|
||||
}
|
||||
|
||||
inline bool isAllActive()const
|
||||
|
||||
inline bool isAllActive() const
|
||||
{
|
||||
return dynPointStruct_.isAllActive();
|
||||
}
|
||||
|
||||
inline
|
||||
const auto& pointPosition()const
|
||||
inline const auto& pointPosition() const
|
||||
{
|
||||
return dynPointStruct_.pointPosition();
|
||||
}
|
||||
|
||||
inline
|
||||
const auto& velocity()const
|
||||
inline const auto& velocity() const
|
||||
{
|
||||
return dynPointStruct_.velocity();
|
||||
}
|
||||
|
||||
inline
|
||||
const auto& accelertion()const
|
||||
inline const auto& accelertion() const
|
||||
{
|
||||
return accelertion_;
|
||||
}
|
||||
|
||||
inline
|
||||
auto& accelertion()
|
||||
inline auto& accelertion()
|
||||
{
|
||||
return accelertion_;
|
||||
}
|
||||
|
||||
inline
|
||||
auto& contactForce()
|
||||
inline auto& contactForce()
|
||||
{
|
||||
return contactForce_;
|
||||
}
|
||||
|
||||
inline
|
||||
const auto& contactForce() const
|
||||
inline const auto& contactForce() const
|
||||
{
|
||||
return contactForce_;
|
||||
}
|
||||
|
||||
inline
|
||||
auto& contactTorque()
|
||||
inline auto& contactTorque()
|
||||
{
|
||||
return contactTorque_;
|
||||
}
|
||||
|
||||
inline
|
||||
const auto& contactTorque() const
|
||||
inline const auto& contactTorque() const
|
||||
{
|
||||
return contactTorque_;
|
||||
}
|
||||
|
||||
bool beforeIteration() override;
|
||||
bool beforeIteration() override;
|
||||
|
||||
bool iterate()override;
|
||||
bool iterate() override;
|
||||
|
||||
bool afterIteration() override;
|
||||
bool afterIteration() override;
|
||||
|
||||
/*virtual
|
||||
bool insertParticles
|
||||
(
|
||||
const realx3Vector& position,
|
||||
const wordVector& shapes,
|
||||
const setFieldList& setField
|
||||
) = 0;*/
|
||||
virtual bool insertParticles(
|
||||
const realx3Vector& position,
|
||||
const wordVector& shapesNames,
|
||||
const anyList& setVarList
|
||||
) = 0;
|
||||
|
||||
virtual
|
||||
const uint32PointField_D& propertyId()const = 0;
|
||||
|
||||
virtual
|
||||
const realPointField_D& diameter()const = 0;
|
||||
virtual const uint32PointField_D& propertyId() const = 0;
|
||||
|
||||
virtual
|
||||
const realPointField_D& mass()const = 0;
|
||||
virtual const realPointField_D& diameter() const = 0;
|
||||
|
||||
virtual
|
||||
realx3PointField_D& rAcceleration() = 0;
|
||||
virtual const realPointField_D& mass() const = 0;
|
||||
|
||||
virtual
|
||||
const realx3PointField_D& rAcceleration() const = 0;
|
||||
virtual realx3PointField_D& rAcceleration() = 0;
|
||||
|
||||
virtual
|
||||
const realPointField_D& boundingSphere()const = 0;
|
||||
virtual const realx3PointField_D& rAcceleration() const = 0;
|
||||
|
||||
virtual
|
||||
word shapeTypeName()const = 0;
|
||||
virtual const realPointField_D& boundingSphere() const = 0;
|
||||
|
||||
virtual
|
||||
const shape& getShapes()const = 0;
|
||||
virtual word shapeTypeName() const = 0;
|
||||
|
||||
virtual
|
||||
void boundingSphereMinMax(real & minDiam, real& maxDiam)const = 0;
|
||||
virtual const shape& getShapes() const = 0;
|
||||
|
||||
|
||||
virtual void boundingSphereMinMax(real& minDiam, real& maxDiam) const = 0;
|
||||
|
||||
}; // particles
|
||||
|
||||
} // pFlow
|
||||
} // namespace pFlow
|
||||
|
||||
#endif //__particles_hpp__
|
||||
|
@ -1,18 +1,18 @@
|
||||
#include "regularParticleHandler.hpp"
|
||||
#include "regularParticleIdHandler.hpp"
|
||||
|
||||
|
||||
|
||||
pFlow::regularParticleHandler::regularParticleHandler
|
||||
pFlow::regularParticleIdHandler::regularParticleIdHandler
|
||||
(
|
||||
uint32PointField_D & id
|
||||
pointStructure& pStruct
|
||||
)
|
||||
:
|
||||
particleIdHandler(id)
|
||||
particleIdHandler(pStruct)
|
||||
{
|
||||
}
|
||||
|
||||
pFlow::Pair<pFlow::uint32, pFlow::uint32>
|
||||
pFlow::regularParticleHandler::getIdRange(uint32 nNewParticles)
|
||||
pFlow::regularParticleIdHandler::getIdRange(uint32 nNewParticles)
|
||||
{
|
||||
uint32 startId;
|
||||
if(maxId_==-1)
|
||||
@ -28,18 +28,18 @@ pFlow::Pair<pFlow::uint32, pFlow::uint32>
|
||||
return {startId, endId};
|
||||
}
|
||||
|
||||
bool pFlow::regularParticleHandler::initialIdCheck()
|
||||
bool pFlow::regularParticleIdHandler::initialIdCheck()
|
||||
{
|
||||
/// empty point structure / no particles in simulation
|
||||
if( id().pStruct().empty() ) return true;
|
||||
if( pStruct().empty() ) return true;
|
||||
|
||||
uint32 maxId = max(id());
|
||||
uint32 maxId = max( *this );
|
||||
|
||||
/// particles should get ids from 0 to size-1
|
||||
if(maxId == -1)
|
||||
{
|
||||
fillSequence(id(),0u);
|
||||
maxId_ = id().size()-1;
|
||||
fillSequence(*this,0u);
|
||||
maxId_ = size()-1;
|
||||
}
|
||||
else
|
||||
{
|
@ -17,15 +17,15 @@ Licence:
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
#ifndef __regularParticleHandler_hpp__
|
||||
#define __regularParticleHandler_hpp__
|
||||
#ifndef __regularParticleIdHandler_hpp__
|
||||
#define __regularParticleIdHandler_hpp__
|
||||
|
||||
#include "particleIdHandler.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class regularParticleHandler
|
||||
class regularParticleIdHandler
|
||||
:
|
||||
public particleIdHandler
|
||||
{
|
||||
@ -35,17 +35,17 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo("particleIdHandler<regular>");
|
||||
ClassInfo("particleIdHandler<regular>");
|
||||
|
||||
explicit regularParticleIdHandler(pointStructure& pStruct);
|
||||
|
||||
explicit regularParticleHandler(uint32PointField_D & id);
|
||||
|
||||
~regularParticleHandler()override = default;
|
||||
~regularParticleIdHandler()override = default;
|
||||
|
||||
add_vCtor
|
||||
(
|
||||
particleIdHandler,
|
||||
regularParticleHandler,
|
||||
pointField
|
||||
regularParticleIdHandler,
|
||||
pointStructure
|
||||
);
|
||||
|
||||
Pair<uint32, uint32> getIdRange(uint32 nNewParticles)override;
|
||||
@ -57,4 +57,4 @@ public:
|
||||
}
|
||||
|
||||
|
||||
#endif //__regularParticleHandler_hpp__
|
||||
#endif //__regularParticleIdHandler_hpp__
|
@ -122,6 +122,17 @@ public:
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
inline
|
||||
uint32 propertyId(uint32 index)const
|
||||
{
|
||||
if(indexValid(index))
|
||||
{
|
||||
return shapePropertyIds_[index];
|
||||
}
|
||||
fatalExit;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
virtual
|
||||
real maxBoundingSphere()const = 0;
|
||||
|
Reference in New Issue
Block a user