Commit Graph

4178 Commits

Author SHA1 Message Date
Andreas Lauser
e57d1697c2 Get dimensions for Cartesian grids
For SPE1, the output writer must also support specifying the grid
via the D[XYZ]V keywords instead of relying on the SPECGRID keyword
2013-11-25 14:14:50 +01:00
Andreas Lauser
f980350af2 Handle empty outputDir setting
The output dir must not be empty or else file names like "/FOO.INIT"
are generated which normally result in a segfault.
2013-11-25 14:14:50 +01:00
Roland Kaufmann
419cffe73b Define destructor in .cpp to handle forward-def field
The EclipseSummary field is just forward declared in the header, and
the compiler cannot create a proper destructor based on just that. If
we define it in the compilation unit, it will get instantiated there
once and for all and the compiler won't try to create it (and leave it
to the linker to sort out duplicates) everywhere the header is used
(which may be in another module, even).

This is similar to commit 18b9f2b for SimulatorOutput.
2013-11-25 14:14:50 +01:00
Roland Kaufmann
8e6ccadfc3 Convert timestep numbers to correct base 2013-11-25 14:14:50 +01:00
Roland Kaufmann
c3bcd6c83c Use all uppercase in filenames
ERT already does the conversion for *some* of the files; we might as
well convert all the names so that there is no confusion.
2013-11-25 14:14:50 +01:00
Roland Kaufmann
d83d7d829c Writing output should not change the state
Therefore we take const parameters across the board. (This is a
follow-up to the patch which declared the UnstructuredGrid const).
2013-11-25 14:14:50 +01:00
Roland Kaufmann
eb276f79e1 Eliminate redundant timestep class
Since all construction should go through the wrapper method, and the
class otherwise just handed everything down to the base class, we might
as well inline everything in there to avoid someone starting to make
their own objects of this type.
2013-11-25 14:14:49 +01:00
Roland Kaufmann
06c370009a Add timesteps to a list and write at once in summary
Instead of having each timestep available just locally in the
writeTimeStep method, which will free the memory and create a
corruption error, keep all timesteps on a free list in the summary,
and do all the writing in the destructor there (the memory of the
individual timesteps will have to linger on anyway).
2013-11-25 14:14:49 +01:00
Roland Kaufmann
04ed5b23b4 Use timestep number as is
Why add one? They are already one based.
2013-11-25 14:14:49 +01:00
Roland Kaufmann
b9c667214d Write pressure and saturation as single-precision 2013-11-25 14:14:49 +01:00
Roland Kaufmann
f3df8d9cf9 Data copying takes an iterator, not necessarily vector 2013-11-25 14:14:49 +01:00
Roland Kaufmann
358f5f75c4 Use float instead of double keywords
ERT requires the type of the keywords that are passed to the grid
allocation routine to be float (and it is checked - causes abort if
there is a mismatch!)
2013-11-25 14:14:49 +01:00
Roland Kaufmann
f4b3e3ec56 Provide compatibility constructor for C++03 clients
Clients written to the C++03 standard (most of opm-core, really) do
obviously not use shared_ptr, and most likely takes references with
an implicit lifetime guarantee instead. Converting everything to
shared_ptr is a task for the long run.

This constructor provides the conversion routine that is most likely
to be used: To rely on the lifetime through convention, and then
wrapping everything with share_obj.

It should be considered deprecated out of the box; as soon as you
have the chance to use shared_ptr instead, you should do so.
2013-11-25 14:14:49 +01:00
Roland Kaufmann
6d444c2657 Define Event type completely
The Event type must be known because we call it from the inline template
method. The alternative is worse, we'd have to instantiate the template
for every possible simulator type in the .cpp!
2013-11-25 14:14:49 +01:00
Roland Kaufmann
c896df77cf Define destructor in .cpp to avoid defining members
If the compiler is to create the default destructor for us, it will
need the size of the OutputWriter type to be defined at the time of
inclusion in the header. By explicitly defining it in a compilation
unit, we can avoid that.
2013-11-25 14:14:49 +01:00
Roland Kaufmann
3c10785241 Use correct pointer indirection
When the sim parameter is a pointer to a simulator, we must of course
use indirect access to its field; the shared_ptr template class does not
have this method!
2013-11-25 14:14:49 +01:00
Roland Kaufmann
1baf7369ef Use constant grid in output writing
Grid manager returns a const UnstructuredGrid*, and the entire chain
of pointer-passing glory should adhere to this const-ness.
2013-11-25 14:14:48 +01:00
Roland Kaufmann
e02f0cd7de Use processed grid to figure out active cell map 2013-11-25 14:14:48 +01:00
Roland Kaufmann
cec6f12f50 Store reference to UnstructuredGrid in EclipseWriter 2013-11-25 14:14:48 +01:00
Roland Kaufmann
e978cbf848 Remove tucked away reference to parser in Sim.outp. 2013-11-25 14:14:48 +01:00
Roland Kaufmann
ce7eb44836 Propagate UnstructuredGrid to the EclipseWriter ctor
The writer will need to know which cells are the active cells after
post-processing (because these are the cells there is stored results
for in the pressure and saturation arrays), and thus not only the
raw input grid (to get the COORD and ZCORN arrays which is not easily
detainable from the UnstructuredGrid), *and* the UnstructuredGrid
needs to be available.
2013-11-25 14:14:48 +01:00
Roland Kaufmann
3b22d1b8f9 Remove superfluous backing class for share_obj
I originally wanted to make share_obj a class so that I could hide the
helper function, but it turned out that I needed a function after all
since a function template can be inferred from the parameters but the
type cannot from the constructor.

By returning a shared_ptr directly, the compiler can do return object
optimization.
2013-11-25 14:14:48 +01:00
Roland Kaufmann
f71eee34e1 Forgot header for partial_sum 2013-11-25 14:14:48 +01:00
Roland Kaufmann
b6c192fea5 Move shared object hack into more useful generic
The template function share_obj let you pass regular references
as shared pointers, which makes it easy (perhaps too easy) to quick-
fix old code which pass references and have stern warnings about the
lifetime rules of the objects in the documentation section instead.
2013-11-25 14:14:48 +01:00
Roland Kaufmann
f710ff71d1 Provide wrapper which connect simulator and writer
This wrapper class aggregate all the result objects (state, timer
etc.) and register itself for notification with the simulator. At
every timestep the simulator should provide a notification. The
wrapper will receive this and pass all the state objects to the
writer(s) which creates a new timestep.

Currently this doesn't work out-of-the-box because only the
two-phase simulator sends notifications and the writer only
understand the state of blackoil simulators, but these two concepts
should be unified.
2013-11-25 14:14:48 +01:00
Roland Kaufmann
ede84e6cc8 Add helper to use stack variables with shared_ptr
If an interface requires a shared_ptr, but we have an object that is
known to outlive the client anyway, we can use a custom deleter to
suppress the delete part and pass this object around anyway.
2013-11-25 14:14:48 +01:00
Roland Kaufmann
568e597561 Use shared_ptr to signal lifetime requirement
The code is now allowed to use C++11, where shared_ptr is available
in the standard. To specify that the parser object must be present
for the output writer in its entire lifetime, we require to be passed
a shared_ptr. (This can be faked for local storage anyway).
2013-11-25 14:14:47 +01:00
Roland Kaufmann
cd3e047957 Change formatting due to shorter names 2013-11-25 14:14:47 +01:00
Roland Kaufmann
7ea2f32bca Use correct order of saturation names
Due to a glitch the order of the names was put incorrectly in the file,
even though the comment stressed that it was important it was right!

Hat tip: @bska
2013-11-25 14:14:47 +01:00
Roland Kaufmann
39e7943618 Accomodate older versions of boost::filesystem
The return type of the path methods has changed in newer version of
Boost; by wrapping them with a new path object we can get a string
in a way that is compatible for both version 2 and 3.

Hat tip: @bska
2013-11-25 14:14:47 +01:00
Roland Kaufmann
b0b50618d0 Only write the declared phases to file
Only the phases that are specified in the input deck should be written.
Hence the class should work with both two- and three-phase simulations.
2013-11-25 14:14:47 +01:00
Roland Kaufmann
6f32b92f6c Renamed away extraneous verbosity in filenames 2013-11-25 14:14:47 +01:00
Roland Kaufmann
36dfc1db52 Assume positive rate for injectors, negative producers
The rate that is written to the file is always (if the flow is natural)
a positive value; for producers we flip the sign before writing.
2013-11-25 14:14:47 +01:00
Roland Kaufmann
c630220e6f Reorder loops to resemble future processing
We will look at the presence of keywords first, and then for each
keyword determine which wells it applies to.
2013-11-25 14:14:47 +01:00
Roland Kaufmann
441fd2825b Masquerade the actual output format with an interface
Using an interface allows us to code the simulator to just pass the
necessary state variables to something which implements this, and
then the user can select the actual output format with configuration
values. This allows us to set new formats without having to change
the code being compiled (for instance, we can have a special debug
"format" which prints out things of interest in each timestep)
2013-11-25 14:14:47 +01:00
Roland Kaufmann
992572c522 Don't rely on implicit inclusion 2013-11-25 14:14:47 +01:00
Roland Kaufmann
8a2fb74f0d Document limitations of type parameter for getValue 2013-11-25 14:14:46 +01:00
Roland Kaufmann
b53e9b952b Copy between arrays instead of function call
By getting a pointer directly into the data store, the copy can be
performed faster than calling a function for every item. Also, the
storage type of the array should now match the C++ one exactly (i.e.
no conversion to float).
2013-11-25 14:14:46 +01:00
Roland Kaufmann
d8db1acc75 Active cell flag is integral, not floating point type 2013-11-25 14:14:46 +01:00
Roland Kaufmann
82ed3dcd72 Refactor common constructor code into a function
GCC 4.4 doesn't handle calling another constructor in the same type.
(Allowed in C++11 but not supported in GCC 4.4's --std=c++0x mode)
2013-11-25 14:14:46 +01:00
Roland Kaufmann
cb14ee7ce8 Provide default (move) constructors and operators
C++11 will write a default move constructor that invoke the same in
the base class. However, GCC 4.4 doesn't support this, so we have to
explicitly give the implementation that would be generated on later
compilers.
2013-11-25 14:14:46 +01:00
Roland Kaufmann
74ed3d54c0 Avoid comparing signed and unsigned integers 2013-11-25 14:14:46 +01:00
Roland Kaufmann
4a6e502869 Use integer for counter and cast to enumeration 2013-11-25 14:14:46 +01:00
Roland Kaufmann
2b1ad42b9e Hide internals in its own namespace
If we put them in the anonymous namespace, then we cannot have a
reference to the types in the header (because that would mean different
things in each compilation unit).
2013-11-25 14:14:46 +01:00
Roland Kaufmann
351043f76e Explicitly mention template parameter for base class
GCC 4.4 doesn't understand that EclipseHandle (without template
parameter) is supposed to refer to the base class and not a field.
2013-11-25 14:14:46 +01:00
Roland Kaufmann
1a0b6f0eb6 Eliminate dependency on UnstructuredGrid
The only thing it was needed for was the number of cells in the grid,
and the Cartesian dimensions, and those are already available from other
structures.
2013-11-25 14:14:46 +01:00
Roland Kaufmann
9dc4df625f Correct parameter sequence
ecl_grid_alloc_GRDECL_kw takes zcorn first, then coord (slightly
unintuitive if you ask me), and this is also the order that is used
in EclipseGrid::make; thus, the order should be consistent through
the constructor also.
2013-11-25 14:14:45 +01:00
Roland Kaufmann
5a914a2852 Initialize writer with directories gotten from params 2013-11-25 14:14:45 +01:00
Roland Kaufmann
98a36189d3 Conditionally use input file
If config.h is written, then the build system will also define
HAVE_CONFIG_H.
2013-11-25 14:14:45 +01:00
Roland Kaufmann
cdc45b2d56 Trim needless header includes 2013-11-25 14:14:45 +01:00