2014-11-20 07:11:16 -06:00
|
|
|
/*
|
|
|
|
Copyright 2014 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OPM_ANISOTROPICEIKONAL_HEADER_INCLUDED
|
|
|
|
#define OPM_ANISOTROPICEIKONAL_HEADER_INCLUDED
|
|
|
|
|
|
|
|
#include <opm/core/utility/SparseTable.hpp>
|
|
|
|
#include <vector>
|
2015-01-07 02:49:47 -06:00
|
|
|
#include <set>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include <boost/version.hpp>
|
|
|
|
|
|
|
|
#define BOOST_HEAP_AVAILABLE ((BOOST_VERSION / 100 % 1000) >= 49)
|
|
|
|
|
|
|
|
#if BOOST_HEAP_AVAILABLE
|
2014-11-24 08:31:12 -06:00
|
|
|
#include <boost/heap/fibonacci_heap.hpp>
|
2015-01-07 02:49:47 -06:00
|
|
|
#endif
|
2014-11-20 07:11:16 -06:00
|
|
|
|
|
|
|
struct UnstructuredGrid;
|
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
/// A solver for the anisotropic eikonal equation:
|
|
|
|
/// \f[ || \nabla u^T M^{-1}(x) \nabla u || = 1 \qquad x \in \Omega \f]
|
|
|
|
/// where M(x) is a symmetric positive definite matrix.
|
|
|
|
/// The boundary conditions are assumed to be
|
|
|
|
/// \f[ u(x) = 0 \qquad x \in \partial\Omega \f].
|
|
|
|
class AnisotropicEikonal2d
|
|
|
|
{
|
|
|
|
public:
|
2014-12-01 08:17:30 -06:00
|
|
|
/// Construct solver.
|
2014-11-20 07:11:16 -06:00
|
|
|
/// \param[in] grid A 2d grid.
|
|
|
|
explicit AnisotropicEikonal2d(const UnstructuredGrid& grid);
|
|
|
|
|
|
|
|
/// Solve the eikonal equation.
|
2014-12-01 08:17:30 -06:00
|
|
|
/// \param[in] metric Array of metric tensors, M, for each cell.
|
2014-11-20 07:11:16 -06:00
|
|
|
/// \param[in] startcells Array of cells where u = 0 at the centroid.
|
|
|
|
/// \param[out] solution Array of solution to the eikonal equation.
|
|
|
|
void solve(const double* metric,
|
2014-12-01 08:17:30 -06:00
|
|
|
const std::vector<int>& startcells,
|
|
|
|
std::vector<double>& solution);
|
2014-11-20 07:11:16 -06:00
|
|
|
private:
|
2015-01-07 02:49:47 -06:00
|
|
|
#if BOOST_HEAP_AVAILABLE
|
2014-11-24 08:31:12 -06:00
|
|
|
// Grid and topology.
|
2014-12-01 08:17:30 -06:00
|
|
|
const UnstructuredGrid& grid_;
|
|
|
|
SparseTable<int> cell_neighbours_;
|
2014-11-24 08:31:12 -06:00
|
|
|
|
|
|
|
// Keep track of accepted cells.
|
2014-12-01 08:17:30 -06:00
|
|
|
std::vector<char> is_accepted_;
|
2014-11-24 08:31:12 -06:00
|
|
|
std::set<int> accepted_front_;
|
2015-01-02 08:22:02 -06:00
|
|
|
|
|
|
|
// Quantities relating to anisotropy.
|
2014-12-03 02:53:05 -06:00
|
|
|
std::vector<double> grid_radius_;
|
2015-01-02 08:22:02 -06:00
|
|
|
std::vector<double> aniso_ratio_;
|
|
|
|
const double safety_factor_;
|
2014-11-24 08:31:12 -06:00
|
|
|
|
|
|
|
// Keep track of considered cells.
|
2014-12-01 08:17:30 -06:00
|
|
|
typedef std::pair<double, int> ValueAndCell;
|
2014-11-24 08:31:12 -06:00
|
|
|
typedef boost::heap::compare<std::greater<ValueAndCell>> Comparator;
|
|
|
|
typedef boost::heap::fibonacci_heap<ValueAndCell, Comparator> Heap;
|
|
|
|
Heap considered_;
|
|
|
|
typedef Heap::handle_type HeapHandle;
|
|
|
|
std::map<int, HeapHandle> considered_handles_;
|
2014-12-01 08:17:30 -06:00
|
|
|
std::vector<char> is_considered_;
|
2014-11-21 08:06:37 -06:00
|
|
|
|
2015-01-02 08:22:02 -06:00
|
|
|
bool isClose(const int c1, const int c2) const;
|
2014-12-01 08:17:30 -06:00
|
|
|
double computeValue(const int cell, const double* metric, const double* solution) const;
|
|
|
|
double computeValueUpdate(const int cell, const double* metric, const double* solution, const int new_cell) const;
|
|
|
|
double computeFromLine(const int cell, const int from, const double* metric, const double* solution) const;
|
|
|
|
double computeFromTri(const int cell, const int n0, const int n1, const double* metric, const double* solution) const;
|
|
|
|
|
|
|
|
const ValueAndCell& topConsidered() const;
|
|
|
|
void pushConsidered(const ValueAndCell& vc);
|
|
|
|
void popConsidered();
|
2014-12-03 02:53:05 -06:00
|
|
|
|
|
|
|
void computeGridRadius();
|
2015-01-02 08:22:02 -06:00
|
|
|
void computeAnisoRatio(const double* metric);
|
2015-01-07 02:49:47 -06:00
|
|
|
#endif // BOOST_HEAP_AVAILABLE
|
2014-11-20 07:11:16 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Opm
|
|
|
|
|
|
|
|
|
|
|
|
#endif // OPM_ANISOTROPICEIKONAL_HEADER_INCLUDED
|