Error with setting the boundary condition
- omar
- Topic Author
- New Member
Less
More
2 years 6 months ago #4390
by omar
Error with setting the boundary condition was created 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
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
2 years 6 months ago #4391
by hvwahl
Replied by hvwahl on topic Error with setting the boundary condition
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
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.099 seconds