← Back to team overview

dolfin team mailing list archive

[noreply@xxxxxxxxxxxxx: [Branch ~dolfin-core/dolfin/main] Rev 6004: Update demo documentation, evidently one of my special skills.]

 

Thanks!

Is verify_code_snippets run now as part of "make runtests" and
correctly reported by the buildbots?

--
Anders
--- Begin Message ---
------------------------------------------------------------
revno: 6004
committer: Marie E. Rognes <meg@xxxxxxxxx>
branch nick: rognes
timestamp: Fri 2011-07-01 17:01:52 +0200
message:
  Update demo documentation, evidently one of my special skills.
modified:
  demo/pde/biharmonic/cpp/documentation.rst
  demo/pde/biharmonic/python/documentation.rst
  demo/pde/cahn-hilliard/cpp/documentation.rst
  demo/pde/cahn-hilliard/cpp/main.cpp
  demo/pde/mixed-poisson/cpp/documentation.rst
  demo/pde/mixed-poisson/python/documentation.rst
  demo/pde/navier-stokes/cpp/documentation.rst
  demo/pde/navier-stokes/python/documentation.rst
  demo/pde/poisson/cpp/documentation.rst
  demo/pde/poisson/cpp/main.cpp
  demo/pde/poisson/python/documentation.rst
  demo/pde/stokes-iterative/python/documentation.rst


--
lp:dolfin
https://code.launchpad.net/~dolfin-core/dolfin/main

Your team DOLFIN Core Team is subscribed to branch lp:dolfin.
To unsubscribe from this branch go to https://code.launchpad.net/~dolfin-core/dolfin/main/+edit-subscription
=== modified file 'demo/pde/biharmonic/cpp/documentation.rst'
--- demo/pde/biharmonic/cpp/documentation.rst	2011-05-28 17:26:14 +0000
+++ demo/pde/biharmonic/cpp/documentation.rst	2011-07-01 15:01:52 +0000
@@ -100,7 +100,8 @@
 
     void eval(Array<double>& values, const Array<double>& x) const
     {
-      values[0] = 4.0*std::pow(DOLFIN_PI, 4)*std::sin(DOLFIN_PI*x[0])*std::sin(DOLFIN_PI*x[1]);
+    values[0] = 4.0*std::pow(DOLFIN_PI, 4)*
+      std::sin(DOLFIN_PI*x[0])*std::sin(DOLFIN_PI*x[1]);
     }
 
   };
@@ -162,23 +163,19 @@
 
 .. code-block:: c++
 
-    // Define forms and attach functions
+    // Define variational problem
     Biharmonic::BilinearForm a(V, V);
     Biharmonic::LinearForm L(V);
     a.alpha = alpha; L.f = f;
 
-A :cpp:class:`VariationalProblem` is created from the forms and the
-Dirichet boundary condition, a finite element function ``u`` is
-created and the problem is solved:
+A :cpp:class:`Function` is created to hold the solution and the
+problem is solved:
 
 .. code-block:: c++
 
-    // Create PDE
-    VariationalProblem problem(a, L, bc);
-
-    // Solve PDE
+    // Compute solution
     Function u(V);
-    problem.solve(u);
+    solve(a == L, u, bc);
 
 The solution is then plotted to the screen and written to a file in VTK
 format:

=== modified file 'demo/pde/biharmonic/python/documentation.rst'
--- demo/pde/biharmonic/python/documentation.rst	2011-06-06 20:49:40 +0000
+++ demo/pde/biharmonic/python/documentation.rst	2011-07-01 15:01:52 +0000
@@ -109,13 +109,14 @@
     # Define linear form
     L = f*v*dx
 
-A variational problem is created and solved:
+A :py:class:`Function <dolfin.functions.function.Function>` is created
+to store the solution and the variational problem is solved:
 
 .. code-block:: python
 
-    # Create variational problem and solve
-    problem = VariationalProblem(a, L, bc)
-    u = problem.solve()
+    # Solve variational problem
+    u = Function(V)
+    solve(a == L, u, bc)
 
 The computed solution is written to a file in VTK format and plotted to
 the screen.

=== modified file 'demo/pde/cahn-hilliard/cpp/documentation.rst'
--- demo/pde/cahn-hilliard/cpp/documentation.rst	2011-05-28 17:26:14 +0000
+++ demo/pde/cahn-hilliard/cpp/documentation.rst	2011-07-01 15:01:52 +0000
@@ -97,11 +97,11 @@
 
 .. code-block:: python
 
-    L0 = c*q*dx  - c0*q*dx   + dt*dot(grad(mu_mid), grad(q))*dx
-    L1 = mu*v*dx - dfdc*v*dx - lmbda*dot(grad(c), grad(v))*dx
-    L = L0 + L1
+    F0 = c*q*dx  - c0*q*dx   + dt*dot(grad(mu_mid), grad(q))*dx
+    F1 = mu*v*dx - dfdc*v*dx - lmbda*dot(grad(c), grad(v))*dx
+    F = F0 + F1
 
-    a = derivative(L, u, du)
+    J = derivative(F, u, du)
 
 C++ program
 ^^^^^^^^^^^
@@ -178,12 +178,12 @@
                          const Constant& theta, const Constant& lambda)
                        : reset_Jacobian(true)
     {
-      // Initialse class (depending on geometric dimension of the mesh).
+      // Initialize class (depending on geometric dimension of the mesh).
       // Unfortunately C++ does not allow namespaces as template arguments
       if (mesh.geometry().dim() == 2)
-        init<CahnHilliard2D::FunctionSpace, CahnHilliard2D::BilinearForm, CahnHilliard2D::LinearForm>(mesh, dt, theta, lambda);
+        init<CahnHilliard2D::FunctionSpace, CahnHilliard2D::JacobianForm, CahnHilliard2D::ResidualForm>(mesh, dt, theta, lambda);
       else if (mesh.geometry().dim() == 3)
-        init<CahnHilliard3D::FunctionSpace, CahnHilliard3D::BilinearForm, CahnHilliard3D::LinearForm>(mesh, dt, theta, lambda);
+        init<CahnHilliard3D::FunctionSpace, CahnHilliard3D::JacobianForm, CahnHilliard3D::ResidualForm>(mesh, dt, theta, lambda);
       else
         error("Cahn-Hilliard model is programmed for 2D and 3D only.");
     }

=== modified file 'demo/pde/cahn-hilliard/cpp/main.cpp'
--- demo/pde/cahn-hilliard/cpp/main.cpp	2011-06-30 19:55:22 +0000
+++ demo/pde/cahn-hilliard/cpp/main.cpp	2011-07-01 15:01:52 +0000
@@ -63,7 +63,7 @@
                          const Constant& theta, const Constant& lambda)
                        : reset_Jacobian(true)
     {
-      // Initialse class (depending on geometric dimension of the mesh).
+      // Initialize class (depending on geometric dimension of the mesh).
       // Unfortunately C++ does not allow namespaces as template arguments
       if (mesh.geometry().dim() == 2)
         init<CahnHilliard2D::FunctionSpace, CahnHilliard2D::JacobianForm, CahnHilliard2D::ResidualForm>(mesh, dt, theta, lambda);

=== modified file 'demo/pde/mixed-poisson/cpp/documentation.rst'
--- demo/pde/mixed-poisson/cpp/documentation.rst	2011-05-28 17:26:14 +0000
+++ demo/pde/mixed-poisson/cpp/documentation.rst	2011-07-01 15:01:52 +0000
@@ -195,20 +195,18 @@
     EssentialBoundary boundary;
     DirichletBC bc(W0, G, boundary);
 
-To compute the solution we use the ``VariationalProblem`` class with
-the bilinear and linear forms, and the boundary condition. The (full)
-solution will be stored in the ``Function`` ``w``, which we also
-initialise using the ``FunctionSpace`` :math:`W`. The actual
-computation is performed by calling ``solve``.
+To compute the solution we use the bilinear and linear forms, and the
+boundary condition, but we also need to create a :cpp:class:`Function`
+to store the solution(s). The (full) solution will be stored in the
+:cpp:class:`Function` ``w``, which we initialise using the
+:cpp:class:`FunctionSpace` ``W``. The actual computation is performed
+by calling ``solve``.
 
 .. code-block:: c++
 
-    // Define variational problem
-    VariationalProblem problem(a, L, bc);
-
-    // Compute (full) solution
+    // Compute solution
     Function w(W);
-    problem.solve(w);
+    solve(a == L, w, bc);
 
 Now, the separate components ``sigma`` and ``u`` of the solution can
 be extracted by taking components. These can easily be visualized by

=== modified file 'demo/pde/mixed-poisson/python/documentation.rst'
--- demo/pde/mixed-poisson/python/documentation.rst	2011-06-06 20:49:40 +0000
+++ demo/pde/mixed-poisson/python/documentation.rst	2011-07-01 15:01:52 +0000
@@ -154,24 +154,24 @@
 
     bc = DirichletBC(W.sub(0), G, boundary)
 
-.. index::
-   single: VariationalProblem; (in Mixed Poisson demo)
 
-To compute the solution, a :py:class:`VariationalProblem
-<dolfin.fem.variationalproblem.VariationalProblem>` object is created
-using the bilinear and linear forms, and the boundary condition.  The
-:py:func:`solve
-<dolfin.fem.variationalproblem.VariationalProblem.solve>` function is
-then called, yielding the full solution. The separate components
-``sigma`` and ``u`` of the solution can be extracted by calling the
-:py:func:`split <dolfin.functions.function.Function.split>`
-function. Finally, we plot the solutions to examine the result.
+To compute the solution we use the bilinear and linear forms, and the
+boundary condition, but we also need to create a :py:class:`Function`
+to store the solution(s). The (full) solution will be stored in the
+``w``, which we initialise using the :py:class:`FunctionSpace
+<dolfin.functions.functionspace.FunctionSpace>` ``W``. The actual
+computation is performed by calling :py:func:`solve
+<dolfin.fem.solving.solve`. The separate components ``sigma`` and
+``u`` of the solution can be extracted by calling the :py:func:`split
+<dolfin.functions.function.Function.split>` function. Finally, we plot
+the solutions to examine the result.
 
 .. code-block:: python
 
     # Compute solution
-    problem = VariationalProblem(a, L, bc)
-    (sigma, u) = problem.solve().split()
+    w = Function(W)
+    solve(a == L, w, bc)
+    (sigma, u) = w.split()
 
     # Plot sigma and u
     plot(sigma)

=== modified file 'demo/pde/navier-stokes/cpp/documentation.rst'
--- demo/pde/navier-stokes/cpp/documentation.rst	2011-05-28 17:26:14 +0000
+++ demo/pde/navier-stokes/cpp/documentation.rst	2011-07-01 15:01:52 +0000
@@ -44,10 +44,10 @@
     nu = 0.01
 
     # Define bilinear and linear forms
-    F = (1/k)*inner(u - u0, v)*dx + inner(grad(u0)*u0, v)*dx + \
+    eq = (1/k)*inner(u - u0, v)*dx + inner(grad(u0)*u0, v)*dx + \
         nu*inner(grad(u), grad(v))*dx - inner(f, v)*dx
-    a = lhs(F)
-    L = rhs(F)
+    a = lhs(eq)
+    L = rhs(eq)
 
 The variational problem for the pressure update is implemented as
 follows:

=== modified file 'demo/pde/navier-stokes/python/documentation.rst'
--- demo/pde/navier-stokes/python/documentation.rst	2011-06-06 20:49:40 +0000
+++ demo/pde/navier-stokes/python/documentation.rst	2011-07-01 15:01:52 +0000
@@ -66,13 +66,11 @@
 .. code-block:: python
 
     # Define time-dependent pressure boundary condition
-    p_in = Expression("sin(3.0*t)")
+    p_in = Expression("sin(3.0*t)", t=0.0)
 
-The variable ``t`` is automatically available as part of an
-:py:class:`Expression <dolfin.functions.expression.Expression>`. Note
-that this variable is not automatically updated during time-stepping,
-so we must remember to manually update the value of the current time
-in each time step.
+Note that the variable ``t`` is not automatically updated during
+time-stepping, so we must remember to manually update the value of the
+current time in each time step.
 
 We may now define the boundary conditions for the velocity and
 pressure. We define one no-slip boundary condition for the velocity
@@ -82,12 +80,16 @@
 .. code-block:: python
 
     # Define boundary conditions
-    noslip  = DirichletBC(V, (0, 0), "on_boundary && x[1] < 1.0 - DOLFIN_EPS && x[0] < 1.0 - DOLFIN_EPS")
+    noslip  = DirichletBC(V, (0, 0),
+                          "on_boundary && \
+                           (x[0] < DOLFIN_EPS | x[1] < DOLFIN_EPS | \
+                           (x[0] > 0.5 - DOLFIN_EPS && x[1] > 0.5 - DOLFIN_EPS))")
     inflow  = DirichletBC(Q, p_in, "x[1] > 1.0 - DOLFIN_EPS")
     outflow = DirichletBC(Q, 0, "x[0] > 1.0 - DOLFIN_EPS")
     bcu = [noslip]
     bcp = [inflow, outflow]
 
+
 We collect the boundary conditions in the two lists ``bcu`` and
 ``bcp`` so that we may easily iterate over them below when we apply
 the boundary conditions. This makes it easy to add new boundary
@@ -161,15 +163,13 @@
 
     # Time-stepping
     t = dt
-    p = Progress("Time-stepping")
     while t < T + DOLFIN_EPS:
 
         # Update pressure boundary condition
         p_in.t = t
 
-We use the :py:class:`Progress <dolfin.cpp.Progress>` class to display
-a progress bar during the computation. We also remember to update the
-current time for the time-dependent pressure boundary value.
+We remember to update the current time for the time-dependent pressure
+boundary value.
 
 For each of the three steps of Chorin's method, we assemble the
 right-hand side, apply boundary conditions and solve a linear
@@ -191,7 +191,7 @@
     begin("Computing pressure correction")
     b2 = assemble(L2)
     [bc.apply(A2, b2) for bc in bcp]
-    solve(A2, p1.vector(), b2, "gmres", "amg_hypre")
+    solve(A2, p1.vector(), b2, "gmres", "amg")
     end()
 
     # Velocity correction
@@ -220,7 +220,6 @@
 
    # Move to next time step
    u0.assign(u1)
-   p.update(t / T)
    t += dt
 
 Finally, we call the ``interactive`` function to signal that the plot

=== modified file 'demo/pde/poisson/cpp/documentation.rst'
--- demo/pde/poisson/cpp/documentation.rst	2011-05-28 17:26:14 +0000
+++ demo/pde/poisson/cpp/documentation.rst	2011-07-01 15:01:52 +0000
@@ -37,7 +37,7 @@
 functions on triangles (or in order words, continuous piecewise linear
 polynomials on triangles).
 
-Next, we use this element to initialise the trial and test functions
+Next, we use this element to initialize the trial and test functions
 (:math:`u` and :math:`v`) and the coefficient functions (:math:`f` and
 :math:`g`):
 
@@ -164,15 +164,15 @@
 .. index::
     triple: forms; attach; expression
 
-Next, we define the variational problem by initialising the bilinear
-and linear forms (:math:`a`, :math:`L`) using the previously defined
-:cpp:class:`FunctionSpace` ``V``.  Then we can create the source and
-boundary flux term (:math:`f`, :math:`g`) and attach these to the
-linear form.
+Next, we define the variational formulation by initializing the
+bilinear and linear forms (:math:`a`, :math:`L`) using the previously
+defined :cpp:class:`FunctionSpace` ``V``.  Then we can create the
+source and boundary flux term (:math:`f`, :math:`g`) and attach these
+to the linear form.
 
 .. code-block:: c++
 
-    // Define variational problem
+    // Define variational forms
     Poisson::BilinearForm a(V, V);
     Poisson::LinearForm L(V);
     Source f;
@@ -180,25 +180,21 @@
     L.f = f;
     L.g = g;
 
-.. index:: VariationalProblem
-
 Now, we have specified the variational forms and can consider the
-solution of the variational problem.  First, a
-:cpp:class:`VariationalProblem` object is created using the bilinear
-and linear forms, and the Dirichlet boundary condition. The solution
-will be represented as a :cpp:class:`Function`, living in the function
-space ``V``, and needs to be declared. Then, to solve the problem, the
-``solve`` function is called with ``u`` as a single argument; ``u``
-now contains the solution.
+solution of the variational problem. First, we need to define a
+:cpp:class:`Function` ``u`` to store the solution. (Upon
+initialization, it is simply set to the zero function.) Next, we can
+call the :cpp:func:`solve` function with the arguments ``a == L``,
+``u`` and ``bc`` as follows:
 
 .. code-block:: c++
 
     // Compute solution
-    VariationalProblem problem(a, L, bc);
     Function u(V);
-    problem.solve(u);
+    solve(a == L, u, bc);
 
-A :cpp:class:`Function` can be manipulated in various ways, in
+The function ``u`` will be modified during the call to solve. A
+:cpp:class:`Function` can be manipulated in various ways, in
 particular, it can be plotted and saved to file. Here, we output the
 solution to a ``VTK`` file (using the suffix ``.pvd``) for later
 visualization and also plot it using the ``plot`` command:

=== modified file 'demo/pde/poisson/cpp/main.cpp'
--- demo/pde/poisson/cpp/main.cpp	2011-06-30 09:59:44 +0000
+++ demo/pde/poisson/cpp/main.cpp	2011-07-01 15:01:52 +0000
@@ -16,7 +16,7 @@
 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
 //
 // First added:  2006-02-07
-// Last changed: 2011-06-28
+// Last changed: 2011-07-01
 //
 // This demo program solves Poisson's equation
 //
@@ -77,7 +77,7 @@
   DirichletBoundary boundary;
   DirichletBC bc(V, u0, boundary);
 
-  // Define variational problem
+  // Define variational forms
   Poisson::BilinearForm a(V, V);
   Poisson::LinearForm L(V);
   Source f;

=== modified file 'demo/pde/poisson/python/documentation.rst'
--- demo/pde/poisson/python/documentation.rst	2011-06-06 20:49:40 +0000
+++ demo/pde/poisson/python/documentation.rst	2011-07-01 15:01:52 +0000
@@ -111,35 +111,31 @@
   a = inner(grad(u), grad(v))*dx
   L = f*v*dx + g*v*ds
 
-.. index::
-   single: VariationalProblem; (in Poisson demo)
-
 Now, we have specified the variational forms and can consider the
-solution of the variational problem.  First, a
-:py:class:`VariationalProblem
-<dolfin.fem.variationalproblem.VariationalProblem>` object is created
-using the bilinear and linear forms, and the Dirichlet boundary
-condition.  Then, to solve the problem, the :py:func:`solve
-<dolfin.fem.variationalproblem.VariationalProblem.solve>` function is
-called, and the solution is returned in ``u``.
+solution of the variational problem. First, we need to define a
+:py:class:`Function <dolfin.functions.function.Function>` ``u`` to
+represent the solution. (Upon initialization, it is simply set to the
+zero function.) A :py:class:`Function
+<dolfin.functions.function.Function>` represents a function living in
+a finite element function space. Next, we can call the :py:func:`solve
+<dolfin.fem.solving.solve>` function with the arguments ``a == L``,
+``u`` and ``bc`` as follows:
 
 .. code-block:: python
 
     # Compute solution
-    problem = VariationalProblem(a, L, bc)
-    u = problem.solve()
+    u = Function(V)
+    solve(a == L, u, bc)
 
-The default settings for solving a variational problem have been
-used. However, various parameters can be used to control aspects of
-the solution process.
+The function ``u`` will be modified during the call to solve. The
+default settings for solving a variational problem have been
+used. However, the solution process can be controlled in much more
+detail if desired.
 
 .. index::
    single: File; (in Poisson demo)
 
-The solution ``u`` is a :py:class:`Function
-<dolfin.functions.function.Function>` object, which represents a
-function living in a finite element function space. A
-:py:class:`Function <dolfin.functions.function.Function>` can be
+A :py:class:`Function <dolfin.functions.function.Function>` can be
 manipulated in various ways, in particular, it can be plotted and
 saved to file. Here, we output the solution to a ``VTK`` file (using
 the suffix ``.pvd``) for later visualization and also plot it using

=== modified file 'demo/pde/stokes-iterative/python/documentation.rst'
--- demo/pde/stokes-iterative/python/documentation.rst	2011-07-01 00:08:50 +0000
+++ demo/pde/stokes-iterative/python/documentation.rst	2011-07-01 15:01:52 +0000
@@ -152,7 +152,7 @@
 .. code-block:: python
 
     # Create Krylov solver and AMG preconditioner
-    solver = KrylovSolver("tfqmr", "amg_ml")
+    solver = KrylovSolver("tfqmr", "amg")
 
     # Associate operator (A) and preconditioner matrix (P)
     solver.set_operators(A, P)


--- End Message ---

Follow ups