mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Fixed sim_simple.cpp
This commit is contained in:
@@ -83,11 +83,11 @@ endif()
|
|||||||
# originally generated with the command:
|
# originally generated with the command:
|
||||||
# find tutorials examples -name '*.c*' -printf '\t%p\n' | sort
|
# find tutorials examples -name '*.c*' -printf '\t%p\n' | sort
|
||||||
list (APPEND EXAMPLE_SOURCE_FILES
|
list (APPEND EXAMPLE_SOURCE_FILES
|
||||||
# examples/find_zero.cpp
|
examples/find_zero.cpp
|
||||||
examples/flow.cpp
|
examples/flow.cpp
|
||||||
# examples/flow_solvent.cpp
|
examples/flow_solvent.cpp
|
||||||
# examples/sim_2p_incomp_ad.cpp
|
examples/sim_2p_incomp_ad.cpp
|
||||||
# examples/sim_simple.cpp
|
examples/sim_simple.cpp
|
||||||
# examples/opm_init_check.cpp
|
# examples/opm_init_check.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ phaseMobility(const Opm::IncompPropertiesInterface& props,
|
|||||||
{
|
{
|
||||||
typedef Eigen::Array<double, Eigen::Dynamic, 2, Eigen::RowMajor> TwoCol;
|
typedef Eigen::Array<double, Eigen::Dynamic, 2, Eigen::RowMajor> TwoCol;
|
||||||
typedef Eigen::Array<double, Eigen::Dynamic, 4, Eigen::RowMajor> FourCol;
|
typedef Eigen::Array<double, Eigen::Dynamic, 4, Eigen::RowMajor> FourCol;
|
||||||
|
typedef Eigen::SparseMatrix<double> S;
|
||||||
typedef typename ADB::V V;
|
typedef typename ADB::V V;
|
||||||
typedef typename ADB::M M;
|
typedef typename ADB::M M;
|
||||||
const int nc = props.numCells();
|
const int nc = props.numCells();
|
||||||
@@ -79,8 +80,8 @@ phaseMobility(const Opm::IncompPropertiesInterface& props,
|
|||||||
V kro = kr.rightCols<1>();
|
V kro = kr.rightCols<1>();
|
||||||
V dkrw = dkr.leftCols<1>(); // Left column is top-left of dkr/ds 2x2 matrix.
|
V dkrw = dkr.leftCols<1>(); // Left column is top-left of dkr/ds 2x2 matrix.
|
||||||
V dkro = -dkr.rightCols<1>(); // Right column is bottom-right of dkr/ds 2x2 matrix.
|
V dkro = -dkr.rightCols<1>(); // Right column is bottom-right of dkr/ds 2x2 matrix.
|
||||||
M krwjac(nc,nc);
|
S krwjac(nc,nc);
|
||||||
M krojac(nc,nc);
|
S krojac(nc,nc);
|
||||||
auto sizes = Eigen::ArrayXi::Ones(nc);
|
auto sizes = Eigen::ArrayXi::Ones(nc);
|
||||||
krwjac.reserve(sizes);
|
krwjac.reserve(sizes);
|
||||||
krojac.reserve(sizes);
|
krojac.reserve(sizes);
|
||||||
@@ -89,8 +90,8 @@ phaseMobility(const Opm::IncompPropertiesInterface& props,
|
|||||||
krojac.insert(c,c) = dkro(c);
|
krojac.insert(c,c) = dkro(c);
|
||||||
}
|
}
|
||||||
const double* mu = props.viscosity();
|
const double* mu = props.viscosity();
|
||||||
std::vector<M> dmw = { krwjac/mu[0] };
|
std::vector<M> dmw = { M(krwjac)/mu[0] };
|
||||||
std::vector<M> dmo = { krojac/mu[1] };
|
std::vector<M> dmo = { M(krojac)/mu[1] };
|
||||||
|
|
||||||
std::vector<ADB> pmobc = { ADB::function(krw / mu[0], std::move(dmw)) ,
|
std::vector<ADB> pmobc = { ADB::function(krw / mu[0], std::move(dmw)) ,
|
||||||
ADB::function(kro / mu[1], std::move(dmo)) };
|
ADB::function(kro / mu[1], std::move(dmo)) };
|
||||||
@@ -116,6 +117,7 @@ try
|
|||||||
typedef Opm::AutoDiffBlock<double> ADB;
|
typedef Opm::AutoDiffBlock<double> ADB;
|
||||||
typedef ADB::V V;
|
typedef ADB::V V;
|
||||||
typedef ADB::M M;
|
typedef ADB::M M;
|
||||||
|
typedef Eigen::SparseMatrix<double> S;
|
||||||
|
|
||||||
Opm::time::StopWatch clock;
|
Opm::time::StopWatch clock;
|
||||||
clock.start();
|
clock.start();
|
||||||
@@ -211,13 +213,14 @@ try
|
|||||||
// residual.derived()[0].
|
// residual.derived()[0].
|
||||||
|
|
||||||
#if HAVE_SUITESPARSE_UMFPACK_H
|
#if HAVE_SUITESPARSE_UMFPACK_H
|
||||||
typedef Eigen::UmfPackLU<M> LinSolver;
|
typedef Eigen::UmfPackLU<S> LinSolver;
|
||||||
#else
|
#else
|
||||||
typedef Eigen::BiCGSTAB<M> LinSolver;
|
typedef Eigen::BiCGSTAB<S> LinSolver;
|
||||||
#endif // HAVE_SUITESPARSE_UMFPACK_H
|
#endif // HAVE_SUITESPARSE_UMFPACK_H
|
||||||
|
|
||||||
LinSolver solver;
|
LinSolver solver;
|
||||||
M pmatr = residual.derivative()[0];
|
S pmatr;
|
||||||
|
residual.derivative()[0].toSparse(pmatr);
|
||||||
pmatr.coeffRef(0,0) *= 2.0;
|
pmatr.coeffRef(0,0) *= 2.0;
|
||||||
pmatr.makeCompressed();
|
pmatr.makeCompressed();
|
||||||
solver.compute(pmatr);
|
solver.compute(pmatr);
|
||||||
@@ -275,7 +278,8 @@ try
|
|||||||
std::cout << "res_norm[" << it << "] = "
|
std::cout << "res_norm[" << it << "] = "
|
||||||
<< res_norm << std::endl;
|
<< res_norm << std::endl;
|
||||||
|
|
||||||
M smatr = transport_residual.derivative()[0];
|
S smatr;
|
||||||
|
transport_residual.derivative()[0].toSparse(smatr);
|
||||||
smatr.makeCompressed();
|
smatr.makeCompressed();
|
||||||
solver.compute(smatr);
|
solver.compute(smatr);
|
||||||
if (solver.info() != Eigen::Success) {
|
if (solver.info() != Eigen::Success) {
|
||||||
|
|||||||
Reference in New Issue
Block a user