This commit is contained in:
Kjetil Olsen Lye 2012-04-11 15:31:10 +02:00
commit 7f36232ba0
51 changed files with 2568 additions and 371 deletions

View File

@ -12,8 +12,6 @@ stamp-*
Makefile
Makefile.in
Doxyfile
Doxyfile.in
aclocal.m4
am
autom4te.cache

1717
Doxyfile Normal file

File diff suppressed because it is too large Load Diff

185
DoxygenLayout.xml Normal file
View File

@ -0,0 +1,185 @@
<doxygenlayout version="1.0">
<!-- Navigation index tabs for HTML output -->
<navindex>
<tab type="mainpage" visible="yes" title="OPM"/>
<tab type="pages" visible="yes" title="Tutorials" intro=""/>
<tab type="modules" visible="yes" title="" intro=""/>
<tab type="namespaces" visible="yes" title="">
<tab type="namespaces" visible="yes" title="" intro=""/>
<tab type="namespacemembers" visible="yes" title="" intro=""/>
</tab>
<tab type="classes" visible="yes" title="">
<tab type="classes" visible="yes" title="" intro=""/>
<tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
<tab type="hierarchy" visible="yes" title="" intro=""/>
<tab type="classmembers" visible="yes" title="" intro=""/>
</tab>
<tab type="files" visible="yes" title="">
<tab type="files" visible="yes" title="" intro=""/>
<tab type="globals" visible="yes" title="" intro=""/>
</tab>
<tab type="dirs" visible="yes" title="" intro=""/>
<tab type="examples" visible="yes" title="" intro=""/>
</navindex>
<!-- Layout definition for a class page -->
<class>
<briefdescription visible="yes"/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<inheritancegraph visible="$CLASS_GRAPH"/>
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
<allmemberslink visible="yes"/>
<memberdecl>
<nestedclasses visible="yes" title=""/>
<publictypes title=""/>
<publicslots title=""/>
<signals title=""/>
<publicmethods title=""/>
<publicstaticmethods title=""/>
<publicattributes title=""/>
<publicstaticattributes title=""/>
<protectedtypes title=""/>
<protectedslots title=""/>
<protectedmethods title=""/>
<protectedstaticmethods title=""/>
<protectedattributes title=""/>
<protectedstaticattributes title=""/>
<packagetypes title=""/>
<packagemethods title=""/>
<packagestaticmethods title=""/>
<packageattributes title=""/>
<packagestaticattributes title=""/>
<properties title=""/>
<events title=""/>
<privatetypes title=""/>
<privateslots title=""/>
<privatemethods title=""/>
<privatestaticmethods title=""/>
<privateattributes title=""/>
<privatestaticattributes title=""/>
<friends title=""/>
<related title="" subtitle=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<typedefs title=""/>
<enums title=""/>
<constructors title=""/>
<functions title=""/>
<related title=""/>
<variables title=""/>
<properties title=""/>
<events title=""/>
</memberdef>
<usedfiles visible="$SHOW_USED_FILES"/>
<authorsection visible="yes"/>
</class>
<!-- Layout definition for a namespace page -->
<namespace>
<briefdescription visible="yes"/>
<memberdecl>
<nestednamespaces visible="yes" title=""/>
<classes visible="yes" title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection visible="yes"/>
</namespace>
<!-- Layout definition for a file page -->
<file>
<briefdescription visible="yes"/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<includegraph visible="$INCLUDE_GRAPH"/>
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
<sourcelink visible="yes"/>
<memberdecl>
<classes visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection/>
</file>
<!-- Layout definition for a group page -->
<group>
<briefdescription visible="yes"/>
<groupgraph visible="$GROUP_GRAPHS"/>
<memberdecl>
<classes visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<dirs visible="yes" title=""/>
<nestedgroups visible="yes" title=""/>
<files visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<pagedocs/>
<inlineclasses title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
</memberdef>
<authorsection visible="yes"/>
</group>
<!-- Layout definition for a directory page -->
<directory>
<briefdescription visible="yes"/>
<directorygraph visible="yes"/>
<memberdecl>
<dirs visible="yes"/>
<files visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
</directory>
</doxygenlayout>

View File

@ -1,19 +1,36 @@
# Additional aclocal(1) macros located here.
ACLOCAL_AMFLAGS = -I m4
# Recurse to build examples after libraries
SUBDIRS = . tests examples
SUBDIRS = . tests examples tutorials
CPPFLAGS += $(BOOST_CPPFLAGS)
LIBS += $(BOOST_LDFLAGS) \
$(BOOST_FILESYSTEM_LIB) \
$(BOOST_SYSTEM_LIB) \
$(BOOST_DATE_TIME_LIB) \
$(BOOST_UNIT_TEST_FRAMEWORK_LIB) \
$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
# Declare libraries
# ----------------------------------------------------------------------
# Declare products (i.e., the library)
lib_LTLIBRARIES = libopmcore.la
# ----------------------------------------------------------------------
# Build-time flags needed to build libopmcore.la
AM_CPPFLAGS = \
$(BOOST_CPPFLAGS)
# ----------------------------------------------------------------------
# Link-time flags needed both to successfully link the library and to
# (transitively) convey inter-library dependency information.
libopmcore_la_LDFLAGS = \
$(BOOST_LDFLAGS) \
$(BOOST_FILESYSTEM_LIB) \
$(BOOST_SYSTEM_LIB) \
$(BOOST_DATE_TIME_LIB) \
$(BOOST_UNIT_TEST_FRAMEWORK_LIB) \
$(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS)
# ----------------------------------------------------------------------
# Library constituents. SOURCES followed by HEADERS.
#
# Please try to keep the list sorted.
libopmcore_la_SOURCES = \
opm/core/eclipse/EclipseGridInspector.cpp \
opm/core/eclipse/EclipseGridParser.cpp \
@ -33,6 +50,15 @@ opm/core/fluid/RockCompressibility.cpp \
opm/core/fluid/RockFromDeck.cpp \
opm/core/fluid/SaturationPropsBasic.cpp \
opm/core/fluid/SaturationPropsFromDeck.cpp \
opm/core/grid.c \
opm/core/grid/cart_grid.c \
opm/core/grid/cornerpoint_grid.c \
opm/core/grid/cpgpreprocess/geometry.c \
opm/core/grid/cpgpreprocess/preprocess.c \
opm/core/grid/cpgpreprocess/readvector.cpp \
opm/core/grid/cpgpreprocess/sparsetable.c \
opm/core/grid/cpgpreprocess/facetopology.c \
opm/core/grid/cpgpreprocess/uniquepoints.c \
opm/core/utility/MonotCubicInterpolator.cpp \
opm/core/utility/parameters/Parameter.cpp \
opm/core/utility/parameters/ParameterGroup.cpp \
@ -42,14 +68,6 @@ opm/core/utility/parameters/tinyxml/tinystr.cpp \
opm/core/utility/parameters/tinyxml/tinyxml.cpp \
opm/core/utility/parameters/tinyxml/tinyxmlerror.cpp \
opm/core/utility/parameters/tinyxml/tinyxmlparser.cpp \
opm/core/utility/cart_grid.c \
opm/core/utility/cpgpreprocess/geometry.c \
opm/core/utility/cpgpreprocess/preprocess.c \
opm/core/utility/cpgpreprocess/readvector.cpp \
opm/core/utility/cpgpreprocess/cgridinterface.c \
opm/core/utility/cpgpreprocess/sparsetable.c \
opm/core/utility/cpgpreprocess/facetopology.c \
opm/core/utility/cpgpreprocess/uniquepoints.c \
opm/core/utility/miscUtilities.cpp \
opm/core/utility/SimulatorTimer.cpp \
opm/core/utility/StopWatch.cpp \
@ -125,6 +143,15 @@ opm/core/fluid/blackoil/SinglePvtLiveGas.hpp \
opm/core/fluid/blackoil/SinglePvtLiveOil.hpp \
opm/core/fluid/blackoil/SinglePvtInterface.hpp \
opm/core/fluid/blackoil/SinglePvtConstCompr.hpp \
opm/core/grid/cart_grid.h \
opm/core/grid/cornerpoint_grid.h \
opm/core/grid/cpgpreprocess/readvector.hpp \
opm/core/grid/cpgpreprocess/uniquepoints.h \
opm/core/grid/cpgpreprocess/preprocess.h \
opm/core/grid/cpgpreprocess/sparsetable.h \
opm/core/grid/cpgpreprocess/geometry.h \
opm/core/grid/cpgpreprocess/facetopology.h \
opm/core/grid/cpgpreprocess/grdecl.h \
opm/core/utility/Average.hpp \
opm/core/utility/ErrorMacros.hpp \
opm/core/utility/Factory.hpp \
@ -152,15 +179,6 @@ opm/core/utility/initState_impl.hpp \
opm/core/utility/linInt.hpp \
opm/core/utility/linearInterpolation.hpp \
opm/core/utility/miscUtilities.hpp \
opm/core/utility/cpgpreprocess/readvector.hpp \
opm/core/utility/cpgpreprocess/uniquepoints.h \
opm/core/utility/cpgpreprocess/preprocess.h \
opm/core/utility/cpgpreprocess/sparsetable.h \
opm/core/utility/cpgpreprocess/cgridinterface.h \
opm/core/utility/cpgpreprocess/geometry.h \
opm/core/utility/cpgpreprocess/facetopology.h \
opm/core/utility/cpgpreprocess/grdecl.h \
opm/core/utility/cart_grid.h \
opm/core/utility/writeVtkData.hpp \
opm/core/linalg/sparse_sys.h \
opm/core/linalg/blas_lapack.h \
@ -221,6 +239,8 @@ opm/core/transport/reorder/nlsolvers.h \
opm/core/transport/reorder/reordersequence.h \
opm/core/transport/reorder/tarjan.h
# ----------------------------------------------------------------------
# Optional library constituents.
if UMFPACK
libopmcore_la_SOURCES += \

View File

@ -84,6 +84,7 @@ AC_CONFIG_FILES([
Makefile
tests/Makefile
examples/Makefile
tutorials/Makefile
])
AC_OUTPUT

View File

@ -2,26 +2,16 @@ AM_CPPFLAGS = \
-I$(top_srcdir) \
$(BOOST_CPPFLAGS)
LDFLAGS = $(BOOST_LDFLAGS)
LDADD = $(top_builddir)/libopmcore.la
noinst_PROGRAMS = \
scaneclipsedeck
if UMFPACK
noinst_PROGRAMS += spu_2p
spu_2p_SOURCES = spu_2p.cpp
spu_2p_LDADD = \
$(BOOST_FILESYSTEM_LIB) \
$(BOOST_SYSTEM_LIB) \
$(LDADD) \
$(LAPACK_LIBS)
endif
noinst_PROGRAMS += \
spu_2p \
wells_example
noinst_PROGRAMS += wells_example
wells_example_SOURCES = wells_example.cpp
wells_example_LDADD = \
$(BOOST_FILESYSTEM_LIB) \
$(BOOST_SYSTEM_LIB) \
$(LDADD)
spu_2p_SOURCES = spu_2p.cpp
wells_example_SOURCES = wells_example.cpp
endif

28
generate_doc_figures.py Executable file
View File

@ -0,0 +1,28 @@
from subprocess import call
from paraview.simple import *
from paraview import servermanager
from os import remove
call("tutorials/tutorial1")
connection = servermanager.Connect()
grid = servermanager.sources.XMLUnstructuredGridReader(FileName="tutorial1.vtu")
grid.UpdatePipeline()
Show(grid)
dp = GetDisplayProperties(grid)
dp.Representation = 'Wireframe'
dp.LineWidth = 5
dp.AmbientColor = [1, 0, 0]
view = GetActiveView()
view.Background = [1, 1, 1]
camera = GetActiveCamera()
camera.SetViewUp(0.5,0.3,0.7)
camera.SetViewAngle(30)
camera.SetFocalPoint(1,1,0.5)
Render()
WriteImage("Figure/tutorial1.png")
remove("tutorial1.vtu")

View File

@ -20,8 +20,8 @@
#include <opm/core/GridManager.hpp>
#include <opm/core/eclipse/EclipseGridParser.hpp>
#include <opm/core/grid.h>
#include <opm/core/utility/cart_grid.h>
#include <opm/core/utility/cpgpreprocess/cgridinterface.h>
#include <opm/core/grid/cart_grid.h>
#include <opm/core/grid/cornerpoint_grid.h>
@ -58,12 +58,11 @@ namespace Opm
grdecl.dims[1] = dims[1];
grdecl.dims[2] = dims[2];
// Process and compute.
ug_ = preprocess(&grdecl, 0.0);
// Process grid.
ug_ = create_grid_cornerpoint(&grdecl, 0.0);
if (!ug_) {
THROW("Failed to construct grid.");
}
compute_geometry(ug_);
}
@ -72,7 +71,7 @@ namespace Opm
/// Construct a 2d cartesian grid with cells of unit size.
GridManager::GridManager(int nx, int ny)
{
ug_ = create_cart_grid_2d(nx, ny);
ug_ = create_grid_cart2d(nx, ny);
if (!ug_) {
THROW("Failed to construct grid.");
}
@ -84,7 +83,7 @@ namespace Opm
/// Construct a 3d cartesian grid with cells of unit size.
GridManager::GridManager(int nx, int ny, int nz)
{
ug_ = create_cart_grid_3d(nx, ny, nz);
ug_ = create_grid_cart3d(nx, ny, nz);
if (!ug_) {
THROW("Failed to construct grid.");
}
@ -95,9 +94,9 @@ namespace Opm
/// Construct a 3d cartesian grid with cells of size [dx, dy, dz].
GridManager::GridManager(int nx, int ny, int nz,
double dx, double dy, double dz)
double dx, double dy, double dz)
{
ug_ = create_hexa_grid_3d(nx, ny, nz, dx, dy, dz);
ug_ = create_grid_hexa3d(nx, ny, nz, dx, dy, dz);
if (!ug_) {
THROW("Failed to construct grid.");
}
@ -109,7 +108,7 @@ namespace Opm
/// Destructor.
GridManager::~GridManager()
{
free_grid(ug_);
destroy_grid(ug_);
}

View File

@ -10,10 +10,12 @@
namespace Opm
{
WellsGroupInterface::WellsGroupInterface(const std::string& name, ProductionSpecification prod_spec,
InjectionSpecification inje_spec)
: name_(name), production_specification_(prod_spec),
injection_specification_(inje_spec)
WellsGroupInterface::WellsGroupInterface(const std::string& myname,
ProductionSpecification prod_spec,
InjectionSpecification inje_spec)
: name_(myname),
production_specification_(prod_spec),
injection_specification_(inje_spec)
{
}
@ -26,13 +28,15 @@ namespace Opm
return name_;
}
WellsGroup::WellsGroup(const std::string& name, ProductionSpecification prod_spec,
InjectionSpecification inj_spec)
: WellsGroupInterface(name, prod_spec, inj_spec)
WellsGroup::WellsGroup(const std::string& myname,
ProductionSpecification prod_spec,
InjectionSpecification inj_spec)
: WellsGroupInterface(myname, prod_spec, inj_spec)
{
}
bool WellsGroupInterface::isLeafNode() const {
bool WellsGroupInterface::isLeafNode() const
{
return false;
}
@ -53,13 +57,15 @@ namespace Opm
}
}
void WellsGroup::addChild(std::tr1::shared_ptr<WellsGroupInterface> child) {
void WellsGroup::addChild(std::tr1::shared_ptr<WellsGroupInterface> child)
{
children_.push_back(child);
}
WellNode::WellNode(const std::string& name, ProductionSpecification prod_spec,
InjectionSpecification inj_spec)
: WellsGroupInterface(name, prod_spec, inj_spec)
WellNode::WellNode(const std::string& myname,
ProductionSpecification prod_spec,
InjectionSpecification inj_spec)
: WellsGroupInterface(myname, prod_spec, inj_spec)
{
}
@ -73,103 +79,108 @@ namespace Opm
}
bool WellNode::isLeafNode() const {
bool WellNode::isLeafNode() const
{
return true;
}
surface_component toSurfaceComponent(std::string type)
namespace
{
if (type == "OIL") {
return OIL;
}
if (type == "WATER") {
return WATER;
}
if (type == "GAS") {
return GAS;
}
THROW("Unknown type " << type << ", could not convert to surface_component");
}
InjectionSpecification::ControlMode toInjectionControlMode(std::string type)
{
if (type == "NONE") {
return InjectionSpecification::NONE;
surface_component toSurfaceComponent(std::string type)
{
if (type == "OIL") {
return OIL;
}
if (type == "WATER") {
return WATER;
}
if (type == "GAS") {
return GAS;
}
THROW("Unknown type " << type << ", could not convert to surface_component");
}
if (type == "ORAT") {
return InjectionSpecification::ORAT;
}
if (type == "REIN") {
return InjectionSpecification::REIN;
}
if (type == "RESV") {
return InjectionSpecification::RESV;
}
if (type == "VREP") {
return InjectionSpecification::VREP;
}
if (type == "WGRA") {
return InjectionSpecification::WGRA;
}
if (type == "FLD") {
return InjectionSpecification::FLD;
}
if (type == "GRUP") {
return InjectionSpecification::GRUP;
}
InjectionSpecification::ControlMode toInjectionControlMode(std::string type)
{
if (type == "NONE") {
return InjectionSpecification::NONE;
}
if (type == "ORAT") {
return InjectionSpecification::ORAT;
}
if (type == "REIN") {
return InjectionSpecification::REIN;
}
if (type == "RESV") {
return InjectionSpecification::RESV;
}
if (type == "VREP") {
return InjectionSpecification::VREP;
}
if (type == "WGRA") {
return InjectionSpecification::WGRA;
}
if (type == "FLD") {
return InjectionSpecification::FLD;
}
if (type == "GRUP") {
return InjectionSpecification::GRUP;
}
THROW("Unknown type " << type << ", could not convert to ControlMode.");
}
ProductionSpecification::ControlMode toProductionControlMode(std::string type)
{
if (type == "NONE") {
return ProductionSpecification::NONE_CM;
}
if (type == "ORAT") {
return ProductionSpecification::ORAT;
}
if (type == "REIN") {
return ProductionSpecification::REIN;
}
if (type == "RESV") {
return ProductionSpecification::RESV;
}
if (type == "VREP") {
return ProductionSpecification::VREP;
}
if (type == "WGRA") {
return ProductionSpecification::WGRA;
}
if (type == "FLD") {
return ProductionSpecification::FLD;
}
if (type == "GRUP") {
return ProductionSpecification::GRUP;
THROW("Unknown type " << type << ", could not convert to ControlMode.");
}
THROW("Unknown type " << type << ", could not convert to ControlMode.");
}
ProductionSpecification::ControlMode toProductionControlMode(std::string type)
{
if (type == "NONE") {
return ProductionSpecification::NONE_CM;
}
if (type == "ORAT") {
return ProductionSpecification::ORAT;
}
if (type == "REIN") {
return ProductionSpecification::REIN;
}
if (type == "RESV") {
return ProductionSpecification::RESV;
}
if (type == "VREP") {
return ProductionSpecification::VREP;
}
if (type == "WGRA") {
return ProductionSpecification::WGRA;
}
if (type == "FLD") {
return ProductionSpecification::FLD;
}
if (type == "GRUP") {
return ProductionSpecification::GRUP;
}
THROW("Unknown type " << type << ", could not convert to ControlMode.");
}
ProductionSpecification::Procedure toProductionProcedure(std::string type)
{
if (type == "NONE") {
return ProductionSpecification::NONE_P;
}
if (type == "RATE") {
return ProductionSpecification::RATE;
}
if (type == "WELL") {
return ProductionSpecification::WELL;
}
ProductionSpecification::Procedure toProductionProcedure(std::string type)
{
if (type == "NONE") {
return ProductionSpecification::NONE_P;
}
if (type == "RATE") {
return ProductionSpecification::RATE;
}
if (type == "WELL") {
return ProductionSpecification::WELL;
}
THROW("Unknown type " << type << ", could not convert to ControlMode.");
}
THROW("Unknown type " << type << ", could not convert to ControlMode.");
}
} // anonymous namespace
std::tr1::shared_ptr<WellsGroupInterface> createWellsGroup(std::string name, const EclipseGridParser& deck)
{
@ -252,8 +263,7 @@ namespace Opm
return_value.reset(new WellsGroup(name, production_specification, injection_specification));
}
return return_value;
}
}
}

View File

@ -13,8 +13,9 @@ namespace Opm
class WellsGroupInterface
{
public:
WellsGroupInterface(const std::string& name, ProductionSpecification prod_spec,
InjectionSpecification inj_spec);
WellsGroupInterface(const std::string& name,
ProductionSpecification prod_spec,
InjectionSpecification inj_spec);
virtual ~WellsGroupInterface();
/// The unique identifier for the well or well group.
@ -38,35 +39,39 @@ namespace Opm
InjectionSpecification injection_specification_;
};
class WellsGroup : public WellsGroupInterface
{
public:
WellsGroup(const std::string& name, ProductionSpecification prod_spec,
InjectionSpecification inj_spec);
WellsGroup(const std::string& name,
ProductionSpecification prod_spec,
InjectionSpecification inj_spec);
virtual WellsGroupInterface* findGroup(std::string name_of_node);
void addChild(std::tr1::shared_ptr<WellsGroupInterface> child);
private:
std::vector<std::tr1::shared_ptr<WellsGroupInterface> > children_;
};
class WellNode : public WellsGroupInterface
{
public:
WellNode(const std::string& name, ProductionSpecification prod_spec,
WellNode(const std::string& name,
ProductionSpecification prod_spec,
InjectionSpecification inj_spec);
virtual WellsGroupInterface* findGroup(std::string name_of_node);
virtual bool isLeafNode() const;
};
/// Doc me!
std::tr1::shared_ptr<WellsGroupInterface> createWellsGroup(std::string name,
const EclipseGridParser& deck);
const EclipseGridParser& deck);
}

View File

@ -516,15 +516,10 @@ namespace Opm
}
}
if(deck.hasField("WELSPECS")) {
WELSPECS welspecs = deck.getWELSPECS();
for(size_t i = 0; i < welspecs.welspecs.size(); ++i) {
WelspecsLine line = welspecs.welspecs[i];
wells_.addChild(line.name_, line.group_, deck);
}
for (size_t i = 0; i < welspecs.welspecs.size(); ++i) {
WelspecsLine line = welspecs.welspecs[i];
wells_.addChild(line.name_, line.group_, deck);
}
}

View File

@ -125,7 +125,7 @@ namespace Opm
double B[2]; // Must be enough since component classes do not handle more than 2.
pvt_.B(1, 0, 0, B);
// Compute A matrix
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
double* m = A + i*np*np;
std::fill(m, m + np*np, 0.0);
@ -137,66 +137,12 @@ namespace Opm
// Derivative of A matrix.
if (dAdp) {
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
double* m = dAdp + i*np*np;
std::fill(m, m + np*np, 0.0);
}
}
#if 0
// This is copied from BlackoilPropertiesFromDeck.
const int np = numPhases();
B_.resize(n*np);
R_.resize(n*np);
if (dAdp) {
dB_.resize(n*np);
dR_.resize(n*np);
pvt_.dBdp(n, p, z, &B_[0], &dB_[0]);
pvt_.dRdp(n, p, z, &R_[0], &dR_[0]);
} else {
pvt_.B(n, p, z, &B_[0]);
pvt_.R(n, p, z, &R_[0]);
}
const int* phase_pos = pvt_.phasePosition();
bool oil_and_gas = pvt_.phaseUsed()[BlackoilPhases::Liquid] &&
pvt_.phaseUsed()[BlackoilPhases::Vapour];
const int o = phase_pos[BlackoilPhases::Liquid];
const int g = phase_pos[BlackoilPhases::Vapour];
// Compute A matrix
#pragma omp parallel for
for (int i = 0; i < n; ++i) {
double* m = A + i*np*np;
std::fill(m, m + np*np, 0.0);
// Diagonal entries.
for (int phase = 0; phase < np; ++phase) {
m[phase + phase*np] = 1.0/B_[i*np + phase];
}
// Off-diagonal entries.
if (oil_and_gas) {
m[o + g*np] = R_[i*np + g]/B_[i*np + g];
m[g + o*np] = R_[i*np + o]/B_[i*np + o];
}
}
// Derivative of A matrix.
if (dAdp) {
#pragma omp parallel for
for (int i = 0; i < n; ++i) {
double* m = dAdp + i*np*np;
std::fill(m, m + np*np, 0.0);
// Diagonal entries.
for (int phase = 0; phase < np; ++phase) {
m[phase + phase*np] = -dB_[i*np + phase]/B_[i*np + phase]*B_[i*np + phase];
}
// Off-diagonal entries.
if (oil_and_gas) {
m[o + g*np] = m[g + g*np]*R_[i*np + g] + dR_[i*np + g]/B_[i*np + g];
m[g + o*np] = m[o + o*np]*R_[i*np + o] + dR_[i*np + o]/B_[i*np + o];
}
}
}
#endif
}
/// \param[in] n Number of data points.
@ -211,7 +157,7 @@ namespace Opm
{
const int np = numPhases();
const double* sdens = pvt_.surfaceDensities();
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
for (int phase = 0; phase < np; ++phase) {
rho[np*i + phase] = 0.0;

View File

@ -131,7 +131,7 @@ namespace Opm
const int g = phase_pos[BlackoilPhases::Vapour];
// Compute A matrix
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
double* m = A + i*np*np;
std::fill(m, m + np*np, 0.0);
@ -148,7 +148,7 @@ namespace Opm
// Derivative of A matrix.
if (dAdp) {
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
double* m = dAdp + i*np*np;
std::fill(m, m + np*np, 0.0);
@ -177,7 +177,7 @@ namespace Opm
{
const int np = numPhases();
const double* sdens = pvt_.surfaceDensities();
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
for (int phase = 0; phase < np; ++phase) {
rho[np*i + phase] = 0.0;

View File

@ -79,7 +79,7 @@ namespace Opm
{
const int np = numPhases();
for (int phase = 0; phase < np; ++phase) {
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_mu[np*i + phase] = viscosity_[phase];
}
@ -93,7 +93,7 @@ namespace Opm
{
const int np = numPhases();
for (int phase = 0; phase < np; ++phase) {
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_B[np*i + phase] = formation_volume_factor_[phase];
}
@ -108,7 +108,7 @@ namespace Opm
{
const int np = numPhases();
for (int phase = 0; phase < np; ++phase) {
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_B[np*i + phase] = formation_volume_factor_[phase];
output_dBdp[np*i + phase] = 0.0;

View File

@ -42,7 +42,7 @@ namespace Opm
permeability_.clear();
const int dsq = dimensions*dimensions;
permeability_.resize(num_cells*dsq, 0.0);
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < num_cells; ++i) {
for (int d = 0; d < dimensions; ++d) {
permeability_[dsq*i + dimensions*d + d] = perm;

View File

@ -71,13 +71,13 @@ namespace Opm
const double* s, double* kr, double* dkrds, Fun fun)
{
if (dkrds == 0) {
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n*np; ++i) {
kr[i] = fun.kr(s[i]);
}
return;
}
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
std::fill(dkrds + i*np*np, dkrds + (i+1)*np*np, 0.0);
for (int phase = 0; phase < np; ++phase) {

View File

@ -111,12 +111,12 @@ namespace Opm
{
const int np = phase_usage_.num_phases;
if (dkrds) {
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
evalKrDeriv(s + np*i, kr + np*i, dkrds + np*np*i);
}
} else {
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
evalKr(s + np*i, kr + np*i);
}
@ -142,12 +142,12 @@ namespace Opm
{
const int np = phase_usage_.num_phases;
if (dpcds) {
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
evalPcDeriv(s + np*i, pc + np*i, dpcds + np*np*i);
}
} else {
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
evalPc(s + np*i, pc + np*i);
}

View File

@ -134,7 +134,7 @@ namespace Opm
data1_.resize(n);
for (int phase = 0; phase < phase_usage_.num_phases; ++phase) {
props_[phase]->mu(n, p, z, &data1_[0]);
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_mu[phase_usage_.num_phases*i + phase] = data1_[i];
}
@ -149,7 +149,7 @@ namespace Opm
data1_.resize(n);
for (int phase = 0; phase < phase_usage_.num_phases; ++phase) {
props_[phase]->B(n, p, z, &data1_[0]);
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_B[phase_usage_.num_phases*i + phase] = data1_[i];
}
@ -166,7 +166,7 @@ namespace Opm
data2_.resize(n);
for (int phase = 0; phase < phase_usage_.num_phases; ++phase) {
props_[phase]->dBdp(n, p, z, &data1_[0], &data2_[0]);
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_B[phase_usage_.num_phases*i + phase] = data1_[i];
output_dBdp[phase_usage_.num_phases*i + phase] = data2_[i];
@ -183,7 +183,7 @@ namespace Opm
data1_.resize(n);
for (int phase = 0; phase < phase_usage_.num_phases; ++phase) {
props_[phase]->R(n, p, z, &data1_[0]);
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_R[phase_usage_.num_phases*i + phase] = data1_[i];
}
@ -200,7 +200,7 @@ namespace Opm
data2_.resize(n);
for (int phase = 0; phase < phase_usage_.num_phases; ++phase) {
props_[phase]->dRdp(n, p, z, &data1_[0], &data2_[0]);
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_R[phase_usage_.num_phases*i + phase] = data1_[i];
output_dRdp[phase_usage_.num_phases*i + phase] = data2_[i];

View File

@ -81,7 +81,7 @@ namespace Opm
double* output_B) const
{
if (comp_) {
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
// Computing a polynomial approximation to the exponential.
double x = comp_*(p[i] - ref_press_);
@ -100,7 +100,7 @@ namespace Opm
{
B(n, p, 0, output_B);
if (comp_) {
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_dBdp[i] = -comp_*output_B[i];
}

View File

@ -75,7 +75,7 @@ namespace Opm
const double* /*z*/,
double* output_mu) const
{
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_mu[i] = viscosity_(p[i]);
}
@ -86,7 +86,7 @@ namespace Opm
const double* /*z*/,
double* output_B) const
{
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_B[i] = 1.0/one_over_B_(p[i]);
}
@ -99,7 +99,7 @@ namespace Opm
double* output_dBdp) const
{
B(n, p, 0, output_B);
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
double Bg = output_B[i];
output_dBdp[i] = -Bg*Bg*one_over_B_.derivative(p[i]);

View File

@ -91,7 +91,7 @@ namespace Opm
const double* z,
double* output_mu) const
{
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_mu[i] = miscible_gas(p[i], z + num_phases_*i, 2, false);
}
@ -104,7 +104,7 @@ namespace Opm
const double* z,
double* output_B) const
{
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_B[i] = evalB(p[i], z + num_phases_*i);
}
@ -119,7 +119,7 @@ namespace Opm
double* output_B,
double* output_dBdp) const
{
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
evalBDeriv(p[i], z + num_phases_*i, output_B[i], output_dBdp[i]);
}
@ -132,7 +132,7 @@ namespace Opm
const double* z,
double* output_R) const
{
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_R[i] = evalR(p[i], z + num_phases_*i);
}
@ -147,7 +147,7 @@ namespace Opm
double* output_R,
double* output_dRdp) const
{
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
evalRDeriv(p[i], z + num_phases_*i, output_R[i], output_dRdp[i]);
}

View File

@ -168,7 +168,7 @@ namespace Opm
const double* z,
double* output_mu) const
{
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_mu[i] = miscible_oil(p[i], z + num_phases_*i, 2, false);
}
@ -181,7 +181,7 @@ namespace Opm
const double* z,
double* output_B) const
{
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_B[i] = evalB(p[i], z + num_phases_*i);
}
@ -196,7 +196,7 @@ namespace Opm
double* output_B,
double* output_dBdp) const
{
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
evalBDeriv(p[i], z + num_phases_*i, output_B[i], output_dBdp[i]);
}
@ -209,7 +209,7 @@ namespace Opm
const double* z,
double* output_R) const
{
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
output_R[i] = evalR(p[i], z + num_phases_*i);
}
@ -224,7 +224,7 @@ namespace Opm
double* output_R,
double* output_dRdp) const
{
#pragma omp parallel for
// #pragma omp parallel for
for (int i = 0; i < n; ++i) {
evalRDeriv(p[i], z + num_phases_*i, output_R[i], output_dRdp[i]);
}

46
opm/core/grid.c Normal file
View File

@ -0,0 +1,46 @@
/*
Copyright 2012 SINTEF ICT, Applied Mathematics.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/core/grid.h>
#include <stdlib.h>
void destroy_grid(struct UnstructuredGrid *g)
{
if (g!=NULL)
{
free(g->face_nodes);
free(g->face_nodepos);
free(g->face_cells);
free(g->cell_facepos);
free(g->cell_faces);
free(g->node_coordinates);
free(g->face_centroids);
free(g->face_areas);
free(g->face_normals);
free(g->cell_centroids);
free(g->cell_volumes);
free(g->global_cell);
free(g->cell_facetag);
}
free(g);
}

View File

@ -25,37 +25,203 @@
extern "C" {
#endif
/*
---- synopsis of grid.h ----
struct UnstructuredGrid {
struct UnstructuredGrid
{
int dimensions;
int number_of_cells;
int number_of_faces;
int number_of_nodes;
int *face_nodes;
int *face_nodepos;
int *face_cells;
int *cell_faces;
int *cell_facepos;
double *node_coordinates;
double *face_centroids;
double *face_areas;
double *face_normals;
double *cell_centroids;
double *cell_volumes;
int *global_cell;
int cartdims[3];
int *cell_facetag;
};
void destroy_grid(struct UnstructuredGrid *g);
---- end of synopsis of grid.h ----
*/
/**
Data structure for an unstructured grid, unstructured meaning that
any cell may have an arbitrary number of adjacent cells. The struct
contains both topological and geometrical data.
The grid consists of a set of cells, which are assumed to partion
the grid domain. A face is defined as the nonempty intersection of
(the closure of) two grid cells (the grid is a cell complex).
The topology information is limited to some adjacency relations
between cells, faces and nodes only. The data structure does not
contain any information pertaining to edges (except in 2d, where
edges are the same as faces).
The geometry information is limited to centroids, areas/volumes and
normals.
*/
struct UnstructuredGrid
{
/**
The topological and geometrical dimensionality of the
grid. Note that we do not support grids that are embedded in
higher-dimensional spaces, such as 2d grids embedded in 3d.
This number must be 2 or 3.
*/
int dimensions;
/** The number of cells in the grid. */
int number_of_cells;
/** The number of faces in the grid. */
int number_of_faces;
/** The number of nodes in the grid. */
int number_of_nodes;
/**
Contains for each face, the indices of its adjacent nodes.
The size of the array is equal to the sum over all faces of
each face's number of adjacent nodes, which also is equal to
face_nodepos[number_of_faces].
*/
int *face_nodes;
/**
For a face f, face_nodepos[f] contains the starting index
for f's nodes in the face_nodes array.
The size of the array is equal to (number_of_faces + 1).
*/
int *face_nodepos;
/**
For a face f, face_cells[2*f] and face_cells[2*f + 1] contain
the cell indices of the cells adjacent to f. The number -1
indicates the outer boundary.
The order is significant, as it gives the orientation: if
face_cells[2*f] == a and face_cells[2*f + 1] == b, f is
oriented from a to b. The inverse of this mapping is stored in
cell_faces and cell_facepos.
The size of the array is equal to (2*number_of_faces).
*/
int *face_cells;
/**
Contains for each cell, the indices of its adjacent faces.
The size of the array is equal to the sum over all cells of
each cell's number of adjacent faces, which also is equal to
cell_facepos[number_of_cells].
*/
int *cell_faces;
/**
For a face c, cell_facepos[c] contains the starting index
for c's faces in the cell_faces array.
The size of the array is equal to (number_of_cells + 1).
*/
int *cell_facepos;
/**
Node coordinates, stored consecutively for each node. That is,
for a node i, node_coordinates[dimensions*i + d] contains the
d'th coordinate of node i.
The size of the array is equal to (dimensions*number_of_nodes).
*/
double *node_coordinates;
/**
Exact or approximate face centroids, stored consecutively for each face. That is,
for a face f, face_centroids[dimensions*f + d] contains the
d'th coordinate of f's centroid.
The size of the array is equal to (dimensions*number_of_faces).
*/
double *face_centroids;
/**
Exact or approximate face areas.
The size of the array is equal to number_of_faces.
*/
double *face_areas;
/**
Exact or approximate face normals, stored consecutively for
each face. That is, for a face f, face_normals[dimensions*f + d]
contains the d'th coordinate of f's normal.
The size of the array is equal to (dimensions*number_of_faces).
IMPORTANT: the normals are not normalized to have unit length!
They are assumed to always have length equal to the
corresponding face's area.
*/
double *face_normals;
/**
Exact or approximate cell centroids, stored consecutively for each cell. That is,
for a cell c, cell_centroids[dimensions*c + d] contains the
d'th coordinate of c's centroid.
The size of the array is equal to (dimensions*number_of_cells).
*/
double *cell_centroids;
/**
Exact or approximate cell volumes.
The size of the array is equal to number_of_cells.
*/
double *cell_volumes;
/**
If non-null, this array contains the logical cartesian indices
(in a lexicographic ordering) of each cell.
In that case, the array size is equal to number_of_cells.
This field is intended for grids that have a (possibly
degenerate) logical cartesian structure, for example
cornerpoint grids.
*/
int *global_cell;
/**
Contains the size of the logical cartesian structure (if any) of the grid.
This field is intended for grids that have a (possibly
degenerate) logical cartesian structure, for example
cornerpoint grids.
*/
int cartdims[3];
/**
If non-null, this array contains a number for cell-face
adjacency indicating the face's position with respect to the
cell, in a logical cartesian sense. The tags are in [0, ..., 5]
meaning [I-, I+, J-, J+, K-, K+], where I, J, K are the logical
cartesian principal directions.
The structure of this array is identical to cell_faces, and
cell_facepos indices into cell_facetag as well.
If non-null, the array size is equal to
cell_facepos[number_of_cells].
This field is intended for grids that have a (possibly
degenerate) logical cartesian structure, for example
cornerpoint grids.
*/
int *cell_facetag;
};
/**
Destroy and deallocate an UnstructuredGrid and all its data.
This function assumes that all arrays of the UnstructuredGrid (if
non-null) have been individually allocated by malloc(). They will
be deallocated with free().
*/
void destroy_grid(struct UnstructuredGrid *g);
#ifdef __cplusplus
}
#endif

View File

@ -31,9 +31,9 @@
#include <stdio.h>
#include <opm/core/grid.h>
#include <opm/core/utility/cpgpreprocess/cgridinterface.h>
#include <opm/core/grid/cornerpoint_grid.h>
#include "cart_grid.h"
#include <opm/core/grid/cart_grid.h>
static struct UnstructuredGrid *allocate_cart_grid_3d(int nx, int ny, int nz);
static void fill_cart_topology_3d(struct UnstructuredGrid *G);
@ -49,14 +49,14 @@ fill_layered_geometry_3d(struct UnstructuredGrid *G,
const double *depthz);
struct UnstructuredGrid *
create_cart_grid_3d(int nx, int ny, int nz)
create_grid_cart3d(int nx, int ny, int nz)
{
return create_hexa_grid_3d(nx, ny, nz, 1.0, 1.0, 1.0);
return create_grid_hexa3d(nx, ny, nz, 1.0, 1.0, 1.0);
}
struct UnstructuredGrid *
create_hexa_grid_3d(int nx, int ny, int nz,
double dx, double dy, double dz)
create_grid_hexa3d(int nx, int ny, int nz,
double dx, double dy, double dz)
{
int i;
double *x, *y, *z;
@ -73,8 +73,8 @@ create_hexa_grid_3d(int nx, int ny, int nz,
for (i = 0; i < ny + 1; i++) { y[i] = i * dy; }
for (i = 0; i < nz + 1; i++) { z[i] = i * dz; }
G = create_tensor_grid_3d(nx, ny, nz, x, y, z,
(const double *) NULL);
G = create_grid_tensor3d(nx, ny, nz, x, y, z,
(const double *) NULL);
}
free(z); free(y); free(x);
@ -91,7 +91,7 @@ static void fill_cart_geometry_2d(struct UnstructuredGrid *G,
const double *y);
struct UnstructuredGrid*
create_cart_grid_2d(int nx, int ny)
create_grid_cart2d(int nx, int ny)
{
int i;
double *x, *y;
@ -107,7 +107,7 @@ create_cart_grid_2d(int nx, int ny)
for (i = 0; i < nx + 1; i++) { x[i] = i; }
for (i = 0; i < ny + 1; i++) { y[i] = i; }
G = create_tensor_grid_2d(nx, ny, x, y);
G = create_grid_tensor2d(nx, ny, x, y);
}
free(y); free(x);
@ -118,7 +118,7 @@ create_cart_grid_2d(int nx, int ny)
/* --------------------------------------------------------------------- */
struct UnstructuredGrid *
create_tensor_grid_2d(int nx, int ny, double x[], double y[])
create_grid_tensor2d(int nx, int ny, double x[], double y[])
{
struct UnstructuredGrid *G;
@ -136,7 +136,7 @@ create_tensor_grid_2d(int nx, int ny, double x[], double y[])
/* --------------------------------------------------------------------- */
struct UnstructuredGrid *
create_tensor_grid_3d(int nx, int ny , int nz ,
create_grid_tensor3d(int nx, int ny , int nz ,
double x[], double y[], double z[],
const double depthz[])
{
@ -218,7 +218,7 @@ allocate_cart_grid_3d(int nx, int ny, int nz)
(G->cell_centroids == NULL ) ||
(G->cell_volumes == NULL ) )
{
free_grid(G);
destroy_grid(G);
G = NULL;
}
}
@ -553,7 +553,7 @@ allocate_cart_grid_2d(int nx, int ny)
(G->cell_centroids == NULL ) ||
(G->cell_volumes == NULL ) )
{
free_grid(G);
destroy_grid(G);
G = NULL;
}
}

View File

@ -36,17 +36,17 @@ extern "C" {
struct UnstructuredGrid;
struct UnstructuredGrid *create_cart_grid_2d(int nx, int ny);
struct UnstructuredGrid *create_cart_grid_3d(int nx, int ny, int nz);
struct UnstructuredGrid *create_hexa_grid_3d(int nx, int ny, int nz,
struct UnstructuredGrid *create_grid_cart2d(int nx, int ny);
struct UnstructuredGrid *create_grid_cart3d(int nx, int ny, int nz);
struct UnstructuredGrid *create_grid_hexa3d(int nx, int ny, int nz,
double dx, double dy, double dz);
struct UnstructuredGrid *create_tensor_grid_2d(int nx, int ny,
double x[], double y[]);
struct UnstructuredGrid *create_grid_tensor2d(int nx, int ny,
double x[], double y[]);
struct UnstructuredGrid *
create_tensor_grid_3d(int nx, int ny, int nz,
double x[], double y[], double z[],
const double depthz[]);
create_grid_tensor3d(int nx, int ny, int nz,
double x[], double y[], double z[],
const double depthz[]);
#ifdef __cplusplus

View File

@ -14,9 +14,9 @@
#include <assert.h>
#include <stdlib.h>
#include <opm/core/utility/cpgpreprocess/cgridinterface.h>
#include <opm/core/utility/cpgpreprocess/geometry.h>
#include <opm/core/utility/cpgpreprocess/preprocess.h>
#include <opm/core/grid/cornerpoint_grid.h>
#include <opm/core/grid/cpgpreprocess/geometry.h>
#include <opm/core/grid/cpgpreprocess/preprocess.h>
#include <opm/core/grid.h>
@ -103,30 +103,6 @@ fill_cell_topology(struct processed_grid *pg,
return g->cell_facepos != NULL;
}
void free_grid(struct UnstructuredGrid *g)
{
if (g!=NULL)
{
free(g->face_nodes);
free(g->face_nodepos);
free(g->face_cells);
free(g->cell_facepos);
free(g->cell_faces);
free(g->node_coordinates);
free(g->face_centroids);
free(g->face_areas);
free(g->face_normals);
free(g->cell_centroids);
free(g->cell_volumes);
free(g->global_cell);
free(g->cell_facetag);
}
free(g);
}
static int
allocate_geometry(struct UnstructuredGrid *g)
{
@ -186,7 +162,7 @@ void compute_geometry(struct UnstructuredGrid *g)
struct UnstructuredGrid *
preprocess (const struct grdecl *in, double tol)
create_grid_cornerpoint(const struct grdecl *in, double tol)
{
struct UnstructuredGrid *g;
int ok;
@ -205,7 +181,7 @@ preprocess (const struct grdecl *in, double tol)
*
* In particular, convey resource ownership from 'pg' to 'g'.
* Consequently, memory resources obtained in process_grdecl()
* will be released in free_grid().
* will be released in destroy_grid().
*/
g->dimensions = 3;
@ -228,7 +204,7 @@ preprocess (const struct grdecl *in, double tol)
pg.face_neighbors = NULL;
/* Initialise subsequently allocated fields to a defined state lest
* we free() random pointers in free_grid() if either of the
* we free() random pointers in destroy_grid() if either of the
* fill_cell_topology() or allocate_geometry() functions fail. */
g->face_centroids = NULL;
g->face_normals = NULL;
@ -246,7 +222,7 @@ preprocess (const struct grdecl *in, double tol)
if (!ok)
{
free_grid(g);
destroy_grid(g);
g = NULL;
}
else

View File

@ -0,0 +1,53 @@
/*===========================================================================
//
// File: preprocess.h
//
// Created: Fri Jun 19 08:43:04 2009
//
// Author: Jostein R. Natvig <Jostein.R.Natvig@sintef.no>
//
// $Date: 2010-08-27 19:12:16 +0200 (Fri, 27 Aug 2010) $
//
// $Revision: 930 $
//
//==========================================================================*/
/*
Copyright 2010, 2011, 2012 SINTEF ICT, Applied Mathematics.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_CORNERPOINT_GRID_HEADER_INCLUDED
#define OPM_CORNERPOINT_GRID_HEADER_INCLUDED
#include <opm/core/grid.h>
#include <opm/core/grid/cpgpreprocess/preprocess.h>
#ifdef __cplusplus
extern "C" {
#endif
struct UnstructuredGrid *
create_grid_cornerpoint(const struct grdecl *in, double tol);
void compute_geometry(struct UnstructuredGrid *g);
#ifdef __cplusplus
}
#endif
#endif /* OPM_CORNERPOINT_GRID_HEADER_INCLUDED */

View File

@ -1,39 +0,0 @@
/*===========================================================================
//
// File: preprocess.h
//
// Created: Fri Jun 19 08:43:04 2009
//
// Author: Jostein R. Natvig <Jostein.R.Natvig@sintef.no>
//
// $Date: 2010-08-27 19:12:16 +0200 (Fri, 27 Aug 2010) $
//
// $Revision: 930 $
//
//==========================================================================*/
/*
Copyright 2010 SINTEF ICT, Applied Mathematics.
*/
#ifndef CGRIDINTERFACE_H
#define CGRIDINTERFACE_H
#include <opm/core/grid.h>
#include <opm/core/utility/cpgpreprocess/preprocess.h>
#ifdef __cplusplus
extern "C" {
#endif
struct UnstructuredGrid *
preprocess (const struct grdecl *in, double tol);
void compute_geometry (struct UnstructuredGrid *g);
void free_grid(struct UnstructuredGrid *g);
#ifdef __cplusplus
}
#endif
#endif /* CGRIDINTERFACE_H */

View File

@ -30,7 +30,6 @@
namespace Opm
{

View File

@ -18,15 +18,14 @@
*/
#include <opm/core/utility/cpgpreprocess/cgridinterface.h>
#include <opm/core/utility/cart_grid.h>
#include <opm/core/grid/cart_grid.h>
#include <opm/core/grid.h>
#include <cstdio>
int main(void)
{
using namespace std;
struct UnstructuredGrid *g = create_cart_grid_2d(2, 2);
struct UnstructuredGrid *g = create_grid_cart2d(2, 2);
int i;
int k;
for (i = 0; i < g->number_of_cells; ++i) {
@ -36,6 +35,6 @@ int main(void)
}
fprintf(stderr, "\n");
}
free_grid(g);
destroy_grid(g);
return 0;
}

View File

@ -3,10 +3,10 @@
#include <vector>
#include <opm/core/grid.h>
#include <opm/core/utility/cpgpreprocess/preprocess.h>
#include <opm/core/utility/cpgpreprocess/cgridinterface.h>
#include <opm/core/grid/cpgpreprocess/preprocess.h>
#include <opm/core/grid/cornerpoint_grid.h>
#include <opm/core/utility/cpgpreprocess/readvector.hpp>
#include <opm/core/grid/cpgpreprocess/readvector.hpp>
static struct UnstructuredGrid*
read_grid(const std::string& dir)
@ -38,7 +38,7 @@ read_grid(const std::string& dir)
grdecl.dims[1] = dimens[1];
grdecl.dims[2] = dimens[2];
struct UnstructuredGrid *g= preprocess(&grdecl, 0.0);
struct UnstructuredGrid *g = create_grid_cornerpoint(&grdecl, 0.0);
double vol = 0.0;
for (int c = 0; c < g->number_of_cells; c++) {
@ -61,7 +61,7 @@ int main()
g = read_grid(std::string("example"));
free_grid(g);
destroy_grid(g);
return 0;
}

10
tutorials/Makefile.am Normal file
View File

@ -0,0 +1,10 @@
AM_CPPFLAGS = \
-I$(top_srcdir) \
$(BOOST_CPPFLAGS)
LDFLAGS = $(BOOST_LDFLAGS)
LDADD = $(top_builddir)/libopmcore.la
noinst_PROGRAMS = tutorial1
tutorial1_SOURCES = tutorial1.cpp

93
tutorials/tutorial1.cpp Normal file
View File

@ -0,0 +1,93 @@
/*
Copyright 2012 SINTEF ICT, Applied Mathematics.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H
/// \page tutorial1 Generation of a simple carthesian grid
/// This tutorial explains how to construct a simple carthesian grid.\n\n
/// We construct a 2x2 two dimensional carthesian grid with 4 blocks of equal size.
#include <opm/core/grid.h>
#include <opm/core/GridManager.hpp>
#include <opm/core/utility/writeVtkData.hpp>
#include <cassert>
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
// ----------------- Main program -----------------
/// \page tutorial1
/// \code
int main()
{
/// \endcode
/// \page tutorial1
/// By setting <code>nz = 1</code>, we make the grid two dimensional
/// \code
int nx = 2;
int ny = 2;
int nz = 1;
/// \endcode
/// The size of each block is 1x1x1. We use standard units (SI)
/// \code
double dx = 1.0;
double dy = 1.0;
double dz = 1.0;
/// \endcode
/// \page tutorial1
/// One of the constructors of the class Opm::GridManager takes <code>nx,ny,nz,dx,dy,dz</code>
/// and construct the corresponding carthesian grid.
/// \code
Opm::GridManager grid(nx, ny, nz, dx, dy, dz);
/// \endcode
/// \page tutorial1
/// We open a file to write down the output
/// \code
std::ofstream vtkfile("tutorial1.vtu");
/// \endcode
/// \page tutorial1
/// The Opm::writeVtkData() function writes output data. Here, we just want to visualize the
/// grid. We construct an empty Opm::DataMap object, which we send to Opm::writeVtkData() together with the grid
/// \code
Opm::DataMap dm;
/// \endcode
/// \page tutorial1
/// The function Opm::writeVtkData() writes down the output.
/// \code
Opm::writeVtkData(*grid.c_grid(), dm, vtkfile);
}
/// \endcode
/// \page tutorial1
/// One can visualize the output using paraview and obtain the following image
/// \image html tutorial1.png
/// \page tutorial1
/// \section sourcecode Complete source code.
/// \include tutorial1.cpp