diff --git a/examples/ImplicitTransportDefs.hpp b/examples/ImplicitTransportDefs.hpp new file mode 100644 index 00000000..2b3f3712 --- /dev/null +++ b/examples/ImplicitTransportDefs.hpp @@ -0,0 +1,91 @@ + +#ifndef OPENRS_IMPLICITTRANSPORTDEFS_HEADER +#define OPENRS_IMPLICITTRANSPORTDEFS_HEADER + +#include +#include +template +Ostream& +operator<<(Ostream& os, const Collection& c) +{ + typedef typename Collection::value_type VT; + + os << "[ "; + std::copy(c.begin(), c.end(), ::std::ostream_iterator(os, " ")); + os << "]"; + + return os; +} +template +class MaxNorm { + public: + static double + norm(const Vector& v) { + return Opm::ImplicitTransportDefault::AccumulationNorm ::norm(v); + } +}; + +template +class ReservoirState { +public: + ReservoirState(const grid_t* g) + : press_ (g->number_of_cells), + fpress_(g->number_of_faces), + flux_ (g->number_of_faces), + sat_ (np * g->number_of_cells) + {} + + ::std::vector& pressure () { return press_ ; } + ::std::vector& facepressure() { return fpress_; } + ::std::vector& faceflux () { return flux_ ; } + ::std::vector& saturation () { return sat_ ; } + + const ::std::vector& faceflux () const { return flux_; } + const ::std::vector& saturation () const { return sat_ ; } + +private: + ::std::vector press_ ; + ::std::vector fpress_; + ::std::vector flux_ ; + ::std::vector sat_ ; +}; +class Rock { +public: + Rock(::std::size_t nc, ::std::size_t dim) + : dim_ (dim ), + perm_(nc * dim * dim), + poro_(nc ) {} + + const ::std::vector& perm() const { return perm_; } + const ::std::vector& poro() const { return poro_; } + + void + perm_homogeneous(double k) { + setVector(0.0, perm_); + + const ::std::size_t d2 = dim_ * dim_; + + for (::std::size_t c = 0, nc = poro_.size(); c < nc; ++c) { + for (::std::size_t i = 0; i < dim_; ++i) { + perm_[c*d2 + i*(dim_ + 1)] = k; + } + } + } + + void + poro_homogeneous(double phi) { + setVector(phi, poro_); + } + +private: + void + setVector(double x, ::std::vector& v) { + ::std::fill(v.begin(), v.end(), x); + } + + ::std::size_t dim_ ; + ::std::vector perm_; + ::std::vector poro_; +}; + +#endif // /OPENRS_IMPLICITTRANSPORTDEFS_HEADER