mesa_pd.py 7.15 KB
Newer Older
1
2
3
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

Sebastian Eibl's avatar
Sebastian Eibl committed
4
from mesa_pd import Module
5
6
7
8
9
10
11
import mesa_pd.data as data
import mesa_pd.kernel as kernel
import mesa_pd.mpi as mpi

import argparse

if __name__ == '__main__':
Sebastian Eibl's avatar
Sebastian Eibl committed
12
13
    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?')
Sebastian Eibl's avatar
Sebastian Eibl committed
14
    parser.add_argument('-y', action='store_true', help='Silent mode. Accept all questions with yes.')
Sebastian Eibl's avatar
Sebastian Eibl committed
15
16
17
    args = parser.parse_args()

    mpd = Module(args.path)
18
    mpd.enable_openmp(False)
Sebastian Eibl's avatar
Sebastian Eibl committed
19
    ps = mpd.add(data.ParticleStorage())
20
    ps.set_shapes('Sphere', 'HalfSpace', 'CylindricalBoundary', 'Box', 'Ellipsoid', 'ConvexPolyhedron')
Sebastian Eibl's avatar
Sebastian Eibl committed
21
22
23
24
25
26
27
28
29
30
31
32
    ps.add_property("position", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS")
    ps.add_property("linearVelocity", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS")
    ps.add_property("invMass", "walberla::real_t", defValue="real_t(1)", syncMode="ON_GHOST_CREATION")
    ps.add_property("force", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="NEVER")
    ps.add_property("oldForce", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ON_OWNERSHIP_CHANGE")

    ps.add_property("shapeID", "size_t", defValue="", syncMode="ON_GHOST_CREATION")
    ps.add_property("rotation", "walberla::mesa_pd::Rot3", defValue="", syncMode="ALWAYS")
    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.add_property("oldTorque", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ON_OWNERSHIP_CHANGE")

33
    ps.add_property("radiusAtTemperature", "walberla::real_t", defValue="real_t(0)", syncMode="ALWAYS")
34

Sebastian Eibl's avatar
Sebastian Eibl committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    ps.add_include("blockforest/BlockForest.h")
    ps.add_property("currentBlock", "blockforest::BlockID", defValue="", syncMode="NEVER")

    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("nextParticle", "int", defValue="-1", syncMode="NEVER")

    ps.add_property("oldContactHistory", "std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>",
                    defValue="", syncMode="ALWAYS")
    ps.add_property("newContactHistory", "std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>",
                    defValue="", syncMode="NEVER")

    ps.add_property("temperature", "walberla::real_t", defValue="real_t(0)", syncMode="ALWAYS")
    ps.add_property("heatFlux", "walberla::real_t", defValue="real_t(0)", syncMode="NEVER")

    # Properties for HCSITS
    ps.add_property("dv", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="NEVER")
    ps.add_property("dw", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="NEVER")

    # Properties for lbm_mesapd_coupling:
57
58
59
60
61
62
63
64
    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")
Sebastian Eibl's avatar
Sebastian Eibl committed
65

66
67
68
69
    # properties for VBond model
    ps.add_property("clusterID", "int64_t", defValue="-1", syncMode="ON_GHOST_CREATION")
    ps.add_property("segmentID", "int64_t", defValue="-1", syncMode="ON_GHOST_CREATION")

Sebastian Eibl's avatar
Sebastian Eibl committed
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
    ch = mpd.add(data.ContactHistory())
    ch.add_property("tangentialSpringDisplacement", "walberla::mesa_pd::Vec3", defValue="real_t(0)")
    ch.add_property("isSticking", "bool", defValue="false")
    ch.add_property("impactVelocityMagnitude", "real_t", defValue="real_t(0)")

    cs = mpd.add(data.ContactStorage())
    cs.add_property("id1", "walberla::id_t", defValue="walberla::id_t(-1)")
    cs.add_property("id2", "walberla::id_t", defValue="walberla::id_t(-1)")
    cs.add_property("distance", "real_t", defValue="real_t(1)")
    cs.add_property("normal", "walberla::mesa_pd::Vec3", defValue="real_t(0)")
    cs.add_property("position", "walberla::mesa_pd::Vec3", defValue="real_t(0)")
    cs.add_property("t", "walberla::mesa_pd::Vec3", defValue="real_t(0)")
    cs.add_property("o", "walberla::mesa_pd::Vec3", defValue="real_t(0)")
    cs.add_property("r1", "walberla::mesa_pd::Vec3", defValue="real_t(0)")
    cs.add_property("r2", "walberla::mesa_pd::Vec3", defValue="real_t(0)")
    cs.add_property("mu", "real_t", defValue="real_t(0)")
    cs.add_property("p", "walberla::mesa_pd::Vec3", defValue="real_t(0)")
    cs.add_property("diag_nto", "walberla::mesa_pd::Mat3", defValue="real_t(0)")
    cs.add_property("diag_nto_inv", "walberla::mesa_pd::Mat3", defValue="real_t(0)")
    cs.add_property("diag_to_inv", "walberla::mesa_pd::Mat2", defValue="real_t(0)")
    cs.add_property("diag_n_inv", "real_t", defValue="real_t(0)")
    cs.add_property("p", "walberla::mesa_pd::Vec3", defValue="real_t(0)")

93
    mpd.add(data.HashGrids())
Sebastian Eibl's avatar
Sebastian Eibl committed
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
    mpd.add(data.LinkedCells())
    mpd.add(data.SparseLinkedCells())
    mpd.add(data.ShapeStorage(ps))

    mpd.add(kernel.DetectAndStoreContacts())
    mpd.add(kernel.DoubleCast(ps))
    mpd.add(kernel.ExplicitEuler())
    mpd.add(kernel.ForceLJ())
    mpd.add(kernel.HCSITSRelaxationStep())
    mpd.add(kernel.HeatConduction())
    mpd.add(kernel.InitParticlesForHCSITS())
    mpd.add(kernel.InitContactsForHCSITS())
    mpd.add(kernel.IntegrateParticlesHCSITS())
    mpd.add(kernel.InsertParticleIntoLinkedCells())
    mpd.add(kernel.InsertParticleIntoSparseLinkedCells())
    mpd.add(kernel.LinearSpringDashpot())
    mpd.add(kernel.NonLinearSpringDashpot())
111
    mpd.add(kernel.PFCDamping())
112
    mpd.add(kernel.SemiImplicitEuler())
Sebastian Eibl's avatar
Sebastian Eibl committed
113
114
    mpd.add(kernel.SingleCast(ps))
    mpd.add(kernel.SpringDashpot())
115
    mpd.add(kernel.SpringDashpotSpring())
Sebastian Eibl's avatar
Sebastian Eibl committed
116
117
118
119
    mpd.add(kernel.TemperatureIntegration())
    mpd.add(kernel.VelocityVerlet())

    mpd.add(mpi.BroadcastProperty())
Sebastian Eibl's avatar
Sebastian Eibl committed
120
    mpd.add(mpi.ClearGhostOwnerSync())
Sebastian Eibl's avatar
Sebastian Eibl committed
121
122
    mpd.add(mpi.ClearNextNeighborSync())
    mpd.add(mpi.Notifications(ps))
123
124
125
    ftn = mpd.add(mpi.PropertyNotification('ForceTorqueNotification'))
    ftn.add_property('force', 'mesa_pd::Vec3', 'Vec3(real_t(0))')
    ftn.add_property('torque', 'mesa_pd::Vec3', 'Vec3(real_t(0))')
126
127
128
    hftn = mpd.add(mpi.PropertyNotification('HydrodynamicForceTorqueNotification'))
    hftn.add_property('hydrodynamicForce', 'mesa_pd::Vec3', 'Vec3(real_t(0))')
    hftn.add_property('hydrodynamicTorque', 'mesa_pd::Vec3', 'Vec3(real_t(0))')
129
130
    hfn = mpd.add(mpi.PropertyNotification('HeatFluxNotification'))
    hfn.add_property('heatFlux', 'real_t', 'real_t(0)')
Sebastian Eibl's avatar
Sebastian Eibl committed
131
132
133
134
135
136
137
    mpd.add(mpi.ReduceContactHistory())
    mpd.add(mpi.ReduceProperty())
    mpd.add(mpi.ShapePackUnpack(ps))
    mpd.add(mpi.SyncGhostOwners(ps))
    mpd.add(mpi.SyncNextNeighbors(ps))
    mpd.add(mpi.SyncNextNeighborsNoGhosts(ps))

Sebastian Eibl's avatar
Sebastian Eibl committed
138
    mpd.generate(not args.y)