Hi together,

the 1p test looks promising. I understand that the best solution is to add 
wrappers for the shallow water model and to use extended Python instead of 
embedded Python. However, understanding and writing these wrappers is not 
straight forward, one has also to understand the python concepts behind the 
dune core modules.

I have to think about the way to go. I looks much easier to start with embedded 
Python (bybind11) to get a fast solution for my simple task. However writing 
some wrappers for the shallow water model seams to be the best solution since 
it is more flexible on the long run. 

Thank you for the detailed information.

Leo 


>     Timo Koch <koch_t...@hotmail.com> hat am 09.09.2021 15:20 geschrieben:
> 
> 
>     see 
> https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/-/tree/master/python
>  on how to set up your environment (might change with updates in Dune coming 
> soon)
> 
> 
>         > >         On 9. Sep 2021, at 15:19, Timo Koch 
> <koch_t...@hotmail.com mailto:koch_t...@hotmail.com > wrote:
> > 
> >         Hi together,
> > 
> >         also just to add this in case someone it interested. There also has 
> > been some more work lately on using Dumux from Python via pybind11 bindings.
> >         Some first full application (1p test) can be found here: 
> > https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/-/blob/master/test/python/test_1p.py
> >         We haven’t announced this properly yet because it’s still in it’s 
> > infancy, and more classes need wrappers and some issues are still not 
> > solved.
> > 
> >         Timo
> > 
> > 
> > 
> >             > > >             On 9. Sep 2021, at 15:12, Timo Koch 
> > <koch_t...@hotmail.com mailto:koch_t...@hotmail.com > wrote:
> > > 
> > >             Big advantage of pybind11 is also that is does automatic type 
> > > conversion for you between Python and C++,
> > >             so you can easily convert between C++ std::vector and 
> > > Python’s list etc...
> > > 
> > > 
> > >                 > > > >                 On 9. Sep 2021, at 15:03, Timo 
> > > Koch <koch_t...@hotmail.com mailto:koch_t...@hotmail.com > wrote:
> > > > 
> > > >                 Hi Leo,
> > > > 
> > > >                 I would definitely look into this with pybind11 which 
> > > > reads very nice on the C++ side too. There are some instructions at the 
> > > > end herehttp://dune-project.org/doc/pythonbindings and in 
> > > > dune-common/dune/python/test/ you also find two small examples for 
> > > > embedded Python. We also have some testing code with a fluid system 
> > > > using embedded Python on the branch “feature/python-fluidsystem” in 
> > > > dumux (MR !2001). 
> > > > 
> > > >                 And of course some test for dumux is also welcome. 
> > > > 
> > > >                 Timo
> > > > 
> > > > 
> > > >                     > > > > > 9. sep. 2021 kl. 13:36 skrev 
> > > > leopold.stad...@baw.de mailto:leopold.stad...@baw.de :
> > > > > 
> > > > > 
> > > > >                 > > > > 
> > > >                     > > > > >                     Hi Bernd,
> > > > > 
> > > > >                     thank you for this nice example. I've used 
> > > > > embedded Python 10 years ago. My code was much less elegant and so I 
> > > > > thought that one has to do this nowadays with Pybind11. However, 
> > > > > looking into your example it looks like the Python/C API does also 
> > > > > the job. For me it helps a lot to see how the Python interpreter is 
> > > > > initialized and finalized in problem.hh and how data is converted. 
> > > > > 
> > > > >                     Actually I need a simple Python function for the 
> > > > > source term so there are just a few parameters which have to be 
> > > > > passed between C++ and Python.
> > > > > 
> > > > >                     Best regards,
> > > > > 
> > > > >                     Leo
> > > > >                      
> > > > > 
> > > > >                         > > > > > >                         Flemisch, 
> > > > > Bernd <bernd.flemi...@iws.uni-stuttgart.de 
> > > > > mailto:bernd.flemi...@iws.uni-stuttgart.de > hat am 09.09.2021 12:27 
> > > > > geschrieben:
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > >                         Hi Leo,
> > > > > > 
> > > > > > 
> > > > > >                         we're doing this here:
> > > > > > 
> > > > > >                         
> > > > > > https://git.iws.uni-stuttgart.de/dumux-appl/dumux-turing/-/tree/master/test/stochastic
> > > > > > 
> > > > > >                         I needed the python3-dev package and had to 
> > > > > > run the executable with
> > > > > > 
> > > > > >                         PYTHONPATH=. ./test_stochastic
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > >                         Kind regards
> > > > > > 
> > > > > >                         Bernd
> > > > > >                          
> > > > > > https://git.iws.uni-stuttgart.de/dumux-appl/dumux-turing/-/tree/master/test/stochastic
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > >                         --
> > > > > >                         
> > > > > > _________________________________________________________________
> > > > > > 
> > > > > >                         Bernd Flemisch
> > > > > >                         IWS, Universität Stuttgart               
> > > > > > phone: +49 711 685 69162
> > > > > >                         Pfaffenwaldring 61              email: 
> > > > > > be...@iws.uni-stuttgart.de mailto:be...@iws.uni-stuttgart.de
> > > > > >                         D-70569 Stuttgart           url: 
> > > > > > www.iws.uni-stuttgart.de/en/lh2/ 
> > > > > > http://www.iws.uni-stuttgart.de/en/lh2/
> > > > > >                         
> > > > > > _________________________________________________________________
> > > > > > 
> > > > > >                         
> > > > > > ---------------------------------------------
> > > > > >                         Von: DuMux 
> > > > > > <dumux-boun...@listserv.uni-stuttgart.de 
> > > > > > mailto:dumux-boun...@listserv.uni-stuttgart.de > im Auftrag von 
> > > > > > leopold.stad...@baw.de mailto:leopold.stad...@baw.de 
> > > > > > <leopold.stad...@baw.de mailto:leopold.stad...@baw.de >
> > > > > >                         Gesendet: Donnerstag, 9. September 2021 
> > > > > > 11:58:04
> > > > > >                         An: dumux@listserv.uni-stuttgart.de 
> > > > > > mailto:dumux@listserv.uni-stuttgart.de
> > > > > >                         Betreff: [DuMux] Using Embedded Python in 
> > > > > > DuMux
> > > > > > 
> > > > > >                         Dear DuMux developers and users,
> > > > > > 
> > > > > >                         I'm interested to call Python from a DuMux 
> > > > > > application (embedded Python). Has anyone tried this before with 
> > > > > > DuMux? I'm also interested to use embedded Python in a parallel 
> > > > > > application in combination with MPI4py.
> > > > > > 
> > > > > >                         Maybe it is a good idea if I open an issue 
> > > > > > in gitlab and try to add a small test (dumux/test/python) to check 
> > > > > > if/how embedded Python works.  
> > > > > > 
> > > > > >                         Best regards,
> > > > > > 
> > > > > >                         Leo
> > > > > > 
> > > > > > 
> > > > > >                         Im Auftrag
> > > > > > 
> > > > > >                         Dr.-Ing. Leopold Stadler
> > > > > > 
> > > > > >                         --
> > > > > >                         Referat Numerische Verfahren im Wasserbau
> > > > > >                         Abteilung Wasserbau im Binnenbereich
> > > > > > 
> > > > > >                         Bundesanstalt für Wasserbau
> > > > > >                         Federal Waterways Engineering and Research 
> > > > > > Institute
> > > > > >                         Kußmaulstraße 17 | 76187 Karlsruhe
> > > > > > 
> > > > > >                         https://www.baw.de/
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > >                         
> > > > > > _______________________________________________
> > > > > >                         DuMux mailing list
> > > > > >                         DuMux@listserv.uni-stuttgart.de 
> > > > > > mailto:DuMux@listserv.uni-stuttgart.de
> > > > > >                         
> > > > > > https://listserv.uni-stuttgart.de/mailman/listinfo/dumux
> > > > > > 
> > > > > >                     > > > > > 
> > > > > 
> > > > >                     Im Auftrag
> > > > > 
> > > > >                     Dr.-Ing. Leopold Stadler
> > > > > 
> > > > >                     --
> > > > >                     Referat Numerische Verfahren im Wasserbau
> > > > >                     Abteilung Wasserbau im Binnenbereich
> > > > > 
> > > > >                     Bundesanstalt für Wasserbau
> > > > >                     Federal Waterways Engineering and Research 
> > > > > Institute
> > > > >                     Kußmaulstraße 17 | 76187 Karlsruhe
> > > > > 
> > > > >                     https://www.baw.de/
> > > > > 
> > > > > 
> > > > > 
> > > > >                     _______________________________________________
> > > > >                     DuMux mailing list
> > > > >                     DuMux@listserv.uni-stuttgart.de 
> > > > > mailto:DuMux@listserv.uni-stuttgart.de
> > > > >                     
> > > > > https://listserv.uni-stuttgart.de/mailman/listinfo/dumux
> > > > > 
> > > > >                 > > > >                 
> > > > > _______________________________________________
> > > >                 DuMux mailing list
> > > >                 DuMux@listserv.uni-stuttgart.de 
> > > > mailto:DuMux@listserv.uni-stuttgart.de
> > > >                 https://listserv.uni-stuttgart.de/mailman/listinfo/dumux
> > > > 
> > > >             > > > 
> > >             _______________________________________________
> > >             DuMux mailing list
> > >             DuMux@listserv.uni-stuttgart.de 
> > > mailto:DuMux@listserv.uni-stuttgart.de
> > >             https://listserv.uni-stuttgart.de/mailman/listinfo/dumux
> > > 
> > >         > > 
> > 
> >     > 
>     _______________________________________________
>     DuMux mailing list
>     DuMux@listserv.uni-stuttgart.de
>     https://listserv.uni-stuttgart.de/mailman/listinfo/dumux
> 


Im Auftrag

Dr.-Ing. Leopold Stadler

--
Referat Numerische Verfahren im Wasserbau
Abteilung Wasserbau im Binnenbereich

Bundesanstalt für Wasserbau
Federal Waterways Engineering and Research Institute
Kußmaulstraße 17 | 76187 Karlsruhe

https://www.baw.de
_______________________________________________
DuMux mailing list
DuMux@listserv.uni-stuttgart.de
https://listserv.uni-stuttgart.de/mailman/listinfo/dumux

Reply via email to