Flow123d
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
flow123d
src
transport
mass_balance.hh
Go to the documentation of this file.
1
#ifndef MASS_BALANCE_HH_
2
#define MASS_BALANCE_HH_
3
4
5
6
/**
7
* Interface class for equation which implements methods required for mass balance.
8
*/
9
10
class
EquationForMassBalance
{
11
public
:
12
13
// TODO: Think if we really need TimeIntegrationScheme.
14
// Currently the cummulative quantities are calculated by the method calculate()
15
// in the same way for both explicit and implicit methods.
16
enum
TimeIntegrationScheme
{
17
none
,
18
explicit_euler
,
19
implicit_euler
,
20
crank_nicholson
21
};
22
23
virtual
~EquationForMassBalance
() {};
24
25
/// Returns number of trnasported substances.
26
virtual
unsigned
int
n_substances
() = 0;
27
28
/// Returns reference to the vector of substnace names.
29
virtual
vector<string> &
substance_names
() = 0;
30
31
/// Returns the time integration scheme of the equation.
32
virtual
TimeIntegrationScheme
time_scheme
() = 0;
33
34
35
protected
:
36
37
/**
38
* Calculates the total flux through boundaries of all regions, and additionally positive and negative fluxes.
39
* The actual calculation depends on the numerical scheme, so each descendant of TransportBase implements this method.
40
* @param bcd_balance bcd_balance[i][j] is the calculated total flux
41
* of @p ith substance through boundary of @p jth region.
42
* @param bcd_plus_balance bcd_plus_balance[i][j] is the total positive flux
43
* of @p ith substance through boundary of @p jth region.
44
* @param bcd_minus_balance bcd_minus_balance[i][j] is the total negative flux
45
* of @p ith substance through boundary of @p jth region.
46
*/
47
virtual
void
calc_fluxes
(vector<vector<double> > &bcd_balance, vector<vector<double> > &bcd_plus_balance, vector<vector<double> > &bcd_minus_balance) = 0;
48
49
/**
50
* Calculates the substance mass and sources on all regions.
51
* The actual calculation depends on the numerical scheme, so each descendant of TransportBase implements this method.
52
* @param mass mass[i][j] is the calculated mass of @p ith
53
* substance on @p jth region.
54
* @param src_balance src_balance[i][j] is the source mass
55
* of @p ith substance on @p jth region.
56
*/
57
virtual
void
calc_elem_sources
(vector<vector<double> > &mass, vector<vector<double> > &src_balance) = 0;
58
59
/// Returns the region database.
60
virtual
const
RegionDB
*
region_db
() = 0;
61
62
friend
class
MassBalance
;
63
64
};
65
66
67
/**
68
* @brief Class for calculation and writing the balance of mass, volume sources and fluxes.
69
*
70
* At each time instant we calculate:
71
* - Flux rate through all boundary regions
72
* - Volume sources rate on all bulk regions
73
* - Mass on all bulk regions
74
*
75
* In addition, the quantities are summed over all regions and integrated in time,
76
* so that the cumulative (integrated) quantities should satisfy:
77
*
78
* INITIAL_MASS + INTEGRATED_SOURCES - INTEGRATED_FLUXES = CURRENT_MASS.
79
*
80
* All quantities are written to the file "mass_balance.txt" in the output directory.
81
*/
82
class
MassBalance
{
83
public
:
84
85
MassBalance
(
EquationForMassBalance
*eq,
const
Input::Record
&in_rec);
86
87
~MassBalance
();
88
89
/**
90
* @brief Write computed fields to file.
91
*/
92
void
output
(
double
time);
93
94
/**
95
* Calculate mass balance: flux through boundary, mass and volume sources
96
*/
97
void
calculate
(
double
time);
98
99
100
static
Input::Type::Record
input_type
;
101
102
103
protected
:
104
105
/// Pointer to the class which implements calculation of mass, sources and fluxes.
106
EquationForMassBalance
*
equation_
;
107
108
/// Handle for output file for output of balance and total fluxes over individual regions and region sets.
109
FILE *
balance_output_file
;
110
111
// Vectors storing mass and balances of fluxes and volumes.
112
vector<vector<double> >
bcd_balance
;
113
vector<vector<double> >
bcd_plus_balance
;
114
vector<vector<double> >
bcd_minus_balance
;
115
vector<vector<double> >
mass
;
116
vector<vector<double> >
src_balance
;
117
118
vector<double>
bcd_total_balance
;
119
vector<double>
bcd_total_inflow
;
120
vector<double>
bcd_total_outflow
;
121
vector<double>
mass_total
;
122
vector<double>
src_total_balance
;
123
124
vector<double>
initial_mass
;
125
vector<double>
integrated_sources
;
126
vector<double>
integrated_fluxes
;
127
128
/// initial time
129
double
initial_time
;
130
131
/// time of last calculated balance
132
double
last_time
;
133
134
/// true before calculating the mass at initial time, otherwise false
135
bool
initial
;
136
137
/// if true then cumulative balance is computed
138
bool
cumulative
;
139
140
};
141
142
143
144
145
146
147
148
149
#endif // MASS_BALANCE_HH_
Generated on Thu May 29 2014 23:14:49 for Flow123d by
1.8.4