units: introduce a "ContextDependent" dimension
this is meant for those nasty keywords where the dimension of an entry depends on a user-defined value of some field of a (potentially different) keyword. One example for this are the surface rates of the produced fluids for the .CON(INJ|PROD).* keywords which exhibit different units depending on whether the user choses to control for the surface gas or the liquid rate. the approach taken in this patch is to convert all numbers to NaN if the unit is queried in SI (via item->getSIDouble()). It might be more desireable to throw an exception in this case, but this approach would be more elaborate and NaNs should be quickly noticeable by the users of this code. I tried to adapt all implemented keywords, but it's quite likely that I missed some...
This commit is contained in:
@@ -24,7 +24,9 @@
|
||||
|
||||
#include <opm/parser/eclipse/Units/ConversionFactors.hpp>
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
|
||||
|
||||
namespace Opm {
|
||||
@@ -148,6 +150,7 @@ namespace Opm {
|
||||
system->addDimension("Density" , Metric::Density );
|
||||
system->addDimension("Viscosity" , Metric::Viscosity);
|
||||
system->addDimension("Timestep" , Metric::Timestep);
|
||||
system->addDimension("ContextDependent", std::numeric_limits<double>::quiet_NaN());
|
||||
return system;
|
||||
}
|
||||
|
||||
@@ -169,6 +172,7 @@ namespace Opm {
|
||||
system->addDimension("Density", Field::Density );
|
||||
system->addDimension("Viscosity", Field::Viscosity);
|
||||
system->addDimension("Timestep", Field::Timestep);
|
||||
system->addDimension("ContextDependent", std::numeric_limits<double>::quiet_NaN());
|
||||
return system;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user