Merge pull request #282 from juliohm/master
Remove trailing whitespaces
This commit is contained in:
commit
0faa2bb49c
64 files changed
+1133
-1134
No files matched your search
+13
-13
@@ -45,7 +45,7 @@ const ecl_type_enum outputFloatType = ECL_DOUBLE_TYPE;
|
||||
/*
|
||||
Only keywords which have more >= minImportSize elements are
|
||||
converted to binary form. This is to avoid conversion of short
|
||||
keywords like MAPAXES and TABDIMS.
|
||||
keywords like MAPAXES and TABDIMS.
|
||||
*/
|
||||
const int minImportSize = 10;
|
||||
|
||||
@@ -64,7 +64,7 @@ static void skipKeyword( std::ifstream& is) {
|
||||
break;
|
||||
} else
|
||||
is >> ignoreLine;
|
||||
|
||||
|
||||
if (!is.good()) {
|
||||
is.clear();
|
||||
is.seekg( 0 , std::ios::end );
|
||||
@@ -80,7 +80,7 @@ static void copyKeyword( std::ifstream& is , std::ofstream& os) {
|
||||
{
|
||||
std::ios::pos_type end_pos = is.tellg();
|
||||
long length = end_pos - start_pos;
|
||||
|
||||
|
||||
{
|
||||
char * buffer = new char[length];
|
||||
{
|
||||
@@ -121,7 +121,7 @@ static bool convertKeyword( const std::string& inputFile , const std::string& ou
|
||||
{
|
||||
std::ios::pos_type inputPos = is.tellg();
|
||||
ecl_kw_type * ecl_kw = loadFromcstdio( inputFile , inputPos , ecl_type );
|
||||
|
||||
|
||||
if (ecl_kw_get_size( ecl_kw ) >= minImportSize) {
|
||||
{
|
||||
if (outputPath.empty())
|
||||
@@ -133,7 +133,7 @@ static bool convertKeyword( const std::string& inputFile , const std::string& ou
|
||||
ecl_kw_fwrite( ecl_kw , fortio );
|
||||
fortio_fclose( fortio );
|
||||
}
|
||||
|
||||
|
||||
os << "IMPORT" << std::endl << " '" << outputFile << "' /" << std::endl << std::endl;
|
||||
}
|
||||
is.seekg( inputPos );
|
||||
@@ -141,7 +141,7 @@ static bool convertKeyword( const std::string& inputFile , const std::string& ou
|
||||
copyKeyword( is , os );
|
||||
convert = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ecl_kw_free( ecl_kw );
|
||||
}
|
||||
@@ -156,7 +156,7 @@ static bool parseFile(const std::string& inputFile, std::string& outputFile, con
|
||||
bool updateFile = false;
|
||||
std::cout << indent << "Parsing " << inputFile << "\n";
|
||||
{
|
||||
std::ifstream is(inputFile.c_str());
|
||||
std::ifstream is(inputFile.c_str());
|
||||
if (is) {
|
||||
std::ofstream os;
|
||||
std::string keyword;
|
||||
@@ -165,11 +165,11 @@ static bool parseFile(const std::string& inputFile, std::string& outputFile, con
|
||||
boost::filesystem::path inputPath(inputFile);
|
||||
path = inputPath.parent_path().string();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
std::string basename;
|
||||
std::string extension;
|
||||
|
||||
|
||||
outputFile = inputFile;
|
||||
size_t ext_pos = inputFile.rfind(".");
|
||||
if (ext_pos == std::string::npos) {
|
||||
@@ -179,14 +179,14 @@ static bool parseFile(const std::string& inputFile, std::string& outputFile, con
|
||||
basename = outputFile.substr(0,ext_pos);
|
||||
extension = outputFile.substr(ext_pos);
|
||||
}
|
||||
|
||||
|
||||
outputFile = basename + "_import" + extension;
|
||||
}
|
||||
os.open( outputFile.c_str() );
|
||||
|
||||
|
||||
while(is.good()) {
|
||||
is >> ignoreWhitespace;
|
||||
{
|
||||
{
|
||||
std::ios::pos_type start_pos = is.tellg();
|
||||
if (EclipseGridParser::readKeyword( is , keyword )) {
|
||||
FieldType fieldType = EclipseGridParser::classifyKeyword( keyword );
|
||||
@@ -231,7 +231,7 @@ static bool parseFile(const std::string& inputFile, std::string& outputFile, con
|
||||
is >> ignoreLine; // Not at a valid keyword
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
os.close();
|
||||
is.close();
|
||||
if (updateFile)
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Opm {
|
||||
inline void extractColumn( const UnstructuredGrid& grid, std::vector<std::vector<int> >& columns )
|
||||
{
|
||||
const int* dims = grid.cartdims;
|
||||
|
||||
|
||||
// Keeps track of column_index ---> index of vector
|
||||
std::map<int, int> global_to_local;
|
||||
for (int cell = 0; cell < grid.number_of_cells; ++cell) {
|
||||
@@ -73,7 +73,7 @@ inline void extractColumn( const UnstructuredGrid& grid, std::vector<std::vector
|
||||
local_index = local_index_iterator->second;
|
||||
} else {
|
||||
local_index = columns.size();
|
||||
global_to_local[i_cart+j_cart*dims[0]] = local_index;
|
||||
global_to_local[i_cart+j_cart*dims[0]] = local_index;
|
||||
columns.push_back(std::vector<int>());
|
||||
}
|
||||
columns[local_index].push_back(cell);
|
||||
@@ -116,7 +116,7 @@ inline void extractColumn( const UnstructuredGrid& grid, std::vector<std::vector
|
||||
for (int col = num_cols; col < num_cols_all; ++col) {
|
||||
columns[col].swap(new_columns[col - num_cols]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace Opm
|
||||
@@ -95,7 +95,7 @@ extern "C" {
|
||||
* @param[in,out] g Grid structure.
|
||||
*/
|
||||
void compute_geometry(struct UnstructuredGrid *g);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -53,7 +53,7 @@ compute_face_geometry_3d(double *coords, int nfaces,
|
||||
int num_face_nodes;
|
||||
double area;
|
||||
/*#pragma omp parallel for */
|
||||
|
||||
|
||||
/*#pragma omp parallel for shared(fnormals,fcentroids,fareas)*/
|
||||
#pragma omp parallel for default(none) \
|
||||
private(f,x,u,v,w,i,k,node,cface,n,a,num_face_nodes,area) \
|
||||
@@ -292,7 +292,7 @@ compute_cell_geometry_3d(double *coords,
|
||||
node = facenodes[nodepos[face+1]-1];
|
||||
for(i=0; i<ndims; ++i) u[i] = coords[3*node+i] - x[i];
|
||||
|
||||
|
||||
|
||||
/* Compute triangular contributions to face normal and face centroid */
|
||||
for(k=nodepos[face]; k<nodepos[face+1]; ++k)
|
||||
{
|
||||
@@ -309,7 +309,7 @@ compute_cell_geometry_3d(double *coords,
|
||||
tet_volume += w[i]*(x[i]-xcell[i]);
|
||||
}
|
||||
tet_volume *= 0.5 / 3;
|
||||
|
||||
|
||||
subnormal_sign=0.0;
|
||||
for(i=0; i<ndims; ++i){
|
||||
subnormal_sign += w[i]*fnormals[3*face+i];
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace Opm
|
||||
|
||||
void verifyInscribedShoebox(int imin, int ilen, int imax,
|
||||
int jmin, int jlen, int jmax,
|
||||
double zmin, double zlen, double zmax)
|
||||
double zmin, double zlen, double zmax)
|
||||
{
|
||||
if (imin < 0) {
|
||||
std::cerr << "Error! imin < 0 (imin = " << imin << ")\n";
|
||||
@@ -232,7 +232,7 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
filterIntegerField("ACTNUM", new_ACTNUM_);
|
||||
filterDoubleField("PORO", new_PORO_);
|
||||
filterDoubleField("PERMX", new_PERMX_);
|
||||
|
||||
@@ -78,14 +78,14 @@ EclipseGridInspector::EclipseGridInspector(const EclipseGridParser& parser)
|
||||
}
|
||||
|
||||
/**
|
||||
Return the dip slopes for the cell relative to xy-plane in x- and y- direction.
|
||||
Dip slope is average rise in positive x-direction over cell length in x-direction.
|
||||
Return the dip slopes for the cell relative to xy-plane in x- and y- direction.
|
||||
Dip slope is average rise in positive x-direction over cell length in x-direction.
|
||||
Similarly for y.
|
||||
|
||||
Current implementation is for vertical pillars, but is not difficult to fix.
|
||||
|
||||
@returns a std::pair<double,double> with x-dip in first component and y-dip in second.
|
||||
*/
|
||||
*/
|
||||
std::pair<double,double> EclipseGridInspector::cellDips(int i, int j, int k) const
|
||||
{
|
||||
checkLogicalCoords(i, j, k);
|
||||
@@ -176,15 +176,15 @@ std::pair<double,double> EclipseGridInspector::cellDips(int cell_idx) const
|
||||
|
||||
boost::array<int, 3> EclipseGridInspector::cellIdxToLogicalCoords(int cell_idx) const
|
||||
{
|
||||
|
||||
|
||||
int i,j,k; // Position of cell in cell hierarchy
|
||||
int horIdx = (cell_idx+1) - int(std::floor(((double)(cell_idx+1))/((double)(logical_gridsize_[0]*logical_gridsize_[1]))))*logical_gridsize_[0]*logical_gridsize_[1]; // index in the corresponding horizon
|
||||
if (horIdx == 0) {
|
||||
horIdx = logical_gridsize_[0]*logical_gridsize_[1];
|
||||
if (horIdx == 0) {
|
||||
horIdx = logical_gridsize_[0]*logical_gridsize_[1];
|
||||
}
|
||||
i = horIdx - int(std::floor(((double)horIdx)/((double)logical_gridsize_[0])))*logical_gridsize_[0];
|
||||
if (i == 0) {
|
||||
i = logical_gridsize_[0];
|
||||
if (i == 0) {
|
||||
i = logical_gridsize_[0];
|
||||
}
|
||||
j = (horIdx-i)/logical_gridsize_[0]+1;
|
||||
k = ((cell_idx+1)-logical_gridsize_[0]*(j-1)-1)/(logical_gridsize_[0]*logical_gridsize_[1])+1;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
//===========================================================================
|
||||
//
|
||||
// File: EclipseGridInspector.h
|
||||
//
|
||||
// Created: Mon Jun 2 09:46:08 2008
|
||||
//
|
||||
//
|
||||
// File: EclipseGridInspector.h
|
||||
//
|
||||
// Created: Mon Jun 2 09:46:08 2008
|
||||
//
|
||||
// Author: Atgeirr F Rasmussen <atgeirr@sintef.no>
|
||||
//
|
||||
// $Date$
|
||||
//
|
||||
//
|
||||
// Revision: $Id: EclipseGridInspector.h,v 1.2 2008/08/18 14:16:12 atgeirr Exp $
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
/*
|
||||
@@ -77,9 +77,9 @@ public:
|
||||
|
||||
// Convert global cell index to logical ijk-coordinates
|
||||
boost::array<int, 3> cellIdxToLogicalCoords(int cell_idx) const;
|
||||
|
||||
|
||||
/// Returns a vector with the outer limits of grid (in the grid's unit).
|
||||
/// The vector contains [xmin, xmax, ymin, ymax, zmin, zmax], as
|
||||
/// The vector contains [xmin, xmax, ymin, ymax, zmin, zmax], as
|
||||
/// read from COORDS and ZCORN
|
||||
boost::array<double, 6> getGridLimits() const;
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace {
|
||||
return us;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // anon namespace
|
||||
|
||||
@@ -242,7 +242,7 @@ EclipseGridParser::EclipseGridParser(const string& filename, bool convert_to_SI)
|
||||
return Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool EclipseGridParser::readKeyword(std::istream& is, std::string& keyword)
|
||||
{
|
||||
@@ -253,7 +253,7 @@ bool EclipseGridParser::readKeyword(std::istream& is, std::string& keyword)
|
||||
for (i=0; i<9; ++i) {
|
||||
buf[i] = '\0';
|
||||
}
|
||||
|
||||
|
||||
/* Read first character and check if it is uppercase*/
|
||||
//buf[0] = fgetc(fp);
|
||||
is.get(buf[0]);
|
||||
@@ -261,7 +261,7 @@ bool EclipseGridParser::readKeyword(std::istream& is, std::string& keyword)
|
||||
is.unget();
|
||||
return false; /* NOT VALID CHARACTER */
|
||||
}
|
||||
|
||||
|
||||
/* Scan as much as possible possible keyword, 8 characters long */
|
||||
i = 1;
|
||||
is.get(c);
|
||||
@@ -275,7 +275,7 @@ bool EclipseGridParser::readKeyword(std::istream& is, std::string& keyword)
|
||||
buf[i++] = c;
|
||||
is.get(c);
|
||||
}
|
||||
|
||||
|
||||
/* Skip rest of line */
|
||||
if (c != '\n'){
|
||||
is.get(c);
|
||||
@@ -288,14 +288,14 @@ bool EclipseGridParser::readKeyword(std::istream& is, std::string& keyword)
|
||||
if(c == '\n') {
|
||||
is.unget();
|
||||
}
|
||||
|
||||
|
||||
/* Find first non-uppercase or non-digit character */
|
||||
for (i=0; i<8; ++i) {
|
||||
if ( !(isupper(buf[i]) || isdigit(buf[i])) ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Check if remaining characters are blank */
|
||||
for (j = i; j<8; ++j) {
|
||||
if(!isspace(buf[j]) && buf[j] != '\0') {
|
||||
@@ -309,7 +309,7 @@ bool EclipseGridParser::readKeyword(std::istream& is, std::string& keyword)
|
||||
keyword = keyword.substr(0, end+1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Read the given stream, overwriting any previous data.
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -559,7 +559,7 @@ void EclipseGridParser::convertToSI()
|
||||
key == "PWAVEMOD" || key == "MULTPV" || key == "PWAVEMOD" ||
|
||||
key == "SGAS" || key == "SWAT" || key == "SOIL" ||
|
||||
key == "SWCR" || key == "SWL" ||
|
||||
key == "SWU" || key == "SOWCR" || key == "KRW" ||
|
||||
key == "SWU" || key == "SOWCR" || key == "KRW" ||
|
||||
key == "KRWR" || key == "KRORW" || key == "KRO") {
|
||||
unit = 1.0;
|
||||
do_convert = false; // Dimensionless keywords...
|
||||
@@ -834,11 +834,11 @@ void EclipseGridParser::computeUnits()
|
||||
THROW("Unknown unit family " << unit_family);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct grdecl EclipseGridParser::get_grdecl() const {
|
||||
struct grdecl grdecl;
|
||||
|
||||
|
||||
// Extract data from deck.
|
||||
const std::vector<double>& zcorn = getFloatingPointValue("ZCORN");
|
||||
const std::vector<double>& coord = getFloatingPointValue("COORD");
|
||||
@@ -855,9 +855,9 @@ struct grdecl EclipseGridParser::get_grdecl() const {
|
||||
} else {
|
||||
THROW("Deck must have either DIMENS or SPECGRID.");
|
||||
}
|
||||
|
||||
|
||||
// Collect in input struct for preprocessing.
|
||||
|
||||
|
||||
grdecl.zcorn = &zcorn[0];
|
||||
grdecl.coord = &coord[0];
|
||||
grdecl.actnum = actnum;
|
||||
@@ -870,8 +870,8 @@ struct grdecl EclipseGridParser::get_grdecl() const {
|
||||
grdecl.mapaxes = &mapaxes[0];
|
||||
} else
|
||||
grdecl.mapaxes = NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
return grdecl;
|
||||
}
|
||||
|
||||
@@ -880,16 +880,16 @@ struct grdecl EclipseGridParser::get_grdecl() const {
|
||||
/*
|
||||
This function will create a ecl_kw instance filled with the data
|
||||
from input argument @keyword. The ecl_kw will get it's own copy of
|
||||
the data.
|
||||
the data.
|
||||
|
||||
If the input type ecl_type == ECL_INT_TYPE the function will use the
|
||||
getIntegerValue() method to get the keyword data, if ecl_type ==
|
||||
ECL_DOUBLE_TYPE || ECL_FLOAT_TYPE the getFloatingPointValue()
|
||||
function is invoked. If ecl_type == ECL_FLOAT_TYPE the data will be
|
||||
converted to when inserting into the ecl_kw.
|
||||
|
||||
|
||||
When the ecl_kw instance is no longer needed it should be discarded
|
||||
with a call to ecl_kw_free( ).
|
||||
with a call to ecl_kw_free( ).
|
||||
|
||||
If you are asking for a non-existent field the function will return NULL
|
||||
*/
|
||||
@@ -909,8 +909,8 @@ ecl_kw_type * EclipseGridParser::newEclKW(const std::string &keyword , ecl_type_
|
||||
} else if (ecl_type == ECL_FLOAT_TYPE) {
|
||||
ecl_kw = ecl_kw_alloc( keyword.c_str() , data.size() , ecl_type );
|
||||
for (std::vector<double>::size_type i=0; i < data.size(); i++)
|
||||
ecl_kw_iset_float( ecl_kw , i , data[i] );
|
||||
}
|
||||
ecl_kw_iset_float( ecl_kw , i , data[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
return ecl_kw;
|
||||
@@ -920,7 +920,7 @@ ecl_kw_type * EclipseGridParser::newEclKW(const std::string &keyword , ecl_type_
|
||||
/**
|
||||
This function will extract the COORD, ZCORN, ACTNUM and optionaly
|
||||
MAPAXES keywords from the eclipse deck and create an ecl_grid
|
||||
instance.
|
||||
instance.
|
||||
|
||||
When you are finished working with the ecl_grid instance it should
|
||||
be disposed with ecl_grid_free( ).
|
||||
@@ -938,7 +938,7 @@ ecl_grid_type * EclipseGridParser::newGrid( ) {
|
||||
mapaxes_kw = newEclKW( MAPAXES_KW , ECL_FLOAT_TYPE );
|
||||
|
||||
grid = ecl_grid_alloc_GRDECL_kw( grdecl.dims[0] , grdecl.dims[1] , grdecl.dims[2] , zcorn_kw , coord_kw , actnum_kw , mapaxes_kw );
|
||||
|
||||
|
||||
ecl_kw_free( coord_kw );
|
||||
ecl_kw_free( zcorn_kw );
|
||||
ecl_kw_free( actnum_kw );
|
||||
@@ -952,7 +952,7 @@ ecl_grid_type * EclipseGridParser::newGrid( ) {
|
||||
|
||||
/**
|
||||
This function will save an EGRID file based on the COORD, ZCORN,
|
||||
ACTNUM and optionally MAPAXES keywords included in the deck.
|
||||
ACTNUM and optionally MAPAXES keywords included in the deck.
|
||||
|
||||
This function creates the EGRID file without going through a
|
||||
ecl_grid instance; this is obviously somewhat faster and less
|
||||
@@ -976,7 +976,7 @@ void EclipseGridParser::saveEGRID( const std::string & filename) const {
|
||||
cerr << "Could not determine formatted/unformatted status of file:" << filename << " non-standard name?" << endl;
|
||||
throw exception();
|
||||
}
|
||||
|
||||
|
||||
fortio = fortio_open_writer( filename.c_str() , fmt_file , endian_flip );
|
||||
{
|
||||
float * mapaxes = NULL;
|
||||
@@ -988,7 +988,7 @@ void EclipseGridParser::saveEGRID( const std::string & filename) const {
|
||||
|
||||
ecl_grid_fwrite_EGRID_header( grdecl.dims , mapaxes , fortio );
|
||||
|
||||
if (grdecl.mapaxes != NULL)
|
||||
if (grdecl.mapaxes != NULL)
|
||||
delete[] mapaxes;
|
||||
}
|
||||
{
|
||||
@@ -1001,7 +1001,7 @@ void EclipseGridParser::saveEGRID( const std::string & filename) const {
|
||||
ecl_kw_fwrite( zcorn_kw , fortio );
|
||||
ecl_kw_fwrite( actnum_kw , fortio );
|
||||
ecl_kw_fwrite( endgrid_kw , fortio );
|
||||
|
||||
|
||||
ecl_kw_free( coord_kw );
|
||||
ecl_kw_free( zcorn_kw );
|
||||
ecl_kw_free( actnum_kw );
|
||||
@@ -1012,7 +1012,7 @@ void EclipseGridParser::saveEGRID( const std::string & filename) const {
|
||||
|
||||
/**
|
||||
Will query the deck for keyword @kw; and save it to the @fortio
|
||||
instance if the keyword can be found.
|
||||
instance if the keyword can be found.
|
||||
*/
|
||||
void EclipseGridParser::save_kw( fortio_type * fortio , const std::string & kw , ecl_type_enum ecl_type) {
|
||||
ecl_kw_type * ecl_kw = newEclKW( kw , ecl_type );
|
||||
@@ -1045,25 +1045,25 @@ void EclipseGridParser::saveINIT( const std::string & filename , const ecl_grid_
|
||||
{
|
||||
ecl_kw_type * poro_kw = newEclKW( PORO_KW , ECL_FLOAT_TYPE );
|
||||
time_t start_date;
|
||||
|
||||
|
||||
{
|
||||
tm td_tm = to_tm( start_date_ );
|
||||
start_date = mktime( &td_tm );
|
||||
}
|
||||
|
||||
ecl_init_file_fwrite_header( fortio , ecl_grid , poro_kw , phases , start_date );
|
||||
|
||||
ecl_init_file_fwrite_header( fortio , ecl_grid , poro_kw , phases , start_date );
|
||||
ecl_kw_free( poro_kw );
|
||||
}
|
||||
|
||||
|
||||
/* This collection of keywords is somewhat arbitrary and random. */
|
||||
save_kw( fortio , "PERMX" , ECL_FLOAT_TYPE);
|
||||
save_kw( fortio , "PERMY" , ECL_FLOAT_TYPE);
|
||||
save_kw( fortio , "PERMZ" , ECL_FLOAT_TYPE);
|
||||
|
||||
|
||||
save_kw( fortio , "FIPNUM" , ECL_INT_TYPE);
|
||||
save_kw( fortio , "SATNUM" , ECL_INT_TYPE);
|
||||
save_kw( fortio , "EQLNUM" , ECL_INT_TYPE);
|
||||
|
||||
|
||||
fortio_fclose( fortio );
|
||||
}
|
||||
|
||||
@@ -1071,7 +1071,7 @@ void EclipseGridParser::saveINIT( const std::string & filename , const ecl_grid_
|
||||
/**
|
||||
This is the main function used to save the state of the ECLIPSE
|
||||
deck in ECLIPSE format. The function will save an INIT file and an
|
||||
EGRID file.
|
||||
EGRID file.
|
||||
|
||||
The input arguments are the output directory to store files in, and
|
||||
the basename to use for the files; the function will build up a
|
||||
@@ -1082,10 +1082,10 @@ void EclipseGridParser::saveEGRID_INIT( const std::string& output_dir , const st
|
||||
ecl_grid_type * ecl_grid = newGrid();
|
||||
char * egrid_file = ecl_util_alloc_filename( output_dir.c_str() , basename.c_str() , ECL_EGRID_FILE , fmt_file , 0);
|
||||
char * init_file = ecl_util_alloc_filename( output_dir.c_str() , basename.c_str() , ECL_INIT_FILE , fmt_file , 0);
|
||||
|
||||
|
||||
ecl_grid_fwrite_EGRID( ecl_grid , egrid_file );
|
||||
saveINIT( init_file , ecl_grid );
|
||||
|
||||
|
||||
free( init_file );
|
||||
free( egrid_file );
|
||||
ecl_grid_free( ecl_grid );
|
||||
@@ -1100,7 +1100,7 @@ void EclipseGridParser::saveEGRID( const std::string & filename) const
|
||||
|
||||
#endif
|
||||
|
||||
// Read an imported fortio data file using Ert.
|
||||
// Read an imported fortio data file using Ert.
|
||||
// Data stored in 'integer_field_map_' and 'floating_field_map_'.
|
||||
void EclipseGridParser::getNumericErtFields(const string& filename)
|
||||
{
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
//===========================================================================
|
||||
//
|
||||
// File: EclipseGridParser.h
|
||||
//
|
||||
// Created: Wed Dec 5 17:05:13 2007
|
||||
//
|
||||
//
|
||||
// File: EclipseGridParser.h
|
||||
//
|
||||
// Created: Wed Dec 5 17:05:13 2007
|
||||
//
|
||||
// Author: Atgeirr F Rasmussen <atgeirr@sintef.no>
|
||||
//
|
||||
// $Date$
|
||||
//
|
||||
//
|
||||
// Revision: $Id: EclipseGridParser.h,v 1.3 2008/08/18 14:16:13 atgeirr Exp $
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
/*
|
||||
@@ -57,7 +57,7 @@ namespace Opm
|
||||
|
||||
/**
|
||||
@brief A class for reading and parsing all fields of an eclipse file.
|
||||
|
||||
|
||||
This object is constructed using an Eclipse .grdecl-file. All data
|
||||
fields are extracted upon construction and written to vector data
|
||||
structures, which can then be read out afterwards via
|
||||
@@ -140,7 +140,7 @@ namespace Opm
|
||||
|
||||
typedef boost::shared_ptr<SpecialBase> SpecialFieldPtr;
|
||||
|
||||
/// Returns a reference to a vector containing pointers to the values
|
||||
/// Returns a reference to a vector containing pointers to the values
|
||||
/// corresponding to the given keyword when the values are not only integers
|
||||
/// or floats.
|
||||
const SpecialFieldPtr getSpecialValue(const std::string& keyword) const;
|
||||
@@ -225,7 +225,7 @@ public:
|
||||
|
||||
struct grdecl get_grdecl() const;
|
||||
|
||||
/// Save grid parts of deck in EGRID format.
|
||||
/// Save grid parts of deck in EGRID format.
|
||||
void saveEGRID(const std::string & filename) const;
|
||||
|
||||
#ifdef HAVE_ERT
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace
|
||||
std::string dummy;
|
||||
is >> dummy;
|
||||
if (dummy == "/") {
|
||||
is >> ignoreLine;
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
} else if (dummy[0] == '-') { // "comment test"
|
||||
is >> ignoreLine; // This line is a comment
|
||||
@@ -221,7 +221,7 @@ namespace
|
||||
}
|
||||
|
||||
|
||||
// Returns month number 1-12. Returns 0 if illegal month name.
|
||||
// Returns month number 1-12. Returns 0 if illegal month name.
|
||||
inline int getMonthNumber(const std::string& month_name)
|
||||
{
|
||||
const int num_months = 12;
|
||||
@@ -302,7 +302,7 @@ namespace
|
||||
const std::ctype<char>& ct =
|
||||
std::use_facet< std::ctype<char> >(std::locale::classic());
|
||||
std::vector<double> record;
|
||||
std::vector<std::vector<double> > table;
|
||||
std::vector<std::vector<double> > table;
|
||||
while (!is.eof()) {
|
||||
record.clear();
|
||||
readVectorData(is, record);
|
||||
@@ -350,7 +350,7 @@ namespace
|
||||
const std::string& field_name, int ncol)
|
||||
{
|
||||
std::vector<double> record;
|
||||
std::vector<std::vector<double> > table(ncol);
|
||||
std::vector<std::vector<double> > table(ncol);
|
||||
while (!is.eof()) {
|
||||
record.clear();
|
||||
readVectorData(is, record);
|
||||
@@ -390,15 +390,15 @@ namespace
|
||||
for (int i=0; i<sz; ++i) {
|
||||
if (table[k][i] == -1) {
|
||||
indx.push_back(i);
|
||||
x.push_back(table[0][i]);
|
||||
x.push_back(table[0][i]);
|
||||
}
|
||||
}
|
||||
if (!indx.empty()) {
|
||||
std::vector<double> xv, yv;
|
||||
for (int i=0; i<sz; ++i) {
|
||||
if (table[k][i] != -1) {
|
||||
xv.push_back(table[0][i]);
|
||||
yv.push_back(table[k][i]);
|
||||
xv.push_back(table[0][i]);
|
||||
yv.push_back(table[k][i]);
|
||||
}
|
||||
}
|
||||
if (xv.empty()) {
|
||||
@@ -427,7 +427,7 @@ namespace
|
||||
const std::string& field_name, int ncol)
|
||||
{
|
||||
std::vector<double> record;
|
||||
std::vector<std::vector<double> > table(ncol);
|
||||
std::vector<std::vector<double> > table(ncol);
|
||||
while (!is.eof()) {
|
||||
record.clear();
|
||||
readRelPermTable(is, record);
|
||||
|
||||
@@ -63,11 +63,11 @@ struct SpecialBase {
|
||||
|
||||
|
||||
|
||||
/// Class for keyword SPECGRID
|
||||
/// Class for keyword SPECGRID
|
||||
struct SPECGRID : public SpecialBase
|
||||
{
|
||||
std::vector<int> dimensions; // Number of grid blocks in x-, y- and z-directions.
|
||||
int numres; // Number of reservoirs.
|
||||
int numres; // Number of reservoirs.
|
||||
char qrdial; // Coordinates. F=cartesian, T=Cylindrical(radial).
|
||||
|
||||
SPECGRID()
|
||||
@@ -98,14 +98,14 @@ struct SPECGRID : public SpecialBase
|
||||
} else {
|
||||
qrdial = candidate[0];
|
||||
}
|
||||
|
||||
|
||||
if (ignoreSlashLine(is)) {
|
||||
return;
|
||||
} else {
|
||||
THROW("End of file reading" << name());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void write(std::ostream& os) const
|
||||
{
|
||||
os << name() << std::endl;
|
||||
@@ -243,7 +243,7 @@ struct MULTFLT : public SpecialBase
|
||||
{
|
||||
os << name() << std::endl;
|
||||
for (int i=0; i<(int)multflts.size(); ++i) {
|
||||
os << multflts[i].fault_name << " "
|
||||
os << multflts[i].fault_name << " "
|
||||
<< multflts[i].transmis_multiplier << " "
|
||||
<< multflts[i].diffusivity_multiplier << std::endl;
|
||||
}
|
||||
@@ -301,7 +301,7 @@ struct GRUPTREE : public SpecialBase {
|
||||
|
||||
std::cout << "CHILD = " << child << std::endl << "PARENT = " << parent << std::endl;
|
||||
tree[child] = parent;
|
||||
|
||||
|
||||
is >> ignoreSlashLine;
|
||||
is >> ignoreWhitespace;
|
||||
if(is.peek() == int('/')) {
|
||||
@@ -396,7 +396,7 @@ struct DENSITY : public SpecialBase
|
||||
|
||||
struct PVDG : public SpecialBase
|
||||
{
|
||||
table_t pvdg_;
|
||||
table_t pvdg_;
|
||||
|
||||
virtual std::string name() const {return std::string("PVDG");}
|
||||
|
||||
@@ -433,7 +433,7 @@ struct PVDG : public SpecialBase
|
||||
|
||||
struct PVDO : public SpecialBase
|
||||
{
|
||||
table_t pvdo_;
|
||||
table_t pvdo_;
|
||||
|
||||
virtual std::string name() const {return std::string("PVDO");}
|
||||
|
||||
@@ -470,7 +470,7 @@ struct PVDO : public SpecialBase
|
||||
|
||||
struct PVTG : public SpecialBase
|
||||
{
|
||||
table_t pvtg_;
|
||||
table_t pvtg_;
|
||||
|
||||
virtual std::string name() const {return std::string("PVTG");}
|
||||
|
||||
@@ -522,7 +522,7 @@ struct PVTG : public SpecialBase
|
||||
|
||||
struct PVTO : public SpecialBase
|
||||
{
|
||||
table_t pvto_;
|
||||
table_t pvto_;
|
||||
|
||||
virtual std::string name() const {return std::string("PVTO");}
|
||||
|
||||
@@ -667,7 +667,7 @@ struct ROCK : public SpecialBase
|
||||
|
||||
struct ROCKTAB : public SpecialBase
|
||||
{
|
||||
table_t rocktab_;
|
||||
table_t rocktab_;
|
||||
|
||||
virtual std::string name() const {return std::string("ROCKTAB");}
|
||||
|
||||
@@ -702,7 +702,7 @@ struct ROCKTAB : public SpecialBase
|
||||
|
||||
struct SGOF : public SpecialBase
|
||||
{
|
||||
table_t sgof_;
|
||||
table_t sgof_;
|
||||
|
||||
virtual std::string name() const {return std::string("SGOF");}
|
||||
|
||||
@@ -733,7 +733,7 @@ struct SGOF : public SpecialBase
|
||||
|
||||
struct SWOF : public SpecialBase
|
||||
{
|
||||
table_t swof_;
|
||||
table_t swof_;
|
||||
|
||||
virtual std::string name() const {return std::string("SWOF");}
|
||||
|
||||
@@ -805,7 +805,7 @@ struct WELSPECS : public SpecialBase
|
||||
virtual void read(std::istream& is)
|
||||
{
|
||||
while(is) {
|
||||
std::string wellname = readString(is);
|
||||
std::string wellname = readString(is);
|
||||
if (wellname[0] == '/') {
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
@@ -839,7 +839,7 @@ struct WELSPECS : public SpecialBase
|
||||
// welspecs_line.crossflow_ = readString(is);
|
||||
// int_data[0] = 0;
|
||||
// readDefaultedVectorData(is, int_data, 1);
|
||||
// welspecs_line.pressure_table_number_ = int_data[0];
|
||||
// welspecs_line.pressure_table_number_ = int_data[0];
|
||||
// welspecs_line.density_calc_type_ = readString(is);
|
||||
// int_data[0] = 0;
|
||||
// readDefaultedVectorData(is, int_data, 1);
|
||||
@@ -852,7 +852,7 @@ struct WELSPECS : public SpecialBase
|
||||
{
|
||||
os << name() << std::endl;
|
||||
for (int i=0; i<(int)welspecs.size(); ++i) {
|
||||
os << welspecs[i].name_ << " "
|
||||
os << welspecs[i].name_ << " "
|
||||
<< welspecs[i].group_ << " "
|
||||
<< welspecs[i].I_ << " "
|
||||
<< welspecs[i].J_ << " "
|
||||
@@ -927,7 +927,7 @@ struct COMPDAT : public SpecialBase
|
||||
virtual void read(std::istream& is)
|
||||
{
|
||||
while(is) {
|
||||
std::string wellname = readString(is);
|
||||
std::string wellname = readString(is);
|
||||
if (wellname[0] == '/') {
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
@@ -962,7 +962,7 @@ struct COMPDAT : public SpecialBase
|
||||
{
|
||||
os << name() << std::endl;
|
||||
for (int i=0; i<(int)compdat.size(); ++i) {
|
||||
os << compdat[i].well_ << " "
|
||||
os << compdat[i].well_ << " "
|
||||
<< compdat[i].grid_ind_[0] << " "
|
||||
<< compdat[i].grid_ind_[1] << " "
|
||||
<< compdat[i].grid_ind_[2] << " "
|
||||
@@ -1004,7 +1004,7 @@ struct GconinjeLine
|
||||
double resv_flow_max_rate_; // Reservoir flow rate target or upper limit
|
||||
double reinjection_fraction_target_;
|
||||
double voidage_replacement_fraction_;
|
||||
|
||||
|
||||
// Default values
|
||||
GconinjeLine() :
|
||||
surface_flow_max_rate_(-1.0E20),
|
||||
@@ -1032,7 +1032,7 @@ struct GCONINJE : public SpecialBase
|
||||
virtual void read(std::istream& is)
|
||||
{
|
||||
while(is) {
|
||||
std::string groupname = readString(is);
|
||||
std::string groupname = readString(is);
|
||||
if (groupname[0] == '/') {
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
@@ -1058,21 +1058,21 @@ struct GCONINJE : public SpecialBase
|
||||
ignoreSlashLine(is);
|
||||
}
|
||||
gconinje.push_back(gconinje_line);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
virtual void write(std::ostream& os) const
|
||||
{
|
||||
os << name() << std::endl;
|
||||
for (int i=0; i<(int) gconinje.size(); ++i) {
|
||||
os << gconinje[i].group_ << " "
|
||||
<< gconinje[i].injector_type_ << " "
|
||||
<< gconinje[i].control_mode_ << " "
|
||||
<< gconinje[i].surface_flow_max_rate_ << " "
|
||||
os << gconinje[i].group_ << " "
|
||||
<< gconinje[i].injector_type_ << " "
|
||||
<< gconinje[i].control_mode_ << " "
|
||||
<< gconinje[i].surface_flow_max_rate_ << " "
|
||||
<< gconinje[i].reinjection_fraction_target_
|
||||
<< std::endl;
|
||||
<< std::endl;
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
@@ -1135,7 +1135,7 @@ struct WCONINJE : public SpecialBase
|
||||
virtual void read(std::istream& is)
|
||||
{
|
||||
while(is) {
|
||||
std::string wellname = readString(is);
|
||||
std::string wellname = readString(is);
|
||||
if (wellname[0] == '/') {
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
@@ -1151,8 +1151,8 @@ struct WCONINJE : public SpecialBase
|
||||
wconinje_line.open_shut_flag_ = readString(is);
|
||||
wconinje_line.control_mode_ = readString(is);
|
||||
std::vector<double> double_data(6, -1.0E20);
|
||||
double_data[2] = wconinje_line.BHP_limit_;
|
||||
double_data[4] = wconinje_line.VFP_table_number_;
|
||||
double_data[2] = wconinje_line.BHP_limit_;
|
||||
double_data[4] = wconinje_line.VFP_table_number_;
|
||||
double_data[5] = wconinje_line.concentration_;
|
||||
const int num_to_read = 6;
|
||||
int num_read = readDefaultedVectorData(is, double_data, num_to_read);
|
||||
@@ -1174,17 +1174,17 @@ struct WCONINJE : public SpecialBase
|
||||
{
|
||||
os << name() << std::endl;
|
||||
for (int i=0; i<(int) wconinje.size(); ++i) {
|
||||
os << wconinje[i].well_ << " "
|
||||
<< wconinje[i].injector_type_ << " "
|
||||
<< wconinje[i].open_shut_flag_ << " "
|
||||
<< wconinje[i].control_mode_ << " "
|
||||
<< wconinje[i].surface_flow_max_rate_ << " "
|
||||
<< wconinje[i].reservoir_flow_max_rate_ << " "
|
||||
<< wconinje[i].BHP_limit_ << " "
|
||||
<< wconinje[i].THP_limit_ << " "
|
||||
<< wconinje[i].VFP_table_number_ << " "
|
||||
os << wconinje[i].well_ << " "
|
||||
<< wconinje[i].injector_type_ << " "
|
||||
<< wconinje[i].open_shut_flag_ << " "
|
||||
<< wconinje[i].control_mode_ << " "
|
||||
<< wconinje[i].surface_flow_max_rate_ << " "
|
||||
<< wconinje[i].reservoir_flow_max_rate_ << " "
|
||||
<< wconinje[i].BHP_limit_ << " "
|
||||
<< wconinje[i].THP_limit_ << " "
|
||||
<< wconinje[i].VFP_table_number_ << " "
|
||||
<< wconinje[i].concentration_
|
||||
<< std::endl;
|
||||
<< std::endl;
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
@@ -1244,7 +1244,7 @@ struct GCONPROD : public SpecialBase
|
||||
virtual void read(std::istream& is)
|
||||
{
|
||||
while(is) {
|
||||
std::string groupname = readString(is);
|
||||
std::string groupname = readString(is);
|
||||
if (groupname[0] == '/') {
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
@@ -1257,7 +1257,7 @@ struct GCONPROD : public SpecialBase
|
||||
GconprodLine gconprod_line;
|
||||
gconprod_line.group_ = groupname;
|
||||
gconprod_line.control_mode_ = readString(is);
|
||||
if (gconprod_line.control_mode_[gconprod_line.control_mode_.size() - 1] == '*')
|
||||
if (gconprod_line.control_mode_[gconprod_line.control_mode_.size() - 1] == '*')
|
||||
{
|
||||
gconprod_line.control_mode_ = "NONE";
|
||||
}
|
||||
@@ -1282,7 +1282,7 @@ struct GCONPROD : public SpecialBase
|
||||
std::string ignored_value = readString(is);
|
||||
if (ignored_value[ignored_value.size()-1]=='*') {
|
||||
// we've got defaulted argument, increment
|
||||
|
||||
|
||||
int num_defaulted;
|
||||
std::string num_defaulted_str = ignored_value.substr(0, ignored_value.size()-1);
|
||||
std::istringstream(num_defaulted_str) >> num_defaulted;
|
||||
@@ -1311,13 +1311,13 @@ struct GCONPROD : public SpecialBase
|
||||
}
|
||||
gconprod_line.procedure_ = procedure;
|
||||
|
||||
|
||||
|
||||
gconprod.push_back(gconprod_line);
|
||||
// HACK! Ignore any further items
|
||||
if (num_read == num_to_read) {
|
||||
ignoreSlashLine(is);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1326,15 +1326,15 @@ struct GCONPROD : public SpecialBase
|
||||
{
|
||||
os << name() << std::endl;
|
||||
for (int i=0; i<(int) gconprod.size(); ++i) {
|
||||
os << gconprod[i].group_ << " "
|
||||
<< gconprod[i].control_mode_ << " "
|
||||
<< gconprod[i].oil_max_rate_ << " "
|
||||
<< gconprod[i].water_max_rate_ << " "
|
||||
<< gconprod[i].gas_max_rate_ << " "
|
||||
<< gconprod[i].liquid_max_rate_ << " "
|
||||
<< gconprod[i].procedure_ << " "
|
||||
os << gconprod[i].group_ << " "
|
||||
<< gconprod[i].control_mode_ << " "
|
||||
<< gconprod[i].oil_max_rate_ << " "
|
||||
<< gconprod[i].water_max_rate_ << " "
|
||||
<< gconprod[i].gas_max_rate_ << " "
|
||||
<< gconprod[i].liquid_max_rate_ << " "
|
||||
<< gconprod[i].procedure_ << " "
|
||||
<< gconprod[i].resv_max_rate_
|
||||
<< std::endl;
|
||||
<< std::endl;
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
@@ -1384,7 +1384,7 @@ struct WGRUPCON : public SpecialBase
|
||||
virtual void read(std::istream& is)
|
||||
{
|
||||
while(is) {
|
||||
std::string wname = readString(is);
|
||||
std::string wname = readString(is);
|
||||
if (wname[0] == '/') {
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
@@ -1397,7 +1397,7 @@ struct WGRUPCON : public SpecialBase
|
||||
WgrupconLine wgrupcon_line;
|
||||
wgrupcon_line.well_ = wname;
|
||||
std::string available = readString(is);
|
||||
if (available[available.size()-1] == '*')
|
||||
if (available[available.size()-1] == '*')
|
||||
{
|
||||
available = "YES";
|
||||
}
|
||||
@@ -1406,8 +1406,8 @@ struct WGRUPCON : public SpecialBase
|
||||
const int num_to_read = 1;
|
||||
int num_read = readDefaultedVectorData(is, double_data, num_to_read);
|
||||
wgrupcon_line.guide_rate_ = double_data[0];
|
||||
|
||||
std::string phase = readString(is);
|
||||
|
||||
std::string phase = readString(is);
|
||||
if (phase[0] == '/') {
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
@@ -1417,9 +1417,9 @@ struct WGRUPCON : public SpecialBase
|
||||
is >> ignoreLine;
|
||||
phase = readString(is);
|
||||
}
|
||||
|
||||
|
||||
wgrupcon_line.phase_ = phase;
|
||||
|
||||
|
||||
wgrupcon.push_back(wgrupcon_line);
|
||||
// HACK! Ignore any further items
|
||||
if (num_read == num_to_read) {
|
||||
@@ -1433,11 +1433,11 @@ struct WGRUPCON : public SpecialBase
|
||||
{
|
||||
os << name() << std::endl;
|
||||
for (int i=0; i<(int) wgrupcon.size(); ++i) {
|
||||
os << wgrupcon[i].well_ << " "
|
||||
<< wgrupcon[i].available_for_group_control_ << " "
|
||||
<< wgrupcon[i].guide_rate_ << " "
|
||||
<< wgrupcon[i].phase_ << " "
|
||||
<< std::endl;
|
||||
os << wgrupcon[i].well_ << " "
|
||||
<< wgrupcon[i].available_for_group_control_ << " "
|
||||
<< wgrupcon[i].guide_rate_ << " "
|
||||
<< wgrupcon[i].phase_ << " "
|
||||
<< std::endl;
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
@@ -1495,7 +1495,7 @@ struct WCONPROD : public SpecialBase
|
||||
virtual void read(std::istream& is)
|
||||
{
|
||||
while(is) {
|
||||
std::string wellname = readString(is);
|
||||
std::string wellname = readString(is);
|
||||
if (wellname[0] == '/') {
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
@@ -1510,9 +1510,9 @@ struct WCONPROD : public SpecialBase
|
||||
wconprod_line.open_shut_flag_ = readString(is);
|
||||
wconprod_line.control_mode_ = readString(is);
|
||||
std::vector<double> double_data(14, -1.0E20);
|
||||
double_data[5] = wconprod_line.BHP_limit_;
|
||||
double_data[6] = wconprod_line.THP_limit_;
|
||||
double_data[7] = wconprod_line.VFP_table_number_;
|
||||
double_data[5] = wconprod_line.BHP_limit_;
|
||||
double_data[6] = wconprod_line.THP_limit_;
|
||||
double_data[7] = wconprod_line.VFP_table_number_;
|
||||
double_data[8] = wconprod_line.artif_lift_quantity_;
|
||||
const int num_to_read = 14;
|
||||
int num_read = readDefaultedVectorData(is, double_data, num_to_read);
|
||||
@@ -1538,19 +1538,19 @@ struct WCONPROD : public SpecialBase
|
||||
{
|
||||
os << name() << std::endl;
|
||||
for (int i=0; i<(int) wconprod.size(); ++i) {
|
||||
os << wconprod[i].well_ << " "
|
||||
<< wconprod[i].open_shut_flag_ << " "
|
||||
<< wconprod[i].control_mode_ << " "
|
||||
<< wconprod[i].oil_max_rate_ << " "
|
||||
<< wconprod[i].water_max_rate_ << " "
|
||||
<< wconprod[i].gas_max_rate_ << " "
|
||||
<< wconprod[i].liquid_max_rate_ << " "
|
||||
<< wconprod[i].reservoir_flow_max_rate_ << " "
|
||||
<< wconprod[i].BHP_limit_ << " "
|
||||
<< wconprod[i].THP_limit_ << " "
|
||||
<< wconprod[i].VFP_table_number_ << " "
|
||||
os << wconprod[i].well_ << " "
|
||||
<< wconprod[i].open_shut_flag_ << " "
|
||||
<< wconprod[i].control_mode_ << " "
|
||||
<< wconprod[i].oil_max_rate_ << " "
|
||||
<< wconprod[i].water_max_rate_ << " "
|
||||
<< wconprod[i].gas_max_rate_ << " "
|
||||
<< wconprod[i].liquid_max_rate_ << " "
|
||||
<< wconprod[i].reservoir_flow_max_rate_ << " "
|
||||
<< wconprod[i].BHP_limit_ << " "
|
||||
<< wconprod[i].THP_limit_ << " "
|
||||
<< wconprod[i].VFP_table_number_ << " "
|
||||
<< wconprod[i].artif_lift_quantity_
|
||||
<< std::endl;
|
||||
<< std::endl;
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
@@ -1604,7 +1604,7 @@ struct WELTARG : public SpecialBase
|
||||
virtual void read(std::istream& is)
|
||||
{
|
||||
while(is) {
|
||||
std::string wellname = readString(is);
|
||||
std::string wellname = readString(is);
|
||||
if (wellname[0] == '/') {
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
@@ -1627,8 +1627,8 @@ struct WELTARG : public SpecialBase
|
||||
{
|
||||
os << name() << std::endl;
|
||||
for (int i=0; i<(int)weltarg.size(); ++i) {
|
||||
os << weltarg[i].well_ << " "
|
||||
<< weltarg[i].control_change_ << " "
|
||||
os << weltarg[i].well_ << " "
|
||||
<< weltarg[i].control_change_ << " "
|
||||
<< weltarg[i].new_value_ << " "
|
||||
<< std::endl;
|
||||
}
|
||||
@@ -1643,7 +1643,7 @@ struct WELTARG : public SpecialBase
|
||||
for (int i=0; i<(int) weltarg.size(); ++i) {
|
||||
if (weltarg[i].control_change_[0] == 'O' ||
|
||||
weltarg[i].control_change_[0] == 'W' ||
|
||||
weltarg[i].control_change_[0] == 'L') {
|
||||
weltarg[i].control_change_[0] == 'L') {
|
||||
weltarg[i].new_value_ *= lrat;
|
||||
} else if (weltarg[i].control_change_[0] == 'G') {
|
||||
weltarg[i].new_value_ *= grat;
|
||||
@@ -1685,7 +1685,7 @@ struct WELOPEN : public SpecialBase
|
||||
virtual void read(std::istream& is)
|
||||
{
|
||||
while(is) {
|
||||
std::string wellname = readString(is);
|
||||
std::string wellname = readString(is);
|
||||
if (wellname[0] == '/') {
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
@@ -1707,7 +1707,7 @@ struct WELOPEN : public SpecialBase
|
||||
{
|
||||
os << name() << std::endl;
|
||||
for (int i=0; i<(int)welopen.size(); ++i) {
|
||||
os << welopen[i].well_ << " "
|
||||
os << welopen[i].well_ << " "
|
||||
<< welopen[i].openshutflag_
|
||||
<< std::endl;
|
||||
}
|
||||
@@ -1735,7 +1735,7 @@ struct EquilLine
|
||||
double gas_oil_cap_pressure_; // Gas-oil capillary pressure at the gas-oil
|
||||
// contact.
|
||||
int live_oil_table_index_; // Rs v Depth or Pb v Depth table index for
|
||||
// under-saturated live oil.
|
||||
// under-saturated live oil.
|
||||
int wet_gas_table_index_; // Rv v Depth or Pd v Depth table index for
|
||||
// under-saturated wet gas.
|
||||
int N_; // Integer defining the accuracy of the
|
||||
@@ -1793,8 +1793,8 @@ struct EQUIL : public SpecialBase
|
||||
{
|
||||
os << name() << std::endl;
|
||||
for (int i=0; i<(int)equil.size(); ++i) {
|
||||
os << equil[i].datum_depth_ << " "
|
||||
<< equil[i].datum_depth_pressure_ << " "
|
||||
os << equil[i].datum_depth_ << " "
|
||||
<< equil[i].datum_depth_pressure_ << " "
|
||||
<< equil[i].water_oil_contact_depth_ << " "
|
||||
<< equil[i].oil_water_cap_pressure_ << " "
|
||||
<< equil[i].gas_oil_contact_depth_ << " "
|
||||
@@ -1925,8 +1925,8 @@ struct MultRec : public SpecialBase
|
||||
if (name.rfind('/') != std::string::npos) {
|
||||
continue; // Unquoted name
|
||||
} else {
|
||||
is.seekg(pos);
|
||||
break; // Read next keyword
|
||||
is.seekg(pos);
|
||||
break; // Read next keyword
|
||||
}
|
||||
} else if (ct.is(std::ctype_base::digit, c) || c== '.') {
|
||||
is >> ignoreSlashLine; // Decimal digit. Ignore data.
|
||||
@@ -2020,7 +2020,7 @@ struct PLYROCK : public SpecialBase
|
||||
|
||||
virtual void convertToSI(const EclipseUnits& units)
|
||||
{
|
||||
|
||||
|
||||
plyrock_[2] *= units.polymer_density;
|
||||
}
|
||||
};
|
||||
@@ -2104,7 +2104,7 @@ struct TLMIXPAR : public SpecialBase
|
||||
tlmixpar_.resize(2, -1e100);
|
||||
int num_to_read = 2;
|
||||
int num_read = readDefaultedVectorData(is, tlmixpar_, num_to_read);
|
||||
if (tlmixpar_[1] < 0) {
|
||||
if (tlmixpar_[1] < 0) {
|
||||
tlmixpar_[1] = tlmixpar_[0];
|
||||
}
|
||||
if (num_read == num_to_read) {
|
||||
@@ -2134,7 +2134,7 @@ struct WpolymerLine
|
||||
double polymer_concentration_;
|
||||
double salt_concentration_;
|
||||
std::string polymer_group_;
|
||||
std::string salt_group_;
|
||||
std::string salt_group_;
|
||||
|
||||
WpolymerLine()
|
||||
{
|
||||
@@ -2164,7 +2164,7 @@ struct WPOLYMER : public SpecialBase
|
||||
}
|
||||
WpolymerLine wpolymer_line;
|
||||
wpolymer_line.well_ = wellname;
|
||||
is >> wpolymer_line.polymer_concentration_;
|
||||
is >> wpolymer_line.polymer_concentration_;
|
||||
is >> wpolymer_line.salt_concentration_;
|
||||
std::string group = readString(is);
|
||||
if (group[0] == '/') {
|
||||
@@ -2192,7 +2192,7 @@ struct WPOLYMER : public SpecialBase
|
||||
<< " " << wpolymer_[i].salt_concentration_
|
||||
<< " " << wpolymer_[i].polymer_group_
|
||||
<< " " << wpolymer_[i].salt_group_;
|
||||
os << '\n';
|
||||
os << '\n';
|
||||
}
|
||||
os << '\n';
|
||||
}
|
||||
@@ -2316,7 +2316,7 @@ struct ENPTVD : public SpecialBase {
|
||||
while (!is.eof()) {
|
||||
if(is.peek() == int('/')) {
|
||||
if (sub_table[0].empty() && !(table_[0].empty())) {
|
||||
is >> ignoreLine;
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
} else {
|
||||
THROW("Error reading ENPTVD data - none or incomplete table.");
|
||||
@@ -2344,7 +2344,7 @@ struct ENPTVD : public SpecialBase {
|
||||
if (sub_table[0].size() >= 2) {
|
||||
insertDefaultValues(sub_table, 5, -1.0, false);
|
||||
std::vector<std::vector<double> >::iterator it_sub = sub_table.begin();
|
||||
for(std::vector<std::vector<std::vector<double> > >::size_type i=0; i<table_.size(); ++i) {
|
||||
for(std::vector<std::vector<std::vector<double> > >::size_type i=0; i<table_.size(); ++i) {
|
||||
table_[i].push_back(*it_sub);
|
||||
(*it_sub).clear();
|
||||
++it_sub;
|
||||
@@ -2370,7 +2370,7 @@ struct ENPTVD : public SpecialBase {
|
||||
std::cout << "-----depth-------swl------swcr-------swu-----sowcr" << std::endl;
|
||||
for (std::vector<std::vector<double> >::size_type j=0; j<table_[0].size(); ++j) {
|
||||
std::cout << "--------------------------------------------------" << std::endl;
|
||||
for (std::vector<double>::size_type k=0; k<table_[0][j].size(); ++k) {
|
||||
for (std::vector<double>::size_type k=0; k<table_[0][j].size(); ++k) {
|
||||
for (std::vector<std::vector<std::vector<double> > >::size_type i=0; i<table_.size(); ++i) {
|
||||
std::cout << std::setw(10) << table_[i][j][k];
|
||||
}
|
||||
@@ -2382,7 +2382,7 @@ struct ENPTVD : public SpecialBase {
|
||||
virtual void convertToSI(const EclipseUnits& units) {
|
||||
//depths
|
||||
for (std::vector<std::vector<double> >::size_type j=0; j<table_[0].size(); ++j) {
|
||||
for (std::vector<double>::size_type k=0; k<table_[0][j].size(); ++k) {
|
||||
for (std::vector<double>::size_type k=0; k<table_[0][j].size(); ++k) {
|
||||
table_[0][j][k] *= units.length;
|
||||
}
|
||||
}
|
||||
@@ -2403,7 +2403,7 @@ struct ENKRVD : public SpecialBase {
|
||||
while (!is.eof()) {
|
||||
if(is.peek() == int('/')) {
|
||||
if (sub_table[0].empty() && !(table_[0].empty())) {
|
||||
is >> ignoreLine;
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
} else {
|
||||
THROW("Error reading ENKRVD data - none or incomplete table.");
|
||||
@@ -2431,7 +2431,7 @@ struct ENKRVD : public SpecialBase {
|
||||
if (sub_table[0].size() >= 2) {
|
||||
insertDefaultValues(sub_table, 5, -1.0, false);
|
||||
std::vector<std::vector<double> >::iterator it_sub = sub_table.begin();
|
||||
for(std::vector<std::vector<std::vector<double> > >::size_type i=0; i<table_.size(); ++i) {
|
||||
for(std::vector<std::vector<std::vector<double> > >::size_type i=0; i<table_.size(); ++i) {
|
||||
table_[i].push_back(*it_sub);
|
||||
(*it_sub).clear();
|
||||
++it_sub;
|
||||
@@ -2458,7 +2458,7 @@ struct ENKRVD : public SpecialBase {
|
||||
std::cout << "-----depth-------krw------krow------krwr-----krorw" << std::endl;
|
||||
for (std::vector<std::vector<double> >::size_type j=0; j<table_[0].size(); ++j) {
|
||||
std::cout << "--------------------------------------------------" << std::endl;
|
||||
for (std::vector<double>::size_type k=0; k<table_[0][j].size(); ++k) {
|
||||
for (std::vector<double>::size_type k=0; k<table_[0][j].size(); ++k) {
|
||||
for (std::vector<std::vector<std::vector<double> > >::size_type i=0; i<table_.size(); ++i) {
|
||||
std::cout << std::setw(10) << table_[i][j][k];
|
||||
}
|
||||
@@ -2470,7 +2470,7 @@ struct ENKRVD : public SpecialBase {
|
||||
virtual void convertToSI(const EclipseUnits& units) {
|
||||
//depths
|
||||
for (std::vector<std::vector<double> >::size_type j=0; j<table_[0].size(); ++j) {
|
||||
for (std::vector<double>::size_type k=0; k<table_[0][j].size(); ++k) {
|
||||
for (std::vector<double>::size_type k=0; k<table_[0][j].size(); ++k) {
|
||||
table_[0][j][k] *= units.length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
|
||||
static ecl_kw_type * ecl_kw_wrapper( const UnstructuredGrid& grid,
|
||||
const std::string& kw_name ,
|
||||
const std::vector<double> * data ,
|
||||
int offset ,
|
||||
const std::string& kw_name ,
|
||||
const std::vector<double> * data ,
|
||||
int offset ,
|
||||
int stride ) {
|
||||
|
||||
if (stride <= 0)
|
||||
@@ -51,7 +51,7 @@ namespace Opm
|
||||
THROW("Internal mismatch grid.number_of_cells: " << grid.number_of_cells << " data size: " << data->size() / stride);
|
||||
{
|
||||
ecl_kw_type * ecl_kw = ecl_kw_alloc( kw_name.c_str() , grid.number_of_cells , ECL_FLOAT_TYPE );
|
||||
for (int i=0; i < grid.number_of_cells; i++)
|
||||
for (int i=0; i < grid.number_of_cells; i++)
|
||||
ecl_kw_iset_float( ecl_kw , i , (*data)[i*stride + offset]);
|
||||
return ecl_kw;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ namespace Opm
|
||||
chunk and non-unified restart files which are one file for each
|
||||
report step. In addition the files can be either formatted
|
||||
(i.e. ASCII) or unformatted (i.e. binary).
|
||||
|
||||
|
||||
The writeECLData() function has two hardcoded settings:
|
||||
'file_type' and 'fmt_file' which regulate which type of files the
|
||||
should be created. The extension of the files follow a convention:
|
||||
@@ -92,10 +92,10 @@ namespace Opm
|
||||
const boost::posix_time::ptime& current_date_time,
|
||||
const std::string& output_dir,
|
||||
const std::string& base_name) {
|
||||
|
||||
|
||||
ecl_file_enum file_type = ECL_UNIFIED_RESTART_FILE; // Alternatively ECL_RESTART_FILE for multiple restart files.
|
||||
bool fmt_file = false;
|
||||
|
||||
|
||||
char * filename = ecl_util_alloc_filename(output_dir.c_str() , base_name.c_str() , file_type , fmt_file , current_step );
|
||||
int phases = ECL_OIL_PHASE + ECL_WATER_PHASE;
|
||||
double days = Opm::unit::convert::to(current_time, Opm::unit::day);
|
||||
@@ -105,20 +105,20 @@ namespace Opm
|
||||
int nz = grid.cartdims[2];
|
||||
int nactive = grid.number_of_cells;
|
||||
ecl_rst_file_type * rst_file;
|
||||
|
||||
|
||||
{
|
||||
using namespace boost::posix_time;
|
||||
ptime t0( boost::gregorian::date(1970 , 1 ,1) );
|
||||
time_duration::sec_type seconds = (current_date_time - t0).total_seconds();
|
||||
|
||||
|
||||
date = time_t( seconds );
|
||||
}
|
||||
|
||||
|
||||
if (current_step > 0 && file_type == ECL_UNIFIED_RESTART_FILE)
|
||||
rst_file = ecl_rst_file_open_append( filename );
|
||||
else
|
||||
rst_file = ecl_rst_file_open_write( filename );
|
||||
|
||||
|
||||
ecl_rst_file_fwrite_header( rst_file , current_step , date , days , nx , ny , nz , nactive , phases );
|
||||
ecl_rst_file_start_solution( rst_file );
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Opm
|
||||
ecl_kw_free( pressure_kw );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
DataMap::const_iterator i = data.find("saturation");
|
||||
if (i != data.end()) {
|
||||
@@ -146,7 +146,7 @@ namespace Opm
|
||||
ecl_rst_file_end_solution( rst_file );
|
||||
ecl_rst_file_close( rst_file );
|
||||
free(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else // that is, we have not defined HAVE_ERT
|
||||
|
||||
@@ -41,6 +41,6 @@ namespace Opm
|
||||
const std::string& output_dir,
|
||||
const std::string& base_name);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
+43
-43
@@ -35,7 +35,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include <opm/core/io/vag/vag.hpp>
|
||||
#include <opm/core/grid/cornerpoint_grid.h>
|
||||
#include <opm/core/grid/cornerpoint_grid.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
@@ -77,7 +77,7 @@ namespace Opm
|
||||
if(pos_struct.pos.size()==0){
|
||||
return;
|
||||
}
|
||||
int n=pos_struct.pos.size()-1;
|
||||
int n=pos_struct.pos.size()-1;
|
||||
pos_struct.pos.resize(n+1);
|
||||
pos_struct.pos[0]=0;
|
||||
for(int i=0;i< n;++i){
|
||||
@@ -94,7 +94,7 @@ namespace Opm
|
||||
using namespace Opm;
|
||||
while (!is.eof()) {
|
||||
string keyword;
|
||||
is >> keyword;
|
||||
is >> keyword;
|
||||
//cout << keyword<< endl;
|
||||
if(keyword == "Number"){
|
||||
string stmp;
|
||||
@@ -113,8 +113,8 @@ namespace Opm
|
||||
vag_grid.number_of_faces=number;
|
||||
}else if(entity=="edges"){
|
||||
vag_grid.number_of_edges=number;
|
||||
}
|
||||
cout << "Found Number of: " << entity <<" " << number << endl;
|
||||
}
|
||||
cout << "Found Number of: " << entity <<" " << number << endl;
|
||||
} else {
|
||||
cerr << "Wrong format: Not of after Number" << endl;
|
||||
return;
|
||||
@@ -123,7 +123,7 @@ namespace Opm
|
||||
// read geometry defined by vertices
|
||||
if(keyword=="Vertices"){
|
||||
int number;
|
||||
is >> number;
|
||||
is >> number;
|
||||
vag_grid.vertices.resize(3*number);// assume 3d data
|
||||
readVector(is,vag_grid.vertices);
|
||||
}
|
||||
@@ -131,33 +131,33 @@ namespace Opm
|
||||
else if(keyword=="Volumes->Faces" || keyword=="Volumes->faces"){
|
||||
//vag_grid.volumes_to_faces=
|
||||
int number;
|
||||
is >> number;
|
||||
is >> number;
|
||||
readPosStruct(is,number,vag_grid.volumes_to_faces);
|
||||
cout << "Volumes->Faces: Number of " << number << endl;
|
||||
}else if(keyword=="Faces->edges" || keyword=="Faces->Edges" || keyword=="Faces->Edgess"){
|
||||
int number;
|
||||
is >> number;
|
||||
is >> number;
|
||||
//vag_grid.volumes_to_faces=
|
||||
readPosStruct(is,number,vag_grid.faces_to_edges);
|
||||
cout << "Faces->edges: Number of " << number << endl;
|
||||
}else if(keyword=="Faces->Vertices" || keyword=="Faces->vertices"){
|
||||
int number;
|
||||
is >> number;
|
||||
is >> number;
|
||||
//vag_grid.volumes_to_faces=
|
||||
readPosStruct(is,number,vag_grid.faces_to_vertices);
|
||||
cout << "Faces->Vertices: Number of " << number << endl;
|
||||
cout << "Faces->Vertices: Number of " << number << endl;
|
||||
}else if(keyword=="Volumes->Vertices" || keyword=="Volumes->Verticess"){
|
||||
int number;
|
||||
is >> number;
|
||||
is >> number;
|
||||
//vag_grid.volumes_to_faces=
|
||||
readPosStruct(is,number,vag_grid.volumes_to_vertices);
|
||||
cout << "Volumes->Vertices: Number of " << number << endl;
|
||||
cout << "Volumes->Vertices: Number of " << number << endl;
|
||||
}
|
||||
|
||||
|
||||
// read simple mappings
|
||||
else if(keyword=="Edge" || keyword=="Edges"){
|
||||
int number;
|
||||
is >> number;
|
||||
is >> number;
|
||||
vag_grid.edges.resize(2*number);
|
||||
readVector(is,vag_grid.edges);
|
||||
cout << "Edges: Number of " << number << endl;
|
||||
@@ -170,7 +170,7 @@ namespace Opm
|
||||
is >> number;
|
||||
vag_grid.faces_to_volumes.resize(2*number);
|
||||
readVector(is,vag_grid.faces_to_volumes);
|
||||
cout << "Faces->Volumes: Number of " << number << endl;
|
||||
cout << "Faces->Volumes: Number of " << number << endl;
|
||||
}
|
||||
// read material
|
||||
else if(keyword=="Material"){
|
||||
@@ -179,7 +179,7 @@ namespace Opm
|
||||
int number;
|
||||
is >> number;
|
||||
cout << "Material number " << number << endl;
|
||||
// we read all the rest into doubles
|
||||
// we read all the rest into doubles
|
||||
while(!is.eof()){
|
||||
double value;
|
||||
is >> value;
|
||||
@@ -203,18 +203,18 @@ namespace Opm
|
||||
grid.number_of_cells=vag_grid.number_of_volumes;
|
||||
grid.number_of_faces=vag_grid.number_of_faces;
|
||||
grid.number_of_nodes=vag_grid.number_of_vertices;
|
||||
|
||||
|
||||
// fill face_nodes
|
||||
for(int i=0;i< int(vag_grid.faces_to_vertices.pos.size());++i){
|
||||
grid.face_nodepos[i] = vag_grid.faces_to_vertices.pos[i];
|
||||
}
|
||||
}
|
||||
for(int i=0;i< int(vag_grid.faces_to_vertices.value.size());++i){
|
||||
grid.face_nodes[i] = vag_grid.faces_to_vertices.value[i]-1;
|
||||
}
|
||||
// fill cell_face
|
||||
for(int i=0;i< int(vag_grid.volumes_to_faces.pos.size());++i){
|
||||
grid.cell_facepos[i] = vag_grid.volumes_to_faces.pos[i];
|
||||
}
|
||||
}
|
||||
for(int i=0;i< int(vag_grid.volumes_to_faces.value.size());++i){
|
||||
grid.cell_faces[i] = vag_grid.volumes_to_faces.value[i]-1;
|
||||
}
|
||||
@@ -231,7 +231,7 @@ namespace Opm
|
||||
// is not used
|
||||
cout << "Computing geometry" << endl;
|
||||
compute_geometry(&grid);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void unstructuredGridToVag(UnstructuredGrid& grid,Opm::VAG& vag_grid){
|
||||
@@ -242,7 +242,7 @@ namespace Opm
|
||||
vag_grid.number_of_volumes=grid.number_of_cells;
|
||||
vag_grid.number_of_faces=grid.number_of_faces;
|
||||
vag_grid.number_of_vertices=grid.number_of_nodes;
|
||||
|
||||
|
||||
// resizing vectors
|
||||
vag_grid.vertices.resize(grid.number_of_nodes*3);
|
||||
vag_grid.faces_to_vertices.pos.resize(grid.number_of_faces+1);
|
||||
@@ -252,8 +252,8 @@ namespace Opm
|
||||
vag_grid.volumes_to_faces.value.resize(grid.cell_facepos[grid.number_of_cells]);//not known
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// fill face_nodes
|
||||
for(int i=0;i< int(vag_grid.faces_to_vertices.pos.size());++i){
|
||||
vag_grid.faces_to_vertices.pos[i] = grid.face_nodepos[i];
|
||||
@@ -262,11 +262,11 @@ namespace Opm
|
||||
for(int i=0;i< int(vag_grid.faces_to_vertices.value.size());++i){
|
||||
vag_grid.faces_to_vertices.value[i] = grid.face_nodes[i] +1;
|
||||
}
|
||||
|
||||
// fill cell_face
|
||||
|
||||
// fill cell_face
|
||||
for(int i=0;i< int(vag_grid.volumes_to_faces.pos.size());++i){
|
||||
vag_grid.volumes_to_faces.pos[i] = grid.cell_facepos[i];
|
||||
}
|
||||
}
|
||||
for(int i=0;i< int(vag_grid.volumes_to_faces.value.size());++i){
|
||||
vag_grid.volumes_to_faces.value[i] = grid.cell_faces[i] +1;
|
||||
}
|
||||
@@ -280,7 +280,7 @@ namespace Opm
|
||||
vag_grid.vertices[i] = grid.node_coordinates[i];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// The missing field need to be constructed
|
||||
// gennerate volume to vertice mapping
|
||||
std::vector< std::set<int> > volumes_to_vertices(grid.number_of_cells);
|
||||
@@ -297,7 +297,7 @@ namespace Opm
|
||||
}
|
||||
volumes_to_vertices[i]=nodes;
|
||||
}
|
||||
|
||||
|
||||
// fill volume to vertice map
|
||||
vag_grid.volumes_to_vertices.pos.resize(grid.number_of_cells+1);
|
||||
vag_grid.volumes_to_vertices.value.resize(0);
|
||||
@@ -318,15 +318,15 @@ namespace Opm
|
||||
for(int i=0;i < grid.number_of_faces;++i){
|
||||
int ne=grid.face_nodepos[i+1]-grid.face_nodepos[i];
|
||||
nfe=nfe+ne;
|
||||
|
||||
|
||||
for(int j=0; j < ne-1;++j){
|
||||
int node1=grid.face_nodes[grid.face_nodepos[i]+j]+1;
|
||||
int node2=grid.face_nodes[grid.face_nodepos[i]+j+1]+1;
|
||||
std::set<int> spair;
|
||||
spair.insert(node1);
|
||||
spair.insert(node2);
|
||||
spair.insert(node2);
|
||||
edges.insert(spair);
|
||||
faces_spares[i].push_back(spair);
|
||||
faces_spares[i].push_back(spair);
|
||||
}
|
||||
// add end segment
|
||||
{
|
||||
@@ -334,12 +334,12 @@ namespace Opm
|
||||
int node1=grid.face_nodes[grid.face_nodepos[i]+ne-1]+1;
|
||||
int node2=grid.face_nodes[grid.face_nodepos[i]]+1;
|
||||
spair.insert(node1);
|
||||
spair.insert(node2);
|
||||
spair.insert(node2);
|
||||
edges.insert(spair);
|
||||
faces_spares[i].push_back(spair);
|
||||
faces_spares[i].push_back(spair);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// make edge numbering and fill edges
|
||||
std::map<std::set<int>, int> edge_map;
|
||||
std::set< std::set<int> >::iterator it;
|
||||
@@ -358,18 +358,18 @@ namespace Opm
|
||||
vag_grid.faces_to_edges.pos.resize(vag_grid.number_of_faces+1);
|
||||
for(int i=0;i < grid.number_of_faces;++i){
|
||||
int ne=grid.face_nodepos[i+1]-grid.face_nodepos[i];
|
||||
vag_grid.faces_to_edges.pos[i+1]=vag_grid.faces_to_edges.pos[i]+ne;
|
||||
vag_grid.faces_to_edges.pos[i+1]=vag_grid.faces_to_edges.pos[i]+ne;
|
||||
for(int j=0;j<int(faces_spares[i].size());++j){
|
||||
int edge_num=edge_map[faces_spares[i][j]];
|
||||
vag_grid.faces_to_edges.value.push_back(edge_num+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// vag_grid.edges(0);//not known
|
||||
// vag_grid.faces_to_edges// not known
|
||||
|
||||
|
||||
// material // can not be extracted from the grid
|
||||
}
|
||||
|
||||
|
||||
void writeVagFormat(std::ostream& os,Opm::VAG& vag_grid){
|
||||
using namespace std;
|
||||
os << "File in the Vag grid format\n";
|
||||
@@ -384,20 +384,20 @@ namespace Opm
|
||||
os <<"Vertices " << vag_grid.vertices.size() << endl;
|
||||
writeVector(os, vag_grid.vertices,3);
|
||||
os << "Volumes->faces " << vag_grid.volumes_to_faces.pos.size()-1 << endl;
|
||||
writePosStruct(os, vag_grid.volumes_to_faces);
|
||||
writePosStruct(os, vag_grid.volumes_to_faces);
|
||||
os << "Volumes->Vertices " << vag_grid.volumes_to_vertices.pos.size()-1 << endl;
|
||||
writePosStruct(os, vag_grid.volumes_to_vertices);
|
||||
writePosStruct(os, vag_grid.volumes_to_vertices);
|
||||
os << "Faces->edges " << vag_grid.faces_to_edges.pos.size()-1 << endl;
|
||||
writePosStruct(os, vag_grid.faces_to_edges);
|
||||
os << "Faces->vertices " << vag_grid.faces_to_vertices.pos.size()-1 << endl;
|
||||
writePosStruct(os, vag_grid.faces_to_vertices);
|
||||
os << "Faces->Control volumes " << floor(vag_grid.faces_to_volumes.size()/2) << endl;
|
||||
writeVector(os,vag_grid.faces_to_volumes,2);
|
||||
writeVector(os,vag_grid.faces_to_volumes,2);
|
||||
os << "Edges " << floor(vag_grid.edges.size()/2) << endl;
|
||||
writeVector(os,vag_grid.edges,2);
|
||||
/*
|
||||
assert(vag_grid.material.size()%vag_grid.number_of_volumes==0);
|
||||
int lines= floor(vag_grid.material.size()/vag_grid.number_of_volumes);
|
||||
int lines= floor(vag_grid.material.size()/vag_grid.number_of_volumes);
|
||||
os << "Material number " << 1 << endl;
|
||||
writeVector(os,vag_grid.material,lines);
|
||||
*/
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Opm
|
||||
Struct to hold mapping from the natural numbers less than pos.size()-1 to
|
||||
a set of integers. value(pos(i):pos(i+1)-1) hold the integers corresponding to i.
|
||||
pos(end)-1==value.size();
|
||||
*/
|
||||
*/
|
||||
struct PosStruct{
|
||||
std::vector<int> pos;
|
||||
std::vector<int> value;
|
||||
@@ -60,7 +60,7 @@ namespace Opm
|
||||
3D grids.
|
||||
*/
|
||||
struct VAG{
|
||||
int number_of_vertices;
|
||||
int number_of_vertices;
|
||||
int number_of_volumes;
|
||||
int number_of_faces;
|
||||
int number_of_edges;
|
||||
@@ -104,7 +104,7 @@ namespace Opm
|
||||
Function to read a vector of some type from a stream.
|
||||
\param[in] os is is stream of the file.
|
||||
\param[out] vag_grid is a resized and filled vector containing the quantiy read.
|
||||
*/
|
||||
*/
|
||||
template <typename T>
|
||||
void readVector(std::istream& is,std::vector<T>& vec){
|
||||
using namespace std;
|
||||
@@ -117,7 +117,7 @@ namespace Opm
|
||||
\param[in] os is is stream of the file.
|
||||
\param[out] vag_grid is a resized and filled vector containing the quantiy read.
|
||||
\param[in] n number of doubles on each line.
|
||||
*/
|
||||
*/
|
||||
template <typename T>
|
||||
void writeVector(std::ostream& os,std::vector<T>& vec,int n){
|
||||
typedef typename std::vector<T>::size_type sz_t;
|
||||
@@ -146,20 +146,20 @@ namespace Opm
|
||||
\param[in] pos_struct to write
|
||||
*/
|
||||
void writePosStruct(std::ostream& os,PosStruct& pos_struct);
|
||||
|
||||
|
||||
/**
|
||||
Fill a UnstructuredGrid from a vag_grid.
|
||||
\param[out] vag_grid s is a valid vag_grid struct.
|
||||
\param[in] grid is a grid with have allocated correct size to each pointer.
|
||||
*/
|
||||
void vagToUnstructuredGrid(Opm::VAG& vag_grid,UnstructuredGrid& grid);
|
||||
|
||||
|
||||
/**
|
||||
Fill a vag_grid from UnstructuredGrid
|
||||
Fill a vag_grid from UnstructuredGrid
|
||||
\param[out] vag_grid s is a valid vag_grid struct.
|
||||
\param[in] grid is a grid with have allocated correct size to each pointer.
|
||||
*/
|
||||
*/
|
||||
void unstructuredGridToVag(UnstructuredGrid& grid, Opm::VAG& vag_grid);
|
||||
}
|
||||
#endif /* OPM_VAG_HPP_HEADER */
|
||||
#endif /* OPM_VAG_HPP_HEADER */
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Opm
|
||||
os << 1;
|
||||
}
|
||||
os << "\n";
|
||||
|
||||
|
||||
os << "ORIGIN " << 0.0 << " " << 0.0 << " " << 0.0 << "\n";
|
||||
|
||||
os << "SPACING " << cell_size[0] << " " << cell_size[1];
|
||||
@@ -106,7 +106,7 @@ namespace Opm
|
||||
indent(os);
|
||||
os << "<" << tag;
|
||||
for (PMap::const_iterator it = props.begin(); it != props.end(); ++it) {
|
||||
os << " " << it->first << "=\"" << it->second << "\"";
|
||||
os << " " << it->first << "=\"" << it->second << "\"";
|
||||
}
|
||||
os << ">\n";
|
||||
++indent_;
|
||||
@@ -310,7 +310,7 @@ namespace Opm
|
||||
|| item == num_cells - 1) {
|
||||
os << '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Opm
|
||||
return solver_->solve(size, nonzeros, ia, ja, sa, rhs, solution);
|
||||
}
|
||||
|
||||
void LinearSolverFactory::setTolerance(const double tol)
|
||||
void LinearSolverFactory::setTolerance(const double tol)
|
||||
{
|
||||
solver_->setTolerance(tol);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Opm
|
||||
/// Get tolerance for the linear solver.
|
||||
/// \param[out] tolerance value
|
||||
virtual double getTolerance() const = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Opm
|
||||
int linsolver_smooth_steps_;
|
||||
/** \brief The factor to scale the coarse grid correction with. */
|
||||
double linsolver_prolongate_factor_;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Opm
|
||||
int ok = flow_conditions_append_multi(BC_PRESSURE, faces.size(), &faces[0], pressure, bc_);
|
||||
if (!ok) {
|
||||
THROW("Failed to append pressure boundary conditions for side " << sideString(side));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
|
||||
#include <opm/core/pressure/msmfem/dfs.h>
|
||||
|
||||
/*
|
||||
* Assign color (nonnegative number) to each connected component of graph
|
||||
/*
|
||||
* Assign color (nonnegative number) to each connected component of graph
|
||||
*/
|
||||
void dfs (int size, int *ia, int *ja, int *ncolors, int *color, int* work)
|
||||
{
|
||||
@@ -35,7 +35,7 @@ void dfs (int size, int *ia, int *ja, int *ncolors, int *color, int* work)
|
||||
int *bottom = stack;
|
||||
|
||||
*ncolors = 0; /* colors are nonnegative */
|
||||
|
||||
|
||||
for (i=0; i<size; ++i) {
|
||||
color [i] = UNVISITED;
|
||||
count [i] = ia[i+1]-ia[i];
|
||||
@@ -52,16 +52,16 @@ void dfs (int size, int *ia, int *ja, int *ncolors, int *color, int* work)
|
||||
|
||||
while ( stack != bottom ) {
|
||||
c = *(stack-1); /* peek */
|
||||
|
||||
|
||||
if (count[c] > 0){
|
||||
int child = ja[ia[c] + count[c]-1];
|
||||
count[c]--;
|
||||
|
||||
|
||||
if (color[child] == UNVISITED) {
|
||||
*stack++ = child;
|
||||
color[c] = VISITED;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
color[c] = *ncolors;
|
||||
--stack; /* pop c */
|
||||
@@ -104,9 +104,9 @@ int main (int argc, char *argv [])
|
||||
|
||||
fprintf(stderr, "ncolors = %d\n", ncolors);
|
||||
for (j=0; j<size; ++j) {
|
||||
fprintf(stderr, "%d\n", color[j]);
|
||||
fprintf(stderr, "%d\n", color[j]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
free (color);
|
||||
free (work);
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Opm
|
||||
/// mapping from cell indices (typically from a processed grid)
|
||||
/// to logical cartesian indices consistent with the deck.
|
||||
BlackoilPropertiesFromDeck(const EclipseGridParser& deck,
|
||||
const UnstructuredGrid& grid, bool init_rock=true );
|
||||
const UnstructuredGrid& grid, bool init_rock=true );
|
||||
|
||||
/// Initialize from deck, grid and parameters.
|
||||
/// \param[in] deck Deck input parser
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace Opm
|
||||
initEPS(deck, grid, std::string("KRWR"), eps_.krwr_);
|
||||
initEPS(deck, grid, std::string("KRO"), eps_.kro_);
|
||||
initEPS(deck, grid, std::string("KRORW"), eps_.krorw_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace Opm
|
||||
const std::string& keyword,
|
||||
std::vector<double>& scaleparam)
|
||||
{
|
||||
bool useKeyword = deck.hasField(keyword);
|
||||
bool useKeyword = deck.hasField(keyword);
|
||||
bool hasENPTVD = deck.hasField("ENPTVD");
|
||||
bool hasENKRVD = deck.hasField("ENKRVD");
|
||||
int itab = 0;
|
||||
@@ -301,8 +301,8 @@ namespace Opm
|
||||
}
|
||||
if (!useKeyword && itab > 0) {
|
||||
table = deck.getENPTVD().table_;
|
||||
}
|
||||
} else if (keyword[0] == 'K' && (useKeyword || hasENKRVD)) {
|
||||
}
|
||||
} else if (keyword[0] == 'K' && (useKeyword || hasENKRVD)) {
|
||||
if (keyword == std::string("KRW")) {
|
||||
if (useKeyword || deck.getENKRVD().mask_[0]) {
|
||||
itab = 1;
|
||||
@@ -336,7 +336,7 @@ namespace Opm
|
||||
}
|
||||
if (!useKeyword && itab > 0) {
|
||||
table = deck.getENKRVD().table_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scaleparam.empty()) {
|
||||
@@ -371,7 +371,7 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Saturation scaling
|
||||
template <class SatFuncSet>
|
||||
@@ -380,11 +380,11 @@ namespace Opm
|
||||
const int wpos = phase_usage_.phase_pos[BlackoilPhases::Aqua];
|
||||
const int opos = phase_usage_.phase_pos[BlackoilPhases::Liquid];
|
||||
double ss[PhaseUsage::MaxNumPhases];
|
||||
|
||||
|
||||
if (do_3pt_) { // Three-point scaling
|
||||
// Transforms for water saturation
|
||||
// Transforms for water saturation
|
||||
if (eps_.swcr_.empty() && eps_.swu_.empty()) {
|
||||
ss[wpos] = s[wpos];
|
||||
ss[wpos] = s[wpos];
|
||||
} else {
|
||||
double s_r = 1.0-funcForCell(cell).sowcr_;
|
||||
double sr = eps_.sowcr_.empty() ? s_r : 1.0-eps_.sowcr_[cell];
|
||||
@@ -398,9 +398,9 @@ namespace Opm
|
||||
ss[wpos] = (s[wpos] >= swmax) ? sw_max : s_r+(s[wpos]-sr)*(sw_max-s_r)/(swmax-sr);
|
||||
}
|
||||
}
|
||||
// Transforms for oil saturation
|
||||
// Transforms for oil saturation
|
||||
if (eps_.sowcr_.empty() && eps_.swl_.empty()) {
|
||||
ss[opos] = s[opos];
|
||||
ss[opos] = s[opos];
|
||||
} else {
|
||||
double s_r = 1.0-funcForCell(cell).swcr_;
|
||||
double sr = eps_.swcr_.empty() ? s_r : 1.0-eps_.swcr_[cell];
|
||||
@@ -415,9 +415,9 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
} else { // Two-point scaling
|
||||
// Transforms for water saturation
|
||||
// Transforms for water saturation
|
||||
if (eps_.swcr_.empty() && eps_.swu_.empty()) {
|
||||
ss[wpos] = s[wpos];
|
||||
ss[wpos] = s[wpos];
|
||||
} else {
|
||||
double sw_cr = funcForCell(cell).swcr_;
|
||||
double swcr = eps_.swcr_.empty() ? sw_cr : eps_.swcr_[cell];
|
||||
@@ -429,9 +429,9 @@ namespace Opm
|
||||
ss[wpos] = (s[wpos] >= swmax) ? sw_max : sw_cr + (s[wpos]-swcr)*(sw_max-sw_cr)/(swmax-swcr);
|
||||
}
|
||||
}
|
||||
// Transforms for oil saturation
|
||||
// Transforms for oil saturation
|
||||
if (eps_.sowcr_.empty() && eps_.swl_.empty()) {
|
||||
ss[opos] = s[opos];
|
||||
ss[opos] = s[opos];
|
||||
} else {
|
||||
double sow_cr = funcForCell(cell).sowcr_;
|
||||
double socr = eps_.sowcr_.empty() ? sow_cr : eps_.sowcr_[cell];
|
||||
@@ -453,7 +453,7 @@ namespace Opm
|
||||
// Assume: sw_cr -> krw=0 sw_max -> krw=<max water relperm>
|
||||
// sow_cr -> kro=0 sow_max -> kro=<max oil relperm>
|
||||
funcForCell(cell).evalKr(ss, kr);
|
||||
}
|
||||
}
|
||||
|
||||
// Scaling of relperms values
|
||||
// - Water
|
||||
@@ -471,7 +471,7 @@ namespace Opm
|
||||
double sw_max = funcForCell(cell).smax_[wpos];
|
||||
double s_r = 1.0-funcForCell(cell).sowcr_;
|
||||
sr = swcr + (s_r-sw_cr)*(swmax-swcr)/(sw_max-sw_cr);
|
||||
}
|
||||
}
|
||||
if (s[wpos] <= swcr) {
|
||||
kr[wpos] = 0.0;
|
||||
} else if (sr > swmax-1.0e-6) {
|
||||
@@ -496,7 +496,7 @@ namespace Opm
|
||||
kr[wpos] = eps_.krw_.empty() ? funcForCell(cell).krwmax_ : eps_.krw_[cell];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// - Oil
|
||||
if (eps_.kro_.empty() && eps_.krorw_.empty()) { // No value scaling
|
||||
} else if (eps_.krorw_.empty()) { // Two-point scaling
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Opm
|
||||
{
|
||||
return boost::posix_time::ptime(start_date_) + boost::posix_time::seconds( (int) current_time_ );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// Total time.
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Opm
|
||||
class BlackoilPropertiesInterface;
|
||||
|
||||
/// \file
|
||||
///
|
||||
///
|
||||
/// Functions for initializing a reservoir state.
|
||||
|
||||
/// Initialize a two-phase state from parameters.
|
||||
|
||||
@@ -507,7 +507,7 @@ namespace Opm
|
||||
if (!deck.hasField("SGAS")) {
|
||||
THROW("initStateFromDeck(): missing SGAS keyword in 2-phase init");
|
||||
}
|
||||
const std::vector<double>& sg_deck = deck.getFloatingPointValue("SGAS");
|
||||
const std::vector<double>& sg_deck = deck.getFloatingPointValue("SGAS");
|
||||
const int gpos = pu.phase_pos[BlackoilPhases::Vapour];
|
||||
const int opos = pu.phase_pos[BlackoilPhases::Liquid];
|
||||
for (int c = 0; c < num_cells; ++c) {
|
||||
|
||||
@@ -9,19 +9,19 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Opm
|
||||
} // anon namespace
|
||||
|
||||
|
||||
|
||||
|
||||
/// \param[in] columns for each column columns.second,
|
||||
/// contains the cells on which to solve the segregation
|
||||
/// problem. For each column, its cells must be in a single
|
||||
@@ -90,16 +90,16 @@ namespace Opm
|
||||
// std::map<int, std::vector<int> >::const_iterator it;
|
||||
//for (it = columns.begin(); it != columns.end(); ++it) {
|
||||
int size = columns.size();
|
||||
|
||||
|
||||
#pragma omp parallel for schedule(dynamic)
|
||||
for(int i = 0; i < size; ++i) {
|
||||
solveSingleColumn(columns[i], dt, s, increment);
|
||||
}
|
||||
}
|
||||
|
||||
for (int cell = 0; cell < grid_.number_of_cells; ++cell) {
|
||||
sys.vector().writableSolution()[cell] += increment[cell];
|
||||
}
|
||||
|
||||
|
||||
const double maxelem = *std::max_element(increment.begin(), increment.end());
|
||||
const double minelem = *std::min_element(increment.begin(), increment.end());
|
||||
max_delta = std::max(maxelem, -minelem);
|
||||
@@ -173,7 +173,7 @@ namespace Opm
|
||||
D[ci] += j1contrib;
|
||||
rhs[ci] += rescontrib;
|
||||
}
|
||||
// model_.sourceTerms(); // Not needed
|
||||
// model_.sourceTerms(); // Not needed
|
||||
// Solve.
|
||||
const MAT_SIZE_T num_rhs = 1, colSize = col_size;
|
||||
MAT_SIZE_T info = 0;
|
||||
|
||||
@@ -9,19 +9,19 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
@@ -9,19 +9,19 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
@@ -83,11 +83,11 @@ spu_explicit(struct UnstructuredGrid *g, double *s0, double *s, double *mob,
|
||||
}
|
||||
}
|
||||
|
||||
/* Water flux */
|
||||
/* Water flux */
|
||||
assert(m1+m2>0.0);
|
||||
flux = m1/(m1+m2)*(dflux[f] + m2*gflux[f]);
|
||||
s[c1] -= flux*dt;
|
||||
s[c2] += flux*dt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,9 @@
|
||||
#ifndef SPU_EXPLICIT_H_INCLUDED
|
||||
#define SPU_EXPLICIT_H_INCLUDED
|
||||
void
|
||||
spu_explicit(struct UnstructuredGrid *g,
|
||||
double *s0,
|
||||
double *s,
|
||||
spu_explicit(struct UnstructuredGrid *g,
|
||||
double *s0,
|
||||
double *s,
|
||||
double *mob,
|
||||
double *dflux,
|
||||
double *gflux,
|
||||
|
||||
@@ -28,25 +28,25 @@ interpolate(int n, double h, double x0, double *tab, double x)
|
||||
assert((x-x0) < h*INT_MAX);
|
||||
assert((x-x0) > h*INT_MIN);
|
||||
|
||||
if ( x < x0 ) {
|
||||
if ( x < x0 ) {
|
||||
return tab[0];
|
||||
}
|
||||
|
||||
|
||||
i = ((x-x0)/h);
|
||||
|
||||
assert(i>=0);
|
||||
|
||||
if (i+1 > n-1) {
|
||||
|
||||
if (i+1 > n-1) {
|
||||
return tab[n-1];
|
||||
}
|
||||
|
||||
|
||||
a = (x-x0 - i*h) / h;
|
||||
|
||||
|
||||
return (1-a) * tab[i] + a * tab[i+1];
|
||||
}
|
||||
|
||||
/* Assume uniformly spaced table. */
|
||||
static double
|
||||
static double
|
||||
differentiate(int n, double h, double x0, double *tab, double x)
|
||||
{
|
||||
int i;
|
||||
@@ -56,27 +56,27 @@ differentiate(int n, double h, double x0, double *tab, double x)
|
||||
assert((x-x0) > h*INT_MIN);
|
||||
assert(n>1);
|
||||
|
||||
if ( x < x0 ) {
|
||||
if ( x < x0 ) {
|
||||
return (tab[1]-tab[0])/h;
|
||||
}
|
||||
|
||||
|
||||
i = ((x-x0)/h);
|
||||
|
||||
assert(i>=0);
|
||||
|
||||
if (i+1 > n-1) {
|
||||
|
||||
if (i+1 > n-1) {
|
||||
return (tab[n-1]-tab[n-2])/h;
|
||||
}
|
||||
|
||||
|
||||
return (tab[i+1]-tab[i])/h;
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
compute_mobilities(int n, double *s, double *mob, double *dmob, int ntab, double h, double x0, double *tab)
|
||||
{
|
||||
double *tabw=tab;
|
||||
double *tabo=tab+ntab;
|
||||
|
||||
|
||||
int i;
|
||||
for (i=0; i<n; ++i) {
|
||||
*mob++ = interpolate (ntab, h, x0, tabw, *s);
|
||||
@@ -102,25 +102,25 @@ compute_mobilities(int n, double *s, double *mob, double *dmob, int ntab, double
|
||||
* dF dt mo 1
|
||||
* --- = -- · ------- ----- (dflux + mo*gflux)
|
||||
* dmw pv mw + mo mw + mo
|
||||
*
|
||||
*
|
||||
* dt fo
|
||||
* = -- -- (dflux + mo*gflux)
|
||||
* pv mt
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* dF dt fw
|
||||
* --- = -1 * -- -- (dflux - mw*gflux)
|
||||
* dmo pv mt
|
||||
*
|
||||
*
|
||||
* and the chain rule
|
||||
* and the chain rule
|
||||
*
|
||||
* dF dF dmw dF dmo
|
||||
* -- = --- --- + --- ---.
|
||||
* dS dmw dS dmo dS
|
||||
*
|
||||
*
|
||||
* If the gravity term is zero, we can use the simpler rule
|
||||
* If the gravity term is zero, we can use the simpler rule
|
||||
*
|
||||
* dF mo * dmw - mw * dmo
|
||||
* -- = -------------------
|
||||
@@ -128,16 +128,16 @@ compute_mobilities(int n, double *s, double *mob, double *dmob, int ntab, double
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
double
|
||||
*/
|
||||
double
|
||||
spu_implicit(struct UnstructuredGrid *g, double *s0, double *s, double h, double x0, int ntab, double *tab,
|
||||
double *dflux, double *gflux, double *src, double dt,
|
||||
double *dflux, double *gflux, double *src, double dt,
|
||||
void (*linear_solver)(int, int*, int*, double *, double *, double *))
|
||||
{
|
||||
int nc = g->number_of_cells;
|
||||
int nhf = g->cell_facepos[nc]; /* Too much */
|
||||
double infnorm;
|
||||
double *b;
|
||||
double *b;
|
||||
double *x;
|
||||
char *work;
|
||||
double *mob, *dmob;
|
||||
@@ -158,28 +158,28 @@ spu_implicit(struct UnstructuredGrid *g, double *s0, double *s, double h, double
|
||||
}
|
||||
|
||||
b = malloc(nc * sizeof *b);
|
||||
x = malloc(nc * sizeof *x);
|
||||
x = malloc(nc * sizeof *x);
|
||||
|
||||
work = malloc(6*sizeof (double));
|
||||
mob = malloc(g->number_of_cells *2* sizeof *mob);
|
||||
dmob = malloc(g->number_of_cells *2* sizeof *dmob);
|
||||
|
||||
|
||||
infnorm = 1.0;
|
||||
it = 0;
|
||||
while (infnorm > 1e-9 && it++ < 20) {
|
||||
compute_mobilities(g->number_of_cells, s, mob, dmob, ntab, h, x0, tab);
|
||||
spu_implicit_assemble(g, s0, s, mob, dmob, dflux, gflux, src, dt, S, b, work);
|
||||
|
||||
|
||||
/* Compute inf-norm of residual */
|
||||
infnorm = 0.0;
|
||||
for(i=0; i<nc; ++i) {
|
||||
infnorm = (infnorm > fabs(b[i]) ? infnorm : fabs(b[i]));
|
||||
}
|
||||
fprintf(stderr, " Max norm of residual: %e\n", infnorm);
|
||||
|
||||
|
||||
/* Solve system */
|
||||
(*linear_solver)(S->m, S->ia, S->ja, S->sa, b, x);
|
||||
|
||||
|
||||
/* Return x. */
|
||||
for(i=0; i<nc; ++i) {
|
||||
s[i] = s[i] - x[i];
|
||||
@@ -191,19 +191,19 @@ spu_implicit(struct UnstructuredGrid *g, double *s0, double *s, double h, double
|
||||
free(mob);
|
||||
free(dmob);
|
||||
|
||||
free(b);
|
||||
free(b);
|
||||
free(x);
|
||||
free(S->ia);
|
||||
free(S->ja);
|
||||
free(S->sa);
|
||||
free(S);
|
||||
|
||||
return infnorm;
|
||||
return infnorm;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
phase_upwind_mobility(double darcyflux, double gravityflux, int i, int c,
|
||||
phase_upwind_mobility(double darcyflux, double gravityflux, int i, int c,
|
||||
double *mob, double *dmob, double *m, double *dm, int *cix)
|
||||
{
|
||||
/* ====================================================== */
|
||||
@@ -217,7 +217,7 @@ phase_upwind_mobility(double darcyflux, double gravityflux, int i, int c,
|
||||
dm[0] = dmob[2*i+0];
|
||||
cix[0] = i;
|
||||
}
|
||||
|
||||
|
||||
/* Negative water phase flux */
|
||||
else {
|
||||
m [0] = mob [2*c+0];
|
||||
@@ -239,11 +239,11 @@ phase_upwind_mobility(double darcyflux, double gravityflux, int i, int c,
|
||||
cix[1] = c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ====================================================== */
|
||||
/* If Darcy flux and gravity flux have opposite sign... */
|
||||
else {
|
||||
|
||||
|
||||
/* Positive oil phase flux */
|
||||
if (darcyflux>0) {
|
||||
m [1] = mob[2*i+1];
|
||||
@@ -274,9 +274,9 @@ phase_upwind_mobility(double darcyflux, double gravityflux, int i, int c,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
spu_implicit_assemble(struct UnstructuredGrid *g, double *s0, double *s, double *mob, double *dmob,
|
||||
double *dflux, double *gflux, double *src, double dt, sparse_t *S,
|
||||
double *dflux, double *gflux, double *src, double dt, sparse_t *S,
|
||||
double *b, char *work)
|
||||
{
|
||||
int i, k, f, c1, c2, c;
|
||||
@@ -286,7 +286,7 @@ spu_implicit_assemble(struct UnstructuredGrid *g, double *s0, double *s, double
|
||||
double *dm = m + 2;
|
||||
int *cix = (int*)(dm + 2);
|
||||
double m1, m2, dm1, dm2, mt2;
|
||||
|
||||
|
||||
int *pja;
|
||||
double *psa;
|
||||
double *d;
|
||||
@@ -295,9 +295,9 @@ spu_implicit_assemble(struct UnstructuredGrid *g, double *s0, double *s, double
|
||||
|
||||
pja = S->ja;
|
||||
psa = S->sa;
|
||||
|
||||
|
||||
/* Assemble system */
|
||||
S->ia[0] = 0;
|
||||
S->ia[0] = 0;
|
||||
for (i=0; i<nc; ++i) {
|
||||
|
||||
/* Store position of diagonal element */
|
||||
@@ -306,9 +306,9 @@ spu_implicit_assemble(struct UnstructuredGrid *g, double *s0, double *s, double
|
||||
*d = 0.0;
|
||||
|
||||
/* Accumulation term */
|
||||
b[i] = (s[i] - s0[i]);
|
||||
b[i] = (s[i] - s0[i]);
|
||||
*d += 1.0;
|
||||
|
||||
|
||||
/* Flux terms follows*/
|
||||
for (k=g->cell_facepos[i]; k<g->cell_facepos[i+1]; ++k) {
|
||||
f = g->cell_faces[k];
|
||||
@@ -316,7 +316,7 @@ spu_implicit_assemble(struct UnstructuredGrid *g, double *s0, double *s, double
|
||||
c2 = g->face_cells[2*f+1];
|
||||
|
||||
/* Skip all boundary terms (for now). */
|
||||
if (c1 == -1 || c2 == -1) { continue; }
|
||||
if (c1 == -1 || c2 == -1) { continue; }
|
||||
|
||||
/* Set cell index of other cell, set correct sign of fluxes. */
|
||||
c = (i==c1 ? c2 : c1);
|
||||
@@ -334,21 +334,21 @@ spu_implicit_assemble(struct UnstructuredGrid *g, double *s0, double *s, double
|
||||
mt2 = (m[0]+m[1])*(m[0]+m[1]);
|
||||
*psa = 0.0;
|
||||
*pja = c;
|
||||
|
||||
|
||||
/* dFw/dmw·dmw/dsw */
|
||||
if (cix[0] == c ) { *psa += m[1]/mt2*(df + m[1]*gf)*dm[0]; }
|
||||
else { *d += m[1]/mt2*(df + m[1]*gf)*dm[0]; }
|
||||
|
||||
|
||||
/* dFw/dmo·dmo/dsw */
|
||||
if (cix[1] == c) { *psa += -m[0]/mt2*(df - m[0]*gf)*dm[1]; }
|
||||
else { *d += -m[0]/mt2*(df - m[0]*gf)*dm[1]; }
|
||||
|
||||
|
||||
|
||||
|
||||
if (cix[0] == c || cix[1] == c) {
|
||||
++psa;
|
||||
++pja;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Injection */
|
||||
@@ -358,18 +358,18 @@ spu_implicit_assemble(struct UnstructuredGrid *g, double *s0, double *s, double
|
||||
m2 = 0.0;
|
||||
b[i] -= dt*src[i] * m1/(m1+m2);
|
||||
}
|
||||
|
||||
|
||||
/* Production */
|
||||
else {
|
||||
m1 = mob [2*i+0];
|
||||
m2 = mob [2*i+1];
|
||||
dm1 = dmob[2*i+0];
|
||||
dm2 = dmob[2*i+1];
|
||||
|
||||
|
||||
*d -= dt*src[i] *(m2*dm1-m1*dm2)/(m1+m2)/(m1+m2);
|
||||
b[i] -= dt*src[i] *m1/(m1+m2);
|
||||
|
||||
|
||||
}
|
||||
S->ia[i+1] = pja - S->ja;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,14 +16,14 @@ typedef struct Sparse {
|
||||
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
spu_implicit_assemble(struct UnstructuredGrid *g, double *s0, double *s, double *mob, double *dmob,
|
||||
double *dflux, double *gflux, double *src, double dt, sparse_t *S,
|
||||
double *dflux, double *gflux, double *src, double dt, sparse_t *S,
|
||||
double *b, char *work);
|
||||
|
||||
double
|
||||
double
|
||||
spu_implicit(struct UnstructuredGrid *g, double *s0, double *s, double h, double x0, int ntab, double *tab,
|
||||
double *dflux, double *gflux, double *src, double dt,
|
||||
double *dflux, double *gflux, double *src, double dt,
|
||||
void (*linear_solver)(int, int*, int*, double *, double *, double *));
|
||||
|
||||
#endif /* SPU_IMPLICIT_H_INCLUDED */
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
MonotCubicInterpolator
|
||||
Copyright (C) 2006 Statoil ASA
|
||||
|
||||
|
||||
This program 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 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
@@ -24,7 +24,7 @@
|
||||
Class to represent a one-dimensional function with single-valued
|
||||
argument. Cubic interpolation, preserving the monotonicity of the
|
||||
discrete known function values
|
||||
|
||||
|
||||
@see MonotCubicInterpolator.h for further documentation.
|
||||
|
||||
*/
|
||||
@@ -50,8 +50,8 @@ using namespace std;
|
||||
|
||||
Internal data structure of points and values:
|
||||
|
||||
vector(s):
|
||||
- Easier coding
|
||||
vector(s):
|
||||
- Easier coding
|
||||
- Faster vector operations when setting up derivatives.
|
||||
- sorting slightly more complex.
|
||||
- insertion of further values bad.
|
||||
@@ -61,11 +61,11 @@ using namespace std;
|
||||
- code complexity almost as for map.
|
||||
- insertion of additional values bad
|
||||
|
||||
vector over struct datapoint { x, f, d}
|
||||
vector over struct datapoint { x, f, d}
|
||||
- nice code
|
||||
- not as sortable, insertion is cumbersome.
|
||||
|
||||
** This is used currently: **
|
||||
** This is used currently: **
|
||||
map<double, double> one for (x,f) and one for (x,d)
|
||||
- Naturally sorted on x-values (done by the map-construction)
|
||||
- Slower to set up, awkward loop coding (?)
|
||||
@@ -79,7 +79,7 @@ using namespace std;
|
||||
- even more unreadable(??) code?
|
||||
- higher skills needed by programmer.
|
||||
|
||||
|
||||
|
||||
MONOTONE CUBIC INTERPOLATION:
|
||||
|
||||
It is a local algorithm. Adding one point only incur recomputation
|
||||
@@ -87,7 +87,7 @@ using namespace std;
|
||||
divided).
|
||||
|
||||
NOTE: We do not currently make use of this local fact. Upon
|
||||
insertion of a new data pair, everything is recomputed. Revisit
|
||||
insertion of a new data pair, everything is recomputed. Revisit
|
||||
this when needed.
|
||||
|
||||
*/
|
||||
@@ -102,7 +102,7 @@ MonotCubicInterpolator(const vector<double> & x, const vector<double> & f) {
|
||||
if (x.size() != f.size()) {
|
||||
throw("Unable to constuct MonotCubicInterpolator from vectors.") ;
|
||||
}
|
||||
|
||||
|
||||
// Add the contents of the input vectors to our map of values.
|
||||
vector<double>::const_iterator posx, posf;
|
||||
for (posx = x.begin(), posf = f.begin(); posx != x.end(); ++posx, ++posf) {
|
||||
@@ -114,9 +114,9 @@ MonotCubicInterpolator(const vector<double> & x, const vector<double> & f) {
|
||||
|
||||
|
||||
|
||||
bool
|
||||
bool
|
||||
MonotCubicInterpolator::
|
||||
read(const std::string & datafilename, int xColumn, int fColumn)
|
||||
read(const std::string & datafilename, int xColumn, int fColumn)
|
||||
{
|
||||
data.clear() ;
|
||||
ddata.clear() ;
|
||||
@@ -125,7 +125,7 @@ read(const std::string & datafilename, int xColumn, int fColumn)
|
||||
if (!datafile_fs) {
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
string linestring;
|
||||
while (!datafile_fs.eof()) {
|
||||
getline(datafile_fs, linestring);
|
||||
@@ -140,7 +140,7 @@ read(const std::string & datafilename, int xColumn, int fColumn)
|
||||
|
||||
stringstream strs(linestring);
|
||||
int columnindex = 0;
|
||||
std::vector<double> value;
|
||||
std::vector<double> value;
|
||||
if (linestring.size() > 0 && linestring.at(0) != '#') {
|
||||
while (!(strs.rdstate() & std::ios::failbit)) {
|
||||
double tmp;
|
||||
@@ -152,34 +152,34 @@ read(const std::string & datafilename, int xColumn, int fColumn)
|
||||
if (columnindex >= (max(xColumn, fColumn))) {
|
||||
data[value[xColumn-1]] = value[fColumn-1] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
datafile_fs.close();
|
||||
|
||||
|
||||
if (data.size() == 0) {
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
computeInternalFunctionData();
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
MonotCubicInterpolator::
|
||||
addPair(double newx, double newf) throw(const char*) {
|
||||
if (std::isnan(newx) || std::isinf(newx) || std::isnan(newf) || std::isinf(newf)) {
|
||||
throw("MonotCubicInterpolator: addPair() received inf/nan input.");
|
||||
}
|
||||
data[newx] = newf ;
|
||||
|
||||
|
||||
// In a critical application, we should only update the
|
||||
// internal function data for the offended interval,
|
||||
// internal function data for the offended interval,
|
||||
// not for all function values over again.
|
||||
computeInternalFunctionData();
|
||||
}
|
||||
|
||||
|
||||
double
|
||||
|
||||
double
|
||||
MonotCubicInterpolator::
|
||||
evaluate(double x) const throw(const char*){
|
||||
|
||||
@@ -189,7 +189,7 @@ evaluate(double x) const throw(const char*){
|
||||
|
||||
// xf becomes the first (xdata,fdata) pair where xdata >= x
|
||||
map<double,double>::const_iterator xf_iterator = data.lower_bound(x);
|
||||
|
||||
|
||||
// First check if we must extrapolate:
|
||||
if (xf_iterator == data.begin()) {
|
||||
if (data.begin()->first == x) { // Just on the interval limit
|
||||
@@ -204,36 +204,36 @@ evaluate(double x) const throw(const char*){
|
||||
// Constant extrapolation (!!)
|
||||
return data.rbegin()->second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Ok, we have x_min < x < x_max
|
||||
|
||||
pair<double,double> xf2 = *xf_iterator;
|
||||
pair<double,double> xf1 = *(--xf_iterator);
|
||||
// we now have: xf2.first > x
|
||||
|
||||
// we now have: xf2.first > x
|
||||
|
||||
// Linear interpolation if derivative data is not available:
|
||||
if (ddata.size() != data.size()) {
|
||||
double finterp = xf1.second +
|
||||
(xf2.second - xf1.second) / (xf2.first - xf1.first)
|
||||
double finterp = xf1.second +
|
||||
(xf2.second - xf1.second) / (xf2.first - xf1.first)
|
||||
* (x - xf1.first);
|
||||
return finterp;
|
||||
}
|
||||
else { // Do Cubic Hermite spline
|
||||
double t = (x - xf1.first)/(xf2.first - xf1.first); // t \in [0,1]
|
||||
double h = xf2.first - xf1.first;
|
||||
double finterp
|
||||
= xf1.second * H00(t)
|
||||
double finterp
|
||||
= xf1.second * H00(t)
|
||||
+ ddata[xf1.first] * H10(t) * h
|
||||
+ xf2.second * H01(t)
|
||||
+ xf2.second * H01(t)
|
||||
+ ddata[xf2.first] * H11(t) * h ;
|
||||
return finterp;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// double
|
||||
// double
|
||||
// MonotCubicInterpolator::
|
||||
// evaluate(double x, double& errorestimate_output) {
|
||||
// cout << "Error: errorestimate not implemented" << endl;
|
||||
@@ -241,12 +241,12 @@ evaluate(double x) const throw(const char*){
|
||||
// return x;
|
||||
// }
|
||||
|
||||
vector<double>
|
||||
vector<double>
|
||||
MonotCubicInterpolator::
|
||||
get_xVector() const
|
||||
get_xVector() const
|
||||
{
|
||||
map<double,double>::const_iterator xf_iterator = data.begin();
|
||||
|
||||
|
||||
vector<double> outputvector;
|
||||
outputvector.reserve(data.size());
|
||||
for (xf_iterator = data.begin(); xf_iterator != data.end(); ++xf_iterator) {
|
||||
@@ -258,11 +258,11 @@ get_xVector() const
|
||||
|
||||
vector<double>
|
||||
MonotCubicInterpolator::
|
||||
get_fVector() const
|
||||
get_fVector() const
|
||||
{
|
||||
|
||||
map<double,double>::const_iterator xf_iterator = data.begin();
|
||||
|
||||
|
||||
vector<double> outputvector;
|
||||
outputvector.reserve(data.size());
|
||||
for (xf_iterator = data.begin(); xf_iterator != data.end(); ++xf_iterator) {
|
||||
@@ -275,7 +275,7 @@ get_fVector() const
|
||||
|
||||
string
|
||||
MonotCubicInterpolator::
|
||||
toString() const
|
||||
toString() const
|
||||
{
|
||||
const int precision = 20;
|
||||
std::string dataString;
|
||||
@@ -295,9 +295,9 @@ toString() const
|
||||
dataStringStream << setprecision(precision) << it->second;
|
||||
dataStringStream << '\n';
|
||||
}
|
||||
|
||||
|
||||
return dataStringStream.str();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -306,31 +306,31 @@ MonotCubicInterpolator::
|
||||
getMissingX() const throw(const char*)
|
||||
{
|
||||
if( data.size() < 2) {
|
||||
throw("MonotCubicInterpolator::getMissingX() only one datapoint.");
|
||||
throw("MonotCubicInterpolator::getMissingX() only one datapoint.");
|
||||
}
|
||||
|
||||
|
||||
// Search for biggest difference value in function-datavalues:
|
||||
|
||||
|
||||
map<double,double>::const_iterator maxfDiffPair_iterator = data.begin();;
|
||||
double maxfDiffValue = 0;
|
||||
|
||||
|
||||
map<double,double>::const_iterator xf_iterator;
|
||||
map<double,double>::const_iterator xf_next_iterator;
|
||||
|
||||
|
||||
for (xf_iterator = data.begin(), xf_next_iterator = ++(data.begin());
|
||||
xf_next_iterator != data.end();
|
||||
xf_next_iterator != data.end();
|
||||
++xf_iterator, ++xf_next_iterator) {
|
||||
double absfDiff = fabs((double)(*xf_next_iterator).second
|
||||
double absfDiff = fabs((double)(*xf_next_iterator).second
|
||||
- (double)(*xf_iterator).second);
|
||||
if (absfDiff > maxfDiffValue) {
|
||||
maxfDiffPair_iterator = xf_iterator;
|
||||
maxfDiffValue = absfDiff;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double newXvalue = ((*maxfDiffPair_iterator).first + ((*(++maxfDiffPair_iterator)).first))/2;
|
||||
return make_pair(newXvalue, maxfDiffValue);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -382,33 +382,33 @@ getMinimumF() const throw(const char*) {
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
MonotCubicInterpolator::
|
||||
computeInternalFunctionData() const {
|
||||
|
||||
computeInternalFunctionData() const {
|
||||
|
||||
/* The contents of this function is meaningless if there is only one datapoint */
|
||||
if (data.size() <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* We do not check the caching flag if we are instructed
|
||||
to do this computation */
|
||||
|
||||
|
||||
/* We compute monotoneness and directions by assuming
|
||||
monotoneness, and setting to false if the function is not for
|
||||
some value */
|
||||
|
||||
|
||||
map<double,double>::const_iterator xf_iterator;
|
||||
map<double,double>::const_iterator xf_next_iterator;
|
||||
|
||||
|
||||
|
||||
|
||||
strictlyMonotone = true; // We assume this is true, and will set to false if not
|
||||
monotone = true;
|
||||
strictlyDecreasing = true;
|
||||
decreasing = true;
|
||||
strictlyIncreasing = true;
|
||||
increasing = true;
|
||||
|
||||
|
||||
// Increasing or decreasing??
|
||||
xf_iterator = data.begin();
|
||||
xf_next_iterator = ++(data.begin());
|
||||
@@ -419,12 +419,12 @@ computeInternalFunctionData() const {
|
||||
strictlyMonotone = false;
|
||||
strictlyIncreasing = false;
|
||||
strictlyDecreasing = false;
|
||||
|
||||
|
||||
++xf_iterator;
|
||||
++xf_next_iterator;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (xf_next_iterator != data.end()) {
|
||||
|
||||
if ( xf_iterator->second > xf_next_iterator->second) {
|
||||
@@ -465,27 +465,27 @@ computeInternalFunctionData() const {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// first two values must be equal if we get
|
||||
else {
|
||||
// first two values must be equal if we get
|
||||
// here, but that should have been taken care
|
||||
// of by the while loop above.
|
||||
throw("Programming logic error.") ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
computeSimpleDerivatives();
|
||||
|
||||
|
||||
|
||||
// If our input data is monotone, we can do monotone cubic
|
||||
// interpolation, so adjust the derivatives if so.
|
||||
//
|
||||
// If input data is not monotone, we should not touch
|
||||
// If input data is not monotone, we should not touch
|
||||
// the derivatives, as this code should reduce to a
|
||||
// standard cubic interpolation algorithm.
|
||||
if (monotone) {
|
||||
adjustDerivativesForMonotoneness();
|
||||
}
|
||||
|
||||
|
||||
strictlyMonotoneCached = true;
|
||||
monotoneCached = true;
|
||||
}
|
||||
@@ -495,7 +495,7 @@ computeInternalFunctionData() const {
|
||||
//
|
||||
// The notion of "flat" is determined by the input parameter "epsilon"
|
||||
// Values whose difference are less than epsilon are regarded as equal.
|
||||
//
|
||||
//
|
||||
// This is implemented to be able to obtain a strictly monotone
|
||||
// curve from a data set that is strictly monotone except at the
|
||||
// endpoints.
|
||||
@@ -505,7 +505,7 @@ computeInternalFunctionData() const {
|
||||
// (1,3), (2,3), (3,4), (4,5), (5,5), (6,5)
|
||||
// will become
|
||||
// (2,3), (3,4), (4,5)
|
||||
//
|
||||
//
|
||||
// Assumes at least 3 datapoints. If less than three, this function is a noop.
|
||||
void
|
||||
MonotCubicInterpolator::
|
||||
@@ -514,26 +514,26 @@ chopFlatEndpoints(const double epsilon) {
|
||||
if (getSize() < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
map<double,double>::iterator xf_iterator;
|
||||
map<double,double>::iterator xf_next_iterator;
|
||||
|
||||
// Clear flags:
|
||||
strictlyMonotoneCached = false;
|
||||
monotoneCached = false;
|
||||
|
||||
|
||||
// Chop left end:
|
||||
xf_iterator = data.begin();
|
||||
xf_next_iterator = ++(data.begin());
|
||||
// Erase data points that are similar to its right value from the left end.
|
||||
while ((xf_next_iterator != data.end()) &&
|
||||
while ((xf_next_iterator != data.end()) &&
|
||||
(fabs(xf_iterator->second - xf_next_iterator->second) < epsilon )) {
|
||||
xf_next_iterator++;
|
||||
data.erase(xf_iterator);
|
||||
xf_iterator++;
|
||||
}
|
||||
|
||||
xf_iterator = data.end();
|
||||
xf_iterator = data.end();
|
||||
xf_iterator--; // (data.end() points beyond the last element)
|
||||
xf_next_iterator = xf_iterator;
|
||||
xf_next_iterator--;
|
||||
@@ -544,15 +544,15 @@ chopFlatEndpoints(const double epsilon) {
|
||||
data.erase(xf_iterator);
|
||||
xf_iterator--;
|
||||
}
|
||||
|
||||
|
||||
// Finished chopping, so recompute function data:
|
||||
computeInternalFunctionData();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// If function is monotone, but not strictly monotone,
|
||||
// this function will remove datapoints from intervals
|
||||
// this function will remove datapoints from intervals
|
||||
// with zero derivative so that the curves become
|
||||
// strictly monotone.
|
||||
//
|
||||
@@ -561,44 +561,44 @@ chopFlatEndpoints(const double epsilon) {
|
||||
// (1,2), (2,3), (3,4), (4,4), (5,5), (6,6)
|
||||
// will become
|
||||
// (1,2), (2,3), (3,4), (5,5), (6,6)
|
||||
//
|
||||
//
|
||||
// Assumes at least two datapoints, if one or zero datapoint, this is a noop.
|
||||
//
|
||||
//
|
||||
//
|
||||
void
|
||||
MonotCubicInterpolator::
|
||||
shrinkFlatAreas(const double epsilon) {
|
||||
|
||||
|
||||
if (getSize() < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
map<double,double>::iterator xf_iterator;
|
||||
map<double,double>::iterator xf_next_iterator;
|
||||
|
||||
|
||||
|
||||
|
||||
// Nothing to do if we already are strictly monotone
|
||||
if (isStrictlyMonotone()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Refuse to change a curve that is not monotone.
|
||||
if (!isMonotone()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Clear flags, they are not to be trusted after we modify the
|
||||
// data
|
||||
strictlyMonotoneCached = false;
|
||||
monotoneCached = false;
|
||||
|
||||
|
||||
// Iterate through data values, if two data pairs
|
||||
// have equal values, delete one of the data pair.
|
||||
// Do not trust the source code on which data point is being
|
||||
// removed (x-values of equal y-points might be averaged in the future)
|
||||
xf_iterator = data.begin();
|
||||
xf_next_iterator = ++(data.begin());
|
||||
|
||||
|
||||
while (xf_next_iterator != data.end()) {
|
||||
//cout << xf_iterator->first << "," << xf_iterator->second << " " << xf_next_iterator->first << "," << xf_next_iterator->second << "\n";
|
||||
if (fabs(xf_iterator->second - xf_next_iterator->second) < epsilon ) {
|
||||
@@ -612,71 +612,71 @@ shrinkFlatAreas(const double epsilon) {
|
||||
xf_next_iterator++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
MonotCubicInterpolator::
|
||||
computeSimpleDerivatives() const {
|
||||
|
||||
|
||||
ddata.clear();
|
||||
|
||||
|
||||
// Do endpoints first:
|
||||
map<double,double>::const_iterator xf_prev_iterator;
|
||||
map<double,double>::const_iterator xf_iterator;
|
||||
map<double,double>::const_iterator xf_next_iterator;
|
||||
double diff;
|
||||
|
||||
|
||||
// Leftmost interval:
|
||||
xf_iterator = data.begin();
|
||||
xf_next_iterator = ++(data.begin());
|
||||
diff =
|
||||
diff =
|
||||
(xf_next_iterator->second - xf_iterator->second) /
|
||||
(xf_next_iterator->first - xf_iterator->first);
|
||||
ddata[xf_iterator->first] = diff ;
|
||||
|
||||
|
||||
// Rightmost interval:
|
||||
xf_iterator = --(--(data.end()));
|
||||
xf_next_iterator = --(data.end());
|
||||
diff =
|
||||
diff =
|
||||
(xf_next_iterator->second - xf_iterator->second) /
|
||||
(xf_next_iterator->first - xf_iterator->first);
|
||||
ddata[xf_next_iterator->first] = diff ;
|
||||
|
||||
|
||||
// If we have more than two intervals, loop over internal points:
|
||||
if (data.size() > 2) {
|
||||
|
||||
|
||||
map<double,double>::const_iterator intpoint;
|
||||
for (intpoint = ++data.begin(); intpoint != --data.end(); ++intpoint) {
|
||||
/*
|
||||
diff = (f2 - f1)/(x2-x1)/w + (f3-f1)/(x3-x2)/2
|
||||
|
||||
diff = (f2 - f1)/(x2-x1)/w + (f3-f1)/(x3-x2)/2
|
||||
|
||||
average of the forward and backward difference.
|
||||
Weights are equal, should we weigh with h_i?
|
||||
*/
|
||||
|
||||
|
||||
map<double,double>::const_iterator lastpoint = intpoint; --lastpoint;
|
||||
map<double,double>::const_iterator nextpoint = intpoint; ++nextpoint;
|
||||
|
||||
|
||||
diff = (nextpoint->second - intpoint->second)/
|
||||
(2*(nextpoint->first - intpoint->first))
|
||||
(2*(nextpoint->first - intpoint->first))
|
||||
+
|
||||
(intpoint->second - lastpoint->second) /
|
||||
(2*(intpoint->first - lastpoint->first));
|
||||
|
||||
ddata[intpoint->first] = diff ;
|
||||
ddata[intpoint->first] = diff ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
MonotCubicInterpolator::
|
||||
adjustDerivativesForMonotoneness() const {
|
||||
map<double,double>::const_iterator point, dpoint;
|
||||
|
||||
|
||||
/* Loop over all intervals, ie. loop over all points and look
|
||||
at the interval to the right of the point */
|
||||
for (point = data.begin(), dpoint = ddata.begin();
|
||||
@@ -685,8 +685,8 @@ adjustDerivativesForMonotoneness() const {
|
||||
map<double,double>::const_iterator nextpoint, nextdpoint;
|
||||
nextpoint = point; ++nextpoint;
|
||||
nextdpoint = dpoint; ++nextdpoint;
|
||||
|
||||
double delta =
|
||||
|
||||
double delta =
|
||||
(nextpoint->second - point->second) /
|
||||
(nextpoint->first - point->first);
|
||||
if (fabs(delta) < 1e-14) {
|
||||
@@ -695,25 +695,25 @@ adjustDerivativesForMonotoneness() const {
|
||||
} else {
|
||||
double alpha = ddata[point->first] / delta;
|
||||
double beta = ddata[nextpoint->first] / delta;
|
||||
|
||||
|
||||
if (! isMonotoneCoeff(alpha, beta)) {
|
||||
double tau = 3/sqrt(alpha*alpha + beta*beta);
|
||||
|
||||
|
||||
ddata[point->first] = tau*alpha*delta;
|
||||
ddata[nextpoint->first] = tau*beta*delta;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
MonotCubicInterpolator::
|
||||
scaleData(double factor) {
|
||||
map<double,double>::iterator it , itd ;
|
||||
@@ -725,8 +725,8 @@ scaleData(double factor) {
|
||||
} else {
|
||||
for (it = data.begin() ; it != data.end() ; ++it ) {
|
||||
it->second *= factor ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,17 +10,17 @@
|
||||
/*
|
||||
MonotCubicInterpolator
|
||||
Copyright (C) 2006 Statoil ASA
|
||||
|
||||
|
||||
This program 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 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
@@ -32,21 +32,21 @@ namespace Opm
|
||||
/**
|
||||
Class to represent a one-dimensional function f with single-valued
|
||||
argument x. The function is represented by a table of function
|
||||
values. Interpolation between table values is cubic and monotonicity
|
||||
values. Interpolation between table values is cubic and monotonicity
|
||||
preserving if input values are monotonous.
|
||||
|
||||
Outside x_min and x_max, the class will extrapolate using the
|
||||
constant f(x_min) or f(x_max).
|
||||
|
||||
|
||||
Extra functionality:
|
||||
- Can return (x_1+x_2)/2 where x_1 and x_2 are such that
|
||||
abs(f(x_1) - f(x_2)) is maximized. This is used to determine where
|
||||
- Can return (x_1+x_2)/2 where x_1 and x_2 are such that
|
||||
abs(f(x_1) - f(x_2)) is maximized. This is used to determine where
|
||||
one should calculate a new value for increased accuracy in the
|
||||
current function
|
||||
|
||||
Monotonicity preserving cubic interpolation algorithm is taken
|
||||
from Fritsch and Carlson, "Monotone piecewise cubic interpolation",
|
||||
SIAM J. Numer. Anal. 17, 238--246, no. 2,
|
||||
Monotonicity preserving cubic interpolation algorithm is taken
|
||||
from Fritsch and Carlson, "Monotone piecewise cubic interpolation",
|
||||
SIAM J. Numer. Anal. 17, 238--246, no. 2,
|
||||
|
||||
$Id$
|
||||
|
||||
@@ -61,9 +61,9 @@ namespace Opm
|
||||
|
||||
class MonotCubicInterpolator {
|
||||
public:
|
||||
|
||||
|
||||
/**
|
||||
@param datafilename A datafile with the x values and the corresponding f(x) values
|
||||
@param datafilename A datafile with the x values and the corresponding f(x) values
|
||||
|
||||
Accepts a filename as input and parses this file for
|
||||
two-column floating point data, interpreting the data as
|
||||
@@ -71,36 +71,36 @@ class MonotCubicInterpolator {
|
||||
|
||||
Ignores all lines not conforming to \<whitespace\>\<float\>\<whitespace\>\<float\>\<whatever\>\<newline\>
|
||||
*/
|
||||
MonotCubicInterpolator(const std::string & datafilename) throw (const char*)
|
||||
MonotCubicInterpolator(const std::string & datafilename) throw (const char*)
|
||||
{
|
||||
if (!read(datafilename)) {
|
||||
throw("Unable to constuct MonotCubicInterpolator from file.") ;
|
||||
if (!read(datafilename)) {
|
||||
throw("Unable to constuct MonotCubicInterpolator from file.") ;
|
||||
} ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@param datafilename A datafile with the x values and the corresponding f(x) values
|
||||
@param datafilename A datafile with the x values and the corresponding f(x) values
|
||||
|
||||
Accepts a filename as input and parses this file for
|
||||
two-column floating point data, interpreting the data as
|
||||
representing function values x and f(x).
|
||||
|
||||
Ignores all lines not conforming to \<whitespace\>\<float\>\<whitespace\>\<float\>\<whatever\>\<newline\>
|
||||
|
||||
|
||||
All commas in the file will be treated as spaces when parsing.
|
||||
|
||||
*/
|
||||
|
||||
MonotCubicInterpolator(const char* datafilename) throw (const char*)
|
||||
|
||||
MonotCubicInterpolator(const char* datafilename) throw (const char*)
|
||||
{
|
||||
if (!read(std::string(datafilename))) {
|
||||
throw("Unable to constuct MonotCubicInterpolator from file.") ;
|
||||
if (!read(std::string(datafilename))) {
|
||||
throw("Unable to constuct MonotCubicInterpolator from file.") ;
|
||||
} ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
@param datafilename data file
|
||||
@param XColumn x values
|
||||
@param fColumn f values
|
||||
@@ -108,14 +108,14 @@ class MonotCubicInterpolator {
|
||||
Accepts a filename as input, and parses the chosen columns in
|
||||
that file.
|
||||
*/
|
||||
MonotCubicInterpolator(const char* datafilename, int xColumn, int fColumn) throw (const char*)
|
||||
MonotCubicInterpolator(const char* datafilename, int xColumn, int fColumn) throw (const char*)
|
||||
{
|
||||
if (!read(std::string(datafilename),xColumn,fColumn)) {
|
||||
throw("Unable to constuct MonotCubicInterpolator from file.") ;
|
||||
if (!read(std::string(datafilename),xColumn,fColumn)) {
|
||||
throw("Unable to constuct MonotCubicInterpolator from file.") ;
|
||||
} ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
@param datafilename data file
|
||||
@param XColumn x values
|
||||
@param fColumn f values
|
||||
@@ -123,13 +123,13 @@ class MonotCubicInterpolator {
|
||||
Accepts a filename as input, and parses the chosen columns in
|
||||
that file.
|
||||
*/
|
||||
MonotCubicInterpolator(const std::string & datafilename, int xColumn, int fColumn) throw (const char*)
|
||||
MonotCubicInterpolator(const std::string & datafilename, int xColumn, int fColumn) throw (const char*)
|
||||
{
|
||||
if (!read(datafilename,xColumn,fColumn)) {
|
||||
throw("Unable to constuct MonotCubicInterpolator from file.") ;
|
||||
if (!read(datafilename,xColumn,fColumn)) {
|
||||
throw("Unable to constuct MonotCubicInterpolator from file.") ;
|
||||
} ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@param x vector of x values
|
||||
@param f vector of corresponding f values
|
||||
@@ -138,12 +138,12 @@ class MonotCubicInterpolator {
|
||||
the interpolation object. First vector is the x-values, the
|
||||
second vector is the function values
|
||||
*/
|
||||
MonotCubicInterpolator(const std::vector<double> & x ,
|
||||
MonotCubicInterpolator(const std::vector<double> & x ,
|
||||
const std::vector<double> & f);
|
||||
|
||||
|
||||
/**
|
||||
No input, an empty function object is created.
|
||||
|
||||
|
||||
This object must be treated with care until
|
||||
populated.
|
||||
*/
|
||||
@@ -152,7 +152,7 @@ class MonotCubicInterpolator {
|
||||
|
||||
|
||||
/**
|
||||
@param datafilename A datafile with the x values and the corresponding f(x) values
|
||||
@param datafilename A datafile with the x values and the corresponding f(x) values
|
||||
|
||||
Accepts a filename as input and parses this file for
|
||||
two-column floating point data, interpreting the data as
|
||||
@@ -167,8 +167,8 @@ class MonotCubicInterpolator {
|
||||
bool read(const std::string & datafilename) {
|
||||
return read(datafilename,1,2) ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
@param datafilename data file
|
||||
@param XColumn x values
|
||||
@param fColumn f values
|
||||
@@ -176,60 +176,60 @@ class MonotCubicInterpolator {
|
||||
Accepts a filename as input, and parses the chosen columns in
|
||||
that file.
|
||||
*/
|
||||
bool read(const std::string & datafilename, int xColumn, int fColumn) ;
|
||||
bool read(const std::string & datafilename, int xColumn, int fColumn) ;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@param x x value
|
||||
|
||||
Returns f(x) for given x (input). Interpolates (monotone cubic
|
||||
Returns f(x) for given x (input). Interpolates (monotone cubic
|
||||
or linearly) if necessary.
|
||||
|
||||
|
||||
Extrapolates using the constants f(x_min) or f(x_max) if
|
||||
input x is outside (x_min, x_max)
|
||||
|
||||
@return f(x) for a given x
|
||||
*/
|
||||
double operator () (double x) const { return evaluate(x) ; }
|
||||
|
||||
|
||||
/**
|
||||
@param x x value
|
||||
|
||||
Returns f(x) for given x (input). Interpolates (monotone cubic
|
||||
Returns f(x) for given x (input). Interpolates (monotone cubic
|
||||
or linearly) if necessary.
|
||||
|
||||
|
||||
Extrapolates using the constants f(x_min) or f(x_max) if
|
||||
input x is outside (x_min, x_max)
|
||||
|
||||
@return f(x) for a given x
|
||||
*/
|
||||
double evaluate(double x) const throw(const char*);
|
||||
|
||||
|
||||
/**
|
||||
@param x x value
|
||||
@param errorestimate_output
|
||||
@param errorestimate_output
|
||||
|
||||
Returns f(x) and an error estimate for given x (input).
|
||||
|
||||
|
||||
Interpolates (linearly) if necessary.
|
||||
|
||||
|
||||
Throws an exception if extrapolation would be necessary for
|
||||
evaluation. We do not want to do extrapolation (yet).
|
||||
|
||||
|
||||
The error estimate for x1 < x < x2 is
|
||||
(x2 - x1)^2/8 * f''(x) where f''(x) is evaluated using
|
||||
the stencil (1 -2 1) using either (x0, x1, x2) or (x1, x2, x3);
|
||||
|
||||
|
||||
Throws an exception if the table contains only two x-values.
|
||||
|
||||
|
||||
NOT IMPLEMENTED YET!
|
||||
*/
|
||||
double evaluate(double x, double & errorestimate_output ) const ;
|
||||
|
||||
double evaluate(double x, double & errorestimate_output ) const ;
|
||||
|
||||
/**
|
||||
Minimum x-value, returns both x and f in a pair.
|
||||
|
||||
|
||||
@return minimum x value
|
||||
@return f(minimum x value)
|
||||
*/
|
||||
@@ -237,10 +237,10 @@ class MonotCubicInterpolator {
|
||||
// Easy since the data is sorted on x:
|
||||
return *data.begin();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Maximum x-value, returns both x and f in a pair.
|
||||
|
||||
|
||||
@return maximum x value
|
||||
@return f(maximum x value)
|
||||
*/
|
||||
@@ -248,10 +248,10 @@ class MonotCubicInterpolator {
|
||||
// Easy since the data is sorted on x:
|
||||
return *data.rbegin();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Maximum f-value, returns both x and f in a pair.
|
||||
|
||||
|
||||
@return x value corresponding to maximum f value
|
||||
@return maximum f value
|
||||
*/
|
||||
@@ -259,39 +259,39 @@ class MonotCubicInterpolator {
|
||||
|
||||
/**
|
||||
Minimum f-value, returns both x and f in a pair
|
||||
|
||||
|
||||
@return x value corresponding to minimal f value
|
||||
@return minimum f value
|
||||
*/
|
||||
std::pair<double,double> getMinimumF() const throw(const char*) ;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Provide a copy of the x-data as a vector
|
||||
|
||||
|
||||
Unspecified order, but corresponds to get_fVector.
|
||||
|
||||
|
||||
@return x values as a vector
|
||||
*/
|
||||
std::vector<double> get_xVector() const ;
|
||||
|
||||
|
||||
/**
|
||||
Provide a copy of tghe function data as a vector
|
||||
|
||||
|
||||
Unspecified order, but corresponds to get_xVector
|
||||
|
||||
@return f values as a vector
|
||||
|
||||
|
||||
*/
|
||||
std::vector<double> get_fVector() const ;
|
||||
|
||||
|
||||
/**
|
||||
@param factor Scaling constant
|
||||
|
||||
Scale all the function value data by a constant
|
||||
*/
|
||||
void scaleData(double factor);
|
||||
|
||||
|
||||
/**
|
||||
Determines if the current function-value-data is strictly
|
||||
monotone. This is a utility function for outsiders if they want
|
||||
@@ -300,7 +300,7 @@ class MonotCubicInterpolator {
|
||||
@return True if f(x) is strictly monotone, else False
|
||||
*/
|
||||
bool isStrictlyMonotone() {
|
||||
|
||||
|
||||
/* Use cached value if it can be trusted */
|
||||
if (strictlyMonotoneCached) {
|
||||
return strictlyMonotone;
|
||||
@@ -313,7 +313,7 @@ class MonotCubicInterpolator {
|
||||
|
||||
/**
|
||||
Determines if the current function-value-data is monotone.
|
||||
|
||||
|
||||
@return True if f(x) is monotone, else False
|
||||
*/
|
||||
bool isMonotone() const {
|
||||
@@ -333,7 +333,7 @@ class MonotCubicInterpolator {
|
||||
@return True if f(x) is strictly increasing, else False
|
||||
*/
|
||||
bool isStrictlyIncreasing() {
|
||||
|
||||
|
||||
/* Use cached value if it can be trusted */
|
||||
if (strictlyMonotoneCached) {
|
||||
return (strictlyMonotone && strictlyIncreasing);
|
||||
@@ -346,7 +346,7 @@ class MonotCubicInterpolator {
|
||||
|
||||
/**
|
||||
Determines if the current function-value-data is monotone and increasing.
|
||||
|
||||
|
||||
@return True if f(x) is monotone and increasing, else False
|
||||
*/
|
||||
bool isMonotoneIncreasing() const {
|
||||
@@ -366,7 +366,7 @@ class MonotCubicInterpolator {
|
||||
@return True if f(x) is strictly decreasing, else False
|
||||
*/
|
||||
bool isStrictlyDecreasing() {
|
||||
|
||||
|
||||
/* Use cached value if it can be trusted */
|
||||
if (strictlyMonotoneCached) {
|
||||
return (strictlyMonotone && strictlyDecreasing);
|
||||
@@ -379,7 +379,7 @@ class MonotCubicInterpolator {
|
||||
|
||||
/**
|
||||
Determines if the current function-value-data is monotone and decreasing
|
||||
|
||||
|
||||
@return True if f(x) is monotone and decreasing, else False
|
||||
*/
|
||||
bool isMonotoneDecreasing() const {
|
||||
@@ -391,9 +391,9 @@ class MonotCubicInterpolator {
|
||||
return (monotone && decreasing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@param newx New x point
|
||||
@param newf New f(x) point
|
||||
@@ -408,12 +408,12 @@ class MonotCubicInterpolator {
|
||||
|
||||
*/
|
||||
void addPair(double newx, double newf) throw(const char*);
|
||||
|
||||
|
||||
/**
|
||||
Returns an x-value that is believed to yield the best
|
||||
improvement in global accuracy for the interpolation if
|
||||
computed.
|
||||
|
||||
|
||||
Searches for the largest jump in f-values, and returns a x
|
||||
value being the average of the two x-values representing the
|
||||
f-value-jump.
|
||||
@@ -422,14 +422,14 @@ class MonotCubicInterpolator {
|
||||
@return Maximal difference
|
||||
*/
|
||||
std::pair<double,double> getMissingX() const throw(const char*) ;
|
||||
|
||||
|
||||
/**
|
||||
Constructs a string containing the data in a table
|
||||
Constructs a string containing the data in a table
|
||||
|
||||
@return a string containing the data in a table
|
||||
*/
|
||||
std::string toString() const;
|
||||
|
||||
|
||||
/**
|
||||
@return Number of datapoint pairs in this object
|
||||
*/
|
||||
@@ -440,7 +440,7 @@ class MonotCubicInterpolator {
|
||||
/**
|
||||
Checks if the function curve is flat at the endpoints, chop off
|
||||
endpoint data points if that is the case.
|
||||
|
||||
|
||||
The notion of "flat" is determined by the input parameter "epsilon"
|
||||
Values whose difference are less than epsilon are regarded as equal.
|
||||
|
||||
@@ -460,7 +460,7 @@ class MonotCubicInterpolator {
|
||||
|
||||
/**
|
||||
Wrapper function for chopFlatEndpoints(const double)
|
||||
providing a default epsilon parameter
|
||||
providing a default epsilon parameter
|
||||
*/
|
||||
void chopFlatEndpoints() {
|
||||
chopFlatEndpoints(1e-14);
|
||||
@@ -468,7 +468,7 @@ class MonotCubicInterpolator {
|
||||
|
||||
/**
|
||||
If function is monotone, but not strictly monotone,
|
||||
this function will remove datapoints from intervals
|
||||
this function will remove datapoints from intervals
|
||||
with zero derivative so that the curve become
|
||||
strictly monotone.
|
||||
|
||||
@@ -477,14 +477,14 @@ class MonotCubicInterpolator {
|
||||
(1,2), (2,3), (3,4), (4,4), (5,5), (6,6)
|
||||
will become
|
||||
(1,2), (2,3), (3,4), (5,5), (6,6)
|
||||
|
||||
|
||||
Assumes at least two datapoints, if one or zero datapoint, this is a noop.
|
||||
*/
|
||||
void shrinkFlatAreas(const double);
|
||||
|
||||
/**
|
||||
Wrapper function for shrinkFlatAreas(const double)
|
||||
providing a default epsilon parameter
|
||||
providing a default epsilon parameter
|
||||
*/
|
||||
void shrinkFlatAreas() {
|
||||
shrinkFlatAreas(1e-14);
|
||||
@@ -493,17 +493,17 @@ class MonotCubicInterpolator {
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
// Data structure to store x- and f-values
|
||||
std::map<double, double> data;
|
||||
|
||||
|
||||
// Data structure to store x- and d-values
|
||||
mutable std::map<double, double> ddata;
|
||||
|
||||
|
||||
mutable std::map<double, double> ddata;
|
||||
|
||||
|
||||
// Storage containers for precomputed interpolation data
|
||||
// std::vector<double> dvalues; // derivatives in Hermite interpolation.
|
||||
|
||||
|
||||
// Flag to determine whether the boolean strictlyMonotone can be
|
||||
// trusted.
|
||||
mutable bool strictlyMonotoneCached;
|
||||
@@ -517,13 +517,13 @@ private:
|
||||
mutable bool strictlyIncreasing;
|
||||
mutable bool decreasing;
|
||||
mutable bool increasing;
|
||||
|
||||
|
||||
|
||||
/* Hermite basis functions, t \in [0,1] ,
|
||||
notation from:
|
||||
http://en.wikipedia.org/w/index.php?title=Cubic_Hermite_spline&oldid=84495502
|
||||
*/
|
||||
|
||||
|
||||
double H00(double t) const {
|
||||
return 2*t*t*t - 3*t*t + 1;
|
||||
}
|
||||
@@ -536,35 +536,35 @@ private:
|
||||
double H11(double t) const {
|
||||
return t*t*t - t*t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void computeInternalFunctionData() const ;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
Computes initial derivative values using centered (second order) difference
|
||||
for internal datapoints, and one-sided derivative for endpoints
|
||||
|
||||
|
||||
The internal datastructure map<double,double> ddata is populated by this method.
|
||||
*/
|
||||
|
||||
|
||||
void computeSimpleDerivatives() const ;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Adjusts the derivative values (ddata) so that we can guarantee that
|
||||
the resulting piecewise Hermite polymial is monotone. This is
|
||||
done according to the algorithm of Fritsch and Carlsson 1980,
|
||||
done according to the algorithm of Fritsch and Carlsson 1980,
|
||||
see Section 4, especially the two last lines.
|
||||
*/
|
||||
void adjustDerivativesForMonotoneness() const ;
|
||||
|
||||
/**
|
||||
Checks if the coefficient alpha and beta is in
|
||||
the region that guarantees monotoneness of the
|
||||
derivative values they represent
|
||||
|
||||
See Fritsch and Carlson 1980, Lemma 2,
|
||||
alternatively Step 5 in Wikipedia's article
|
||||
/**
|
||||
Checks if the coefficient alpha and beta is in
|
||||
the region that guarantees monotoneness of the
|
||||
derivative values they represent
|
||||
|
||||
See Fritsch and Carlson 1980, Lemma 2,
|
||||
alternatively Step 5 in Wikipedia's article
|
||||
on Monotone cubic interpolation.
|
||||
*/
|
||||
bool isMonotoneCoeff(double alpha, double beta) const {
|
||||
@@ -574,8 +574,8 @@ private:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Opm
|
||||
int ix2 = ix1 + 1;
|
||||
return (yv[ix2] - yv[ix1])/(xv[ix2] - xv[ix1])*(x - xv[ix1]) + yv[ix1];
|
||||
}
|
||||
|
||||
|
||||
inline double linearInterpolation(const std::vector<double>& xv,
|
||||
const std::vector<double>& yv,
|
||||
double x, int& ix1)
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace Opm
|
||||
const std::vector<int>& cells,
|
||||
const std::vector<double>& s ,
|
||||
std::vector<double>& pmobc);
|
||||
|
||||
|
||||
|
||||
/// Computes the fractional flow for each cell in the cells argument
|
||||
/// @param[in] props rock and fluid properties
|
||||
@@ -202,42 +202,42 @@ namespace Opm
|
||||
/// For this to be valid, the wells must be all rate-controlled and
|
||||
/// single-perforation.
|
||||
void wellsToSrc(const Wells& wells, const int num_cells, std::vector<double>& src);
|
||||
|
||||
|
||||
/// Computes the WDP for each well.
|
||||
/// \param[in] wells Wells that need their wdp calculated.
|
||||
/// \param[in] grid The associated grid to make cell lookups.
|
||||
/// \param[in] saturations A vector of weights for each cell for each phase
|
||||
/// in the grid (or well, see per_grid_cell parameter). So for cell i,
|
||||
/// \param[in] saturations A vector of weights for each cell for each phase
|
||||
/// in the grid (or well, see per_grid_cell parameter). So for cell i,
|
||||
/// saturations[i*densities.size() + p] should give the weight
|
||||
/// of phase p in cell i.
|
||||
/// \param[in] densities Density for each phase.
|
||||
/// \param[out] wdp Will contain, for each well, the wdp of the well.
|
||||
/// \param[in] per_grid_cell Whether or not the saturations are per grid cell or per
|
||||
/// \param[in] per_grid_cell Whether or not the saturations are per grid cell or per
|
||||
/// well cell.
|
||||
void computeWDP(const Wells& wells, const UnstructuredGrid& grid, const std::vector<double>& saturations,
|
||||
const double* densities, const double gravity, const bool per_grid_cell,
|
||||
std::vector<double>& wdp);
|
||||
|
||||
/// Computes (sums) the flow rate for each well.
|
||||
|
||||
/// Computes (sums) the flow rate for each well.
|
||||
/// \param[in] wells The wells for which the flow rate should be computed.
|
||||
/// \param[in] flow_rates_per_cell Flow rates per well cells. Should ordered the same way as
|
||||
/// \param[in] flow_rates_per_cell Flow rates per well cells. Should ordered the same way as
|
||||
/// wells.
|
||||
/// \param[out] flow_rates_per_well Will contain the summed up flow_rates for each well.
|
||||
void computeFlowRatePerWell(const Wells& wells, const std::vector<double>& flow_rates_per_cell,
|
||||
std::vector<double>& flow_rates_per_well);
|
||||
|
||||
|
||||
/// Computes the phase flow rate per well
|
||||
/// \param[in] wells The wells for which the flow rate should be computed
|
||||
/// \param[in] flow_rates_per_well_cell The total flow rate for each cell (ordered the same
|
||||
/// way as the wells struct
|
||||
/// \param[in] fractional_flows the fractional flow for each cell in each well
|
||||
/// \param[out] phase_flow_per_well Will contain the phase flow per well
|
||||
void computePhaseFlowRatesPerWell(const Wells& wells,
|
||||
void computePhaseFlowRatesPerWell(const Wells& wells,
|
||||
const std::vector<double>& flow_rates_per_well_cell,
|
||||
const std::vector<double>& fractional_flows,
|
||||
std::vector<double>& phase_flow_per_well);
|
||||
|
||||
|
||||
|
||||
|
||||
/// Encapsulates the watercut curves.
|
||||
class Watercut
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Opm {
|
||||
class Parameter : public ParameterMapItem {
|
||||
public:
|
||||
/// @brief
|
||||
/// @todo Doc me!
|
||||
/// @todo Doc me!
|
||||
virtual ~Parameter() {}
|
||||
/// @brief
|
||||
/// @todo Doc me!
|
||||
|
||||
@@ -224,7 +224,7 @@ class TiXmlString
|
||||
// to the normal allocation, although use an 'int' for systems
|
||||
// that are overly picky about structure alignment.
|
||||
const size_type bytesNeeded = sizeof(Rep) + cap;
|
||||
const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int );
|
||||
const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int );
|
||||
rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] );
|
||||
|
||||
rep_->str[ rep_->size = sz ] = '\0';
|
||||
|
||||
@@ -58,7 +58,7 @@ void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString )
|
||||
{
|
||||
unsigned char c = (unsigned char) str[i];
|
||||
|
||||
if ( c == '&'
|
||||
if ( c == '&'
|
||||
&& i < ( (int)str.length() - 2 )
|
||||
&& str[i+1] == '#'
|
||||
&& str[i+2] == 'x' )
|
||||
@@ -111,12 +111,12 @@ void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString )
|
||||
// Easy pass at non-alpha/numeric/symbol
|
||||
// Below 32 is symbolic.
|
||||
char buf[ 32 ];
|
||||
|
||||
#if defined(TIXML_SNPRINTF)
|
||||
|
||||
#if defined(TIXML_SNPRINTF)
|
||||
TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) );
|
||||
#else
|
||||
sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//*ME: warning C4267: convert 'size_t' to 'int'
|
||||
//*ME: Int-Cast to make compiler happy ...
|
||||
@@ -155,14 +155,14 @@ TiXmlNode::~TiXmlNode()
|
||||
temp = node;
|
||||
node = node->next;
|
||||
delete temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TiXmlNode::CopyTo( TiXmlNode* target ) const
|
||||
{
|
||||
target->SetValue (value.c_str() );
|
||||
target->userData = userData;
|
||||
target->userData = userData;
|
||||
target->location = location;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ void TiXmlNode::Clear()
|
||||
temp = node;
|
||||
node = node->next;
|
||||
delete temp;
|
||||
}
|
||||
}
|
||||
|
||||
firstChild = 0;
|
||||
lastChild = 0;
|
||||
@@ -192,7 +192,7 @@ TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
|
||||
if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT )
|
||||
{
|
||||
delete node;
|
||||
if ( GetDocument() )
|
||||
if ( GetDocument() )
|
||||
GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||
return 0;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
|
||||
{
|
||||
if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
|
||||
{
|
||||
if ( GetDocument() )
|
||||
if ( GetDocument() )
|
||||
GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||
return 0;
|
||||
}
|
||||
@@ -229,13 +229,13 @@ TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
|
||||
|
||||
|
||||
TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis )
|
||||
{
|
||||
{
|
||||
if ( !beforeThis || beforeThis->parent != this ) {
|
||||
return 0;
|
||||
}
|
||||
if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
|
||||
{
|
||||
if ( GetDocument() )
|
||||
if ( GetDocument() )
|
||||
GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||
return 0;
|
||||
}
|
||||
@@ -268,7 +268,7 @@ TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& a
|
||||
}
|
||||
if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
|
||||
{
|
||||
if ( GetDocument() )
|
||||
if ( GetDocument() )
|
||||
GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||
return 0;
|
||||
}
|
||||
@@ -305,7 +305,7 @@ TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& wit
|
||||
if ( withThis.ToDocument() ) {
|
||||
// A document can never be a child. Thanks to Noam.
|
||||
TiXmlDocument* document = GetDocument();
|
||||
if ( document )
|
||||
if ( document )
|
||||
document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||
return 0;
|
||||
}
|
||||
@@ -340,7 +340,7 @@ bool TiXmlNode::RemoveChild( TiXmlNode* removeThis )
|
||||
}
|
||||
|
||||
if ( removeThis->parent != this )
|
||||
{
|
||||
{
|
||||
assert( 0 );
|
||||
return false;
|
||||
}
|
||||
@@ -411,7 +411,7 @@ const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode*
|
||||
}
|
||||
|
||||
|
||||
const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const
|
||||
const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const
|
||||
{
|
||||
const TiXmlNode* node;
|
||||
for ( node = next; node; node = node->next )
|
||||
@@ -532,7 +532,7 @@ TiXmlElement::TiXmlElement (const char * _value)
|
||||
|
||||
|
||||
#ifdef TIXML_USE_STL
|
||||
TiXmlElement::TiXmlElement( const std::string& _value )
|
||||
TiXmlElement::TiXmlElement( const std::string& _value )
|
||||
: TiXmlNode( TiXmlNode::TINYXML_ELEMENT )
|
||||
{
|
||||
firstChild = lastChild = 0;
|
||||
@@ -545,7 +545,7 @@ TiXmlElement::TiXmlElement( const TiXmlElement& copy)
|
||||
: TiXmlNode( TiXmlNode::TINYXML_ELEMENT )
|
||||
{
|
||||
firstChild = lastChild = 0;
|
||||
copy.CopyTo( this );
|
||||
copy.CopyTo( this );
|
||||
}
|
||||
|
||||
|
||||
@@ -686,18 +686,18 @@ int TiXmlElement::QueryBoolAttribute( const char* name, bool* bval ) const
|
||||
const TiXmlAttribute* node = attributeSet.Find( name );
|
||||
if ( !node )
|
||||
return TIXML_NO_ATTRIBUTE;
|
||||
|
||||
|
||||
int result = TIXML_WRONG_TYPE;
|
||||
if ( StringEqual( node->Value(), "true", true, TIXML_ENCODING_UNKNOWN )
|
||||
|| StringEqual( node->Value(), "yes", true, TIXML_ENCODING_UNKNOWN )
|
||||
|| StringEqual( node->Value(), "1", true, TIXML_ENCODING_UNKNOWN ) )
|
||||
if ( StringEqual( node->Value(), "true", true, TIXML_ENCODING_UNKNOWN )
|
||||
|| StringEqual( node->Value(), "yes", true, TIXML_ENCODING_UNKNOWN )
|
||||
|| StringEqual( node->Value(), "1", true, TIXML_ENCODING_UNKNOWN ) )
|
||||
{
|
||||
*bval = true;
|
||||
result = TIXML_SUCCESS;
|
||||
}
|
||||
else if ( StringEqual( node->Value(), "false", true, TIXML_ENCODING_UNKNOWN )
|
||||
|| StringEqual( node->Value(), "no", true, TIXML_ENCODING_UNKNOWN )
|
||||
|| StringEqual( node->Value(), "0", true, TIXML_ENCODING_UNKNOWN ) )
|
||||
else if ( StringEqual( node->Value(), "false", true, TIXML_ENCODING_UNKNOWN )
|
||||
|| StringEqual( node->Value(), "no", true, TIXML_ENCODING_UNKNOWN )
|
||||
|| StringEqual( node->Value(), "0", true, TIXML_ENCODING_UNKNOWN ) )
|
||||
{
|
||||
*bval = false;
|
||||
result = TIXML_SUCCESS;
|
||||
@@ -739,7 +739,7 @@ int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval )
|
||||
|
||||
|
||||
void TiXmlElement::SetAttribute( const char * name, int val )
|
||||
{
|
||||
{
|
||||
TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
|
||||
if ( attrib ) {
|
||||
attrib->SetIntValue( val );
|
||||
@@ -749,7 +749,7 @@ void TiXmlElement::SetAttribute( const char * name, int val )
|
||||
|
||||
#ifdef TIXML_USE_STL
|
||||
void TiXmlElement::SetAttribute( const std::string& name, int val )
|
||||
{
|
||||
{
|
||||
TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
|
||||
if ( attrib ) {
|
||||
attrib->SetIntValue( val );
|
||||
@@ -759,7 +759,7 @@ void TiXmlElement::SetAttribute( const std::string& name, int val )
|
||||
|
||||
|
||||
void TiXmlElement::SetDoubleAttribute( const char * name, double val )
|
||||
{
|
||||
{
|
||||
TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
|
||||
if ( attrib ) {
|
||||
attrib->SetDoubleValue( val );
|
||||
@@ -769,13 +769,13 @@ void TiXmlElement::SetDoubleAttribute( const char * name, double val )
|
||||
|
||||
#ifdef TIXML_USE_STL
|
||||
void TiXmlElement::SetDoubleAttribute( const std::string& name, double val )
|
||||
{
|
||||
{
|
||||
TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
|
||||
if ( attrib ) {
|
||||
attrib->SetDoubleValue( val );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
void TiXmlElement::SetAttribute( const char * cname, const char * cvalue )
|
||||
@@ -856,7 +856,7 @@ void TiXmlElement::CopyTo( TiXmlElement* target ) const
|
||||
// superclass:
|
||||
TiXmlNode::CopyTo( target );
|
||||
|
||||
// Element class:
|
||||
// Element class:
|
||||
// Clone the attributes, then clone the children.
|
||||
const TiXmlAttribute* attribute = 0;
|
||||
for( attribute = attributeSet.First();
|
||||
@@ -875,7 +875,7 @@ void TiXmlElement::CopyTo( TiXmlElement* target ) const
|
||||
|
||||
bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const
|
||||
{
|
||||
if ( visitor->VisitEnter( *this, attributeSet.First() ) )
|
||||
if ( visitor->VisitEnter( *this, attributeSet.First() ) )
|
||||
{
|
||||
for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
|
||||
{
|
||||
@@ -969,7 +969,7 @@ bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
|
||||
value = filename;
|
||||
|
||||
// reading in binary mode so that tinyxml can normalize the EOL
|
||||
FILE* file = TiXmlFOpen( value.c_str (), "rb" );
|
||||
FILE* file = TiXmlFOpen( value.c_str (), "rb" );
|
||||
|
||||
if ( file )
|
||||
{
|
||||
@@ -986,7 +986,7 @@ bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
|
||||
|
||||
bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding )
|
||||
{
|
||||
if ( !file )
|
||||
if ( !file )
|
||||
{
|
||||
SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||
return false;
|
||||
@@ -1013,13 +1013,13 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding )
|
||||
// 2.11 End-of-Line Handling
|
||||
// <snip>
|
||||
// <quote>
|
||||
// ...the XML processor MUST behave as if it normalized all line breaks in external
|
||||
// parsed entities (including the document entity) on input, before parsing, by translating
|
||||
// both the two-character sequence #xD #xA and any #xD that is not followed by #xA to
|
||||
// ...the XML processor MUST behave as if it normalized all line breaks in external
|
||||
// parsed entities (including the document entity) on input, before parsing, by translating
|
||||
// both the two-character sequence #xD #xA and any #xD that is not followed by #xA to
|
||||
// a single #xA character.
|
||||
// </quote>
|
||||
//
|
||||
// It is not clear fgets does that, and certainly isn't clear it works cross platform.
|
||||
// It is not clear fgets does that, and certainly isn't clear it works cross platform.
|
||||
// Generally, you expect fgets to translate from the convention of the OS to the c/unix
|
||||
// convention, and not work generally.
|
||||
|
||||
@@ -1044,7 +1044,7 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding )
|
||||
// a newline-carriage return is hit.
|
||||
//
|
||||
// Wikipedia:
|
||||
// Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or
|
||||
// Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or
|
||||
// CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A)...
|
||||
// * LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others
|
||||
// * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS
|
||||
@@ -1098,7 +1098,7 @@ bool TiXmlDocument::SaveFile( const char * filename ) const
|
||||
|
||||
bool TiXmlDocument::SaveFile( FILE* fp ) const
|
||||
{
|
||||
if ( useMicrosoftBOM )
|
||||
if ( useMicrosoftBOM )
|
||||
{
|
||||
const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
|
||||
const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
|
||||
@@ -1128,7 +1128,7 @@ void TiXmlDocument::CopyTo( TiXmlDocument* target ) const
|
||||
for ( node = firstChild; node; node = node->NextSibling() )
|
||||
{
|
||||
target->LinkEndChild( node->Clone() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1251,7 +1251,7 @@ int TiXmlAttribute::QueryDoubleValue( double* dval ) const
|
||||
void TiXmlAttribute::SetIntValue( int _value )
|
||||
{
|
||||
char buf [64];
|
||||
#if defined(TIXML_SNPRINTF)
|
||||
#if defined(TIXML_SNPRINTF)
|
||||
TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value);
|
||||
#else
|
||||
sprintf (buf, "%d", _value);
|
||||
@@ -1262,7 +1262,7 @@ void TiXmlAttribute::SetIntValue( int _value )
|
||||
void TiXmlAttribute::SetDoubleValue( double _value )
|
||||
{
|
||||
char buf [256];
|
||||
#if defined(TIXML_SNPRINTF)
|
||||
#if defined(TIXML_SNPRINTF)
|
||||
TIXML_SNPRINTF( buf, sizeof(buf), "%g", _value);
|
||||
#else
|
||||
sprintf (buf, "%g", _value);
|
||||
@@ -1365,7 +1365,7 @@ bool TiXmlText::Accept( TiXmlVisitor* visitor ) const
|
||||
|
||||
|
||||
TiXmlNode* TiXmlText::Clone() const
|
||||
{
|
||||
{
|
||||
TiXmlText* clone = 0;
|
||||
clone = new TiXmlText( "" );
|
||||
|
||||
@@ -1404,7 +1404,7 @@ TiXmlDeclaration::TiXmlDeclaration( const std::string& _version,
|
||||
TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy )
|
||||
: TiXmlNode( TiXmlNode::TINYXML_DECLARATION )
|
||||
{
|
||||
copy.CopyTo( this );
|
||||
copy.CopyTo( this );
|
||||
}
|
||||
|
||||
|
||||
@@ -1455,7 +1455,7 @@ bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const
|
||||
|
||||
|
||||
TiXmlNode* TiXmlDeclaration::Clone() const
|
||||
{
|
||||
{
|
||||
TiXmlDeclaration* clone = new TiXmlDeclaration();
|
||||
|
||||
if ( !clone )
|
||||
@@ -1593,7 +1593,7 @@ TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const char* _name )
|
||||
}
|
||||
|
||||
|
||||
#ifdef TIXML_USE_STL
|
||||
#ifdef TIXML_USE_STL
|
||||
std::istream& operator>> (std::istream & in, TiXmlNode & base)
|
||||
{
|
||||
TIXML_STRING tag;
|
||||
@@ -1606,7 +1606,7 @@ std::istream& operator>> (std::istream & in, TiXmlNode & base)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TIXML_USE_STL
|
||||
#ifdef TIXML_USE_STL
|
||||
std::ostream& operator<< (std::ostream & out, const TiXmlNode & base)
|
||||
{
|
||||
TiXmlPrinter printer;
|
||||
@@ -1776,12 +1776,12 @@ bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute
|
||||
attrib->Print( 0, 0, &buffer );
|
||||
}
|
||||
|
||||
if ( !element.FirstChild() )
|
||||
if ( !element.FirstChild() )
|
||||
{
|
||||
buffer += " />";
|
||||
DoLineBreak();
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
buffer += ">";
|
||||
if ( element.FirstChild()->ToText()
|
||||
@@ -1796,7 +1796,7 @@ bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute
|
||||
DoLineBreak();
|
||||
}
|
||||
}
|
||||
++depth;
|
||||
++depth;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1804,11 +1804,11 @@ bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute
|
||||
bool TiXmlPrinter::VisitExit( const TiXmlElement& element )
|
||||
{
|
||||
--depth;
|
||||
if ( !element.FirstChild() )
|
||||
if ( !element.FirstChild() )
|
||||
{
|
||||
// nothing.
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if ( simpleTextPrint )
|
||||
{
|
||||
|
||||
@@ -80,7 +80,7 @@ distribution.
|
||||
#define TIXML_SNPRINTF snprintf
|
||||
#define TIXML_SSCANF sscanf
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class TiXmlDocument;
|
||||
class TiXmlElement;
|
||||
@@ -95,7 +95,7 @@ const int TIXML_MAJOR_VERSION = 2;
|
||||
const int TIXML_MINOR_VERSION = 6;
|
||||
const int TIXML_PATCH_VERSION = 2;
|
||||
|
||||
/* Internal structure for tracking location of items
|
||||
/* Internal structure for tracking location of items
|
||||
in the XML file.
|
||||
*/
|
||||
struct TiXmlCursor
|
||||
@@ -118,7 +118,7 @@ struct TiXmlCursor
|
||||
If you return 'true' from a Visit method, recursive parsing will continue. If you return
|
||||
false, <b>no children of this node or its sibilings</b> will be Visited.
|
||||
|
||||
All flavors of Visit methods have a default implementation that returns 'true' (continue
|
||||
All flavors of Visit methods have a default implementation that returns 'true' (continue
|
||||
visiting). You need to only override methods that are interesting to you.
|
||||
|
||||
Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting.
|
||||
@@ -153,8 +153,8 @@ public:
|
||||
};
|
||||
|
||||
// Only used by Attribute::Query functions
|
||||
enum
|
||||
{
|
||||
enum
|
||||
{
|
||||
TIXML_SUCCESS,
|
||||
TIXML_NO_ATTRIBUTE,
|
||||
TIXML_WRONG_TYPE
|
||||
@@ -206,10 +206,10 @@ public:
|
||||
/** All TinyXml classes can print themselves to a filestream
|
||||
or the string class (TiXmlString in non-STL mode, std::string
|
||||
in STL mode.) Either or both cfile and str can be null.
|
||||
|
||||
This is a formatted print, and will insert
|
||||
|
||||
This is a formatted print, and will insert
|
||||
tabs and newlines.
|
||||
|
||||
|
||||
(For an unformatted stream, use the << operator.)
|
||||
*/
|
||||
virtual void Print( FILE* cfile, int depth ) const = 0;
|
||||
@@ -254,11 +254,11 @@ public:
|
||||
// in the UTF-8 sequence.
|
||||
static const int utf8ByteTable[256];
|
||||
|
||||
virtual const char* Parse( const char* p,
|
||||
TiXmlParsingData* data,
|
||||
virtual const char* Parse( const char* p,
|
||||
TiXmlParsingData* data,
|
||||
TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
|
||||
|
||||
/** Expands entities in a string. Note this should not contian the tag's '<', '>', etc,
|
||||
/** Expands entities in a string. Note this should not contian the tag's '<', '>', etc,
|
||||
or they will be transformed into entities!
|
||||
*/
|
||||
static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
|
||||
@@ -289,9 +289,9 @@ protected:
|
||||
|
||||
static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
|
||||
|
||||
inline static bool IsWhiteSpace( char c )
|
||||
{
|
||||
return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
|
||||
inline static bool IsWhiteSpace( char c )
|
||||
{
|
||||
return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
|
||||
}
|
||||
inline static bool IsWhiteSpace( int c )
|
||||
{
|
||||
@@ -376,7 +376,7 @@ protected:
|
||||
|
||||
/// Field containing a generic user pointer
|
||||
void* userData;
|
||||
|
||||
|
||||
// None of these methods are reliable for any language except English.
|
||||
// Good for approximation, not great for accuracy.
|
||||
static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
|
||||
@@ -428,7 +428,7 @@ class TiXmlNode : public TiXmlBase
|
||||
friend class TiXmlElement;
|
||||
|
||||
public:
|
||||
#ifdef TIXML_USE_STL
|
||||
#ifdef TIXML_USE_STL
|
||||
|
||||
/** An input stream operator, for every class. Tolerant of newlines and
|
||||
formatting, but doesn't expect them.
|
||||
@@ -442,7 +442,7 @@ public:
|
||||
The operator<< and operator>> are not completely symmetric. Writing
|
||||
a node to a stream is very well defined. You'll get a nice stream
|
||||
of output, without any extra whitespace or newlines.
|
||||
|
||||
|
||||
But reading is not as well defined. (As it always is.) If you create
|
||||
a TiXmlElement (for example) and read that from an input stream,
|
||||
the text needs to define an element or junk will result. This is
|
||||
@@ -450,7 +450,7 @@ public:
|
||||
|
||||
A TiXmlDocument will read nodes until it reads a root element, and
|
||||
all the children of that root element.
|
||||
*/
|
||||
*/
|
||||
friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
|
||||
|
||||
/// Appends the XML node or attribute to a std::string.
|
||||
@@ -532,7 +532,7 @@ public:
|
||||
}
|
||||
const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children.
|
||||
TiXmlNode* LastChild() { return lastChild; }
|
||||
|
||||
|
||||
const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children.
|
||||
TiXmlNode* LastChild( const char * _value ) {
|
||||
return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
|
||||
@@ -711,11 +711,11 @@ public:
|
||||
virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
|
||||
|
||||
/** Create an exact duplicate of this node and return it. The memory must be deleted
|
||||
by the caller.
|
||||
by the caller.
|
||||
*/
|
||||
virtual TiXmlNode* Clone() const = 0;
|
||||
|
||||
/** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the
|
||||
/** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the
|
||||
XML tree will be conditionally visited and the host will be called back
|
||||
via the TiXmlVisitor interface.
|
||||
|
||||
@@ -726,7 +726,7 @@ public:
|
||||
The interface has been based on ideas from:
|
||||
|
||||
- http://www.saxproject.org/
|
||||
- http://c2.com/cgi/wiki?HierarchicalVisitorPattern
|
||||
- http://c2.com/cgi/wiki?HierarchicalVisitorPattern
|
||||
|
||||
Which are both good references for "visiting".
|
||||
|
||||
@@ -823,7 +823,7 @@ public:
|
||||
|
||||
/** QueryIntValue examines the value string. It is an alternative to the
|
||||
IntValue() method with richer error checking.
|
||||
If the value is an integer, it is stored in 'value' and
|
||||
If the value is an integer, it is stored in 'value' and
|
||||
the call returns TIXML_SUCCESS. If it is not
|
||||
an integer, it returns TIXML_WRONG_TYPE.
|
||||
|
||||
@@ -842,21 +842,21 @@ public:
|
||||
|
||||
#ifdef TIXML_USE_STL
|
||||
/// STL std::string form.
|
||||
void SetName( const std::string& _name ) { name = _name; }
|
||||
/// STL std::string form.
|
||||
void SetName( const std::string& _name ) { name = _name; }
|
||||
/// STL std::string form.
|
||||
void SetValue( const std::string& _value ) { value = _value; }
|
||||
#endif
|
||||
|
||||
/// Get the next sibling attribute in the DOM. Returns null at end.
|
||||
const TiXmlAttribute* Next() const;
|
||||
TiXmlAttribute* Next() {
|
||||
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
|
||||
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
|
||||
}
|
||||
|
||||
/// Get the previous sibling attribute in the DOM. Returns null at beginning.
|
||||
const TiXmlAttribute* Previous() const;
|
||||
TiXmlAttribute* Previous() {
|
||||
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
|
||||
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
|
||||
}
|
||||
|
||||
bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
|
||||
@@ -892,7 +892,7 @@ private:
|
||||
|
||||
/* A class used to manage a group of attributes.
|
||||
It is only used internally, both by the ELEMENT and the DECLARATION.
|
||||
|
||||
|
||||
The set can be changed transparent to the Element and Declaration
|
||||
classes that use it, but NOT transparent to the Attribute
|
||||
which has to implement a next() and previous() method. Which makes
|
||||
@@ -979,15 +979,15 @@ public:
|
||||
|
||||
/** QueryIntAttribute examines the attribute - it is an alternative to the
|
||||
Attribute() method with richer error checking.
|
||||
If the attribute is an integer, it is stored in 'value' and
|
||||
If the attribute is an integer, it is stored in 'value' and
|
||||
the call returns TIXML_SUCCESS. If it is not
|
||||
an integer, it returns TIXML_WRONG_TYPE. If the attribute
|
||||
does not exist, then TIXML_NO_ATTRIBUTE is returned.
|
||||
*/
|
||||
*/
|
||||
int QueryIntAttribute( const char* name, int* _value ) const;
|
||||
/// QueryUnsignedAttribute examines the attribute - see QueryIntAttribute().
|
||||
int QueryUnsignedAttribute( const char* name, unsigned* _value ) const;
|
||||
/** QueryBoolAttribute examines the attribute - see QueryIntAttribute().
|
||||
/** QueryBoolAttribute examines the attribute - see QueryIntAttribute().
|
||||
Note that '1', 'true', or 'yes' are considered true, while '0', 'false'
|
||||
and 'no' are considered false.
|
||||
*/
|
||||
@@ -1018,7 +1018,7 @@ public:
|
||||
/** Template form of the attribute query which will try to read the
|
||||
attribute into the specified type. Very easy, very powerful, but
|
||||
be careful to make sure to call this with the correct type.
|
||||
|
||||
|
||||
NOTE: This method doesn't work correctly for 'string' types that contain spaces.
|
||||
|
||||
@return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE
|
||||
@@ -1091,7 +1091,7 @@ public:
|
||||
/** Convenience function for easy access to the text inside an element. Although easy
|
||||
and concise, GetText() is limited compared to getting the TiXmlText child
|
||||
and accessing it directly.
|
||||
|
||||
|
||||
If the first child of 'this' is a TiXmlText, the GetText()
|
||||
returns the character string of the Text node, else null is returned.
|
||||
|
||||
@@ -1101,23 +1101,23 @@ public:
|
||||
const char* str = fooElement->GetText();
|
||||
@endverbatim
|
||||
|
||||
'str' will be a pointer to "This is text".
|
||||
|
||||
'str' will be a pointer to "This is text".
|
||||
|
||||
Note that this function can be misleading. If the element foo was created from
|
||||
this XML:
|
||||
@verbatim
|
||||
<foo><b>This is text</b></foo>
|
||||
<foo><b>This is text</b></foo>
|
||||
@endverbatim
|
||||
|
||||
then the value of str would be null. The first child node isn't a text node, it is
|
||||
another element. From this XML:
|
||||
@verbatim
|
||||
<foo>This is <b>text</b></foo>
|
||||
<foo>This is <b>text</b></foo>
|
||||
@endverbatim
|
||||
GetText() will return "This is ".
|
||||
|
||||
WARNING: GetText() accesses a child node - don't become confused with the
|
||||
similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are
|
||||
WARNING: GetText() accesses a child node - don't become confused with the
|
||||
similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are
|
||||
safe type casts on the referenced node.
|
||||
*/
|
||||
const char* GetText() const;
|
||||
@@ -1135,7 +1135,7 @@ public:
|
||||
virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
|
||||
/** Walk the XML tree visiting this node and all of its children.
|
||||
/** Walk the XML tree visiting this node and all of its children.
|
||||
*/
|
||||
virtual bool Accept( TiXmlVisitor* visitor ) const;
|
||||
|
||||
@@ -1188,7 +1188,7 @@ public:
|
||||
virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
|
||||
/** Walk the XML tree visiting this node and all of its children.
|
||||
/** Walk the XML tree visiting this node and all of its children.
|
||||
*/
|
||||
virtual bool Accept( TiXmlVisitor* visitor ) const;
|
||||
|
||||
@@ -1206,16 +1206,16 @@ private:
|
||||
};
|
||||
|
||||
|
||||
/** XML text. A text node can have 2 ways to output the next. "normal" output
|
||||
/** XML text. A text node can have 2 ways to output the next. "normal" output
|
||||
and CDATA. It will default to the mode it was parsed from the XML file and
|
||||
you generally want to leave it alone, but you can change the output mode with
|
||||
you generally want to leave it alone, but you can change the output mode with
|
||||
SetCDATA() and query it with CDATA().
|
||||
*/
|
||||
class TiXmlText : public TiXmlNode
|
||||
{
|
||||
friend class TiXmlElement;
|
||||
public:
|
||||
/** Constructor for text element. By default, it is treated as
|
||||
/** Constructor for text element. By default, it is treated as
|
||||
normal, encoded text. If you want it be output as a CDATA text
|
||||
element, set the parameter _cdata to 'true'
|
||||
*/
|
||||
@@ -1251,7 +1251,7 @@ public:
|
||||
virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
|
||||
/** Walk the XML tree visiting this node and all of its children.
|
||||
/** Walk the XML tree visiting this node and all of its children.
|
||||
*/
|
||||
virtual bool Accept( TiXmlVisitor* content ) const;
|
||||
|
||||
@@ -1327,7 +1327,7 @@ public:
|
||||
virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
|
||||
/** Walk the XML tree visiting this node and all of its children.
|
||||
/** Walk the XML tree visiting this node and all of its children.
|
||||
*/
|
||||
virtual bool Accept( TiXmlVisitor* visitor ) const;
|
||||
|
||||
@@ -1372,7 +1372,7 @@ public:
|
||||
virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
|
||||
/** Walk the XML tree visiting this node and all of its children.
|
||||
/** Walk the XML tree visiting this node and all of its children.
|
||||
*/
|
||||
virtual bool Accept( TiXmlVisitor* content ) const;
|
||||
|
||||
@@ -1458,7 +1458,7 @@ public:
|
||||
- The ErrorId() will contain the integer identifier of the error (not generally useful)
|
||||
- The ErrorDesc() method will return the name of the error. (very useful)
|
||||
- The ErrorRow() and ErrorCol() will return the location of the error (if known)
|
||||
*/
|
||||
*/
|
||||
bool Error() const { return error; }
|
||||
|
||||
/// Contains a textual (english) description of the error if one occurs.
|
||||
@@ -1469,7 +1469,7 @@ public:
|
||||
*/
|
||||
int ErrorId() const { return errorId; }
|
||||
|
||||
/** Returns the location (if known) of the error. The first column is column 1,
|
||||
/** Returns the location (if known) of the error. The first column is column 1,
|
||||
and the first row is row 1. A value of 0 means the row and column wasn't applicable
|
||||
(memory errors, for example, have no row/column) or the parser lost the error. (An
|
||||
error in the error reporting, in that case.)
|
||||
@@ -1482,7 +1482,7 @@ public:
|
||||
/** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol())
|
||||
to report the correct values for row and column. It does not change the output
|
||||
or input in any way.
|
||||
|
||||
|
||||
By calling this method, with a tab size
|
||||
greater than 0, the row and column of each node and attribute is stored
|
||||
when the file is loaded. Very useful for tracking the DOM back in to
|
||||
@@ -1510,11 +1510,11 @@ public:
|
||||
/** If you have handled the error, it can be reset with this call. The error
|
||||
state is automatically cleared if you Parse a new XML block.
|
||||
*/
|
||||
void ClearError() { error = false;
|
||||
errorId = 0;
|
||||
errorDesc = "";
|
||||
errorLocation.row = errorLocation.col = 0;
|
||||
//errorLocation.last = 0;
|
||||
void ClearError() { error = false;
|
||||
errorId = 0;
|
||||
errorDesc = "";
|
||||
errorLocation.row = errorLocation.col = 0;
|
||||
//errorLocation.last = 0;
|
||||
}
|
||||
|
||||
/** Write the document to standard out using formatted printing ("pretty print"). */
|
||||
@@ -1524,7 +1524,7 @@ public:
|
||||
will allocate a character array (new char[]) and return it as a pointer. The
|
||||
calling code pust call delete[] on the return char* to avoid a memory leak.
|
||||
*/
|
||||
//char* PrintToMemory() const;
|
||||
//char* PrintToMemory() const;
|
||||
|
||||
/// Print this Document to a FILE stream.
|
||||
virtual void Print( FILE* cfile, int depth = 0 ) const;
|
||||
@@ -1534,7 +1534,7 @@ public:
|
||||
virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
|
||||
/** Walk the XML tree visiting this node and all of its children.
|
||||
/** Walk the XML tree visiting this node and all of its children.
|
||||
*/
|
||||
virtual bool Accept( TiXmlVisitor* content ) const;
|
||||
|
||||
@@ -1572,7 +1572,7 @@ private:
|
||||
<Document>
|
||||
@endverbatim
|
||||
|
||||
Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
|
||||
Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
|
||||
easy to write a *lot* of code that looks like:
|
||||
|
||||
@verbatim
|
||||
@@ -1592,7 +1592,7 @@ private:
|
||||
@endverbatim
|
||||
|
||||
And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity
|
||||
of such code. A TiXmlHandle checks for null pointers so it is perfectly safe
|
||||
of such code. A TiXmlHandle checks for null pointers so it is perfectly safe
|
||||
and correct to use:
|
||||
|
||||
@verbatim
|
||||
@@ -1613,7 +1613,7 @@ private:
|
||||
What they should not be used for is iteration:
|
||||
|
||||
@verbatim
|
||||
int i=0;
|
||||
int i=0;
|
||||
while ( true )
|
||||
{
|
||||
TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement();
|
||||
@@ -1624,8 +1624,8 @@ private:
|
||||
}
|
||||
@endverbatim
|
||||
|
||||
It seems reasonable, but it is in fact two embedded while loops. The Child method is
|
||||
a linear walk to find the element, so this code would iterate much more than it needs
|
||||
It seems reasonable, but it is in fact two embedded while loops. The Child method is
|
||||
a linear walk to find the element, so this code would iterate much more than it needs
|
||||
to. Instead, prefer:
|
||||
|
||||
@verbatim
|
||||
@@ -1655,20 +1655,20 @@ public:
|
||||
/// Return a handle to the first child element with the given name.
|
||||
TiXmlHandle FirstChildElement( const char * value ) const;
|
||||
|
||||
/** Return a handle to the "index" child with the given name.
|
||||
/** Return a handle to the "index" child with the given name.
|
||||
The first child is 0, the second 1, etc.
|
||||
*/
|
||||
TiXmlHandle Child( const char* value, int index ) const;
|
||||
/** Return a handle to the "index" child.
|
||||
/** Return a handle to the "index" child.
|
||||
The first child is 0, the second 1, etc.
|
||||
*/
|
||||
TiXmlHandle Child( int index ) const;
|
||||
/** Return a handle to the "index" child element with the given name.
|
||||
/** Return a handle to the "index" child element with the given name.
|
||||
The first child element is 0, the second 1, etc. Note that only TiXmlElements
|
||||
are indexed: other types are not counted.
|
||||
*/
|
||||
TiXmlHandle ChildElement( const char* value, int index ) const;
|
||||
/** Return a handle to the "index" child element.
|
||||
/** Return a handle to the "index" child element.
|
||||
The first child element is 0, the second 1, etc. Note that only TiXmlElements
|
||||
are indexed: other types are not counted.
|
||||
*/
|
||||
@@ -1684,7 +1684,7 @@ public:
|
||||
|
||||
/** Return the handle as a TiXmlNode. This may return null.
|
||||
*/
|
||||
TiXmlNode* ToNode() const { return node; }
|
||||
TiXmlNode* ToNode() const { return node; }
|
||||
/** Return the handle as a TiXmlElement. This may return null.
|
||||
*/
|
||||
TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
|
||||
@@ -1695,11 +1695,11 @@ public:
|
||||
*/
|
||||
TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
|
||||
|
||||
/** @deprecated use ToNode.
|
||||
/** @deprecated use ToNode.
|
||||
Return the handle as a TiXmlNode. This may return null.
|
||||
*/
|
||||
TiXmlNode* Node() const { return ToNode(); }
|
||||
/** @deprecated use ToElement.
|
||||
TiXmlNode* Node() const { return ToNode(); }
|
||||
/** @deprecated use ToElement.
|
||||
Return the handle as a TiXmlElement. This may return null.
|
||||
*/
|
||||
TiXmlElement* Element() const { return ToElement(); }
|
||||
@@ -1759,7 +1759,7 @@ public:
|
||||
void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; }
|
||||
/// Query the indention string.
|
||||
const char* Indent() { return indent.c_str(); }
|
||||
/** Set the line breaking string. By default set to newline (\n).
|
||||
/** Set the line breaking string. By default set to newline (\n).
|
||||
Some operating systems prefer other characters, or can be
|
||||
set to the null/empty string for no indenation.
|
||||
*/
|
||||
@@ -1767,12 +1767,12 @@ public:
|
||||
/// Query the current line breaking string.
|
||||
const char* LineBreak() { return lineBreak.c_str(); }
|
||||
|
||||
/** Switch over to "stream printing" which is the most dense formatting without
|
||||
/** Switch over to "stream printing" which is the most dense formatting without
|
||||
linebreaks. Common when the XML is needed for network transmission.
|
||||
*/
|
||||
void SetStreamPrinting() { indent = "";
|
||||
lineBreak = "";
|
||||
}
|
||||
}
|
||||
/// Return the result.
|
||||
const char* CStr() { return buffer.c_str(); }
|
||||
/// Return the length of the result string.
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
Original code by Lee Thomason (www.grinninglizard.com)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
@@ -40,8 +40,8 @@ distribution.
|
||||
|
||||
// Note tha "PutString" hardcodes the same list. This
|
||||
// is less flexible than it appears. Changing the entries
|
||||
// or order will break putstring.
|
||||
TiXmlBase::Entity TiXmlBase::entity[ TiXmlBase::NUM_ENTITY ] =
|
||||
// or order will break putstring.
|
||||
TiXmlBase::Entity TiXmlBase::entity[ TiXmlBase::NUM_ENTITY ] =
|
||||
{
|
||||
{ "&", 5, '&' },
|
||||
{ "<", 4, '<' },
|
||||
@@ -55,16 +55,16 @@ TiXmlBase::Entity TiXmlBase::entity[ TiXmlBase::NUM_ENTITY ] =
|
||||
// Including the basic of this table, which determines the #bytes in the
|
||||
// sequence from the lead byte. 1 placed for invalid sequences --
|
||||
// although the result will be junk, pass it through as much as possible.
|
||||
// Beware of the non-characters in UTF-8:
|
||||
// Beware of the non-characters in UTF-8:
|
||||
// ef bb bf (Microsoft "lead bytes")
|
||||
// ef bf be
|
||||
// ef bf bf
|
||||
// ef bf bf
|
||||
|
||||
const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
|
||||
const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
|
||||
const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
|
||||
|
||||
const int TiXmlBase::utf8ByteTable[256] =
|
||||
const int TiXmlBase::utf8ByteTable[256] =
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00
|
||||
@@ -76,9 +76,9 @@ const int TiXmlBase::utf8ByteTable[256] =
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0
|
||||
1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte
|
||||
@@ -92,7 +92,7 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
||||
const unsigned long BYTE_MARK = 0x80;
|
||||
const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
||||
|
||||
if (input < 0x80)
|
||||
if (input < 0x80)
|
||||
*length = 1;
|
||||
else if ( input < 0x800 )
|
||||
*length = 2;
|
||||
@@ -106,22 +106,22 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
||||
output += *length;
|
||||
|
||||
// Scary scary fall throughs.
|
||||
switch (*length)
|
||||
switch (*length)
|
||||
{
|
||||
case 4:
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
input >>= 6;
|
||||
case 3:
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
input >>= 6;
|
||||
case 2:
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
input >>= 6;
|
||||
case 1:
|
||||
--output;
|
||||
--output;
|
||||
*output = (char)(input | FIRST_BYTE_MARK[*length]);
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
||||
{
|
||||
// This will only work for low-ascii, everything else is assumed to be a valid
|
||||
// letter. I'm not sure this is the best approach, but it is quite tricky trying
|
||||
// to figure out alhabetical vs. not across encoding. So take a very
|
||||
// to figure out alhabetical vs. not across encoding. So take a very
|
||||
// conservative approach.
|
||||
|
||||
// if ( encoding == TIXML_ENCODING_UTF8 )
|
||||
@@ -152,7 +152,7 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
||||
{
|
||||
// This will only work for low-ascii, everything else is assumed to be a valid
|
||||
// letter. I'm not sure this is the best approach, but it is quite tricky trying
|
||||
// to figure out alhabetical vs. not across encoding. So take a very
|
||||
// to figure out alhabetical vs. not across encoding. So take a very
|
||||
// conservative approach.
|
||||
|
||||
// if ( encoding == TIXML_ENCODING_UTF8 )
|
||||
@@ -225,7 +225,7 @@ void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
|
||||
case '\r':
|
||||
// bump down to the next line
|
||||
++row;
|
||||
col = 0;
|
||||
col = 0;
|
||||
// Eat the character
|
||||
++p;
|
||||
|
||||
@@ -267,11 +267,11 @@ void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
|
||||
// In these cases, don't advance the column. These are
|
||||
// 0-width spaces.
|
||||
if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 )
|
||||
p += 3;
|
||||
p += 3;
|
||||
else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU )
|
||||
p += 3;
|
||||
p += 3;
|
||||
else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU )
|
||||
p += 3;
|
||||
p += 3;
|
||||
else
|
||||
{ p +=3; ++col; } // A normal character.
|
||||
}
|
||||
@@ -323,10 +323,10 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
|
||||
while ( *p )
|
||||
{
|
||||
const unsigned char* pU = (const unsigned char*)p;
|
||||
|
||||
|
||||
// Skip the stupid Microsoft UTF-8 Byte order marks
|
||||
if ( *(pU+0)==TIXML_UTF_LEAD_0
|
||||
&& *(pU+1)==TIXML_UTF_LEAD_1
|
||||
&& *(pU+1)==TIXML_UTF_LEAD_1
|
||||
&& *(pU+2)==TIXML_UTF_LEAD_2 )
|
||||
{
|
||||
p += 3;
|
||||
@@ -414,12 +414,12 @@ const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncodi
|
||||
// After that, they can be letters, underscores, numbers,
|
||||
// hyphens, or colons. (Colons are valid ony for namespaces,
|
||||
// but tinyxml can't tell namespaces from names.)
|
||||
if ( p && *p
|
||||
if ( p && *p
|
||||
&& ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) )
|
||||
{
|
||||
const char* start = p;
|
||||
while( p && *p
|
||||
&& ( IsAlphaNum( (unsigned char ) *p, encoding )
|
||||
&& ( IsAlphaNum( (unsigned char ) *p, encoding )
|
||||
|| *p == '_'
|
||||
|| *p == '-'
|
||||
|| *p == '.'
|
||||
@@ -470,7 +470,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml
|
||||
ucs += mult * (*q - 'a' + 10);
|
||||
else if ( *q >= 'A' && *q <= 'F' )
|
||||
ucs += mult * (*q - 'A' + 10 );
|
||||
else
|
||||
else
|
||||
return 0;
|
||||
mult *= 16;
|
||||
--q;
|
||||
@@ -493,7 +493,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml
|
||||
{
|
||||
if ( *q >= '0' && *q <= '9' )
|
||||
ucs += mult * (*q - '0');
|
||||
else
|
||||
else
|
||||
return 0;
|
||||
mult *= 10;
|
||||
--q;
|
||||
@@ -572,10 +572,10 @@ bool TiXmlBase::StringEqual( const char* p,
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* TiXmlBase::ReadText( const char* p,
|
||||
TIXML_STRING * text,
|
||||
bool trimWhiteSpace,
|
||||
const char* endTag,
|
||||
const char* TiXmlBase::ReadText( const char* p,
|
||||
TIXML_STRING * text,
|
||||
bool trimWhiteSpace,
|
||||
const char* endTag,
|
||||
bool caseInsensitive,
|
||||
TiXmlEncoding encoding )
|
||||
{
|
||||
@@ -648,7 +648,7 @@ void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag )
|
||||
// This "pre-streaming" will never read the closing ">" so the
|
||||
// sub-tag can orient itself.
|
||||
|
||||
if ( !StreamTo( in, '<', tag ) )
|
||||
if ( !StreamTo( in, '<', tag ) )
|
||||
{
|
||||
SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||
return;
|
||||
@@ -670,7 +670,7 @@ void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag )
|
||||
|
||||
if ( in->good() )
|
||||
{
|
||||
// We now have something we presume to be a node of
|
||||
// We now have something we presume to be a node of
|
||||
// some sort. Identify it, and call the node to
|
||||
// continue streaming.
|
||||
TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING );
|
||||
@@ -779,7 +779,7 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX
|
||||
encoding = TIXML_ENCODING_UTF8;
|
||||
else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) )
|
||||
encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice
|
||||
else
|
||||
else
|
||||
encoding = TIXML_ENCODING_LEGACY;
|
||||
}
|
||||
|
||||
@@ -797,7 +797,7 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX
|
||||
}
|
||||
|
||||
void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding )
|
||||
{
|
||||
{
|
||||
// The first error in a chain is more accurate - don't set again!
|
||||
if ( error )
|
||||
return;
|
||||
@@ -833,7 +833,7 @@ TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
|
||||
return 0;
|
||||
}
|
||||
|
||||
// What is this thing?
|
||||
// What is this thing?
|
||||
// - Elements start with a letter or underscore, but xml is reserved.
|
||||
// - Comments: <!--
|
||||
// - Decleration: <?xml
|
||||
@@ -916,7 +916,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag)
|
||||
return;
|
||||
}
|
||||
(*tag) += (char) c ;
|
||||
|
||||
|
||||
if ( c == '>' )
|
||||
break;
|
||||
}
|
||||
@@ -926,7 +926,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag)
|
||||
// Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
|
||||
// If not, identify and stream.
|
||||
|
||||
if ( tag->at( tag->length() - 1 ) == '>'
|
||||
if ( tag->at( tag->length() - 1 ) == '>'
|
||||
&& tag->at( tag->length() - 2 ) == '/' )
|
||||
{
|
||||
// All good!
|
||||
@@ -944,7 +944,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag)
|
||||
StreamWhiteSpace( in, tag );
|
||||
|
||||
// Do we have text?
|
||||
if ( in->good() && in->peek() != '<' )
|
||||
if ( in->good() && in->peek() != '<' )
|
||||
{
|
||||
// Yep, text.
|
||||
TiXmlText text( "" );
|
||||
@@ -977,7 +977,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag)
|
||||
document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( c == '>' )
|
||||
break;
|
||||
|
||||
@@ -1096,7 +1096,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
||||
// Empty tag.
|
||||
if ( *p != '>' )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );
|
||||
if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );
|
||||
return 0;
|
||||
}
|
||||
return (p+1);
|
||||
@@ -1118,7 +1118,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
||||
// We should find the end tag now
|
||||
// note that:
|
||||
// </foo > and
|
||||
// </foo>
|
||||
// </foo>
|
||||
// are both valid end tags.
|
||||
if ( StringEqual( p, endTag.c_str(), false, encoding ) )
|
||||
{
|
||||
@@ -1212,8 +1212,8 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
|
||||
LinkEndChild( textNode );
|
||||
else
|
||||
delete textNode;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
// We hit a '<'
|
||||
// Have we hit a new element or an end tag? This could also be
|
||||
@@ -1229,7 +1229,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
|
||||
{
|
||||
p = node->Parse( p, data, encoding );
|
||||
LinkEndChild( node );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
@@ -1243,7 +1243,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
|
||||
if ( !p )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -1253,7 +1253,7 @@ void TiXmlUnknown::StreamIn( std::istream * in, TIXML_STRING * tag )
|
||||
{
|
||||
while ( in->good() )
|
||||
{
|
||||
int c = in->get();
|
||||
int c = in->get();
|
||||
if ( c <= 0 )
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
@@ -1266,7 +1266,7 @@ void TiXmlUnknown::StreamIn( std::istream * in, TIXML_STRING * tag )
|
||||
if ( c == '>' )
|
||||
{
|
||||
// All is well.
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1299,7 +1299,7 @@ const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
||||
|
||||
if ( !p )
|
||||
{
|
||||
if ( document )
|
||||
if ( document )
|
||||
document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding );
|
||||
}
|
||||
if ( p && *p == '>' )
|
||||
@@ -1312,7 +1312,7 @@ void TiXmlComment::StreamIn( std::istream * in, TIXML_STRING * tag )
|
||||
{
|
||||
while ( in->good() )
|
||||
{
|
||||
int c = in->get();
|
||||
int c = in->get();
|
||||
if ( c <= 0 )
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
@@ -1323,12 +1323,12 @@ void TiXmlComment::StreamIn( std::istream * in, TIXML_STRING * tag )
|
||||
|
||||
(*tag) += (char) c;
|
||||
|
||||
if ( c == '>'
|
||||
if ( c == '>'
|
||||
&& tag->at( tag->length() - 2 ) == '-'
|
||||
&& tag->at( tag->length() - 3 ) == '-' )
|
||||
{
|
||||
// All is well.
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1364,11 +1364,11 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
||||
//
|
||||
// from the XML spec:
|
||||
/*
|
||||
[Definition: Comments may appear anywhere in a document outside other markup; in addition,
|
||||
they may appear within the document type declaration at places allowed by the grammar.
|
||||
They are not part of the document's character data; an XML processor MAY, but need not,
|
||||
make it possible for an application to retrieve the text of comments. For compatibility,
|
||||
the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity
|
||||
[Definition: Comments may appear anywhere in a document outside other markup; in addition,
|
||||
they may appear within the document type declaration at places allowed by the grammar.
|
||||
They are not part of the document's character data; an XML processor MAY, but need not,
|
||||
make it possible for an application to retrieve the text of comments. For compatibility,
|
||||
the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity
|
||||
references MUST NOT be recognized within comments.
|
||||
|
||||
An example of a comment:
|
||||
@@ -1383,7 +1383,7 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
||||
value.append( p, 1 );
|
||||
++p;
|
||||
}
|
||||
if ( p && *p )
|
||||
if ( p && *p )
|
||||
p += strlen( endTag );
|
||||
|
||||
return p;
|
||||
@@ -1422,7 +1422,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
|
||||
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const char* end;
|
||||
const char SINGLE_QUOTE = '\'';
|
||||
const char DOUBLE_QUOTE = '\"';
|
||||
@@ -1451,7 +1451,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
|
||||
{
|
||||
if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {
|
||||
// [ 1451649 ] Attribute values with trailing quotes not handled correctly
|
||||
// We did not have an opening quote but seem to have a
|
||||
// We did not have an opening quote but seem to have a
|
||||
// closing one. Give up and throw an error.
|
||||
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
|
||||
return 0;
|
||||
@@ -1468,8 +1468,8 @@ void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag )
|
||||
{
|
||||
while ( in->good() )
|
||||
{
|
||||
int c = in->peek();
|
||||
if ( !cdata && (c == '<' ) )
|
||||
int c = in->peek();
|
||||
if ( !cdata && (c == '<' ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1490,7 +1490,7 @@ void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag )
|
||||
// terminator of cdata.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1530,7 +1530,7 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncodi
|
||||
++p;
|
||||
}
|
||||
|
||||
TIXML_STRING dummy;
|
||||
TIXML_STRING dummy;
|
||||
p = ReadText( p, &dummy, false, endTag, false, encoding );
|
||||
return p;
|
||||
}
|
||||
@@ -1604,19 +1604,19 @@ const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXm
|
||||
if ( StringEqual( p, "version", true, _encoding ) )
|
||||
{
|
||||
TiXmlAttribute attrib;
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
version = attrib.Value();
|
||||
}
|
||||
else if ( StringEqual( p, "encoding", true, _encoding ) )
|
||||
{
|
||||
TiXmlAttribute attrib;
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
encoding = attrib.Value();
|
||||
}
|
||||
else if ( StringEqual( p, "standalone", true, _encoding ) )
|
||||
{
|
||||
TiXmlAttribute attrib;
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
standalone = attrib.Value();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -104,7 +104,7 @@ int main()
|
||||
"<Item priority=\"2\" distance='none'> Do bills </Item>"
|
||||
"<Item priority=\"2\" distance='far & back'> Look for Evil Dinosaurs! </Item>"
|
||||
"</ToDo>";
|
||||
|
||||
|
||||
{
|
||||
|
||||
#ifdef TIXML_USE_STL
|
||||
@@ -134,7 +134,7 @@ int main()
|
||||
// The example parses from the character string (above):
|
||||
#if defined( WIN32 ) && defined( TUNE )
|
||||
_CrtMemCheckpoint( &startMemState );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
{
|
||||
// Write to a file and read it back, to check file I/O.
|
||||
@@ -169,7 +169,7 @@ int main()
|
||||
doc.Accept( &printer );
|
||||
fprintf( stdout, "%s", printer.CStr() );
|
||||
}
|
||||
#ifdef TIXML_USE_STL
|
||||
#ifdef TIXML_USE_STL
|
||||
{
|
||||
printf( "** Printing via operator<< **\n" );
|
||||
std::cout << doc;
|
||||
@@ -405,13 +405,13 @@ int main()
|
||||
ostringstream outputStream0( ostringstream::out );
|
||||
outputStream0 << document0;
|
||||
|
||||
XmlTest( "Stream round trip correct.", string( demoEnd ).c_str(),
|
||||
XmlTest( "Stream round trip correct.", string( demoEnd ).c_str(),
|
||||
outputStream0.str().c_str(), true );
|
||||
|
||||
std::string str;
|
||||
str << document0;
|
||||
|
||||
XmlTest( "String printing correct.", string( demoEnd ).c_str(),
|
||||
XmlTest( "String printing correct.", string( demoEnd ).c_str(),
|
||||
str.c_str(), true );
|
||||
}
|
||||
#endif
|
||||
@@ -465,7 +465,7 @@ int main()
|
||||
XmlTest( "Attribute round trip. int.", 1, iVal );
|
||||
XmlTest( "Attribute round trip. double.", -1, (int)dVal );
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
const char* str = "\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n"
|
||||
"</room>";
|
||||
@@ -490,7 +490,7 @@ int main()
|
||||
XmlTest( "Location tracking: Tab 8: doors row", doors->Row(), 1 );
|
||||
XmlTest( "Location tracking: Tab 8: doors col", doors->Column(), 55 );
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
const char* str = "\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n"
|
||||
" <!-- Silly example -->\n"
|
||||
@@ -535,7 +535,7 @@ int main()
|
||||
XmlTest( "Location tracking: doors col", doors->Column(), 51 );
|
||||
XmlTest( "Location tracking: Comment row", comment->Row(), 2 );
|
||||
XmlTest( "Location tracking: Comment col", comment->Column(), 3 );
|
||||
XmlTest( "Location tracking: text row", text->Row(), 3 );
|
||||
XmlTest( "Location tracking: text row", text->Row(), 3 );
|
||||
XmlTest( "Location tracking: text col", text->Column(), 24 );
|
||||
XmlTest( "Location tracking: door0 row", door0->Row(), 3 );
|
||||
XmlTest( "Location tracking: door0 col", door0->Column(), 5 );
|
||||
@@ -564,7 +564,7 @@ int main()
|
||||
TiXmlHandle docH( &doc );
|
||||
// Get the attribute "value" from the "Russian" element and check it.
|
||||
TiXmlElement* element = docH.FirstChildElement( "document" ).FirstChildElement( "Russian" ).Element();
|
||||
const unsigned char correctValue[] = { 0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU,
|
||||
const unsigned char correctValue[] = { 0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU,
|
||||
0xd0U, 0xbeU, 0xd1U, 0x81U, 0xd1U, 0x82U, 0xd1U, 0x8cU, 0 };
|
||||
|
||||
XmlTest( "UTF-8: Russian value.", (const char*)correctValue, element->Attribute( "value" ), true );
|
||||
@@ -637,7 +637,7 @@ int main()
|
||||
text = latinDoc.FirstChildElement()->FirstChild()->ToText();
|
||||
XmlTest( "Legacy encoding: Verify text element.", "r\x82sum\x82", text->Value() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// Copy and assignment
|
||||
@@ -674,7 +674,7 @@ int main()
|
||||
unknownAssign = unknownCopy;
|
||||
XmlTest( "Copy/Assign: unknown copy.", "[unknown]", unknownCopy.Value() );
|
||||
XmlTest( "Copy/Assign: unknown assign.", "[unknown]", unknownAssign.Value() );
|
||||
|
||||
|
||||
TiXmlText text( "TextNode" );
|
||||
TiXmlText textCopy( text );
|
||||
TiXmlText textAssign( "incorrect" );
|
||||
@@ -710,7 +710,7 @@ int main()
|
||||
XmlTest( "Copy/Assign: document assign.", original.c_str(), assign.c_str(), true );
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
#ifdef TIXML_USE_STL
|
||||
@@ -769,7 +769,7 @@ int main()
|
||||
doc.Parse( str );
|
||||
doc.Print();
|
||||
|
||||
XmlTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(),
|
||||
XmlTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(),
|
||||
"I am > the rules!\n...since I make symbolic puns",
|
||||
true );
|
||||
|
||||
@@ -782,7 +782,7 @@ int main()
|
||||
parse0 >> doc;
|
||||
//cout << doc << '\n';
|
||||
|
||||
XmlTest( "CDATA stream.", doc.FirstChildElement()->FirstChild()->Value(),
|
||||
XmlTest( "CDATA stream.", doc.FirstChildElement()->FirstChild()->Value(),
|
||||
"I am > the rules!\n...since I make symbolic puns",
|
||||
true );
|
||||
#endif
|
||||
@@ -790,7 +790,7 @@ int main()
|
||||
TiXmlDocument doc1 = doc;
|
||||
//doc.Print();
|
||||
|
||||
XmlTest( "CDATA copy.", doc1.FirstChildElement()->FirstChild()->Value(),
|
||||
XmlTest( "CDATA copy.", doc1.FirstChildElement()->FirstChild()->Value(),
|
||||
"I am > the rules!\n...since I make symbolic puns",
|
||||
true );
|
||||
}
|
||||
@@ -836,7 +836,7 @@ int main()
|
||||
doc.Parse( str );
|
||||
doc.Print();
|
||||
|
||||
XmlTest( "CDATA parse. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(),
|
||||
XmlTest( "CDATA parse. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(),
|
||||
"<b>I am > the rules!</b>\n...since I make symbolic puns",
|
||||
true );
|
||||
|
||||
@@ -847,7 +847,7 @@ int main()
|
||||
istringstream parse0( str );
|
||||
parse0 >> doc;
|
||||
|
||||
XmlTest( "CDATA stream. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(),
|
||||
XmlTest( "CDATA stream. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(),
|
||||
"<b>I am > the rules!</b>\n...since I make symbolic puns",
|
||||
true );
|
||||
#endif
|
||||
@@ -855,7 +855,7 @@ int main()
|
||||
TiXmlDocument doc1 = doc;
|
||||
//doc.Print();
|
||||
|
||||
XmlTest( "CDATA copy. [ 1480107 ]", doc1.FirstChildElement()->FirstChild()->Value(),
|
||||
XmlTest( "CDATA copy. [ 1480107 ]", doc1.FirstChildElement()->FirstChild()->Value(),
|
||||
"<b>I am > the rules!</b>\n...since I make symbolic puns",
|
||||
true );
|
||||
}
|
||||
@@ -871,7 +871,7 @@ int main()
|
||||
|
||||
// The only goal is not to crash on bad input.
|
||||
int len = (int) strlen( demoStart );
|
||||
for( int i=0; i<FUZZ_ITERATION; ++i )
|
||||
for( int i=0; i<FUZZ_ITERATION; ++i )
|
||||
{
|
||||
char* demoCopy = new char[ len+1 ];
|
||||
strcpy( demoCopy, demoStart );
|
||||
@@ -886,7 +886,7 @@ int main()
|
||||
delete [] demoCopy;
|
||||
}
|
||||
printf( "** Fuzzing Complete. **\n" );
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
printf ("\n** Bug regression tests **\n");
|
||||
|
||||
@@ -1020,7 +1020,7 @@ int main()
|
||||
|
||||
{
|
||||
// DOCTYPE not preserved (950171)
|
||||
//
|
||||
//
|
||||
const char* doctype =
|
||||
"<?xml version=\"1.0\" ?>"
|
||||
"<!DOCTYPE PLAY SYSTEM 'play.dtd'>"
|
||||
@@ -1033,7 +1033,7 @@ int main()
|
||||
doc.SaveFile( "test7.xml" );
|
||||
doc.Clear();
|
||||
doc.LoadFile( "test7.xml" );
|
||||
|
||||
|
||||
TiXmlHandle docH( &doc );
|
||||
TiXmlUnknown* unknown = docH.Child( 1 ).Unknown();
|
||||
XmlTest( "Correct value of unknown.", "!DOCTYPE PLAY SYSTEM 'play.dtd'", unknown->Value() );
|
||||
@@ -1048,7 +1048,7 @@ int main()
|
||||
{
|
||||
// [ 791411 ] Formatting bug
|
||||
// Comments do not stream out correctly.
|
||||
const char* doctype =
|
||||
const char* doctype =
|
||||
"<!-- Somewhat<evil> -->";
|
||||
TiXmlDocument doc;
|
||||
doc.Parse( doctype );
|
||||
@@ -1069,7 +1069,7 @@ int main()
|
||||
TiXmlDocument doc;
|
||||
TiXmlText* text;
|
||||
TiXmlHandle docH( &doc );
|
||||
|
||||
|
||||
const char* doctype0 = "<element> This has leading and trailing space </element>";
|
||||
const char* doctype1 = "<element>This has internal space</element>";
|
||||
const char* doctype2 = "<element> This has leading, trailing, and internal space </element>";
|
||||
@@ -1113,7 +1113,7 @@ int main()
|
||||
|
||||
TiXmlDocument doc;
|
||||
doc.Parse( doctype );
|
||||
|
||||
|
||||
XmlTest( "Parsing repeated attributes.", true, doc.Error() ); // is an error to tinyxml (didn't use to be, but caused issues)
|
||||
//XmlTest( "Parsing repeated attributes.", "blue", doc.FirstChildElement( "element" )->Attribute( "attr" ) );
|
||||
}
|
||||
@@ -1175,9 +1175,9 @@ int main()
|
||||
#endif
|
||||
{
|
||||
// Bug [ 1195696 ] from marlonism
|
||||
TiXmlBase::SetCondenseWhiteSpace(false);
|
||||
TiXmlDocument xml;
|
||||
xml.Parse("<text><break/>This hangs</text>");
|
||||
TiXmlBase::SetCondenseWhiteSpace(false);
|
||||
TiXmlDocument xml;
|
||||
xml.Parse("<text><break/>This hangs</text>");
|
||||
XmlTest( "Test safe error return.", xml.Error(), false );
|
||||
}
|
||||
|
||||
@@ -1186,7 +1186,7 @@ int main()
|
||||
TiXmlDocument doc;
|
||||
doc.SetCondenseWhiteSpace(false);
|
||||
doc.Parse("<p><pb></pb>test</p>");
|
||||
}
|
||||
}
|
||||
{
|
||||
// Low entities
|
||||
TiXmlDocument xml;
|
||||
@@ -1264,7 +1264,7 @@ int main()
|
||||
XmlTest("Missing end tag at end of input", xml.Error(), true);
|
||||
xml.Parse("<x> ");
|
||||
XmlTest("Missing end tag with trailing whitespace", xml.Error(), true);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// [ 1635701 ] fail to parse files with a tag separated into two lines
|
||||
@@ -1332,7 +1332,7 @@ int main()
|
||||
|
||||
TiXmlDocument doc;
|
||||
doc.Parse( (const char*)buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Opm
|
||||
{
|
||||
|
||||
ProductionSpecification::ProductionSpecification()
|
||||
:
|
||||
:
|
||||
control_mode_(NONE),
|
||||
procedure_(NONE_P),
|
||||
oil_max_rate_(-1e100),
|
||||
@@ -15,7 +15,7 @@ namespace Opm
|
||||
reservoir_flow_max_rate_(-1e100),
|
||||
BHP_limit_(-1e100),
|
||||
guide_rate_(1.0),
|
||||
guide_rate_type_(NONE_GRT)
|
||||
guide_rate_type_(NONE_GRT)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@ namespace Opm
|
||||
{
|
||||
NONE_P, RATE, WELL
|
||||
};
|
||||
|
||||
|
||||
enum GuideRateType
|
||||
{
|
||||
OIL, NONE_GRT
|
||||
};
|
||||
|
||||
ProductionSpecification();
|
||||
|
||||
|
||||
ControlMode control_mode_;
|
||||
Procedure procedure_;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Opm
|
||||
void WellCollection::addChild(const std::string& child_name,
|
||||
const std::string& parent_name,
|
||||
const EclipseGridParser& deck)
|
||||
{
|
||||
{
|
||||
WellsGroupInterface* parent = findNode(parent_name);
|
||||
if (!parent) {
|
||||
roots_.push_back(createWellsGroup(parent_name, deck));
|
||||
@@ -42,7 +42,7 @@ namespace Opm
|
||||
for(size_t j = i; j < roots_.size() - 1; ++j) {
|
||||
roots_[j] = roots_[j+1];
|
||||
}
|
||||
|
||||
|
||||
roots_.resize(roots_.size()-1);
|
||||
break;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ namespace Opm
|
||||
if (!child.get()) {
|
||||
child = createWellsGroup(child_name, deck);
|
||||
}
|
||||
|
||||
|
||||
WellsGroup* parent_as_group = static_cast<WellsGroup*> (parent);
|
||||
if (!parent_as_group) {
|
||||
THROW("Trying to add child to group named " << parent_name << ", but it's not a group.");
|
||||
@@ -60,12 +60,12 @@ namespace Opm
|
||||
if(child->isLeafNode()) {
|
||||
leaf_nodes_.push_back(static_cast<WellNode*>(child.get()));
|
||||
}
|
||||
|
||||
|
||||
child->setParent(parent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const std::vector<WellNode*>& WellCollection::getLeafNodes() const {
|
||||
return leaf_nodes_;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace Opm
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
const WellsGroupInterface* WellCollection::findNode(const std::string& name) const
|
||||
{
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Opm
|
||||
leaf_nodes_.push_back(static_cast<WellNode*> (child_node.get()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool WellCollection::conditionsMet(const std::vector<double>& well_bhp,
|
||||
const std::vector<double>& well_reservoirrates_phase,
|
||||
const std::vector<double>& well_surfacerates_phase)
|
||||
@@ -139,13 +139,13 @@ namespace Opm
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void WellCollection::setWellsPointer(Wells* wells) {
|
||||
for(size_t i = 0; i < leaf_nodes_.size(); i++) {
|
||||
leaf_nodes_[i]->setWellsPointer(wells, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WellCollection::applyGroupControls()
|
||||
{
|
||||
for (size_t i = 0; i < roots_.size(); ++i) {
|
||||
|
||||
@@ -43,14 +43,14 @@ namespace Opm
|
||||
void addChild(const std::string& child,
|
||||
const std::string& parent,
|
||||
const EclipseGridParser& deck);
|
||||
|
||||
|
||||
/// Adds the child to the collection
|
||||
/// and appends it to parent's children.
|
||||
/// \param[in] child the child node
|
||||
/// \param[in] parent name of parent node
|
||||
void addChild(boost::shared_ptr<WellsGroupInterface>& child_node,
|
||||
const std::string& parent);
|
||||
|
||||
|
||||
/// Adds the node to the collection (as a root node)
|
||||
void addChild(boost::shared_ptr<WellsGroupInterface>& child_node);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Opm
|
||||
/// \endcode
|
||||
///
|
||||
/// \note It's highly recommended to use the conditionsMet found in WellsManager.
|
||||
/// \param[in] well_bhp A vector containing the bhp for each well. Is assumed
|
||||
/// \param[in] well_bhp A vector containing the bhp for each well. Is assumed
|
||||
/// to be ordered the same way as the related Wells-struct.
|
||||
/// \param[in] well_reservoirrates_phase
|
||||
/// A vector containing reservoir rates by phase for each well.
|
||||
@@ -79,26 +79,26 @@ namespace Opm
|
||||
bool conditionsMet(const std::vector<double>& well_bhp,
|
||||
const std::vector<double>& well_reservoirrates_phase,
|
||||
const std::vector<double>& well_surfacerates_phase);
|
||||
|
||||
|
||||
/// Adds the well pointer to each leaf node (does not take ownership).
|
||||
void setWellsPointer(Wells* wells);
|
||||
|
||||
|
||||
/// \return A set of pointers to every well in the collection
|
||||
const std::vector<WellNode*>& getLeafNodes() const;
|
||||
|
||||
|
||||
/// Finds the group with the given name.
|
||||
/// \param[in] the name of the group
|
||||
/// \return the pointer to the group if found, NULL otherwise
|
||||
WellsGroupInterface* findNode(const std::string& name);
|
||||
|
||||
|
||||
/// Finds the group with the given name.
|
||||
/// \param[in] the name of the group
|
||||
/// \return the pointer to the group if found, NULL otherwise
|
||||
const WellsGroupInterface* findNode(const std::string& name) const;
|
||||
|
||||
|
||||
/// Applies all group controls (injection and production)
|
||||
void applyGroupControls();
|
||||
|
||||
|
||||
/// Applies explicit reinjection controls. This must be called at each timestep to be correct.
|
||||
/// \param[in] well_reservoirrates_phase
|
||||
/// A vector containing reservoir rates by phase for each well.
|
||||
@@ -110,15 +110,15 @@ namespace Opm
|
||||
/// with all phase rates of a single well adjacent in the array.
|
||||
void applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
|
||||
const std::vector<double>& well_surfacerates_phase);
|
||||
|
||||
|
||||
private:
|
||||
// To account for the possibility of a forest
|
||||
std::vector<boost::shared_ptr<WellsGroupInterface> > roots_;
|
||||
|
||||
|
||||
// This will be used to traverse the bottom nodes.
|
||||
std::vector<WellNode*> leaf_nodes_;
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Opm
|
||||
|
||||
// ========== WellPhasesSummed methods ===========
|
||||
|
||||
WellPhasesSummed::WellPhasesSummed()
|
||||
WellPhasesSummed::WellPhasesSummed()
|
||||
{
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
res_inj_rates[i] = 0.0;
|
||||
@@ -38,7 +38,7 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
void WellPhasesSummed::operator+=(const WellPhasesSummed& other)
|
||||
void WellPhasesSummed::operator+=(const WellPhasesSummed& other)
|
||||
{
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
res_inj_rates[i] += other.res_inj_rates[i];
|
||||
@@ -75,8 +75,8 @@ namespace Opm
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
const PhaseUsage& WellsGroupInterface::phaseUsage() const
|
||||
|
||||
const PhaseUsage& WellsGroupInterface::phaseUsage() const
|
||||
{
|
||||
return phase_usage_;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ namespace Opm
|
||||
}
|
||||
|
||||
/// Calculates the correct rate for the given ProductionSpecification::ControlMode
|
||||
double WellsGroupInterface::rateByMode(const double* res_rates,
|
||||
double WellsGroupInterface::rateByMode(const double* res_rates,
|
||||
const double* surf_rates,
|
||||
const ProductionSpecification::ControlMode mode)
|
||||
{
|
||||
@@ -130,7 +130,7 @@ namespace Opm
|
||||
case ProductionSpecification::GRAT:
|
||||
return surf_rates[phaseUsage().phase_pos[BlackoilPhases::Vapour]];
|
||||
case ProductionSpecification::LRAT:
|
||||
return surf_rates[phaseUsage().phase_pos[BlackoilPhases::Liquid]]
|
||||
return surf_rates[phaseUsage().phase_pos[BlackoilPhases::Liquid]]
|
||||
+ surf_rates[phaseUsage().phase_pos[BlackoilPhases::Aqua]];
|
||||
case ProductionSpecification::RESV:
|
||||
{
|
||||
@@ -146,7 +146,7 @@ namespace Opm
|
||||
}
|
||||
|
||||
/// Calculates the correct rate for the given InjectionSpecification::ControlMode
|
||||
double WellsGroupInterface::rateByMode(const double* res_rates,
|
||||
double WellsGroupInterface::rateByMode(const double* res_rates,
|
||||
const double* surf_rates,
|
||||
const InjectionSpecification::ControlMode mode)
|
||||
{
|
||||
@@ -167,7 +167,7 @@ namespace Opm
|
||||
}
|
||||
return tot_rate;
|
||||
}
|
||||
|
||||
|
||||
double WellsGroupInterface::getTarget(ProductionSpecification::ControlMode mode)
|
||||
{
|
||||
double target = -1.0;
|
||||
@@ -194,10 +194,10 @@ namespace Opm
|
||||
THROW("Unsupported control mode to query target " << mode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
double WellsGroupInterface::getTarget(InjectionSpecification::ControlMode mode)
|
||||
{
|
||||
double target = -1.0;
|
||||
@@ -215,13 +215,13 @@ namespace Opm
|
||||
THROW("Unsupported control mode to query target " << mode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ============== WellsGroup members =============
|
||||
|
||||
@@ -257,10 +257,10 @@ namespace Opm
|
||||
/// \param[in] forced if true, all children will be set under group control, otherwise
|
||||
/// only children that are under group control will be changed.
|
||||
void WellsGroup::applyInjGroupControl(const InjectionSpecification::ControlMode control_mode,
|
||||
const double target,
|
||||
const double target,
|
||||
const bool forced)
|
||||
{
|
||||
if (forced || injSpec().control_mode_ == InjectionSpecification::FLD
|
||||
if (forced || injSpec().control_mode_ == InjectionSpecification::FLD
|
||||
|| injSpec().control_mode_ == InjectionSpecification::NONE) {
|
||||
const double my_guide_rate = injectionGuideRate(!forced);
|
||||
if (my_guide_rate == 0.0) {
|
||||
@@ -284,7 +284,7 @@ namespace Opm
|
||||
const double target,
|
||||
const bool forced)
|
||||
{
|
||||
if (forced || (prodSpec().control_mode_ == ProductionSpecification::FLD
|
||||
if (forced || (prodSpec().control_mode_ == ProductionSpecification::FLD
|
||||
|| prodSpec().control_mode_ == ProductionSpecification::NONE)) {
|
||||
const double my_guide_rate = productionGuideRate(!forced);
|
||||
if (my_guide_rate == 0.0) {
|
||||
@@ -334,7 +334,7 @@ namespace Opm
|
||||
double my_rate = rateByMode(child_phases_summed.res_inj_rates,
|
||||
child_phases_summed.surf_inj_rates,
|
||||
mode);
|
||||
|
||||
|
||||
if (my_rate > target_rate) {
|
||||
std::cout << "Group " << mode<<" target not met for group " << name() << std::endl;
|
||||
std::cout << "target = " << target_rate << '\n'
|
||||
@@ -345,7 +345,7 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// REIN
|
||||
// \TODO: Add support for REIN controls.
|
||||
|
||||
@@ -364,7 +364,7 @@ namespace Opm
|
||||
}
|
||||
const double target_rate = getTarget(mode);
|
||||
if (target_rate >= 0.0) {
|
||||
const double my_rate = rateByMode(child_phases_summed.res_prod_rates,
|
||||
const double my_rate = rateByMode(child_phases_summed.res_prod_rates,
|
||||
child_phases_summed.surf_prod_rates,
|
||||
mode);
|
||||
if (std::fabs(my_rate) > target_rate) {
|
||||
@@ -377,7 +377,7 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (production_violated) {
|
||||
switch (prodSpec().procedure_) {
|
||||
case ProductionSpecification::WELL:
|
||||
@@ -387,7 +387,7 @@ namespace Opm
|
||||
return false;
|
||||
case ProductionSpecification::RATE:
|
||||
std::cout << "Applying group control" << std::endl;
|
||||
applyProdGroupControl(production_mode_violated,
|
||||
applyProdGroupControl(production_mode_violated,
|
||||
getTarget(production_mode_violated),
|
||||
true);
|
||||
return false;
|
||||
@@ -396,7 +396,7 @@ namespace Opm
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
summed_phases += child_phases_summed;
|
||||
return true;
|
||||
}
|
||||
@@ -406,19 +406,19 @@ namespace Opm
|
||||
children_.push_back(child);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int WellsGroup::numberOfLeafNodes() {
|
||||
// This could probably use some caching, but seeing as how the number of
|
||||
// This could probably use some caching, but seeing as how the number of
|
||||
// wells is relatively small, we'll do without for now.
|
||||
int sum = 0;
|
||||
|
||||
|
||||
for(size_t i = 0; i < children_.size(); i++) {
|
||||
sum += children_[i]->numberOfLeafNodes();
|
||||
}
|
||||
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
std::pair<WellNode*, double> WellsGroup::getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
|
||||
const std::vector<double>& well_surfacerates_phase,
|
||||
ProductionSpecification::ControlMode mode)
|
||||
@@ -434,7 +434,7 @@ namespace Opm
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
void WellsGroup::applyProdGroupControls()
|
||||
{
|
||||
ProductionSpecification::ControlMode prod_mode = prodSpec().control_mode_;
|
||||
@@ -449,12 +449,12 @@ namespace Opm
|
||||
THROW("Can't apply group control for group " << name() << " as the sum of guide rates for all group controlled wells is zero.");
|
||||
}
|
||||
for (size_t i = 0; i < children_.size(); ++i ) {
|
||||
// Apply for all children.
|
||||
// Apply for all children.
|
||||
// Note, we do _not_ want to call the applyProdGroupControl in this object,
|
||||
// as that would check if we're under group control, something we're not.
|
||||
const double children_guide_rate = children_[i]->productionGuideRate(true);
|
||||
children_[i]->applyProdGroupControl(prod_mode,
|
||||
(children_guide_rate / my_guide_rate) * getTarget(prod_mode),
|
||||
children_[i]->applyProdGroupControl(prod_mode,
|
||||
(children_guide_rate / my_guide_rate) * getTarget(prod_mode),
|
||||
false);
|
||||
}
|
||||
break;
|
||||
@@ -470,7 +470,7 @@ namespace Opm
|
||||
THROW("Unhandled group production control type " << prod_mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WellsGroup::applyInjGroupControls()
|
||||
{
|
||||
InjectionSpecification::ControlMode inj_mode = injSpec().control_mode_;
|
||||
@@ -480,7 +480,7 @@ namespace Opm
|
||||
{
|
||||
const double my_guide_rate = injectionGuideRate(true);
|
||||
for (size_t i = 0; i < children_.size(); ++i) {
|
||||
// Apply for all children.
|
||||
// Apply for all children.
|
||||
// Note, we do _not_ want to call the applyProdGroupControl in this object,
|
||||
// as that would check if we're under group control, something we're not.
|
||||
const double children_guide_rate = children_[i]->injectionGuideRate(true);
|
||||
@@ -505,11 +505,11 @@ namespace Opm
|
||||
THROW("Unhandled group injection control mode " << inj_mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Calculates the production guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
double WellsGroup::productionGuideRate(bool only_group)
|
||||
double WellsGroup::productionGuideRate(bool only_group)
|
||||
{
|
||||
double sum = 0.0;
|
||||
for (size_t i = 0; i < children_.size(); ++i) {
|
||||
@@ -519,7 +519,7 @@ namespace Opm
|
||||
}
|
||||
|
||||
/// Calculates the injection guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
double WellsGroup::injectionGuideRate(bool only_group)
|
||||
{
|
||||
@@ -530,7 +530,7 @@ namespace Opm
|
||||
return sum;
|
||||
}
|
||||
|
||||
/// Gets the total production flow of the given phase.
|
||||
/// Gets the total production flow of the given phase.
|
||||
/// \param[in] phase_flows A vector containing rates by phase for each well.
|
||||
/// Is assumed to be ordered the same way as the related Wells-struct,
|
||||
/// with all phase rates of a single well adjacent in the array.
|
||||
@@ -576,7 +576,7 @@ namespace Opm
|
||||
const double total_reinjected = - total_produced; // Production negative, injection positive
|
||||
const double my_guide_rate = injectionGuideRate(true);
|
||||
for (size_t i = 0; i < children_.size(); ++i) {
|
||||
// Apply for all children.
|
||||
// Apply for all children.
|
||||
// Note, we do _not_ want to call the applyProdGroupControl in this object,
|
||||
// as that would check if we're under group control, something we're not.
|
||||
const double children_guide_rate = children_[i]->injectionGuideRate(true);
|
||||
@@ -605,7 +605,7 @@ namespace Opm
|
||||
const double total_reinjected = - total_produced; // Production negative, injection positive
|
||||
const double my_guide_rate = injectionGuideRate(true);
|
||||
for (size_t i = 0; i < children_.size(); ++i) {
|
||||
// Apply for all children.
|
||||
// Apply for all children.
|
||||
// Note, we do _not_ want to call the applyProdGroupControl in this object,
|
||||
// as that would check if we're under group control, something we're not.
|
||||
const double children_guide_rate = children_[i]->injectionGuideRate(true);
|
||||
@@ -613,14 +613,14 @@ namespace Opm
|
||||
(children_guide_rate / my_guide_rate) * total_reinjected * injSpec().voidage_replacment_fraction_,
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ============== WellNode members ============
|
||||
|
||||
|
||||
|
||||
|
||||
WellNode::WellNode(const std::string& myname,
|
||||
const ProductionSpecification& prod_spec,
|
||||
const InjectionSpecification& inj_spec,
|
||||
@@ -730,13 +730,13 @@ namespace Opm
|
||||
wells_ = wells;
|
||||
self_index_ = self_index;
|
||||
}
|
||||
|
||||
int WellNode::numberOfLeafNodes()
|
||||
|
||||
int WellNode::numberOfLeafNodes()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void WellNode::shutWell()
|
||||
|
||||
void WellNode::shutWell()
|
||||
{
|
||||
if (shut_well_) {
|
||||
// We set the tilde of the current control
|
||||
@@ -774,13 +774,13 @@ namespace Opm
|
||||
&well_surfacerates_phase[index],
|
||||
mode));
|
||||
}
|
||||
|
||||
|
||||
void WellNode::applyInjGroupControl(const InjectionSpecification::ControlMode control_mode,
|
||||
const double target,
|
||||
const bool forced)
|
||||
{
|
||||
// Not changing if we're not forced to change
|
||||
if (!forced
|
||||
if (!forced
|
||||
&& (injSpec().control_mode_ != InjectionSpecification::GRUP && injSpec().control_mode_ != InjectionSpecification::NONE)) {
|
||||
return;
|
||||
}
|
||||
@@ -818,7 +818,7 @@ namespace Opm
|
||||
}
|
||||
|
||||
|
||||
/// Gets the total production flow of the given phase.
|
||||
/// Gets the total production flow of the given phase.
|
||||
/// \param[in] phase_flows A vector containing rates by phase for each well.
|
||||
/// Is assumed to be ordered the same way as the related Wells-struct,
|
||||
/// with all phase rates of a single well adjacent in the array.
|
||||
@@ -832,7 +832,7 @@ namespace Opm
|
||||
}
|
||||
return phase_flows[self_index_*phaseUsage().num_phases + phaseUsage().phase_pos[phase]];
|
||||
}
|
||||
|
||||
|
||||
WellType WellNode::type() const {
|
||||
return wells_->type[self_index_];
|
||||
}
|
||||
@@ -867,7 +867,7 @@ namespace Opm
|
||||
}
|
||||
// We're a producer, so we need to negate the input
|
||||
double ntarget = -target;
|
||||
|
||||
|
||||
double distr[3] = { 0.0, 0.0, 0.0 };
|
||||
const int* phase_pos = phaseUsage().phase_pos;
|
||||
const int* phase_used = phaseUsage().phase_used;
|
||||
@@ -895,7 +895,7 @@ namespace Opm
|
||||
distr[phase_pos[BlackoilPhases::Vapour]] = 1.0;
|
||||
break;
|
||||
case ProductionSpecification::LRAT:
|
||||
std::cout << "applying rate" << std::endl;
|
||||
std::cout << "applying rate" << std::endl;
|
||||
wct = SURFACE_RATE;
|
||||
if (!phase_used[BlackoilPhases::Liquid]) {
|
||||
THROW("Oil phase not active and LRAT control specified.");
|
||||
@@ -929,21 +929,21 @@ namespace Opm
|
||||
set_current_control(self_index_, group_control_index_, wells_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void WellNode::applyProdGroupControls()
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
|
||||
void WellNode::applyInjGroupControls()
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
|
||||
/// Calculates the production guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
double WellNode::productionGuideRate(bool only_group)
|
||||
double WellNode::productionGuideRate(bool only_group)
|
||||
{
|
||||
if (!only_group || prodSpec().control_mode_ == ProductionSpecification::GRUP) {
|
||||
return prodSpec().guide_rate_;
|
||||
@@ -952,7 +952,7 @@ namespace Opm
|
||||
}
|
||||
|
||||
/// Calculates the injection guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
double WellNode::injectionGuideRate(bool only_group)
|
||||
{
|
||||
@@ -961,8 +961,8 @@ namespace Opm
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
// Need to forward declare this one, some of the methods in the base
|
||||
// Need to forward declare this one, some of the methods in the base
|
||||
// class returns pointers to it.
|
||||
class WellNode;
|
||||
|
||||
|
||||
/// Basic information needed for group control (each group should typically
|
||||
/// not exceed the sum of its leaf nodes)
|
||||
struct WellPhasesSummed
|
||||
@@ -59,37 +59,37 @@ namespace Opm
|
||||
|
||||
/// The unique identifier for the well or well group.
|
||||
const std::string& name();
|
||||
|
||||
|
||||
/// Production specifications for the well or well group.
|
||||
const ProductionSpecification& prodSpec() const;
|
||||
|
||||
|
||||
/// Injection specifications for the well or well group.
|
||||
const InjectionSpecification& injSpec() const;
|
||||
|
||||
|
||||
/// Production specifications for the well or well group.
|
||||
ProductionSpecification& prodSpec();
|
||||
|
||||
|
||||
/// Injection specifications for the well or well group.
|
||||
InjectionSpecification& injSpec();
|
||||
|
||||
/// Phase usage information.
|
||||
const PhaseUsage& phaseUsage() const;
|
||||
|
||||
|
||||
/// \returns true if the object is a leaf node (WellNode), false otherwise.
|
||||
virtual bool isLeafNode() const;
|
||||
|
||||
/// \returns the pointer to the WellsGroupInterface with the given name. NULL if
|
||||
|
||||
/// \returns the pointer to the WellsGroupInterface with the given name. NULL if
|
||||
/// the name is not found.a
|
||||
virtual WellsGroupInterface* findGroup(const std::string& name_of_node) = 0;
|
||||
|
||||
/// Sets the parent
|
||||
/// \param[in] parent the pointer to the parent
|
||||
void setParent(WellsGroupInterface* parent);
|
||||
|
||||
|
||||
/// Gets the parent of the group, NULL if no parent.
|
||||
const WellsGroupInterface* getParent() const;
|
||||
|
||||
/// Calculates the number of leaf nodes in the given group.
|
||||
|
||||
/// Calculates the number of leaf nodes in the given group.
|
||||
/// A leaf node is defined to have one leaf node in its group.
|
||||
virtual int numberOfLeafNodes() = 0;
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Opm
|
||||
/// \endcode
|
||||
///
|
||||
/// \note It's highly recommended to use the conditionsMet found in WellsManager.
|
||||
/// \param[in] well_bhp A vector containing the bhp for each well. Is assumed
|
||||
/// \param[in] well_bhp A vector containing the bhp for each well. Is assumed
|
||||
/// to be ordered the same way as the related Wells-struct.
|
||||
/// \param[in] well_reservoirrates_phase
|
||||
/// A vector containing reservoir rates by phase for each well.
|
||||
@@ -121,7 +121,7 @@ namespace Opm
|
||||
const std::vector<double>& well_reservoirrates_phase,
|
||||
const std::vector<double>& well_surfacerates_phase,
|
||||
WellPhasesSummed& summed_phases) = 0;
|
||||
|
||||
|
||||
/// Sets the current active control to the provided one for all injectors within the group.
|
||||
/// After this call, the combined rate (which rate depending on control_mode) of the group
|
||||
/// shall be equal to target.
|
||||
@@ -154,39 +154,39 @@ namespace Opm
|
||||
virtual std::pair<WellNode*, double> getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
|
||||
const std::vector<double>& well_surfacerates_phase,
|
||||
ProductionSpecification::ControlMode mode) = 0;
|
||||
|
||||
|
||||
/// Gets the target rate for the given mode.
|
||||
double getTarget(ProductionSpecification::ControlMode mode);
|
||||
|
||||
|
||||
/// Gets the target rate for the given mode.
|
||||
double getTarget(InjectionSpecification::ControlMode mode);
|
||||
|
||||
|
||||
/// Applies any production group control relevant to all children nodes.
|
||||
/// If no group control is set, this is called recursively to the children.
|
||||
virtual void applyProdGroupControls() = 0;
|
||||
|
||||
|
||||
/// Applies any injection group control relevant to all children nodes.
|
||||
/// If no group control is set, this is called recursively to the children.
|
||||
virtual void applyInjGroupControls() = 0;
|
||||
|
||||
|
||||
/// Calculates the production guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
virtual double productionGuideRate(bool only_group) = 0;
|
||||
|
||||
|
||||
/// Calculates the injection guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
virtual double injectionGuideRate(bool only_group) = 0;
|
||||
|
||||
/// Gets the total production flow of the given phase.
|
||||
|
||||
/// Gets the total production flow of the given phase.
|
||||
/// \param[in] phase_flows A vector containing rates by phase for each well.
|
||||
/// Is assumed to be ordered the same way as the related Wells-struct,
|
||||
/// with all phase rates of a single well adjacent in the array.
|
||||
/// \param[in] phase The phase for which to sum up.
|
||||
virtual double getTotalProductionFlow(const std::vector<double>& phase_flows,
|
||||
const BlackoilPhases::PhaseIndex phase) = 0;
|
||||
|
||||
|
||||
/// Applies explicit reinjection controls. This must be called at each timestep to be correct.
|
||||
/// \param[in] well_reservoirrates_phase
|
||||
/// A vector containing reservoir rates by phase for each well.
|
||||
@@ -198,16 +198,16 @@ namespace Opm
|
||||
/// with all phase rates of a single well adjacent in the array.
|
||||
virtual void applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
|
||||
const std::vector<double>& well_surfacerates_phase) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
/// Calculates the correct rate for the given ProductionSpecification::ControlMode
|
||||
double rateByMode(const double* res_rates,
|
||||
double rateByMode(const double* res_rates,
|
||||
const double* surf_rates,
|
||||
const ProductionSpecification::ControlMode mode);
|
||||
|
||||
/// Calculates the correct rate for the given InjectionSpecification::ControlMode
|
||||
double rateByMode(const double* res_rates,
|
||||
double rateByMode(const double* res_rates,
|
||||
const double* surf_rates,
|
||||
const InjectionSpecification::ControlMode mode);
|
||||
|
||||
@@ -233,12 +233,12 @@ namespace Opm
|
||||
virtual WellsGroupInterface* findGroup(const std::string& name_of_node);
|
||||
|
||||
void addChild(boost::shared_ptr<WellsGroupInterface> child);
|
||||
|
||||
|
||||
virtual bool conditionsMet(const std::vector<double>& well_bhp,
|
||||
const std::vector<double>& well_reservoirrates_phase,
|
||||
const std::vector<double>& well_surfacerates_phase,
|
||||
WellPhasesSummed& summed_phases);
|
||||
|
||||
|
||||
virtual int numberOfLeafNodes();
|
||||
virtual std::pair<WellNode*, double> getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
|
||||
const std::vector<double>& well_surfacerates_phase,
|
||||
@@ -261,33 +261,33 @@ namespace Opm
|
||||
virtual void applyProdGroupControl(const ProductionSpecification::ControlMode control_mode,
|
||||
const double target,
|
||||
bool forced);
|
||||
|
||||
|
||||
/// Applies any production group control relevant to all children nodes.
|
||||
/// If no group control is set, this is called recursively to the children.
|
||||
virtual void applyProdGroupControls();
|
||||
|
||||
|
||||
/// Applies any injection group control relevant to all children nodes.
|
||||
/// If no group control is set, this is called recursively to the children.
|
||||
virtual void applyInjGroupControls();
|
||||
|
||||
|
||||
/// Calculates the production guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
virtual double productionGuideRate(bool only_group);
|
||||
|
||||
|
||||
/// Calculates the injection guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
virtual double injectionGuideRate(bool only_group);
|
||||
|
||||
/// Gets the total production flow of the given phase.
|
||||
|
||||
/// Gets the total production flow of the given phase.
|
||||
/// \param[in] phase_flows A vector containing rates by phase for each well.
|
||||
/// Is assumed to be ordered the same way as the related Wells-struct,
|
||||
/// with all phase rates of a single well adjacent in the array.
|
||||
/// \param[in] phase The phase for which to sum up.
|
||||
virtual double getTotalProductionFlow(const std::vector<double>& phase_flows,
|
||||
const BlackoilPhases::PhaseIndex phase);
|
||||
|
||||
|
||||
/// Applies explicit reinjection controls. This must be called at each timestep to be correct.
|
||||
/// \param[in] well_reservoirrates_phase
|
||||
/// A vector containing reservoir rates by phase for each well.
|
||||
@@ -319,16 +319,16 @@ namespace Opm
|
||||
const std::vector<double>& well_reservoirrates_phase,
|
||||
const std::vector<double>& well_surfacerates_phase,
|
||||
WellPhasesSummed& summed_phases);
|
||||
|
||||
|
||||
virtual bool isLeafNode() const;
|
||||
|
||||
|
||||
void setWellsPointer(Wells* wells, int self_index);
|
||||
|
||||
|
||||
virtual int numberOfLeafNodes();
|
||||
|
||||
|
||||
// Shuts the well (in the well struct)
|
||||
void shutWell();
|
||||
|
||||
|
||||
virtual std::pair<WellNode*, double> getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
|
||||
const std::vector<double>& well_surfacerates_phase,
|
||||
ProductionSpecification::ControlMode mode);
|
||||
@@ -350,26 +350,26 @@ namespace Opm
|
||||
virtual void applyProdGroupControl(const ProductionSpecification::ControlMode control_mode,
|
||||
const double target,
|
||||
bool forced);
|
||||
|
||||
|
||||
/// Applies any production group control relevant to all children nodes.
|
||||
/// If no group control is set, this is called recursively to the children.
|
||||
virtual void applyProdGroupControls();
|
||||
|
||||
|
||||
/// Applies any injection group control relevant to all children nodes.
|
||||
/// If no group control is set, this is called recursively to the children.
|
||||
virtual void applyInjGroupControls();
|
||||
|
||||
|
||||
/// Calculates the production guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
virtual double productionGuideRate(bool only_group);
|
||||
|
||||
|
||||
/// Calculates the injection guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
virtual double injectionGuideRate(bool only_group);
|
||||
|
||||
/// Gets the total production flow of the given phase.
|
||||
|
||||
/// Gets the total production flow of the given phase.
|
||||
/// \param[in] phase_flows A vector containing rates by phase for each well.
|
||||
/// Is assumed to be ordered the same way as the related Wells-struct,
|
||||
/// with all phase rates of a single well adjacent in the array.
|
||||
@@ -379,7 +379,7 @@ namespace Opm
|
||||
|
||||
/// Returns the type of the well.
|
||||
WellType type() const;
|
||||
|
||||
|
||||
/// Applies explicit reinjection controls. This must be called at each timestep to be correct.
|
||||
/// \param[in] well_reservoirrates_phase
|
||||
/// A vector containing reservoir rates by phase for each well.
|
||||
@@ -402,7 +402,7 @@ namespace Opm
|
||||
/// Creates the WellsGroupInterface for the given name
|
||||
/// \param[in] name the name of the wells group.
|
||||
/// \param[in] deck the deck from which to fetch information.
|
||||
boost::shared_ptr<WellsGroupInterface> createWellsGroup(const std::string& name,
|
||||
boost::shared_ptr<WellsGroupInterface> createWellsGroup(const std::string& name,
|
||||
const EclipseGridParser& deck);
|
||||
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ namespace Opm
|
||||
: w_(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Construct from existing wells object.
|
||||
WellsManager::WellsManager(struct Wells* W)
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Opm
|
||||
|
||||
/// Does the "deck" define any wells?
|
||||
bool empty() const;
|
||||
|
||||
|
||||
/// Access the managed Wells.
|
||||
/// The method is named similarly to c_str() in std::string,
|
||||
/// to make it clear that we are returning a C-compatible struct.
|
||||
@@ -71,7 +71,7 @@ namespace Opm
|
||||
|
||||
/// Access the well group hierarchy.
|
||||
const WellCollection& wellCollection() const;
|
||||
|
||||
|
||||
/// Checks if each condition is met, applies well controls where needed
|
||||
/// (that is, it either changes the active control of violating wells, or shuts
|
||||
/// down wells). Only one change is applied per invocation. Typical use will be
|
||||
@@ -81,7 +81,7 @@ namespace Opm
|
||||
/// solve_pressure();
|
||||
/// }
|
||||
/// \endcode
|
||||
/// \param[in] well_bhp A vector containing the bhp for each well. Is assumed
|
||||
/// \param[in] well_bhp A vector containing the bhp for each well. Is assumed
|
||||
/// to be ordered the same way as the related Wells-struct.
|
||||
/// \param[in] well_reservoirrates_phase
|
||||
/// A vector containing reservoir rates by phase for each well.
|
||||
@@ -95,7 +95,7 @@ namespace Opm
|
||||
bool conditionsMet(const std::vector<double>& well_bhp,
|
||||
const std::vector<double>& well_reservoirrates_phase,
|
||||
const std::vector<double>& well_surfacerates_phase);
|
||||
|
||||
|
||||
/// Applies explicit reinjection controls. This must be called at each timestep to be correct.
|
||||
/// \param[in] well_reservoirrates_phase
|
||||
/// A vector containing reservoir rates by phase for each well.
|
||||
@@ -117,7 +117,7 @@ namespace Opm
|
||||
Wells* w_;
|
||||
WellCollection well_collection_;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -60,8 +60,8 @@ int main(int argc, char** argv)
|
||||
Opm::BlackoilPvtProperties pvt;
|
||||
int samples = param.getDefault("dead_tab_size", 1025);
|
||||
pvt.init(deck, samples);
|
||||
|
||||
|
||||
|
||||
|
||||
const int n = 1;
|
||||
std::fstream inos(input_file.c_str());
|
||||
if(!inos.good()){
|
||||
@@ -103,7 +103,7 @@ int main(int argc, char** argv)
|
||||
double p[n];
|
||||
double z[max_np*n];
|
||||
int cells[n] = { 0 };
|
||||
inos >> p[0];
|
||||
inos >> p[0];
|
||||
for(int i=0; i < np; ++i){
|
||||
inos >> z[i];
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ int main(int argc, char** argv)
|
||||
grid.cartdims[1] = 1;
|
||||
grid.cartdims[2] = 1;
|
||||
Opm::BlackoilPropertiesFromDeck props(deck, grid, param);
|
||||
|
||||
|
||||
std::fstream inos(input_file.c_str());//, std::fstream::in);
|
||||
if(!inos.good()){
|
||||
std::cout << "Could not open :" << input_file << std::endl;
|
||||
|
||||
+23
-23
@@ -38,13 +38,13 @@ static
|
||||
void cell_nodes(const UnstructuredGrid * c_grid , int cell , std::vector<int>& nodes) {
|
||||
int face_offset = c_grid->cell_facepos[cell];
|
||||
int num_faces = c_grid->cell_facepos[cell + 1] - face_offset;
|
||||
|
||||
|
||||
nodes.clear();
|
||||
//printf("cell: %d \n",cell);
|
||||
for (int iface = 0; iface < num_faces; iface++) {
|
||||
int face = c_grid->cell_faces[ face_offset + iface];
|
||||
//printf("face[%d] = %d \n",iface , face );
|
||||
|
||||
|
||||
{
|
||||
int node_offset = c_grid->face_nodepos[ face ];
|
||||
int num_nodes = c_grid->face_nodepos[ face + 1] - node_offset;
|
||||
@@ -84,22 +84,22 @@ void cell_nodes(const UnstructuredGrid * c_grid , int cell , std::vector<int>& n
|
||||
static
|
||||
void eclExport(Opm::GridManager& grid) {
|
||||
const UnstructuredGrid * c_grid = grid.c_grid();
|
||||
|
||||
|
||||
printf("dimensions : %d \n",c_grid->dimensions);
|
||||
printf("number of cells : %d \n",c_grid->number_of_cells);
|
||||
printf("number of nodes : %d \n",c_grid->number_of_nodes);
|
||||
printf("number of faces : %d \n",c_grid->number_of_faces);
|
||||
printf("length(face_nodes) : %d \n",c_grid->face_nodepos[ c_grid->number_of_faces ]);
|
||||
printf("cartdims : %d %d %d \n",
|
||||
c_grid->cartdims[0] ,
|
||||
c_grid->cartdims[1] ,
|
||||
c_grid->cartdims[2]);
|
||||
c_grid->cartdims[0] ,
|
||||
c_grid->cartdims[1] ,
|
||||
c_grid->cartdims[2]);
|
||||
|
||||
printf("global_cell : %d %d %d %d %d\n",
|
||||
c_grid->global_cell[0] ,
|
||||
c_grid->global_cell[1] ,
|
||||
c_grid->global_cell[2] ,
|
||||
c_grid->global_cell[3] ,
|
||||
c_grid->global_cell[0] ,
|
||||
c_grid->global_cell[1] ,
|
||||
c_grid->global_cell[2] ,
|
||||
c_grid->global_cell[3] ,
|
||||
c_grid->global_cell[4]);
|
||||
|
||||
{
|
||||
@@ -109,20 +109,20 @@ void eclExport(Opm::GridManager& grid) {
|
||||
cell_nodes( c_grid , 20 , nodes );
|
||||
cell_nodes( c_grid , 25 , nodes );
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
ecl_grid_type * ecl_grid;
|
||||
int num_coords = c_grid->number_of_cells;
|
||||
int coords_size = 4;
|
||||
int nx = c_grid->cartdims[0];
|
||||
int ny = c_grid->cartdims[1];
|
||||
int nz = c_grid->cartdims[2];
|
||||
|
||||
int nz = c_grid->cartdims[2];
|
||||
|
||||
int ** coords;
|
||||
float ** corners;
|
||||
// float * mapaxes = NULL;
|
||||
std::vector<int> nodes;
|
||||
|
||||
|
||||
corners = (float **) malloc( num_coords * sizeof * corners );
|
||||
coords = (int **) malloc( num_coords * sizeof * coords );
|
||||
|
||||
@@ -132,12 +132,12 @@ void eclExport(Opm::GridManager& grid) {
|
||||
corners[c] = (float *) malloc( 24 * sizeof * corners[c] );
|
||||
coords[c] = (int *) malloc( coords_size * sizeof * coords[c] );
|
||||
}
|
||||
|
||||
|
||||
for (c=0; c < num_coords; c++) {
|
||||
cell_nodes( c_grid , c , nodes );
|
||||
for (int p=0; p < 8; p++) {
|
||||
int n = nodes[p];
|
||||
for (int d=0; d < c_grid->dimensions; d++)
|
||||
for (int d=0; d < c_grid->dimensions; d++)
|
||||
corners[c][3*p + d] = c_grid->node_coordinates[ c_grid->dimensions * n + d ];
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ void eclExport(Opm::GridManager& grid) {
|
||||
{
|
||||
int g = c_grid->global_cell[ c ];
|
||||
k = g / nx*ny; g -= k * nx*ny;
|
||||
j = g / nx; g -= j * nx;
|
||||
j = g / nx; g -= j * nx;
|
||||
i = g;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ void eclExport(Opm::GridManager& grid) {
|
||||
ecl_grid = ecl_grid_alloc( "/private/joaho/ERT/NR/libenkf/src/Gurbat/EXAMPLE_01_BASE.EGRID" );
|
||||
printf("Grid loaded ... \n");
|
||||
ecl_grid_free( ecl_grid );
|
||||
|
||||
|
||||
printf("Grid discarded ... \n");
|
||||
|
||||
ecl_grid = ecl_grid_alloc_GRID_data( num_coords , nx , ny , nz , coords_size , coords , corners , NULL );
|
||||
@@ -174,7 +174,7 @@ void eclExport(Opm::GridManager& grid) {
|
||||
}
|
||||
|
||||
ecl_grid_free( ecl_grid );
|
||||
|
||||
|
||||
{
|
||||
for (int c=0; c < num_coords; c++) {
|
||||
free(corners[c]);
|
||||
@@ -189,7 +189,7 @@ void eclExport(Opm::GridManager& grid) {
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
#ifdef HAVE_ERT
|
||||
ecl_grid_type * create_ecl_grid( const struct UnstructuredGrid * g) {
|
||||
int num_coords = g->number_of_cells;
|
||||
@@ -200,7 +200,7 @@ ecl_grid_type * create_ecl_grid( const struct UnstructuredGrid * g) {
|
||||
int ** coords;
|
||||
float ** corners;
|
||||
float * mapaxes = NULL;
|
||||
|
||||
|
||||
corners = malloc( num_coords * sizeof * corners );
|
||||
coords = malloc( num_coords * sizeof * coords );
|
||||
|
||||
@@ -221,7 +221,7 @@ ecl_grid_type * create_ecl_grid( const struct UnstructuredGrid * g) {
|
||||
coords[global_index][1] = j;
|
||||
coords[global_index][2] = k;
|
||||
coords[global_index][3] = 1;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,6 +255,6 @@ int main(int /*argc*/ , char **argv)
|
||||
//eclParser.saveEGRID_INIT("/tmp" , "OPM" );
|
||||
|
||||
grid.reset(new Opm::GridManager(eclParser));
|
||||
|
||||
|
||||
props.reset(new Opm::IncompPropertiesFromDeck(eclParser , *grid->c_grid()));
|
||||
}
|
||||
@@ -96,7 +96,7 @@ int main()
|
||||
std::vector<double> AB(nrowAB*N, 0.);
|
||||
BandMatrixCoeff bmc(N, ku, kl);
|
||||
|
||||
// Rewrite AA matrix in band format AB
|
||||
// Rewrite AA matrix in band format AB
|
||||
for (MAT_SIZE_T i = 0; i < N; ++i) {
|
||||
for (MAT_SIZE_T j = -1; j < 2; ++j) {
|
||||
if (i + j > -1 && i + j < N)
|
||||
|
||||
@@ -61,7 +61,7 @@ int main(int argc, char** argv)
|
||||
// Size of mappings found
|
||||
std::cout << " faces_to_vertices " << vag_grid.faces_to_vertices.value.size() << endl;
|
||||
std::cout << " volumes_to_faces " << vag_grid.volumes_to_vertices.value.size() << endl;
|
||||
|
||||
|
||||
grid = allocate_grid(3,
|
||||
vag_grid.number_of_volumes,
|
||||
vag_grid.number_of_faces,
|
||||
@@ -70,15 +70,15 @@ int main(int argc, char** argv)
|
||||
vag_grid.number_of_vertices);
|
||||
vagToUnstructuredGrid(vag_grid,*grid);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//}
|
||||
// {
|
||||
std::cout << "*************************************************************\n";
|
||||
VAG vag_grid_new;
|
||||
unstructuredGridToVag(*grid,vag_grid_new);
|
||||
writeVagFormat(std::cout,vag_grid_new);
|
||||
writeVagFormat(std::cout,vag_grid_new);
|
||||
// }
|
||||
destroy_grid(grid);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
//===========================================================================
|
||||
//
|
||||
// File: test_readpolymer.cpp
|
||||
//
|
||||
// Created: Thu Jan 12 15:18:46 2012
|
||||
//
|
||||
//
|
||||
// File: test_readpolymer.cpp
|
||||
//
|
||||
// Created: Thu Jan 12 15:18:46 2012
|
||||
//
|
||||
// Author: Bjørn Spjelkavik <bsp@sintef.no>
|
||||
//
|
||||
//
|
||||
// Revision: $Id$
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -42,13 +42,13 @@ int main(int argc, char** argv)
|
||||
if (parser.hasField("PLYROCK")) {
|
||||
parser.getPLYROCK().write(std::cout);
|
||||
}
|
||||
if (parser.hasField("PLYADS")) {
|
||||
if (parser.hasField("PLYADS")) {
|
||||
parser.getPLYADS().write(std::cout);
|
||||
}
|
||||
if (parser.hasField("TLMIXPAR")) {
|
||||
parser.getTLMIXPAR().write(std::cout);
|
||||
}
|
||||
if (parser.hasField("PLYMAX")) {
|
||||
if (parser.hasField("PLYMAX")) {
|
||||
parser.getPLYMAX().write(std::cout);
|
||||
}
|
||||
if (parser.hasField("WPOLYMER")) {
|
||||
|
||||
@@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE(construction_and_queries)
|
||||
row[j] = elem[s];
|
||||
}
|
||||
BOOST_CHECK(st2 == st2_allocate);
|
||||
|
||||
|
||||
// One element too few.
|
||||
BOOST_CHECK_THROW(const SparseTable<int> st3(elem, elem + num_elem - 1, rowsizes, rowsizes + num_rows), std::exception);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
/// in subdirectories.
|
||||
/// \snippet tutorial1.cpp including headers
|
||||
|
||||
/// \internal [including headers]
|
||||
/// \internal [including headers]
|
||||
#include "config.h"
|
||||
|
||||
#include <opm/core/grid.h>
|
||||
@@ -53,7 +53,7 @@ int main()
|
||||
int nx = 4;
|
||||
int ny = 3;
|
||||
int nz = 2;
|
||||
/// \internal [num blocks]
|
||||
/// \internal [num blocks]
|
||||
/// \endinternal
|
||||
/// The size of each block is 1m x 1m x 1m. The default units are always the
|
||||
/// standard units (SI). But other units can easily be dealt with, see Opm::unit.
|
||||
@@ -113,6 +113,6 @@ int main()
|
||||
|
||||
/// \page tutorial1
|
||||
/// \details
|
||||
/// \section pythonscript1 Python script to generate figures:
|
||||
/// \section pythonscript1 Python script to generate figures:
|
||||
/// \snippet generate_doc_figures.py tutorial1
|
||||
|
||||
@@ -47,11 +47,11 @@
|
||||
|
||||
/// \page tutorial2
|
||||
/// \section commentedcode2 Program walk-through.
|
||||
///
|
||||
///
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
/// \page tutorial2
|
||||
/// We construct a Cartesian grid
|
||||
/// \snippet tutorial2.cpp cartesian grid
|
||||
@@ -117,9 +117,9 @@ int main()
|
||||
/// We take UMFPACK as the linear solver for the pressure solver
|
||||
/// (this library has therefore to be installed).
|
||||
/// \snippet tutorial2.cpp linsolver
|
||||
/// \internal [linsolver]
|
||||
/// \internal [linsolver]
|
||||
Opm::LinearSolverUmfpack linsolver;
|
||||
/// \internal [linsolver]
|
||||
/// \internal [linsolver]
|
||||
/// \endinternal
|
||||
|
||||
/// \page tutorial2
|
||||
@@ -131,7 +131,7 @@ int main()
|
||||
src[num_cells-1] = -src[0];
|
||||
/// \internal [source]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial2
|
||||
/// \details We set up the boundary conditions.
|
||||
/// By default, we obtain no-flow boundary conditions.
|
||||
@@ -151,7 +151,7 @@ int main()
|
||||
Opm::IncompTpfa psolver(*grid.c_grid(), props, linsolver, NULL, NULL, src, NULL);
|
||||
/// \internal [tpfa]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial2
|
||||
/// We declare the state object, that will contain the pressure and face
|
||||
/// flux vectors we are going to compute. The well state
|
||||
@@ -207,5 +207,5 @@ int main()
|
||||
|
||||
/// \page tutorial2
|
||||
/// \details
|
||||
/// \section pythonscript2 python script to generate figures:
|
||||
/// \section pythonscript2 python script to generate figures:
|
||||
/// \snippet generate_doc_figures.py tutorial2
|
||||
+32
-32
@@ -43,12 +43,12 @@
|
||||
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||
|
||||
/// \page tutorial3 Multiphase flow
|
||||
/// The Darcy law gives
|
||||
/// The Darcy law gives
|
||||
/// \f[u_\alpha= -\frac1{\mu_\alpha} K_\alpha\nabla p_\alpha\f]
|
||||
/// where \f$\mu_\alpha\f$ and \f$K_\alpha\f$ represent the viscosity
|
||||
/// and the permeability tensor for each phase \f$\alpha\f$. In the two phase
|
||||
/// case, we have either \f$\alpha=w\f$ or \f$\alpha=o\f$.
|
||||
/// In this tutorial, we do not take into account capillary pressure so that
|
||||
/// case, we have either \f$\alpha=w\f$ or \f$\alpha=o\f$.
|
||||
/// In this tutorial, we do not take into account capillary pressure so that
|
||||
/// \f$p=p_w=p_o\f$ and gravity
|
||||
/// effects. We denote by \f$K\f$ the absolute permeability tensor and each phase
|
||||
/// permeability is defined through its relative permeability by the expression
|
||||
@@ -67,21 +67,21 @@
|
||||
/// \f[u=u_w+u_o.\f]
|
||||
/// Let the total mobility be equal to
|
||||
/// \f[\lambda=\lambda_w+\lambda_o\f]
|
||||
/// Then, we have
|
||||
/// Then, we have
|
||||
/// \f[u=-\lambda K\nabla p.\f]
|
||||
/// The set of equations
|
||||
/// \f[\nabla\cdot u=\frac{q_w}{\rho_w}+\frac{q_o}{\rho_o},\quad u=-\lambda K\nabla p.\f]
|
||||
/// is referred to as the <strong>pressure equation</strong>. We introduce
|
||||
/// is referred to as the <strong>pressure equation</strong>. We introduce
|
||||
/// the fractional flow \f$f_w\f$
|
||||
/// as
|
||||
/// \f[f_w=\frac{\lambda_w}{\lambda_w+\lambda_o}\f]
|
||||
/// and obtain
|
||||
/// \f[\phi\frac{\partial s_w}{\partial t}+\nabla\cdot(f_w u)=\frac{q_w}{\rho_w}\f]
|
||||
/// which is referred to as the <strong>transport equation</strong>. The pressure and
|
||||
/// transport equation are coupled. In this tutorial, we implement a splitting scheme,
|
||||
/// which is referred to as the <strong>transport equation</strong>. The pressure and
|
||||
/// transport equation are coupled. In this tutorial, we implement a splitting scheme,
|
||||
/// where, at each time step, we decouple the two equations. We solve first
|
||||
/// the pressure equation and then update the water saturation by solving
|
||||
/// the transport equation assuming that \f$u\f$ is constant in time in the time step
|
||||
/// the transport equation assuming that \f$u\f$ is constant in time in the time step
|
||||
/// interval we are considering.
|
||||
|
||||
|
||||
@@ -95,8 +95,8 @@
|
||||
int main ()
|
||||
{
|
||||
/// \internal [main]
|
||||
/// \endinternal
|
||||
|
||||
/// \endinternal
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details
|
||||
/// We define the grid. A Cartesian grid with 400 cells,
|
||||
@@ -120,11 +120,11 @@ int main ()
|
||||
const UnstructuredGrid& grid = *grid_manager.c_grid();
|
||||
int num_cells = grid.number_of_cells;
|
||||
/// \internal [grid]
|
||||
/// \endinternal
|
||||
/// \endinternal
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details
|
||||
/// We define the properties of the fluid.\n
|
||||
/// We define the properties of the fluid.\n
|
||||
/// Number of phases, phase densities, phase viscosities,
|
||||
/// rock porosity and permeability.
|
||||
///
|
||||
@@ -142,37 +142,37 @@ int main ()
|
||||
double porosity = 0.5;
|
||||
double permeability = 10.0*milli*darcy;
|
||||
/// \internal [set properties]
|
||||
/// \endinternal
|
||||
/// \endinternal
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details We define the relative permeability function. We use a basic fluid
|
||||
/// description and set this function to be linear. For more realistic fluid, the
|
||||
/// description and set this function to be linear. For more realistic fluid, the
|
||||
/// saturation function may be interpolated from experimental data.
|
||||
/// \snippet tutorial3.cpp relperm
|
||||
/// \internal [relperm]
|
||||
SaturationPropsBasic::RelPermFunc rel_perm_func = SaturationPropsBasic::Linear;
|
||||
/// \internal [relperm]
|
||||
/// \endinternal
|
||||
/// \endinternal
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details We construct a basic fluid and rock property object
|
||||
/// with the properties we have defined above. Each property is
|
||||
/// constant and hold for all cells.
|
||||
/// \snippet tutorial3.cpp properties
|
||||
/// \internal [properties]
|
||||
/// \internal [properties]
|
||||
IncompPropertiesBasic props(num_phases, rel_perm_func, density, viscosity,
|
||||
porosity, permeability, grid.dimensions, num_cells);
|
||||
/// \internal [properties]
|
||||
/// \endinternal
|
||||
/// \endinternal
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details Gravity parameters. Here, we set zero gravity.
|
||||
/// \snippet tutorial3.cpp gravity
|
||||
/// \internal [gravity]
|
||||
const double *grav = 0;
|
||||
std::vector<double> omega;
|
||||
std::vector<double> omega;
|
||||
/// \internal [gravity]
|
||||
/// \endinternal
|
||||
/// \endinternal
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details We set up the source term. Positive numbers indicate that the cell is a source,
|
||||
@@ -183,16 +183,16 @@ int main ()
|
||||
src[0] = 1.;
|
||||
src[num_cells-1] = -1.;
|
||||
/// \internal [source]
|
||||
/// \endinternal
|
||||
/// \endinternal
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details We set up the boundary conditions. Letting bcs be empty is equivalent
|
||||
/// \details We set up the boundary conditions. Letting bcs be empty is equivalent
|
||||
/// to no-flow boundary conditions.
|
||||
/// \snippet tutorial3.cpp boundary
|
||||
/// \internal [boundary]
|
||||
/// \internal [boundary]
|
||||
FlowBCManager bcs;
|
||||
/// \internal [boundary]
|
||||
/// \endinternal
|
||||
/// \endinternal
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details We may now set up the pressure solver. At this point,
|
||||
@@ -204,7 +204,7 @@ int main ()
|
||||
LinearSolverUmfpack linsolver;
|
||||
IncompTpfa psolver(grid, props, linsolver, grav, NULL, src, bcs.c_bcs());
|
||||
/// \internal [pressure solver]
|
||||
/// \endinternal
|
||||
/// \endinternal
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details We set up a state object for the wells. Here, there are
|
||||
@@ -245,7 +245,7 @@ int main ()
|
||||
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details We define a vector which contains all cell indexes. We use this
|
||||
/// \details We define a vector which contains all cell indexes. We use this
|
||||
/// vector to set up parameters on the whole domain.
|
||||
/// \snippet tutorial3.cpp cell indexes
|
||||
/// \internal [cell indexes]
|
||||
@@ -257,7 +257,7 @@ int main ()
|
||||
/// \endinternal
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details
|
||||
/// \details
|
||||
/// We set up a two-phase state object, and
|
||||
/// initialize water saturation to minimum everywhere.
|
||||
/// \snippet tutorial3.cpp two-phase state
|
||||
@@ -280,12 +280,12 @@ int main ()
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details Loop over the time steps.
|
||||
/// \snippet tutorial3.cpp time loop
|
||||
/// \snippet tutorial3.cpp time loop
|
||||
/// \internal [time loop]
|
||||
for (int i = 0; i < num_time_steps; ++i) {
|
||||
/// \internal [time loop]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details Solve the pressure equation
|
||||
@@ -294,7 +294,7 @@ int main ()
|
||||
psolver.solve(dt, state, well_state);
|
||||
/// \internal [solve pressure]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details Solve the transport equation.
|
||||
/// \snippet tutorial3.cpp transport solve
|
||||
@@ -307,7 +307,7 @@ int main ()
|
||||
/// \details Write the output to file.
|
||||
/// \snippet tutorial3.cpp write output
|
||||
/// \internal [write output]
|
||||
vtkfilename.str("");
|
||||
vtkfilename.str("");
|
||||
vtkfilename << "tutorial3-" << std::setw(3) << std::setfill('0') << i << ".vtu";
|
||||
std::ofstream vtkfile(vtkfilename.str().c_str());
|
||||
Opm::DataMap dm;
|
||||
@@ -342,9 +342,9 @@ int main ()
|
||||
/// \page tutorial3
|
||||
/// \details
|
||||
/// \section completecode3 Complete source code:
|
||||
/// \include tutorial3.cpp
|
||||
/// \include tutorial3.cpp
|
||||
|
||||
/// \page tutorial3
|
||||
/// \details
|
||||
/// \section pythonscript3 python script to generate figures:
|
||||
/// \section pythonscript3 python script to generate figures:
|
||||
/// \snippet generate_doc_figures.py tutorial3
|
||||
+40
-41
@@ -76,7 +76,7 @@ int main ()
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details
|
||||
/// We define the properties of the fluid.\n
|
||||
/// We define the properties of the fluid.\n
|
||||
/// Number of phases.
|
||||
/// \snippet tutorial4.cpp Number of phases
|
||||
/// \internal[Number of phases]
|
||||
@@ -85,7 +85,7 @@ int main ()
|
||||
using namespace prefix;
|
||||
/// \internal[Number of phases]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details density vector (one component per phase).
|
||||
/// \snippet tutorial4.cpp density
|
||||
@@ -93,7 +93,7 @@ int main ()
|
||||
std::vector<double> rho(2, 1000.);
|
||||
/// \internal[density]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details viscosity vector (one component per phase).
|
||||
/// \snippet tutorial4.cpp viscosity
|
||||
@@ -101,7 +101,7 @@ int main ()
|
||||
std::vector<double> mu(2, 1.*centi*Poise);
|
||||
/// \internal[viscosity]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details porosity and permeability of the rock.
|
||||
/// \snippet tutorial4.cpp rock
|
||||
@@ -113,7 +113,7 @@ int main ()
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details We define the relative permeability function. We use a basic fluid
|
||||
/// description and set this function to be linear. For more realistic fluid, the
|
||||
/// description and set this function to be linear. For more realistic fluid, the
|
||||
/// saturation function is given by the data.
|
||||
/// \snippet tutorial4.cpp relative permeability
|
||||
/// \internal[relative permeability]
|
||||
@@ -131,13 +131,13 @@ int main ()
|
||||
/// \internal[fluid properties]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details Gravity parameters. Here, we set zero gravity.
|
||||
/// \snippet tutorial4.cpp Gravity
|
||||
/// \internal[Gravity]
|
||||
const double *grav = 0;
|
||||
std::vector<double> omega;
|
||||
std::vector<double> omega;
|
||||
/// \internal[Gravity]
|
||||
/// \endinternal
|
||||
|
||||
@@ -182,7 +182,7 @@ int main ()
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details We define a vector which contains all cell indexes. We use this
|
||||
/// \details We define a vector which contains all cell indexes. We use this
|
||||
/// vector to set up parameters on the whole domains.
|
||||
/// \snippet tutorial4.cpp cell indexes
|
||||
/// \internal[cell indexes]
|
||||
@@ -195,7 +195,7 @@ int main ()
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details We set up the boundary conditions. Letting bcs empty is equivalent
|
||||
/// \details We set up the boundary conditions. Letting bcs empty is equivalent
|
||||
/// to no flow boundary conditions.
|
||||
/// \snippet tutorial4.cpp boundary
|
||||
/// \internal[boundary]
|
||||
@@ -204,7 +204,7 @@ int main ()
|
||||
/// \endinternal
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details
|
||||
/// \details
|
||||
/// We set up a two-phase state object, and
|
||||
/// initialise water saturation to minimum everywhere.
|
||||
/// \snippet tutorial4.cpp two-phase state
|
||||
@@ -214,7 +214,7 @@ int main ()
|
||||
state.setFirstSat(allcells, props, TwophaseState::MinSat);
|
||||
/// \internal[two-phase state]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details This string will contain the name of a VTK output vector.
|
||||
/// \snippet tutorial4.cpp VTK output
|
||||
@@ -232,7 +232,7 @@ int main ()
|
||||
phase_usage.phase_used[BlackoilPhases::Aqua] = 1;
|
||||
phase_usage.phase_used[BlackoilPhases::Liquid] = 1;
|
||||
phase_usage.phase_used[BlackoilPhases::Vapour] = 0;
|
||||
|
||||
|
||||
phase_usage.phase_pos[BlackoilPhases::Aqua] = 0;
|
||||
phase_usage.phase_pos[BlackoilPhases::Liquid] = 1;
|
||||
/// \internal[PhaseUsage-object]
|
||||
@@ -245,7 +245,7 @@ int main ()
|
||||
WellCollection well_collection;
|
||||
/// \internal[well_collection]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details Create the production specification for our top well group.
|
||||
/// We set a target limit for total reservoir rate, and set the controlling
|
||||
@@ -257,18 +257,18 @@ int main ()
|
||||
well_group_prod_spec.control_mode_ = ProductionSpecification::RESV;
|
||||
/// \internal[production specification]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details Create our well group. We hand it an empty injection specification,
|
||||
/// as we don't want to control its injection target. We use the shared_ptr-type because that's
|
||||
/// \details Create our well group. We hand it an empty injection specification,
|
||||
/// as we don't want to control its injection target. We use the shared_ptr-type because that's
|
||||
/// what the interface expects. The first argument is the (unique) name of the group.
|
||||
/// \snippet tutorial4.cpp injection specification
|
||||
/// \internal[injection specification]
|
||||
boost::shared_ptr<WellsGroupInterface> well_group(new WellsGroup("group", well_group_prod_spec, InjectionSpecification(),
|
||||
boost::shared_ptr<WellsGroupInterface> well_group(new WellsGroup("group", well_group_prod_spec, InjectionSpecification(),
|
||||
phase_usage));
|
||||
/// \internal[injection specification]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details We add our well_group to the well_collection
|
||||
/// \snippet tutorial4.cpp well_collection
|
||||
@@ -276,10 +276,10 @@ int main ()
|
||||
well_collection.addChild(well_group);
|
||||
/// \internal[well_collection]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details Create the production specification and Well objects (total 4 wells). We set all our wells to be group controlled.
|
||||
/// \details Create the production specification and Well objects (total 4 wells). We set all our wells to be group controlled.
|
||||
/// We pass in the string argument \C "group" to set the parent group.
|
||||
/// \snippet tutorial4.cpp create well objects
|
||||
/// \internal[create well objects]
|
||||
@@ -289,27 +289,26 @@ int main ()
|
||||
well_name << "well" << i;
|
||||
ProductionSpecification production_specification;
|
||||
production_specification.control_mode_ = ProductionSpecification::GRUP;
|
||||
boost::shared_ptr<WellsGroupInterface> well_leaf_node(new WellNode(well_name.str(), production_specification, InjectionSpecification(),
|
||||
boost::shared_ptr<WellsGroupInterface> well_leaf_node(new WellNode(well_name.str(), production_specification, InjectionSpecification(),
|
||||
phase_usage));
|
||||
well_collection.addChild(well_leaf_node, "group");
|
||||
|
||||
|
||||
}
|
||||
/// \internal[create well objects]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details Now we create the C struct to hold our wells (this is to interface with the solver code). For now we
|
||||
/// \details Now we create the C struct to hold our wells (this is to interface with the solver code).
|
||||
/// \snippet tutorial4.cpp well struct
|
||||
/// \internal[well struct]
|
||||
Wells* wells = create_wells(num_phases, num_wells, num_wells /*number of perforations. We'll only have one perforation per well*/);
|
||||
/// \internal[well struct]
|
||||
/// \endinternal
|
||||
|
||||
///
|
||||
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details We need to add each well to the C API.
|
||||
/// To do this we need to specify the relevant cells the well will be located in (\C well_cells).
|
||||
/// \details We need to add each well to the C API.
|
||||
/// To do this we need to specify the relevant cells the well will be located in (\C well_cells).
|
||||
/// \snippet tutorial4.cpp well cells
|
||||
/// \internal[well cells]
|
||||
for (int i = 0; i < num_wells; ++i) {
|
||||
@@ -322,7 +321,7 @@ int main ()
|
||||
}
|
||||
/// \internal[well cells]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details We need to make the well collection aware of our wells object
|
||||
/// \snippet tutorial4.cpp set well pointer
|
||||
@@ -330,15 +329,15 @@ int main ()
|
||||
well_collection.setWellsPointer(wells);
|
||||
/// \internal[set well pointer]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// We're not using well controls, just group controls, so we need to apply them.
|
||||
/// \snippet tutorial4.cpp apply group controls
|
||||
/// \snippet tutorial4.cpp apply group controls
|
||||
/// \internal[apply group controls]
|
||||
well_collection.applyGroupControls();
|
||||
/// \internal[apply group controls]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details We set up necessary information for the wells
|
||||
/// \snippet tutorial4.cpp init wells
|
||||
@@ -361,7 +360,7 @@ int main ()
|
||||
/// \internal[pressure solver]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details Loop over the time steps.
|
||||
/// \snippet tutorial4.cpp time loop
|
||||
@@ -371,7 +370,7 @@ int main ()
|
||||
/// \endinternal
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details We're solving the pressure until the well conditions are met
|
||||
/// \details We're solving the pressure until the well conditions are met
|
||||
/// or until we reach the maximum number of iterations.
|
||||
/// \snippet tutorial4.cpp well iterations
|
||||
/// \internal[well iterations]
|
||||
@@ -389,9 +388,9 @@ int main ()
|
||||
psolver.solve(dt, state, well_state);
|
||||
/// \internal[pressure solve]
|
||||
/// \endinternal
|
||||
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details We compute the new well rates. Notice that we approximate (wrongly) surfflowsrates := resflowsrate
|
||||
/// \details We compute the new well rates. Notice that we approximate (wrongly) surfflowsrates := resflowsrate
|
||||
/// \snippet tutorial4.cpp compute well rates
|
||||
/// \internal[compute well rates]
|
||||
Opm::computeFractionalFlow(props, allcells, state.saturation(), fractional_flows);
|
||||
@@ -426,7 +425,7 @@ int main ()
|
||||
/// \details Write the output to file.
|
||||
/// \snippet tutorial4.cpp write output
|
||||
/// \internal[write output]
|
||||
vtkfilename.str("");
|
||||
vtkfilename.str("");
|
||||
vtkfilename << "tutorial4-" << std::setw(3) << std::setfill('0') << i << ".vtu";
|
||||
std::ofstream vtkfile(vtkfilename.str().c_str());
|
||||
Opm::DataMap dm;
|
||||
@@ -463,9 +462,9 @@ int main ()
|
||||
/// \page tutorial4
|
||||
/// \details
|
||||
/// \section completecode4 Complete source code:
|
||||
/// \include tutorial4.cpp
|
||||
/// \include tutorial4.cpp
|
||||
|
||||
/// \page tutorial4
|
||||
/// \details
|
||||
/// \section pythonscript4 python script to generate figures:
|
||||
/// \section pythonscript4 python script to generate figures:
|
||||
/// \snippet generate_doc_figures.py tutorial4
|
||||
Reference in new issue
Block a user