Skip to content
Snippets Groups Projects
Commit 2ea618df authored by Timo Koch's avatar Timo Koch
Browse files

[python][material] Use hash in name of generated classes

parent 48bde781
No related branches found
No related tags found
1 merge request!2681Feature/python main file
"""Components are building blocks of fluid and solid systems""" """Components are building blocks of fluid and solid systems"""
from dune.generator.generator import SimpleGenerator from dune.generator.generator import SimpleGenerator
from dune.common.hashit import hashIt
from dumux.wrapping import cppWrapperCreator, cppWrapperClassAlias from dumux.wrapping import cppWrapperCreator, cppWrapperClassAlias
...@@ -23,8 +24,8 @@ def listComponents(): ...@@ -23,8 +24,8 @@ def listComponents():
def _createComponent(name, *, scalar="double"): def _createComponent(name, *, scalar="double"):
"""Create a new component of the given name""" """Create a new component of the given name"""
moduleName = name
typeName = f"Dumux::Components::{name} <{scalar}>" typeName = f"Dumux::Components::{name} <{scalar}>"
moduleName = f"{name.lower()}_{hashIt(typeName)}"
includes = ["dumux/python/material/components/component.hh"] includes = ["dumux/python/material/components/component.hh"]
includes += [_components[name]] includes += [_components[name]]
generator = SimpleGenerator("Component", "Dumux::Python") generator = SimpleGenerator("Component", "Dumux::Python")
......
...@@ -35,7 +35,7 @@ def _createFluidSystem(name, *, component, scalar: Property = None): ...@@ -35,7 +35,7 @@ def _createFluidSystem(name, *, component, scalar: Property = None):
includes += availableFluidSystems[name]["includes"] includes += availableFluidSystems[name]["includes"]
typeName = availableFluidSystems[name]["type"] typeName = availableFluidSystems[name]["type"]
moduleName = "FluidSystem_" + hashIt(typeName) moduleName = "fluidsystem_" + hashIt(typeName)
generator = SimpleGenerator("FluidSystem", "Dumux::Python") generator = SimpleGenerator("FluidSystem", "Dumux::Python")
module = generator.load(includes, typeName, moduleName) module = generator.load(includes, typeName, moduleName)
return module.FluidSystem() return module.FluidSystem()
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import numpy as np import numpy as np
from dune.generator.generator import SimpleGenerator from dune.generator.generator import SimpleGenerator
from dune.common.hashit import hashIt
from dumux.common import Property from dumux.common import Property
from dumux.wrapping import cppWrapperCreator, cppWrapperClassAlias from dumux.wrapping import cppWrapperCreator, cppWrapperClassAlias
...@@ -10,7 +11,6 @@ from dumux.wrapping import cppWrapperCreator, cppWrapperClassAlias ...@@ -10,7 +11,6 @@ from dumux.wrapping import cppWrapperCreator, cppWrapperClassAlias
def _createOnePSpatialParamsDecorator(*, gridGeometry, scalar: Property = None): def _createOnePSpatialParamsDecorator(*, gridGeometry, scalar: Property = None):
"""Turn a Python spatial parameter class into an C++/Python hybrid class""" """Turn a Python spatial parameter class into an C++/Python hybrid class"""
moduleName = "spatialparams"
dim = gridGeometry.gridView.dimension dim = gridGeometry.gridView.dimension
includes = gridGeometry._includes + [ includes = gridGeometry._includes + [
"dumux/python/material/spatialparams/spatialparams.hh", "dumux/python/material/spatialparams/spatialparams.hh",
...@@ -25,6 +25,7 @@ def _createOnePSpatialParamsDecorator(*, gridGeometry, scalar: Property = None): ...@@ -25,6 +25,7 @@ def _createOnePSpatialParamsDecorator(*, gridGeometry, scalar: Property = None):
typeName = ( typeName = (
f"Dumux::Python::FVSpatialParamsOneP<{gridGeometry._typeName}, {scalarType}, {permType}>" f"Dumux::Python::FVSpatialParamsOneP<{gridGeometry._typeName}, {scalarType}, {permType}>"
) )
moduleName = f"spatialparams_{hashIt(typeName)}"
def decorateOnePSpatialParams(cls): def decorateOnePSpatialParams(cls):
generator = SimpleGenerator("OnePSpatialParams", "Dumux::Python") generator = SimpleGenerator("OnePSpatialParams", "Dumux::Python")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment