Skip to content
Snippets Groups Projects
Commit dc82794d authored by Jan Hönig's avatar Jan Hönig
Browse files

Merge branch 'mesapd_codegen' into 'master'

enable mesa_pd codegen for ci

See merge request walberla/walberla!292
parents 554cf1f3 d837db01
Branches
No related merge requests found
......@@ -25,6 +25,8 @@ stages:
- cmake --version
- ccache --version
- mpirun --version
- python3 --version
- python3 python/mesa_pd.py -y ..
- export CCACHE_BASEDIR=$CI_PROJECT_DIR
- mkdir $CI_PROJECT_DIR/build
- cd $CI_PROJECT_DIR/build
......
......@@ -11,6 +11,7 @@ import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate all necessary files for the waLBerla mesa_pd module.')
parser.add_argument('path', help='Where should the files be created?')
parser.add_argument('-y', action='store_true', help='Silent mode. Accept all questions with yes.')
args = parser.parse_args()
mpd = Module(args.path)
......@@ -122,4 +123,4 @@ if __name__ == '__main__':
mpd.add(mpi.SyncNextNeighbors(ps))
mpd.add(mpi.SyncNextNeighborsNoGhosts(ps))
mpd.generate()
mpd.generate(not args.y)
......@@ -30,21 +30,20 @@ class Module:
return component
def rename(self):
for root, dirnames, filenames in os.walk(self.context['module_path']):
for filename in filenames:
filedata = None
# print(f'renaming module name: {root}/{filename}')
with open(f'{root}/{filename}', 'r') as file:
filedata = file.read()
for filename in (f for f in self.context['module_path'].glob('**/*') if f.is_file()):
filedata = None
#print(f'renaming module name: {filename}')
with open(filename, encoding="utf-8") as fin:
filedata = fin.read()
filedata = filedata.replace('mesa_pd', self.context['name'])
filedata = filedata.replace('mesa_pd', self.context['name'])
with open(f'{root}/{filename}', 'w') as file:
file.write(filedata)
with open(filename, 'w', encoding="utf-8") as fout:
fout.write(filedata)
def generate(self, folder_check=True):
print(f"This operation will overwrite the content of: {self.context['module_path']}")
if (folder_check):
print(f"This operation will overwrite the content of: {self.context['module_path']}")
answer = input("Continue? (y to confirm)")
if (answer != "y"):
return
......@@ -52,11 +51,11 @@ class Module:
mesa_pd_folder = (Path(__file__).parents[2] / 'src' / 'mesa_pd').resolve()
if (mesa_pd_folder != self.context['module_path']):
if not self.context['module_path'].exists():
self.context['module_path'].mkdir()
self.context['module_path'].mkdir(parents=True)
shutil.rmtree(self.context['module_path'])
shutil.copytree(mesa_pd_folder, self.context['module_path'])
for d in self.components:
d.generate(self.context)
self.rename()
\ No newline at end of file
self.rename()
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