Dear Firedrakers, When taking a Firedrake (functional/form) derivative, say the derivative of the functional int (du/dx)^2 dx (plus some bc's) is the outcome the functional derivative (i) with or (ii) without integration by parts? I.e. is it: (ii) 2 int du/dx dv/dx dx or (i) -2 int d^2u/d x^2 v dx, modulo bc's, and with v = delta u? https://www.firedrakeproject.org/firedrake.html#firedrake.ufl_expr.derivativ... (I am trying to understand why the below would work, and it does, with CG1 for X, or in the above with CG1 for v and u, which only can work when no ibp is done. ) Kind regards, Onno PS: # Kinematics # Right Cauchy-Green tensor if self.nonlin: d = self.X.geometric_dimension() I = fd.Identity(d) # Identity tensor F = I + fd.grad(self.X) # Deformation gradient C = F.T*F E = (C-I)/2. # Green-Lagrangian strain # E = 1./2.*( fd.grad(self.X).T + fd.grad(self.X) + fd.grad(self.X).T * fd.grad(self.X) ) # alternative equivalent definition else: E = 1./2.*( fd.grad(self.X).T + fd.grad(self.X) ) # linear strain self.W = (self.lam/2.)*(fd.tr(E))**2 + self.mu*fd.tr( E*E ) # f = fd.Constant((0, 0, -self.g)) # body force / rho # T = self.surface_force() # Total potential energy Pi = self.W * fd.dx # Compute first variation of Pi (directional derivative about X in the direction of v) F_expr = fd.derivative(Pi, self.X, self.v)
Hi Onno, It is the element-wise derivative ie the usual derivative when restricted to each element. So if the FE space is continuous, that’s the usual global weak derivative. all the best cjc On 26 Jan 2020, at 10:32, Onno Bokhove <O.Bokhove@leeds.ac.uk> wrote:  Dear Firedrakers, When taking a Firedrake (functional/form) derivative, say the derivative of the functional int (du/dx)^2 dx (plus some bc's) is the outcome the functional derivative (i) with or (ii) without integration by parts? I.e. is it: (ii) 2 int du/dx dv/dx dx or (i) -2 int d^2u/d x^2 v dx, modulo bc's, and with v = delta u? https://www.firedrakeproject.org/firedrake.html#firedrake.ufl_expr.derivativ... (I am trying to understand why the below would work, and it does, with CG1 for X, or in the above with CG1 for v and u, which only can work when no ibp is done. ) Kind regards, Onno PS: # Kinematics # Right Cauchy-Green tensor if self.nonlin: d = self.X.geometric_dimension() I = fd.Identity(d) # Identity tensor F = I + fd.grad(self.X) # Deformation gradient C = F.T*F E = (C-I)/2. # Green-Lagrangian strain # E = 1./2.*( fd.grad(self.X).T + fd.grad(self.X) + fd.grad(self.X).T * fd.grad(self.X) ) # alternative equivalent definition else: E = 1./2.*( fd.grad(self.X).T + fd.grad(self.X) ) # linear strain self.W = (self.lam/2.)*(fd.tr(E))**2 + self.mu*fd.tr( E*E ) # f = fd.Constant((0, 0, -self.g)) # body force / rho # T = self.surface_force() # Total potential energy Pi = self.W * fd.dx # Compute first variation of Pi (directional derivative about X in the direction of v) F_expr = fd.derivative(Pi, self.X, self.v) _______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
So then, it is (ii) below, the one option without integration by parts. (ii) 2 int du/dx dv/dx dx Which is the reason why it worked. It may be useful to add the word "weak" in the description of "derivative", and also maybe my silly example, for clarity? I deduced it from the outcome but missed it (somehow) in the description? I am lecturing next week so I am seeking clarity, anticipating the possible questions, and hope to promote Firedrake. Thank you. --Onno ________________________________ From: Cotter, Colin J <colin.cotter@imperial.ac.uk> Sent: Sunday, January 26, 2020 10:48 AM To: Onno Bokhove <O.Bokhove@leeds.ac.uk> Cc: firedrake <firedrake@imperial.ac.uk> Subject: Re: [firedrake] fd.derivative Hi Onno, It is the element-wise derivative ie the usual derivative when restricted to each element. So if the FE space is continuous, that’s the usual global weak derivative. all the best cjc On 26 Jan 2020, at 10:32, Onno Bokhove <O.Bokhove@leeds.ac.uk> wrote:  Dear Firedrakers, When taking a Firedrake (functional/form) derivative, say the derivative of the functional int (du/dx)^2 dx (plus some bc's) is the outcome the functional derivative (i) with or (ii) without integration by parts? I.e. is it: (ii) 2 int du/dx dv/dx dx or (i) -2 int d^2u/d x^2 v dx, modulo bc's, and with v = delta u? https://www.firedrakeproject.org/firedrake.html#firedrake.ufl_expr.derivativ... (I am trying to understand why the below would work, and it does, with CG1 for X, or in the above with CG1 for v and u, which only can work when no ibp is done. ) Kind regards, Onno PS: # Kinematics # Right Cauchy-Green tensor if self.nonlin: d = self.X.geometric_dimension() I = fd.Identity(d) # Identity tensor F = I + fd.grad(self.X) # Deformation gradient C = F.T*F E = (C-I)/2. # Green-Lagrangian strain # E = 1./2.*( fd.grad(self.X).T + fd.grad(self.X) + fd.grad(self.X).T * fd.grad(self.X) ) # alternative equivalent definition else: E = 1./2.*( fd.grad(self.X).T + fd.grad(self.X) ) # linear strain self.W = (self.lam/2.)*(fd.tr(E))**2 + self.mu*fd.tr( E*E ) # f = fd.Constant((0, 0, -self.g)) # body force / rho # T = self.surface_force() # Total potential energy Pi = self.W * fd.dx # Compute first variation of Pi (directional derivative about X in the direction of v) F_expr = fd.derivative(Pi, self.X, self.v) _______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
Hi Onno, I’m sorry, I completely misread your question, so my answer was wrong (but your conclusion correct). If you have a functional F[v]:V -> R then the functional derivative wrt v is a linear form F[v, :] satisfying dF[v; dv] = lim(e->0) (F[v+e*dv]-F[v])/e This is a linear form ie has one slot for the test function. Setting it to zero implies a nonlinear system for v which can be passed to solve(). all the best cjc On 26 Jan 2020, at 10:59, Onno Bokhove <O.Bokhove@leeds.ac.uk> wrote:  So then, it is (ii) below, the one option without integration by parts. (ii) 2 int du/dx dv/dx dx Which is the reason why it worked. It may be useful to add the word "weak" in the description of "derivative", and also maybe my silly example, for clarity? I deduced it from the outcome but missed it (somehow) in the description? I am lecturing next week so I am seeking clarity, anticipating the possible questions, and hope to promote Firedrake. Thank you. --Onno ________________________________ From: Cotter, Colin J <colin.cotter@imperial.ac.uk> Sent: Sunday, January 26, 2020 10:48 AM To: Onno Bokhove <O.Bokhove@leeds.ac.uk> Cc: firedrake <firedrake@imperial.ac.uk> Subject: Re: [firedrake] fd.derivative Hi Onno, It is the element-wise derivative ie the usual derivative when restricted to each element. So if the FE space is continuous, that’s the usual global weak derivative. all the best cjc On 26 Jan 2020, at 10:32, Onno Bokhove <O.Bokhove@leeds.ac.uk> wrote:  Dear Firedrakers, When taking a Firedrake (functional/form) derivative, say the derivative of the functional int (du/dx)^2 dx (plus some bc's) is the outcome the functional derivative (i) with or (ii) without integration by parts? I.e. is it: (ii) 2 int du/dx dv/dx dx or (i) -2 int d^2u/d x^2 v dx, modulo bc's, and with v = delta u? https://www.firedrakeproject.org/firedrake.html#firedrake.ufl_expr.derivativ... (I am trying to understand why the below would work, and it does, with CG1 for X, or in the above with CG1 for v and u, which only can work when no ibp is done. ) Kind regards, Onno PS: # Kinematics # Right Cauchy-Green tensor if self.nonlin: d = self.X.geometric_dimension() I = fd.Identity(d) # Identity tensor F = I + fd.grad(self.X) # Deformation gradient C = F.T*F E = (C-I)/2. # Green-Lagrangian strain # E = 1./2.*( fd.grad(self.X).T + fd.grad(self.X) + fd.grad(self.X).T * fd.grad(self.X) ) # alternative equivalent definition else: E = 1./2.*( fd.grad(self.X).T + fd.grad(self.X) ) # linear strain self.W = (self.lam/2.)*(fd.tr(E))**2 + self.mu*fd.tr( E*E ) # f = fd.Constant((0, 0, -self.g)) # body force / rho # T = self.surface_force() # Total potential energy Pi = self.W * fd.dx # Compute first variation of Pi (directional derivative about X in the direction of v) F_expr = fd.derivative(Pi, self.X, self.v) _______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
Dear Firedrakers, Some queries: (a1) I have been updating one of the tutorials by adapting the python script of the BL-demo; how can I test its page, and where do I submit it as candidate update? (a2) In essence I updated the demo so that it has reduced output and reproduces the Figure 3 test of an associated publication, which figure I included as target for reproduction by any user, because then the user would know whether the outcome is right; also adding a small python script to visualise the energy (lower panel of Figure 3 attached). Since Figure 3a and 3b contain line plots at multiple times: rather than using an animation in Paraview: how can one with "Plot over line" keep multiple line plots at different time levels in one plot (since this would literally reproduce Figure 3a and 3b)? Also the old demo had some old expired links which I fixed. (b) Finally: with h_n0 = Function(V) on a 2D mesh, how can I find the maximum value on the mesh? This is in preparation for a potential flow test with a nonlinear, 8.4-fold amplification. I now use/added: ... from firedrake.petsc import PETS ... with h_n0.dat.vec_ro as hh: L_inf_err = hh.max()[1] ... but that seems a bit overkill? MPI next!?! Thank you and kind regards, Onno
participants (2)
- 
                
                Cotter, Colin J
- 
                
                Onno Bokhove