mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-22 16:28:30 +00:00
src folder
This commit is contained in:
19
src/Particles/CMakeLists.txt
Normal file
19
src/Particles/CMakeLists.txt
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
set(SourceFiles
|
||||
dynamicPointStructure/dynamicPointStructure.C
|
||||
particles/particles.C
|
||||
SphereParticles/sphereShape/sphereShape.C
|
||||
SphereParticles/sphereParticles/sphereParticles.C
|
||||
Insertion/shapeMixture/shapeMixture.C
|
||||
Insertion/insertion/insertion.C
|
||||
Insertion/Insertion/Insertions.C
|
||||
Insertion/insertionRegion/insertionRegion.C
|
||||
Insertion/insertionRegion/timeFlowControl.C
|
||||
)
|
||||
|
||||
set(link_libs Kokkos::kokkos phasicFlow Integration Property)
|
||||
|
||||
pFlow_add_library_install(Particles SourceFiles link_libs)
|
||||
|
||||
|
||||
|
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__
|
353
src/Particles/SphereParticles/sphereParticles/sphereParticles.C
Normal file
353
src/Particles/SphereParticles/sphereParticles/sphereParticles.C
Normal file
@ -0,0 +1,353 @@
|
||||
/*------------------------------- 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 "sphereParticles.H"
|
||||
#include "setFieldList.H"
|
||||
#include "sphereParticlesKernels.H"
|
||||
|
||||
pFlow::uniquePtr<pFlow::List<pFlow::eventObserver*>>
|
||||
pFlow::sphereParticles::getFieldObjectList()const
|
||||
{
|
||||
auto objListPtr = particles::getFieldObjectList();
|
||||
|
||||
objListPtr().push_back(
|
||||
static_cast<eventObserver*>(&I_) );
|
||||
|
||||
return objListPtr;
|
||||
}
|
||||
|
||||
bool pFlow::sphereParticles::diameterMassInertiaPropId
|
||||
(
|
||||
const word& shName,
|
||||
real& diam,
|
||||
real& mass,
|
||||
real& I,
|
||||
int8& propIdx
|
||||
)
|
||||
{
|
||||
uint32 idx;
|
||||
if( !shapes_.nameToIndex(shName, idx) )
|
||||
{
|
||||
printKeys(fatalErrorInFunction<<
|
||||
" wrong shape name in the input: "<< shName<<endl<<
|
||||
" available shape names are: ", shapes_.names())<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
diam = shapes_.diameter(idx);
|
||||
word materialName = shapes_.material(idx);
|
||||
uint32 pIdx;
|
||||
if( !property_.nameToIndex(materialName, pIdx) )
|
||||
{
|
||||
fatalErrorInFunction <<
|
||||
" wrong material name "<< materialName <<" specified for shape "<< shName<<
|
||||
" in the sphereShape dictionary.\n"<<
|
||||
" available materials are "<< property_.materials()<<endl;
|
||||
return false;
|
||||
}
|
||||
real rho = property_.density(pIdx);
|
||||
|
||||
mass = Pi/6.0*pow(diam,3.0)*rho;
|
||||
I = 0.4 * mass * pow(diam/2.0,2.0);
|
||||
propIdx= static_cast<int8>(pIdx);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::sphereParticles::initializeParticles()
|
||||
{
|
||||
|
||||
int32IndexContainer indices(0, shapeName_.size());
|
||||
return insertSphereParticles(shapeName_, indices);
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::sphereParticles::beforeIteration()
|
||||
{
|
||||
particles::beforeIteration();
|
||||
|
||||
intPredictTimer_.start();
|
||||
dynPointStruct_.predict(this->dt(), accelertion_);
|
||||
rVelIntegration_().predict(this->dt(),rVelocity_, rAcceleration_);
|
||||
intPredictTimer_.end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::sphereParticles::iterate()
|
||||
{
|
||||
accelerationTimer_.start();
|
||||
pFlow::sphereParticlesKernels::acceleration(
|
||||
control().g(),
|
||||
mass().deviceVectorAll(),
|
||||
contactForce().deviceVectorAll(),
|
||||
I().deviceVectorAll(),
|
||||
contactTorque().deviceVectorAll(),
|
||||
pStruct().activePointsMaskD(),
|
||||
accelertion().deviceVectorAll(),
|
||||
rAcceleration().deviceVectorAll()
|
||||
);
|
||||
accelerationTimer_.end();
|
||||
|
||||
intCorrectTimer_.start();
|
||||
dynPointStruct_.correct(this->dt(), accelertion_);
|
||||
rVelIntegration_().correct(this->dt(), rVelocity_, rAcceleration_);
|
||||
intCorrectTimer_.end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::sphereParticles::afterIteration()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::sphereParticles::insertSphereParticles(
|
||||
const wordVector& names,
|
||||
const int32IndexContainer& indices
|
||||
)
|
||||
{
|
||||
|
||||
if(names.size()!= indices.size())
|
||||
{
|
||||
fatalErrorInFunction <<
|
||||
"sizes of names ("<<names.size()<<") and indices ("
|
||||
<< indices.size()<<") do not match \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto len = names.size();
|
||||
|
||||
realVector diamVec(len, RESERVE());
|
||||
realVector massVec(len, RESERVE());
|
||||
realVector IVec(len, RESERVE());
|
||||
int8Vector pIdVec(len, RESERVE());
|
||||
int32Vector IdVec(len, RESERVE());
|
||||
|
||||
real d, m, I;
|
||||
int8 pId;
|
||||
|
||||
forAll(i, names )
|
||||
{
|
||||
if (diameterMassInertiaPropId(names[i], d, m, I, pId))
|
||||
{
|
||||
diamVec.push_back(d);
|
||||
massVec.push_back(m);
|
||||
IVec.push_back(I);
|
||||
pIdVec.push_back(pId);
|
||||
IdVec.push_back(idHandler_.getNextId());
|
||||
}
|
||||
else
|
||||
{
|
||||
fatalErrorInFunction<< "failed to calculate properties of shape " <<
|
||||
names[i]<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!diameter_.insertSetElement(indices, diamVec))
|
||||
{
|
||||
fatalErrorInFunction<< " failed to insert diameters to the diameter field. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!mass_.insertSetElement(indices, massVec))
|
||||
{
|
||||
fatalErrorInFunction<< " failed to insert mass to the mass field. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!I_.insertSetElement(indices, IVec))
|
||||
{
|
||||
fatalErrorInFunction<< " failed to insert I to the I field. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!propertyId_.insertSetElement(indices, pIdVec))
|
||||
{
|
||||
fatalErrorInFunction<< " failed to insert propertyId to the propertyId field. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!id_.insertSetElement(indices, IdVec))
|
||||
{
|
||||
fatalErrorInFunction<< " failed to insert id to the id field. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
pFlow::sphereParticles::sphereParticles(
|
||||
systemControl &control,
|
||||
const property& prop
|
||||
)
|
||||
:
|
||||
particles(
|
||||
control,
|
||||
control.settingsDict().getValOrSet(
|
||||
"integrationMethod",
|
||||
word("AdamsBashforth3")
|
||||
)
|
||||
),
|
||||
property_(prop),
|
||||
shapes_(
|
||||
control.caseSetup().emplaceObjectOrGet<sphereShape>(
|
||||
objectFile(
|
||||
sphereShapeFile__,
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_NEVER
|
||||
)
|
||||
)
|
||||
),
|
||||
I_(
|
||||
this->time().emplaceObject<realPointField_D>(
|
||||
objectFile(
|
||||
"I",
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct(),
|
||||
static_cast<real>(0.0000000001)
|
||||
)
|
||||
),
|
||||
rVelocity_(
|
||||
this->time().emplaceObject<realx3PointField_D>(
|
||||
objectFile(
|
||||
"rVelocity",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct(),
|
||||
zero3
|
||||
)
|
||||
),
|
||||
rAcceleration_(
|
||||
this->time().emplaceObject<realx3PointField_D>(
|
||||
objectFile(
|
||||
"rAcceleration",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct(),
|
||||
zero3
|
||||
)
|
||||
),
|
||||
accelerationTimer_(
|
||||
"Acceleration", &this->timers() ),
|
||||
intPredictTimer_(
|
||||
"Integration-predict", &this->timers() ),
|
||||
intCorrectTimer_(
|
||||
"Integration-correct", &this->timers() )
|
||||
|
||||
{
|
||||
|
||||
Report(1)<<"Creating integration method "<<greenText(this->integrationMethod())
|
||||
<< " for rotational velocity."<<endReport;
|
||||
|
||||
rVelIntegration_ =
|
||||
integration::create(
|
||||
"rVelocity",
|
||||
this->time().integration(),
|
||||
this->pStruct(),
|
||||
this->integrationMethod());
|
||||
|
||||
if( !rVelIntegration_ )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in creating integration object for rVelocity. \n";
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
|
||||
if(!initializeParticles())
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::sphereParticles::insertParticles
|
||||
(
|
||||
const realx3Vector& position,
|
||||
const wordVector& shapes,
|
||||
const setFieldList& setField
|
||||
)
|
||||
{
|
||||
|
||||
if( position.size() != shapes.size() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" size of vectors position ("<<position.size()<<
|
||||
") and shapes ("<<shapes.size()<<") are not the same. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto exclusionListAllPtr = getFieldObjectList();
|
||||
|
||||
auto newInsertedPtr = pStruct().insertPoints( position, exclusionListAllPtr());
|
||||
|
||||
if(!newInsertedPtr)
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in inserting points into pStruct. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto& newInserted = newInsertedPtr();
|
||||
|
||||
if(!shapeName_.insertSetElement(newInserted, shapes))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in inserting shapes into sphereParticles system.\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !insertSphereParticles(shapes, newInserted) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"error in inserting shapes into the sphereParticles. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
for(auto sfEntry:setField)
|
||||
{
|
||||
if(!sfEntry.setPointFieldSelectedAll( time(), newInserted, false ))return false;
|
||||
}
|
||||
|
||||
auto activeR = this->activeRange();
|
||||
|
||||
Report(1)<< "Active range is "<<yellowText("["<<activeR.first<<", "<<activeR.second<<")")<<
|
||||
" and number of active points is "<< cyanText(this->numActive())<<
|
||||
" and pointStructure capacity is "<<cyanText(this->capacity())<<endReport;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
191
src/Particles/SphereParticles/sphereParticles/sphereParticles.H
Normal file
191
src/Particles/SphereParticles/sphereParticles/sphereParticles.H
Normal file
@ -0,0 +1,191 @@
|
||||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
/*!
|
||||
@class pFlow::sphereParticles
|
||||
|
||||
@brief Class for managing spherical particles
|
||||
|
||||
This is a top-level class that contains the essential components for
|
||||
defining spherical prticles in a DEM simulation.
|
||||
*/
|
||||
|
||||
#ifndef __sphereParticles_H__
|
||||
#define __sphereParticles_H__
|
||||
|
||||
#include "systemControl.H"
|
||||
#include "particles.H"
|
||||
#include "sphereShape.H"
|
||||
#include "property.H"
|
||||
#include "indexContainer.H"
|
||||
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class sphereParticles
|
||||
:
|
||||
public particles
|
||||
{
|
||||
protected:
|
||||
|
||||
/// reference to material properties
|
||||
const property& property_;
|
||||
|
||||
/// reference to shapes
|
||||
sphereShape& shapes_;
|
||||
|
||||
/// pointField of inertial of particles
|
||||
realPointField_D& I_;
|
||||
|
||||
/// pointField of rotational Velocity of particles on device
|
||||
realx3PointField_D& rVelocity_;
|
||||
|
||||
/// pointField of rotational acceleration of particles on device
|
||||
realx3PointField_D& rAcceleration_;
|
||||
|
||||
/// rotational velocity integrator
|
||||
uniquePtr<integration> rVelIntegration_ = nullptr;
|
||||
|
||||
/// timer for acceleration computations
|
||||
Timer accelerationTimer_;
|
||||
|
||||
/// timer for integration computations (prediction step)
|
||||
Timer intPredictTimer_;
|
||||
|
||||
/// timer for integration computations (correction step)
|
||||
Timer intCorrectTimer_;
|
||||
|
||||
bool diameterMassInertiaPropId(const word& shName, real& diam, real& mass, real& I, int8& propIdx);
|
||||
|
||||
bool initializeParticles();
|
||||
|
||||
bool insertSphereParticles(const wordVector& names, const int32IndexContainer& indices);
|
||||
|
||||
virtual uniquePtr<List<eventObserver*>> getFieldObjectList()const override;
|
||||
|
||||
public:
|
||||
|
||||
/// construct from systemControl and property
|
||||
sphereParticles(systemControl &control, const property& prop);
|
||||
|
||||
/// no copy constructor
|
||||
sphereParticles(const sphereParticles&) = delete;
|
||||
|
||||
/// move constructor
|
||||
sphereParticles(sphereParticles&&) = default;
|
||||
|
||||
/// no copy-assignement
|
||||
sphereParticles& operator=(const sphereParticles&) = delete;
|
||||
|
||||
/// move-assignement
|
||||
sphereParticles& operator=(sphereParticles&&) = default;
|
||||
|
||||
virtual ~sphereParticles()=default;
|
||||
|
||||
/**
|
||||
* Insert new particles in position with specified shapes
|
||||
*
|
||||
* This function is involked by inserted object to insert new set of particles
|
||||
* into the simulation.
|
||||
* \param position position of new particles
|
||||
* \param shape shape of new particles
|
||||
* \param setField initial value of the selected fields for new particles
|
||||
*/
|
||||
bool insertParticles
|
||||
(
|
||||
const realx3Vector& position,
|
||||
const wordVector& shapes,
|
||||
const setFieldList& setField
|
||||
) override ;
|
||||
|
||||
/// const reference to shapes object
|
||||
const auto& shapes()const
|
||||
{
|
||||
return shapes_;
|
||||
}
|
||||
|
||||
/// const reference to inertia pointField
|
||||
const auto& I()const
|
||||
{
|
||||
return I_;
|
||||
}
|
||||
|
||||
/// reference to inertia pointField
|
||||
auto& I()
|
||||
{
|
||||
return I_;
|
||||
}
|
||||
|
||||
const realx3Vector_D rVelocity()const
|
||||
{
|
||||
return rVelocity_;
|
||||
}
|
||||
|
||||
const realVector_D& boundingSphere()const override
|
||||
{
|
||||
return this->diameter();
|
||||
}
|
||||
|
||||
word shapeTypeName() const override
|
||||
{
|
||||
return "sphere";
|
||||
}
|
||||
|
||||
void boundingSphereMinMax(
|
||||
real& minDiam,
|
||||
real& maxDiam )const override
|
||||
{
|
||||
shapes_.diameterMinMax(minDiam, maxDiam);
|
||||
}
|
||||
|
||||
bool update(const eventMessage& msg) override
|
||||
{
|
||||
CONSUME_PARAM(msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
realx3PointField_D& rAcceleration() override
|
||||
{
|
||||
return rAcceleration_;
|
||||
}
|
||||
|
||||
const realx3PointField_D& rAcceleration() const override
|
||||
{
|
||||
return rAcceleration_;
|
||||
}
|
||||
|
||||
/// before iteration step
|
||||
bool beforeIteration() override;
|
||||
|
||||
/// iterate particles
|
||||
bool iterate() override;
|
||||
|
||||
/// after iteration step
|
||||
bool afterIteration() override;
|
||||
|
||||
|
||||
|
||||
}; //sphereParticles
|
||||
|
||||
} // pFlow
|
||||
|
||||
#endif //__sphereParticles_H__
|
@ -0,0 +1,77 @@
|
||||
/*------------------------------- 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 __sphereParticlesKernels_H__
|
||||
#define __sphereParticlesKernels_H__
|
||||
|
||||
namespace pFlow::sphereParticlesKernels
|
||||
{
|
||||
|
||||
using rpAcceleration = Kokkos::RangePolicy<
|
||||
DefaultExecutionSpace,
|
||||
Kokkos::Schedule<Kokkos::Static>,
|
||||
Kokkos::IndexType<int32>
|
||||
>;
|
||||
|
||||
template<typename IncludeFunctionType>
|
||||
void acceleration(
|
||||
realx3 g,
|
||||
deviceViewType1D<real> mass,
|
||||
deviceViewType1D<realx3> force,
|
||||
deviceViewType1D<real> I,
|
||||
deviceViewType1D<realx3> torque,
|
||||
IncludeFunctionType incld,
|
||||
deviceViewType1D<realx3> lAcc,
|
||||
deviceViewType1D<realx3> rAcc
|
||||
)
|
||||
{
|
||||
|
||||
auto activeRange = incld.activeRange();
|
||||
if(incld.allActive())
|
||||
{
|
||||
Kokkos::parallel_for(
|
||||
"pFlow::sphereParticlesKernels::acceleration",
|
||||
rpAcceleration(activeRange.first, activeRange.second),
|
||||
LAMBDA_HD(int32 i){
|
||||
lAcc[i] = force[i]/mass[i] + g;
|
||||
rAcc[i] = torque[i]/I[i];
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Kokkos::parallel_for(
|
||||
"pFlow::sphereParticlesKernels::acceleration",
|
||||
rpAcceleration(activeRange.first, activeRange.second),
|
||||
LAMBDA_HD(int32 i){
|
||||
if(incld(i))
|
||||
{
|
||||
lAcc[i] = force[i]/mass[i] + g;
|
||||
rAcc[i] = torque[i]/I[i];
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Kokkos::fence();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
204
src/Particles/SphereParticles/sphereShape/sphereShape.C
Normal file
204
src/Particles/SphereParticles/sphereShape/sphereShape.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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "sphereShape.H"
|
||||
#include "dictionary.H"
|
||||
#include "vocabs.H"
|
||||
#include "streams.H"
|
||||
|
||||
|
||||
bool pFlow::sphereShape::insertNames
|
||||
(
|
||||
const wordVector& names
|
||||
)
|
||||
{
|
||||
names_.clear();
|
||||
uint32 i=0;
|
||||
for(const auto& nm:names)
|
||||
{
|
||||
if(!names_.insertIf(nm, i))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" repeated name in the list of sphere names: " << names;
|
||||
return false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
names_.rehash(0);
|
||||
|
||||
numShapes_ = names_.size();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::sphereShape::readDictionary
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
diameters_ = dict.getVal<realVector>("diameters");
|
||||
materials_ = dict.getVal<wordVector>("materials");
|
||||
auto names = dict.getVal<wordVector>("names");
|
||||
|
||||
if(diameters_.size() != materials_.size() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" number of elements in diameters and properties are not the same in "<< dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
else if(diameters_.size() != names.size() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" number of elements in diameters and names are not the same in "<< dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !insertNames(names) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in reading dictionary "<< dict.globalName();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::sphereShape::writeDictionary
|
||||
(
|
||||
dictionary& dict
|
||||
)const
|
||||
{
|
||||
|
||||
if( !dict.add("diamters", diameters_) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" Error in writing diameters to dictionary "<< dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !dict.add("properties", materials_) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" Error in writing properties to dictionary "<< dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t n = names_.size();
|
||||
wordVector names(n);
|
||||
names.clear();
|
||||
word nm;
|
||||
|
||||
for(label i=0; i<n; i++)
|
||||
{
|
||||
indexToName(i, nm);
|
||||
names.push_back(nm);
|
||||
}
|
||||
|
||||
if( !dict.add("names", names) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" Error in writing names to dictionary "<< dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
pFlow::sphereShape::sphereShape
|
||||
(
|
||||
const realVector& diameter,
|
||||
const wordVector& property,
|
||||
const wordVector& name
|
||||
)
|
||||
:
|
||||
diameters_(diameter),
|
||||
materials_(property)
|
||||
{
|
||||
if( !insertNames( name) )
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
bool pFlow::sphereShape::shapeToDiameter
|
||||
(
|
||||
wordVector& names,
|
||||
realVector& diams
|
||||
)const
|
||||
{
|
||||
diams.clear();
|
||||
uint32 idx;
|
||||
for(const auto& nm:names)
|
||||
{
|
||||
if(!nameToIndex(nm, idx))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" invalid shape name requested "<< nm <<endl;
|
||||
return false;
|
||||
}
|
||||
diams.push_back(diameters_[idx]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::sphereShape::read(iIstream& is)
|
||||
{
|
||||
|
||||
dictionary sphereDict(sphereShapeFile__, true);
|
||||
|
||||
if( !sphereDict.read(is) )
|
||||
{
|
||||
ioErrorInFile(is.name(), is.lineNumber()) <<
|
||||
" error in reading dictionray " << sphereShapeFile__ <<" from file. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !readDictionary(sphereDict) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::sphereShape::write(iOstream& os)const
|
||||
{
|
||||
|
||||
dictionary sphereDict(sphereShapeFile__, true);
|
||||
|
||||
if( !writeDictionary(sphereDict))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !sphereDict.write(os) )
|
||||
{
|
||||
ioErrorInFile( os.name(), os.lineNumber() )<<
|
||||
" error in writing dictionray to file. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
177
src/Particles/SphereParticles/sphereShape/sphereShape.H
Normal file
177
src/Particles/SphereParticles/sphereShape/sphereShape.H
Normal file
@ -0,0 +1,177 @@
|
||||
/*------------------------------- 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 __sphereShape_H__
|
||||
#define __sphereShape_H__
|
||||
|
||||
#include "Vectors.H"
|
||||
#include "hashMap.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class dictionary;
|
||||
|
||||
class sphereShape
|
||||
{
|
||||
protected:
|
||||
|
||||
// - diameter of spheres
|
||||
realVector diameters_;
|
||||
|
||||
// - property name of spheres
|
||||
wordVector materials_;
|
||||
|
||||
// - hashed list of spheres names
|
||||
wordHashMap<uint32> names_;
|
||||
|
||||
size_t numShapes_;
|
||||
|
||||
|
||||
bool insertNames(const wordVector& names);
|
||||
|
||||
bool readDictionary(const dictionary& dict);
|
||||
|
||||
bool writeDictionary(dictionary& dict)const;
|
||||
|
||||
public:
|
||||
|
||||
// - type info
|
||||
TypeNameNV("sphereShape");
|
||||
|
||||
|
||||
sphereShape(){}
|
||||
|
||||
sphereShape(
|
||||
const realVector& diameter,
|
||||
const wordVector& property,
|
||||
const wordVector& name
|
||||
);
|
||||
|
||||
sphereShape(const sphereShape&) = default;
|
||||
|
||||
sphereShape(sphereShape&&) = default;
|
||||
|
||||
sphereShape& operator=(const sphereShape&) = default;
|
||||
|
||||
sphereShape& operator=(sphereShape&&) = default;
|
||||
|
||||
auto clone()const
|
||||
{
|
||||
return makeUnique<sphereShape>(*this);
|
||||
}
|
||||
|
||||
sphereShape* clonePtr()const
|
||||
{
|
||||
return new sphereShape(*this);
|
||||
}
|
||||
|
||||
~sphereShape() = default;
|
||||
|
||||
//// - Methods
|
||||
const auto& names()const{
|
||||
return names_;
|
||||
}
|
||||
|
||||
const auto& diameters()const{
|
||||
return diameters_;
|
||||
}
|
||||
|
||||
const auto& materials()const{
|
||||
return materials_;
|
||||
}
|
||||
|
||||
const auto diameter(label i)const{
|
||||
return diameters_[i];
|
||||
}
|
||||
|
||||
const auto material(label i)const{
|
||||
return materials_[i];
|
||||
}
|
||||
|
||||
|
||||
// name to index
|
||||
bool nameToIndex(const word& name, uint32& index)const
|
||||
{
|
||||
if(auto[iter, found] = names_.findIf(name); found )
|
||||
{
|
||||
index = iter->second;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
index = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 nameToIndex(const word& name)const
|
||||
{
|
||||
return names_.at(name);
|
||||
}
|
||||
|
||||
bool indexToName(uint32 i, word& name)const
|
||||
{
|
||||
for(auto& nm: names_)
|
||||
{
|
||||
if(nm.second == i)
|
||||
{
|
||||
name = nm.first;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
name = "";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool shapeToDiameter(wordVector& names, realVector& diams)const;
|
||||
|
||||
void diameterMinMax(real& minD, real& maxD)const
|
||||
{
|
||||
minD = min(diameters_);
|
||||
maxD = max(diameters_);
|
||||
}
|
||||
|
||||
//// - IO operatoin
|
||||
|
||||
// - read from stream/file
|
||||
bool read(iIstream& is);
|
||||
|
||||
// - write to stream/file
|
||||
bool write(iOstream& os)const;
|
||||
|
||||
// - read from dictionary
|
||||
bool read(const dictionary& dict)
|
||||
{
|
||||
return readDictionary(dict);
|
||||
}
|
||||
|
||||
// - write to dictionary
|
||||
bool write(dictionary& dict)const
|
||||
{
|
||||
return writeDictionary(dict);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // pFlow
|
||||
|
||||
#endif //__sphereShape_H__
|
115
src/Particles/dynamicPointStructure/dynamicPointStructure.C
Normal file
115
src/Particles/dynamicPointStructure/dynamicPointStructure.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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "dynamicPointStructure.H"
|
||||
|
||||
|
||||
pFlow::dynamicPointStructure::dynamicPointStructure
|
||||
(
|
||||
Time& time,
|
||||
const word& integrationMethod
|
||||
)
|
||||
:
|
||||
time_(time),
|
||||
integrationMethod_(integrationMethod),
|
||||
pStruct_(
|
||||
time_.emplaceObject<pointStructure>(
|
||||
objectFile(
|
||||
pointStructureFile__,
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_ALWAYS
|
||||
)
|
||||
)
|
||||
),
|
||||
velocity_(
|
||||
time_.emplaceObject<realx3PointField_D>(
|
||||
objectFile(
|
||||
"velocity",
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct_,
|
||||
zero3
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
|
||||
Report(1)<< "Creating integration method "<<
|
||||
greenText(integrationMethod_)<<" for dynamicPointStructure."<<endReport;
|
||||
|
||||
integrationPos_ = integration::create(
|
||||
"pStructPosition",
|
||||
time_.integration(),
|
||||
pStruct_,
|
||||
integrationMethod_);
|
||||
|
||||
integrationVel_ = integration::create(
|
||||
"pStructVelocity",
|
||||
time_.integration(),
|
||||
pStruct_,
|
||||
integrationMethod_);
|
||||
|
||||
if( !integrationPos_ )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in creating integration object for dynamicPointStructure (position). \n";
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
if( !integrationVel_ )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in creating integration object for dynamicPointStructure (velocity). \n";
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::dynamicPointStructure::predict
|
||||
(
|
||||
real dt,
|
||||
realx3PointField_D& acceleration
|
||||
)
|
||||
{
|
||||
auto& pos = pStruct_.pointPosition();
|
||||
|
||||
if(!integrationPos_().predict(dt, pos.VectorField(), velocity_.VectorField() ))return false;
|
||||
if(!integrationVel_().predict(dt, velocity_.VectorField(), acceleration.VectorField()))return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::dynamicPointStructure::correct
|
||||
(
|
||||
real dt,
|
||||
realx3PointField_D& acceleration
|
||||
)
|
||||
{
|
||||
auto& pos = pStruct_.pointPosition();
|
||||
|
||||
if(!integrationPos_().correct(dt, pos.VectorField(), velocity_.VectorField() ))return false;
|
||||
|
||||
if(!integrationVel_().correct(dt, velocity_.VectorField(), acceleration.VectorField()))return false;
|
||||
|
||||
return true;
|
||||
}
|
87
src/Particles/dynamicPointStructure/dynamicPointStructure.H
Normal file
87
src/Particles/dynamicPointStructure/dynamicPointStructure.H
Normal file
@ -0,0 +1,87 @@
|
||||
/*------------------------------- 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 __dynamicPointStructure_H__
|
||||
#define __dynamicPointStructure_H__
|
||||
|
||||
#include "Time.H"
|
||||
#include "pointFields.H"
|
||||
#include "integrations.H"
|
||||
#include "uniquePtr.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class dynamicPointStructure
|
||||
{
|
||||
protected:
|
||||
|
||||
Time& time_;
|
||||
|
||||
const word integrationMethod_;
|
||||
|
||||
pointStructure& pStruct_;
|
||||
|
||||
realx3PointField_D& velocity_;
|
||||
|
||||
uniquePtr<integration> integrationPos_;
|
||||
|
||||
uniquePtr<integration> integrationVel_;
|
||||
|
||||
public:
|
||||
|
||||
TypeName("dynamicPointStructure");
|
||||
|
||||
dynamicPointStructure(Time& time, const word& integrationMethod);
|
||||
|
||||
virtual ~dynamicPointStructure() = default;
|
||||
|
||||
inline pointStructure& pStruct()
|
||||
{
|
||||
return pStruct_;
|
||||
}
|
||||
|
||||
inline const pointStructure& pStruct() const
|
||||
{
|
||||
return pStruct_;
|
||||
}
|
||||
|
||||
inline const realx3PointField_D& velocity()const
|
||||
{
|
||||
return velocity_;
|
||||
}
|
||||
|
||||
auto markDeleteOutOfBox(const box& domain)
|
||||
{
|
||||
return pStruct_.markDeleteOutOfBox(domain);
|
||||
}
|
||||
|
||||
bool predict(real dt, realx3PointField_D& acceleration);
|
||||
|
||||
bool correct(real dt, realx3PointField_D& acceleration);
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
47
src/Particles/particles/demParticles.H
Normal file
47
src/Particles/particles/demParticles.H
Normal file
@ -0,0 +1,47 @@
|
||||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
------------------------------------------------------------------------------
|
||||
Copyright (C): www.cemf.ir
|
||||
email: hamid.r.norouzi AT gmail.com
|
||||
------------------------------------------------------------------------------
|
||||
Licence:
|
||||
This file is part of phasicFlow code. It is a free software for simulating
|
||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||
the terms of GNU General Public License v3 or any other later versions.
|
||||
|
||||
phasicFlow is distributed to help others in their research in the field of
|
||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __demParticles_H__
|
||||
#define __demParticles_H__
|
||||
|
||||
#include "demComponent.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
class demParticles
|
||||
:
|
||||
public demComponent
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
demParticles(systemControl& control):
|
||||
demComponent("particles", control)
|
||||
{}
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
81
src/Particles/particles/particleIdHandler.H
Normal file
81
src/Particles/particles/particleIdHandler.H
Normal file
@ -0,0 +1,81 @@
|
||||
/*------------------------------- 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 __particleIdHandler_H__
|
||||
#define __particleIdHandler_H__
|
||||
|
||||
|
||||
#include "pointFields.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class particleIdHandler
|
||||
{
|
||||
protected:
|
||||
int32 nextId_=0;
|
||||
public:
|
||||
particleIdHandler(int32PointField_HD & id)
|
||||
{
|
||||
int32 maxID = maxActive<DeviceSide>(id);
|
||||
|
||||
if( maxID != -1 && id.size() == 0 )
|
||||
{
|
||||
nextId_ = 0;
|
||||
}
|
||||
else if( maxID == -1 && id.size()>0 )
|
||||
{
|
||||
nextId_ = 0;
|
||||
id.modifyOnHost();
|
||||
|
||||
forAll(i,id)
|
||||
{
|
||||
if(id.isActive(i))
|
||||
{
|
||||
id[i] = getNextId();
|
||||
}
|
||||
}
|
||||
|
||||
id.syncViews();
|
||||
}
|
||||
else if( maxID >= static_cast<int32>(id.size()) )
|
||||
{
|
||||
nextId_ = maxID + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nextId_ = id.size();
|
||||
}
|
||||
}
|
||||
|
||||
int32 getNextId()
|
||||
{
|
||||
return nextId_++;
|
||||
}
|
||||
|
||||
int32 nextId() const
|
||||
{
|
||||
return nextId_;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
162
src/Particles/particles/particles.C
Normal file
162
src/Particles/particles/particles.C
Normal file
@ -0,0 +1,162 @@
|
||||
/*------------------------------- 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"
|
||||
|
||||
|
||||
pFlow::particles::particles
|
||||
(
|
||||
systemControl& control,
|
||||
const word& integrationMethod
|
||||
)
|
||||
:
|
||||
demParticles(control),
|
||||
time_(control.time()),
|
||||
integrationMethod_(integrationMethod),
|
||||
dynPointStruct_(
|
||||
control.time(),
|
||||
integrationMethod
|
||||
),
|
||||
shapeName_(
|
||||
control.time().emplaceObject<wordPointField>(
|
||||
objectFile(
|
||||
"shapeName",
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_ALWAYS,
|
||||
false
|
||||
),
|
||||
pStruct(),
|
||||
word("NO_NAME_SHAPE")
|
||||
)
|
||||
),
|
||||
id_(
|
||||
control.time().emplaceObject<int32PointField_HD>(
|
||||
objectFile(
|
||||
"id",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct(),
|
||||
static_cast<int32>(-1)
|
||||
)
|
||||
),
|
||||
propertyId_(
|
||||
control.time().emplaceObject<int8PointField_D>(
|
||||
objectFile(
|
||||
"propertyId",
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
pStruct(),
|
||||
static_cast<int8>(0)
|
||||
)
|
||||
),
|
||||
diameter_(
|
||||
control.time().emplaceObject<realPointField_D>(
|
||||
objectFile(
|
||||
"diameter",
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct(),
|
||||
static_cast<real>(0.00000000001)
|
||||
)
|
||||
),
|
||||
mass_(
|
||||
control.time().emplaceObject<realPointField_D>(
|
||||
objectFile(
|
||||
"mass",
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct(),
|
||||
static_cast<real>(0.0000000001)
|
||||
)
|
||||
),
|
||||
accelertion_(
|
||||
control.time().emplaceObject<realx3PointField_D>(
|
||||
objectFile(
|
||||
"accelertion",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct(),
|
||||
zero3
|
||||
)
|
||||
),
|
||||
contactForce_(
|
||||
control.time().emplaceObject<realx3PointField_D>(
|
||||
objectFile(
|
||||
"contactForce",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct(),
|
||||
zero3
|
||||
)
|
||||
),
|
||||
contactTorque_(
|
||||
control.time().emplaceObject<realx3PointField_D>(
|
||||
objectFile(
|
||||
"contactTorque",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct(),
|
||||
zero3
|
||||
)
|
||||
),
|
||||
idHandler_(id_)
|
||||
{
|
||||
|
||||
this->subscribe(pStruct());
|
||||
|
||||
}
|
||||
|
||||
pFlow::uniquePtr<pFlow::List<pFlow::eventObserver*>>
|
||||
pFlow::particles::getFieldObjectList()const
|
||||
{
|
||||
auto objListPtr = makeUnique<pFlow::List<pFlow::eventObserver*>>();
|
||||
objListPtr().push_back(
|
||||
static_cast<eventObserver*>(&id_) );
|
||||
|
||||
objListPtr().push_back(
|
||||
static_cast<eventObserver*>(&propertyId_) );
|
||||
|
||||
objListPtr().push_back(
|
||||
static_cast<eventObserver*>(&diameter_) );
|
||||
|
||||
objListPtr().push_back(
|
||||
static_cast<eventObserver*>(&mass_) );
|
||||
|
||||
objListPtr().push_back(
|
||||
static_cast<eventObserver*>(&shapeName_) );
|
||||
|
||||
return objListPtr;
|
||||
}
|
291
src/Particles/particles/particles.H
Normal file
291
src/Particles/particles/particles.H
Normal file
@ -0,0 +1,291 @@
|
||||
/*------------------------------- 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 __particles_H__
|
||||
#define __particles_H__
|
||||
|
||||
#include "dynamicPointStructure.H"
|
||||
#include "particleIdHandler.H"
|
||||
#include "demParticles.H"
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class setFieldList;
|
||||
|
||||
class particles
|
||||
:
|
||||
public eventObserver,
|
||||
public demParticles
|
||||
{
|
||||
protected:
|
||||
|
||||
// owner repository
|
||||
Time& time_;
|
||||
|
||||
const word integrationMethod_;
|
||||
|
||||
// dynamic point structure for particles
|
||||
dynamicPointStructure dynPointStruct_;
|
||||
|
||||
// - name of shapes - this is managed by particles
|
||||
wordPointField& shapeName_;
|
||||
|
||||
// id of particles on host
|
||||
int32PointField_HD& id_;
|
||||
|
||||
// property id on device
|
||||
int8PointField_D& propertyId_;
|
||||
|
||||
// diameter / boundig sphere size of particles on device
|
||||
realPointField_D& diameter_;
|
||||
|
||||
// mass on device
|
||||
realPointField_D& mass_;
|
||||
|
||||
// - acceleration on device
|
||||
realx3PointField_D& accelertion_;
|
||||
|
||||
|
||||
realx3PointField_D& contactForce_;
|
||||
|
||||
|
||||
realx3PointField_D& contactTorque_;
|
||||
|
||||
|
||||
// - object handling particle id
|
||||
particleIdHandler idHandler_;
|
||||
|
||||
virtual uniquePtr<List<eventObserver*>> getFieldObjectList()const;
|
||||
|
||||
void zeroForce()
|
||||
{
|
||||
contactForce_.fill(zero3);
|
||||
}
|
||||
|
||||
void zeroTorque()
|
||||
{
|
||||
contactTorque_.fill(zero3);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// type info
|
||||
TypeName("particles");
|
||||
|
||||
particles(systemControl& control, const word& integrationMethod);
|
||||
|
||||
inline const auto& time()const {
|
||||
return time_;
|
||||
}
|
||||
|
||||
inline auto& time() {
|
||||
return time_;
|
||||
}
|
||||
|
||||
inline auto integrationMethod()const
|
||||
{
|
||||
return integrationMethod_;
|
||||
}
|
||||
|
||||
inline const auto& dynPointStruct()const
|
||||
{
|
||||
return dynPointStruct_;
|
||||
}
|
||||
|
||||
inline auto& dynPointStruct()
|
||||
{
|
||||
return dynPointStruct_;
|
||||
}
|
||||
|
||||
inline const auto& pStruct()const{
|
||||
return dynPointStruct_.pStruct();
|
||||
}
|
||||
|
||||
inline auto& pStruct(){
|
||||
return dynPointStruct_.pStruct();
|
||||
}
|
||||
|
||||
inline auto size()const{
|
||||
return pStruct().size();
|
||||
}
|
||||
|
||||
inline auto capacity() const{
|
||||
return pStruct().capacity();
|
||||
}
|
||||
|
||||
inline auto activePointsMaskD()const{
|
||||
return pStruct().activePointsMaskD();
|
||||
}
|
||||
|
||||
inline auto numActive()const
|
||||
{
|
||||
return pStruct().numActive();
|
||||
}
|
||||
|
||||
inline bool allActive()const{
|
||||
return pStruct().allActive();
|
||||
}
|
||||
|
||||
inline auto activeRange()const{
|
||||
return pStruct().activeRange();
|
||||
}
|
||||
|
||||
inline auto activePointsMaskH()const{
|
||||
return pStruct().activePointsMaskH();
|
||||
}
|
||||
|
||||
inline const auto& pointPosition()const{
|
||||
return pStruct().pointPosition();
|
||||
}
|
||||
|
||||
inline const auto& position()const
|
||||
{
|
||||
return pStruct().pointPosition();
|
||||
}
|
||||
|
||||
inline const auto& pointVelocity()const{
|
||||
return dynPointStruct().velocity();
|
||||
}
|
||||
|
||||
inline const auto& velocity()const{
|
||||
return dynPointStruct().velocity();
|
||||
}
|
||||
|
||||
inline const auto& id()const{
|
||||
return id_;
|
||||
}
|
||||
|
||||
inline auto& id(){
|
||||
return id_;
|
||||
}
|
||||
|
||||
inline const auto& diameter()const{
|
||||
return diameter_;
|
||||
}
|
||||
|
||||
inline auto& diameter(){
|
||||
return diameter_;
|
||||
}
|
||||
|
||||
inline const auto& mass()const{
|
||||
return mass_;
|
||||
}
|
||||
|
||||
inline auto& mass() {
|
||||
return mass_;
|
||||
}
|
||||
|
||||
inline const auto& accelertion()const{
|
||||
return accelertion_;
|
||||
}
|
||||
|
||||
inline auto& accelertion(){
|
||||
return accelertion_;
|
||||
}
|
||||
|
||||
inline
|
||||
realx3PointField_D& contactForce()
|
||||
{
|
||||
return contactForce_;
|
||||
}
|
||||
|
||||
inline
|
||||
const realx3PointField_D& contactForce() const
|
||||
{
|
||||
return contactForce_;
|
||||
}
|
||||
|
||||
inline
|
||||
realx3PointField_D& contactTorque()
|
||||
{
|
||||
return contactTorque_;
|
||||
}
|
||||
|
||||
inline
|
||||
const realx3PointField_D& contactTorque() const
|
||||
{
|
||||
return contactTorque_;
|
||||
}
|
||||
|
||||
inline const auto& propertyId()const{
|
||||
return propertyId_;
|
||||
}
|
||||
|
||||
inline auto& propertyId(){
|
||||
return propertyId_;
|
||||
}
|
||||
|
||||
inline const auto& shapeName()const{
|
||||
return shapeName_;
|
||||
}
|
||||
|
||||
inline auto& shapName(){
|
||||
return shapeName_;
|
||||
}
|
||||
|
||||
bool beforeIteration() override
|
||||
{
|
||||
auto domain = this->control().domain();
|
||||
|
||||
auto numMarked = dynPointStruct_.markDeleteOutOfBox(domain);
|
||||
/*if(numMarked)
|
||||
{
|
||||
output<<"\nNumber of deleted points/particles that are out of domain box: "<<numMarked<<endl;
|
||||
}*/
|
||||
|
||||
this->zeroForce();
|
||||
this->zeroTorque();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual
|
||||
bool insertParticles
|
||||
(
|
||||
const realx3Vector& position,
|
||||
const wordVector& shapes,
|
||||
const setFieldList& setField
|
||||
) = 0;
|
||||
|
||||
|
||||
|
||||
virtual
|
||||
realx3PointField_D& rAcceleration() = 0;
|
||||
|
||||
virtual
|
||||
const realx3PointField_D& rAcceleration() const = 0;
|
||||
|
||||
virtual
|
||||
const realVector_D& boundingSphere()const = 0;
|
||||
|
||||
virtual
|
||||
word shapeTypeName()const = 0;
|
||||
|
||||
virtual
|
||||
void boundingSphereMinMax(real & minDiam, real& maxDiam)const = 0;
|
||||
|
||||
|
||||
|
||||
}; // particles
|
||||
|
||||
} // pFlow
|
||||
|
||||
#endif //__particles_H__
|
Reference in New Issue
Block a user