Merge from upstream.

This commit is contained in:
Bård Skaflestad 2012-04-10 18:13:15 +02:00
commit 24ef4cde3c
20 changed files with 2073 additions and 94 deletions

View File

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

1716
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,7 +1,7 @@
ACLOCAL_AMFLAGS = -I m4
# Recurse to build examples after libraries
SUBDIRS = . tests examples
SUBDIRS = . tests examples tutorials
# ----------------------------------------------------------------------
# Declare products (i.e., the library)

View File

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

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

@ -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]);
}

View File

@ -27,7 +27,7 @@
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>

12
tutorials/Makefile.am Normal file
View File

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

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