From f7d934249d6dad6bbd0f9d5e3f9c28fdb5c73f87 Mon Sep 17 00:00:00 2001 From: Xavier Raynaud Date: Tue, 10 Apr 2012 17:18:19 +0200 Subject: [PATCH] Added first tutorial. --- tutorials/Makefile.am | 12 ++++++ tutorials/tutorial1.cpp | 93 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 tutorials/Makefile.am create mode 100644 tutorials/tutorial1.cpp diff --git a/tutorials/Makefile.am b/tutorials/Makefile.am new file mode 100644 index 00000000..395c3c09 --- /dev/null +++ b/tutorials/Makefile.am @@ -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) diff --git a/tutorials/tutorial1.cpp b/tutorials/tutorial1.cpp new file mode 100644 index 00000000..7077ec52 --- /dev/null +++ b/tutorials/tutorial1.cpp @@ -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 . +*/ + + + + + + +#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 +#include +#include +#include +#include +#include +#include +#include +#include + +// ----------------- Main program ----------------- + +/// \page tutorial1 +/// \code +int main() +{ + /// \endcode + /// \page tutorial1 + /// By setting nz = 1, 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 nx,ny,nz,dx,dy,dz + /// 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 +