Setting grid function on Facet Space in 3-D

More
2 years 8 months ago #4232 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?
 
More
2 years 8 months ago #4233 by walker_tr9
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...")
 
More
2 years 8 months ago #4234 by joachim
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.

 
More
2 years 8 months ago #4235 by walker_tr9
Thanks for this.  But why did it work in 2-D without that extra flag?
Time to create page: 0.106 seconds