Flow123d  jenkins-Flow123d-windows32-release-multijob-28
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 
32 #include "flow/darcy_flow_mh.hh"
35 #include "transport/transport.h"
37 #include "mesh/mesh.h"
38 #include "mesh/msh_gmshreader.h"
39 #include "system/sys_profiler.hh"
40 #include "input/input_type.hh"
42 #include "transport/heat_model.hh"
43 
44 
45 namespace it = Input::Type;
46 
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.")
54  "Computational mesh common to all equations.");
55 
56 
58  = it::Record("SequentialCoupling",
59  "Record with data for a general sequential coupling.\n")
60  .derive_from( CouplingBase::input_type )
62  "Simulation time frame and time step.")
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  */
75 {
76  START_TIMER("HC constructor");
77  //int i=0;
78  using namespace Input;
79 
80  // Initialize Time Marks
81  //main_time_marks = new TimeMarks();
82 
83  // Material Database
84  // material_database = new MaterialDatabase( in_record.val<FilePath>("material") );
85 
86  // Read mesh
87  {
88  mesh = new Mesh( in_record.val<Record>("mesh") );
90 
91  //getting description for the Profiler
92  string description;
93  in_record.opt_val<string>("description", description);
94 
96  description,
97  //"Description has to be set in main. by different method.",
98  mesh->n_elements());
99  }
100 
101  // setup primary equation - water flow object
102  AbstractRecord prim_eq = in_record.val<AbstractRecord>("primary_equation");
103  if (prim_eq.type() == DarcyFlowMH_Steady::input_type ) {
104  water = new DarcyFlowMH_Steady(*mesh, prim_eq);
105  } else if (prim_eq.type() == DarcyFlowMH_Unsteady::input_type ) {
106  water = new DarcyFlowMH_Unsteady(*mesh, prim_eq);
107  } else if (prim_eq.type() == DarcyFlowLMH_Unsteady::input_type ) {
108  water = new DarcyFlowLMH_Unsteady(*mesh, prim_eq);
109  } else {
110  xprintf(UsrErr,"Equation type not implemented.");
111  }
112 
113 
114 
115  // TODO: optionally setup transport objects
116  Iterator<AbstractRecord> it = in_record.find<AbstractRecord>("secondary_equation");
117  if (it) {
118  if (it->type() == TransportOperatorSplitting::input_type)
119  {
121  }
123  {
125  }
126  else if (it->type() == TransportDG<HeatTransferModel>::input_type)
127  {
129  }
130  else
131  {
132  xprintf(PrgErr,"Value of TYPE in the Transport an AbstractRecord out of set of descendants.\n");
133  }
134 
135  // setup fields
136  transport_reaction->data()["cross_section"]
137  .copy_from(water->data()["cross_section"]);
138 
139  } else {
141  }
142 }
143 
144 
145 
146 /**
147  * TODO:
148  * - have support for steady problems in TimeGovernor, make Noting problems steady
149  * - apply splitting of compute_one_step to particular models
150  * - how to set output time marks for steady problems (we need solved time == infinity) but
151  * add no time marks
152  * - allow create steady time governor without time marks (at least in nothing models)
153  * - pass refference to time marks in time governor constructor?
154  */
155 
157 {
158  START_TIMER("HC run simulation");
159  // following should be specified in constructor:
160  // value for velocity interpolation :
161  // theta = 0 velocity from beginning of transport interval (fully explicit method)
162  // theta = 0.5 velocity from center of transport interval ( mimic Crank-Nicholson)
163  // theta = 1.0 velocity from end of transport interval (partialy explicit scheme)
164  const double theta=0.5;
165 
166 
167  double velocity_interpolation_time;
168  bool velocity_changed=true;
169 
170 
172 
173 
174 
175  // following cycle is designed to support independent time stepping of
176  // both processes. The question is which value of the water field use to compute a transport step.
177  // Meaningful cases are
178  // 1) beginning (fully explicit method)
179  // 2) center ( mimic Crank-Nicholson)
180  // 3) end of the interval (partialy explicit scheme)
181  // However with current implementation of the explicit transport on have to assembly transport matrix for
182  // every new value of the velocity field. So we have to keep same velocity field over some time interval t_dt
183  // which is further split into shorter time intervals ts_dt dictated by the CFL condition.
184  // One can consider t_dt as the transport time step and apply one of the previous three cases.
185  //
186  // The question is how to choose intervals t_dt. That should depend on variability of the velocity field in time.
187  // Currently we simply use t_dt == w_dt.
188 
189  while (! (water->time().is_end() && transport_reaction->time().is_end() ) ) {
190 
192  // in future here could be re-estimation of transport planed time according to
193  // evolution of the velocity field. Consider the case w_dt << t_dt and velocity almost constant in time
194  // which suddenly rise in time 3*w_dt. First we the planed transport time step t_dt could be quite big, but
195  // in time 3*w_dt we can reconsider value of t_dt to better capture changing velocity.
196  velocity_interpolation_time= theta * transport_reaction->planned_time() + (1-theta) * transport_reaction->solved_time();
197 
198  // printing water and transport times every step
199  //xprintf(Msg,"HC_EXPL_SEQ: velocity_interpolation_time: %f, water_time: %f transport time: %f\n",
200  // velocity_interpolation_time, water->time().t(), transport_reaction->time().t());
201 
202  // if transport is off, transport should return infinity solved and planned times so that
203  // only water branch takes the place
204  if (water->solved_time() < velocity_interpolation_time) {
205  // solve water over the nearest transport interval
207 
208  // here possibly save solution from water for interpolation in time
209 
210  //water->time().view("WATER"); //show water time governor
211 
212  //water->output_data();
214 
215  velocity_changed = true;
216  } else {
217  // having information about velocity field we can perform transport step
218 
219  // here should be interpolation of the velocity at least if the interpolation time
220  // is not close to the solved_time of the water module
221  // for simplicity we use only last velocity field
222  if (velocity_changed) {
223  //DBGMSG("velocity update\n");
225  velocity_changed = false;
226  }
228 
230 
231  //transport_reaction->time().view("TRANSPORT"); //show transport time governor
232 
234  }
235 
236  // Write all data
237  //OutputTime::write_all_data();
238  }
239  xprintf(Msg, "End of simulation at time: %f\n", transport_reaction->solved_time());
240 }
241 
242 
244  //delete material_database;
245  delete water;
246  delete transport_reaction;
247  delete mesh;
248 }
249 
250 
251 
252 //-----------------------------------------------------------------------------
253 // vim: set cindent:
254 //-----------------------------------------------------------------------------
FieldSet & data()
Definition: equation.hh:197
virtual void zero_time_step()
Definition: equation.hh:97
Mesh * mesh
mesh common to darcy flow and transport
Output class for darcy_flow_mh model.
static Input::Type::AbstractRecord input_type
Common specification of the input record for secondary equations.
Definition: system.hh:75
int tlevel() const
Transport with dispersion implemented using discontinuous Galerkin method.
static Profiler * instance()
bool is_end() const
Returns true if the actual time is greater than or equal to the end time.
static Input::Type::AbstractRecord input_type
DarcyFlowMH * water
Material database to provide various material dependent data.
static Default obligatory()
Definition: type_record.hh:87
???
Coupling of a transport model with a reaction model by operator splitting.
Definition: mesh.h:108
Iterator< Ret > find(const string &key) const
static Input::Type::Record input_type
Record & derive_from(AbstractRecord &parent)
Definition: type_record.cc:172
const MH_DofHandler & get_mh_dofhandler()
static Input::Type::Record input_type
Discontinuous Galerkin method for equation of transport with dispersion.
virtual void choose_next_time()
Definition: equation.hh:134
virtual void output_data()
Write computed fields.
Definition: equation.hh:220
AdvectionProcessBase * transport_reaction
explicit transport with chemistry through operator splitting
HC_ExplicitSequential(Input::Record in_record)
static Default optional()
Definition: type_record.hh:100
Mixed-hybrid solution of unsteady Darcy flow.
bool opt_val(const string &key, Ret &value) const
unsigned int n_elements() const
Definition: mesh.h:137
Accessor to the data with type Type::Record.
Definition: accessors.hh:308
const Ret val(const string &key) const
#define xprintf(...)
Definition: system.hh:104
#define START_TIMER(tag)
Starts a timer with specified tag.
Class for declaration of polymorphic Record.
Definition: type_record.hh:467
static Input::Type::Record input_type
AbstractRecord & declare_key(const string &key, const KeyType &type, const Default &default_value, const string &description)
Definition: type_record.cc:426
static Input::Type::Record input_type
Accessor to the polymorphic input data of a type given by an AbstracRecord object.
Definition: accessors.hh:423
Discontinuous Galerkin method for equation of transport with dispersion.
Empty transport class.
Definition: system.hh:75
static Input::Type::AbstractRecord input_type
virtual void update_solution()
Definition: equation.hh:105
static Input::Type::Record input_type
Definition: mesh.h:111
double dt() const
Definition: system.hh:75
TimeGovernor const & time()
Definition: equation.hh:152
Edge lumped mixed-hybrid solution of unsteady Darcy flow.
double solved_time()
Definition: equation.hh:174
Mixed-hybrid of steady Darcy flow with sources and variable density.
virtual void set_velocity_field(const MH_DofHandler &dh)=0
Discontinuous Galerkin method for equation of transport with dispersion.
static Input::Type::Record input_type
mixed-hybrid model of linear Darcy flow, possibly unsteady.
Record type proxy class.
Definition: type_record.hh:161
static Input::Type::Record input_type
Declare input record type for the equation TransportOperatorSplittiong.
virtual void set_time_upper_constraint(double dt)
Definition: equation.hh:140
void init_from_input()
Definition: mesh.cc:199
void set_task_info(string description, int size)
Record & declare_key(const string &key, const KeyType &type, const Default &default_value, const string &description)
Definition: type_record.cc:390
double planned_time()
Definition: equation.hh:168