mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-07-08 03:07:03 +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:
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user