Flow123d
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
flow123d
src
coupling
hc_explicit_sequential.cc
Go to the documentation of this file.
1
/*!
2
*
3
* Copyright (C) 2007 Technical University of Liberec. All rights reserved.
4
*
5
* Please make a following refer to Flow123d on your project site if you use the program for any purpose,
6
* especially for academic research:
7
* Flow123d, Research Centre: Advanced Remedial Technologies, Technical University of Liberec, Czech Republic
8
*
9
* This program is free software; you can redistribute it and/or modify it under the terms
10
* of the GNU General Public License version 3 as published by the Free Software Foundation.
11
*
12
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
* See the GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along with this program; if not,
17
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.
18
*
19
*
20
* $Id$
21
* $Revision$
22
* $LastChangedBy$
23
* $LastChangedDate$
24
*
25
* @file
26
* @brief
27
*
28
* @author Jan Brezina
29
*/
30
31
#include "
hc_explicit_sequential.hh
"
32
#include "
flow/darcy_flow_mh.hh
"
33
#include "
flow/darcy_flow_mh_output.hh
"
34
#include "
transport/transport_operator_splitting.hh
"
35
#include "
transport/transport.h
"
36
#include "
transport/transport_dg.hh
"
37
#include "
mesh/mesh.h
"
38
#include "
mesh/msh_gmshreader.h
"
39
#include "
system/sys_profiler.hh
"
40
#include "
input/input_type.hh
"
41
#include "
transport/concentration_model.hh
"
42
#include "
transport/heat_model.hh
"
43
44
45
namespace
it = Input::Type;
46
47
it::AbstractRecord
CouplingBase::input_type
48
=
it::AbstractRecord
(
"Problem"
,
49
"The root record of description of particular the problem to solve."
)
50
.
declare_key
(
"description"
,
it::String
(),
51
"Short description of the solved problem.\n"
52
"Is displayed in the main log, and possibly in other text output files."
)
53
.
declare_key
(
"mesh"
,
Mesh::input_type
,
it::Default::obligatory
(),
54
"Computational mesh common to all equations."
);
55
56
57
it::Record
HC_ExplicitSequential::input_type
58
=
it::Record
(
"SequentialCoupling"
,
59
"Record with data for a general sequential coupling.\n"
)
60
.
derive_from
( CouplingBase::input_type )
61
.
declare_key
(
"time"
,
TimeGovernor::input_type
,
it::Default::optional
(),
62
"Simulation time frame and time step."
)
63
.
declare_key
(
"primary_equation"
,
DarcyFlowMH::input_type
,
it::Default::obligatory
(),
64
"Primary equation, have all data given."
)
65
.
declare_key
(
"secondary_equation"
,
TransportBase::input_type
,
66
"The equation that depends (the velocity field) on the result of the primary equation."
);
67
68
69
70
71
/**
72
* FUNCTION "MAIN" FOR COMPUTING MIXED-HYBRID PROBLEM FOR UNSTEADY SATURATED FLOW
73
*/
74
HC_ExplicitSequential::HC_ExplicitSequential
(
Input::Record
in_record)
75
{
76
START_TIMER
(
"HC constructor"
);
77
F_ENTRY
;
78
//int i=0;
79
using namespace
Input;
80
81
// Initialize Time Marks
82
//main_time_marks = new TimeMarks();
83
84
// Material Database
85
// material_database = new MaterialDatabase( in_record.val<FilePath>("material") );
86
87
// Read mesh
88
{
89
mesh
=
new
Mesh
( in_record.
val
<
Record
>(
"mesh"
) );
90
mesh
->
init_from_input
();
91
92
//getting description for the Profiler
93
string
description;
94
in_record.
opt_val
<
string
>(
"description"
, description);
95
96
Profiler::instance
()->
set_task_info
(
97
description,
98
//"Description has to be set in main. by different method.",
99
mesh
->
n_elements
());
100
}
101
102
// setup primary equation - water flow object
103
AbstractRecord
prim_eq = in_record.
val
<
AbstractRecord
>(
"primary_equation"
);
104
if
(prim_eq.type() ==
DarcyFlowMH_Steady::input_type
) {
105
water
=
new
DarcyFlowMH_Steady
(*
mesh
, prim_eq);
106
}
else
if
(prim_eq.type() ==
DarcyFlowMH_Unsteady::input_type
) {
107
water
=
new
DarcyFlowMH_Unsteady
(*
mesh
, prim_eq);
108
}
else
if
(prim_eq.type() ==
DarcyFlowLMH_Unsteady::input_type
) {
109
water
=
new
DarcyFlowLMH_Unsteady
(*
mesh
, prim_eq);
110
}
else
{
111
xprintf
(
UsrErr
,
"Equation type not implemented."
);
112
}
113
114
115
116
// TODO: optionally setup transport objects
117
Iterator<AbstractRecord>
it = in_record.
find
<
AbstractRecord
>(
"secondary_equation"
);
118
if
(it) {
119
if
(it->type() ==
TransportOperatorSplitting::input_type
)
120
{
121
transport_reaction
=
new
TransportOperatorSplitting
(*
mesh
, *it);
122
}
123
else
if
(it->type() ==
TransportDG<ConcentrationTransportModel>::input_type
)
124
{
125
transport_reaction
=
new
TransportDG<ConcentrationTransportModel>
(*
mesh
, *it);
126
}
127
else
if
(it->type() ==
TransportDG<HeatTransferModel>::input_type
)
128
{
129
transport_reaction
=
new
TransportDG<HeatTransferModel>
(*
mesh
, *it);
130
}
131
else
132
{
133
xprintf
(
PrgErr
,
"Value of TYPE in the Transport an AbstractRecord out of set of descendants.\n"
);
134
}
135
136
// setup fields
137
transport_reaction
->
data
().
get_field
(
"cross_section"
)
138
.
copy_from
(
water
->
data
().
get_field
(
"cross_section"
));
139
140
}
else
{
141
transport_reaction
=
new
TransportNothing
(*
mesh
);
142
}
143
}
144
145
146
147
/**
148
* TODO:
149
* - have support for steady problems in TimeGovernor, make Noting problems steady
150
* - apply splitting of compute_one_step to particular models
151
* - how to set output time marks for steady problems (we need solved time == infinity) but
152
* add no time marks
153
* - allow create steady time governor without time marks (at least in nothing models)
154
* - pass refference to time marks in time governor constructor?
155
*/
156
157
void
HC_ExplicitSequential::run_simulation
()
158
{
159
START_TIMER
(
"HC run simulation"
);
160
// following should be specified in constructor:
161
// value for velocity interpolation :
162
// theta = 0 velocity from beginning of transport interval (fully explicit method)
163
// theta = 0.5 velocity from center of transport interval ( mimic Crank-Nicholson)
164
// theta = 1.0 velocity from end of transport interval (partialy explicit scheme)
165
const
double
theta=0.5;
166
167
168
double
velocity_interpolation_time;
169
bool
velocity_changed;
170
171
172
water
->
zero_time_step
();
173
174
175
176
// following cycle is designed to support independent time stepping of
177
// both processes. The question is which value of the water field use to compute a transport step.
178
// Meaningful cases are
179
// 1) beginning (fully explicit method)
180
// 2) center ( mimic Crank-Nicholson)
181
// 3) end of the interval (partialy explicit scheme)
182
// However with current implementation of the explicit transport on have to assembly transport matrix for
183
// every new value of the velocity field. So we have to keep same velocity field over some time interval t_dt
184
// which is further split into shorter time intervals ts_dt dictated by the CFL condition.
185
// One can consider t_dt as the transport time step and apply one of the previous three cases.
186
//
187
// The question is how to choose intervals t_dt. That should depend on variability of the velocity field in time.
188
// Currently we simply use t_dt == w_dt.
189
190
while
(! (
water
->
time
().
is_end
() &&
transport_reaction
->
time
().
is_end
() ) ) {
191
192
transport_reaction
->
set_time_upper_constraint
(
water
->
time
().
dt
());
193
// in future here could be re-estimation of transport planed time according to
194
// evolution of the velocity field. Consider the case w_dt << t_dt and velocity almost constant in time
195
// which suddenly rise in time 3*w_dt. First we the planed transport time step t_dt could be quite big, but
196
// in time 3*w_dt we can reconsider value of t_dt to better capture changing velocity.
197
velocity_interpolation_time= theta *
transport_reaction
->
planned_time
() + (1-theta) *
transport_reaction
->
solved_time
();
198
199
// printing water and transport times every step
200
//xprintf(Msg,"HC_EXPL_SEQ: velocity_interpolation_time: %f, water_time: %f transport time: %f\n",
201
// velocity_interpolation_time, water->time().t(), transport_reaction->time().t());
202
203
// if transport is off, transport should return infinity solved and planned times so that
204
// only water branch takes the place
205
if
(
water
->
solved_time
() < velocity_interpolation_time) {
206
// solve water over the nearest transport interval
207
water
->
update_solution
();
208
209
// here possibly save solution from water for interpolation in time
210
211
//water->time().view("WATER"); //show water time governor
212
213
//water->output_data();
214
water
->
choose_next_time
();
215
216
velocity_changed =
true
;
217
}
else
{
218
// having information about velocity field we can perform transport step
219
220
// here should be interpolation of the velocity at least if the interpolation time
221
// is not close to the solved_time of the water module
222
// for simplicity we use only last velocity field
223
if
(velocity_changed) {
224
//DBGMSG("velocity update\n");
225
transport_reaction
->
set_velocity_field
(
water
->
get_mh_dofhandler
() );
226
velocity_changed =
false
;
227
}
228
if
(
transport_reaction
->
time
().
tlevel
() == 0)
transport_reaction
->
zero_time_step
();
229
230
transport_reaction
->
update_solution
();
231
232
//transport_reaction->time().view("TRANSPORT"); //show transport time governor
233
234
transport_reaction
->
output_data
();
235
}
236
237
// Write all data
238
//OutputTime::write_all_data();
239
}
240
xprintf
(
Msg
,
"End of simulation at time: %f\n"
,
transport_reaction
->
solved_time
());
241
}
242
243
244
HC_ExplicitSequential::~HC_ExplicitSequential
() {
245
//delete material_database;
246
delete
water
;
247
delete
transport_reaction
;
248
delete
mesh
;
249
}
250
251
252
253
//-----------------------------------------------------------------------------
254
// vim: set cindent:
255
//-----------------------------------------------------------------------------
Generated on Thu May 29 2014 23:14:47 for Flow123d by
1.8.4