# PhasicFlow: src/Particles/Insertion/insertionRegion/insertionRegion.cpp Source File

insertionRegion.cpp
Go to the documentation of this file.
/*------------------------------- 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.hpp"
#include "dictionary.hpp"
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;
}
pFlow::insertionRegion::type_
word type_
Definition: insertionRegion.hpp:44
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::insertionRegion::insertionRegion
insertionRegion(const dictionary &dict)
Definition: insertionRegion.cpp:95
pFlow::dictionary::write
virtual bool write(iOstream &os) const
Definition: dictionary.cpp:780
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::insertionRegion::setFields_
uniquePtr< setFieldList > setFields_
Definition: insertionRegion.hpp:53
pFlow::dictionary::globalName
virtual word globalName() const
Definition: dictionary.cpp:349
pFlow::dictionary::subDictOrCreate
dictionary & subDictOrCreate(const word &keyword)
Definition: dictionary.cpp:634
pFlow::dictionary::add
bool add(const word &keyword, const float &v)
Definition: dictionary.cpp:422
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::timeFlowControl
Definition: timeFlowControl.hpp:32
pFlow::insertionRegion
Definition: insertionRegion.hpp:34
pFlow::insertionRegion::mixture_
uniquePtr< shapeMixture > mixture_
Definition: insertionRegion.hpp:50
pFlow::dictionary::containsDictionay
bool containsDictionay(const word &name) const
Definition: dictionary.cpp:736
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
dictionary.hpp
pFlow::output
Ostream output
insertionRegion.hpp
pFlow::insertionRegion::name_
word name_
Definition: insertionRegion.hpp:41
pFlow::dictionary::subDict
dictionary & subDict(const word &keyword)
Definition: dictionary.cpp:547
pFlow::iEntry::name
virtual word name() const
Definition: iEntry.hpp:95
pFlow::dictionary::getVal
T getVal(const word &keyword) const
Definition: dictionary.hpp:309
pFlow::insertionRegion::writeInsertionRegion
bool writeInsertionRegion(dictionary &dict) const
Definition: insertionRegion.cpp:65
pFlow::insertionRegion::pRegion_
uniquePtr< peakableRegion > pRegion_
Definition: insertionRegion.hpp:47
pFlow::insertionRegion::readInsertionRegion
bool readInsertionRegion(const dictionary &dict)
Definition: insertionRegion.cpp:26
pFlow::dictionary
Definition: dictionary.hpp:38