mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-07-08 03:07:03 +00:00
src folder
This commit is contained in:
204
src/Particles/Insertion/Insertion/Insertion.C
Normal file
204
src/Particles/Insertion/Insertion/Insertion.C
Normal file
@ -0,0 +1,204 @@
|
||||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
template<typename ShapeType>
|
||||
bool pFlow::Insertion<ShapeType>::readInsertionDict
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
if(!insertion::readInsertionDict(dict)) return false;
|
||||
|
||||
regions_.clear();
|
||||
|
||||
if( !this->isActive() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
wordList regionDicNames = dict.dictionaryKeywords();
|
||||
|
||||
for(auto& name:regionDicNames)
|
||||
{
|
||||
Report(2)<<"reading insertion region "<< greenText(name)<<endReport;
|
||||
regions_.push_backSafe(dict.subDict(name), shapes_);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename ShapeType>
|
||||
bool pFlow::Insertion<ShapeType>::writeInsertionDict
|
||||
(
|
||||
dictionary& dict
|
||||
)const
|
||||
{
|
||||
if( !insertion::writeInsertionDict(dict) ) return false;
|
||||
|
||||
if( !this->isActive() ) return true;
|
||||
|
||||
forAll(i,regions_)
|
||||
{
|
||||
auto& rgnDict = dict.subDictOrCreate(regions_[i].name());
|
||||
|
||||
if( !regions_[i].write(rgnDict) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename ShapeType>
|
||||
pFlow::Insertion<ShapeType>::Insertion
|
||||
(
|
||||
particles& prtcl,
|
||||
const ShapeType& shapes
|
||||
)
|
||||
:
|
||||
insertion(prtcl),
|
||||
shapes_(shapes)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
template<typename ShapeType>
|
||||
bool pFlow::Insertion<ShapeType>::insertParticles
|
||||
(
|
||||
real currentTime,
|
||||
real dt
|
||||
)
|
||||
{
|
||||
if(!isActive()) return true;
|
||||
|
||||
|
||||
forAll(i,regions_)
|
||||
{
|
||||
bool insertionOccured = false;
|
||||
auto& rgn = regions_[i];
|
||||
if( rgn.insertionTime(currentTime, dt) )
|
||||
{
|
||||
|
||||
realx3Vector pos;
|
||||
wordVector shapes;
|
||||
if( rgn.insertParticles(currentTime, 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;
|
||||
|
||||
if(!particles_.insertParticles(pos, shapes, rgn.setFields()))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" Cannot add "<< pos.size() << " particles from region "<< rgn.name() <<
|
||||
" to particles. \n";
|
||||
return false;
|
||||
}
|
||||
Report(1)<<"Total number of particles inserted from this region is "<<
|
||||
cyanText(rgn.totalInserted())<<'\n'<<endReport;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(insertionOccured)
|
||||
{
|
||||
Warning<< "\n fewer number of particles are inserted from region "<< rgn.name() <<
|
||||
" than expected. You may stop the simulation to change settings."<<endWarning;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in inserting particles from region "<< rgn.name()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<typename ShapeType>
|
||||
bool pFlow::Insertion<ShapeType>::read
|
||||
(
|
||||
iIstream& is
|
||||
)
|
||||
{
|
||||
|
||||
// create an empty dictionary
|
||||
dictionary dict(is.name(), true);
|
||||
|
||||
if(!dict.read(is))
|
||||
{
|
||||
ioErrorInFile( is.name(), is.lineNumber() )<<
|
||||
" error in reading "<< insertionFile__ << "dictionary from file."<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!readInsertionDict(dict))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in reading from dictionary "<<dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename ShapeType>
|
||||
bool pFlow::Insertion<ShapeType>::write
|
||||
(
|
||||
iOstream& os
|
||||
)const
|
||||
{
|
||||
|
||||
dictionary dict(insertionFile__,true);
|
||||
|
||||
if(! writeInsertionDict(dict) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing to " << dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !dict.write(os) )
|
||||
{
|
||||
ioErrorInFile(os.name(), os.lineNumber())<<
|
||||
" erro in writing to "<< os.name()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
70
src/Particles/Insertion/Insertion/Insertion.H
Normal file
70
src/Particles/Insertion/Insertion/Insertion.H
Normal file
@ -0,0 +1,70 @@
|
||||
/*------------------------------- 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 __Insertion_H__
|
||||
#define __Insertion_H__
|
||||
|
||||
|
||||
#include "insertion.H"
|
||||
#include "ListPtr.H"
|
||||
#include "InsertionRegion.H"
|
||||
#include "particles.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
template<typename ShapeType>
|
||||
class Insertion
|
||||
:
|
||||
public insertion
|
||||
{
|
||||
protected:
|
||||
|
||||
const ShapeType& shapes_;
|
||||
|
||||
// - insertion regions
|
||||
ListPtr<InsertionRegion<ShapeType>> regions_;
|
||||
|
||||
|
||||
bool readInsertionDict(const dictionary& dict);
|
||||
|
||||
bool writeInsertionDict(dictionary& dict)const;
|
||||
|
||||
public:
|
||||
|
||||
TypeNameTemplateNV("Insertion",ShapeType);
|
||||
|
||||
Insertion(particles& prtcl, const ShapeType& shapes);
|
||||
|
||||
|
||||
bool insertParticles(real currentTime, real dt);
|
||||
|
||||
virtual bool read(iIstream& is) override;
|
||||
|
||||
virtual bool write(iOstream& os)const override;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#include "Insertion.C"
|
||||
|
||||
#endif
|
24
src/Particles/Insertion/Insertion/Insertions.C
Normal file
24
src/Particles/Insertion/Insertion/Insertions.C
Normal file
@ -0,0 +1,24 @@
|
||||
/*------------------------------- 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 "Insertions.H"
|
||||
|
||||
template class pFlow::Insertion<pFlow::sphereShape>;
|
35
src/Particles/Insertion/Insertion/Insertions.H
Normal file
35
src/Particles/Insertion/Insertion/Insertions.H
Normal file
@ -0,0 +1,35 @@
|
||||
/*------------------------------- 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 __Insertions_H__
|
||||
#define __Insertions_H__
|
||||
|
||||
|
||||
#include "Insertion.H"
|
||||
#include "sphereShape.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
using sphereInsertion = Insertion<sphereShape> ;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
115
src/Particles/Insertion/InsertionRegion/InsertionRegion.C
Normal file
115
src/Particles/Insertion/InsertionRegion/InsertionRegion.C
Normal file
@ -0,0 +1,115 @@
|
||||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
template<typename ShapeType>
|
||||
bool pFlow::InsertionRegion<ShapeType>::checkForContact
|
||||
(
|
||||
const realx3Vector& pos,
|
||||
const realVector& diams,
|
||||
const realx3& p,
|
||||
const real& d
|
||||
)
|
||||
{
|
||||
|
||||
forAll(i, pos)
|
||||
{
|
||||
if( length(pos[i]-p) < 0.5*(diams[i]+d) ) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename ShapeType>
|
||||
pFlow::InsertionRegion<ShapeType>::InsertionRegion
|
||||
(
|
||||
const dictionary& dict,
|
||||
const ShapeType& shapes
|
||||
)
|
||||
:
|
||||
insertionRegion(dict),
|
||||
shapes_(shapes)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
template<typename ShapeType>
|
||||
bool pFlow::InsertionRegion<ShapeType>::insertParticles
|
||||
(
|
||||
real currentTime,
|
||||
real dt,
|
||||
wordVector& names,
|
||||
realx3Vector& pos,
|
||||
bool& insertionOccured
|
||||
)
|
||||
{
|
||||
insertionOccured = false;
|
||||
|
||||
if(!insertionTime( currentTime, dt)) return true;
|
||||
|
||||
size_t newNum = numberToBeInserted(currentTime);
|
||||
|
||||
if(newNum == 0) return true;
|
||||
|
||||
names.reserve(max(newNum,names.capacity()));
|
||||
pos.reserve(max(newNum,pos.capacity()));
|
||||
names.clear();
|
||||
pos.clear();
|
||||
|
||||
realVector diams(newNum, RESERVE());
|
||||
|
||||
mixture_->getNextShapeNameN(newNum, names);
|
||||
|
||||
if(!shapes_.shapeToDiameter(names,diams))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error occured in insertion region "<< name() <<
|
||||
" while converting shapes to diameter. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t n = 0;
|
||||
|
||||
for(label iter=0; iter< 10*newNum ; ++iter)
|
||||
{
|
||||
if( !(n < newNum) )
|
||||
{
|
||||
addToNumInserted(newNum);
|
||||
insertionOccured = true;
|
||||
return true;
|
||||
}
|
||||
realx3 p = pRegion_().peek();
|
||||
real d = diams[pos.size()];
|
||||
if( !checkForContact(pos, diams, p, d) )
|
||||
{
|
||||
pos.push_back(p);
|
||||
n++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fatalErrorInFunction<<
|
||||
" Cannot insert "<< newNum << " new particles from region "<< name()<<". \n"
|
||||
" pFlow could position only "<< n<< " particles in this region. \n";
|
||||
addToNumInserted(n);
|
||||
insertionOccured = false;
|
||||
return false;
|
||||
|
||||
}
|
95
src/Particles/Insertion/InsertionRegion/InsertionRegion.H
Normal file
95
src/Particles/Insertion/InsertionRegion/InsertionRegion.H
Normal file
@ -0,0 +1,95 @@
|
||||
/*------------------------------- 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 __InsertionRegion_H__
|
||||
#define __InsertionRegion_H__
|
||||
|
||||
|
||||
#include "insertionRegion.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
template<typename ShapeType>
|
||||
class InsertionRegion
|
||||
:
|
||||
public insertionRegion
|
||||
{
|
||||
protected:
|
||||
// - type of particle shapes
|
||||
const ShapeType& shapes_;
|
||||
|
||||
static bool checkForContact(
|
||||
const realx3Vector& pos,
|
||||
const realVector& diams,
|
||||
const realx3& p,
|
||||
const real& d);
|
||||
|
||||
public:
|
||||
|
||||
// - type info
|
||||
TypeNameTemplateNV("insertionRegion", ShapeType);
|
||||
|
||||
InsertionRegion(const dictionary& dict, const ShapeType& shapes);
|
||||
|
||||
InsertionRegion(const InsertionRegion<ShapeType>& ) = default;
|
||||
|
||||
InsertionRegion(InsertionRegion<ShapeType>&&) = default;
|
||||
|
||||
InsertionRegion<ShapeType>& operator=(const InsertionRegion<ShapeType>& ) = default;
|
||||
|
||||
InsertionRegion<ShapeType>& operator=(InsertionRegion<ShapeType>&&) = default;
|
||||
|
||||
|
||||
auto clone()const
|
||||
{
|
||||
return makeUnique<InsertionRegion<ShapeType>>(*this);
|
||||
}
|
||||
|
||||
auto clonePtr()const
|
||||
{
|
||||
return new InsertionRegion<ShapeType>(*this);
|
||||
}
|
||||
|
||||
|
||||
bool insertParticles
|
||||
(
|
||||
real currentTime,
|
||||
real dt,
|
||||
wordVector& names,
|
||||
realx3Vector& pos,
|
||||
bool& insertionOccured
|
||||
);
|
||||
|
||||
//bool read(const dictionary& dict);
|
||||
|
||||
//bool write(dictionary& dict)const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
||||
#include "InsertionRegion.C"
|
||||
|
||||
#endif
|
74
src/Particles/Insertion/insertion/insertion.C
Normal file
74
src/Particles/Insertion/insertion/insertion.C
Normal file
@ -0,0 +1,74 @@
|
||||
/*------------------------------- 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 "particles.H"
|
||||
#include "dictionary.H"
|
||||
#include "insertion.H"
|
||||
#include "streams.H"
|
||||
|
||||
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;
|
||||
else
|
||||
Report(1)<< "Particle insertion mechanism is "<<
|
||||
yellowText("not active")<<" in the simulation."<<endReport;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::insertion::writeInsertionDict
|
||||
(
|
||||
dictionary& dict
|
||||
)const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pFlow::insertion::insertion
|
||||
(
|
||||
particles& prtcl
|
||||
)
|
||||
:
|
||||
particles_(prtcl)
|
||||
{}
|
72
src/Particles/Insertion/insertion/insertion.H
Normal file
72
src/Particles/Insertion/insertion/insertion.H
Normal file
@ -0,0 +1,72 @@
|
||||
/*------------------------------- 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 __insertion_H__
|
||||
#define __insertion_H__
|
||||
|
||||
|
||||
#include "streams.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class particles;
|
||||
class dictionary;
|
||||
|
||||
class insertion
|
||||
{
|
||||
protected:
|
||||
// - insertion active
|
||||
Logical active_ = "No";
|
||||
|
||||
// - check for collision / desabled for now
|
||||
Logical checkForCollision_ = "No";
|
||||
|
||||
// - particles
|
||||
particles& particles_;
|
||||
|
||||
|
||||
bool readInsertionDict(const dictionary& dict);
|
||||
|
||||
bool writeInsertionDict(dictionary& dict)const;
|
||||
|
||||
public:
|
||||
|
||||
// type info
|
||||
TypeName("insertion");
|
||||
|
||||
insertion(particles& prtcl);
|
||||
|
||||
virtual ~insertion() = default;
|
||||
|
||||
bool isActive()const {
|
||||
return active_();
|
||||
}
|
||||
|
||||
|
||||
virtual bool read(iIstream& is) = 0;
|
||||
|
||||
virtual bool write(iOstream& os)const = 0;
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
139
src/Particles/Insertion/insertionRegion/insertionRegion.C
Normal file
139
src/Particles/Insertion/insertionRegion/insertionRegion.C
Normal file
@ -0,0 +1,139 @@
|
||||
/*------------------------------- 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 "insertionRegion.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
bool pFlow::insertionRegion::readInsertionRegion
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
|
||||
name_ = dict.name();
|
||||
type_ = dict.getVal<word>("type");
|
||||
|
||||
pRegion_ = peakableRegion::create(type_, dict.subDict(type_+"Info"));
|
||||
|
||||
mixture_ = makeUnique<shapeMixture>(dict.subDict("mixture"));
|
||||
|
||||
addToNumInserted(mixture_().totalInserted());
|
||||
|
||||
if( !dict.containsDictionay("setFields"))
|
||||
{
|
||||
output<<"\n insertion region "<< name_ << " does not contain setFields dictionary."
|
||||
" An empty dictoiinary is created for it. \n";
|
||||
setFields_ = makeUnique<setFieldList>( dictionary("setFields") );
|
||||
}
|
||||
else
|
||||
{
|
||||
setFields_ = makeUnique<setFieldList>( dict.subDict("setFields") );
|
||||
}
|
||||
|
||||
for(auto& sfEntry:setFields_())
|
||||
{
|
||||
if(!sfEntry.checkForTypeAndValueAll())
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in setFields dictionary "<< dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::insertionRegion::writeInsertionRegion
|
||||
(
|
||||
dictionary& dict
|
||||
) const
|
||||
{
|
||||
|
||||
if(!dict.add("type", type_)) return false;
|
||||
|
||||
|
||||
if(pRegion_)
|
||||
{
|
||||
auto& prDict = dict.subDictOrCreate(type_+"Info");
|
||||
if(!pRegion_().write(prDict)) return false;
|
||||
}
|
||||
|
||||
if(mixture_)
|
||||
{
|
||||
auto& mixDict = dict.subDictOrCreate("mixture");
|
||||
if(!mixture_().write(mixDict)) return false;
|
||||
}
|
||||
|
||||
if(setFields_)
|
||||
{
|
||||
auto& sfDict = dict.subDictOrCreate("setFields");
|
||||
setFields_().write(sfDict);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pFlow::insertionRegion::insertionRegion
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
timeFlowControl(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
|
||||
)
|
||||
{
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
114
src/Particles/Insertion/insertionRegion/insertionRegion.H
Normal file
114
src/Particles/Insertion/insertionRegion/insertionRegion.H
Normal file
@ -0,0 +1,114 @@
|
||||
/*------------------------------- 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 __insertionRegion_H__
|
||||
#define __insertionRegion_H__
|
||||
|
||||
#include "timeFlowControl.H"
|
||||
#include "shapeMixture.H"
|
||||
#include "peakableRegions.H"
|
||||
#include "setFieldList.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class dictionary;
|
||||
|
||||
class insertionRegion
|
||||
:
|
||||
public timeFlowControl
|
||||
{
|
||||
protected:
|
||||
|
||||
// - name of the region
|
||||
word name_;
|
||||
|
||||
// - type of insertion region
|
||||
word type_;
|
||||
|
||||
// peakable region of points
|
||||
uniquePtr<peakableRegion> pRegion_ = nullptr;
|
||||
|
||||
// mixture of shapes
|
||||
uniquePtr<shapeMixture> mixture_ = nullptr;
|
||||
|
||||
// setFields for insertion region
|
||||
uniquePtr<setFieldList> setFields_ = nullptr;
|
||||
|
||||
|
||||
bool readInsertionRegion(const dictionary& dict);
|
||||
|
||||
bool writeInsertionRegion(dictionary& dict) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
TypeNameNV("insertionRegion");
|
||||
|
||||
//// - Constructors
|
||||
|
||||
insertionRegion(const dictionary& dict);
|
||||
|
||||
insertionRegion(const insertionRegion& src);
|
||||
|
||||
insertionRegion(insertionRegion&&) = default;
|
||||
|
||||
insertionRegion& operator=(const insertionRegion&);
|
||||
|
||||
insertionRegion& operator=(insertionRegion&&) = default;
|
||||
|
||||
|
||||
~insertionRegion() = default;
|
||||
|
||||
|
||||
//// - Methods
|
||||
const auto& setFields()const
|
||||
{
|
||||
return setFields_();
|
||||
}
|
||||
|
||||
const auto& name()const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
//// - IO operation
|
||||
|
||||
bool read(const dictionary& dict)
|
||||
{
|
||||
if(!timeFlowControl::read(dict))return false;
|
||||
|
||||
return readInsertionRegion(dict);
|
||||
}
|
||||
|
||||
bool write(dictionary& dict)const
|
||||
{
|
||||
if(!timeFlowControl::write(dict)) return false;
|
||||
|
||||
return writeInsertionRegion(dict);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
} //pFlow
|
||||
|
||||
#endif //__insertionRegion_H__
|
62
src/Particles/Insertion/insertionRegion/timeFlowControl.C
Normal file
62
src/Particles/Insertion/insertionRegion/timeFlowControl.C
Normal file
@ -0,0 +1,62 @@
|
||||
/*------------------------------- 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.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
98
src/Particles/Insertion/insertionRegion/timeFlowControl.H
Normal file
98
src/Particles/Insertion/insertionRegion/timeFlowControl.H
Normal file
@ -0,0 +1,98 @@
|
||||
/*------------------------------- 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_H__
|
||||
#define __timeFlowControl_H__
|
||||
|
||||
#include "types.H"
|
||||
#include "streams.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class dictionary;
|
||||
|
||||
class timeFlowControl
|
||||
{
|
||||
protected:
|
||||
|
||||
real startTime_;
|
||||
|
||||
real endTime_;
|
||||
|
||||
real interval_;
|
||||
|
||||
real rate_;
|
||||
|
||||
size_t numInserted_ = 0;
|
||||
|
||||
bool readTimeFlowControl(const dictionary& dict);
|
||||
|
||||
bool writeTimeFlowControl(dictionary& dict) const;
|
||||
|
||||
size_t numberToBeInserted(real currentTime)
|
||||
{
|
||||
if(currentTime<startTime_)return 0;
|
||||
if(currentTime>endTime_) return 0;
|
||||
|
||||
return static_cast<size_t>( (currentTime - startTime_ + interval_)*rate_ - numInserted_ );
|
||||
}
|
||||
|
||||
size_t addToNumInserted(size_t newInserted)
|
||||
{
|
||||
return numInserted_ += newInserted;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
|
||||
timeFlowControl(const dictionary& dict);
|
||||
|
||||
|
||||
bool 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;
|
||||
}
|
||||
|
||||
size_t totalInserted()const
|
||||
{
|
||||
return numInserted_;
|
||||
}
|
||||
|
||||
bool read(const dictionary& dict)
|
||||
{
|
||||
return readTimeFlowControl(dict);
|
||||
}
|
||||
|
||||
bool write(dictionary& dict)const
|
||||
{
|
||||
return writeTimeFlowControl(dict);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //__timeFlowControl_H__
|
151
src/Particles/Insertion/shapeMixture/shapeMixture.C
Executable file
151
src/Particles/Insertion/shapeMixture/shapeMixture.C
Executable file
@ -0,0 +1,151 @@
|
||||
/*------------------------------- 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 "shapeMixture.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
|
||||
pFlow::shapeMixture::shapeMixture
|
||||
(
|
||||
const dictionary & dict
|
||||
)
|
||||
{
|
||||
if( !read(dict))
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
pFlow::word pFlow::shapeMixture::getNextShapeName()
|
||||
{
|
||||
|
||||
forAll(i, names_)
|
||||
{
|
||||
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
|
||||
)
|
||||
{
|
||||
names.clear();
|
||||
|
||||
|
||||
for(label i=0; i<n; ++i)
|
||||
{
|
||||
names.push_back( getNextShapeName() );
|
||||
}
|
||||
}
|
||||
|
||||
bool pFlow::shapeMixture::read(const dictionary& dict)
|
||||
{
|
||||
|
||||
bool containNumberIneserted = false;
|
||||
|
||||
auto shNames = dict.dataEntryKeywords();
|
||||
|
||||
for (auto nm = shNames.begin(); nm != shNames.end(); )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
if(containNumberIneserted)
|
||||
{
|
||||
numberInserted_ = dict.getVal<uint32Vector>("numberInserted");
|
||||
}
|
||||
else
|
||||
{
|
||||
numberInserted_ = uint32Vector(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;
|
||||
}
|
||||
|
||||
current_.clear();
|
||||
forAll(i, numberInserted_)
|
||||
{
|
||||
current_.push_back(numberInserted_[i]%number_[i]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::shapeMixture::write
|
||||
(
|
||||
dictionary& dict
|
||||
) const
|
||||
{
|
||||
|
||||
forAll(i, names_)
|
||||
{
|
||||
if(!dict.add(names_[i],number_[i]))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing "<< names_[i] << " to dictionary "<<dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!dict.add("numberInserted", numberInserted_))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing numberInserted to dictionary "<< dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
104
src/Particles/Insertion/shapeMixture/shapeMixture.H
Executable file
104
src/Particles/Insertion/shapeMixture/shapeMixture.H
Executable file
@ -0,0 +1,104 @@
|
||||
/*------------------------------- 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 __shapeMixture_H__
|
||||
#define __shapeMixture_H__
|
||||
|
||||
|
||||
#include "Vectors.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class dictionary;
|
||||
|
||||
class shapeMixture
|
||||
{
|
||||
|
||||
protected:
|
||||
// - list of shape names
|
||||
wordVector names_;
|
||||
|
||||
// - number composition
|
||||
uint32Vector number_;
|
||||
|
||||
// - number inserted of each shape
|
||||
uint32Vector numberInserted_;
|
||||
|
||||
uint32Vector current_;
|
||||
|
||||
public:
|
||||
|
||||
//- type Info
|
||||
TypeNameNV("shapeMixture");
|
||||
|
||||
//// - constrcutores
|
||||
|
||||
//
|
||||
shapeMixture(const dictionary & dict);
|
||||
|
||||
shapeMixture(const shapeMixture&) = default;
|
||||
|
||||
shapeMixture(shapeMixture&&) = default;
|
||||
|
||||
shapeMixture& operator=(const shapeMixture&) = default;
|
||||
|
||||
shapeMixture& operator=(shapeMixture&&) = default;
|
||||
|
||||
|
||||
uniquePtr<shapeMixture> clone()const
|
||||
{
|
||||
return makeUnique<shapeMixture>(*this);
|
||||
}
|
||||
|
||||
shapeMixture* clonePtr()const
|
||||
{
|
||||
return new shapeMixture(*this);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
~shapeMixture() = default;
|
||||
|
||||
//// - Methods
|
||||
word getNextShapeName();
|
||||
|
||||
|
||||
void getNextShapeNameN(size_t n, wordVector& names);
|
||||
|
||||
|
||||
auto size()const {
|
||||
return names_.size();
|
||||
}
|
||||
|
||||
auto totalInserted()const {
|
||||
return sum(numberInserted_);
|
||||
}
|
||||
|
||||
//// - IO operatoins
|
||||
bool read(const dictionary& dict);
|
||||
|
||||
bool write(dictionary& dict) const;
|
||||
|
||||
};
|
||||
|
||||
} // pFlow
|
||||
|
||||
#endif //__shapeMixture_H__
|
Reference in New Issue
Block a user