getfem-users
[Top][All Lists]
Advanced

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

## Re: [Getfem-users] Re-assemble one brick in a model

 From: Yves Renard Subject: Re: [Getfem-users] Re-assemble one brick in a model Date: Sun, 20 Dec 2015 13:05:41 +0100 (CET)

```Dear Magnus,

Getfem model terms are not re-assembled if you make multiple solves and if the
data they depend on do not change.

So, in you case, you can perform between two solve a

md.set_variable('WF', NewWF)

Where NewWF is your new vector of values for the data WF.
Then the Helmholtz brick will not be re-assembled. Only the right hand side
will be.

However, of course, the linear system will be solved at each solve. There is no
option for the moment to perform say a LU decomposition only once and apply
several second hand. If you ant to perform this, you have to mak a specific
solve by yourself (you can extract the assembled matrix and righ hand side).

Best regards,

Yves.

----- Mail original -----
De: "Magnus Paulsson" <address@hidden>
À: "getfem-users" <address@hidden>
Envoyé: Vendredi 18 Décembre 2015 16:56:46
Objet: [Getfem-users] Re-assemble one brick in a model

I’m using the python interface to solve a Helmholtz problem and want to repeat
the solution for many different values of the Dirichlet boundary conditions.
The question is: Can I use the model framework and only re-assemble the part
that I want to change without assembling the full problem?
(Or do I have to assemble the parts myself ...)

As I do it today I repeat the following where the “mfWF” variable is updated
and assembles the full problem for each value of the boundary conditions:

################################################
import numpy as N

md = GF.Model('complex')

# Helmholtz brick
md.add_fem_variable('psi', mf)
md.add_initialized_fem_data('sqrtpot', mf, N.sqrt(-mfPot.astype(N.complex)))
md.add_Helmholtz_brick(mim,'psi','sqrtpot')
# Zero boundary
md.add_initialized_data('zerov', 0)
md.add_Dirichlet_condition_with_multipliers(mim,'psi',mf,[zeroSide],'zerov')

# Wavefunction boundary
md.add_initialized_fem_data('WF', mf, mfWF)
md.add_Dirichlet_condition_with_multipliers(mim, 'psi', mf, [wfSide], 'WF')

# Periodic boundary conditions
numPBC = pbcMat.size()[0]
md.add_variable('mult', numPBC)
md.add_constraint_with_multipliers('psi', 'mult', pbcMat,
N.zeros(numPBC,N.complex))

md.solve()
################################################

What I would like to do is to replace the md.solve() line with:
for ii in mfWFs:
md.add_initialized_fem_data('WF', mf, ii)
md.solve()

Is this possible (from the documentation I kind of guess that the
enable_bricks, disable_bricks etc are there for this kind of purpose but it’s
not clear).
Finally, thank you for the GetFEM software. Awesome.

-----------------------------------------------
Magnus Paulsson
Associate Professor
Dept. of Physics and Electrical Engineering
Linnaeus University
Phone: +46-480-446308
Mobile: +46-70-6942987

_______________________________________________
Getfem-users mailing list
address@hidden
https://mail.gna.org/listinfo/getfem-users

```

reply via email to

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