Manipulating functions and function spaces

We start with setting the Feel++ environment and loading the Feel++ library. We download a 2D and 3D geometry from the Feel++ github repository.

import feelpp
import sys

app=feelppEnvironment(["myapp"],config=localRepository(""))

from pyfeelpp import mesh,discr,vf
geo={
    '2':feelpp.download( "github:{repo:feelpp,path:feelpp/quickstart/laplacian/cases/feelpp2d/feelpp2d.geo}", worldComm=app.worldCommPtr() )[0],
    '3':feelpp.download( "github:{repo:feelpp,path:feelpp/quickstart/laplacian/cases/feelpp3d/feelpp3d.geo}", worldComm=app.worldCommPtr() )[0]
}
print(" . 2D geometry file: {}".format(geo['2']))
print(" . 3D geometry file: {}".format(geo['3']))
Results
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
File :1
----> 1 import feelpp
      2 import sys
      4 app=feelppEnvironment(["myapp"],config=localRepository(""))

ModuleNotFoundError: No module named 'feelpp'

1. Notations

The domain \(\Omega\) is discretized using a mesh of triangles or tetrahedra. Scalar functions \(f \Omega \rightarrow \mathbb{R}\) are defined on the mesh and are represented by a finite element space.

2. Scalar function spaces

2D mesh and function space example
def run( m, geo ):
    m2d = feelpp.load(m,geo,0.1)
    Xh=feelpp.functionSpace(mesh=m2d)

    if app.isMasterRank():
        print("Xh basisname: ", Xh.basisName())
        print("Xh nDof: ", Xh.nDof())
        print("Xh nLocalDof: ", Xh.nLocalDof())
        print("Xh nLocalDofWithGhost: ", Xh.nLocalDofWithGhost())
        print("Xh nLocalDofWithoutGhost: ", Xh.nLocalDofWithoutGhost())

    m3=Xh.mesh()

    assert m3==m2d

    u=Xh.element()
    u.on(range=feelpp.elements(m2d),expr=feelpp.expr("x:x"))

    assert u.functionSpace() == Xh
    assert u.size() == Xh.nDof()

run( feelpp.mesh(dim=2), geo['2'] )
Results
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
File :22
     19     assert u.functionSpace() == Xh
     20     assert u.size() == Xh.nDof()
---> 22 run( feelpp.mesh(dim=2), geo['2'] )

NameError: name 'feelpp' is not defined

Finally, we can do the same in 3D

3D mesh and function space example
run( feelpp.mesh(dim=3,realdim=3), geo['3'] )
Results
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
File :1
----> 1 run( feelpp.mesh(dim=3,realdim=3), geo['3'] )

NameError: name 'feelpp' is not defined