diff --git a/apps/benchmarks/GranularGas/ConfigGenerator.py b/apps/benchmarks/GranularGas/ConfigGenerator.py index 8c3ad3f8feb4085eba3febc2757d43e8d5fd125d..6d84f643439e4efacf50bc4d5a19ab2b12939149 100644 --- a/apps/benchmarks/GranularGas/ConfigGenerator.py +++ b/apps/benchmarks/GranularGas/ConfigGenerator.py @@ -3,66 +3,67 @@ from jinja2 import Environment, FileSystemLoader import os + class Parameter: - def __init__(self, name, type, defValue=""): - """Propery of a data strcuture + def __init__(self, name, type, defValue=""): + """Propery of a data strcuture + + Parameters + ---------- + name : str + name of the property + type : str + type of the property + defValue : str + default value the property should be initialized with + """ - Parameters - ---------- - name : str - name of the property - type : str - type of the property - defValue : str - default value the property should be initialized with - """ + self.name = name + self.type = type + self.defValue = defValue - self.name = name - self.type = type - self.defValue = defValue + def __str__(self): + return "name: {}, type: {}, defValue: {}".format(self.name, self.type, self.defValue) - def __str__(self): - return "name: {}, type: {}, defValue: {}".format(self.name, self.type, self.defValue) class Config: - def __init__(self): - self.parameters = [] + def __init__(self): + self.parameters = [] - def parameterExists(self, name): - for v in self.parameters: - if v.name==name: - return True - return False + def parameterExists(self, name): + for v in self.parameters: + if v.name == name: + return True + return False - def addParameter(self, name, type, defValue): - if self.parameterExists( name ): - print("parameters already added: " + name) - else: - self.parameters.append( Parameter(name, type, defValue) ) + def addParameter(self, name, type, defValue): + if self.parameterExists(name): + print("parameters already added: " + name) + else: + self.parameters.append(Parameter(name, type, defValue)) - def generateFile(self, template): - context = dict() - context["parameters"] = self.parameters + def generateFile(self, template): + context = dict() + context["parameters"] = self.parameters - path = "" - filename = template.replace(".templ", "") - dirname = os.path.dirname(__file__) - env = Environment(loader=FileSystemLoader(dirname)) - print("generating: " + path + filename) - fout = open(path + filename, "wb") - content = env.get_template(template).render(context) - fout.write(content.encode('utf8')) - fout.close() + path = "" + filename = template.replace(".templ", "") + dirname = os.path.dirname(__file__) + env = Environment(loader=FileSystemLoader(dirname)) + print("generating: " + path + filename) + with open(path + filename, "wb") as fout: + content = env.get_template(template).render(context) + fout.write(content.encode('utf8')) - def generate(self): - print("="*90) - print("Config File:") - print("") - print("{0: <30}{1: <30}{2: <30}".format("Name", "Type", "Def. Value")) - print("="*90) - for param in self.parameters: - print("{0: <30.29}{1: <30.29}{2: <30.29}".format(param.name, param.type, param.defValue)) - print("="*90) + def generate(self): + print("=" * 90) + print("Config File:") + print("") + print("{0: <30}{1: <30}{2: <30}".format("Name", "Type", "Def. Value")) + print("=" * 90) + for param in self.parameters: + print("{0: <30.29}{1: <30.29}{2: <30.29}".format(param.name, param.type, param.defValue)) + print("=" * 90) - self.generateFile("Parameters.templ.h") - self.generateFile("Parameters.templ.cpp") + self.generateFile("Parameters.templ.h") + self.generateFile("Parameters.templ.cpp") diff --git a/apps/benchmarks/GranularGas/GenerateModule.py b/apps/benchmarks/GranularGas/GenerateModule.py index 2ac9ebfb45da6911ce537de1ead08c043098e556..55a9044197827c83926a5b8046a4e7a44a03fdfa 100755 --- a/apps/benchmarks/GranularGas/GenerateModule.py +++ b/apps/benchmarks/GranularGas/GenerateModule.py @@ -30,7 +30,8 @@ if __name__ == '__main__': ps.add_property("type", "uint_t", defValue="0", syncMode="ON_GHOST_CREATION") - ps.add_property("flags", "walberla::mesa_pd::data::particle_flags::FlagT", defValue="", syncMode="ON_GHOST_CREATION") + ps.add_property("flags", "walberla::mesa_pd::data::particle_flags::FlagT", defValue="", + syncMode="ON_GHOST_CREATION") ps.add_property("nextParticle", "int", defValue="-1", syncMode="NEVER") ps.add_include("blockforest/BlockForest.h") diff --git a/apps/benchmarks/GranularGas/generateConfig.py b/apps/benchmarks/GranularGas/generateConfig.py index 195534574c85a9fee6efe988b8dab8b0f77a7fb1..0212a46ddcb7b83c5148c867d642637f4eaf18f9 100755 --- a/apps/benchmarks/GranularGas/generateConfig.py +++ b/apps/benchmarks/GranularGas/generateConfig.py @@ -20,14 +20,14 @@ cfg.addParameter("visSpacing", "int64_t", "1000") cfg.addParameter("vtk_out", "std::string", '"vtk_out"') cfg.addParameter("sqlFile", "std::string", '"benchmark.sqlite"') -cfg.addParameter("recalculateBlockLevelsInRefresh", "bool", "false"); -cfg.addParameter("alwaysRebalanceInRefresh", "bool", "true"); -cfg.addParameter("reevaluateMinTargetLevelsAfterForcedRefinement", "bool", "false"); -cfg.addParameter("allowRefreshChangingDepth", "bool", "false"); +cfg.addParameter("recalculateBlockLevelsInRefresh", "bool", "false") +cfg.addParameter("alwaysRebalanceInRefresh", "bool", "true") +cfg.addParameter("reevaluateMinTargetLevelsAfterForcedRefinement", "bool", "false") +cfg.addParameter("allowRefreshChangingDepth", "bool", "false") -cfg.addParameter("allowMultipleRefreshCycles", "bool", "false"); -cfg.addParameter("checkForEarlyOutInRefresh", "bool", "true"); -cfg.addParameter("checkForLateOutInRefresh", "bool", "true"); +cfg.addParameter("allowMultipleRefreshCycles", "bool", "false") +cfg.addParameter("checkForEarlyOutInRefresh", "bool", "true") +cfg.addParameter("checkForLateOutInRefresh", "bool", "true") cfg.addParameter("regridMin", "uint_t", 'uint_c(100)') cfg.addParameter("regridMax", "uint_t", 'uint_c(1000)') @@ -35,8 +35,8 @@ cfg.addParameter("maxBlocksPerProcess", "int", 'int_c(1000)') cfg.addParameter("baseWeight", "real_t", 'real_t(10.0)') cfg.addParameter("metisipc2redist", "real_t", 'real_t(1000.0)') cfg.addParameter("LBAlgorithm", "std::string", '"Hilbert"') -cfg.addParameter("metisAlgorithm", "std::string", '"PART_GEOM_KWAY"' ); -cfg.addParameter("metisWeightsToUse", "std::string", '"BOTH_WEIGHTS"' ); -cfg.addParameter("metisEdgeSource", "std::string", '"EDGES_FROM_EDGE_WEIGHTS"' ); +cfg.addParameter("metisAlgorithm", "std::string", '"PART_GEOM_KWAY"') +cfg.addParameter("metisWeightsToUse", "std::string", '"BOTH_WEIGHTS"') +cfg.addParameter("metisEdgeSource", "std::string", '"EDGES_FROM_EDGE_WEIGHTS"') cfg.generate() diff --git a/apps/benchmarks/GranularGas/mesa_pd_upload.py b/apps/benchmarks/GranularGas/mesa_pd_upload.py index 492c58e09875f46c8ac293c9ce33a9058d43d120..0d8eccbcf31496bf2afb5f0b47e74ac33d2f15e7 100755 --- a/apps/benchmarks/GranularGas/mesa_pd_upload.py +++ b/apps/benchmarks/GranularGas/mesa_pd_upload.py @@ -2,51 +2,49 @@ import os import time -import math -import random import re from influxdb import InfluxDBClient -from git import Repo class Upload: - def __init__(self): - try: - self.write_user_pw = os.environ["INFLUXDB_MESAPD_PW"] - except KeyError: - import sys - print('Password for the InfluxDB write_user was not set.\n', - 'See https://docs.gitlab.com/ee/ci/variables/#secret-variables', file=sys.stderr) - exc_info = sys.exc_info() - raise exc_info[0].with_traceback(exc_info[1], exc_info[2]) - - self.client = InfluxDBClient('i10grafana.informatik.uni-erlangen.de', 8086, - 'mesa_pd', self.write_user_pw, 'mesa_pd') - - def process(self, filename): - tts = dict() - - with open(filename) as f: - for s in f.readlines(): - m = re.search(r'\[0\]\s*(\w*)\s*\|[\s\d\.\%]*\|\s*([\d\.]*)', s) - - if (m != None): - tts[m.group(1)] = float(m.group(2)) - - json_body = [ - { - 'measurement': 'mesa_pd_benchmark', - 'tags': { - 'host' : os.uname()[1], - 'image' : os.environ["DOCKER_IMAGE_NAME"], - }, - 'time': int(time.time()), - 'fields': tts - } - ] - print(tts) - self.client.write_points(json_body, time_precision='s') + def __init__(self): + try: + self.write_user_pw = os.environ["INFLUXDB_MESAPD_PW"] + except KeyError: + import sys + print('Password for the InfluxDB write_user was not set.\n', + 'See https://docs.gitlab.com/ee/ci/variables/#secret-variables', file=sys.stderr) + exc_info = sys.exc_info() + raise exc_info[0].with_traceback(exc_info[1], exc_info[2]) + + self.client = InfluxDBClient('i10grafana.informatik.uni-erlangen.de', 8086, + 'mesa_pd', self.write_user_pw, 'mesa_pd') + + def process(self, filename): + tts = dict() + + with open(filename) as f: + for s in f.readlines(): + m = re.search(r'\[0\]\s*(\w*)\s*\|[\s\d\.\%]*\|\s*([\d\.]*)', s) + + if m is not None: + tts[m.group(1)] = float(m.group(2)) + + json_body = [ + { + 'measurement': 'mesa_pd_benchmark', + 'tags': { + 'host': os.uname()[1], + 'image': os.environ["DOCKER_IMAGE_NAME"], + }, + 'time': int(time.time()), + 'fields': tts + } + ] + print(tts) + self.client.write_points(json_body, time_precision='s') + if __name__ == "__main__": - up = Upload() - up.process("mesa_pd.txt") + up = Upload() + up.process("mesa_pd.txt") diff --git a/apps/benchmarks/GranularGas/pe_upload.py b/apps/benchmarks/GranularGas/pe_upload.py index 7d1b1badd8912f513f40f3c2842d8be0d1d7ff52..4b76e4407645d540f2ef809209e21b2df10790c4 100644 --- a/apps/benchmarks/GranularGas/pe_upload.py +++ b/apps/benchmarks/GranularGas/pe_upload.py @@ -1,56 +1,58 @@ +# -*- coding: utf-8 -*- + import os import time -import math -import random import re from influxdb import InfluxDBClient -from git import Repo class Upload: - def __init__(self): - try: - self.write_user_pw = os.environ["INFLUXDB_WRITE_USER"] - except KeyError: - import sys - print('Password for the InfluxDB write_user was not set.\n', - 'See https://docs.gitlab.com/ee/ci/variables/#secret-variables', file=sys.stderr) - exc_info = sys.exc_info() - raise exc_info[0].with_traceback(exc_info[1], exc_info[2]) - - self.client = InfluxDBClient('i10grafana.informatik.uni-erlangen.de', 8086, - 'pe', self.write_user_pw, 'pe') - - def process(self, filename, model, friction, sync, parallelization): - with open(filename) as f: - s = f.read() - m = re.search('PUpS: (\S*)', s) - - json_body = [ - { - 'measurement': 'pe_benchmark', - 'tags': { - 'host' : os.uname()[1], - 'image' : os.environ["DOCKER_IMAGE_NAME"], - 'model' : model, - 'friction' : friction, - 'sync' : sync, - 'parallelization' : parallelization - }, - 'time': int(time.time()), - 'fields': {'PUpS': float(m.group(1))} - } - ] - print(float(m.group(1))) - self.client.write_points(json_body, time_precision='s') + def __init__(self): + try: + self.write_user_pw = os.environ["INFLUXDB_WRITE_USER"] + except KeyError: + import sys + print('Password for the InfluxDB write_user was not set.\n', + 'See https://docs.gitlab.com/ee/ci/variables/#secret-variables', file=sys.stderr) + exc_info = sys.exc_info() + raise exc_info[0].with_traceback(exc_info[1], exc_info[2]) -if __name__ == "__main__": - up = Upload() - up.process("GranularGas_DEM_NN.txt", "DEM", "Coulomb", "next neighbors", "8P1T") - up.process("GranularGas_DEM_SO.txt", "DEM", "Coulomb", "shadow owners", "8P1T") - up.process("GranularGas_HCSITS_NN_IFC.txt", "HCSITS", "InelasticFrictionlessContact", "next neighbors", "8P1T") - up.process("GranularGas_HCSITS_NN_AICCBD.txt", "HCSITS", "ApproximateInelasticCoulombContactByDecoupling", "next neighbors", "8P1T") - up.process("GranularGas_HCSITS_NN_ICCBD.txt", "HCSITS", "InelasticCoulombContactByDecoupling", "next neighbors", "8P1T") - up.process("GranularGas_HCSITS_NN_IGMDC.txt", "HCSITS", "InelasticGeneralizedMaximumDissipationContact", "next neighbors", "8P1T") - up.process("GranularGas_HCSITS_SO_IFC.txt", "HCSITS", "InelasticFrictionlessContact", "shadow owners", "8P1T") + self.client = InfluxDBClient('i10grafana.informatik.uni-erlangen.de', 8086, + 'pe', self.write_user_pw, 'pe') + + def process(self, filename, model, friction, sync, parallelization): + with open(filename) as f: + s = f.read() + m = re.search(r'PUpS: (\S*)', s) + json_body = [ + { + 'measurement': 'pe_benchmark', + 'tags': { + 'host': os.uname()[1], + 'image': os.environ["DOCKER_IMAGE_NAME"], + 'model': model, + 'friction': friction, + 'sync': sync, + 'parallelization': parallelization + }, + 'time': int(time.time()), + 'fields': {'PUpS': float(m.group(1))} + } + ] + print(float(m.group(1))) + self.client.write_points(json_body, time_precision='s') + + +if __name__ == "__main__": + up = Upload() + up.process("GranularGas_DEM_NN.txt", "DEM", "Coulomb", "next neighbors", "8P1T") + up.process("GranularGas_DEM_SO.txt", "DEM", "Coulomb", "shadow owners", "8P1T") + up.process("GranularGas_HCSITS_NN_IFC.txt", "HCSITS", "InelasticFrictionlessContact", "next neighbors", "8P1T") + up.process("GranularGas_HCSITS_NN_AICCBD.txt", "HCSITS", "ApproximateInelasticCoulombContactByDecoupling", + "next neighbors", "8P1T") + up.process("GranularGas_HCSITS_NN_ICCBD.txt", "HCSITS", "InelasticCoulombContactByDecoupling", "next neighbors", + "8P1T") + up.process("GranularGas_HCSITS_NN_IGMDC.txt", "HCSITS", "InelasticGeneralizedMaximumDissipationContact", + "next neighbors", "8P1T") + up.process("GranularGas_HCSITS_SO_IFC.txt", "HCSITS", "InelasticFrictionlessContact", "shadow owners", "8P1T") diff --git a/python/mesa_pd.py b/python/mesa_pd.py index 050e6ed421ff1f4278e7fb2f25f22e8a239377f9..cc8b5309131ae2e90b3cd32a04bd77599fef9256 100755 --- a/python/mesa_pd.py +++ b/python/mesa_pd.py @@ -54,10 +54,14 @@ if __name__ == '__main__': ps.add_property("dw", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="NEVER") # Properties for lbm_mesapd_coupling: - ps.add_property("hydrodynamicForce", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ON_OWNERSHIP_CHANGE") - ps.add_property("hydrodynamicTorque", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ON_OWNERSHIP_CHANGE") - ps.add_property("oldHydrodynamicForce", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ON_OWNERSHIP_CHANGE") - ps.add_property("oldHydrodynamicTorque", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ON_OWNERSHIP_CHANGE") + ps.add_property("hydrodynamicForce", "walberla::mesa_pd::Vec3", defValue="real_t(0)", + syncMode="ON_OWNERSHIP_CHANGE") + ps.add_property("hydrodynamicTorque", "walberla::mesa_pd::Vec3", defValue="real_t(0)", + syncMode="ON_OWNERSHIP_CHANGE") + ps.add_property("oldHydrodynamicForce", "walberla::mesa_pd::Vec3", defValue="real_t(0)", + syncMode="ON_OWNERSHIP_CHANGE") + ps.add_property("oldHydrodynamicTorque", "walberla::mesa_pd::Vec3", defValue="real_t(0)", + syncMode="ON_OWNERSHIP_CHANGE") ch = mpd.add(data.ContactHistory()) ch.add_property("tangentialSpringDisplacement", "walberla::mesa_pd::Vec3", defValue="real_t(0)") diff --git a/python/mesa_pd/data/ContactHistory.py b/python/mesa_pd/data/ContactHistory.py index 4189f6648f680debca389adb208076a40cab6d59..9a6c4f49ce6e74de1d721fc90a714a63b0dad44a 100644 --- a/python/mesa_pd/data/ContactHistory.py +++ b/python/mesa_pd/data/ContactHistory.py @@ -31,7 +31,9 @@ class ContactHistory(): if not (prop['type'] == type and prop['name'] == name and prop['defValue'] == defValue): new_prop = create_contact_history_property(name, type, defValue=defValue) raise RuntimeError( - f"{TerminalColor.RED} property definition differs from previous one:\nPREVIOUS {prop}\nNEW {new_prop} {TerminalColor.DEFAULT}") + f"{TerminalColor.RED} property definition differs from previous one:\n" + f"PREVIOUS {prop}\n" + f"NEW {new_prop} {TerminalColor.DEFAULT}") print(f"{TerminalColor.YELLOW} reusing property: {name} {TerminalColor.DEFAULT}") def add_include(self, include): diff --git a/python/mesa_pd/data/ContactStorage.py b/python/mesa_pd/data/ContactStorage.py index 2d68864c9ea9e21de65bc3474ef34b81f63534b9..3b66d14b6986329220f5c38f48b5c1d72243ff42 100644 --- a/python/mesa_pd/data/ContactStorage.py +++ b/python/mesa_pd/data/ContactStorage.py @@ -32,7 +32,9 @@ class ContactStorage(): if not (prop['type'] == type and prop['name'] == name and prop['defValue'] == defValue): new_prop = create_contact_storage_property(name, type, defValue=defValue) raise RuntimeError( - f"{TerminalColor.RED} property definition differs from previous one:\nPREVIOUS {prop}\nNEW {new_prop} {TerminalColor.DEFAULT}") + f"{TerminalColor.RED} property definition differs from previous one:\n" + f"PREVIOUS {prop}\n" + f"NEW {new_prop} {TerminalColor.DEFAULT}") print(f"{TerminalColor.YELLOW} reusing property: {name} {TerminalColor.DEFAULT}") def add_include(self, include): diff --git a/python/mesa_pd/data/ParticleStorage.py b/python/mesa_pd/data/ParticleStorage.py index 5571f95581ef7db82a3015218618e6bdd1d5e43a..c52e384948ae86bc7340019f874388097289243f 100644 --- a/python/mesa_pd/data/ParticleStorage.py +++ b/python/mesa_pd/data/ParticleStorage.py @@ -72,7 +72,9 @@ class ParticleStorage(): if not (prop['type'] == type and prop['name'] == name and prop['defValue'] == defValue): new_prop = create_particle_property(name, type, defValue=defValue, syncMode=syncMode) raise RuntimeError( - f"{TerminalColor.RED} property definition differs from previous one:\nPREVIOUS {prop}\nNEW {new_prop} {TerminalColor.DEFAULT}") + f"{TerminalColor.RED} property definition differs from previous one:\n" + f"PREVIOUS {prop}\n" + f"NEW {new_prop} {TerminalColor.DEFAULT}") print(f"{TerminalColor.YELLOW} reusing particle property: {name} {TerminalColor.DEFAULT}") def add_include(self, include): diff --git a/python/mesa_pd/kernel/DetectAndStoreContacts.py b/python/mesa_pd/kernel/DetectAndStoreContacts.py index 4bcf797128ac2bb9f164d46c8d3c8e4ba98c6e7c..36d00aa7772e241144a8a3937278c3b87dbf695e 100644 --- a/python/mesa_pd/kernel/DetectAndStoreContacts.py +++ b/python/mesa_pd/kernel/DetectAndStoreContacts.py @@ -7,11 +7,15 @@ from mesa_pd.utility import generate_file class DetectAndStoreContacts: def __init__(self): - self.context = {'interface': [create_access("uid", "walberla::id_t", access="g"), - create_access("flags", "walberla::mesa_pd::data::particle_flags::FlagT", access="g"), - create_access("position", "walberla::mesa_pd::Vec3", access="g"), - create_access("rotation", "walberla::mesa_pd::Rot3", access="g"), - create_access("shape", "BaseShape*", access="g")]} + self.context = { + 'interface': [ + create_access("uid", "walberla::id_t", access="g"), + create_access("flags", "walberla::mesa_pd::data::particle_flags::FlagT", access="g"), + create_access("position", "walberla::mesa_pd::Vec3", access="g"), + create_access("rotation", "walberla::mesa_pd::Rot3", access="g"), + create_access("shape", "BaseShape*", access="g") + ] + } def generate(self, module): ctx = {'module': module, **self.context} diff --git a/python/mesa_pd/kernel/ExplicitEuler.py b/python/mesa_pd/kernel/ExplicitEuler.py index 6a18b0e508982c889673d43514e770f903c2d6ed..1b51adb853ddbcf7174c1b2c3a23c48c641ff619 100644 --- a/python/mesa_pd/kernel/ExplicitEuler.py +++ b/python/mesa_pd/kernel/ExplicitEuler.py @@ -6,12 +6,15 @@ from mesa_pd.utility import generate_file class ExplicitEuler: def __init__(self, integrate_rotation=True): - self.context = {'bIntegrateRotation': integrate_rotation, 'interface': []} - self.context['interface'].append(create_access("position", "walberla::mesa_pd::Vec3", access="gs")) - self.context['interface'].append(create_access("linearVelocity", "walberla::mesa_pd::Vec3", access="gs")) - self.context['interface'].append(create_access("invMass", "walberla::real_t", access="g")) - self.context['interface'].append(create_access("force", "walberla::mesa_pd::Vec3", access="gs")) - self.context['interface'].append(create_access("flags", "walberla::mesa_pd::data::particle_flags::FlagT", access="g")) + self.context = {'bIntegrateRotation': integrate_rotation, + 'interface': [ + create_access("position", "walberla::mesa_pd::Vec3", access="gs"), + create_access("linearVelocity", "walberla::mesa_pd::Vec3", access="gs"), + create_access("invMass", "walberla::real_t", access="g"), + create_access("force", "walberla::mesa_pd::Vec3", access="gs"), + create_access("flags", "walberla::mesa_pd::data::particle_flags::FlagT", access="g") + ] + } if integrate_rotation: self.context['interface'].append(create_access("rotation", "walberla::mesa_pd::Rot3", access="gs")) @@ -25,6 +28,7 @@ class ExplicitEuler: ctx["InterfaceTestName"] = "ExplicitEulerInterfaceCheck" ctx["KernelInclude"] = "kernel/ExplicitEuler.h" - ctx["ExplicitInstantiation"] = "template void kernel::ExplicitEuler::operator()(const size_t p_idx1, Accessor& ac) const;" + ctx["ExplicitInstantiation"] = \ + "template void kernel::ExplicitEuler::operator()(const size_t p_idx1, Accessor& ac) const;" generate_file(module['test_path'], 'tests/CheckInterface.templ.cpp', ctx, 'kernel/interfaces/ExplicitEulerInterfaceCheck.cpp') diff --git a/python/mesa_pd/kernel/ForceLJ.py b/python/mesa_pd/kernel/ForceLJ.py index 45c22f298a655fd5828b335e99d84e9f4fc92557..5d0f539179644b48d95587dc7eb7812ab568ea1f 100644 --- a/python/mesa_pd/kernel/ForceLJ.py +++ b/python/mesa_pd/kernel/ForceLJ.py @@ -6,19 +6,26 @@ from mesa_pd.utility import generate_file class ForceLJ: def __init__(self): - self.context = {'interface': []} - self.context['interface'].append(create_access("position", "walberla::mesa_pd::Vec3", access="g")) - self.context['interface'].append(create_access("force", "walberla::mesa_pd::Vec3", access="r")) - self.context['interface'].append(create_access("type", "uint_t", access="g")) + self.context = { + 'interface': [ + create_access("position", "walberla::mesa_pd::Vec3", access="g"), + create_access("force", "walberla::mesa_pd::Vec3", access="r"), + create_access("type", "uint_t", access="g") + ] + } def generate(self, module): - ctx = {'module': module, **self.context} - ctx["parameters"] = ["epsilon", "sigma"] + ctx = { + 'module': module, + **self.context, + "parameters": ["epsilon", "sigma"] + } generate_file(module['module_path'], 'kernel/ForceLJ.templ.h', ctx) ctx["InterfaceTestName"] = "ForceLJInterfaceCheck" ctx["KernelInclude"] = "kernel/ForceLJ.h" - ctx["ExplicitInstantiation"] = "template void kernel::ForceLJ::operator()(const size_t p_idx1, const size_t p_idx2, Accessor& ac) const;" + ctx["ExplicitInstantiation"] = \ + "template void kernel::ForceLJ::operator()(const size_t p_idx1, const size_t p_idx2, Accessor& ac) const;" generate_file(module['test_path'], 'tests/CheckInterface.templ.cpp', ctx, 'kernel/interfaces/ForceLJInterfaceCheck.cpp') diff --git a/python/mesa_pd/kernel/HeatConduction.py b/python/mesa_pd/kernel/HeatConduction.py index 1135cf1998bf735cdd5801756a43876ff31caae6..f197206c826e28391a99b1986f9d599c174a13ad 100644 --- a/python/mesa_pd/kernel/HeatConduction.py +++ b/python/mesa_pd/kernel/HeatConduction.py @@ -6,10 +6,13 @@ from mesa_pd.utility import generate_file class HeatConduction: def __init__(self): - self.context = {'interface': []} - self.context['interface'].append(create_access("temperature", "walberla::real_t", access="g")) - self.context['interface'].append(create_access("heatFlux", "walberla::real_t", access="gsr")) - self.context['interface'].append(create_access("type", "uint_t", access="g")) + self.context = { + 'interface': [ + create_access("temperature", "walberla::real_t", access="g"), + create_access("heatFlux", "walberla::real_t", access="gsr"), + create_access("type", "uint_t", access="g") + ] + } def generate(self, module): ctx = {'module': module, @@ -20,6 +23,10 @@ class HeatConduction: ctx["InterfaceTestName"] = "HeatConductionInterfaceCheck" ctx["KernelInclude"] = "kernel/HeatConduction.h" - ctx["ExplicitInstantiation"] = "template void kernel::HeatConduction::operator()(const size_t p_idx1, const size_t p_idx2, Accessor& ac) const;" + ctx["ExplicitInstantiation"] = \ + "template void kernel::HeatConduction::operator()(" \ + "const size_t p_idx1, " \ + "const size_t p_idx2, " \ + "Accessor& ac) const;" generate_file(module['test_path'], 'tests/CheckInterface.templ.cpp', ctx, 'kernel/interfaces/HeatConductionInterfaceCheck.cpp') diff --git a/python/mesa_pd/kernel/SpringDashpot.py b/python/mesa_pd/kernel/SpringDashpot.py index 8b7a783b449be0dcf073650cb728572d1140499c..bc44b156e1172349d088111f54fe3c129e404396 100644 --- a/python/mesa_pd/kernel/SpringDashpot.py +++ b/python/mesa_pd/kernel/SpringDashpot.py @@ -24,7 +24,13 @@ class SpringDashpot: ctx["InterfaceTestName"] = "SpringDashpotInterfaceCheck" ctx["KernelInclude"] = "kernel/SpringDashpot.h" - ctx[ - "ExplicitInstantiation"] = "template void kernel::SpringDashpot::operator()(const size_t p_idx1, const size_t p_idx2, Accessor& ac, const Vec3& contactPoint, const Vec3& contactNormal, const real_t& penetrationDepth) const;" + ctx["ExplicitInstantiation"] = \ + "template void kernel::SpringDashpot::operator()(" \ + "const size_t p_idx1, " \ + "const size_t p_idx2, " \ + "Accessor& ac, " \ + "const Vec3& contactPoint, " \ + "const Vec3& contactNormal, " \ + "const real_t& penetrationDepth) const;" generate_file(module['test_path'], 'tests/CheckInterface.templ.cpp', ctx, 'kernel/interfaces/SpringDashpotInterfaceCheck.cpp') diff --git a/python/mesa_pd/kernel/TemperatureIntegration.py b/python/mesa_pd/kernel/TemperatureIntegration.py index 006eb37232df257eb42c5ac2c7d8be1c44ce72ab..817f9cf0ef70fe24c3f026be30e558070e4f4a16 100644 --- a/python/mesa_pd/kernel/TemperatureIntegration.py +++ b/python/mesa_pd/kernel/TemperatureIntegration.py @@ -6,20 +6,27 @@ from mesa_pd.utility import generate_file class TemperatureIntegration: def __init__(self): - self.context = {'interface': []} - self.context['interface'].append(create_access("temperature", "walberla::real_t", access="gs")) - self.context['interface'].append(create_access("heatFlux", "walberla::real_t", access="gs")) - self.context['interface'].append(create_access("invMass", "walberla::real_t", access="g")) - self.context['interface'].append(create_access("type", "uint_t", access="g")) + self.context = { + 'interface': [ + create_access("temperature", "walberla::real_t", access="gs"), + create_access("heatFlux", "walberla::real_t", access="gs"), + create_access("invMass", "walberla::real_t", access="g"), + create_access("type", "uint_t", access="g") + ] + } def generate(self, module): - ctx = {'module': module, **self.context} - ctx["parameters"] = ["invSpecificHeat"] + ctx = { + 'module': module, + **self.context, + "parameters": ["invSpecificHeat"] + } generate_file(module['module_path'], 'kernel/TemperatureIntegration.templ.h', ctx) ctx["InterfaceTestName"] = "TemperatureIntegrationInterfaceCheck" ctx["KernelInclude"] = "kernel/TemperatureIntegration.h" ctx[ - "ExplicitInstantiation"] = "template void kernel::TemperatureIntegration::operator()(const size_t p_idx1, Accessor& ac) const;" + "ExplicitInstantiation"] = \ + "template void kernel::TemperatureIntegration::operator()(const size_t p_idx1, Accessor& ac) const;" generate_file(module['test_path'], 'tests/CheckInterface.templ.cpp', ctx, 'kernel/interfaces/TemperatureIntegrationInterfaceCheck.cpp') diff --git a/python/mesa_pd/kernel/VelocityVerlet.py b/python/mesa_pd/kernel/VelocityVerlet.py index 7ec1320564a6c0c63a74fe834d60976c505a3001..1a31554cba85349fe7fba8fd755fbff62f540915 100644 --- a/python/mesa_pd/kernel/VelocityVerlet.py +++ b/python/mesa_pd/kernel/VelocityVerlet.py @@ -30,8 +30,12 @@ class VelocityVerlet: ctx["InterfaceTestName"] = "VelocityVerletInterfaceCheck" ctx["KernelInclude"] = "kernel/VelocityVerlet.h" - ctx[ - "ExplicitInstantiation"] = "template void kernel::VelocityVerletPreForceUpdate::operator()(const size_t p_idx1, Accessor& ac) const;\n" + \ - "template void kernel::VelocityVerletPostForceUpdate::operator()(const size_t p_idx1, Accessor& ac) const;" + ctx["ExplicitInstantiation"] = \ + "template void kernel::VelocityVerletPreForceUpdate::operator()(" \ + "const size_t p_idx1, " \ + "Accessor& ac) const;\n" + \ + "template void kernel::VelocityVerletPostForceUpdate::operator()(" \ + "const size_t p_idx1, " \ + "Accessor& ac) const;" generate_file(module['test_path'], 'tests/CheckInterface.templ.cpp', ctx, 'kernel/interfaces/VelocityVerletInterfaceCheck.cpp') diff --git a/python/mesa_pd/mpi/PropertyNotification.py b/python/mesa_pd/mpi/PropertyNotification.py index 0e027cd1e88c82b85fb2da394511a5f04cf3af66..4f034c20afc5eb02a7920dc1ba9070bbf3b961f0 100644 --- a/python/mesa_pd/mpi/PropertyNotification.py +++ b/python/mesa_pd/mpi/PropertyNotification.py @@ -5,7 +5,10 @@ from ..utility import find, generate_file, TerminalColor class PropertyNotification: def __init__(self, name): - self.context = {'name': name, 'properties': []} + self.context = { + 'name': name, + 'properties': [] + } def add_property(self, name, type, reset_value): prop = find(lambda x: x['name'] == name, self.context['properties']) @@ -15,9 +18,14 @@ class PropertyNotification: if not (prop['type'] == type and prop['name'] == name and prop['resetValue'] == reset_value): new_prop = {'name': name, 'type': type, 'resetValue': reset_value} raise RuntimeError( - f"{TerminalColor.RED} property definition differs from previous one:\nPREVIOUS {prop}\nNEW {new_prop} {TerminalColor.DEFAULT}") + f"{TerminalColor.RED} property definition differs from previous one:\n" + f"PREVIOUS {prop}\n" + f"NEW {new_prop} {TerminalColor.DEFAULT}") print(f"{TerminalColor.YELLOW} reusing property: {name} {TerminalColor.DEFAULT}") def generate(self, module): ctx = {'module': module, **self.context} - generate_file(module['module_path'], 'mpi/notifications/PropertyNotification.templ.h', ctx, f'mpi/notifications/{self.context["name"]}.h') + generate_file(module['module_path'], + 'mpi/notifications/PropertyNotification.templ.h', + ctx, + f'mpi/notifications/{self.context["name"]}.h')