PropertyNotification.templ.h 3.89 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//======================================================================================================================
//
//  This file is part of waLBerla. waLBerla is free software: you can
//  redistribute it and/or modify it under the terms of the GNU General Public
//  License as published by the Free Software Foundation, either version 3 of
//  the License, or (at your option) any later version.
//
//  waLBerla is distributed in the hope that it will be useful, but WITHOUT
//  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
//  for more details.
//
//  You should have received a copy of the GNU General Public License along
//  with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
16
//! \file
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================

//======================================================================================================================
//
//  THIS FILE IS GENERATED - PLEASE CHANGE THE TEMPLATE !!!
//
//======================================================================================================================

#pragma once

#include <mesa_pd/data/DataTypes.h>
#include <mesa_pd/data/ParticleStorage.h>
#include <mesa_pd/mpi/notifications/NotificationType.h>
32
#include <mesa_pd/mpi/notifications/reset.h>
33
34
35
36
37
38
39
40
41

#include <core/mpi/Datatype.h>
#include <core/mpi/RecvBuffer.h>
#include <core/mpi/SendBuffer.h>

namespace walberla {
namespace mesa_pd {

/**
42
 * Transmits force and torque information.
43
 */
44
class {{name}}
45
46
47
48
49
{
public:
   struct Parameters
   {
      id_t uid_;
50
51
52
      {%- for prop in properties %}
      {{prop.type}} {{prop.name}}_;
      {%- endfor %}
53
54
   };

55
   inline explicit {{name}}( const data::Particle& p ) : p_(p) {}
56
57
58
59

   const data::Particle& p_;
};

60
template <>
61
void reset<{{name}}>(data::Particle& p)
62
{
63
64
65
   {%- for prop in properties %}
   p.set{{prop.name | capFirst}}( {{prop.resetValue}} );
   {%- endfor %}
66
67
}

68
void reduce(data::Particle&& p, const {{name}}::Parameters& objparam)
69
{
70
71
72
   {%- for prop in properties %}
   p.get{{prop.name | capFirst}}Ref() += objparam.{{prop.name}}_;
   {%- endfor %}
73
74
}

75
void update(data::Particle&& p, const {{name}}::Parameters& objparam)
76
{
77
78
79
   {%- for prop in properties %}
   p.set{{prop.name | capFirst}}( objparam.{{prop.name}}_ );
   {%- endfor %}
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
}

}  // namespace mesa_pd
}  // namespace walberla

//======================================================================================================================
//
//  Send/Recv Buffer Serialization Specialization
//
//======================================================================================================================

namespace walberla {
namespace mpi {

template< typename T,    // Element type of SendBuffer
          typename G>    // Growth policy of SendBuffer
96
mpi::GenericSendBuffer<T,G>& operator<<( mpi::GenericSendBuffer<T,G> & buf, const mesa_pd::{{name}}& obj )
97
{
98
   buf.addDebugMarker( "pn" );
99
   buf << obj.p_.getUid();
100
101
102
   {%- for prop in properties %}
   buf << obj.p_.get{{prop.name | capFirst}}();
   {%- endfor %}
103
104
105
106
   return buf;
}

template< typename T>    // Element type  of RecvBuffer
107
mpi::GenericRecvBuffer<T>& operator>>( mpi::GenericRecvBuffer<T> & buf, mesa_pd::{{name}}::Parameters& objparam )
108
{
109
   buf.readDebugMarker( "pn" );
110
   buf >> objparam.uid_;
111
112
113
   {%- for prop in properties %}
   buf >> objparam.{{prop.name}}_;
   {%- endfor %}
114
115
116
117
   return buf;
}

template< >
118
struct BufferSizeTrait< mesa_pd::{{name}} > {
119
120
   static const bool constantSize = true;
   static const uint_t size = BufferSizeTrait<id_t>::size +
121
122
123
   {%- for prop in properties %}
                              BufferSizeTrait<{{prop.type}}>::size +
   {%- endfor %}
124
125
126
127
128
                              mpi::BUFFER_DEBUG_OVERHEAD;
};

} // mpi
} // walberla