- Thank you received: 0
Setting grid function on Facet Space in 3-D
- walker_tr9
- Topic Author
- Offline
- Senior Member
Less
More
2 years 8 months ago #4232
by walker_tr9
Setting grid function on Facet Space in 3-D was created by walker_tr9
So I have been doing this problem in 2-D. I have this space:
fes_rhs_Gm = FacetFESpace(Om_mesh, order=0, definedon="", definedonbound="Gamma")
I then do this:
gf_rhs_Gm = GridFunction(fes_rhs_Gm)
gf_rhs_Gm.Set(0.0)
And this works fine in 2-D. However, when my mesh is 3-D cube (with boundary labeled "Gamma") I get an error when I run:
gf_rhs_Gm.Set(0.0)
The error is:
netgen.libngpy._meshing.NgException: cannot evaluate facet-fe inside element, add trans simd
What does this mean?
fes_rhs_Gm = FacetFESpace(Om_mesh, order=0, definedon="", definedonbound="Gamma")
I then do this:
gf_rhs_Gm = GridFunction(fes_rhs_Gm)
gf_rhs_Gm.Set(0.0)
And this works fine in 2-D. However, when my mesh is 3-D cube (with boundary labeled "Gamma") I get an error when I run:
gf_rhs_Gm.Set(0.0)
The error is:
netgen.libngpy._meshing.NgException: cannot evaluate facet-fe inside element, add trans simd
What does this mean?
- walker_tr9
- Topic Author
- Offline
- Senior Member
Less
More
- Thank you received: 0
2 years 8 months ago #4233
by walker_tr9
Replied by walker_tr9 on topic Setting grid function on Facet Space in 3-D
Here is a minimal example:
import numpy as np
import netgen.gui
from ngsolve import *
#from netgen.geom2d import unit_square
from netgen.geom2d import SplineGeometry
from netgen.csg import unit_cube
from netgen.csg import CSGeometry
from netgen.csg import Pnt
from netgen.csg import OrthoBrick
# # make the mesh (this works)
# geo = SplineGeometry()
# geo.AddRectangle( (0,0), (1,1), bc = "Gamma")
# Om_mesh = Mesh(geo.GenerateMesh(maxh=1.0))
# for r in range(3):
# Om_mesh.Refine()
# Draw(Om_mesh)
# print(Om_mesh.GetBoundaries())
# make the mesh (this does not work!)
cube = OrthoBrick( Pnt(0,0,0), Pnt(1,1,1) ).bc("Gamma")
geo = CSGeometry()
geo.Add (cube)
Om_mesh = Mesh(geo.GenerateMesh(maxh=1.0))
for r in range(2):
Om_mesh.Refine()
Draw(Om_mesh)
print(Om_mesh.GetBoundaries())
# bdy space
fes_rhs_Gm = FacetFESpace(Om_mesh, order=0, definedon="", definedonbound="Gamma")
print(" ")
num_Gm_dofs = np.sum(fes_rhs_Gm.FreeDofs())
print("number of FreeDofs for fes_rhs_Gm: ", num_Gm_dofs)
print("fes_rhs_Gm FreeDof mask: ")
print(fes_rhs_Gm.FreeDofs())
gf_rhs_Gm = GridFunction(fes_rhs_Gm)
# init
gf_rhs_Gm.Set(0.0)
input("Press Enter to finish...")
import numpy as np
import netgen.gui
from ngsolve import *
#from netgen.geom2d import unit_square
from netgen.geom2d import SplineGeometry
from netgen.csg import unit_cube
from netgen.csg import CSGeometry
from netgen.csg import Pnt
from netgen.csg import OrthoBrick
# # make the mesh (this works)
# geo = SplineGeometry()
# geo.AddRectangle( (0,0), (1,1), bc = "Gamma")
# Om_mesh = Mesh(geo.GenerateMesh(maxh=1.0))
# for r in range(3):
# Om_mesh.Refine()
# Draw(Om_mesh)
# print(Om_mesh.GetBoundaries())
# make the mesh (this does not work!)
cube = OrthoBrick( Pnt(0,0,0), Pnt(1,1,1) ).bc("Gamma")
geo = CSGeometry()
geo.Add (cube)
Om_mesh = Mesh(geo.GenerateMesh(maxh=1.0))
for r in range(2):
Om_mesh.Refine()
Draw(Om_mesh)
print(Om_mesh.GetBoundaries())
# bdy space
fes_rhs_Gm = FacetFESpace(Om_mesh, order=0, definedon="", definedonbound="Gamma")
print(" ")
num_Gm_dofs = np.sum(fes_rhs_Gm.FreeDofs())
print("number of FreeDofs for fes_rhs_Gm: ", num_Gm_dofs)
print("fes_rhs_Gm FreeDof mask: ")
print(fes_rhs_Gm.FreeDofs())
gf_rhs_Gm = GridFunction(fes_rhs_Gm)
# init
gf_rhs_Gm.Set(0.0)
input("Press Enter to finish...")
2 years 8 months ago #4234
by joachim
Replied by joachim on topic Setting grid function on Facet Space in 3-D
using
gf.Set (x, dual=True)
works. The default is to use element-wise L2-projection followed by averaging. This does not work for facet-spaces. dual=True does the projection using degrees of freedom of the finite element, which are usually moments on edges, faces and cells.
gf.Set (x, dual=True)
works. The default is to use element-wise L2-projection followed by averaging. This does not work for facet-spaces. dual=True does the projection using degrees of freedom of the finite element, which are usually moments on edges, faces and cells.
- walker_tr9
- Topic Author
- Offline
- Senior Member
Less
More
- Thank you received: 0
2 years 8 months ago #4235
by walker_tr9
Replied by walker_tr9 on topic Setting grid function on Facet Space in 3-D
Thanks for this. But why did it work in 2-D without that extra flag?
Time to create page: 0.106 seconds