Added wrapper in code in separate file. Continued to change ../simulator/SimulatorIncompTwophase.cpp

This commit is contained in:
Halvor Møll Nilsen 2012-11-15 15:01:12 +01:00
parent a30e42b962
commit aaa10cf17b
3 changed files with 185 additions and 1 deletions

View File

@ -98,7 +98,20 @@ namespace Opm
const FlowBoundaryConditions* bcs_;
// Solvers
IncompTpfa psolver_;
// this should maybe be packed in a separate file
typedef Opm::SimpleFluid2pWrappingProps TwophaseFluid;
typedef Opm::SinglePointUpwindTwoPhase<TwophaseFluid> TransportModel;
using namespace Opm::ImplicitTransportDefault;
typedef NewtonVectorCollection< ::std::vector<double> > NVecColl;
typedef JacobianSystem < struct CSRMatrix, NVecColl > JacSys;
template <class Vector>
class MaxNorm {
public:
static double
norm(const Vector& v) {
return AccumulationNorm <Vector, MaxAbs>::norm(v);
}
};
typedef Opm::ImplicitTransport<TransportModel,
JacSys ,
MaxNorm ,
@ -106,7 +119,8 @@ namespace Opm
VectorZero ,
MatrixZero ,
VectorAssign > ImpliciteTwoPhaseTransportSolver;
ImpliciteTwoPhaseTransporSolver tsolver_;
ImpliciteTwoPhaseTransportSolver tsolver_;
// Needed by column-based gravity segregation solver.
std::vector< std::vector<int> > columns_;
// Misc. data

View File

@ -0,0 +1,104 @@
/*===========================================================================
//
// File: SimpleFluid2pWrappingProps.cpp
//
// Author: hnil <hnil@sintef.no>
//
// Created: 15 Nov 2012
//==========================================================================*/
/*
Copyright 2011 SINTEF ICT, Applied Mathematics.
Copyright 2011 Statoil ASA.
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/>.
*/
#include "SimpleFluid2pWrappingProps.hpp"
SimpleFluid2pWrappingProps::SimpleFluid2pWrappingProps()
{
}
namespace opm{
SimpleFluid2pWrappingProps::SimpleFluid2pWrappingProps(const Opm::IncompPropertiesInterface& props)
: props_(props),
smin_(props.numCells()*props.numPhases()),
smax_(props.numCells()*props.numPhases())
{
if (props.numPhases() != 2) {
THROW("SimpleFluid2pWrapper requires 2 phases.");
}
const int num_cells = props.numCells();
std::vector<int> cells(num_cells);
for (int c = 0; c < num_cells; ++c) {
cells[c] = c;
}
props.satRange(num_cells, &cells[0], &smin_[0], &smax_[0]);
}
double density(int phase) const
{
return props_.density()[phase];
}
template <class Sat,
class Mob,
class DMob>
void SimpleFluid2pWrappingProps:;mobility(int c, const Sat& s, Mob& mob, DMob& dmob) const
{
props_.relperm(1, &s[0], &c, &mob[0], &dmob[0]);
const double* mu = props_.viscosity();
mob[0] /= mu[0];
mob[1] /= mu[1];
// Recall that we use Fortran ordering for kr derivatives,
// therefore dmob[i*2 + j] is row j and column i of the
// matrix.
// Each row corresponds to a kr function, so which mu to
// divide by also depends on the row, j.
dmob[0*2 + 0] /= mu[0];
dmob[0*2 + 1] /= mu[1];
dmob[1*2 + 0] /= mu[0];
dmob[1*2 + 1] /= mu[1];
}
template <class Sat,
class Pcap,
class DPcap>
void SimpleFluid2pWrappingProps::pc(int c, const Sat& s, Pcap& pcap, DPcap& dpcap) const
{
double pcow[2];
double dpcow[4];
props_.capPress(1, &s[0], &c, pcow, dpcow);
pcap = pcow[0];
ASSERT(pcow[1] == 0.0);
dpcap = dpcow[0];
ASSERT(dpcow[1] == 0.0);
ASSERT(dpcow[2] == 0.0);
ASSERT(dpcow[3] == 0.0);
}
double SimpleFluid2pWrappingProps::s_min(int c) const
{
return smin_[2*c + 0];
}
double SimpleFluid2pWrappingProps::s_max(int c) const
{
return smax_[2*c + 0];
}
}

View File

@ -0,0 +1,66 @@
/*===========================================================================
//
// File: SimpleFluid2pWrappingProps.hpp
//
// Author: hnil <hnil@sintef.no>
//
// Created: 15 Nov 2012
//==========================================================================*/
/*
Copyright 2011 SINTEF ICT, Applied Mathematics.
Copyright 2011 Statoil ASA.
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 SIMPLEFLUID2PWRAPPINGPROPS_HPP
#define SIMPLEFLUID2PWRAPPINGPROPS_HPP
namespace opm{
class SimpleFluid2pWrappingProps
{
public:
SimpleFluid2pWrappingProps(const Opm::IncompPropertiesInterface& props);
double density(int phase) const;
template <class Sat,
class Mob,
class DMob>
void mobility(int c, const Sat& s, Mob& mob, DMob& dmob) const;
template <class Sat,
class Pcap,
class DPcap>
void pc(int c, const Sat& s, Pcap& pcap, DPcap& dpcap) const;
double s_min(int c) const;
double s_max(int c) const;
private:
const Opm::IncompPropertiesInterface& props_;
std::vector<double> smin_;
std::vector<double> smax_;
}
}
#endif // SIMPLEFLUID2PWRAPPINGPROPS_HPP