Skip to content
Snippets Groups Projects
Commit 2d95fb9a authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

fixed smaller formatting issues in mesa_pd

parent 64d0d56d
No related merge requests found
Showing with 30 additions and 36 deletions
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
from pathlib import Path from pathlib import Path
import shutil import shutil
import os
class Module: class Module:
...@@ -32,14 +31,14 @@ class Module: ...@@ -32,14 +31,14 @@ class Module:
def rename(self): def rename(self):
for filename in (f for f in self.context['module_path'].glob('**/*') if f.is_file()): for filename in (f for f in self.context['module_path'].glob('**/*') if f.is_file()):
filedata = None filedata = None
#print(f'renaming module name: {filename}') # print(f'renaming module name: {filename}')
with open(filename, encoding="utf-8") as fin: with open(filename, encoding="utf-8") as fin:
filedata = fin.read() filedata = fin.read()
filedata = filedata.replace('mesa_pd', self.context['name']) filedata = filedata.replace('mesa_pd', self.context['name'])
with open(filename, 'w', encoding="utf-8") as fout: with open(filename, 'w', encoding="utf-8") as fout:
fout.write(filedata) fout.write(filedata)
def generate(self, folder_check=True): def generate(self, folder_check=True):
print(f"This operation will overwrite the content of: {self.context['module_path']}") print(f"This operation will overwrite the content of: {self.context['module_path']}")
......
from .Module import Module from .Module import Module
__all__ = ['Module'] __all__ = ['Module']
\ No newline at end of file
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import numpy as np
from ..utility import TerminalColor, find, generate_file from ..utility import TerminalColor, find, generate_file
...@@ -25,7 +24,7 @@ class ContactHistory(): ...@@ -25,7 +24,7 @@ class ContactHistory():
def add_property(self, name, type, defValue=""): def add_property(self, name, type, defValue=""):
prop = find(lambda x: x['name'] == name, self.context['properties']) prop = find(lambda x: x['name'] == name, self.context['properties'])
if (prop == None): if (prop is None):
# print(f"{TerminalColor.GREEN} creating property: {name} {TerminalColor.DEFAULT}") # print(f"{TerminalColor.GREEN} creating property: {name} {TerminalColor.DEFAULT}")
self.context['properties'].append(create_contact_history_property(name, type, defValue=defValue)) self.context['properties'].append(create_contact_history_property(name, type, defValue=defValue))
else: else:
...@@ -54,8 +53,7 @@ class ContactHistory(): ...@@ -54,8 +53,7 @@ class ContactHistory():
print("=" * 90) print("=" * 90)
def generate(self, module): def generate(self, module):
ctx = {} ctx = {'module': module}
ctx['module'] = module
ctx.update(self.context) ctx.update(self.context)
generate_file(module['module_path'], 'data/ContactHistory.templ.h', ctx, filename='data/ContactHistory.h') generate_file(module['module_path'], 'data/ContactHistory.templ.h', ctx, filename='data/ContactHistory.h')
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import numpy as np
from ..utility import TerminalColor, find, generate_file from ..utility import TerminalColor, find, generate_file
...@@ -26,7 +25,7 @@ class ContactStorage(): ...@@ -26,7 +25,7 @@ class ContactStorage():
def add_property(self, name, type, defValue=""): def add_property(self, name, type, defValue=""):
prop = find(lambda x: x['name'] == name, self.context['properties']) prop = find(lambda x: x['name'] == name, self.context['properties'])
if (prop == None): if (prop is None):
# print(f"{TerminalColor.GREEN} creating property: {name} {TerminalColor.DEFAULT}") # print(f"{TerminalColor.GREEN} creating property: {name} {TerminalColor.DEFAULT}")
self.context['properties'].append(create_contact_storage_property(name, type, defValue=defValue)) self.context['properties'].append(create_contact_storage_property(name, type, defValue=defValue))
else: else:
...@@ -55,8 +54,7 @@ class ContactStorage(): ...@@ -55,8 +54,7 @@ class ContactStorage():
print("=" * 90) print("=" * 90)
def generate(self, module): def generate(self, module):
ctx = {} ctx = {'module': module}
ctx['module'] = module
ctx.update(self.context) ctx.update(self.context)
generate_file(module['module_path'], 'data/ContactStorage.templ.h', ctx, filename='data/ContactStorage.h') generate_file(module['module_path'], 'data/ContactStorage.templ.h', ctx, filename='data/ContactStorage.h')
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import numpy as np
from ..utility import generate_file from ..utility import generate_file
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import numpy as np
from ..utility import find, TerminalColor, generate_file from ..utility import find, TerminalColor, generate_file
...@@ -27,8 +26,8 @@ def create_particle_property(name, type, access="grs", defValue="", syncMode="AL ...@@ -27,8 +26,8 @@ def create_particle_property(name, type, access="grs", defValue="", syncMode="AL
""" """
if (type == 'bool'): if (type == 'bool'):
raise RuntimeError(f"Due to flaws in the implementation of std::vector<bool>, bool is not supported as a " raise RuntimeError("Due to flaws in the implementation of std::vector<bool>, bool is not supported as a "
f"property type! Please use char instead.") "property type! Please use char instead.")
# sort access specifier and remove duplicates # sort access specifier and remove duplicates
foo = "".join(sorted(access)) foo = "".join(sorted(access))
...@@ -65,7 +64,7 @@ class ParticleStorage(): ...@@ -65,7 +64,7 @@ class ParticleStorage():
def add_property(self, name, type, access="grs", defValue="", syncMode="ALWAYS"): def add_property(self, name, type, access="grs", defValue="", syncMode="ALWAYS"):
prop = find(lambda x: x['name'] == name, self.context['properties']) prop = find(lambda x: x['name'] == name, self.context['properties'])
if (prop == None): if (prop is None):
# print(f"{TerminalColor.GREEN} creating particle property: {name} {TerminalColor.DEFAULT}") # print(f"{TerminalColor.GREEN} creating particle property: {name} {TerminalColor.DEFAULT}")
self.context['properties'].append( self.context['properties'].append(
create_particle_property(name, type, access=access, defValue=defValue, syncMode=syncMode)) create_particle_property(name, type, access=access, defValue=defValue, syncMode=syncMode))
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import numpy as np
from ..utility import generate_file from ..utility import generate_file
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import numpy as np
from ..utility import generate_file from ..utility import generate_file
......
...@@ -11,4 +11,5 @@ __all__ = ['ContactHistory', ...@@ -11,4 +11,5 @@ __all__ = ['ContactHistory',
'ContactStorage', 'ContactStorage',
'LinkedCells', 'LinkedCells',
'ParticleStorage', 'ParticleStorage',
'ShapeStorage',
'SparseLinkedCells'] 'SparseLinkedCells']
...@@ -5,7 +5,7 @@ from mesa_pd.utility import generate_file ...@@ -5,7 +5,7 @@ from mesa_pd.utility import generate_file
class VelocityVerlet: class VelocityVerlet:
def __init__(self, integrate_rotation = True): def __init__(self, integrate_rotation=True):
self.context = {'bIntegrateRotation': integrate_rotation, 'interface': []} 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("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("linearVelocity", "walberla::mesa_pd::Vec3", access="gs"))
......
...@@ -2,19 +2,20 @@ ...@@ -2,19 +2,20 @@
from ..utility import generate_file from ..utility import generate_file
class Notifications: class Notifications:
def __init__(self, particle_storage): def __init__(self, particle_storage):
self.ps = particle_storage self.ps = particle_storage
def generate(self, module): def generate(self, module):
ctx = {'module': module, 'particle' : self.ps.get_context()} ctx = {'module': module, 'particle': self.ps.get_context()}
generate_file(module['module_path'], 'mpi/notifications/ParseMessage.templ.h', ctx) generate_file(module['module_path'], 'mpi/notifications/ParseMessage.templ.h', ctx)
generate_file(module['module_path'], 'mpi/notifications/ParticleCopyNotification.templ.h', ctx) generate_file(module['module_path'], 'mpi/notifications/ParticleCopyNotification.templ.h', ctx)
generate_file(module['module_path'], 'mpi/notifications/ParticleGhostCopyNotification.templ.h', ctx) generate_file(module['module_path'], 'mpi/notifications/ParticleGhostCopyNotification.templ.h', ctx)
generate_file(module['module_path'], 'mpi/notifications/NewGhostParticleNotification.templ.h', ctx) generate_file(module['module_path'], 'mpi/notifications/NewGhostParticleNotification.templ.h', ctx)
generate_file(module['module_path'], 'mpi/notifications/ParticleMigrationNotification.templ.h', ctx) generate_file(module['module_path'], 'mpi/notifications/ParticleMigrationNotification.templ.h', ctx)
generate_file(module['module_path'], 'mpi/notifications/ParticleRemoteMigrationNotification.templ.h', ctx) generate_file(module['module_path'], 'mpi/notifications/ParticleRemoteMigrationNotification.templ.h', ctx)
generate_file(module['module_path'], 'mpi/notifications/ParticleRemovalInformationNotification.templ.h', ctx) generate_file(module['module_path'], 'mpi/notifications/ParticleRemovalInformationNotification.templ.h', ctx)
generate_file(module['module_path'], 'mpi/notifications/ParticleRemovalNotification.templ.h', ctx) generate_file(module['module_path'], 'mpi/notifications/ParticleRemovalNotification.templ.h', ctx)
generate_file(module['module_path'], 'mpi/notifications/ParticleUpdateNotification.templ.h', ctx) generate_file(module['module_path'], 'mpi/notifications/ParticleUpdateNotification.templ.h', ctx)
...@@ -9,7 +9,7 @@ class PropertyNotification: ...@@ -9,7 +9,7 @@ class PropertyNotification:
def add_property(self, name, type, reset_value): def add_property(self, name, type, reset_value):
prop = find(lambda x: x['name'] == name, self.context['properties']) prop = find(lambda x: x['name'] == name, self.context['properties'])
if (prop == None): if (prop is None):
self.context['properties'].append({'name': name, 'type': type, 'resetValue': reset_value}) self.context['properties'].append({'name': name, 'type': type, 'resetValue': reset_value})
else: else:
if not (prop['type'] == type and prop['name'] == name and prop['resetValue'] == reset_value): if not (prop['type'] == type and prop['name'] == name and prop['resetValue'] == reset_value):
......
...@@ -15,6 +15,7 @@ from .SyncNextNeighborsNoGhosts import SyncNextNeighborsNoGhosts ...@@ -15,6 +15,7 @@ from .SyncNextNeighborsNoGhosts import SyncNextNeighborsNoGhosts
__all__ = ['BroadcastProperty', __all__ = ['BroadcastProperty',
'ClearGhostOwnerSync', 'ClearGhostOwnerSync',
'ClearNextNeighborSync', 'ClearNextNeighborSync',
'Notifications',
'PropertyNotification', 'PropertyNotification',
'ReduceContactHistory', 'ReduceContactHistory',
'ReduceProperty', 'ReduceProperty',
......
...@@ -31,7 +31,7 @@ def get_jinja_environment(): ...@@ -31,7 +31,7 @@ def get_jinja_environment():
def generate_file(path, template, context={}, filename=None): def generate_file(path, template, context={}, filename=None):
if filename == None: if filename is None:
filename = template.replace(".templ", "") filename = template.replace(".templ", "")
env = get_jinja_environment() env = get_jinja_environment()
print(f"generating: {(path / filename)}") print(f"generating: {(path / filename)}")
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment