Commit a56cc0da authored by Steffen Müthing's avatar Steffen Müthing

Initial commit to import SVN data

parents
# Stuff to ignore recursively
*.la
*.lo
*.o
*~
.deps/
.libs/
Makefile
Makefile.in
semantic.cache
# Stuff to ignore in this directory only
/aclocal.m4
/autom4te.cache/
/build-cmake/
/compile
/config.guess
/config.h
/config.h.in
/config.log
/config.lt
/config.status
/config.sub
/configure
/configure
/configure.lineno
/depcomp
/dependencies.m4
/dune-common-*.tar.gz
/dune-common-?.?
/dune-common.pc
/dune.css
/install-sh
/libtool
/ltmain.sh
/missing
/mkinstalldirs
/stamp-h1
/test-driver
# $Id: duneproject 6304 2011-01-04 18:53:16Z christi $
# we need the module file to be able to build via dunecontrol
EXTRA_DIST=dune.module
SUBDIRS = src m4 dune
# don't follow the full GNU-standard
# we need automake 1.5
AUTOMAKE_OPTIONS = foreign 1.5
# pass most important options when "make distcheck" is used
DISTCHECK_CONFIGURE_FLAGS = --with-dune-pdelab=$(DUNE_PDELAB_ROOT) CXX="$(CXX)" CC="$(CC)"
include $(top_srcdir)/am/top-rules
include $(top_srcdir)/am/global-rules
Preparing the Sources
=========================
Additional to the software mentioned in README you'll need the
following programs installed on your system:
automake >= 1.5
autoconf >= 2.50
libtool
Getting started
---------------
If these preliminaries are met, you should run
dunecontrol all
which will find all installed dune modules as well as all dune modules
(not installed) which sources reside in a subdirectory of the current
directory. Note that if dune is not installed properly you will either
have to add the directory where the dunecontrol script resides (probably
./dune-common/bin) to your path or specify the relative path of the script.
On your project and all uninstalled DUNE source modules found the script
will then calls the GNU autoconf/automake to create a ./configure-script
and the Makefiles. Afterwards that configure script will be called and the
modules will be build using make all
Most probably you'll have to provide additional information to dunecontrol
(e. g. compilers, configure options) and/or make options.
The most convenient way is to use options files in this case. The files
defining three variables:
AUTOGEN_FLAGS flags passed to autogen
CONFIGURE_FLAGS flags passed to configure
MAKE_FLAGS flags passed to make
An example options file might look like this:
#use this options to autogen, configure and make if no other options are given
AUTOGEN_FLAGS="--ac=2.50 --ac=1.8" #Forces automake 2,50 and autoconf 1.8
CONFIGURE_FLAGS="CXX=g++-3.4 --prefix=/install/path" #force g++-3.4 as compiler
MAKE_FLAGS=install #Per default run make install instead of simply make
If you save this information into example.opts you can path the opts file to
dunecontrol via the --opts option, e. g.
dunecontrol --opts=example.opts all
To get a full list of available configure flags just run
dunecontrol configure --help
after running at least
dunecontrol autogen
More info
---------
See
dunecontrol --help
for further options.
The full build-system is described in the dune-common/doc/buildsystem (SVN version) or under share/doc/dune-common/buildsystem if you installed DUNE!
$Id: duneproject 6304 2011-01-04 18:53:16Z christi $
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.50)
DUNE_AC_INIT # gets module version from dune.module file
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([pdelab-exercise2-sol.pc.in])
AM_CONFIG_HEADER([config.h])
# we need no more than the standard DE-stuff
# this module depends on dune-pdelab
# this implies checking for [dune-common], [dune-grid], [dune-localfunctions], [dune-istl], [dune-pdelab]
DUNE_CHECK_ALL
# implicitly set the Dune-flags everywhere
AC_SUBST(AM_CPPFLAGS, $DUNE_CPPFLAGS)
AC_SUBST(AM_LDFLAGS, $DUNE_LDFLAGS)
LIBS="$DUNE_LIBS"
AC_CONFIG_FILES([
Makefile
src/Makefile
dune/Makefile
m4/Makefile
pdelab-exercise2-sol.pc
])
AC_OUTPUT
# finally print the summary information
DUNE_SUMMARY_ALL
################################
# Dune module information file #
################################
#Name of the module
Module: pdelab-exercise2-sol
Version: 0.2013
Maintainer: jorrit@jorrit.de
#depending on
Depends: dune-pdelab (>= 1.1)
mydir = $(includedir)/dune
my_HEADERS = pdelab_exercise2_sol_dummy.hh
include $(top_srcdir)/am/global-rules
#error This file only exists because of a peculiarity of DUNE's buildsystem.
#error It should never be included.
M4FILES = pdelab-exercise2-sol.m4
aclocaldir = $(datadir)/aclocal
aclocal_DATA = $(M4FILES)
EXTRA_DIST = $(M4FILES)
include $(top_srcdir)/am/global-rules
dnl -*- autoconf -*-
# Macros needed to find pdelab-exercise2-sol and dependent libraries. They are called by
# the macros in ${top_src_dir}/dependencies.m4, which is generated by
# "dunecontrol autogen"
# Additional checks needed to build pdelab-exercise2-sol
# This macro should be invoked by every module which depends on pdelab-exercise2-sol, as
# well as by pdelab-exercise2-sol itself
AC_DEFUN([PDELAB_EXERCISE2_SOL_CHECKS])
# Additional checks needed to find pdelab-exercise2-sol
# This macro should be invoked by every module which depends on pdelab-exercise2-sol, but
# not by pdelab-exercise2-sol itself
AC_DEFUN([PDELAB_EXERCISE2_SOL_CHECK_MODULE],
[
DUNE_CHECK_MODULES([pdelab-exercise2-sol],[pdelab_exercise2_sol_dummy.hh])
])
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
CXX=@CXX@
CC=@CC@
DEPENDENCIES=@REQUIRES@
Name: @PACKAGE_NAME@
Version: @VERSION@
Description: pdelab-exercise2 solutions module
URL: http://dune-project.org/
Requires: ${DEPENDENCIES}
Libs: -L${libdir}
Cflags: -I${includedir}
noinst_PROGRAMS =
noinst_HEADERS = \
example02_bcextension.hh \
example02_bctype.hh \
example02_operator.hh \
example02_Q1.hh \
example02b_bctype.hh \
example02b_operator.hh \
example02b_Q1.hh \
example02c_P1.hh
noinst_DATA =
noinst_PROGRAMS += example02
example02_SOURCES = example02.cc
example02_CPPFLAGS = $(AM_CPPFLAGS) \
$(SUPERLU_CPPFLAGS) \
$(DUNEMPICPPFLAGS) \
$(AMIRAMESH_CPPFLAGS) \
$(ALBERTA_CPPFLAGS) \
$(ALUGRID_CPPFLAGS)
example02_LDFLAGS = $(AM_LDFLAGS) \
$(SUPERLU_LDFLAGS) \
$(DUNEMPILDFLAGS) \
$(AMIRAMESH_LDFLAGS) \
$(ALBERTA_LDFLAGS) \
$(ALUGRID_LDFLAGS)
example02_LDADD = \
$(SUPERLU_LIBS) \
$(DUNEMPILIBS) \
$(AMIRAMESH_LIBS) \
$(ALBERTA_LIBS) \
$(ALUGRID_LIBS) \
$(LDADD)
noinst_PROGRAMS += example02b
example02b_SOURCES = example02b.cc
example02b_CPPFLAGS = $(AM_CPPFLAGS) \
$(SUPERLU_CPPFLAGS) \
$(DUNEMPICPPFLAGS) \
$(AMIRAMESH_CPPFLAGS) \
$(ALBERTA_CPPFLAGS) \
$(ALUGRID_CPPFLAGS)
example02b_LDFLAGS = $(AM_LDFLAGS) \
$(SUPERLU_LDFLAGS) \
$(DUNEMPILDFLAGS) \
$(AMIRAMESH_LDFLAGS) \
$(ALBERTA_LDFLAGS) \
$(ALUGRID_LDFLAGS)
example02b_LDADD = \
$(SUPERLU_LIBS) \
$(DUNEMPILIBS) \
$(AMIRAMESH_LIBS) \
$(ALBERTA_LIBS) \
$(ALUGRID_LIBS) \
$(LDADD)
noinst_PROGRAMS += example02c
example02c_SOURCES = example02c.cc
example02c_CPPFLAGS = $(AM_CPPFLAGS) \
$(SUPERLU_CPPFLAGS) \
$(DUNEMPICPPFLAGS) \
$(AMIRAMESH_CPPFLAGS) \
$(ALBERTA_CPPFLAGS) \
$(ALUGRID_CPPFLAGS)
example02c_LDFLAGS = $(AM_LDFLAGS) \
$(SUPERLU_LDFLAGS) \
$(DUNEMPILDFLAGS) \
$(AMIRAMESH_LDFLAGS) \
$(ALBERTA_LDFLAGS) \
$(ALUGRID_LDFLAGS)
example02c_LDADD = \
$(SUPERLU_LIBS) \
$(DUNEMPILIBS) \
$(AMIRAMESH_LIBS) \
$(ALBERTA_LIBS) \
$(ALUGRID_LIBS) \
$(LDADD)
noinst_DATA += \
example02c.geo \
example02c_hole.geo
# don't follow the full GNU-standard
# we need automake 1.5
AUTOMAKE_OPTIONS = foreign 1.5
# pass most important options when "make distcheck" is used
DISTCHECK_CONFIGURE_FLAGS = --with-dune-common=$(DUNE_COMMON_ROOT) --with-dune-grid=$(DUNE_GRID_ROOT) --with-dune-istl=$(DUNE_ISTL_ROOT) --with-dune-localfunctions=$(DUNE_LOCALFUNCTIONS_ROOT) --with-dune-pdelab=$(DUNE_PDELAB_ROOT) CXX="$(CXX)" CC="$(CC)"
include $(top_srcdir)/am/global-rules
CLEANFILES = dgfparser.log q1*.vtu *.vtu *.png
// -*- tab-width: 4; indent-tabs-mode: nil -*-
/** \file
\brief Solve elliptic problem in constrained spaces with conforming finite elements
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<math.h>
#include<dune/common/exceptions.hh>
#include<dune/common/fvector.hh>
#include<dune/common/parallel/mpihelper.hh>
#include<dune/common/static_assert.hh>
#include<dune/common/timer.hh>
#include<dune/grid/io/file/gmshreader.hh>
#include<dune/grid/io/file/vtk/subsamplingvtkwriter.hh>
#include<dune/grid/yaspgrid.hh>
#if HAVE_ALBERTA
#include<dune/grid/albertagrid.hh>
#endif
#if HAVE_ALUGRID
#include<dune/grid/alugrid.hh>
#endif
#if HAVE_UG
#include<dune/grid/uggrid.hh>
#endif
#include<dune/istl/bvector.hh>
#include<dune/istl/io.hh>
#include<dune/istl/operators.hh>
#include<dune/istl/preconditioners.hh>
#include<dune/istl/solvers.hh>
#include<dune/istl/superlu.hh>
#include<dune/pdelab/backend/istlmatrixbackend.hh>
#include<dune/pdelab/backend/istlsolverbackend.hh>
#include<dune/pdelab/backend/istlvectorbackend.hh>
#include<dune/pdelab/common/function.hh>
#include<dune/pdelab/common/vtkexport.hh>
#include<dune/pdelab/constraints/constraints.hh>
#include<dune/pdelab/constraints/conforming.hh>
#include<dune/pdelab/finiteelementmap/p0fem.hh>
#include<dune/pdelab/finiteelementmap/pkfem.hh>
#include<dune/pdelab/finiteelementmap/qkfem.hh>
#include<dune/pdelab/finiteelementmap/rannacher_turek2dfem.hh>
#include<dune/pdelab/gridfunctionspace/genericdatahandle.hh>
#include<dune/pdelab/gridfunctionspace/gridfunctionspace.hh>
#include<dune/pdelab/gridfunctionspace/gridfunctionspaceutilities.hh>
#include<dune/pdelab/gridfunctionspace/interpolate.hh>
#include<dune/pdelab/gridoperator/gridoperator.hh>
#include<dune/pdelab/stationary/linearproblem.hh>
#include"example02_bctype.hh"
#include"example02_bcextension.hh"
#include"example02_operator.hh"
#include"example02_Q1.hh"
//===============================================================
// Main program with grid setup
//===============================================================
int main(int argc, char** argv)
{
try{
//Maybe initialize Mpi
Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv);
if(Dune::MPIHelper::isFake)
std::cout<< "This is a sequential program." << std::endl;
else
{
if(helper.rank()==0)
std::cout << "parallel run on " << helper.size() << " process(es)" << std::endl;
}
if (argc!=2)
{
if(helper.rank()==0)
std::cout << "usage: ./example02 <level>" << std::endl;
return 1;
}
int level;
sscanf(argv[1],"%d",&level);
// sequential version
if (1 && helper.size()==1)
{
Dune::FieldVector<double,2> L(1.0);
Dune::array<int,2> N{{1,1}};
std::bitset<2> periodic(false);
int overlap=0;
Dune::YaspGrid<2> grid(L,N,periodic,overlap);
grid.globalRefine(level);
typedef Dune::YaspGrid<2>::LeafGridView GV;
const GV& gv=grid.leafGridView();
example02_Q1(gv);
}
}
catch (Dune::Exception &e){
std::cerr << "Dune reported error: " << e << std::endl;
throw;
}
catch (...){
std::cerr << "Unknown exception thrown!" << std::endl;
throw;
}
}
template<class GV> void example02_Q1 (const GV& gv)
{
// <<<1>>> Choose domain and range field type
typedef typename GV::Grid::ctype Coord;
typedef double Real;
// <<<2>>> Make grid function space
typedef Dune::PDELab::QkLocalFiniteElementMap<GV,Coord,Real,1> FEM;
FEM fem(gv);
typedef Dune::PDELab::ConformingDirichletConstraints CONSTRAINTS; // constraints class
typedef Dune::PDELab::ISTLVectorBackend<> VBE;
typedef Dune::PDELab::GridFunctionSpace<GV,FEM,CONSTRAINTS,VBE> GFS;
GFS gfs(gv,fem);
BCTypeParam bctype; // boundary condition type
typedef typename GFS::template ConstraintsContainer<Real>::Type CC;
CC cc;
Dune::PDELab::constraints( bctype, gfs, cc ); // assemble constraints
std::cout << "constrained dofs=" << cc.size() << " of " << gfs.globalSize() << std::endl;
// <<<3>>> Make grid operator
typedef Example02LocalOperator<BCTypeParam> LOP; // operator including boundary
LOP lop( bctype );
typedef Dune::PDELab::ISTLMatrixBackend MBE;
typedef Dune::PDELab::GridOperator<
GFS,GFS, /* ansatz and test space */
LOP, /* local operator */
MBE, /* matrix backend */
Real,Real,Real, /* field types for domain, range and jacobian */
CC,CC /* constraints transformation for ansatz and test space */
> GO;
GO go(gfs,cc,gfs,cc,lop);
// <<<4>>> Make FE function extending Dirichlet boundary conditions
typedef typename GO::Traits::Domain U;
U u(gfs,0.0);
typedef BCExtension<GV,Real> G; // boundary value + extension
G g(gv);
Dune::PDELab::interpolate(g,gfs,u); // interpolate coefficient vector
// <<<5>>> Select a linear solver backend
typedef Dune::PDELab::ISTLBackend_SEQ_BCGS_SSOR LS;
LS ls(5000,true);
// <<<6>>> assemble and solve linear problem
typedef Dune::PDELab::StationaryLinearProblemSolver<GO,LS,U> SLP;
SLP slp(go,ls,1e-10);
slp.apply(u);
// <<<7>>> graphical output
typedef Dune::PDELab::DiscreteGridFunction<GFS,U> DGF;
DGF udgf(gfs,u);
Dune::VTKWriter<GV> vtkwriter(gv,Dune::VTK::conforming);
vtkwriter.addVertexData(new Dune::PDELab::VTKGridFunctionAdapter<DGF>(udgf,"solution"));
vtkwriter.write("example02_Q1",Dune::VTK::appendedraw);
}
/** \brief A function that defines Dirichlet boundary conditions AND
its extension to the interior */
template<typename GV, typename RF>
class BCExtension
: public Dune::PDELab::GridFunctionBase<Dune::PDELab::
GridFunctionTraits<GV,RF,1,Dune::FieldVector<RF,1> >, BCExtension<GV,RF> > {
const GV& gv;
public:
typedef Dune::PDELab::GridFunctionTraits<GV,RF,1,Dune::FieldVector<RF,1> > Traits;
//! construct from grid view
BCExtension (const GV& gv_) : gv(gv_) {}
//! evaluate extended function on element
inline void evaluate (const typename Traits::ElementType& e,
const typename Traits::DomainType& xlocal,
typename Traits::RangeType& y) const
{
const int dim = Traits::GridViewType::Grid::dimension;
typedef typename Traits::GridViewType::Grid::ctype ctype;
Dune::FieldVector<ctype,dim> x = e.geometry().global(xlocal);
if (x[0]<1E-6 && x[1]>0.25 && x[1]<0.5) y = 1.0; else y = 0.0;
return;
}
//! get a reference to the grid view
inline const GV& getGridView () {return gv;}
};
#include<dune/common/fvector.hh>
#include<dune/pdelab/common/function.hh>
#include<dune/pdelab/constraints/constraintsparameters.hh>
//! \brief Parameter class selecting boundary conditions
class BCTypeParam
: public Dune::PDELab::DirichletConstraintsParameters
{
public:
//! Test whether boundary is Dirichlet-constrained
template<typename I>
bool isDirichlet(const I & intersection,
const Dune::FieldVector<typename I::ctype, I::dimension-1> & coord
) const
{
Dune::FieldVector<typename I::ctype, I::dimension>
xg = intersection.geometry().global( coord );
if( xg[0]>1.0-1E-6 )
return false; // no Dirichlet b.c. on the eastern boundary
return true; // Dirichlet b.c. on all other boundaries
}
};
#include<dune/geometry/quadraturerules.hh>
#include<dune/geometry/referenceelements.hh>
#include<dune/pdelab/localoperator/defaultimp.hh>
#include<dune/pdelab/localoperator/flags.hh>
#include<dune/pdelab/localoperator/pattern.hh>
/** a local operator for solving the equation
*
* - \Delta u + a*u = f in \Omega
* u = g on \Gamma_D\subseteq\partial\Omega
* -\nabla u \cdot n = j on \Gamma_N = \partial\Omega\setminus\Gamma_D
*
* with conforming finite elements on all types of grids in any dimension
*
* \tparam BCType parameter class indicating the type of boundary condition
*/
template<class BCType>
class Example02LocalOperator :
public Dune::PDELab::NumericalJacobianApplyVolume<Example02LocalOperator<BCType> >,
public Dune::PDELab::NumericalJacobianVolume<Example02LocalOperator<BCType> >,
public Dune::PDELab::NumericalJacobianApplyBoundary<Example02LocalOperator<BCType> >,
public Dune::PDELab::NumericalJacobianBoundary<Example02LocalOperator<BCType> >,
public Dune::PDELab::FullVolumePattern,
public Dune::PDELab::LocalOperatorDefaultFlags
{
public:
// pattern assembly flags
enum { doPatternVolume = true };
// residual assembly flags
enum { doAlphaVolume = true };
enum { doAlphaBoundary = true }; // assemble boundary
Example02LocalOperator(const BCType& bctype_, // boundary cond.type
unsigned int intorder_=2) :
bctype( bctype_ ), intorder( intorder_ )
{}
// volume integral depending on test and ansatz functions
template<typename EG, typename LFSU, typename X, typename LFSV, typename R>
void alpha_volume (const EG& eg, const LFSU& lfsu, const X& x, const LFSV& lfsv, R& r) const
{
// assume Galerkin: lfsu == lfsv
// This yields more efficient code since the local functionspace only
// needs to be evaluated once, but would be incorrect for a finite volume
// method
// dimensions
const int dim = EG::Geometry::dimension;
const int dimw = EG::Geometry::dimensionworld;
// extract some types
typedef typename LFSU::Traits::FiniteElementType::
Traits::LocalBasisType::Traits::DomainFieldType DF;
typedef typename LFSU::Traits::FiniteElementType::
Traits::LocalBasisType::Traits::RangeFieldType RF;
typedef typename LFSU::Traits::FiniteElementType::
Traits::LocalBasisType::Traits::JacobianType Jacobian;
typedef typename LFSU::Traits::FiniteElementType::
Traits::LocalBasisType::Traits::RangeType Range;
typedef Dune::FieldVector<RF,dimw> Gradient;
typedef typename LFSU::Traits::SizeType size_type;
// select quadrature rule
Dune::GeometryType gt = eg.geometry().type();
const Dune::QuadratureRule<DF,dim>&
rule = Dune::QuadratureRules<DF,dim>::rule(gt,intorder);
// loop over quadrature points
for (typename Dune::QuadratureRule<DF,dim>::const_iterator
it=rule.begin(); it!=rule.end(); ++it)