From: schrage Date: Fri, 19 Feb 1999 16:33:07 +0000 (+0000) Subject: Changes to doc, added code example (broken) X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2be67c8aad541253c49fcc103e1b6a3cff036a9;p=dealii-svn.git Changes to doc, added code example (broken) git-svn-id: https://svn.dealii.org/trunk@852 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/tutorial/chapter-3.laplace/assemble.html b/deal.II/doc/tutorial/chapter-3.laplace/assemble.html new file mode 100644 index 0000000000..3433378160 --- /dev/null +++ b/deal.II/doc/tutorial/chapter-3.laplace/assemble.html @@ -0,0 +1,217 @@ + + + + DEAL tutorial: the Laplace problem + + + + + + +

Assembling the problem

+ +

What's to be done

+In order to assemble the matrices we basically need to: +
    +
  1. Generate the matrices, i.e. call the DEAL functions that reserve +storage space for us. +
  2. +
  3. +Calculate the finite element trial functions +
  4. +
  5. +Traverse all existing cells and integrate the problem +using the discretized laplace operator +
  6. +
  7. +Traverse all the cell faces and set the appropriate boundary conditions +
  8. +
  9. +Insert the local matrices we have used into the global matrix using the +appropriate DEAL functions +
  10. +
+ +

...and how to do it

+ +

Function parameters

+
+
+void
+Laplace::assemble_primal(const Function<2>& exact, const Function<2>&)
+{
+
+
+ +

Generating the matrix structures

+ +

+First we generate an n times n square matrix where n is the number +of the degrees of freedom, i.e. the number of points of our discretization. +The parameter max_couplings_between_dofs() returns the maximum +number of couplings between degrees of freedom and allows DEAL +to generate the matrix structure more efficiently, for most of its +elements are zero. +

+

+Afterwards the hanging nodes are copied into the matrix, i.e. +the matrix is generated. +

+
+
+  matrix_structure.reinit(dof_primal.n_dofs(),dof_primal.n_dofs(),
+			  dof_primal.max_couplings_between_dofs());
+  dof_primal.make_sparsity_pattern(matrix_structure);
+  hanging_nodes.clear();
+  dof_primal.make_constraint_matrix(hanging_nodes);
+  hanging_nodes.condense(matrix_structure);
+
+
+

+The problem is of the form Au=f: +

+
+
+  A.reinit(matrix_structure);
+  f.reinit(dof_primal.n_dofs());
+
+
+ +

Calculatinginite element trial functions

+

+The two lines below calculate trial functions for the finite elements and +for their faces using Gaussian quadrature. +

+
+
+  FEValues<2> fevalues(fe_primal, qc_primal, UpdateFlags(update_gradients |
+						   update_JxW_values));
+  FEFaceValues<2> ffvalues(fe_primal, qf_primal,
+			   UpdateFlags(update_JxW_values | update_q_points));
+
+
+ +

Integrating the problem

+

+Integration is done locally. Therefore we need appropriate definitions for +

+

+
+
+  vector indices(fe_primal.total_dofs);
+  dVector elvec(fe_primal.total_dofs);
+  
+  dFMatrix elmat(fe_primal.total_dofs);
+
+
+

+Next we traverse all the cells and integrate the Laplace problem using the +discretized Laplace operator. qc_primal is a Gaussian quadrature. +

+
+
+  for (DoFHandler<2>::active_cell_iterator c = dof_primal.begin_active()
+					; c != dof_primal.end() ; ++c)
+  {
+    fevalues.reinit(c, stb);
+    elmat.clear();
+    elvec.clear();
+    c->get_dof_indices(indices);
+    
+    for (unsigned k=0;k dv = fevalues.shape_grad(i,k);
+	
+	for (unsigned j=0;j du = fevalues.shape_grad(j,k);
+	  
+	  elmat(i,j) += fevalues.JxW(k)
+			* du * dv
+			;
+	  
+	}
+      }
+    }
+
+
+ +

Setting boundary conditions

+ +

+There are two DEAL functions relevant for us at the moment: +

+
+static_void interpolate_boundary_values(...)
+
+
+which does exactly what it says. This function returns a list of pairs +of boundary indicators and the according functions denoting the respective +Dirichlet boundary values. +

+

+This output is used by +

+
+static void apply_boundary_values(...)
+
+
+that inserts the proper boundary conditions into the equation system: +

+

+


+  map boundary_values;
+  DoFHandler<2>::FunctionMap dirichlet_bc;
+  BoundaryFct bfkt;
+  dirichlet_bc[0]=&bfkt;
+  VectorTools<2>::interpolate_boundary_values(dof_primal,dirichlet_bc,fe_primal,boundary,boundary_values);
+  u.reinit(f);
+  MatrixTools<2>::apply_boundary_values(boundary_values,A,u,f);  
+
+First, we need a few definitions: + +This may seem a bit confusing. What actually happens is the following: +
    +
  1. interpolate_boundary_values takes the boundary functions +bfkt, its relation to boundaries dirichlet_bc and +the triangulation dof_primal, fe_primal and returns a +mapping boundary_values that maps values instead of functions +to our boundaries. The function looks at all the boundaries. All we +ever need to do is specify the initial triangulation. +
  2. +
  3. apply_boundary_values subsequently takes that mapping and +our equation system Au=f and inserts the boundary values into +the equation system which can then be solved. +
  4. +
+

+ +
+

+Back to the tutorial index +

+ +
+
Jan Schrage
+

+Last modified: Fri Feb 12, 1999 +

+ + diff --git a/deal.II/doc/tutorial/chapter-3.laplace/code/Makefile b/deal.II/doc/tutorial/chapter-3.laplace/code/Makefile new file mode 100644 index 0000000000..7fbd4d5906 --- /dev/null +++ b/deal.II/doc/tutorial/chapter-3.laplace/code/Makefile @@ -0,0 +1,152 @@ +# $Id$ +# Author: Wolfgang Bangerth, 1998 + +root = ../../../../ + +vpath %.a $(root)/deal.II/lib +vpath %.a $(root)/lac/lib +vpath %.a $(root)/base/lib + +# Template for makefiles for the examples subdirectory. In principle, +# everything should be done automatically if you set the target file +# here correctly: +target = laplace + +# All dependencies between files should be updated by the included +# file Makefile.dep if necessary. Object files are compiled into +# the archives ./Obj.a and ./Obj.g.a. By default, the debug version +# is used to link. It you don't like that, change the following +# variable to "off" +debug-mode = on + +# If you want your program to be linked with extra object or library +# files, specify them here: +user-libs = + +# To run the program, use "make run"; to give parameters to the program, +# give the parameters to the following variable: +run-parameters = 60 4 + +# To execute additional action apart from running the program, fill +# in this list: +#additional-run-action = + +# To specify which files are to be deleted by "make clean" (apart from +# the usual ones: object files, executables, backups, etc), fill in the +# following list +delete-files = gnuplot* *.eps + +deal_II_dimension=2 + + +############################################################################### +# Internals + +INCLUDE=-I$(root)/deal.II/include -I$(root)/lac/include -I$(root)/base/include + +CXXFLAGS.g= -DDEBUG -g -Wall -W -pedantic -Wconversion \ + -Winline -Woverloaded-virtual \ + $(INCLUDE) -Ddeal_II_dimension=$(deal_II_dimension) +CXXFLAGS =-O3 -Wuninitialized -finline-functions -ffast-math \ + -felide-constructors -fnonnull-objects \ + $(INCLUDE) \ + -Ddeal_II_dimension=$(deal_II_dimension) + +ifeq ($(shell uname),Linux) +CXX = g++ +endif + +ifeq ($(shell uname),SunOS) +CXX = g++ +endif + + +%.go : %.cc #Makefile + @echo ============================ Compiling with debugging information: $< + @echo $(CXX) ... -c $< -o $@ + @$(CXX) $(CXXFLAGS.g) -c $< -o $@ +%.o : %.cc #Makefile + @echo ============================ Compiling with optimization: $< + @echo $(CXX) ... -c $< -o $@ + @$(CXX) $(CXXFLAGS) -c $< -o $@ + + +# get lists of files we need +cc-files = $(wildcard *.cc) +o-files = $(cc-files:.cc=.o) +go-files = $(cc-files:.cc=.go) +h-files = $(wildcard *.h) +lib-h-files = $(wildcard $(root)/deal.II/include/*/*.h) + +# list of libraries needed to link with +libs = ./Obj.a $(wildcard $(root)/deal.II/lib/lib*2d.a) $(root)/lac/lib/liblac.a +libs.g = ./Obj.g.a $(wildcard $(root)/deal.II/lib/lib*2d.g.a) $(root)/lac/lib/liblac.a $(root)/base/lib/libbase.g.a + +#$(root)/deal.II/lib/deal_II_2d.g -llac.g -lbase.g#-lbasic.g -lfe.g -lgrid.g -lbasic.g -llac.g + + +# check whether we use debug mode or not +ifeq ($(debug-mode),on) +libraries = $(libs.g) +flags = $(CXXFLAGS.g) +endif + +ifeq ($(debug-mode),off) +libraries = $(libs) +flags = $(CXXFLAGS) +endif + + + +# make rule for the target +$(target) : $(libraries) $(user-libs) + @echo ============================ Linking $@ + $(CXX) $(flags) -o $@ $^ + +# rule how to run the program +run: $(target) + $(target) $(run-parameters) + $(additional-run-action) + + +# rule to make object files +%.go : %.cc + @echo ============================ Compiling with debugging information: $< + @echo $(CXX) ... -c $< -o $@ + @$(CXX) $(CXXFLAGS.g) -c $< -o $@ +%.o : %.cc + @echo ============================ Compiling with optimization: $< + @echo $(CXX) ... -c $< -o $@ + @$(CXX) $(CXXFLAGS) -c $< -o $@ + + +# rules which files the libraries depend upon +Obj.a: ./Obj.a($(o-files)) +Obj.g.a: ./Obj.g.a($(go-files)) + + +clean: + rm -f *.o *.go *~ Makefile.dep Obj.a Obj.g.a $(target) $(delete-files) + + + +.PHONY: clean + + +#Rule to generate the dependency file. This file is +#automagically remade whenever needed, i.e. whenever +#one of the cc-/h-files changed. Make detects whether +#to remake this file upon inclusion at the bottom +#of this file. +# +#use perl to generate rules for the .go files as well +#as to make rules not for tria.o and the like, but +#rather for libnumerics.a(tria.o) +Makefile.dep: $(cc-files) $(h-files) $(lib-h-files) + @echo ============================ Remaking Makefile + @perl $(root)/deal.II/Make_dep.pl ./Obj $(INCLUDE) $(cc-files) \ + > Makefile.dep + + +include Makefile.dep + diff --git a/deal.II/doc/tutorial/chapter-3.laplace/code/func.cc b/deal.II/doc/tutorial/chapter-3.laplace/code/func.cc new file mode 100644 index 0000000000..b76e900ec1 --- /dev/null +++ b/deal.II/doc/tutorial/chapter-3.laplace/code/func.cc @@ -0,0 +1,24 @@ +// $Id$ + +// JS. +const char* funcversion = "Functions: $Revision$"; + +#include "functions.h" + +#include + +double +WeightFunction::operator() (const Point<2>& p) const +{ + // double r = p(0)*p(0) + p(1) * p(1); + //if (r>=.8) return 0.; + //return 1.-r*(2.-r); + return 1.; + +} + +double +BoundaryFct::operator ()(const Point<2> &p) const +{ + return sin(4*M_PI*p(0))*sin(4*M_PI*p(1)); +} diff --git a/deal.II/doc/tutorial/chapter-3.laplace/code/functions.h b/deal.II/doc/tutorial/chapter-3.laplace/code/functions.h new file mode 100644 index 0000000000..fa55d4aba9 --- /dev/null +++ b/deal.II/doc/tutorial/chapter-3.laplace/code/functions.h @@ -0,0 +1,22 @@ +// $Id$ + +// JS.Wird das File ueberhaupt gebraucht ? + +#include + +class WeightFunction + : public Function<2> +{ +public: + WeightFunction() + {} + virtual double operator()(const Point<2> &p) const; +}; + +class BoundaryFct + : public Function<2> +{ + public: + virtual double operator()(const Point<2> &p) const; +}; + diff --git a/deal.II/doc/tutorial/chapter-3.laplace/code/laplace.cc b/deal.II/doc/tutorial/chapter-3.laplace/code/laplace.cc new file mode 100644 index 0000000000..329b00c93c --- /dev/null +++ b/deal.II/doc/tutorial/chapter-3.laplace/code/laplace.cc @@ -0,0 +1,287 @@ +// $Id$ + +const char* laplaceversion = "Laplace: $Revision$"; + +#include "laplace.h" +#include "functions.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#define PRIMEL FELinear<2> +#define DUEL FEQuadraticSub<2> + +// Finite Elements + +static PRIMEL fe_primal; +// JS.static DUEL fe_dual; + +// Quadrature formulae + +static QGauss2<2> qc_primal; +static QGauss2<1> qf_primal; +// static QGauss3<2> qc_dual; +// static QGauss3<1> qf_dual; +static QGauss5<2> qc_integrate; +static QGauss5<1> qf_integrate; + +StraightBoundary<2> stb; + +// JS.ist im Moment noch PureTransportSolution... +Laplace::Laplace() + : dof_primal(&tr) +{ + // JS.Triangulation generieren. Zellränder werden numeriert. + tr.create_hypercube(-1.,1.); + + // JS.Freiheitsgrade verteilen. D.h. Zellen numerieren. + dof_primal.distribute_dofs(fe_primal); + } + +Laplace::~Laplace() +{} + + +// JS.Gitter verfeinern. +void +Laplace::remesh(unsigned int steps) +{ + if (tr.n_levels() <= 1) + { + tr.refine_global(1); //JS.Lokal ist execute_coarsening_etc... + } + + if (steps) + tr.refine_global(steps); + else + tr.execute_coarsening_and_refinement(); + + // JS. Freiheitsgrade neu verteilen. + dof_primal.distribute_dofs(fe_primal); + // JS. und dem Problem angemessener nochmal numerieren. + dof_primal.renumber_dofs(Cuthill_McKee); + deallog << "Cells " << tr.n_active_cells() + << " PrimalDoFs " << dof_primal.n_dofs() + << endl; +} + +// JS.Primales Problem zusammenstellen. +void +Laplace::assemble_primal(const Function<2>&,const Function<2>&) +{ + deallog << "Assembling primal problem" << endl; + // JS. Platz für neue Matrix mit (?) (2x = quadratisch) Anzahl der Zellen, + // Anzahl der Kopplungen (Matrix dünn besetzt, für effizientes Speichern) + matrix_structure.reinit(dof_primal.n_dofs(),dof_primal.n_dofs(), + dof_primal.max_couplings_between_dofs()); + // JS.Hängende Noden in die Matrix einbauen; d.h. Matrix generieren. + dof_primal.make_sparsity_pattern(matrix_structure); + hanging_nodes.clear(); + dof_primal.make_constraint_matrix(hanging_nodes); + hanging_nodes.condense(matrix_structure); + + //JS.Problem der Form Au=f. + A.reinit(matrix_structure); + f.reinit(dof_primal.n_dofs()); + + // JS.Ansatzfunktionen auf Zellrändern im Voraus berechnen aus + // Effizienzgründen. + FEValues<2> fevalues(fe_primal, qc_primal, UpdateFlags(update_gradients | + update_JxW_values)); + FEFaceValues<2> ffvalues(fe_primal, qf_primal, + UpdateFlags(update_JxW_values | update_q_points)); + //JS.Ab hier lokales Problem el... = Finites Element... + //JS. Index für eine Zelle, für späteren Einbau in globale Matrix. + vector indices(fe_primal.total_dofs); + dVector elvec(fe_primal.total_dofs); + + dFMatrix elmat(fe_primal.total_dofs); + + // JS.Einmal alle Zellen durchlaufen + for (DoFHandler<2>::active_cell_iterator c = dof_primal.begin_active() + ; c != dof_primal.end() ; ++c) + { + fevalues.reinit(c, stb); + elmat.clear(); + elvec.clear(); + c->get_dof_indices(indices); + + // JS.Integration des Problems. Diese Schleifenfolge für Effizienz. + for (unsigned k=0;k dv = fevalues.shape_grad(i,k); + + + for (unsigned j=0;j du = fevalues.shape_grad(j,k); + + elmat(i,j) += fevalues.JxW(k) + * du * dv + ; + + } + } + } + // JS.Lokale Matrix in globale einbauen. + for (unsigned i=0;i boundary_values; + DoFHandler<2>::FunctionMap dirichlet_bc; + BoundaryFct bfkt; + dirichlet_bc[0]=&bfkt; + VectorTools<2>::interpolate_boundary_values(dof_primal,dirichlet_bc, + fe_primal,boundary, + boundary_values); + u.reinit(f); + MatrixTools<2>::apply_boundary_values(boundary_values,A,u,f); + + cout << "u: " << u.l2_norm() << endl; + cout << "f: " << f.l2_norm() << endl; + + // JS.Hängende Noden einbauen. + // hanging_nodes.condense(A); + //hanging_nodes.condense(f); +} + +// JS. Primales Problem lösen. +void +Laplace::solve_primal() +{ + deallog.push("Solve"); + + // JS.Empfindlichkeit des Lösers einstellen. + SolverControl control(1000, 1.e-10); + // JS. Löser definieren. modifiziertes cg-Verfahren, + SolverCG solver(control, mem); + + // JS.??? + cout << "f:L2-norm=" << f.l2_norm() << endl; + // u.reinit(f); + + // JS.lösen. + solver.solve(A,u,f); + cout << "u:L2-norm=" << u.l2_norm() << endl; + + // JS.??? + hanging_nodes.distribute(u); + + deallog.pop(); +} + + +// JS. Datenausgabe im Gnuplot-Format. +void Laplace::write_data(const char* name) +{ + deallog << "Writing gnuplot" << endl; + + DataOut<2> out; + char fname[100]; + sprintf(fname,"P_%s",name); + + { + ofstream gnuplot(fname); + + out.clear_data_vectors(); + out.attach_dof_handler(dof_primal); + out.add_data_vector(u,"solution","kg"); + + out.write_gnuplot (gnuplot, 1); + gnuplot.close (); + } + +} + + +// JS. Ergebnis zurückgeben. Wie funktioniert das ? +double +Laplace::result(const Function<2>& interior, const Function<2>& boundary) +{ + double erg = 0., ergex = 0.; + FEValues<2> fevalues(fe_primal, qc_integrate, + UpdateFlags(update_q_points | update_JxW_values)); + FEFaceValues<2> ffvalues(fe_primal, qf_integrate, + UpdateFlags(update_q_points | update_JxW_values)); + vector uh(qc_integrate.n_quadrature_points); + vector uf(qf_integrate.n_quadrature_points); + + // JS.Alle Zellen durch. + for (DoFHandler<2>::active_cell_iterator c = dof_primal.begin_active() + ; c != dof_primal.end() ; ++c) + { + double s = 0.; + fevalues.reinit(c, stb); + + fevalues.get_function_values(u, uh); + + for (unsigned int k=0;k::faces_per_cell;++fi) + { + DoFHandler<2>::face_iterator f = c->face(fi); + unsigned char bi = f->boundary_indicator(); + if (bi == 0xFF) continue; + ffvalues.reinit(c, fi, stb); + ffvalues.get_function_values(u, uf); + + // JS.??? Integrationspunkte ??? + for (unsigned k=0;k +#include +#include +#include +#include +#include +#include +#include +#include + +class AdvMatrix : + public dSMatrix +{ +public: + void precondition(dVector& dst, const dVector& src) const + { + dSMatrix::precondition_SSOR(dst, src); + } +}; + + +class Laplace +{ + Function<2>& exact; +protected: + Point<2> direction; + Triangulation<2> tr; + DoFHandler<2> dof_primal; +// DoFHandler<2> dof_dual; + + dSMatrixStruct matrix_structure; + AdvMatrix A; + + dVector u; + dVector z; + dVector f; + + PrimitiveVectorMemory mem; + + ConstraintMatrix hanging_nodes; + + StraightBoundary<2> boundary; + +public: + Laplace(); + ~Laplace(); + + void remesh(unsigned int global_refine = 0); + void assemble_primal(const Function<2>& boundary, const Function<2>& rhs); + void solve_primal(); + + double result(const Function<2>& interior, const Function<2>& boundary); + + void adapt(); + + void write_data(const char* name); + + void fill_vector(dVector& v, const Function<2>& f) const; +}; + diff --git a/deal.II/doc/tutorial/chapter-3.laplace/code/main.cc b/deal.II/doc/tutorial/chapter-3.laplace/code/main.cc new file mode 100644 index 0000000000..7e2181f5f5 --- /dev/null +++ b/deal.II/doc/tutorial/chapter-3.laplace/code/main.cc @@ -0,0 +1,74 @@ +// $Id$ + +#include "laplace.h" +#include "functions.h" + +#include +#include +#include + +#include +#include + +ZeroFunction<2> zero; + +char fname[30]; + +main(int argc, char** argv) +{ + // JS.Logfile erzeugen, als Stream konzipiert + + ofstream logfile("T"); + deallog.attach(logfile); + + if (argc==1) + cerr << "Usage: " << argv[0] << "firstgrid\nUsing 3" + << endl; + + int firstgrid = 3; + + if (argc>=2) firstgrid = atoi(argv[1]); + + deallog << "Firstgrid " << firstgrid << endl; + + // JS.Benötigte Funktionen zur Lösung des Problems + WeightFunction weight; + BoundaryFct boundary; + Laplace lap; + + // JS.Logstream ist ein stack, ab hier wird "Adaptive:" vor jede Zeile + // gestellt + deallog.push("Adaptive"); + deallog.depth_console(2); + + for (unsigned step = 0; step < 3 ; ++step) + { + deallog << "Step " << step << endl; + // JS.Beim ersten Mal ein verfeinertes Grid erzeugen, firstgrid=Anzahl + // der Verfeinerungen + if (!step) + lap.remesh(firstgrid); + else + { +//JS. lap.adapt(); + lap.remesh(1); + } + + deallog.push("Primal"); + + // JS.exakte Lösung mit 0 auf der rechten Seite + lap.assemble_primal(boundary,zero); + lap.solve_primal(); + + // JS.ab hier kein "Adaptive:" mehr + deallog.pop(); + + sprintf(fname,"T%02d",step); + // JS.Daten zurückschreiben. Aber welche ? + lap.result(weight,boundary); + lap.write_data(fname); + } + // JS.Logfile sauber abschließen und Schluß + deallog.pop(); + deallog.detach(); +} diff --git a/deal.II/doc/tutorial/chapter-3.laplace/index.html b/deal.II/doc/tutorial/chapter-3.laplace/index.html index bc60a8f8ad..f977f4cff8 100644 --- a/deal.II/doc/tutorial/chapter-3.laplace/index.html +++ b/deal.II/doc/tutorial/chapter-3.laplace/index.html @@ -4,7 +4,7 @@ The Laplace Problem - @@ -65,10 +65,11 @@ triangulation

where a triangulation is generated and degrees of freedom are discussed

  • -Assembling the problem +Assembling the problem matrix

    -where the matrices describing the problem and the boundary conditions are -built

    +where the matrices describing the problem is assembled +and the boundary conditions are set +

  • Solving the problem @@ -79,14 +80,14 @@ where the problem is solved


    -Back to the tutorial index

    +Back to the tutorial index +


    Jan Schrage
    -

    -Last modified: Tue 5 Jan 1999 +Last modified: Mon 15 Feb 1999

    diff --git a/deal.II/doc/tutorial/chapter-3.laplace/laplace.html b/deal.II/doc/tutorial/chapter-3.laplace/laplace.html new file mode 100644 index 0000000000..bbc49f1be2 --- /dev/null +++ b/deal.II/doc/tutorial/chapter-3.laplace/laplace.html @@ -0,0 +1,95 @@ + + + + DEAL tutorial: the Laplace problem + + + + + + +

    The class Laplace

    +

    +The class Laplace contains most of the code we need to actually solve the problem at +hand. The purpose of this chapter is to establish the elements that are needed for this class +or any one like it. +

    + +

    +Let's have a look at the class definition: +

    +
    +class Laplace
    +{
    +  Function<2>& exact;
    +protected:
    +  Triangulation<2> tr;
    +  DoFHandler<2> dof_primal;
    +
    +  dSMatrixStruct matrix_structure;
    +  LapMatrix A;
    +
    +  ConstraintMatrix hanging_nodes;
    +
    +
    +
    +

    +These few lines define several important elements: The right hand side of the equation +exact, the triangulation tr, i.e. the grid, and a handler for the degrees +of freedom for the finite elements dof_primal, all for the two-dimensional case. +In addition three matrices are defined (the matrix A defining our problem). Note that +in order to solve any problem at all with DEAL the definitions above are paramount. +

    + +

    +The next bit are the functions actually called by our program, the working part, so to say. +The constructor has the task of generating a triangulation, too. +

    +
    +
    +public:
    +  Laplace(Function<2>& solution);
    +  ~Laplace();
    +
    +
    +

    +The next few functions refine the grid - non-adaptively - assemble the primal problem and +call the appropriate solver. +

    +
    +
    +  void remesh(unsigned int global_refine = 0);
    +  void assemble_primal(const Function<2>& boundary, const Function<2>& rhs);
    +  void solve_primal();
    +
    +
    + +}; +
    + + +
    +

    +Back to the tutorial index +

    + +
    +

    +

    Jan Schrage
    +

    + +

    +Last modified: Fri Feb 12, 1999 +

    + + diff --git a/deal.II/doc/tutorial/chapter-3.laplace/main.html b/deal.II/doc/tutorial/chapter-3.laplace/main.html index e62d24984e..e6a65ccdd5 100644 --- a/deal.II/doc/tutorial/chapter-3.laplace/main.html +++ b/deal.II/doc/tutorial/chapter-3.laplace/main.html @@ -1,5 +1,5 @@ - + DEAL tutorial: the Laplace problem @@ -21,18 +21,15 @@ The main program has several functions:
  • Inclusion of the necessary headers and variable definitions.
  • -
  • - Creation of a logfile and data logging. -
  • Instantiation of the C++ class Laplace dealing with the problem.
  • -
  • Calling the Laplace methods for assemblage and solution of the - problem. +
  • Calling the Laplace methods for assemblage and solution of the + problem.
  • - Writing out of the output data and termination. + Writing out of the output data and termination.
  • @@ -54,47 +51,6 @@ the function definition for our solution function are included:
    -

    -Next, we need some standard include files -

    - -
    -
    -#include <iostream.h&rt;
    -#include <fstream.h&rt;
    -#include <stdlib.h&rt;
    -
    -
    - -

    -and some DEAL specific include files that enable us to do runtime logging and -nicely identify our program:

    -
    -
    -#include <base/logstream.h&rt;
    -#include <base/jobidentifier.h&rt;
    -
    -
    - -

    -and some more stuff which will be discussed when appropriate: -

    - -
    -
    -ZeroFunction<2> zero;
    -char fname[30];
    -extern const char* funcversion;
    -extern const char* laplaceversion;
    -char versioninfo[500];
    -
    -const char* JobIdentifier::program_id() 
    -{ 
    -  sprintf(versioninfo,"%s\n%s", funcversion, laplaceversion);	    
    -  return versioninfo;
    -}
    -
    -

    Our main program starts here. It will take the initial number of global grid refinements as its argument. That means that the number 3 as argument will @@ -108,20 +64,6 @@ main(int argc, char** argv) { - -

    Data logging

    -

    -We want to log info about the program run to a file. Logfiles are streams, -which behave like stacks in several ways. How to make use of the stack concept -will be apparent later. -

    -
    -
    -ofstream logfile("T");
    -deallog.attach(logfile);
    -
    -
    -

    Instantiation of needed classes

    We need a solution function and an instance of the class dealing with the @@ -137,18 +79,12 @@ Laplace lap(exact);

    In addition we need to do some refinement (the command line argument was -previously stored in the variable firstgrid.Please note that every -log entry will now be preceeded by "Adaptive: " and that the stack height is -increased by one. Only entries with a stack height of two or less will we -written to the console. +previously stored in the variable firstgrid.

    
    -deallog.push("Adaptive");
    -deallog.depth_console(2);
    -
     for (unsigned step = 0; step < 3 ; ++step)   
     {     
    -  deallog << "Step " << step << endl;
    +  
       if (!step) 
          lap.remesh(firstgrid);
       else
    @@ -157,34 +93,30 @@ for (unsigned step = 0; step < 3 ; ++step)
       }
     
    +

    Problem assemblage and solution

    -Now we have our log entries preceded by "Primal" since we solve the primal problem, -our class assembles and solves the problem; the solution is exact (as defined above) +Our class assembles and solves the primal problem; the solution is exact (as defined above) and the right hand side of the equation is zero (as defined above). If the right -hand side were not zero we would solve the Poisson equation instead. Afterwards -"Primal" is removed from all the following log entries. +hand side were not zero we would solve the Poisson equation instead.

    
    -  deallog.push("Primal"); 
       lap.assemble_primal(exact, zero); 
       lap.solve_primal();          
    -  deallog.pop();
     
    + +

    Data output

    -Finally the solution is written to a file and the logfile is closed. -

    +Finally the solution is written to a file.

     
       sprintf(fname,"T%02d",step);    
       lap.write_data(fname);   
      }   
    - deallog.pop();   
    - deallog.detach();
     }
     

    -Back to the tutorial index +Back to the tutorial index


    diff --git a/deal.II/doc/tutorial/chapter-3.laplace/solution.html b/deal.II/doc/tutorial/chapter-3.laplace/solution.html new file mode 100644 index 0000000000..6be9cb3784 --- /dev/null +++ b/deal.II/doc/tutorial/chapter-3.laplace/solution.html @@ -0,0 +1,28 @@ + + + + DEAL tutorial: the Laplace problem + + + + + + +

    Solving the problem

    + +
    +

    +Back to the tutorial index +

    + +
    +

    +

    Jan Schrage
    +

    + +

    +Last modified: Fri Feb 12, 1999 +

    + + diff --git a/deal.II/doc/tutorial/chapter-3.laplace/structure.html b/deal.II/doc/tutorial/chapter-3.laplace/structure.html new file mode 100644 index 0000000000..b0bf4bcd4d --- /dev/null +++ b/deal.II/doc/tutorial/chapter-3.laplace/structure.html @@ -0,0 +1,58 @@ + + + + DEAL tutorial: the Laplace problem + + + + + + +

    Program structure

    +

    + In order to solve our differential equation we have to deal with the + the following tasks: +

    + +

    + All these tasks are problem specific, therefore we will put them into + a class called Laplace. + The main program + will - for now - do nothing but call the methods of this class in their + proper order. +

    +

    + We end up with a program consisting of two major components: +

      +
    • a main program that starts the process of problem + generation and solution by calling methods of +
    • +
    • the class Laplace that contains all the parts specific + to the problem at hand +
    • +
    + + +
    +

    +Back to the tutorial index +

    + +
    +
    Jan Schrage
    + +

    +Last modified: Mon Feb 15, 1999 +

    + + diff --git a/deal.II/doc/tutorial/chapter-3.laplace/triangulation.html b/deal.II/doc/tutorial/chapter-3.laplace/triangulation.html new file mode 100644 index 0000000000..6c5d679907 --- /dev/null +++ b/deal.II/doc/tutorial/chapter-3.laplace/triangulation.html @@ -0,0 +1,63 @@ + + + + DEAL tutorial: the Laplace problem + + + + + + +

    Generating a triangulation

    + +The initial triangulation is generated by the constructor of the class Laplace. +It is a hypercube with the coordinates along each axis ranging from -1 to 1. This first +triangulation consists of only one finite element. +
    +
    +Laplace::Laplace(Function<2>& solution)		
    +{
    +  tr.create_hypercube(-1.,1.);
    +
    +
    +

    +Right afterwards an iterator for the cells is defined (in effect a pointer to the first cell +in this case) and all the cell's faces are numbered. +

    +
    +
    +  Triangulation<2>::cell_iterator c = tr.begin();
    +  for (unsigned int i=0;i::faces_per_cell;++i)
    +  {
    +    Triangulation<2>::face_iterator f = c->face(i);
    +    f->set_boundary_indicator(i+1);
    +  }
    +
    +
    +

    +Afterwards all the degrees of freedom, i.e. all the cell vertices, are renumbered. +This step is necessary whenever the triangulation has changed, e.g. after each refinement. +

    +
    +
    +  dof_primal.distribute_dofs(fe_primal);
    + }
    +
    +
    + +
    +

    +Back to the tutorial index +

    + +
    +

    +

    Jan Schrage
    +

    + +

    +Last modified: Fri Feb 12, 1999 +

    + + diff --git a/deal.II/doc/tutorial/dealdoc.css b/deal.II/doc/tutorial/dealdoc.css new file mode 100644 index 0000000000..c32d82f87d --- /dev/null +++ b/deal.II/doc/tutorial/dealdoc.css @@ -0,0 +1,5 @@ + +BODY {background: white} + diff --git a/deal.II/doc/tutorial/dealtut.css b/deal.II/doc/tutorial/dealtut.css new file mode 100644 index 0000000000..4e91f27dde --- /dev/null +++ b/deal.II/doc/tutorial/dealtut.css @@ -0,0 +1,4 @@ + +@import url(dealdoc.css); diff --git a/deal.II/doc/tutorial/glossary.html b/deal.II/doc/tutorial/glossary.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/deal.II/doc/tutorial/index.html b/deal.II/doc/tutorial/index.html new file mode 100644 index 0000000000..513405feab --- /dev/null +++ b/deal.II/doc/tutorial/index.html @@ -0,0 +1,72 @@ + + + + + The DEAL Tutorial + + + + +

    The DEAL Tutorial

    + +

    or DEAL in several easy and some more hard lessons

    + +

    Prerequisites

    +

    + This tutorial is written in HTML + 4.0 which your browser may or may not support. If you run into problems + you are advised to try a recent browser or one that is able to parse Document + Type Definitions. The reason for this is the math support of HTML 4.0. Most + people should, however, not run into any + problems.

    +

    + You yourself should have some background knowledge on numerical methods, finite + elements and C++. +

    + +

    Usage of this document

    +

    + This tutorial is split into several parts, starting with the stationary + Laplace problem and advancing to more complicated problems. If you have never + used DEAL we recommend that you begin at the beginning and + advance through the chapters in their proper order. This tutorial contains the + complete code for every example program and can be used as a reference, too, + if you are looking for code to solve a specific problem with + DEAL. +

    + +

    On DEAL

    +

    + DEAL is short for Differential Equations Analysis Library, + which says it all, really. Its purpose it the solution of partial differential + equations on unstructured grids with error control. You can find more + information on DEAL and some examples at + + http://gaia.iwr.uni-heidelberg.de/DEAL/. DEAL was written + by the numerics group at the IWR, University of Heidelberg. +

    + +

    Chapter 1: The Laplace + problem

    +

    + We will solve the stationary Laplace problem on a square grid with zero + boundary condition on three of the edges and a constant boundary condition on + one edge. +

    + +

    Technical terms

    +

    + There is a glossary available to explain technical terms. +

    + +
    + +
    + Jan Schrage
    +

    + Last modified: Tue 5 Jan 1999 +

    + + + diff --git a/deal.II/doc/tutorial/validate b/deal.II/doc/tutorial/validate new file mode 100755 index 0000000000..2df9a75fe4 --- /dev/null +++ b/deal.II/doc/tutorial/validate @@ -0,0 +1,3 @@ +#!/bin/sh +echo Validating $1 +cat $1 | sed -e 's/http:\/\/www.w3.org\/TR\/REC-html40\/strict.dtd//' -e 's/\"\"//' | nsgmls -s -m /home/people/schrage/lib/sgml/pubtext/HTML4.soc