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.

BR
Kostas

On Fri, Sep 30, 2022 at 10:01 AM Eloi Martinet <eloi.marti...@gmail.com>
wrote:

> Hello,
> 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
>             self.md.set_variable("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.
> Best,
> Eloi.
>
> Le jeu. 29 sept. 2022 à 21:39, Konstantinos Poulios <
> logar...@googlemail.com> 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?
>>
>> BR
>> Kostas
>>
>> On Thu, Sep 29, 2022 at 6:27 PM Eloi Martinet <eloi.marti...@univ-smb.fr>
>> 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,
>>> Eloi.
>>>
>>

Reply via email to