Initializing Feel++

The core module provides the basic data structures to

  • setup and run Feel++ application in a parallel environment.

  • handle the command line options

  • download and upload data from and to GitHub and/or Girder

1. Setting up the Feel++ Environment

To set Feel++ environment, we create an environment and set the associated repository for the results. A Feel++ environment can be created only once. The repository can be global with respect to $HOME/.feelppconfig globalroot setting or local with respect to the current directory.

Set the Feel++ environment with local repository
import feelpp as fpp
import sys
app = fpp.Environment(["myapp"],config=fpp.localRepository(""))
Results
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
File :1
----> 1 import feelpp as fpp
      2 import sys
      3 app = fpp.Environment(["myapp"],config=fpp.localRepository(""))

ModuleNotFoundError: No module named 'feelpp'
Query the app about the current environment
print("pid:",app.worldComm().localRank() )
print("isMasterRank:",app.isMasterRank() )
print("is parallel: ",app.isParallel() )
Results
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
File :1
----> 1 print("pid:",app.worldComm().localRank() )
      2 print("isMasterRank:",app.isMasterRank() )
      3 print("is parallel: ",app.isParallel() )

NameError: name 'app' is not defined

2. Downloading data

Feel++ can query data on GitHub and Girder.

readme=fpp.download( "github:{repo:feelpp,path:README.adoc}", worldComm=app.worldCommPtr() )[0]

print("downloaded Feel++ README.adoc from Github: ",readme)
Results
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
File :1
----> 1 readme=fpp.download( "github:{repo:feelpp,path:README.adoc}", worldComm=app.worldCommPtr() )[0]
      3 print("downloaded Feel++ README.adoc from Github: ",readme)

NameError: name 'fpp' is not defined

The code will get the file README.adoc from the toplevel Feel++ github directory downloaded

A bit more interesting example: the following code will download a csv file from the Feel++ github repository and plot the data using the plotly library.

acsv=fpp.download( "github:{repo:feelpp,path:toolboxes/fluid/cases/moving_body/gravity/cylinder_under_gravity/curve_comparison.csv}", worldComm=app.worldCommPtr() )[0] (1)
import pandas as pd (2)
df = pd.read_csv(acsv, sep=",") (3)
df.columns = df.columns.str.replace(' ', '')
print(df.head())
Results
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
File :1
----> 1 acsv=fpp.download( "github:{repo:feelpp,path:toolboxes/fluid/cases/moving_body/gravity/cylinder_under_gravity/curve_comparison.csv}", worldComm=app.worldCommPtr() )[0]
      2 import pandas as pd
      3 df = pd.read_csv(acsv, sep=",")

NameError: name 'fpp' is not defined
1 download the file curve_comparison.csv from the Feel++ github repository toolboxes/fluid/cases/moving_body/gravity/cylinder_under_gravity/curve_comparison.csv
2 use the pandas library to read the csv file
3 read the csv file and remove the spaces in the column names

We can now use plotly to plot the data

import plotly.express as px
fig = px.scatter(df,x="TIME", y="Y_CM", title="y-displacement of the center of mass(CM) of the cylinder",labels={"TIME":"t (s)","Y_CM":r'y-displacement (m)'})
fig.show()
Results
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) File :1 ----> 1 import plotly.express as px 2 fig = px.scatter(df,x="TIME", y="Y_CM", title="y-displacement of the center of mass(CM) of the cylinder",labels={"TIME":"t (s)","Y_CM":r'y-displacement (m)'}) 3 import sys File ~/python3.8/lib/python3.8/site-packages/plotly/express/__init__.py:10 8 pd = optional_imports.get_module("pandas") 9 if pd is None: ---> 10 raise ImportError( 11 """\ 12 Plotly express requires pandas to be installed.""" 13 ) 15 from ._imshow import imshow 16 from ._chart_types import ( # noqa: F401 17 scatter, 18 scatter_3d, (...) 51 density_mapbox, 52 ) ImportError: Plotly express requires pandas to be installed.