remove the "Eclipse" prefix from all classes in namespace "EclipseWriterDetails"
this have become become superfluous by the namespace...
This commit is contained in:
parent
d71c2a0fa6
commit
e142094443
@ -93,32 +93,32 @@ static const char* SAT_NAMES[] = { "SWAT", "SOIL", "SGAS" };
|
|||||||
///
|
///
|
||||||
/// \tparam T Type of handle being wrapper
|
/// \tparam T Type of handle being wrapper
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct EclipseHandle {
|
struct Handle {
|
||||||
/// Instead of inheriting std::unique_ptr and letting the compiler
|
/// Instead of inheriting std::unique_ptr and letting the compiler
|
||||||
/// provide a default implementation which calls the base class, we
|
/// provide a default implementation which calls the base class, we
|
||||||
/// define the move constructor and assignment operator ourselves
|
/// define the move constructor and assignment operator ourselves
|
||||||
/// and call and aggregated pointer, because of bugs in GCC 4.4
|
/// and call and aggregated pointer, because of bugs in GCC 4.4
|
||||||
EclipseHandle <T> (EclipseHandle <T>&& rhs)
|
Handle <T> (Handle <T>&& rhs)
|
||||||
: h_ (std::move (rhs.h_)) { }
|
: h_ (std::move (rhs.h_)) { }
|
||||||
|
|
||||||
EclipseHandle <T>& operator= (EclipseHandle <T>&& rhs) {
|
Handle <T>& operator= (Handle <T>&& rhs) {
|
||||||
h_ = std::move (rhs.h_);
|
h_ = std::move (rhs.h_);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prevent GCC 4.4 from the urge of generating a copy constructor
|
/// Prevent GCC 4.4 from the urge of generating a copy constructor
|
||||||
EclipseHandle (const EclipseHandle&) = delete;
|
Handle (const Handle&) = delete;
|
||||||
EclipseHandle <T>& operator= (const EclipseHandle <T>&) = delete;
|
Handle <T>& operator= (const Handle <T>&) = delete;
|
||||||
|
|
||||||
/// Construct a new smart handle based on the returned value of
|
/// Construct a new smart handle based on the returned value of
|
||||||
/// an allocation function and the corresponding destroyer function.
|
/// an allocation function and the corresponding destroyer function.
|
||||||
EclipseHandle <T> (T* t, void (*destroy)(T*))
|
Handle <T> (T* t, void (*destroy)(T*))
|
||||||
: h_ (t, destroy) { }
|
: h_ (t, destroy) { }
|
||||||
|
|
||||||
/// Construct an object whose memory is freed as part of another
|
/// Construct an object whose memory is freed as part of another
|
||||||
/// structure. This constructor is dangerous! Make sure that you
|
/// structure. This constructor is dangerous! Make sure that you
|
||||||
/// have the lifetime management correct before using it.
|
/// have the lifetime management correct before using it.
|
||||||
EclipseHandle <T> (T* t) : h_ (t, no_delete) { }
|
Handle <T> (T* t) : h_ (t, no_delete) { }
|
||||||
|
|
||||||
/// Convenience operator that lets us use this type as if
|
/// Convenience operator that lets us use this type as if
|
||||||
/// it was a handle directly.
|
/// it was a handle directly.
|
||||||
@ -273,44 +273,44 @@ void getActiveCells_(int number_of_cells,
|
|||||||
* different from EclKW in the constructors it provide).
|
* different from EclKW in the constructors it provide).
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct EclipseKeyword : public EclipseHandle <ecl_kw_type> {
|
struct Keyword : public Handle <ecl_kw_type> {
|
||||||
/// Special initialization from double-precision array.
|
/// Special initialization from double-precision array.
|
||||||
EclipseKeyword (const std::string& name,
|
Keyword (const std::string& name,
|
||||||
const std::vector<double>& data)
|
const std::vector<double>& data)
|
||||||
: EclipseHandle<ecl_kw_type>(ecl_kw_alloc(name.c_str(),
|
: Handle<ecl_kw_type>(ecl_kw_alloc(name.c_str(),
|
||||||
data.size(),
|
data.size(),
|
||||||
type()),
|
type()),
|
||||||
ecl_kw_free)
|
ecl_kw_free)
|
||||||
{ copyData (data, &noConversion, /*offset=*/0, /*stride=*/1); }
|
{ copyData (data, &noConversion, /*offset=*/0, /*stride=*/1); }
|
||||||
|
|
||||||
/// Initialization from integer array.
|
/// Initialization from integer array.
|
||||||
EclipseKeyword (const std::string& name,
|
Keyword (const std::string& name,
|
||||||
const std::vector<int>& data)
|
const std::vector<int>& data)
|
||||||
: EclipseHandle<ecl_kw_type>(ecl_kw_alloc(name.c_str(),
|
: Handle<ecl_kw_type>(ecl_kw_alloc(name.c_str(),
|
||||||
data.size(),
|
data.size(),
|
||||||
type()),
|
type()),
|
||||||
ecl_kw_free)
|
ecl_kw_free)
|
||||||
{ copyData (data, &noConversion, /*offset=*/0, /*stride=*/1); }
|
{ copyData (data, &noConversion, /*offset=*/0, /*stride=*/1); }
|
||||||
|
|
||||||
/// Constructor for optional fields
|
/// Constructor for optional fields
|
||||||
EclipseKeyword (const std::string& name)
|
Keyword (const std::string& name)
|
||||||
: EclipseHandle <ecl_kw_type> (0, ecl_kw_free) {
|
: Handle <ecl_kw_type> (0, ecl_kw_free) {
|
||||||
static_cast<void> (name);
|
static_cast<void> (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GCC 4.4 doesn't generate these constructors for us; provide the
|
// GCC 4.4 doesn't generate these constructors for us; provide the
|
||||||
// default implementation explicitly here instead
|
// default implementation explicitly here instead
|
||||||
EclipseKeyword (EclipseKeyword&& rhs)
|
Keyword (Keyword&& rhs)
|
||||||
: EclipseHandle <ecl_kw_type> (std::move (rhs))
|
: Handle <ecl_kw_type> (std::move (rhs))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
EclipseKeyword& operator= (EclipseKeyword&& rhs)
|
Keyword& operator= (Keyword&& rhs)
|
||||||
{
|
{
|
||||||
EclipseHandle <ecl_kw_type>::operator= (std::move(rhs));
|
Handle <ecl_kw_type>::operator= (std::move(rhs));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
EclipseKeyword (const EclipseKeyword&) = delete;
|
Keyword (const Keyword&) = delete;
|
||||||
EclipseKeyword& operator= (const EclipseKeyword&) = delete;
|
Keyword& operator= (const Keyword&) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Map the C++ data type (given by T) to an Eclipse type enum
|
/// Map the C++ data type (given by T) to an Eclipse type enum
|
||||||
@ -383,28 +383,28 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// specializations for known keyword types
|
// specializations for known keyword types
|
||||||
template <> ecl_type_enum EclipseKeyword<int >::type () { return ECL_INT_TYPE ; }
|
template <> ecl_type_enum Keyword<int >::type () { return ECL_INT_TYPE ; }
|
||||||
template <> ecl_type_enum EclipseKeyword<float >::type () { return ECL_FLOAT_TYPE ; }
|
template <> ecl_type_enum Keyword<float >::type () { return ECL_FLOAT_TYPE ; }
|
||||||
template <> ecl_type_enum EclipseKeyword<double>::type () { return ECL_DOUBLE_TYPE; }
|
template <> ecl_type_enum Keyword<double>::type () { return ECL_DOUBLE_TYPE; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pointer to memory that holds the name to an Eclipse output file.
|
* Pointer to memory that holds the name to an Eclipse output file.
|
||||||
*/
|
*/
|
||||||
struct EclipseFileName : public EclipseHandle <const char> {
|
struct FileName : public Handle <const char> {
|
||||||
EclipseFileName (const std::string& outputDir,
|
FileName (const std::string& outputDir,
|
||||||
const std::string& baseName,
|
const std::string& baseName,
|
||||||
ecl_file_enum type,
|
ecl_file_enum type,
|
||||||
int outputStepIdx)
|
int outputStepIdx)
|
||||||
|
|
||||||
// filename formatting function returns a pointer to allocated
|
// filename formatting function returns a pointer to allocated
|
||||||
// memory that must be released with the free() function
|
// memory that must be released with the free() function
|
||||||
: EclipseHandle <const char> (
|
: Handle <const char> (
|
||||||
ecl_util_alloc_filename (outputDir.c_str(),
|
ecl_util_alloc_filename (outputDir.c_str(),
|
||||||
baseName.c_str(),
|
baseName.c_str(),
|
||||||
type,
|
type,
|
||||||
false, // formatted?
|
false, // formatted?
|
||||||
outputStepIdx),
|
outputStepIdx),
|
||||||
freestr) { }
|
freestr) { }
|
||||||
private:
|
private:
|
||||||
/// Facade which allows us to free a const char*
|
/// Facade which allows us to free a const char*
|
||||||
static void freestr (const char* ptr) {
|
static void freestr (const char* ptr) {
|
||||||
@ -443,16 +443,16 @@ static int phaseMask (const PhaseUsage uses) {
|
|||||||
| (uses.phase_used [BlackoilPhases::Vapour] ? ECL_GAS_PHASE : 0);
|
| (uses.phase_used [BlackoilPhases::Vapour] ? ECL_GAS_PHASE : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct EclipseRestart : public EclipseHandle <ecl_rst_file_type> {
|
struct Restart : public Handle <ecl_rst_file_type> {
|
||||||
EclipseRestart (const std::string& outputDir,
|
Restart (const std::string& outputDir,
|
||||||
const std::string& baseName,
|
const std::string& baseName,
|
||||||
const SimulatorTimer& timer,
|
const SimulatorTimer& timer,
|
||||||
int outputStepIdx)
|
int outputStepIdx)
|
||||||
// notice the poor man's polymorphism of the allocation function
|
// notice the poor man's polymorphism of the allocation function
|
||||||
: EclipseHandle <ecl_rst_file_type> (
|
: Handle <ecl_rst_file_type> (
|
||||||
(timer.currentStepNum () > 0 ? ecl_rst_file_open_append
|
(timer.currentStepNum () > 0 ? ecl_rst_file_open_append
|
||||||
: ecl_rst_file_open_write)(
|
: ecl_rst_file_open_write)(
|
||||||
EclipseFileName (outputDir,
|
FileName (outputDir,
|
||||||
baseName,
|
baseName,
|
||||||
ECL_UNIFIED_RESTART_FILE,
|
ECL_UNIFIED_RESTART_FILE,
|
||||||
outputStepIdx)),
|
outputStepIdx)),
|
||||||
@ -482,19 +482,19 @@ struct EclipseRestart : public EclipseHandle <ecl_rst_file_type> {
|
|||||||
* restart file while writing solution variables; it is not a handle on
|
* restart file while writing solution variables; it is not a handle on
|
||||||
* its own.
|
* its own.
|
||||||
*/
|
*/
|
||||||
struct EclipseSolution : public EclipseHandle <ecl_rst_file_type> {
|
struct Solution : public Handle <ecl_rst_file_type> {
|
||||||
EclipseSolution (EclipseRestart& rst_file)
|
Solution (Restart& rst_file)
|
||||||
: EclipseHandle <ecl_rst_file_type> (start_solution (rst_file),
|
: Handle <ecl_rst_file_type> (start_solution (rst_file),
|
||||||
ecl_rst_file_end_solution) { }
|
ecl_rst_file_end_solution) { }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void add (const EclipseKeyword<T>& kw) {
|
void add (const Keyword<T>& kw) {
|
||||||
ecl_rst_file_add_kw (*this, kw);
|
ecl_rst_file_add_kw (*this, kw);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Helper method to call function *and* return the handle
|
/// Helper method to call function *and* return the handle
|
||||||
static ecl_rst_file_type* start_solution (EclipseRestart& rst_file) {
|
static ecl_rst_file_type* start_solution (Restart& rst_file) {
|
||||||
ecl_rst_file_start_solution (rst_file);
|
ecl_rst_file_start_solution (rst_file);
|
||||||
return rst_file;
|
return rst_file;
|
||||||
}
|
}
|
||||||
@ -503,12 +503,12 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Representation of an Eclipse grid.
|
* Representation of an Eclipse grid.
|
||||||
*/
|
*/
|
||||||
struct EclipseWriterGrid : public EclipseHandle <ecl_grid_type> {
|
struct Grid : public Handle <ecl_grid_type> {
|
||||||
/// Create a grid based on the keywords available in input file
|
/// Create a grid based on the keywords available in input file
|
||||||
static EclipseWriterGrid make (Opm::DeckConstPtr deck,
|
static Grid make (Opm::DeckConstPtr deck,
|
||||||
int number_of_cells,
|
int number_of_cells,
|
||||||
const int* cart_dims,
|
const int* cart_dims,
|
||||||
const int* global_cell)
|
const int* global_cell)
|
||||||
{
|
{
|
||||||
auto runspecSection = std::make_shared<RUNSPECSection>(deck);
|
auto runspecSection = std::make_shared<RUNSPECSection>(deck);
|
||||||
auto gridSection = std::make_shared<GRIDSection>(deck);
|
auto gridSection = std::make_shared<GRIDSection>(deck);
|
||||||
@ -524,18 +524,18 @@ struct EclipseWriterGrid : public EclipseHandle <ecl_grid_type> {
|
|||||||
eGrid.exportCOORD(coordData);
|
eGrid.exportCOORD(coordData);
|
||||||
eGrid.exportACTNUM(actnumData);
|
eGrid.exportACTNUM(actnumData);
|
||||||
|
|
||||||
EclipseKeyword<float> mapaxesKeyword("MAPAXES", mapaxesData);
|
Keyword<float> mapaxesKeyword("MAPAXES", mapaxesData);
|
||||||
EclipseKeyword<float> zcornKeyword("ZCORN", zcornData);
|
Keyword<float> zcornKeyword("ZCORN", zcornData);
|
||||||
EclipseKeyword<float> coordKeyword("COORD", coordData);
|
Keyword<float> coordKeyword("COORD", coordData);
|
||||||
EclipseKeyword<int> actnumKeyword("ACTNUM", actnumData);
|
Keyword<int> actnumKeyword("ACTNUM", actnumData);
|
||||||
|
|
||||||
return EclipseWriterGrid(eGrid.getNX(),
|
return Grid(eGrid.getNX(),
|
||||||
eGrid.getNY(),
|
eGrid.getNY(),
|
||||||
eGrid.getNZ(),
|
eGrid.getNZ(),
|
||||||
zcornKeyword,
|
zcornKeyword,
|
||||||
coordKeyword,
|
coordKeyword,
|
||||||
actnumKeyword,
|
actnumKeyword,
|
||||||
mapaxesKeyword);
|
mapaxesKeyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -545,65 +545,65 @@ struct EclipseWriterGrid : public EclipseHandle <ecl_grid_type> {
|
|||||||
const std::string& baseName,
|
const std::string& baseName,
|
||||||
int outputStepIdx) {
|
int outputStepIdx) {
|
||||||
ecl_grid_fwrite_EGRID (*this,
|
ecl_grid_fwrite_EGRID (*this,
|
||||||
EclipseFileName (outputDir,
|
FileName (outputDir,
|
||||||
baseName,
|
baseName,
|
||||||
ECL_EGRID_FILE,
|
ECL_EGRID_FILE,
|
||||||
outputStepIdx));
|
outputStepIdx));
|
||||||
}
|
}
|
||||||
|
|
||||||
// GCC 4.4 doesn't generate these constructors for us; provide the
|
// GCC 4.4 doesn't generate these constructors for us; provide the
|
||||||
// default implementation explicitly here instead
|
// default implementation explicitly here instead
|
||||||
EclipseWriterGrid (EclipseWriterGrid&& rhs)
|
Grid (Grid&& rhs)
|
||||||
: EclipseHandle <ecl_grid_type> (std::move (rhs)) { }
|
: Handle <ecl_grid_type> (std::move (rhs)) { }
|
||||||
EclipseWriterGrid& operator= (EclipseWriterGrid&& rhs) {
|
Grid& operator= (Grid&& rhs) {
|
||||||
EclipseHandle <ecl_grid_type>::operator= (std::move(rhs));
|
Handle <ecl_grid_type>::operator= (std::move(rhs));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
EclipseWriterGrid (const EclipseWriterGrid&) = delete;
|
Grid (const Grid&) = delete;
|
||||||
EclipseWriterGrid& operator= (const EclipseWriterGrid&) = delete;
|
Grid& operator= (const Grid&) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// setup smart pointer for cornerpoint grid
|
// setup smart pointer for cornerpoint grid
|
||||||
EclipseWriterGrid (int nx,
|
Grid (int nx,
|
||||||
int ny,
|
int ny,
|
||||||
int nz,
|
int nz,
|
||||||
const EclipseKeyword<float>& zcorn,
|
const Keyword<float>& zcorn,
|
||||||
const EclipseKeyword<float>& coord,
|
const Keyword<float>& coord,
|
||||||
const EclipseKeyword<int>& actnum,
|
const Keyword<int>& actnum,
|
||||||
const EclipseKeyword<float>& mapaxes)
|
const Keyword<float>& mapaxes)
|
||||||
: EclipseHandle <ecl_grid_type> (
|
: Handle <ecl_grid_type> (
|
||||||
ecl_grid_alloc_GRDECL_kw(nx,
|
ecl_grid_alloc_GRDECL_kw(nx,
|
||||||
ny,
|
ny,
|
||||||
nz,
|
nz,
|
||||||
zcorn,
|
zcorn,
|
||||||
coord,
|
coord,
|
||||||
actnum,
|
actnum,
|
||||||
mapaxes),
|
mapaxes),
|
||||||
ecl_grid_free) { }
|
ecl_grid_free) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization file which contains static properties (such as
|
* Initialization file which contains static properties (such as
|
||||||
* porosity and permeability) for the simulation field.
|
* porosity and permeability) for the simulation field.
|
||||||
*/
|
*/
|
||||||
struct EclipseInit : public EclipseHandle <fortio_type> {
|
struct Init : public Handle <fortio_type> {
|
||||||
// contrary to the grid, the location of the file goes here because
|
// contrary to the grid, the location of the file goes here because
|
||||||
// there is only one construction method but several write methods
|
// there is only one construction method but several write methods
|
||||||
// (but we need to do a bit of logic before we can call the actual
|
// (but we need to do a bit of logic before we can call the actual
|
||||||
// constructor, so we'll have to do with a static wrapper)
|
// constructor, so we'll have to do with a static wrapper)
|
||||||
static EclipseInit make (const std::string& outputDir,
|
static Init make (const std::string& outputDir,
|
||||||
const std::string& baseName,
|
const std::string& baseName,
|
||||||
int outputStepIdx) {
|
int outputStepIdx) {
|
||||||
EclipseFileName initFileName (outputDir,
|
FileName initFileName (outputDir,
|
||||||
baseName,
|
baseName,
|
||||||
ECL_INIT_FILE,
|
ECL_INIT_FILE,
|
||||||
outputStepIdx);
|
outputStepIdx);
|
||||||
bool fmt_file;
|
bool fmt_file;
|
||||||
if (!ecl_util_fmt_file(initFileName, &fmt_file)) {
|
if (!ecl_util_fmt_file(initFileName, &fmt_file)) {
|
||||||
OPM_THROW(std::runtime_error,
|
OPM_THROW(std::runtime_error,
|
||||||
"Could not determine formatted/unformatted status of file:" << initFileName << " non-standard name?" << std::endl);
|
"Could not determine formatted/unformatted status of file:" << initFileName << " non-standard name?" << std::endl);
|
||||||
}
|
}
|
||||||
return EclipseInit (initFileName, fmt_file);
|
return Init (initFileName, fmt_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeHeader (int number_of_cells,
|
void writeHeader (int number_of_cells,
|
||||||
@ -616,10 +616,10 @@ struct EclipseInit : public EclipseHandle <fortio_type> {
|
|||||||
auto dataField = getAllSiDoubles_(deck->getKeyword(PORO_KW));
|
auto dataField = getAllSiDoubles_(deck->getKeyword(PORO_KW));
|
||||||
restrictToActiveCells_(dataField, number_of_cells, global_cell);
|
restrictToActiveCells_(dataField, number_of_cells, global_cell);
|
||||||
|
|
||||||
EclipseWriterGrid eclGrid = EclipseWriterGrid::make (deck, number_of_cells,
|
Grid eclGrid = Grid::make (deck, number_of_cells,
|
||||||
cart_dims, global_cell);
|
cart_dims, global_cell);
|
||||||
|
|
||||||
EclipseKeyword<float> poro (PORO_KW, dataField);
|
Keyword<float> poro (PORO_KW, dataField);
|
||||||
ecl_init_file_fwrite_header (*this,
|
ecl_init_file_fwrite_header (*this,
|
||||||
eclGrid,
|
eclGrid,
|
||||||
poro,
|
poro,
|
||||||
@ -629,53 +629,53 @@ struct EclipseInit : public EclipseHandle <fortio_type> {
|
|||||||
|
|
||||||
void writeKeyword (const std::string& keywordName, const std::vector<double> &data)
|
void writeKeyword (const std::string& keywordName, const std::vector<double> &data)
|
||||||
{
|
{
|
||||||
EclipseKeyword <float> kw (keywordName, data);
|
Keyword <float> kw (keywordName, data);
|
||||||
ecl_kw_fwrite(kw, *this);
|
ecl_kw_fwrite(kw, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GCC 4.4 doesn't generate these constructors for us; provide the
|
// GCC 4.4 doesn't generate these constructors for us; provide the
|
||||||
// default implementation explicitly here instead
|
// default implementation explicitly here instead
|
||||||
EclipseInit (EclipseInit&& rhs)
|
Init (Init&& rhs)
|
||||||
: EclipseHandle <fortio_type> (std::move (rhs)) { }
|
: Handle <fortio_type> (std::move (rhs)) { }
|
||||||
EclipseInit& operator= (EclipseInit& rhs) {
|
Init& operator= (Init& rhs) {
|
||||||
EclipseHandle <fortio_type>::operator= (std::move(rhs));
|
Handle <fortio_type>::operator= (std::move(rhs));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
EclipseInit (const EclipseInit&) = delete;
|
Init (const Init&) = delete;
|
||||||
EclipseInit& operator= (const EclipseInit&) = delete;
|
Init& operator= (const Init&) = delete;
|
||||||
private:
|
private:
|
||||||
EclipseInit (const EclipseFileName& fname, const bool formatted)
|
Init (const FileName& fname, const bool formatted)
|
||||||
: EclipseHandle <fortio_type> (
|
: Handle <fortio_type> (
|
||||||
fortio_open_writer (fname, formatted, ECL_ENDIAN_FLIP),
|
fortio_open_writer (fname, formatted, ECL_ENDIAN_FLIP),
|
||||||
fortio_fclose) { }
|
fortio_fclose) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// in order to get RTTI for this "class" (which is just a typedef), we must
|
// in order to get RTTI for this "class" (which is just a typedef), we must
|
||||||
// ask the compiler to explicitly instantiate it.
|
// ask the compiler to explicitly instantiate it.
|
||||||
template struct EclipseHandle<ecl_sum_tstep_struct>;
|
template struct Handle<ecl_sum_tstep_struct>;
|
||||||
|
|
||||||
// Note: the following parts were taken out of the anonymous
|
// Note: the following parts were taken out of the anonymous
|
||||||
// namespace, since EclipseSummary is now used as a pointer member in
|
// namespace, since Summary is now used as a pointer member in
|
||||||
// EclipseWriter and forward declared in EclipseWriter.hpp.
|
// Writer and forward declared in EclipseWriter.hpp.
|
||||||
|
|
||||||
// forward decl. of mutually dependent type
|
// forward decl. of mutually dependent type
|
||||||
struct EclipseWellReport;
|
struct WellReport;
|
||||||
|
|
||||||
class EclipseSummary : public EclipseHandle <ecl_sum_type> {
|
class Summary : public Handle <ecl_sum_type> {
|
||||||
public:
|
public:
|
||||||
EclipseSummary (const std::string& outputDir,
|
Summary (const std::string& outputDir,
|
||||||
const std::string& baseName,
|
const std::string& baseName,
|
||||||
const SimulatorTimer& timer,
|
const SimulatorTimer& timer,
|
||||||
Opm::DeckConstPtr deck)
|
Opm::DeckConstPtr deck)
|
||||||
: EclipseHandle <ecl_sum_type> (
|
: Handle <ecl_sum_type> (
|
||||||
alloc_writer (outputDir, baseName, timer, deck),
|
alloc_writer (outputDir, baseName, timer, deck),
|
||||||
ecl_sum_free) { }
|
ecl_sum_free) { }
|
||||||
|
|
||||||
typedef std::unique_ptr <EclipseWellReport> var_t;
|
typedef std::unique_ptr <WellReport> var_t;
|
||||||
typedef std::vector <var_t> vars_t;
|
typedef std::vector <var_t> vars_t;
|
||||||
|
|
||||||
EclipseSummary& add (var_t var) {
|
Summary& add (var_t var) {
|
||||||
vars_.push_back (std::move (var));
|
vars_.push_back (std::move (var));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -683,7 +683,7 @@ public:
|
|||||||
// make sure the summary section is flushed before it goes away
|
// make sure the summary section is flushed before it goes away
|
||||||
// (this will happen before all the timesteps are individually
|
// (this will happen before all the timesteps are individually
|
||||||
// destroyed, so their memory is still valid at this point)
|
// destroyed, so their memory is still valid at this point)
|
||||||
~EclipseSummary () {
|
~Summary () {
|
||||||
ecl_sum_fwrite (*this);
|
ecl_sum_fwrite (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,9 +692,9 @@ public:
|
|||||||
const PhaseUsage& uses);
|
const PhaseUsage& uses);
|
||||||
|
|
||||||
// no inline implementation of this since it depends on the
|
// no inline implementation of this since it depends on the
|
||||||
// EclipseWellReport type being completed first
|
// WellReport type being completed first
|
||||||
void writeTimeStep (const SimulatorTimer& timer,
|
void writeTimeStep (const SimulatorTimer& timer,
|
||||||
const WellState& wellState);
|
const WellState& wellState);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vars_t vars_;
|
vars_t vars_;
|
||||||
@ -702,19 +702,19 @@ private:
|
|||||||
// don't define a new type for timesteps (since they should all
|
// don't define a new type for timesteps (since they should all
|
||||||
// be created with makeTimeStep anyway), just use the basic handle
|
// be created with makeTimeStep anyway), just use the basic handle
|
||||||
// type and a typedef.
|
// type and a typedef.
|
||||||
typedef EclipseHandle <ecl_sum_tstep_type> EclipseTimeStep;
|
typedef Handle <ecl_sum_tstep_type> TimeStep;
|
||||||
|
|
||||||
/// Create a new time step and add it to this summary. The summary
|
/// Create a new time step and add it to this summary. The summary
|
||||||
/// will take care of memory management, the object returned is a
|
/// will take care of memory management, the object returned is a
|
||||||
/// "view" into it. Make sure that that view does not outlive the
|
/// "view" into it. Make sure that that view does not outlive the
|
||||||
/// summary object! Notice that there is no deleter in the constructor.
|
/// summary object! Notice that there is no deleter in the constructor.
|
||||||
std::unique_ptr <EclipseTimeStep> makeTimeStep (const SimulatorTimer& timer) {
|
std::unique_ptr <TimeStep> makeTimeStep (const SimulatorTimer& timer) {
|
||||||
EclipseTimeStep* tstep = new EclipseTimeStep (
|
TimeStep* tstep = new TimeStep (
|
||||||
ecl_sum_add_tstep (*this,
|
ecl_sum_add_tstep (*this,
|
||||||
timer.currentStepNum (),
|
timer.currentStepNum (),
|
||||||
Opm::unit::convert::to (timer.simulationTimeElapsed (),
|
Opm::unit::convert::to (timer.simulationTimeElapsed (),
|
||||||
Opm::unit::day)));
|
Opm::unit::day)));
|
||||||
return std::unique_ptr <EclipseTimeStep> (tstep);
|
return std::unique_ptr <TimeStep> (tstep);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper routine that lets us use local variables to hold
|
/// Helper routine that lets us use local variables to hold
|
||||||
@ -744,17 +744,17 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Summary variable that reports a characteristics of a well.
|
* Summary variable that reports a characteristics of a well.
|
||||||
*/
|
*/
|
||||||
struct EclipseWellReport : public EclipseHandle <smspec_node_type> {
|
struct WellReport : public Handle <smspec_node_type> {
|
||||||
protected:
|
protected:
|
||||||
EclipseWellReport (const EclipseSummary& summary, /* section to add to */
|
WellReport (const Summary& summary, /* section to add to */
|
||||||
Opm::DeckConstPtr deck, /* well names */
|
Opm::DeckConstPtr deck, /* well names */
|
||||||
int whichWell, /* index of well line */
|
int whichWell, /* index of well line */
|
||||||
PhaseUsage uses, /* phases present */
|
PhaseUsage uses, /* phases present */
|
||||||
BlackoilPhases::PhaseIndex phase, /* oil, water or gas */
|
BlackoilPhases::PhaseIndex phase, /* oil, water or gas */
|
||||||
WellType type, /* prod. or inj. */
|
WellType type, /* prod. or inj. */
|
||||||
char aggregation, /* rate or total */
|
char aggregation, /* rate or total */
|
||||||
std::string unit)
|
std::string unit)
|
||||||
: EclipseHandle <smspec_node_type> (
|
: Handle <smspec_node_type> (
|
||||||
ecl_sum_add_var (summary,
|
ecl_sum_add_var (summary,
|
||||||
varName (phase,
|
varName (phase,
|
||||||
type,
|
type,
|
||||||
@ -778,7 +778,7 @@ public:
|
|||||||
/// Update the monitor according to the new state of the well, and
|
/// Update the monitor according to the new state of the well, and
|
||||||
/// get the reported value. Note: Only call this once for each timestep.
|
/// get the reported value. Note: Only call this once for each timestep.
|
||||||
virtual double update (const SimulatorTimer& timer,
|
virtual double update (const SimulatorTimer& timer,
|
||||||
const WellState& wellState) = 0;
|
const WellState& wellState) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// index into a (flattened) wells*phases matrix
|
/// index into a (flattened) wells*phases matrix
|
||||||
@ -841,51 +841,51 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Monitors the rate given by a well.
|
/// Monitors the rate given by a well.
|
||||||
struct EclipseWellRate : public EclipseWellReport {
|
struct WellRate : public WellReport {
|
||||||
EclipseWellRate (const EclipseSummary& summary,
|
WellRate (const Summary& summary,
|
||||||
Opm::DeckConstPtr deck,
|
Opm::DeckConstPtr deck,
|
||||||
int whichWell,
|
int whichWell,
|
||||||
PhaseUsage uses,
|
PhaseUsage uses,
|
||||||
BlackoilPhases::PhaseIndex phase,
|
BlackoilPhases::PhaseIndex phase,
|
||||||
WellType type)
|
WellType type)
|
||||||
: EclipseWellReport (summary,
|
: WellReport (summary,
|
||||||
deck,
|
deck,
|
||||||
whichWell,
|
whichWell,
|
||||||
uses,
|
uses,
|
||||||
phase,
|
phase,
|
||||||
type,
|
type,
|
||||||
'R',
|
'R',
|
||||||
"SM3/DAY" /* surf. cub. m. per day */ ) { }
|
"SM3/DAY" /* surf. cub. m. per day */ ) { }
|
||||||
|
|
||||||
virtual double update (const SimulatorTimer& /*timer*/,
|
virtual double update (const SimulatorTimer& /*timer*/,
|
||||||
const WellState& wellState) {
|
const WellState& wellState) {
|
||||||
// TODO: Why only positive rates?
|
// TODO: Why only positive rates?
|
||||||
return std::max (0., rate (wellState));
|
return std::max (0., rate (wellState));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Monitors the total production in a well.
|
/// Monitors the total production in a well.
|
||||||
struct EclipseWellTotal : public EclipseWellReport {
|
struct WellTotal : public WellReport {
|
||||||
EclipseWellTotal (const EclipseSummary& summary,
|
WellTotal (const Summary& summary,
|
||||||
Opm::DeckConstPtr deck,
|
Opm::DeckConstPtr deck,
|
||||||
int whichWell,
|
int whichWell,
|
||||||
PhaseUsage uses,
|
PhaseUsage uses,
|
||||||
BlackoilPhases::PhaseIndex phase,
|
BlackoilPhases::PhaseIndex phase,
|
||||||
WellType type)
|
WellType type)
|
||||||
: EclipseWellReport (summary,
|
: WellReport (summary,
|
||||||
deck,
|
deck,
|
||||||
whichWell,
|
whichWell,
|
||||||
uses,
|
uses,
|
||||||
phase,
|
phase,
|
||||||
type,
|
type,
|
||||||
'T',
|
'T',
|
||||||
"SM3" /* surface cubic meter */ )
|
"SM3" /* surface cubic meter */ )
|
||||||
|
|
||||||
// nothing produced when the reporting starts
|
// nothing produced when the reporting starts
|
||||||
, total_ (0.) { }
|
, total_ (0.) { }
|
||||||
|
|
||||||
virtual double update (const SimulatorTimer& timer,
|
virtual double update (const SimulatorTimer& timer,
|
||||||
const WellState& wellState) {
|
const WellState& wellState) {
|
||||||
if (timer.currentStepNum() == 0) {
|
if (timer.currentStepNum() == 0) {
|
||||||
// We are at the initial state.
|
// We are at the initial state.
|
||||||
// No step has been taken yet.
|
// No step has been taken yet.
|
||||||
@ -907,21 +907,21 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Monitors the bottom hole pressure in a well.
|
/// Monitors the bottom hole pressure in a well.
|
||||||
struct EclipseWellBhp : public EclipseWellReport {
|
struct WellBhp : public WellReport {
|
||||||
EclipseWellBhp (const EclipseSummary& summary,
|
WellBhp (const Summary& summary,
|
||||||
Opm::DeckConstPtr deck,
|
Opm::DeckConstPtr deck,
|
||||||
int whichWell,
|
int whichWell,
|
||||||
PhaseUsage uses,
|
PhaseUsage uses,
|
||||||
BlackoilPhases::PhaseIndex phase,
|
BlackoilPhases::PhaseIndex phase,
|
||||||
WellType type)
|
WellType type)
|
||||||
: EclipseWellReport (summary,
|
: WellReport (summary,
|
||||||
deck,
|
deck,
|
||||||
whichWell,
|
whichWell,
|
||||||
uses,
|
uses,
|
||||||
phase,
|
phase,
|
||||||
type,
|
type,
|
||||||
'B',
|
'B',
|
||||||
"Pascal")
|
"Pascal")
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual double update (const SimulatorTimer& /*timer*/,
|
virtual double update (const SimulatorTimer& /*timer*/,
|
||||||
@ -932,11 +932,11 @@ struct EclipseWellBhp : public EclipseWellReport {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
EclipseSummary::writeTimeStep (const SimulatorTimer& timer,
|
Summary::writeTimeStep (const SimulatorTimer& timer,
|
||||||
const WellState& wellState)
|
const WellState& wellState)
|
||||||
{
|
{
|
||||||
// internal view; do not move this code out of EclipseSummary!
|
// internal view; do not move this code out of Summary!
|
||||||
std::unique_ptr <EclipseTimeStep> tstep = makeTimeStep (timer);
|
std::unique_ptr <TimeStep> tstep = makeTimeStep (timer);
|
||||||
// write all the variables
|
// write all the variables
|
||||||
for (vars_t::iterator v = vars_.begin(); v != vars_.end(); ++v) {
|
for (vars_t::iterator v = vars_.begin(); v != vars_.end(); ++v) {
|
||||||
const double value = (*v)->update (timer, wellState);
|
const double value = (*v)->update (timer, wellState);
|
||||||
@ -952,7 +952,7 @@ EclipseSummary::writeTimeStep (const SimulatorTimer& timer,
|
|||||||
static WellType WELL_TYPES[] = { INJECTOR, PRODUCER };
|
static WellType WELL_TYPES[] = { INJECTOR, PRODUCER };
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
EclipseSummary::addWells (Opm::DeckConstPtr deck,
|
Summary::addWells (Opm::DeckConstPtr deck,
|
||||||
const PhaseUsage& uses) {
|
const PhaseUsage& uses) {
|
||||||
// TODO: Only create report variables that are requested with keywords
|
// TODO: Only create report variables that are requested with keywords
|
||||||
// (e.g. "WOPR") in the input files, and only for those wells that are
|
// (e.g. "WOPR") in the input files, and only for those wells that are
|
||||||
@ -974,21 +974,21 @@ EclipseSummary::addWells (Opm::DeckConstPtr deck,
|
|||||||
const WellType type = WELL_TYPES[typeIndex];
|
const WellType type = WELL_TYPES[typeIndex];
|
||||||
for (int whichWell = 0; whichWell != numWells; ++whichWell) {
|
for (int whichWell = 0; whichWell != numWells; ++whichWell) {
|
||||||
// W{O,G,W}{I,P}R
|
// W{O,G,W}{I,P}R
|
||||||
add (std::unique_ptr <EclipseWellReport> (
|
add (std::unique_ptr <WellReport> (
|
||||||
new EclipseWellRate (*this,
|
new WellRate (*this,
|
||||||
deck,
|
deck,
|
||||||
whichWell,
|
whichWell,
|
||||||
uses,
|
uses,
|
||||||
phase,
|
phase,
|
||||||
type)));
|
type)));
|
||||||
// W{O,G,W}{I,P}T
|
// W{O,G,W}{I,P}T
|
||||||
add (std::unique_ptr <EclipseWellReport> (
|
add (std::unique_ptr <WellReport> (
|
||||||
new EclipseWellTotal (*this,
|
new WellTotal (*this,
|
||||||
deck,
|
deck,
|
||||||
whichWell,
|
whichWell,
|
||||||
uses,
|
uses,
|
||||||
phase,
|
phase,
|
||||||
type)));
|
type)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -998,23 +998,23 @@ EclipseSummary::addWells (Opm::DeckConstPtr deck,
|
|||||||
// In the call below: uses, phase and the well type arguments
|
// In the call below: uses, phase and the well type arguments
|
||||||
// are not used, except to set up an index that stores the
|
// are not used, except to set up an index that stores the
|
||||||
// well indirectly. For details see the implementation of the
|
// well indirectly. For details see the implementation of the
|
||||||
// EclipseWellReport constructor, and the method
|
// WellReport constructor, and the method
|
||||||
// EclipseWellReport::bhp().
|
// WellReport::bhp().
|
||||||
BlackoilPhases::PhaseIndex phase = BlackoilPhases::Liquid;
|
BlackoilPhases::PhaseIndex phase = BlackoilPhases::Liquid;
|
||||||
if (!uses.phase_used[BlackoilPhases::Liquid]) {
|
if (!uses.phase_used[BlackoilPhases::Liquid]) {
|
||||||
phase = BlackoilPhases::Vapour;
|
phase = BlackoilPhases::Vapour;
|
||||||
}
|
}
|
||||||
add (std::unique_ptr <EclipseWellReport> (
|
add (std::unique_ptr <WellReport> (
|
||||||
new EclipseWellBhp (*this,
|
new WellBhp (*this,
|
||||||
deck,
|
deck,
|
||||||
whichWell,
|
whichWell,
|
||||||
uses,
|
uses,
|
||||||
phase,
|
phase,
|
||||||
WELL_TYPES[0])));
|
WELL_TYPES[0])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace EclipseWriterDetails
|
} // end namespace WriterDetails
|
||||||
|
|
||||||
void EclipseWriter::writeInit(const SimulatorTimer &timer)
|
void EclipseWriter::writeInit(const SimulatorTimer &timer)
|
||||||
{
|
{
|
||||||
@ -1024,11 +1024,11 @@ void EclipseWriter::writeInit(const SimulatorTimer &timer)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Grid files */
|
/* Grid files */
|
||||||
EclipseWriterDetails::EclipseWriterGrid eclGrid = EclipseWriterDetails::EclipseWriterGrid::make(
|
EclipseWriterDetails::Grid eclGrid = EclipseWriterDetails::Grid::make(
|
||||||
deck_, number_of_cells_, cart_dims_, global_cell_);
|
deck_, number_of_cells_, cart_dims_, global_cell_);
|
||||||
eclGrid.write (outputDir_, baseName_, /*stepIdx=*/0);
|
eclGrid.write (outputDir_, baseName_, /*stepIdx=*/0);
|
||||||
|
|
||||||
EclipseWriterDetails::EclipseInit fortio = EclipseWriterDetails::EclipseInit::make(
|
EclipseWriterDetails::Init fortio = EclipseWriterDetails::Init::make(
|
||||||
outputDir_, baseName_, /*stepIdx=*/0);
|
outputDir_, baseName_, /*stepIdx=*/0);
|
||||||
fortio.writeHeader (number_of_cells_,
|
fortio.writeHeader (number_of_cells_,
|
||||||
cart_dims_,
|
cart_dims_,
|
||||||
@ -1055,7 +1055,7 @@ void EclipseWriter::writeInit(const SimulatorTimer &timer)
|
|||||||
|
|
||||||
/* Create summary object (could not do it at construction time,
|
/* Create summary object (could not do it at construction time,
|
||||||
since it requires knowledge of the start time). */
|
since it requires knowledge of the start time). */
|
||||||
summary_.reset(new EclipseWriterDetails::EclipseSummary(outputDir_, baseName_, timer, deck_));
|
summary_.reset(new EclipseWriterDetails::Summary(outputDir_, baseName_, timer, deck_));
|
||||||
summary_->addWells (deck_, uses_);
|
summary_->addWells (deck_, uses_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1075,9 +1075,9 @@ void EclipseWriter::writeTimeStep(const SimulatorTimer& timer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start writing to files
|
// start writing to files
|
||||||
EclipseWriterDetails::EclipseRestart rst(outputDir_, baseName_, timer, outputTimeStepIdx_);
|
EclipseWriterDetails::Restart rst(outputDir_, baseName_, timer, outputTimeStepIdx_);
|
||||||
rst.writeHeader (timer, outputTimeStepIdx_, uses_, deck_, reservoirState.pressure().size ());
|
rst.writeHeader (timer, outputTimeStepIdx_, uses_, deck_, reservoirState.pressure().size ());
|
||||||
EclipseWriterDetails::EclipseSolution sol (rst);
|
EclipseWriterDetails::Solution sol (rst);
|
||||||
|
|
||||||
// write out the pressure of the reference phase (whatever
|
// write out the pressure of the reference phase (whatever
|
||||||
// phase that is...). this is not the most performant solution
|
// phase that is...). this is not the most performant solution
|
||||||
@ -1086,7 +1086,7 @@ void EclipseWriter::writeTimeStep(const SimulatorTimer& timer,
|
|||||||
std::vector<double> tmp = reservoirState.pressure();
|
std::vector<double> tmp = reservoirState.pressure();
|
||||||
EclipseWriterDetails::convertUnit_(tmp, EclipseWriterDetails::toBar);
|
EclipseWriterDetails::convertUnit_(tmp, EclipseWriterDetails::toBar);
|
||||||
|
|
||||||
sol.add(EclipseWriterDetails::EclipseKeyword<float>("PRESSURE", tmp));
|
sol.add(EclipseWriterDetails::Keyword<float>("PRESSURE", tmp));
|
||||||
|
|
||||||
for (int phase = 0; phase != BlackoilPhases::MaxNumPhases; ++phase) {
|
for (int phase = 0; phase != BlackoilPhases::MaxNumPhases; ++phase) {
|
||||||
// Eclipse never writes the oil saturation, so all post-processors
|
// Eclipse never writes the oil saturation, so all post-processors
|
||||||
@ -1099,7 +1099,7 @@ void EclipseWriter::writeTimeStep(const SimulatorTimer& timer,
|
|||||||
EclipseWriterDetails::extractFromStripedData_(tmp,
|
EclipseWriterDetails::extractFromStripedData_(tmp,
|
||||||
/*offset=*/uses_.phase_pos[phase],
|
/*offset=*/uses_.phase_pos[phase],
|
||||||
/*stride=*/uses_.num_phases);
|
/*stride=*/uses_.num_phases);
|
||||||
sol.add(EclipseWriterDetails::EclipseKeyword<float>(EclipseWriterDetails::SAT_NAMES[phase], tmp));
|
sol.add(EclipseWriterDetails::Keyword<float>(EclipseWriterDetails::SAT_NAMES[phase], tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace Opm {
|
|||||||
|
|
||||||
// forward declarations
|
// forward declarations
|
||||||
namespace EclipseWriterDetails {
|
namespace EclipseWriterDetails {
|
||||||
class EclipseSummary;
|
class Summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
class SimulatorState;
|
class SimulatorState;
|
||||||
@ -105,7 +105,7 @@ private:
|
|||||||
std::string outputDir_;
|
std::string outputDir_;
|
||||||
std::string baseName_;
|
std::string baseName_;
|
||||||
PhaseUsage uses_; // active phases in the input deck
|
PhaseUsage uses_; // active phases in the input deck
|
||||||
std::shared_ptr <EclipseWriterDetails::EclipseSummary> summary_;
|
std::shared_ptr <EclipseWriterDetails::Summary> summary_;
|
||||||
|
|
||||||
void init(const parameter::ParameterGroup& params);
|
void init(const parameter::ParameterGroup& params);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user