Menu

How to manually set boudnary DOFs for H1 grid function

2017-03-30
2017-03-30
  • Guosheng Fu

    Guosheng Fu - 2017-03-30

    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

     
  • schruste

    schruste - 2017-03-30

    Hi Guosheng,

    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

     
    • Guosheng Fu

      Guosheng Fu - 2017-03-30

      Hi Christoph,

      Thanks!
      That's exactly what I want.

      Best,
      Guosheng

       

Anonymous
Anonymous

Add attachments
Cancel