Skip to content

Commit

Permalink
up pyfeelpp notebooks and up site for components order
Browse files Browse the repository at this point in the history
  • Loading branch information
prudhomm committed Aug 14, 2023
1 parent be5c97f commit f8dbab5
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 227 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ jupyter/
/.bundle
/**/node_modules/
/**/build/
/**/feelppdb/
14 changes: 6 additions & 8 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,24 @@
"component": [
"dev",
"mor",
"cases",
"user",
"toolboxes",
"tutorial-dev"
"feelpp-tutorial-dev"
],
"version": [

This comment has been minimized.

Copy link
@prudhomm

prudhomm Aug 14, 2023

Author Member

up #260

"latest",
"0.111",
"0.110",
"0.109",
"0.108",
"0.107"
"0.108"
]
}
},
{
"url": "https://docs.feelpp.org/(?P<component>.*?)/",
"variables": {
"component": [
"feelpp",
"contribute",
"data",
"math"
"feelpp-project", "data", "math", "contribute"

This comment has been minimized.

Copy link
@prudhomm

prudhomm Aug 14, 2023

Author Member

up #260

]
},
"selectors_key": "versionless"
Expand Down
38 changes: 3 additions & 35 deletions docs/user/modules/python/pages/pyfeelpp/discr.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include::user:ROOT:partial$header-macros.adoc[]
We start with setting the {feelpp} environment and loading the {feelpp} library.
We download a 2D and 3D geometry from the {feelpp} github repository.

[source,python]
[%dynamic,python]
----
import feelpp
import sys
Expand All @@ -21,14 +21,6 @@ print(" . 2D geometry file: {}".format(geo['2']))
print(" . 3D geometry file: {}".format(geo['3']))
----

[%collapsible.result]
====
----
. 2D geometry file: /scratch/jupyter/feelppdb/downloads/feelpp2d.geo
. 3D geometry file: /scratch/jupyter/feelppdb/downloads/feelpp3d.geo
----
====
== Notations

The domain stem:[\Omega] is discretized using a mesh of triangles or tetrahedra.
Expand All @@ -38,7 +30,7 @@ Scalar functions stem:[f \Omega \rightarrow \mathbb{R}] are defined on the mesh
== Scalar function spaces


[source,python]
[%dynamic,python]
.2D mesh and function space example
----
def run( m, geo ):
Expand All @@ -65,34 +57,10 @@ def run( m, geo ):
run( feelpp.mesh(dim=2), geo['2'] )
----

[%collapsible.result]
.Results
====
----
Xh basisname: lagrange
Xh nDof: 2867
Xh nLocalDof: 2867
Xh nLocalDofWithGhost: 2867
Xh nLocalDofWithoutGhost: 2867
----
====
Finally, we can do the same in 3D

[source,python]
[%dynamic,python]
.3D mesh and function space example
----
run( feelpp.mesh(dim=3,realdim=3), geo['3'] )
----
[%collapsible.result]
.Results
====
----
Xh basisname: lagrange
Xh nDof: 21739
Xh nLocalDof: 21739
Xh nLocalDofWithGhost: 21739
Xh nLocalDofWithoutGhost: 21739
----
====
15 changes: 4 additions & 11 deletions docs/user/modules/python/pages/pyfeelpp/integrals.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include::user:ROOT:partial$header-macros.adoc[]
We start with setting the {feelpp} environment and loading the {feelpp} library.

.Set the {feelpp} environment with local repository
[source,python]
[%dynamic,python]
----
import feelpp
import sys
Expand All @@ -23,7 +23,7 @@ The integral over each element is computed using a quadrature formula.
We first load a mesh
.Load a mesh stem:[\mathcal{T}]
[source,python]
[%dynamic,python]
----
geo=feelpp.download( "github:{repo:feelpp,path:feelpp/quickstart/laplacian/cases/feelpp2d/feelpp2d.geo}", worldComm=app.worldCommPtr() )[0]
print("geo file: {}".format(geo))
Expand All @@ -32,24 +32,17 @@ mesh = feelpp.load(feelpp.mesh(dim=2,realdim=2), geo, 0.1)

Then we can define functions stem:[f] and compute the integral of stem:[f] over the mesh stem:[\mathcal{T}].

[source,python]
.Compute integrals
[%dynamic,python]
----
from feelpp.integrate import integrate

i1 = integrate(range=feelpp.elements(mesh),expr="sin(x+y):x:y")
i2 = integrate(range=feelpp.boundaryfaces(mesh),expr="x*nx+y*ny+z*nz:x:y:z:nx:ny:nz")
i3 = integrate(range=feelpp.markedelements(mesh, "marker"), expr="1")
print("i1 = {}, i2 = {}, i3 = {}".format(i1,i2,i3))
----

[%collapsible.result]
.Results
====
----
i1 = [3.24282386], i2 = [149.465], i3 = [0.]
print(f"i1 = {i1}, i2 = {i2}, i3 = {i3}")
----
====

== Next steps

Expand Down
4 changes: 2 additions & 2 deletions docs/user/modules/python/pages/pyfeelpp/interpolator.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ include::user:ROOT:partial$header-macros.adoc[]

== Import the package

[source,python]
[%dynamic,python]
----
from feelpp.interpolation import *
----


== Create an interpolator

[source, python]
[%dynamic, python]
----
I = interpolator(_domain = <space domain>,
_image = <space domain>,
Expand Down
114 changes: 19 additions & 95 deletions docs/user/modules/python/pages/pyfeelpp/mesh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include::user:ROOT:partial$header-macros.adoc[]
We start with setting the {feelpp} environment and loading the {feelpp} library.

.Set the {feelpp} environment with local repository
[source,python]
[%dynamic,python]
----
import feelpp
import sys
Expand Down Expand Up @@ -34,54 +34,13 @@ Keyword arguments:


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

[%collapsible.result]
.Results
====
----
[ Starting Feel++ ] application myapp version 0.1 date 2022-Nov-07
. myapp files are stored in /scratch/jupyter/feelppdb/np_1
.. logfiles :/scratch/jupyter/feelppdb/np_1/logs
Output exceeds the size limit. Open the full output data in a text editor
geo file: /scratch/jupyter/feelppdb/downloads/feelpp2d.geo
[loadMesh] Loading mesh in format geo+msh: "/scratch/jupyter/feelppdb/downloads/feelpp2d.geo"
[loadMesh] Use default geo desc: /scratch/jupyter/feelppdb/downloads/feelpp2d.geo 0.1
Info : Reading 'feelpp2d.geo'...
Info : Done reading 'feelpp2d.geo'
Info : Meshing 1D...
Info : [ 0%] Meshing curve 1 (Line)
Info : [ 10%] Meshing curve 2 (Line)
Info : [ 10%] Meshing curve 3 (Line)
Info : [ 10%] Meshing curve 4 (Line)
Info : [ 10%] Meshing curve 5 (Line)
Info : [ 10%] Meshing curve 6 (Line)
Info : [ 10%] Meshing curve 7 (Line)
Info : [ 20%] Meshing curve 8 (Line)
Info : [ 20%] Meshing curve 9 (Line)
Info : [ 20%] Meshing curve 10 (Line)
Info : [ 20%] Meshing curve 11 (Line)
Info : [ 20%] Meshing curve 12 (Line)
Info : [ 20%] Meshing curve 13 (Line)
Info : [ 20%] Meshing curve 14 (Line)
Info : [ 30%] Meshing curve 15 (Line)
Info : [ 30%] Meshing curve 16 (Line)
Info : [ 30%] Meshing curve 17 (Line)
Info : [ 30%] Meshing curve 18 (Line)
Info : [ 30%] Meshing curve 19 (Line)
...
Info : Done meshing 2D (Wall 0.106645s, CPU 0.106853s)
Info : 2867 nodes 5812 elements
Info : Writing 'feelpp2d.msh'...
Info : Done writing 'feelpp2d.msh'
----
====

== Usage

The `mesh` provides the {feelpp} data structures in Python:
Expand All @@ -105,33 +64,18 @@ The following methods are to use on the mesh object (`mesh` in the previous exam

Here is an example of how to use the mesh information:

[source,python]
[%dynamic,python]
.Query the mesh information
----
print("dimention: {}".format(mesh.dimension()))
print("number of elements: {}".format(mesh.numGlobalElements()))
print("number of faces: {}".format(mesh.numGlobalFaces()))
print("hmin: {}".format(mesh.hMin()))
print("havg: {}".format(mesh.hAverage()))
print("hmax: {}".format(mesh.hMax()))
print("measure: {}".format(mesh.measure()))
print("measure of boundary: {}".format(mesh.measureBoundary()))
----

[%collapsible.result]
.Results
====
----
dimention: 2
number of elements: 5134
number of faces: 8006
hmin: 0.0763352613189128
havg: 0.10274873094289755
hmax: 0.13695416558140516
measure: 20.79999999999997
measure of boundary: 1497.0959239128888
print(f"dimention: {mesh.dimension()}")
print(f"number of elements: {mesh.numGlobalElements()}")
print(f"number of faces: {mesh.numGlobalFaces()}")
print(f"hmin: {mesh.hMin()}")
print(f"havg: {mesh.hAverage()}")
print(f"hmax: {mesh.hMax()}")
print(f"measure: {mesh.measure()}")
print(f"measure of boundary: {mesh.measureBoundary()}")
----
====

=== Test relation between meshes :

Expand All @@ -146,64 +90,44 @@ measure of boundary: 1497.0959239128888
* `saveHDF5(self, name: str) -> None` : save mesh to H5 file
* `loadHDF5(self, name: str) -> None` : load mesh from H5 file

[source,python]
----
mesh.saveHDF5("mesh.h5")
mesh.loadHDF5("mesh.h5")
----

== Ranges

* `elements` : `feelpp.elements(mesh)` : get iterator over the elements of the mesh
* `markedelements` :
`elements`:: `feelpp.elements(mesh)` : get iterator over the elements of the mesh
`markedelements`::
1. `feelpp.markedelements(mesh, tag: str)` : get iterator over the marked elements of the mesh
2. `feelpp.markedelements(mesh, marker: str)` : return the range of elements of the mesh with marker
3. `feelpp.markedelements(mesh, markers: List[str])` : return the range of elements of the mesh with markers
* `faces` (???)
* `markedfaces` :
`faces`:: `feelpp.faces(mesh)` : get iterator over the faces of the mesh
`markedfaces`::
1. `feelpp.markedfaces(mesh, marker: str)` : return the range of facets of the mesh with marker
2. `markedfaces(mesh, markers: List[str])` : return the range of facets of the mesh with marker
* `boundaryfaces` : `feelpp.boundaryfaces(mesh)`: get iterator over the boundary faces of the mesh
`boundaryfaces`:: `feelpp.boundaryfaces(mesh)`: get iterator over the boundary faces of the mesh

A first example with ranges:

[source,python]
[%dynamic,python]
----
r = feelpp.elements(mesh)
print("mesh elts:", feelpp.nelements(r))
r = feelpp.boundaryfaces(mesh)
print("mesh boundary faces:", feelpp.nelements(r))
----

[%collapsible.result]
.Results
====
----
mesh elts: 5134
mesh boundary faces: 610
----
====

A second more interesting example with ranges uses integrate to compute integrals of expressions over the mesh:

.Example : compute integrals
[source,python]
[%dynamic,python]
----
from feelpp.integrate import integrate
i1 = integrate(range=feelpp.elements(mesh),expr="sin(x+y):x:y")
i2 = integrate(range=feelpp.boundaryfaces(mesh),expr="x*nx+y*ny+z*nz:x:y:z:nx:ny:nz")
i3 = integrate(range=feelpp.markedelements(mesh, "marker"), expr="1")
print("i1 = {}, i2 = {}, i3 = {}".format(i1,i2,i3))
----
[%collapsible.result]
.Results
====
----
i1 = [3.24282386], i2 = [149.465], i3 = [0.]
print(f"i1 = {i1}, i2 = {i2}, i3 = {i3}")
----
====

== Next steps

Expand Down
2 changes: 1 addition & 1 deletion site-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ antora:
- '@antora/collector-extension'
asciidoc:
attributes:
page-component-order: '!home, !ROOT, user, toolboxes, feelpp-project, dev, data, math, *'
page-component-order: '!home, !ROOT, user, toolboxes, feelpp-project, dev, data, math, mor, contribute'
dynamic-blocks@: '' # soft enable
version: 0.110
feelpp-git-tag: develop
Expand Down
2 changes: 1 addition & 1 deletion site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ antora:
- '@antora/collector-extension'
asciidoc:
attributes:
page-component-order: '!home, !ROOT, user, toolboxes, feelpp-project, dev, data, math, *'
page-component-order: '!home, !ROOT, user, toolboxes, feelpp-project, dev, data, math, mor, contribute'
dynamic-blocks@: '' # soft enable
page-pagination: ''
kroki-fetch-diagram: true
Expand Down
Loading

0 comments on commit f8dbab5

Please sign in to comment.