amg preconditioner

Asked by Sven Fanghänel

Hi
i would like to set boundary condition in a rectangular mesh, with 2 subdoimain that are circles. I want to two Dirichlet boundary condition on the border of each circle.
i got an error mesage: unknown preconditioner `amg`
the code is:
I use windows 7.
Has everyone a tip for this problem.

Thanx Sven

from dolfin import *
import numpy as np
not_working_in_parallel("mesh smoothing demo")

# Create rectangular mesh
mesh = Rectangle(0.0, 0.0, 1.4, 0.8, 60, 20)

# Define a circular hole
center = Point(0.1, 0.1)
center2 = Point(0.6, 0.6)
radius = 0.05

class Hole(SubDomain):

    def inside(self, x, on_boundary):
        r = sqrt((x[0] - center[0])**2 + (x[1] - center[1])**2)
        return r < 1.5*radius # slightly larger

    def snap(self, x):
        r = sqrt((x[0] - center[0])**2 + (x[1] - center[1])**2)
        if r < 1.5*radius:
            x[0] = center[0] + (radius / r)*(x[0] - center[0])
            x[1] = center[1] + (radius / r)*(x[1] - center[1])

class Hole2(SubDomain):

    def inside(self, x, on_boundary):
        r = sqrt((x[0] - center2[0])**2 + (x[1] - center2[0])**2)
        return r < 1.5*radius # slightly larger

    def snap(self, x):
        r = sqrt((x[0] - center2[0])**2 + (x[1] - center2[1])**2)
        if r < 1.5*radius:
            x[0] = center2[0] + (radius / r)*(x[0] - center2[0])
            x[1] = center2[1] + (radius / r)*(x[1] - center2[1])

# Mark hole and extract submesh
hole = Hole()
hole2 = Hole2()
sub_domains = MeshFunction("uint", mesh, mesh.topology().dim())
sub_domains.set_all(0)
hole.mark(sub_domains, 1)
hole2.mark(sub_domains, 2)
mesh = SubMesh(mesh, sub_domains, 0)
mesh.snap_boundary(hole)
mesh.snap_boundary(hole2)

# Refine and snap mesh
plot(mesh, title="Mesh 0")
num_refinements = 3
for i in range(num_refinements):

    # Mark cells for refinement
    markers = MeshFunction("bool", mesh, mesh.topology().dim())
    markers.set_all(False)
    for cell in cells(mesh):
        if cell.midpoint().distance(center2) < 2*radius:
            markers[cell.index()] = True

    # Refine mesh
    mesh = refine(mesh, markers)

    # Snap boundary
    mesh.snap_boundary(hole)
    mesh.snap_boundary(hole2)
  # Plot mesh
    #plot(mesh, title=("Mesh %d" % (i + 1)))
#interactive()

# Initialize mesh function for interior domains
boundaries = CellFunction("uint", mesh)
boundaries.set_all(0)
hole.mark(boundaries, 1)
hole2.mark(boundaries, 2)
h = CellSize(mesh)
# Create mesh and define function space

V = FunctionSpace(mesh, "CG", 1)
R = FunctionSpace(mesh, "R", 0)
W = V * R
# Define input data
a0 = Constant(1.0)
a1 = Constant(0.01)
g_L = Expression("- 10*exp(- pow(x[1] - 0.5, 2))")
g_R = Constant("1.0")
f = Constant(1.0)

# Define function space and basis functions
V = FunctionSpace(mesh, "CG", 2)
u = TrialFunction(V)
v = TestFunction(V)

# Define Dirichlet boundary conditions at top and bottom boundaries
bcs = [DirichletBC(V, 1.0, boundaries, 1),
       DirichletBC(V, 0.0, boundaries, 2)]

Question information

Language:
English Edit question
Status:
Answered
For:
FEniCS Project Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Johan Hake (johan-hake) said :
#1

This is an old bug for linearalgebra backends, which do not include amg
as a preconditioner. Only PETSc, Trilinos do that. The bug has been
fixed in the stable and development branches of DOLFIN, but
unfortunately not released.

Not sure if there are any nightly builds for Windows binaries, otherwise
you need to get the code your self and compile.

Johan

On 08/24/2012 10:01 AM, Sven Fanghänel wrote:
> New question #206671 on FEniCS Project:
> https://answers.launchpad.net/fenics/+question/206671
>
> Hi
> i would like to set boundary condition in a rectangular mesh, with 2 subdoimain that are circles. I want to two Dirichlet boundary condition on the border of each circle.
> i got an error mesage: unknown preconditioner `amg`
> the code is:
> I use windows 7.
> Has everyone a tip for this problem.
>
> Thanx Sven
>
> from dolfin import *
> import numpy as np
> not_working_in_parallel("mesh smoothing demo")
>
> # Create rectangular mesh
> mesh = Rectangle(0.0, 0.0, 1.4, 0.8, 60, 20)
>
> # Define a circular hole
> center = Point(0.1, 0.1)
> center2 = Point(0.6, 0.6)
> radius = 0.05
>
> class Hole(SubDomain):
>
> def inside(self, x, on_boundary):
> r = sqrt((x[0] - center[0])**2 + (x[1] - center[1])**2)
> return r < 1.5*radius # slightly larger
>
> def snap(self, x):
> r = sqrt((x[0] - center[0])**2 + (x[1] - center[1])**2)
> if r < 1.5*radius:
> x[0] = center[0] + (radius / r)*(x[0] - center[0])
> x[1] = center[1] + (radius / r)*(x[1] - center[1])
>
> class Hole2(SubDomain):
>
> def inside(self, x, on_boundary):
> r = sqrt((x[0] - center2[0])**2 + (x[1] - center2[0])**2)
> return r < 1.5*radius # slightly larger
>
> def snap(self, x):
> r = sqrt((x[0] - center2[0])**2 + (x[1] - center2[1])**2)
> if r < 1.5*radius:
> x[0] = center2[0] + (radius / r)*(x[0] - center2[0])
> x[1] = center2[1] + (radius / r)*(x[1] - center2[1])
>
> # Mark hole and extract submesh
> hole = Hole()
> hole2 = Hole2()
> sub_domains = MeshFunction("uint", mesh, mesh.topology().dim())
> sub_domains.set_all(0)
> hole.mark(sub_domains, 1)
> hole2.mark(sub_domains, 2)
> mesh = SubMesh(mesh, sub_domains, 0)
> mesh.snap_boundary(hole)
> mesh.snap_boundary(hole2)
>
> # Refine and snap mesh
> plot(mesh, title="Mesh 0")
> num_refinements = 3
> for i in range(num_refinements):
>
> # Mark cells for refinement
> markers = MeshFunction("bool", mesh, mesh.topology().dim())
> markers.set_all(False)
> for cell in cells(mesh):
> if cell.midpoint().distance(center2) < 2*radius:
> markers[cell.index()] = True
>
> # Refine mesh
> mesh = refine(mesh, markers)
>
> # Snap boundary
> mesh.snap_boundary(hole)
> mesh.snap_boundary(hole2)
> # Plot mesh
> #plot(mesh, title=("Mesh %d" % (i + 1)))
> #interactive()
>
> # Initialize mesh function for interior domains
> boundaries = CellFunction("uint", mesh)
> boundaries.set_all(0)
> hole.mark(boundaries, 1)
> hole2.mark(boundaries, 2)
> h = CellSize(mesh)
> # Create mesh and define function space
>
> V = FunctionSpace(mesh, "CG", 1)
> R = FunctionSpace(mesh, "R", 0)
> W = V * R
> # Define input data
> a0 = Constant(1.0)
> a1 = Constant(0.01)
> g_L = Expression("- 10*exp(- pow(x[1] - 0.5, 2))")
> g_R = Constant("1.0")
> f = Constant(1.0)
>
> # Define function space and basis functions
> V = FunctionSpace(mesh, "CG", 2)
> u = TrialFunction(V)
> v = TestFunction(V)
>
> # Define Dirichlet boundary conditions at top and bottom boundaries
> bcs = [DirichletBC(V, 1.0, boundaries, 1),
> DirichletBC(V, 0.0, boundaries, 2)]
>

Revision history for this message
Sven Fanghänel (fanghaenel) said :
#2

Hi Johan thanx for your quick answer.
is it runnuing if i installed fenics on ubuntu 12.04

Revision history for this message
Johan Hake (johan-hake) said :
#3

At least then you have possibilities to run a nightly build of the
development version, which should incorporate the bug fix.

Johan

On 08/24/2012 01:15 PM, Sven Fanghänel wrote:
> Question #206671 on FEniCS Project changed:
> https://answers.launchpad.net/fenics/+question/206671
>
> Status: Answered => Open
>
> Sven Fanghänel is still having a problem:
> Hi Johan thanx for your quick answer.
> is it runnuing if i installed fenics on ubuntu 12.04
>

Revision history for this message
Johannes Ring (johannr) said :
#4

There is also a nightly build for Windows, but this is not working reliably at the moment. And the Windows binaries does not come with PETSc or Trilinos if that matters.

Can you help with this problem?

Provide an answer of your own, or ask Sven Fanghänel for more information if necessary.

To post a message you must log in.