Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
dumux-repositories
dumux
Commits
6c106cf0
Commit
6c106cf0
authored
3 years ago
by
Timo Koch
Browse files
Options
Downloads
Patches
Plain Diff
[python][cleanup] Use fstring to improve readability
parent
fc4b930f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2834
[python][cleanup] Use fstring in properties for better readability
Pipeline
#8975
failed
3 years ago
Stage: trigger
Stage: downstream modules
+1
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
python/dumux/common/__init__.py
+5
-7
5 additions, 7 deletions
python/dumux/common/__init__.py
python/dumux/discretization/__init__.py
+4
-4
4 additions, 4 deletions
python/dumux/discretization/__init__.py
python/dumux/io/__init__.py
+1
-3
1 addition, 3 deletions
python/dumux/io/__init__.py
with
10 additions
and
14 deletions
python/dumux/common/__init__.py
+
5
−
7
View file @
6c106cf0
...
@@ -23,15 +23,13 @@ def _createFVProblemDecorator(gridGeometry, enableInternalDirichletConstraints=F
...
@@ -23,15 +23,13 @@ def _createFVProblemDecorator(gridGeometry, enableInternalDirichletConstraints=F
"""
"""
def
createModule
(
numEq
):
def
createModule
(
numEq
):
priVarType
=
"
Dune::FieldVector<double, {
}>
"
.
format
(
numEq
)
priVarType
=
f
"
Dune::FieldVector<double,
{
numEq
}
>
"
ggType
=
gridGeometry
.
_typeName
ggType
=
gridGeometry
.
_typeName
enableIntDirConstraint
=
"
true
"
if
enableInternalDirichletConstraints
else
"
false
"
enableIntDirConstraint
=
"
true
"
if
enableInternalDirichletConstraints
else
"
false
"
problemType
=
"
Dumux::Python::FVProblem<{}, {}, {}>
"
.
format
(
problemType
=
f
"
Dumux::Python::FVProblem<
{
ggType
}
,
{
priVarType
}
,
{
enableIntDirConstraint
}
>
"
ggType
,
priVarType
,
enableIntDirConstraint
)
includes
=
gridGeometry
.
_includes
+
[
"
dumux/python/common/fvproblem.hh
"
]
includes
=
gridGeometry
.
_includes
+
[
"
dumux/python/common/fvproblem.hh
"
]
moduleName
=
"
fvproblem_
"
+
hashIt
(
problemType
)
moduleName
=
"
fvproblem_
"
+
hashIt
(
problemType
)
holderType
=
"
std::shared_ptr<{
}>
"
.
format
(
problemType
)
holderType
=
f
"
std::shared_ptr<
{
problemType
}
>
"
generator
=
SimpleGenerator
(
"
FVProblem
"
,
"
Dumux::Python
"
)
generator
=
SimpleGenerator
(
"
FVProblem
"
,
"
Dumux::Python
"
)
module
=
generator
.
load
(
includes
,
problemType
,
moduleName
,
options
=
[
holderType
])
module
=
generator
.
load
(
includes
,
problemType
,
moduleName
,
options
=
[
holderType
])
return
module
return
module
...
@@ -57,12 +55,12 @@ def _createBoundaryTypes(numEq=1):
...
@@ -57,12 +55,12 @@ def _createBoundaryTypes(numEq=1):
"""
Create BoundaryTypes instances
"""
"""
Create BoundaryTypes instances
"""
# only compile this once per numEq
# only compile this once per numEq
cacheKey
=
"
BoundaryTypes_{
}
"
.
format
(
numEq
)
cacheKey
=
f
"
BoundaryTypes_
{
numEq
}
"
try
:
try
:
return
globals
()[
cacheKey
]()
return
globals
()[
cacheKey
]()
except
KeyError
:
except
KeyError
:
includes
=
[
"
dumux/python/common/boundarytypes.hh
"
]
includes
=
[
"
dumux/python/common/boundarytypes.hh
"
]
typeName
=
"
Dumux::BoundaryTypes<{
}>
"
.
format
(
numEq
)
typeName
=
f
"
Dumux::BoundaryTypes<
{
numEq
}
>
"
moduleName
=
"
boundarytypes_
"
+
hashIt
(
typeName
)
moduleName
=
"
boundarytypes_
"
+
hashIt
(
typeName
)
generator
=
SimpleGenerator
(
"
BoundaryTypes
"
,
"
Dumux::Python
"
)
generator
=
SimpleGenerator
(
"
BoundaryTypes
"
,
"
Dumux::Python
"
)
module
=
generator
.
load
(
includes
,
typeName
,
moduleName
)
module
=
generator
.
load
(
includes
,
typeName
,
moduleName
)
...
...
This diff is collapsed.
Click to expand it.
python/dumux/discretization/__init__.py
+
4
−
4
View file @
6c106cf0
...
@@ -18,10 +18,10 @@ def _createGridGeometry(gridView, discMethod="cctpfa"):
...
@@ -18,10 +18,10 @@ def _createGridGeometry(gridView, discMethod="cctpfa"):
includes
+=
[
"
dumux/discretization/box/fvgridgeometry.hh
"
]
includes
+=
[
"
dumux/discretization/box/fvgridgeometry.hh
"
]
typeName
=
"
Dumux::BoxFVGridGeometry<double,
"
+
gridView
.
_typeName
+
"
>
"
typeName
=
"
Dumux::BoxFVGridGeometry<double,
"
+
gridView
.
_typeName
+
"
>
"
else
:
else
:
raise
ValueError
(
"
Unknown discMethod {
}
"
.
format
(
discMethod
)
)
raise
ValueError
(
f
"
Unknown discMethod
{
discMethod
}
"
)
moduleName
=
"
gridgeometry_
"
+
hashIt
(
typeName
)
moduleName
=
"
gridgeometry_
"
+
hashIt
(
typeName
)
holderType
=
"
std::shared_ptr<{
}>
"
.
format
(
typeName
)
holderType
=
f
"
std::shared_ptr<
{
typeName
}
>
"
generator
=
SimpleGenerator
(
"
GridGeometry
"
,
"
Dumux::Python
"
)
generator
=
SimpleGenerator
(
"
GridGeometry
"
,
"
Dumux::Python
"
)
module
=
generator
.
load
(
includes
,
typeName
,
moduleName
,
options
=
[
holderType
])
module
=
generator
.
load
(
includes
,
typeName
,
moduleName
,
options
=
[
holderType
])
return
module
.
GridGeometry
(
gridView
)
return
module
.
GridGeometry
(
gridView
)
...
@@ -43,10 +43,10 @@ def _createGridVariables(*, problem, model):
...
@@ -43,10 +43,10 @@ def _createGridVariables(*, problem, model):
ggeo
=
f
"
Dumux::GetPropType<
{
model
.
cppType
}
, Dumux::Properties::GridGeometry>
"
ggeo
=
f
"
Dumux::GetPropType<
{
model
.
cppType
}
, Dumux::Properties::GridGeometry>
"
gvv
=
f
"
Dumux::GetPropType<
{
model
.
cppType
}
, Dumux::Properties::GridVolumeVariables>
"
gvv
=
f
"
Dumux::GetPropType<
{
model
.
cppType
}
, Dumux::Properties::GridVolumeVariables>
"
gfc
=
f
"
Dumux::GetPropType<
{
model
.
cppType
}
, Dumux::Properties::GridFluxVariablesCache>
"
gfc
=
f
"
Dumux::GetPropType<
{
model
.
cppType
}
, Dumux::Properties::GridFluxVariablesCache>
"
typeName
=
"
Dumux::FVGridVariables<{
}, {}, {}>
"
.
format
(
ggeo
,
gvv
,
gfc
)
typeName
=
f
"
Dumux::FVGridVariables<
{
ggeo
}
,
{
gvv
}
,
{
gfc
}
>
"
moduleName
=
"
gridvariables_
"
+
hashIt
(
typeName
)
moduleName
=
"
gridvariables_
"
+
hashIt
(
typeName
)
holderType
=
"
std::shared_ptr<{
}>
"
.
format
(
typeName
)
holderType
=
f
"
std::shared_ptr<
{
typeName
}
>
"
generator
=
SimpleGenerator
(
"
GridVariables
"
,
"
Dumux::Python
"
)
generator
=
SimpleGenerator
(
"
GridVariables
"
,
"
Dumux::Python
"
)
module
=
generator
.
load
(
module
=
generator
.
load
(
includes
,
typeName
,
moduleName
,
options
=
[
holderType
],
preamble
=
model
.
cppHeader
includes
,
typeName
,
moduleName
,
options
=
[
holderType
],
preamble
=
model
.
cppHeader
...
...
This diff is collapsed.
Click to expand it.
python/dumux/io/__init__.py
+
1
−
3
View file @
6c106cf0
...
@@ -11,9 +11,7 @@ def _createVtkOutputModule(*, gridVariables, solutionVector, name):
...
@@ -11,9 +11,7 @@ def _createVtkOutputModule(*, gridVariables, solutionVector, name):
includes
=
gridVariables
.
_includes
+
solutionVector
.
_includes
includes
=
gridVariables
.
_includes
+
solutionVector
.
_includes
includes
+=
[
"
dumux/python/io/vtkoutputmodule.hh
"
,
"
dumux/io/vtkoutputmodule.hh
"
]
includes
+=
[
"
dumux/python/io/vtkoutputmodule.hh
"
,
"
dumux/io/vtkoutputmodule.hh
"
]
typeName
=
"
Dumux::VtkOutputModule<{}, {}>
"
.
format
(
typeName
=
f
"
Dumux::VtkOutputModule<
{
gridVariables
.
_typeName
}
,
{
solutionVector
.
_typeName
}
>
"
gridVariables
.
_typeName
,
solutionVector
.
_typeName
)
moduleName
=
"
vtkoutputmodule_
"
+
hashIt
(
typeName
)
moduleName
=
"
vtkoutputmodule_
"
+
hashIt
(
typeName
)
generator
=
SimpleGenerator
(
"
VtkOutputModule
"
,
"
Dumux::Python
"
)
generator
=
SimpleGenerator
(
"
VtkOutputModule
"
,
"
Dumux::Python
"
)
module
=
generator
.
load
(
includes
,
typeName
,
moduleName
,
preamble
=
gridVariables
.
model
.
cppHeader
)
module
=
generator
.
load
(
includes
,
typeName
,
moduleName
,
preamble
=
gridVariables
.
model
.
cppHeader
)
...
...
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