SimulatorTester.hpp
Go to the documentation of this file.
1//===========================================================================
2//
3// File: SimulatorTester.hpp
4//
5// Created: Fri Aug 7 09:21:55 2009
6//
7// Author(s): Atgeirr F Rasmussen <atgeirr@sintef.no>
8// Bård Skaflestad <bard.skaflestad@sintef.no>
9//
10// $Date$
11//
12// $Revision$
13//
14//===========================================================================
15
16/*
17 Copyright 2009, 2010 SINTEF ICT, Applied Mathematics.
18 Copyright 2009, 2010 Statoil ASA.
19
20 This file is part of The Open Reservoir Simulator Project (OpenRS).
21
22 OpenRS is free software: you can redistribute it and/or modify
23 it under the terms of the GNU General Public License as published by
24 the Free Software Foundation, either version 3 of the License, or
25 (at your option) any later version.
26
27 OpenRS is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31
32 You should have received a copy of the GNU General Public License
33 along with OpenRS. If not, see <http://www.gnu.org/licenses/>.
34*/
35
36#ifndef OPENRS_SIMULATORTESTER_HEADER
37#define OPENRS_SIMULATORTESTER_HEADER
38
39
41#include <dune/grid/io/file/vtk/vtkwriter.hh>
42
43#include <iostream>
44
45namespace Opm
46{
47
48
49
52 template <class SimTraits>
53 class SimulatorTester : public SimulatorBase<SimTraits>
54 {
55 public:
59 void run()
60 {
61 // Initial saturation.
62 std::vector<double> saturation(this->init_saturation_);
63 std::vector<double> saturation_old(saturation);
64 // Gravity.
65 // Dune::FieldVector<double, 3> gravity(0.0);
66 // gravity[2] = -Dune::unit::gravity;
67 // Compute flow field.
68 if (this->gravity_.two_norm() > 0.0) {
69 OPM_MESSAGE("Warning: Gravity not handled by flow solver.");
70 }
71
72 // Solve some steps.
73 for (int i = 0; i < this->simulation_steps_; ++i) {
74 std::cout << "\n\n================ Simulation step number " << i
75 << " ===============" << std::endl;
76 // Flow.
77 this->flow_solver_.solve(this->res_prop_, saturation, this->bcond_, this->injection_rates_psolver_,
79// if (i == 0) {
80// flow_solver_.printSystem("linsys_dump_mimetic");
81// }
82 // Transport.
83 this->transport_solver_.transportSolve(saturation, this->stepsize_, this->gravity_,
84 this->flow_solver_.getSolution(),
85 this->injection_rates_);
86 // Output.
88 this->res_prop_,
89 this->flow_solver_.getSolution(),
90 saturation,
91 "testsolution-" + boost::lexical_cast<std::string>(i));
92
93 writeField(saturation, "saturation-" + boost::lexical_cast<std::string>(i));
94
95 // Comparing old to new.
96 int num_cells = saturation.size();
97 double maxdiff = 0.0;
98 for (int i = 0; i < num_cells; ++i) {
99 maxdiff = std::max(maxdiff, std::fabs(saturation[i] - saturation_old[i]));
100 }
101 std::cout << "Maximum saturation change: " << maxdiff << std::endl;
102
103 // Copy to old.
104 saturation_old = saturation;
105 }
106 }
107
108 };
109
110
111
112} // namespace Opm
113
114
115#endif // OPENRS_SIMULATORTESTER_HEADER
Definition: SimulatorBase.hpp:81
Vector gravity_
Definition: SimulatorBase.hpp:128
double stepsize_
Definition: SimulatorBase.hpp:126
ResProp res_prop_
Definition: SimulatorBase.hpp:135
std::vector< double > injection_rates_psolver_
Definition: SimulatorBase.hpp:138
TransportSolver transport_solver_
Definition: SimulatorBase.hpp:140
int linsolver_verbosity_
Definition: SimulatorBase.hpp:130
FlowSolver flow_solver_
Definition: SimulatorBase.hpp:139
int linsolver_type_
Definition: SimulatorBase.hpp:131
GridInterface ginterf_
Definition: SimulatorBase.hpp:134
BCs bcond_
Definition: SimulatorBase.hpp:136
double residual_tolerance_
Definition: SimulatorBase.hpp:129
std::vector< double > init_saturation_
Definition: SimulatorBase.hpp:127
int simulation_steps_
Definition: SimulatorBase.hpp:125
Definition: SimulatorTester.hpp:54
void run()
Definition: SimulatorTester.hpp:59
SimulatorBase< SimTraits > Super
Definition: SimulatorTester.hpp:56
Definition: BlackoilFluid.hpp:32
void writeField(const std::vector< double > &field, const std::string &filename)
Definition: SimulatorUtilities.hpp:288
void writeVtkOutput(const GridInterface &ginterf, const ReservoirProperties &rp, const FlowSol &flowsol, const std::vector< double > &saturation, const std::string &filename)
Definition: SimulatorUtilities.hpp:234