Skip to content

Commit

Permalink
#151 up documentaiton about :
Browse files Browse the repository at this point in the history
- parameterSpace
- parameters
- toolboxmor
  • Loading branch information
thomas-saigre committed Nov 24, 2021
1 parent c26440f commit 459f441
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/user/modules/python/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
*** xref:pyfeelpptoolboxes/solid.adoc[Solid Mechanics]
** xref:pyfeelppmor/index.adoc[{pyfeelppmor}]
*** xref:pyfeelppmor/parameters.adoc[Parameters]
*** xref:pyfeelppmor/petscDouble.adoc[PETSc vector and matrix]
*** xref:pyfeelppmor/parametersSpace.adoc[Parameter space]
*** xref:pyfeelppmor/petscDouble.adoc[PETSc vector and matrix]
*** xref:pyfeelppmor/reducedbasis.adoc[Python module `reducedbasis`]
25 changes: 25 additions & 0 deletions docs/user/modules/python/pages/pyfeelppmor/parameterSpace.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
= ParameterSpace

Class `ParameterSpace` (more precisely `feelpp.mor._mor.ParameterSpace`). Space of the parameters of the problem.

.Get a parameter from the model (see xref:pyfeelppmor/reducedbasis.adoc[this page])
[source,python]
----
Dmu = model.parameterSpace()
----


== Methods


* `element(broadcast: bool = True, apply_log: bool = False) -> feelpp.mor._mor.ParameterSpaceElement` : return a parameter from the space :
- `broadcast` : share the parameter to all processors
- `apply_log` : log random chosen parameter

* `sampling() -> feelpp.mor._mor.ParameterSpaceSampling`



== Static method

* `create(arg0: int) -> feelpp.mor._mor.ParameterSpace` : return a `ParameterSpace` of a dimension `arg0`.
2 changes: 1 addition & 1 deletion docs/user/modules/python/pages/pyfeelppmor/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Class `ParameterSpaceElement` (more precisely `feelpp.mor._mor.ParameterSpaceElement`). Contains the parameters of the problem.

.Get a parameter from the model
.Get a parameter from the model (see xref:pyfeelppmor/reducedbasis.adoc[this page])
[source,python]
----
Dmu = model.parameterSpace()
Expand Down
113 changes: 113 additions & 0 deletions docs/user/modules/python/pages/pyfeelppmor/reducedbasis.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
== Module `reducedbasis`

=== Import

NOTE: The work has not yet been merged in `develop`. To include the module at current state, you need to checkout the branch https://github.com/feelpp/feelpp/tree/feature/pyrb[`feature/pyrb`], and move to the directory https://github.com/feelpp/feelpp/tree/feature/pyrb/mor/pyfeelpp-mor/feelpp/mor[mor/pyfeelpp-mor/feelpp/mor].

Line to import the module :

[source, python]
----
from reducedbasis.reducedbasis import *
----

To set the environment, those module also need to be imported :

[source, python]
----
import sys
from feelpp.toolboxes.heat import *
from feelpp.toolboxes.core import *
from feelpp.mor import *
import feelpp
----


=== Set the model

To declare the objects, use these lines :

[source,python]
----
DIM = 2
heatBox=heat(dim=DIM,order=1)
heatBox.init()
model = toolboxmor(dim=DIM, time_dependent=False)
model.setFunctionSpaces( Vh=heatBox.spaceTemperature())
----

- `DIM` is the dimension of the case (should be `2` or `3`)
- `time_dependent` depends if the case is time-steady or time-dependant.

Those functions define how the `DEIM` matrix and right-hand side are updated according to the parameter `mu`.
[source,python]
----
def assembleDEIM(mu):
for i in range(0,mu.size()):
heatBox.addParameterInModelProperties(mu.parameterName(i),mu(i))
heatBox.updateParameterValues()
return heatBox.assembleRhs()
def assembleMDEIM(mu):
for i in range(0,mu.size()):
heatBox.addParameterInModelProperties(mu.parameterName(i),mu(i))
heatBox.updateParameterValues()
return heatBox.assembleMatrix()
model.setAssembleDEIM(fct=assembleDEIM)
model.setAssembleMDEIM(fct=assembleMDEIM)
model.initModel()
----

WARNING: When the function `assembleDEIM` is called, the value of the parameters of the object `heatBox` is updated.

Creation of `DEIM` and `MDEIM` toolboxes, with the associated assembly functions.


[source,python]
----
heatBoxDEIM=heat(dim=DIM,order=1)
meshDEIM = model.getDEIMReducedMesh()
heatBoxDEIM.setMesh(meshDEIM)
heatBoxDEIM.init()
def assembleOnlineDEIM(mu):
for i in range(0,mu.size()):
heatBoxDEIM.addParameterInModelProperties(mu.parameterName(i),mu(i))
heatBoxDEIM.updateParameterValues()
return heatBoxDEIM.assembleRhs()
model.setOnlineAssembleDEIM(assembleOnlineDEIM)
heatBoxMDEIM=heat(dim=DIM,order=1)
meshMDEIM = model.getMDEIMReducedMesh()
heatBoxMDEIM.setMesh(meshMDEIM)
heatBoxMDEIM.init()
def assembleOnlineMDEIM(mu):
for i in range(0,mu.size()):
heatBoxMDEIM.addParameterInModelProperties(mu.parameterName(i),mu(i))
heatBoxMDEIM.updateParameterValues()
return heatBoxMDEIM.assembleMatrix()
model.setOnlineAssembleMDEIM(assembleOnlineMDEIM)
----

Then finalize the initialization :

[soucre,python]
----
model.postInitModel()
model.setInitialized(True)
----


=== Access to a parameter

[source,python]
----
Dmu = model.parameterSpace()
mu = Dmu.element(True, False)
----

See xref:parameters.adoc[the dedicated page] for the API of `ParameterSpaceElement`

0 comments on commit 459f441

Please sign in to comment.