[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fast computation of a quantity

From: Konstantinos Poulios
Subject: Re: Fast computation of a quantity
Date: Fri, 30 Sep 2022 11:16:38 +0200

ok, what you are doing is equivalent to

grad_norm = gf.asm_generic(self.IM, 1, "(2+2*p)*sign(u)*pow(abs(u), 1+2*p)*Test_phi", -1, md)

This is the definition of assembling a residual vector, assembling the product with each basis function.


On Fri, Sep 30, 2022 at 10:01 AM Eloi Martinet <> wrote:
Here is what I do currently :

md = gf.Model("real")
md.add_fem_variable("u", self.V)  
md.add_fem_variable("phi", self.V) # Represents a basis function
md.add_data("p", 1)
md.set_variable("p", p)
md.set_variable("u", u)

grad_norm = np.zeros(nbdof_V)

for i in tqdm(range(nbdof_V)):
            phi = np.zeros(self.nbdof_V)
            phi[i] = 1
  "phi", phi)

            grad_norm[i] = (2+2*p)*gf.asm_generic(self.IM, 0, "sign(u)*pow(abs(u), 1+2*p)*phi", -1, md)

Sorry I should have included this snippet from the beginning.
Have a great day.

Le jeu. 29 sept. 2022 à 21:39, Konstantinos Poulios <> a écrit :
Hello, would you like to send us a naive implementation of your assembly with asm_generic (and a loop) to take it from there?


On Thu, Sep 29, 2022 at 6:27 PM Eloi Martinet <> wrote:
Hello everyone,
My problem is the following : I have a FE space V with basis phi_i. Let u be a function on V and f a real valued function. What is the quickest way to compute the vector (\int f(u)*phi_i)_i ? I would like to use asm_generic but I don't see how to do it without looping on i and computing it for all i, which is way too long.

Thank you, have a good day.
Best regards,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]