Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Behaviour of TensorProductFESpace

More
4 years 6 months ago - 4 years 6 months ago #1956 by JanWesterdiep
Hello!

I am building a spacetime formulation of the heat equation, on a tensor product "prism"-like mesh (simplices in space, intervals in time). For now, I am focussing on 1+1 and 1+2 dimensions.

I found some (mostly undocumented) files regarding tensor product meshes and -FEspaces in the directory "ngsolve/py_tutorials/TensorProduct". However, whenever I try to use these objects, I get very unexpected behaviour.

First example, where the mesh on Y is just 1-dimensional (as opposed to 1+2-dimensional as I was hoping) and the matrix A contains far less nonzero entries than what I had expected:
Code:
from ngsolve import Mesh, x, y, GridFunction, H1 from netgen.geom2d import unit_square from ngsolve.TensorProductTools import * from ngsolve.comp import * import scipy.sparse as sp time_mesh = Mesh(SegMesh(20, 0, 1)) space_mesh = Mesh(unit_square.GenerateMesh(maxh=0.1)) Y = TensorProductFESpace([L2(time_mesh), H1(space_mesh)]) A = BilinearForm(Y) u, v = Y.TnT() A += u * v * dx A.Assemble() Amat = sp.csr_matrix(A.mat.CSR()) print(Amat.nnz) print(Y.mesh.dim) Draw(Y.mesh)

Secondly, when I create a compound FESpace from these TensorProductFESpace's (or even just *one*), I get segfaults:
Code:
from ngsolve import Mesh, x, y, GridFunction, H1 from netgen.geom2d import unit_square from ngsolve.TensorProductTools import * from ngsolve.comp import * import scipy.sparse as sp time_mesh = Mesh(SegMesh(20, 0, 1)) space_mesh = Mesh(unit_square.GenerateMesh(maxh=0.1)) Y = TensorProductFESpace([L2(time_mesh), H1(space_mesh)]) compound_fes = FESpace([Y]) A = BilinearForm(Y) u, v = Y.TnT() A += u * v * dx A.Assemble()

Lastly, when I use this compound FESpace "as intended", I get an error indicating "not implemented":
Code:
from ngsolve import Mesh, x, y, GridFunction, H1 from netgen.geom2d import unit_square from ngsolve.TensorProductTools import * from ngsolve.comp import * import scipy.sparse as sp time_mesh = Mesh(SegMesh(20, 0, 1)) space_mesh = Mesh(unit_square.GenerateMesh(maxh=0.1)) Y = TensorProductFESpace([L2(time_mesh), H1(space_mesh)]) compound_fes = FESpace([Y]) A = BilinearForm(compound_fes) (u, ), (v, ) = compound_fes.TnT() A += u * v * dx A.Assemble() $ netgen mwe.py <snip> catch in AssembleBilinearform 2: 4 not implemented Traceback (most recent call last): File "<string>", line 15, in <module> netgen.libngpy._meshing.NgException: 4 not implementedin Assemble BilinearForm 'biform_from_py'

Is there any way I can get around this, maybe by *not* using a TensorProductFESpace, but rather specifying the FESpace (L2 in the time-direction, H1 in the space-direction) on the tensorproduct mesh directly?
Last edit: 4 years 6 months ago by JanWesterdiep. Reason: Added another example of things going wrong
Time to create page: 0.149 seconds