This commit is contained in:
Kjetil Olsen Lye 2012-03-28 15:49:48 +02:00
commit 6b20238c13
12 changed files with 89 additions and 72 deletions

View File

@ -166,16 +166,16 @@ namespace Opm
} }
void SinglePvtLiveGas::evalBDeriv(const double press, const double* surfvol, void SinglePvtLiveGas::evalBDeriv(const double press, const double* surfvol,
double& B, double& dBdp) const double& Bval, double& dBdpval) const
{ {
if (surfvol[phase_pos_[Vapour]] == 0.0) { if (surfvol[phase_pos_[Vapour]] == 0.0) {
// To handle no-gas case. // To handle no-gas case.
B = 1.0; Bval = 1.0;
dBdp = 0.0; dBdpval = 0.0;
return; return;
} }
B = miscible_gas(press, surfvol, 1, false); Bval = miscible_gas(press, surfvol, 1, false);
dBdp = miscible_gas(press, surfvol, 1, true); dBdpval = miscible_gas(press, surfvol, 1, true);
} }
double SinglePvtLiveGas::evalR(const double press, const double* surfvol) const double SinglePvtLiveGas::evalR(const double press, const double* surfvol) const
@ -197,12 +197,12 @@ namespace Opm
} }
void SinglePvtLiveGas::evalRDeriv(const double press, const double* surfvol, void SinglePvtLiveGas::evalRDeriv(const double press, const double* surfvol,
double& R, double& dRdp) const double& Rval, double& dRdpval) const
{ {
if (surfvol[phase_pos_[Liquid]] == 0.0) { if (surfvol[phase_pos_[Liquid]] == 0.0) {
// To handle no-gas case. // To handle no-gas case.
R = 0.0; Rval = 0.0;
dRdp = 0.0; dRdpval = 0.0;
return; return;
} }
double satR = linearInterpolationExtrap(saturated_gas_table_[0], double satR = linearInterpolationExtrap(saturated_gas_table_[0],
@ -210,14 +210,14 @@ namespace Opm
double maxR = surfvol[phase_pos_[Liquid]]/surfvol[phase_pos_[Vapour]]; double maxR = surfvol[phase_pos_[Liquid]]/surfvol[phase_pos_[Vapour]];
if (satR < maxR ) { if (satR < maxR ) {
// Saturated case // Saturated case
R = satR; Rval = satR;
dRdp = linearInterpolDerivative(saturated_gas_table_[0], dRdpval = linearInterpolDerivative(saturated_gas_table_[0],
saturated_gas_table_[3], saturated_gas_table_[3],
press); press);
} else { } else {
// Undersaturated case // Undersaturated case
R = maxR; Rval = maxR;
dRdp = 0.0; dRdpval = 0.0;
} }
} }
@ -227,12 +227,12 @@ namespace Opm
const bool deriv) const const bool deriv) const
{ {
int section; int section;
double R = linearInterpolationExtrap(saturated_gas_table_[0], double Rval = linearInterpolationExtrap(saturated_gas_table_[0],
saturated_gas_table_[3], press, saturated_gas_table_[3], press,
section); section);
double maxR = surfvol[phase_pos_[Liquid]]/surfvol[phase_pos_[Vapour]]; double maxR = surfvol[phase_pos_[Liquid]]/surfvol[phase_pos_[Vapour]];
if (deriv) { if (deriv) {
if (R < maxR ) { // Saturated case if (Rval < maxR ) { // Saturated case
return linearInterpolDerivative(saturated_gas_table_[0], return linearInterpolDerivative(saturated_gas_table_[0],
saturated_gas_table_[item], saturated_gas_table_[item],
press); press);
@ -258,7 +258,7 @@ namespace Opm
return val; return val;
} }
} else { } else {
if (R < maxR ) { // Saturated case if (Rval < maxR ) { // Saturated case
return linearInterpolationExtrap(saturated_gas_table_[0], return linearInterpolationExtrap(saturated_gas_table_[0],
saturated_gas_table_[item], saturated_gas_table_[item],
press); press);

View File

@ -243,10 +243,10 @@ namespace Opm
void SinglePvtLiveOil::evalBDeriv(const double press, const double* surfvol, void SinglePvtLiveOil::evalBDeriv(const double press, const double* surfvol,
double& B, double& dBdp) const double& Bval, double& dBdpval) const
{ {
B = evalB(press, surfvol); Bval = evalB(press, surfvol);
dBdp = -B*B*miscible_oil(press, surfvol, 1, true); dBdpval = -Bval*Bval*miscible_oil(press, surfvol, 1, true);
} }
double SinglePvtLiveOil::evalR(double press, const double* surfvol) const double SinglePvtLiveOil::evalR(double press, const double* surfvol) const
@ -254,36 +254,36 @@ namespace Opm
if (surfvol[phase_pos_[Vapour]] == 0.0) { if (surfvol[phase_pos_[Vapour]] == 0.0) {
return 0.0; return 0.0;
} }
double R = linearInterpolationExtrap(saturated_oil_table_[0], double Rval = linearInterpolationExtrap(saturated_oil_table_[0],
saturated_oil_table_[3], press); saturated_oil_table_[3], press);
double maxR = surfvol[phase_pos_[Vapour]]/surfvol[phase_pos_[Liquid]]; double maxR = surfvol[phase_pos_[Vapour]]/surfvol[phase_pos_[Liquid]];
if (R < maxR ) { // Saturated case if (Rval < maxR ) { // Saturated case
return R; return Rval;
} else { } else {
return maxR; // Undersaturated case return maxR; // Undersaturated case
} }
} }
void SinglePvtLiveOil::evalRDeriv(const double press, const double* surfvol, void SinglePvtLiveOil::evalRDeriv(const double press, const double* surfvol,
double& R, double& dRdp) const double& Rval, double& dRdpval) const
{ {
if (surfvol[phase_pos_[Vapour]] == 0.0) { if (surfvol[phase_pos_[Vapour]] == 0.0) {
R = 0.0; Rval = 0.0;
dRdp = 0.0; dRdpval = 0.0;
return; return;
} }
R = linearInterpolationExtrap(saturated_oil_table_[0], Rval = linearInterpolationExtrap(saturated_oil_table_[0],
saturated_oil_table_[3], press); saturated_oil_table_[3], press);
double maxR = surfvol[phase_pos_[Vapour]]/surfvol[phase_pos_[Liquid]]; double maxR = surfvol[phase_pos_[Vapour]]/surfvol[phase_pos_[Liquid]];
if (R < maxR ) { if (Rval < maxR ) {
// Saturated case // Saturated case
dRdp = linearInterpolDerivative(saturated_oil_table_[0], dRdpval = linearInterpolDerivative(saturated_oil_table_[0],
saturated_oil_table_[3], saturated_oil_table_[3],
press); press);
} else { } else {
// Undersaturated case // Undersaturated case
R = maxR; Rval = maxR;
dRdp = 0.0; dRdpval = 0.0;
} }
} }
@ -294,12 +294,12 @@ namespace Opm
const bool deriv) const const bool deriv) const
{ {
int section; int section;
double R = linearInterpolationExtrap(saturated_oil_table_[0], double Rval = linearInterpolationExtrap(saturated_oil_table_[0],
saturated_oil_table_[3], saturated_oil_table_[3],
press, section); press, section);
double maxR = (surfvol[phase_pos_[Liquid]] == 0.0) ? 0.0 : surfvol[phase_pos_[Vapour]]/surfvol[phase_pos_[Liquid]]; double maxR = (surfvol[phase_pos_[Liquid]] == 0.0) ? 0.0 : surfvol[phase_pos_[Vapour]]/surfvol[phase_pos_[Liquid]];
if (deriv) { if (deriv) {
if (R < maxR ) { // Saturated case if (Rval < maxR ) { // Saturated case
return linearInterpolDerivative(saturated_oil_table_[0], return linearInterpolDerivative(saturated_oil_table_[0],
saturated_oil_table_[item], saturated_oil_table_[item],
press); press);
@ -321,7 +321,7 @@ namespace Opm
return val; return val;
} }
} else { } else {
if (R < maxR ) { // Saturated case if (Rval < maxR ) { // Saturated case
return linearInterpolationExtrap(saturated_oil_table_[0], return linearInterpolationExtrap(saturated_oil_table_[0],
saturated_oil_table_[item], saturated_oil_table_[item],
press); press);

View File

@ -431,7 +431,7 @@ coarse_topology_build_final(int ncoarse_f, int nblk,
int *subfacepos, int *subfaces) int *subfacepos, int *subfaces)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
{ {
int coarse_f, b1, b2, n, subpos, subface_valid; int coarse_f, b1, b2, n, subpos, subface_valid = 1;
size_t i; size_t i;
struct hash_set *set; struct hash_set *set;
@ -451,8 +451,6 @@ coarse_topology_build_final(int ncoarse_f, int nblk,
coarse_f = 0; coarse_f = 0;
subpos = 0; subpos = 0;
subface_valid = 1;
for (b1 = 0; (b1 < nblk) && subface_valid; b1++) { for (b1 = 0; (b1 < nblk) && subface_valid; b1++) {
if (bns[b1] != NULL) { if (bns[b1] != NULL) {
for (n = 0; n < bns[b1]->nneigh; n++) { for (n = 0; n < bns[b1]->nneigh; n++) {

View File

@ -718,7 +718,7 @@ blkdof_fill(struct coarse_topology *ct,
struct coarse_sys *sys) struct coarse_sys *sys)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
{ {
int p, ret, dof; int p, ret = 0, dof;
size_t b, nb; size_t b, nb;
nb = ct->nblocks; nb = ct->nblocks;
@ -749,7 +749,6 @@ blkdof_fill(struct coarse_topology *ct,
if (sys->blkdof == NULL) { if (sys->blkdof == NULL) {
free(sys->blkdof_pos); free(sys->blkdof_pos);
sys->blkdof_pos = NULL; sys->blkdof_pos = NULL;
ret = 0;
} else { } else {
sys->blkdof_pos[0] = 0; sys->blkdof_pos[0] = 0;

View File

@ -296,7 +296,7 @@ ifsh_ms_impl_construct(struct UnstructuredGrid *G ,
LocalSolver linsolve) LocalSolver linsolve)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
{ {
int max_nconn, nb, nconn_tot; int max_nconn = -1, nb, nconn_tot;
int expected_nconn, alloc_ok; int expected_nconn, alloc_ok;
struct ifsh_ms_impl *new; struct ifsh_ms_impl *new;

View File

@ -785,7 +785,7 @@ assemble_completion_to_well(int w, int c, int nc, int np,
{ {
int wdof; int wdof;
size_t jc, jw; size_t jc, jw;
double res, w2c, w2w; double res = 0.0, w2c = 0.0, w2w = 0.0;
switch (W->ctrl->ctrl[w]) { switch (W->ctrl->ctrl[w]) {
case BHP : case BHP :

View File

@ -723,28 +723,3 @@ fill_cart_geometry_2d(struct UnstructuredGrid *G,
} }
} }
} }
#if UNIT_TEST
int main(void)
{
struct UnstructuredGrid *g = create_cart_grid_2d(2,2);
int i;
int k;
for(i=0; i<g->number_of_cells; ++i)
{
fprintf(stderr, "%d: ", i);
for (k=g->cell_facepos[i]; k<g->cell_facepos[i+1]; ++k)
{
fprintf(stderr, "%d ", g->cell_faces[k]);
}
fprintf(stderr, "\n");
}
free_grid(g);
return 0;
}
#endif

View File

@ -85,9 +85,9 @@ namespace Opm {
return path_; return path_;
} }
ParameterGroup::ParameterGroup(const std::string& path, ParameterGroup::ParameterGroup(const std::string& patharg,
const ParameterGroup* parent) const ParameterGroup* parent)
: path_(path), parent_(parent), output_is_enabled_(true) : path_(patharg), parent_(parent), output_is_enabled_(true)
{ {
} }

View File

@ -54,6 +54,8 @@ namespace Opm {
namespace parameter { namespace parameter {
namespace tinyxml { namespace tinyxml {
std::string getProperty(const std::string& property,
const TiXmlElement* node_ptr);
void read_xml(ParameterGroup& pg, const std::string filename); void read_xml(ParameterGroup& pg, const std::string filename);
void fill_tree(ParameterGroup& pg, void fill_tree(ParameterGroup& pg,
const TiXmlNode* root, const TiXmlNode* root,

View File

@ -667,7 +667,7 @@ int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const
} }
int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* value ) const int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* valuearg ) const
{ {
const TiXmlAttribute* node = attributeSet.Find( name ); const TiXmlAttribute* node = attributeSet.Find( name );
if ( !node ) if ( !node )
@ -675,7 +675,7 @@ int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* value ) co
int ival = 0; int ival = 0;
int result = node->QueryIntValue( &ival ); int result = node->QueryIntValue( &ival );
*value = (unsigned)ival; *valuearg = (unsigned)ival;
return result; return result;
} }

View File

@ -14,6 +14,7 @@ monotcubicinterpolator_test \
param_test \ param_test \
sparsetable_test \ sparsetable_test \
sparsevector_test \ sparsevector_test \
test_cartgrid \
test_column_extract \ test_column_extract \
test_lapack \ test_lapack \
test_readpolymer \ test_readpolymer \
@ -30,6 +31,7 @@ sparsetable_test_SOURCES = sparsetable_test.cpp
sparsetable_test_LDADD = $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LDADD) sparsetable_test_LDADD = $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LDADD)
sparsevector_test_SOURCES = sparsevector_test.cpp sparsevector_test_SOURCES = sparsevector_test.cpp
sparsevector_test_LDADD = $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LDADD) sparsevector_test_LDADD = $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LDADD)
test_cartgrid_SOURCES = test_cartgrid.cpp
test_column_extract_SOURCES = test_column_extract.cpp test_column_extract_SOURCES = test_column_extract.cpp
test_column_extract_LDADD = $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LDADD) test_column_extract_LDADD = $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LDADD)
test_lapack_SOURCES = test_lapack.cpp test_lapack_SOURCES = test_lapack.cpp

41
tests/test_cartgrid.cpp Normal file
View File

@ -0,0 +1,41 @@
/*
Copyright 2012 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/>.
*/
#include <opm/core/utility/cpgpreprocess/cgridinterface.h>
#include <opm/core/utility/cart_grid.h>
#include <opm/core/grid.h>
#include <cstdio>
int main(void)
{
using namespace std;
struct UnstructuredGrid *g = create_cart_grid_2d(2, 2);
int i;
int k;
for (i = 0; i < g->number_of_cells; ++i) {
fprintf(stderr, "%d: ", i);
for (k = g->cell_facepos[i]; k < g->cell_facepos[i + 1]; ++k) {
fprintf(stderr, "%d ", g->cell_faces[k]);
}
fprintf(stderr, "\n");
}
free_grid(g);
return 0;
}