From 2ea618df13422f5c3bead4b2e224a4ca864532df Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Tue, 27 Jul 2021 23:54:45 +0200 Subject: [PATCH] [python][material] Use hash in name of generated classes --- python/dumux/material/components/__init__.py | 3 ++- python/dumux/material/fluidsystems/__init__.py | 2 +- python/dumux/material/spatialparams/__init__.py | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/python/dumux/material/components/__init__.py b/python/dumux/material/components/__init__.py index e93845ecb6..12b1989a07 100644 --- a/python/dumux/material/components/__init__.py +++ b/python/dumux/material/components/__init__.py @@ -1,6 +1,7 @@ """Components are building blocks of fluid and solid systems""" from dune.generator.generator import SimpleGenerator +from dune.common.hashit import hashIt from dumux.wrapping import cppWrapperCreator, cppWrapperClassAlias @@ -23,8 +24,8 @@ def listComponents(): def _createComponent(name, *, scalar="double"): """Create a new component of the given name""" - moduleName = name typeName = f"Dumux::Components::{name} <{scalar}>" + moduleName = f"{name.lower()}_{hashIt(typeName)}" includes = ["dumux/python/material/components/component.hh"] includes += [_components[name]] generator = SimpleGenerator("Component", "Dumux::Python") diff --git a/python/dumux/material/fluidsystems/__init__.py b/python/dumux/material/fluidsystems/__init__.py index 5d1f0e7d1f..29c73efd8d 100644 --- a/python/dumux/material/fluidsystems/__init__.py +++ b/python/dumux/material/fluidsystems/__init__.py @@ -35,7 +35,7 @@ def _createFluidSystem(name, *, component, scalar: Property = None): includes += availableFluidSystems[name]["includes"] typeName = availableFluidSystems[name]["type"] - moduleName = "FluidSystem_" + hashIt(typeName) + moduleName = "fluidsystem_" + hashIt(typeName) generator = SimpleGenerator("FluidSystem", "Dumux::Python") module = generator.load(includes, typeName, moduleName) return module.FluidSystem() diff --git a/python/dumux/material/spatialparams/__init__.py b/python/dumux/material/spatialparams/__init__.py index 71f85d016e..3440a50002 100644 --- a/python/dumux/material/spatialparams/__init__.py +++ b/python/dumux/material/spatialparams/__init__.py @@ -2,6 +2,7 @@ import numpy as np from dune.generator.generator import SimpleGenerator +from dune.common.hashit import hashIt from dumux.common import Property from dumux.wrapping import cppWrapperCreator, cppWrapperClassAlias @@ -10,7 +11,6 @@ from dumux.wrapping import cppWrapperCreator, cppWrapperClassAlias def _createOnePSpatialParamsDecorator(*, gridGeometry, scalar: Property = None): """Turn a Python spatial parameter class into an C++/Python hybrid class""" - moduleName = "spatialparams" dim = gridGeometry.gridView.dimension includes = gridGeometry._includes + [ "dumux/python/material/spatialparams/spatialparams.hh", @@ -25,6 +25,7 @@ def _createOnePSpatialParamsDecorator(*, gridGeometry, scalar: Property = None): typeName = ( f"Dumux::Python::FVSpatialParamsOneP<{gridGeometry._typeName}, {scalarType}, {permType}>" ) + moduleName = f"spatialparams_{hashIt(typeName)}" def decorateOnePSpatialParams(cls): generator = SimpleGenerator("OnePSpatialParams", "Dumux::Python") -- GitLab