Hello folks, I have a scalar field in 2D, $w$, say: V = FunctionSpace(mesh, "CG", 1) w = Function(V) w.interpolate(Expression("1")) and I need too find an norm of grad(w) in every point of the given area, i.e. get a scalar field back. I've found no way to iterate through individual elements of grad(w) to be able to do in manually, neither abs(grad(w)) or something similar works. Any ideas? Do I need to solve some variational problem for this, too? Sincerely, George
On 18/11/15 15:42, George Ovchinnikov wrote:
Hello folks,
I have a scalar field in 2D, $w$, say:
V = FunctionSpace(mesh, "CG", 1) w = Function(V) w.interpolate(Expression("1"))
and I need too find an norm of grad(w) in every point of the given area, i.e. get a scalar field back.
I've found no way to iterate through individual elements of grad(w) to be able to do in manually, neither abs(grad(w)) or something similar works. Any ideas? Do I need to solve some variational problem for this, too?
You can't do this pointwise because the strong gradient doesn't exist. What do you later want to use this for. If you need |grad(w)| in a form, you can just write it in directly. When you say norm grad(w), do you mean: sqrt(dot(grad(w), grad(w))) ? Lawrence
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Lawrence,
sqrt(dot(grad(w), grad(w)))
Yes, this is exactly what I meant. I needed to use in Tikhonov regularization in method which I'm working with. I'm updating on every step w based on the rule H(w) - \alpha |\grad(w)|, where H(w) is basic updating rule, and |\grad(w)| is a penalty for local non-smoothness. - --George On 18.11.2015 19:21, Lawrence Mitchell wrote:
On 18/11/15 15:42, George Ovchinnikov wrote:
Hello folks,
I have a scalar field in 2D, $w$, say:
V = FunctionSpace(mesh, "CG", 1) w = Function(V) w.interpolate(Expression("1"))
and I need too find an norm of grad(w) in every point of the given area, i.e. get a scalar field back.
I've found no way to iterate through individual elements of grad(w) to be able to do in manually, neither abs(grad(w)) or something similar works. Any ideas? Do I need to solve some variational problem for this, too?
You can't do this pointwise because the strong gradient doesn't exist.
What do you later want to use this for. If you need |grad(w)| in a form, you can just write it in directly. When you say norm grad(w), do you mean:
sqrt(dot(grad(w), grad(w))) ?
Lawrence
_______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWTPD7AAoJEAmjzQNAL1ujqhsP/0eA5bc/dZmV5otSGuKOUG2b C42OIoGjKMwyDev8V9Hb3pGU4AHS3A4Si1LWkqCc7ZyTpTf1Xx3Cg+CH/JASwxT3 NFGQ5OitPEZD0LjNq+cZ78pX6sQ2SrVzTD1rcv8LFTKBH3a2Om5Ytzo26SL+wL7h KGQ9UDCICJqhm4t294QARyoISMfLDvwvyXh9e97bNJl2+1n/OqS1xBcceYnIOn6W F2EjebF5yG1vfVt7mABP0vdO/cquqVdhyilLgUzzg8eI9QZIDjXo2WGT1t28aSDp 2ypuk4Ew4/Cpb0h4LT/sVvepL1ZezabwwThYKftZEdivvaDWMJh9kNue9HIyna2J 7sXatCjZKnMtCJl6WUOsC8bgFIA0oALJLN2S6cGxmILmAARwHimiIp5EbIlqIvTF zfW7/gvKcRDeiuVPMo7Qataw5m8b30Q5eHVUNzPuhytZfA7lPI3YjV5EXcNFO0OI lCjka/aOYHsNrXpcT7G0mCk9GcYsPPLee+vwIl/qj+h9U6AJFOq5iNYlH2AH+vO4 2TumrEf34p2Y74o0GRoYRD3qg9RjuD51vJCTGT4ipDwf+LG0gmv2xd1ItAw5pz5+ wAlsN6I7l+67P9Iq2zOn9k/d85oVm0JSP5jhxJcJUlbKPTKjOAzj3RmhIcyKmHKH Z760tpuaoSohR01q+KRl =aUqy -----END PGP SIGNATURE-----
On 18/11/15 21:43, George Ovchinnikov wrote:
Hi Lawrence,
sqrt(dot(grad(w), grad(w)))
Yes, this is exactly what I meant. I needed to use in Tikhonov regularization in method which I'm working with. I'm updating on every step w based on the rule H(w) - \alpha |\grad(w)|,
where H(w) is basic updating rule, and |\grad(w)| is a penalty for local non-smoothness.
So if w is a Function, you can just add the term alpha * sqrt(dot(grad(w), grad(w))) to your residual and things should work. If you really need it in a different function space you'll have to solve an equation for the mass matrix (to L2 project it into the space). Lawrence
Hi Lawrence, I have an equation g(u, w) = f. I need to set w, to minimize certain functional F(u,f). I'm using greedy approach. By means of firedrake I got sensitivity vector of given functional (i.e. how F changes with respect to change of w at position of i-th basis function). Then I "cut" (i.e. set to small, non zero value) w corresponding the smallest values in sensitivity vector. This approach is unstable w.r.t to mesh size and has other problems. The idea is to use Tikhonov regularization, that is to "cut" w corresponding the smallest values in sensitivity vector - \alpha \|grad(w)| For this I need point-wise access to grad(w). Hopefully this is clear enough description as I tried to make it brief. --George On 18.11.2015 19:21, Lawrence Mitchell wrote:
On 18/11/15 15:42, George Ovchinnikov wrote:
Hello folks,
I have a scalar field in 2D, $w$, say:
V = FunctionSpace(mesh, "CG", 1) w = Function(V) w.interpolate(Expression("1"))
and I need too find an norm of grad(w) in every point of the given area, i.e. get a scalar field back.
I've found no way to iterate through individual elements of grad(w) to be able to do in manually, neither abs(grad(w)) or something similar works. Any ideas? Do I need to solve some variational problem for this, too?
You can't do this pointwise because the strong gradient doesn't exist.
What do you later want to use this for. If you need |grad(w)| in a form, you can just write it in directly. When you say norm grad(w), do you mean:
sqrt(dot(grad(w), grad(w))) ?
Lawrence
_______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
participants (2)
- 
                
                George Ovchinnikov
- 
                
                Lawrence Mitchell