VelocityVerlet.py 2.4 KB
Newer Older
1
2
# -*- coding: utf-8 -*-

Sebastian Eibl's avatar
Sebastian Eibl committed
3
4
from mesa_pd.accessor import create_access
from mesa_pd.utility import generate_file
5
6


Sebastian Eibl's avatar
Sebastian Eibl committed
7
class VelocityVerlet:
8
    def __init__(self, integrate_rotation=True):
9
        self.context = {'bIntegrateRotation': integrate_rotation, 'interface': []}
Sebastian Eibl's avatar
Sebastian Eibl committed
10
11
12
13
14
        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("invMass", "walberla::real_t", access="g"))
        self.context['interface'].append(create_access("force", "walberla::mesa_pd::Vec3", access="gs"))
        self.context['interface'].append(create_access("oldForce", "walberla::mesa_pd::Vec3", access="gs"))
15
16
17
18
19

        if integrate_rotation:
            self.context['interface'].append(create_access("rotation", "walberla::mesa_pd::Rot3", access="gs"))
            self.context['interface'].append(create_access("angularVelocity", "walberla::mesa_pd::Vec3", access="gs"))
            self.context['interface'].append(create_access("invInertiaBF", "walberla::mesa_pd::Mat3", access="g"))
20
            self.context['interface'].append(create_access("inertiaBF", "walberla::mesa_pd::Mat3", access="g"))
21
22
23
            self.context['interface'].append(create_access("torque", "walberla::mesa_pd::Vec3", access="gs"))
            self.context['interface'].append(create_access("oldTorque", "walberla::mesa_pd::Vec3", access="gs"))

Sebastian Eibl's avatar
Sebastian Eibl committed
24
25
        self.context['interface'].append(
            create_access("flags", "walberla::mesa_pd::data::particle_flags::FlagT", access="g"))
26

Sebastian Eibl's avatar
Sebastian Eibl committed
27
28
    def generate(self, module):
        ctx = {'module': module, **self.context}
29

Sebastian Eibl's avatar
Sebastian Eibl committed
30
        generate_file(module['module_path'], 'kernel/VelocityVerlet.templ.h', ctx)
31

Sebastian Eibl's avatar
Sebastian Eibl committed
32
33
        ctx["InterfaceTestName"] = "VelocityVerletInterfaceCheck"
        ctx["KernelInclude"] = "kernel/VelocityVerlet.h"
34
35
36
37
38
39
40
        ctx["ExplicitInstantiation"] = \
            "template void kernel::VelocityVerletPreForceUpdate::operator()(" \
            "const size_t p_idx1, " \
            "Accessor& ac) const;\n" + \
            "template void kernel::VelocityVerletPostForceUpdate::operator()(" \
            "const size_t p_idx1, " \
            "Accessor& ac) const;"
Sebastian Eibl's avatar
Sebastian Eibl committed
41
42
        generate_file(module['test_path'], 'tests/CheckInterface.templ.cpp', ctx,
                      'kernel/interfaces/VelocityVerletInterfaceCheck.cpp')