From 1311e42208014c6d44e3b387896967859b554d95 Mon Sep 17 00:00:00 2001 From: Xavier Raynaud Date: Mon, 19 Mar 2012 09:47:44 +0100 Subject: [PATCH 1/2] updated test with band matrix assignement for lapack solver. --- tests/test_lapack.cpp | 77 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 13 deletions(-) diff --git a/tests/test_lapack.cpp b/tests/test_lapack.cpp index a9be6f27..1719a307 100644 --- a/tests/test_lapack.cpp +++ b/tests/test_lapack.cpp @@ -21,6 +21,26 @@ #include #include +namespace { + struct BandMatrixCoeff + { + BandMatrixCoeff(int N, int ku, int kl) : N_(N), ku_(ku), kl_(kl), nrow_(2*kl + ku + 1) { + } + + + // compute the position where to store the coefficient of a matrix A_{i,j} (i,j=0,...,N-1) + // in a array which is sent to the band matrix solver of LAPACK. + + int operator ()(int i, int j) { + return kl_ + ku_ + i - j + j*nrow_; + } + + const int ku_; + const int kl_; + const int nrow_; + const int N_; + }; +} //end anonymous namespace int main() { @@ -43,11 +63,11 @@ int main() } //test of dgbsv_ - const int kl = 1; - const int ku = 1; - const int nrowAB = 2*kl + ku + 1; - const int ldb = N; - const int ldab = nrowAB; + int kl = 1; + int ku = 1; + int nrowAB = 2*kl + ku + 1; + int ldb = N; + int ldab = nrowAB; int ipiv; std::vector AB(nrowAB*N, 0.); std::vector BB(N, 0.); @@ -64,14 +84,7 @@ int main() BB[2] = 2.6; BB[3] = 0.6; BB[4] = 2.7; - std::vector::iterator it; - - std::cout << "myvector contains:"; - for ( it=AB.begin() ; it < AB.end(); it++ ) { - std::cout << " " << *it; - } - - std::cout << std::endl; + dgbsv_(&N, &kl, &ku, &nrhs, &AB[0], &ldab, &ipiv, &BB[0], &ldb, &info); if (info == 0) { @@ -82,5 +95,43 @@ int main() } else { std::cerr << "Something went wrong in dgbsv_()\n"; } + + int NN = 3; + kl = 1; + ku = 1; + nrowAB = 2*kl + ku + 1; + ldb = NN; + ldab = nrowAB; + AB.assign(NN*nrowAB, 0.); + BB.assign(NN, 0.); + BandMatrixCoeff bmc(NN, ku, kl); + AB[bmc(0, 0)] = 1.; + AB[bmc(1, 0)] = 1.; + AB[bmc(0, 1)] = 1.; + AB[bmc(1, 1)] = 2.; + AB[bmc(2, 1)] = 2.; + AB[bmc(1, 2)] = 1.; + AB[bmc(2, 2)] = 4.; + BB[0] = 3.; + BB[1] = 8.; + BB[2] = 16.; + + // std::vector::iterator it; + // std::cout << "myvector contains:"; + // for ( it=AB.begin() ; it < AB.end(); it++ ) { + // std::cout << " " << *it; + // } + // std::cout << std::endl; + + dgbsv_(&NN ,&kl, &ku, &nrhs, &AB[0], &ldab, &ipiv, &BB[0], &ldb, &info); + if (info == 0) { + for (int i = 0; i < NN; ++i) { + std::cout << BB[i] << ' '; + } + std::cout << std::endl; + } else { + std::cerr << "Something went wrong in dgbsv_()\n"; + } + } From d4e50087439548a4615076865b0576929a67257e Mon Sep 17 00:00:00 2001 From: Xavier Raynaud Date: Tue, 20 Mar 2012 10:15:15 +0100 Subject: [PATCH 2/2] merge --- opm/core/utility/parameters/ParameterGroup.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opm/core/utility/parameters/ParameterGroup.hpp b/opm/core/utility/parameters/ParameterGroup.hpp index 6ad8f30c..1ad75663 100644 --- a/opm/core/utility/parameters/ParameterGroup.hpp +++ b/opm/core/utility/parameters/ParameterGroup.hpp @@ -47,7 +47,7 @@ along with OpenRS. If not, see . namespace Opm { namespace parameter { - /// ParameterGroup is a class that is used to provide run-time paramters. + /// ParameterGroup is a class that is used to provide run-time parameters. /// The standard use of the class is to call create it with the /// (int argc, char** argv) constructor (where the arguments are those /// given by main). This parses the command line, where each token @@ -55,7 +55,7 @@ namespace Opm { /// A) specifies a parameter (by a "param=value" token). /// B) specifies a xml file to be read (by a "filename.xml" token). /// C) specifies a param file to be read (by a "filename.param" token). - /// After the tokens are parsem they are stored in a tree structure + /// After the tokens are parsed they are stored in a tree structure /// in the ParameterGroup object; it is worth mentioning that parameters /// are inherited in this tree structure. Thus, if ``grid\_prefix'' is /// given a value in the root node, this value will be visible in all