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

updated generation scripts for new interface

parent d3b385c5
Branches
Tags
No related merge requests found
#! /usr/bin/env python3 #! /usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from mesa_pd.accessor import Accessor from mesa_pd import Module
import mesa_pd.data as data import mesa_pd.data as data
import mesa_pd.kernel as kernel import mesa_pd.kernel as kernel
import mesa_pd.mpi as mpi import mesa_pd.mpi as mpi
import argparse import argparse
import numpy as np
import os
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate all necessary files for the waLBerla mesa_pd module.') 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('path', help='Where should the files be created?')
parser.add_argument("-f", "--force", help="Generate the files even if not inside a waLBerla directory.", args = parser.parse_args()
action="store_true")
args = parser.parse_args() mpd = Module(args.path)
ps = mpd.add(data.ParticleStorage())
if ((not os.path.isfile(args.path + "/src/walberla.h")) and (not args.force)):
raise RuntimeError(args.path + " is not the path to a waLBerla root directory! Specify -f to generate the files anyway.") ps.set_shapes("Sphere", "HalfSpace")
os.makedirs(args.path + "/src/mesa_pd/common", exist_ok = True) ps.add_property("position", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS")
os.makedirs(args.path + "/src/mesa_pd/data", exist_ok = True) ps.add_property("linearVelocity", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS")
os.makedirs(args.path + "/src/mesa_pd/domain", exist_ok = True) ps.add_property("invMass", "walberla::real_t", defValue="real_t(1)", syncMode="ON_GHOST_CREATION")
os.makedirs(args.path + "/src/mesa_pd/kernel", exist_ok = True) ps.add_property("force", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="NEVER")
os.makedirs(args.path + "/src/mesa_pd/mpi/notifications", exist_ok = True)
os.makedirs(args.path + "/src/mesa_pd/vtk", exist_ok = True) ps.add_property("shapeID", "size_t", defValue="", syncMode="ON_GHOST_CREATION")
ps.add_property("rotation", "walberla::mesa_pd::Rot3", defValue="", syncMode="ALWAYS")
shapes = ["Sphere", "HalfSpace"] ps.add_property("angularVelocity", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS")
ps.add_property("torque", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="NEVER")
ps = data.ParticleStorage()
ch = data.ContactHistory() ps.add_property("type", "uint_t", defValue="0", syncMode="ON_GHOST_CREATION")
lc = data.LinkedCells()
ss = data.ShapeStorage(ps, shapes) 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.addProperty("position", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS")
ps.addProperty("linearVelocity", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS") ps.add_include("blockforest/BlockForest.h")
ps.addProperty("invMass", "walberla::real_t", defValue="real_t(1)", syncMode="ON_GHOST_CREATION") ps.add_property("currentBlock", "blockforest::BlockID", defValue="", syncMode="NEVER")
ps.addProperty("force", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="NEVER")
mpd.add(data.LinkedCells())
ps.addProperty("shapeID", "size_t", defValue="", syncMode="ON_GHOST_CREATION") mpd.add(data.SparseLinkedCells())
ps.addProperty("rotation", "walberla::mesa_pd::Rot3", defValue="", syncMode="ALWAYS") mpd.add(data.ShapeStorage(ps))
ps.addProperty("angularVelocity", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS")
ps.addProperty("torque", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="NEVER") mpd.add(kernel.DoubleCast(ps))
mpd.add(kernel.ExplicitEuler())
ps.addProperty("type", "uint_t", defValue="0", syncMode="ON_GHOST_CREATION") mpd.add(kernel.ExplicitEulerWithShape())
mpd.add(kernel.ForceLJ())
ps.addProperty("flags", "walberla::mesa_pd::data::particle_flags::FlagT", defValue="", syncMode="ON_GHOST_CREATION") mpd.add(kernel.HeatConduction())
ps.addProperty("nextParticle", "int", defValue="-1", syncMode="NEVER") mpd.add(kernel.InsertParticleIntoLinkedCells())
mpd.add(kernel.LinearSpringDashpot())
ps.addInclude("blockforest/BlockForest.h") mpd.add(kernel.NonLinearSpringDashpot())
ps.addProperty("currentBlock", "blockforest::BlockID", defValue="", syncMode="NEVER") mpd.add(kernel.SingleCast(ps))
mpd.add(kernel.SpringDashpot())
kernels = [] mpd.add(kernel.TemperatureIntegration())
kernels.append( kernel.DoubleCast(shapes) ) mpd.add(kernel.VelocityVerlet())
kernels.append( kernel.ExplicitEuler() ) mpd.add(kernel.VelocityVerletWithShape())
kernels.append( kernel.ExplicitEulerWithShape() )
kernels.append( kernel.ForceLJ() ) mpd.add(mpi.BroadcastProperty())
kernels.append( kernel.HeatConduction() ) mpd.add(mpi.ClearGhostOwnerSync())
kernels.append( kernel.InsertParticleIntoLinkedCells() ) mpd.add(mpi.ClearNextNeighborSync())
kernels.append( kernel.LinearSpringDashpot() ) mpd.add(mpi.Notifications(ps))
kernels.append( kernel.NonLinearSpringDashpot() ) ftn = mpd.add(mpi.PropertyNotification('ForceTorqueNotification'))
kernels.append( kernel.SingleCast(shapes) ) ftn.add_property('force', 'mesa_pd::Vec3', 'Vec3(real_t(0))')
kernels.append( kernel.SpringDashpot() ) ftn.add_property('torque', 'mesa_pd::Vec3', 'Vec3(real_t(0))')
kernels.append( kernel.TemperatureIntegration() ) mpd.add(mpi.ReduceContactHistory())
kernels.append( kernel.VelocityVerlet() ) mpd.add(mpi.ReduceProperty())
kernels.append( kernel.VelocityVerletWithShape() ) mpd.add(mpi.ShapePackUnpack(ps))
mpd.add(mpi.SyncGhostOwners(ps))
ac = Accessor() mpd.add(mpi.SyncNextNeighbors(ps))
for k in kernels: mpd.add(mpi.SyncNextNeighborsNoGhosts(ps))
ac.mergeRequirements(k.getRequirements())
ac.printSummary() mpd.generate()
comm = []
comm.append(mpi.BroadcastProperty())
comm.append(mpi.ClearNextNeighborSync())
comm.append(mpi.ReduceContactHistory())
comm.append(mpi.ReduceProperty())
comm.append(mpi.SyncGhostOwners(ps))
comm.append(mpi.SyncNextNeighbors(ps))
ps.generate(args.path + "/src/mesa_pd/")
ch.generate(args.path + "/src/mesa_pd/")
lc.generate(args.path + "/src/mesa_pd/")
ss.generate(args.path + "/src/mesa_pd/")
for k in kernels:
k.generate(args.path + "/src/mesa_pd/")
for c in comm:
c.generate(args.path + "/src/mesa_pd/")
...@@ -7,8 +7,6 @@ import mesa_pd.kernel as kernel ...@@ -7,8 +7,6 @@ import mesa_pd.kernel as kernel
import mesa_pd.mpi as mpi import mesa_pd.mpi as mpi
import argparse import argparse
import numpy as np
import os
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate all necessary files for the waLBerla mesa_pd module.') parser = argparse.ArgumentParser(description='Generate all necessary files for the waLBerla mesa_pd module.')
......
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