Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Error with setting the boundary condition

  • omar
  • New Member
  • New Member
More
1 year 11 months ago #4390 by omar
Dear all

I am trying to solve Poisson equation on a contraction step problem. I get an error to set dirichlet boundary condition at different boundaries.

Here is the part of the code:  
######################################################################################################

from ngsolve import *
import matplotlib.pyplot as plt
import numpy as np
from netgen.geom2d import SplineGeometry
ngsglobals.msg_level =2


# %% Geometry generation (points definition)
geo = SplineGeometry()
p1 = geo.AppendPoint (0,0)
p2 = geo.AppendPoint (3,0)
p3 = geo.AppendPoint (3,0.1)
p4 = geo.AppendPoint (2,0.1)
p5 = geo.AppendPoint (2,1)
p6 = geo.AppendPoint (0,1)

geo.Append (["line", p1, p2],bc=1) # bottom
geo.Append (["line", p2, p3],bc=2) # outlet
geo.Append (["line", p3, p4],bc=3) # horizontal
geo.Append (["line", p4, p5],bc=4) # vertical
geo.Append (["line", p5, p6],bc=5) # top
geo.Append (["line", p6, p1],bc=6) # Inlet

mesh = geo.GenerateMesh (maxh=0.1)

fes = H1(mesh, order=2, dirichlet=[1,2])

###################################

And this is the error message:

__init__(): incompatible constructor arguments. The following argument types are supported:
1. ngsolve.comp.H1(mesh: ngsolve.comp.Mesh, **kwargs)

Invoked with: <netgen.libngpy._meshing.Mesh object at 0x000001722D060BF0>; kwargs: order=2, dirichlet=[1, 2
More
1 year 11 months ago #4391 by hvwahl
Hi omar,

the FE space needs a ngsolve mesh (rather than a netgen mesh). You can fix it by making the netgen mesh a ngsolve mesh:

mesh = Mesh(geo.GenerateMesh (maxh=0.1))

Best wishes, Henry
Time to create page: 0.103 seconds