I have a H1 gridfunction, say, obtained from interpolation from a DG solution, and would like to manually set the boundary dofs to 0. I don't know how to locate the global indexes of boundary dofs.
The finite element space have pure Dirichlet boundary conditions, and I need vanishing boundary dofs for my grid function, without modifying the internal dofs.
Thanks,
Guosheng
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If I understood you correctly you can do it this way:
for i,freedof in enumerate(V.FreeDofs()):
if not freedof:
u.vec[i] = 0.0
The FreeDofs() of an FESpace are all degrees of freedom which are not marked as Dirichlet-Dofs. So whereever you set Dirichlet-boundaries in the space, you will have V.FreeDofs(i) = False.
Alternatively you can loop over all boundary elements (this would be a solution which is independent of what the dirichlet-marking in the FESpace says) and set all boundary dofs to zero:
for el in V.Elements(BND):
for i in el.dofs:
u.vec[i] = 0.0
Best,
Christoph
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello again,
I have a H1 gridfunction, say, obtained from interpolation from a DG solution, and would like to manually set the boundary dofs to 0. I don't know how to locate the global indexes of boundary dofs.
The finite element space have pure Dirichlet boundary conditions, and I need vanishing boundary dofs for my grid function, without modifying the internal dofs.
Thanks,
Guosheng
Hi Guosheng,
If I understood you correctly you can do it this way:
The FreeDofs() of an FESpace are all degrees of freedom which are not marked as Dirichlet-Dofs. So whereever you set Dirichlet-boundaries in the space, you will have V.FreeDofs(i) = False.
Alternatively you can loop over all boundary elements (this would be a solution which is independent of what the dirichlet-marking in the FESpace says) and set all boundary dofs to zero:
Best,
Christoph
Hi Christoph,
Thanks!
That's exactly what I want.
Best,
Guosheng