PhasicFlow
v0.1
www.cemf.ir
insertionRegion.cpp
Go to the documentation of this file.
1
/*------------------------------- phasicFlow ---------------------------------
2
O C enter of
3
O O E ngineering and
4
O O M ultiscale modeling of
5
OOOOOOO F luid flow
6
------------------------------------------------------------------------------
7
Copyright (C): www.cemf.ir
8
email: hamid.r.norouzi AT gmail.com
9
------------------------------------------------------------------------------
10
Licence:
11
This file is part of phasicFlow code. It is a free software for simulating
12
granular and multiphase flows. You can redistribute it and/or modify it under
13
the terms of GNU General Public License v3 or any other later versions.
14
15
phasicFlow is distributed to help others in their research in the field of
16
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
19
-----------------------------------------------------------------------------*/
20
21
22
#include "
insertionRegion.hpp
"
23
#include "
dictionary.hpp
"
24
25
bool
pFlow::insertionRegion::readInsertionRegion
26
(
27
const
dictionary
& dict
28
)
29
{
30
31
name_ = dict.
name
();
32
type_ = dict.
getVal
<
word
>(
"type"
);
33
34
pRegion_ = peakableRegion::create(type_, dict.
subDict
(type_+
"Info"
));
35
36
mixture_ = makeUnique<shapeMixture>(dict.
subDict
(
"mixture"
));
37
38
addToNumInserted(mixture_().totalInserted());
39
40
if
( !dict.
containsDictionay
(
"setFields"
))
41
{
42
output
<<
"\n insertion region "
<< name_ <<
" does not contain setFields dictionary."
43
" An empty dictoiinary is created for it. \n"
;
44
setFields_ = makeUnique<setFieldList>(
dictionary
(
"setFields"
) );
45
}
46
else
47
{
48
setFields_ = makeUnique<setFieldList>( dict.
subDict
(
"setFields"
) );
49
}
50
51
for
(
auto
& sfEntry:setFields_())
52
{
53
if
(!sfEntry.checkForTypeAndValueAll())
54
{
55
fatalErrorInFunction
<<
56
" error in setFields dictionary "
<< dict.
globalName
()<<
endl
;
57
return
false
;
58
}
59
}
60
61
return
true
;
62
}
63
64
bool
pFlow::insertionRegion::writeInsertionRegion
65
(
66
dictionary
& dict
67
)
const
68
{
69
70
if
(!dict.
add
(
"type"
, type_))
return
false
;
71
72
73
if
(pRegion_)
74
{
75
auto
& prDict = dict.
subDictOrCreate
(type_+
"Info"
);
76
if
(!pRegion_().write(prDict))
return
false
;
77
}
78
79
if
(mixture_)
80
{
81
auto
& mixDict = dict.
subDictOrCreate
(
"mixture"
);
82
if
(!mixture_().write(mixDict))
return
false
;
83
}
84
85
if
(setFields_)
86
{
87
auto
& sfDict = dict.
subDictOrCreate
(
"setFields"
);
88
setFields_().
write
(sfDict);
89
}
90
91
return
true
;
92
}
93
94
pFlow::insertionRegion::insertionRegion
95
(
96
const
dictionary
& dict
97
)
98
:
99
timeFlowControl
(dict)
100
{
101
102
if
(!readInsertionRegion(dict))
103
{
104
fatalExit
;
105
}
106
}
107
108
pFlow::insertionRegion::insertionRegion
109
(
110
const
insertionRegion
& src
111
)
112
:
113
timeFlowControl
(src),
114
name_(src.
name_
),
115
type_(src.
type_
),
116
pRegion_( src.
pRegion_
? src.
pRegion_
->clone():
nullptr
),
117
mixture_( src.
mixture_
? src.
mixture_
->clone():
nullptr
),
118
setFields_( src.
setFields_
? src.
setFields_
->clone():
nullptr
)
119
{}
120
121
pFlow::insertionRegion
& pFlow::insertionRegion::operator=
122
(
123
const
insertionRegion
& src
124
)
125
{
126
127
if
(&src ==
this
)
return
*
this
;
128
timeFlowControl::operator=(src);
129
130
name_ = src.
name_
;
131
type_ = src.
type_
;
132
pRegion_ = (src.
pRegion_
? src.
pRegion_
->clone():
nullptr
);
133
mixture_ = (src.
mixture_
? src.
mixture_
->clone():
nullptr
);
134
setFields_ = (src.
setFields_
? src.
setFields_
->clone():
nullptr
);
135
136
return
*
this
;
137
}
138
139
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
src
Particles
Insertion
insertionRegion
insertionRegion.cpp
Generated by
1.8.17