Square Root Estimator Aposteriori Residual Based

Hi everyone.

I am doing adaptivity to a problem using Aposteriori Residual Based, but I don’t know how can I take square root to an estimator. I show my code

W = FunctionSpace(mesh, "DG", 0)
    w = TestFunction(W)
    he = FacetArea(mesh)
  
    RK =  gamma*(p+1)*f-kappa*u+grad(p)   #Residual Elemento
    Eta = (1.0/kappa)*w*inner(RK,RK)*dx + kappa*w*div(u)*div(u)*dx + (1.0/kappa)*(1/he)*w*p*p*ds(1) 

    Estimador = assemble(Eta)
    Eta = sqrt(sum(Estimador))
    #
    # OJO: Falta sacarle raiz cuadrada a cada comoponente del Estimador!!
    #
    
    Eta_max = max(Estimador)
   #
   # ********* Error estimation and mesh adaptivity ******** #
    theta = 0.5; tolAdapt  = 1.0E-3;

    if (Eta < tolAdapt and iterAdapt==adaptSteps):
        print("\nEstimated error < tolerance: %s < %s" % (Eta,
                                                          tolAdapt))
        break

    #Mark cells for refinement based on maximal marking strategy
    cell_markers = MeshFunction('bool', mesh, mesh.topology().dim())
    cell_markers.set_all(False)
    for c in cells ( mesh ):
        if( Estimador[c.index()] > (theta * Eta_max)):
           cell_markers[c] = True

I need use the square root of the Estimator = assemble(Eta). Is it possible get that?

Greetings

Do you mean taking the elementwise square root of the assembled vector? This could be done like this:

for m in range(len(Estimador[:])):
    Estimador[m] = sqrt(Estimador[m])

Thank you very much!!!