Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ag-ohlberger
dune-community
dune-xt
Commits
bc93c90d
Commit
bc93c90d
authored
7 years ago
by
Dr. Felix Tobias Schindler
Browse files
Options
Downloads
Patches
Plain Diff
[bindings] update mpi and logger handling
parent
b7485b58
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/xt/common/bindings.cc
+8
-7
8 additions, 7 deletions
dune/xt/common/bindings.cc
python/dune/xt/common/__init__.py
+29
-16
29 additions, 16 deletions
python/dune/xt/common/__init__.py
with
37 additions
and
23 deletions
dune/xt/common/bindings.cc
+
8
−
7
View file @
bc93c90d
...
...
@@ -16,6 +16,8 @@
#include
<boost/numeric/conversion/cast.hpp>
#include
<dune/xt/common/exceptions.hh>
#include
<dune/common/parallel/mpihelper.hh>
#if HAVE_DUNE_FEM
...
...
@@ -33,29 +35,28 @@
#include
"fmatrix.pbh"
#include
"configuration.pbh"
namespace
py
=
pybind11
;
using
namespace
pybind11
::
literals
;
PYBIND11_PLUGIN
(
_common
)
{
namespace
py
=
pybind11
;
using
namespace
pybind11
::
literals
;
py
::
module
m
(
"_common"
,
"dune-xt-common"
);
Dune
::
XT
::
Common
::
bind_Exception
(
m
);
m
.
def
(
"init_mpi"
,
m
.
def
(
"
_
init_mpi"
,
[](
const
std
::
vector
<
std
::
string
>&
args
)
{
int
argc
=
boost
::
numeric_cast
<
int
>
(
args
.
size
());
char
**
argv
=
Dune
::
XT
::
Common
::
vector_to_main_args
(
args
);
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
#if HAVE_DUNE_FEM
Dune
::
Fem
::
MPIManager
::
initialize
(
argc
,
argv
);
#else
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
#endif
},
"args"
_a
=
std
::
vector
<
std
::
string
>
());
m
.
def
(
"init_logger"
,
m
.
def
(
"
_
init_logger"
,
[](
const
ssize_t
max_info_level
,
const
ssize_t
max_debug_level
,
const
bool
enable_warnings
,
...
...
This diff is collapsed.
Click to expand it.
python/dune/xt/common/__init__.py
+
29
−
16
View file @
bc93c90d
...
...
@@ -14,6 +14,18 @@ try:
except
ImportError
:
pass
_init_logger_methods
=
list
()
_init_mpi_methods
=
list
()
_other_modules
=
(
'
xt.la
'
,
'
xt.grid
'
,
'
xt.functions
'
,
'
gdt
'
)
from
._common
import
__dict__
as
module
to_import
=
[
name
for
name
in
module
if
not
name
.
startswith
(
'
_
'
)]
globals
().
update
({
name
:
module
[
name
]
for
name
in
to_import
})
_init_logger_methods
.
append
(
module
[
'
_init_logger
'
])
_init_mpi_methods
.
append
(
module
[
'
_init_mpi
'
])
del
to_import
del
module
def
init_logger
(
max_info_level
=-
1
,
max_debug_level
=-
1
,
...
...
@@ -22,26 +34,27 @@ def init_logger(max_info_level=-1,
info_color
=
'
blue
'
,
debug_color
=
'
darkgray
'
,
warning_color
=
'
red
'
):
from
._common
import
init_logger
as
_init_logger
initializers
=
[
_init_logger
]
for
module_name
in
(
'
xt.la
'
,
'
xt.grid
'
,
'
xt.functions
'
,
'
gdt
'
):
init_logger_methods
=
_init_logger_methods
.
copy
()
for
module_name
in
_other_modules
:
try
:
mm
=
import_module
(
'
dune.{}
'
.
format
(
module_name
))
initializers
.
append
(
mm
.
init_logger
)
for
init_logger_method
in
mm
.
_init_logger_methods
:
init_logger_methods
.
append
(
init_logger_method
)
except
ModuleNotFoundError
:
pass
for
initializer
in
initializers
:
initializer
(
max_info_level
,
max_debug_level
,
enable_warnings
,
enable_colors
,
info_color
,
debug_color
,
warning_color
)
for
init_logger_method
in
init_logger_methods
:
init_logger_method
(
max_info_level
,
max_debug_level
,
enable_warnings
,
enable_colors
,
info_color
,
debug_color
,
warning_color
)
def
init_mpi
(
args
=
list
()):
try
:
from
dune.gdt
import
init_mpi
as
_init_mpi
except
ModuleNotFoundError
:
from
dune.xt.common
import
init_mpi
as
_init_mpi
_init_mpi
(
args
)
from
._common
import
*
init_mpi_methods
=
_init_mpi_methods
.
copy
()
for
module_name
in
_other_modules
:
try
:
mm
=
import_module
(
'
dune.{}
'
.
format
(
module_name
))
for
init_mpi_method
in
mm
.
_init_mpi_methods
:
init_mpi_methods
.
append
(
init_mpi_method
)
except
ModuleNotFoundError
:
pass
for
init_mpi_method
in
init_mpi_methods
:
init_mpi_method
(
args
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment