From 4296cc009809f687c5c715f2930fb1b666fa0947 Mon Sep 17 00:00:00 2001 From: thomas-saigre <60920471+thomas-saigre@users.noreply.github.com> Date: Tue, 6 Jul 2021 12:49:48 +0200 Subject: [PATCH] saigre/pyfeelpp (#152) * write doc about : - parameters - petsc vectors - petsc matrix Write documentation on python x feel++ modules #151 [ci skip] * add documentation about parameters see commit https://github.com/feelpp/feelpp/commit/9512e771590a6a6bd1f7261bee32d08d294921d7 [ci skip] --- docs/user/modules/python/nav.adoc | 3 ++ .../python/pages/pyfeelppmor/index.adoc | 5 ++ .../python/pages/pyfeelppmor/parameters.adoc | 50 +++++++++++++++++++ .../python/pages/pyfeelppmor/petscDouble.adoc | 38 ++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 docs/user/modules/python/pages/pyfeelppmor/index.adoc create mode 100644 docs/user/modules/python/pages/pyfeelppmor/parameters.adoc create mode 100644 docs/user/modules/python/pages/pyfeelppmor/petscDouble.adoc diff --git a/docs/user/modules/python/nav.adoc b/docs/user/modules/python/nav.adoc index 0dd13684d..98d61b648 100644 --- a/docs/user/modules/python/nav.adoc +++ b/docs/user/modules/python/nav.adoc @@ -9,3 +9,6 @@ *** xref:pyfeelpptoolboxes/electric.adoc[Electrostatic] *** xref:pyfeelpptoolboxes/fluid.adoc[Fluid Mechanics] *** xref:pyfeelpptoolboxes/solid.adoc[Solid Mechanics] +** xref:pyfeelppmor/index.adoc[{pyfeelppmor}] +*** xref:pyfeelppmor/parameters.adoc[Parameters] +*** xref:pyfeelppmor/petscDouble.adoc[PETSc vector and matrix] \ No newline at end of file diff --git a/docs/user/modules/python/pages/pyfeelppmor/index.adoc b/docs/user/modules/python/pages/pyfeelppmor/index.adoc new file mode 100644 index 000000000..cef409545 --- /dev/null +++ b/docs/user/modules/python/pages/pyfeelppmor/index.adoc @@ -0,0 +1,5 @@ += {feelpp} model order reduction in Python +include::{partialsdir}/header-macros.adoc[] + +This sections present the modules developped and the function implemented to handle {fpp} MOR objects in Python. The script link:https://github.com/feelpp/feelpp/blob/develop/mor/pyfeelpp-mor/feelpp/mor/toolboxmor.py[toolboxmor.py] presents the main features, on the case opus-heat. + diff --git a/docs/user/modules/python/pages/pyfeelppmor/parameters.adoc b/docs/user/modules/python/pages/pyfeelppmor/parameters.adoc new file mode 100644 index 000000000..b721e7f98 --- /dev/null +++ b/docs/user/modules/python/pages/pyfeelppmor/parameters.adoc @@ -0,0 +1,50 @@ += Parameters + +Class `ParameterSpaceElement` (more precisely `feelpp.mor._mor.ParameterSpaceElement`). Contains the parameters of the problem. + +.Get a parameter from the model +[source,python] +---- +Dmu = model.parameterSpace() +mu = Dmu.element(True, False) +---- + + +== Methods + +* `__call__(i: int)` -> `float` : return the _i_-th parameter + +* `__str__()` : + +[source,python] +---- +>>> print("mu =", mu) +mu = [4.37e+00,2.92e+00,1.17e+00,8.75e+05,5.28e+05,2.83e+01] +---- + +* `parameterName(i: int)` -> `str` : return the named of the _i_-th parameter + +* `parameterNamed(name: str)` -> `float` : return the parameter named `str` + +* `setParameter(i: int, value: float)` : set the _i_-th to `value` + +* `setParameterNamed(name: str, value: float)` : set the parameter `name` to `value` + +* `setParameters(...)` : Overloaded function. + 1. `setParameters(values: List[float])` : set the parameter to the given list, the argument shas to be in the same order as values are stored in the `ParameterSpaceElement`. + 2. `setParameters(values: Dict[str, float])` : set the parameter to the given dict with values. Eg `mu.setParameters({hcoeff: 2, q_1: 18712.5})`. + +* `size()` -> `int` : return the size of the parameter + +* `view()` : displays the names of the parameters, associated to their values. Here is an example : + +[source, python] +---- +>>> mu.view() +hcoeff 3.77075 +k_1 2.36557 +k_2 1.79914 +q_1 18710.5 +q_2 166074 +vinconv 3.58235 +---- diff --git a/docs/user/modules/python/pages/pyfeelppmor/petscDouble.adoc b/docs/user/modules/python/pages/pyfeelppmor/petscDouble.adoc new file mode 100644 index 000000000..0e3e5c9d0 --- /dev/null +++ b/docs/user/modules/python/pages/pyfeelppmor/petscDouble.adoc @@ -0,0 +1,38 @@ +== Vector PETSc Double + +Class `VectorPetscDouble` (`feelpp._alg.VectorPetscDouble`) + + +=== Methods + +* `__init__(*args, **kwargs)` : Overloaded function. + + 1. `__init__()`. The vector created is empty. + 2. `__init__(arg0: int, arg1: feelpp._core.WorldComm)`. The vector created has a size `arg0`. + 3. `__init__(arg0: int, arg1: int, arg2: feelpp._core.WorldComm)`. The vector created has a global size `arg0`, and a local size `arg1`. + 4. `__init__(arg0: feelpp._alg.DataMap, arg1: bool)` +* `clear()` : clear PETSc vector +* `size()` -> `int` : return PETSc Vector size +* `vec()` -> `vec` : return a PETSc Vector that can be manipulated with funciton of the module https://pypi.org/project/petsc4py/[petsc4py]. The functions of this class can be found on the https://www.mcs.anl.gov/petsc/petsc4py-current/docs/apiref/petsc4py.PETSc.Vec-class.html[documentation of PETSc4py]. +* `zero()` : zero PETSc vector + + +== Matrix PETSc Double + +Class `MatrixPetscDouble` (`feelpp._alg.MatrixPetscDouble`). The methods of this class are similar to the previous class, the apply on matrices insted of vectors. + + +=== Methods + +* `__init__(*args, **kwargs)` : Overloaded function. + 1. `__init__(arg0: feelpp._core.WorldComm)` + 2. `__init__(arg0: feelpp._alg.DataMap, arg1: feelpp._alg.DataMap)` + 3. `__init__(arg1: feelpp._alg.DataMap, arg2: feelpp._core.WorldComm)` +* `clear()` : clear PETSc matrix +* `mat(...)` -> `mat` : return a PETSc sparse matrix. See https://www.mcs.anl.gov/petsc/petsc4py-current/docs/apiref/petsc4py.PETSc.Mat-class.html[the documentation]. +* `rowStart()` -> `int` : return PETSc Matrix row start. This method is usefull is the matrix is shared with many processors, as the following. +* `rowStop()` -> `int` : return PETSc Matrix row stop +* `size1()` -> `int` : return PETSc Matrix row size +* `size2()` -> `int` : return PETSc Matrix column size +* `shape()` -> `Tuple[int,int]` : return PETSc Matrix shape (`(row size, column size)`) +* `zero()` : zero PETSc matrix \ No newline at end of file