getfem-users
[Top][All Lists]
Advanced

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

Re: [Getfem-users] gradient interpolation matrix


From: Konstantinos Poulios
Subject: Re: [Getfem-users] gradient interpolation matrix
Date: Fri, 17 Nov 2017 15:14:00 +0100

Dear Edouard,

You need a MeshImData object. You can define one for example with

mim = gf.MeshIm(mesh, integration_degree)

mimd1 = gf.MeshImData(mim, -1)
mimd4 = gf.MeshImData(mim, -1, [4])

where mimd1 stores one value per quadrature point, while mimd4 stores a vector of 4 values.

I use for example the following

md.set_variable("ksi0", md.interpolation(_ksi_, mimd1, -1))

to update the value of some data "ksi0" that where defined on quadrature points:

md.add_im_data("ksi0", mimd1)

If you are interested in one value per element you can define a MeshIm with only 1 quadrature point.

Best regards
Kostas



On Fri, Nov 17, 2017 at 2:37 PM, EDOUARD OUDET <address@hidden> wrote:
Still a variation on the same question. Following the documentation,

interpolation(expr, *args)

Synopsis: V = Model.interpolation(self, string expr, {MeshFem mf | MeshImd mimd | vec pts, Mesh m}[, int region[, int extrapolation[, int rg_source]]])


I tried interpolation on MeshImd:

#-------------------------------------------------------------------------------------
degp = 2; NX = 30
tmesh = gf.Mesh('regular_simplices', np.arange(0,1+1./NX,1./NX),
                                                           np.arange(0,1+1./NX,1./NX))
tmeshfem = gf.MeshFem(tmesh, 1)
tmeshfem.set_fem(gf.Fem('FEM_PK(2,' + str(degp) + ')'))
tmeshim = gf.MeshIm(tmesh, gf.Integ('IM_TRIANGLE(6)'))
U = np.random.rand(tmeshfem.nb_basic_dof())

md = gf.Model('real')
md.add_fem_variable('u', tmeshfem)
md.to_variables(U)
GU = md.interpolation('Grad_u', tmeshim)
#-------------------------------------------------------------------------------------

and get

Traceback (most recent call last):
  File "testinterpgetfem.py", line 21, in <module>
    GU = md.interpolation('Grad_u', tmeshim) #pts.T, tmeshi)
  File ".../Conda/deps/usr/lib/python2.7/site-packages/getfem/getfem.py", line 2800, in interpolation
    return self.get("interpolation", expr, *args)
  File ".../Conda/deps/usr/lib/python2.7/site-packages/getfem/getfem.py", line 2708, in get
    return getfem('model_get',self.id, *args)
RuntimeError: (Getfem::InterfaceError) -- Argument 4 should be a DOUBLE REAL data array

It is not the right way to call it perhaps..?
Sorry for the noise,
best regards, Edouard.



reply via email to

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