Course PrePost Processing Notebook

This is a Jupyter notebook for the Course PrePost Processing project.

1. Introduction

You write your notebook in AsciiDoc including LaTeX math and thanks to the :page-jupyter: true attribute, the notebook is converted to a Jupyter notebook when the book is built.

To run the notebook in VScode:

  • create a python virtual env

  • install the required packages from 'requirements.tx'

  • start vscode within this python virtual env

  • select the kernel to use: use the previously created virtual env

To run the notebook, you can also use this docker image

To run the notebook in an already install jupyter

2. Code cells

You can include code cells in your notebook using the [source,python] block macro.

import sys, os
print("Hello, world!")
Results
Hello, world!

3. Mesh

You can check that pyvista package is running as expected:

import pyvista as pv
# uncomment the next line, if you don't have a nvidia graphic card
# pv.start_xvfb()
mesh = pv.Plane().triangulate()
submesh = mesh.subdivide(2, 'linear')
submesh.plot(show_edges=True)

4. Feel++ Code cells

You can include Feel++ code cells in your notebook using the [source,python] block macro.

import feelpp.core as fppc
app = fppc.Environment(["myapp"],config=fppc.globalRepository("myapp"))

geo=fppc.download( "github:{repo:feelpp,path:feelpp/quickstart/laplacian/cases/feelpp2d/feelpp2d.geo}", worldComm=app.worldCommPtr() )[0]
print("geo file: {}".format(geo))
mesh = fppc.load(fppc.mesh(dim=2,realdim=2), geo, 0.1)

Xh=fppc.functionSpace(mesh=mesh, space="Pchv")
f = Xh.element()
f.on(range=fppc.elements(mesh),expr=fppc.expr("{sin(pi*x)*sin(pi*y),cos(pi*x)*cos(pi*y)}:x:y",row=2,col=1))
e= fppc.exporter(mesh=mesh)
e.add("f",f)
e.save()
Results
geo file: /data/prudhomm/feelppdb/myapp/downloads/feelpp2d.geo

You can then visualize the result using the pyvista package as follows:

import pyvista as pv
# pv.start_xvfb()
reader = pv.get_reader("exports/ensightgold/Exporter/Exporter.case")
mesh = reader.read()
mesh.plot(scalars="f",show_edges=True)