Commit 2d95fb9a authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

fixed smaller formatting issues in mesa_pd

parent 64d0d56d
Pipeline #25027 passed with stages
in 202 minutes and 5 seconds
......@@ -2,7 +2,6 @@
from pathlib import Path
import shutil
import os
class Module:
......@@ -32,14 +31,14 @@ class Module:
def rename(self):
for filename in (f for f in self.context['module_path'].glob('**/*') if f.is_file()):
filedata = None
#print(f'renaming module name: {filename}')
# print(f'renaming module name: {filename}')
with open(filename, encoding="utf-8") as fin:
filedata = fin.read()
filedata = fin.read()
filedata = filedata.replace('mesa_pd', self.context['name'])
with open(filename, 'w', encoding="utf-8") as fout:
fout.write(filedata)
fout.write(filedata)
def generate(self, folder_check=True):
print(f"This operation will overwrite the content of: {self.context['module_path']}")
......
from .Module import Module
__all__ = ['Module']
\ No newline at end of file
__all__ = ['Module']
# -*- coding: utf-8 -*-
import numpy as np
from ..utility import TerminalColor, find, generate_file
......@@ -25,7 +24,7 @@ class ContactHistory():
def add_property(self, name, type, defValue=""):
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}")
self.context['properties'].append(create_contact_history_property(name, type, defValue=defValue))
else:
......@@ -54,8 +53,7 @@ class ContactHistory():
print("=" * 90)
def generate(self, module):
ctx = {}
ctx['module'] = module
ctx = {'module': module}
ctx.update(self.context)
generate_file(module['module_path'], 'data/ContactHistory.templ.h', ctx, filename='data/ContactHistory.h')
......
# -*- coding: utf-8 -*-
import numpy as np
from ..utility import TerminalColor, find, generate_file
......@@ -26,7 +25,7 @@ class ContactStorage():
def add_property(self, name, type, defValue=""):
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}")
self.context['properties'].append(create_contact_storage_property(name, type, defValue=defValue))
else:
......@@ -55,8 +54,7 @@ class ContactStorage():
print("=" * 90)
def generate(self, module):
ctx = {}
ctx['module'] = module
ctx = {'module': module}
ctx.update(self.context)
generate_file(module['module_path'], 'data/ContactStorage.templ.h', ctx, filename='data/ContactStorage.h')
......
# -*- coding: utf-8 -*-
import numpy as np
from ..utility import generate_file
......
# -*- coding: utf-8 -*-
import numpy as np
from ..utility import find, TerminalColor, generate_file
......@@ -27,8 +26,8 @@ def create_particle_property(name, type, access="grs", defValue="", syncMode="AL
"""
if (type == 'bool'):
raise RuntimeError(f"Due to flaws in the implementation of std::vector<bool>, bool is not supported as a "
f"property type! Please use char instead.")
raise RuntimeError("Due to flaws in the implementation of std::vector<bool>, bool is not supported as a "
"property type! Please use char instead.")
# sort access specifier and remove duplicates
foo = "".join(sorted(access))
......@@ -65,7 +64,7 @@ class ParticleStorage():
def add_property(self, name, type, access="grs", defValue="", syncMode="ALWAYS"):
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}")
self.context['properties'].append(
create_particle_property(name, type, access=access, defValue=defValue, syncMode=syncMode))
......
# -*- coding: utf-8 -*-
import numpy as np
from ..utility import generate_file
......
# -*- coding: utf-8 -*-
import numpy as np
from ..utility import generate_file
......
......@@ -11,4 +11,5 @@ __all__ = ['ContactHistory',
'ContactStorage',
'LinkedCells',
'ParticleStorage',
'ShapeStorage',
'SparseLinkedCells']
......@@ -5,7 +5,7 @@ from mesa_pd.utility import generate_file
class VelocityVerlet:
def __init__(self, integrate_rotation = True):
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"))
......
......@@ -2,19 +2,20 @@
from ..utility import generate_file
class Notifications:
def __init__(self, particle_storage):
self.ps = particle_storage
def __init__(self, particle_storage):
self.ps = particle_storage
def generate(self, module):
ctx = {'module': module, 'particle' : self.ps.get_context()}
def generate(self, module):
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/ParticleCopyNotification.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/ParticleMigrationNotification.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/ParticleRemovalNotification.templ.h', ctx)
generate_file(module['module_path'], 'mpi/notifications/ParticleUpdateNotification.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/ParticleGhostCopyNotification.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/ParticleRemoteMigrationNotification.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/ParticleUpdateNotification.templ.h', ctx)
......@@ -9,7 +9,7 @@ class PropertyNotification:
def add_property(self, name, type, reset_value):
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})
else:
if not (prop['type'] == type and prop['name'] == name and prop['resetValue'] == reset_value):
......
......@@ -15,6 +15,7 @@ from .SyncNextNeighborsNoGhosts import SyncNextNeighborsNoGhosts
__all__ = ['BroadcastProperty',
'ClearGhostOwnerSync',
'ClearNextNeighborSync',
'Notifications',
'PropertyNotification',
'ReduceContactHistory',
'ReduceProperty',
......
......@@ -31,7 +31,7 @@ def get_jinja_environment():
def generate_file(path, template, context={}, filename=None):
if filename == None:
if filename is None:
filename = template.replace(".templ", "")
env = get_jinja_environment()
print(f"generating: {(path / filename)}")
......
Markdown is supported
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