2012-08-24 09:08:26 -05:00
|
|
|
/*
|
|
|
|
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2012-11-16 09:06:01 -06:00
|
|
|
#ifndef OPM_TOFREORDER_HEADER_INCLUDED
|
|
|
|
#define OPM_TOFREORDER_HEADER_INCLUDED
|
2012-08-24 09:08:26 -05:00
|
|
|
|
2012-11-16 09:24:54 -06:00
|
|
|
#include <opm/core/transport/reorder/ReorderSolverInterface.hpp>
|
2012-08-24 09:08:26 -05:00
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <ostream>
|
2013-04-22 07:02:45 -05:00
|
|
|
|
2012-08-24 09:08:26 -05:00
|
|
|
struct UnstructuredGrid;
|
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
|
|
|
class IncompPropertiesInterface;
|
2013-04-22 07:02:45 -05:00
|
|
|
template <typename T> class SparseTable;
|
2012-08-24 09:08:26 -05:00
|
|
|
|
2012-10-09 02:54:54 -05:00
|
|
|
/// Implements a first-order finite volume solver for
|
|
|
|
/// (single-phase) time-of-flight using reordering.
|
|
|
|
/// The equation solved is:
|
2013-03-21 08:51:49 -05:00
|
|
|
/// \f[v \cdot \nabla\tau = \phi\f]
|
2013-03-22 03:26:45 -05:00
|
|
|
/// in which \f$ v \f$ is the fluid velocity, \f$ \tau \f$ is time-of-flight and
|
|
|
|
/// \f$ \phi \f$ is the porosity. This is a boundary value problem, and
|
2013-03-21 08:51:49 -05:00
|
|
|
/// \f$ \tau \f$ is specified to be zero on all inflow boundaries.
|
2012-11-16 09:06:01 -06:00
|
|
|
class TofReorder : public ReorderSolverInterface
|
2012-08-24 09:08:26 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// Construct solver.
|
2013-04-22 04:29:59 -05:00
|
|
|
/// \param[in] grid A 2d or 3d grid.
|
2012-10-29 11:23:17 -05:00
|
|
|
/// \param[in] use_multidim_upwind If true, use multidimensional tof upwinding.
|
2013-03-14 10:18:39 -05:00
|
|
|
TofReorder(const UnstructuredGrid& grid,
|
|
|
|
const bool use_multidim_upwind = false);
|
2012-08-24 09:08:26 -05:00
|
|
|
|
2012-10-09 02:54:54 -05:00
|
|
|
/// Solve for time-of-flight.
|
2012-09-25 07:00:17 -05:00
|
|
|
/// \param[in] darcyflux Array of signed face fluxes.
|
|
|
|
/// \param[in] porevolume Array of pore volumes.
|
2012-10-09 02:54:54 -05:00
|
|
|
/// \param[in] source Source term. Sign convention is:
|
|
|
|
/// (+) inflow flux,
|
|
|
|
/// (-) outflow flux.
|
2012-09-25 07:00:17 -05:00
|
|
|
/// \param[out] tof Array of time-of-flight values.
|
2012-08-24 09:08:26 -05:00
|
|
|
void solveTof(const double* darcyflux,
|
|
|
|
const double* porevolume,
|
2012-09-25 07:00:17 -05:00
|
|
|
const double* source,
|
2012-08-24 09:08:26 -05:00
|
|
|
std::vector<double>& tof);
|
|
|
|
|
2013-01-03 07:07:51 -06:00
|
|
|
/// Solve for time-of-flight and a number of tracers.
|
|
|
|
/// \param[in] darcyflux Array of signed face fluxes.
|
|
|
|
/// \param[in] porevolume Array of pore volumes.
|
|
|
|
/// \param[in] source Source term. Sign convention is:
|
|
|
|
/// (+) inflow flux,
|
|
|
|
/// (-) outflow flux.
|
2013-04-22 07:02:45 -05:00
|
|
|
/// \param[in] tracerheads Table containing one row per tracer, and each
|
|
|
|
/// row contains the source cells for that tracer.
|
2013-01-03 07:07:51 -06:00
|
|
|
/// \param[out] tof Array of time-of-flight values (1 per cell).
|
2013-04-24 03:36:52 -05:00
|
|
|
/// \param[out] tracer Array of tracer values. N per cell, where N is
|
|
|
|
/// equalt to tracerheads.size().
|
2013-01-03 07:07:51 -06:00
|
|
|
void solveTofTracer(const double* darcyflux,
|
|
|
|
const double* porevolume,
|
|
|
|
const double* source,
|
2013-04-22 07:02:45 -05:00
|
|
|
const SparseTable<int>& tracerheads,
|
2013-01-03 07:07:51 -06:00
|
|
|
std::vector<double>& tof,
|
|
|
|
std::vector<double>& tracer);
|
|
|
|
|
2012-08-24 09:08:26 -05:00
|
|
|
private:
|
|
|
|
virtual void solveSingleCell(const int cell);
|
2012-11-05 07:26:00 -06:00
|
|
|
void solveSingleCellMultidimUpwind(const int cell);
|
2013-04-17 05:58:15 -05:00
|
|
|
void assembleSingleCell(const int cell,
|
|
|
|
std::vector<int>& local_column,
|
|
|
|
std::vector<double>& local_coefficient,
|
|
|
|
double& rhs);
|
2012-08-24 09:08:26 -05:00
|
|
|
virtual void solveMultiCell(const int num_cells, const int* cells);
|
|
|
|
|
2012-11-05 07:26:00 -06:00
|
|
|
void multidimUpwindTerms(const int face, const int upwind_cell,
|
|
|
|
double& face_term, double& cell_term_factor) const;
|
2012-10-29 11:23:17 -05:00
|
|
|
|
2012-08-24 09:08:26 -05:00
|
|
|
private:
|
|
|
|
const UnstructuredGrid& grid_;
|
|
|
|
const double* darcyflux_; // one flux per grid face
|
|
|
|
const double* porevolume_; // one volume per cell
|
2012-09-25 07:00:17 -05:00
|
|
|
const double* source_; // one volumetric source term per cell
|
2012-08-24 09:08:26 -05:00
|
|
|
double* tof_;
|
2013-01-03 07:07:51 -06:00
|
|
|
double* tracer_;
|
|
|
|
int num_tracers_;
|
2013-04-23 08:35:47 -05:00
|
|
|
enum { NoTracerHead = -1 };
|
|
|
|
std::vector<int> tracerhead_by_cell_;
|
2013-04-22 04:11:55 -05:00
|
|
|
// For solveMultiCell():
|
2013-04-22 04:22:23 -05:00
|
|
|
double gauss_seidel_tol_;
|
2013-04-17 06:18:22 -05:00
|
|
|
int num_multicell_;
|
|
|
|
int max_size_multicell_;
|
2013-04-22 04:22:23 -05:00
|
|
|
int max_iter_multicell_;
|
2013-04-22 04:11:55 -05:00
|
|
|
// For multidim upwinding:
|
2012-10-29 11:23:17 -05:00
|
|
|
bool use_multidim_upwind_;
|
2012-10-30 07:10:50 -05:00
|
|
|
std::vector<double> face_tof_; // For multidim upwind face tofs.
|
|
|
|
mutable std::vector<int> adj_faces_; // For multidim upwind logic.
|
2012-08-24 09:08:26 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Opm
|
|
|
|
|
|
|
|
#endif // OPM_TRANSPORTMODELTRACERTOF_HEADER_INCLUDED
|