aboutsummaryrefslogtreecommitdiffstats
path: root/test/FrontendC++/2008-10-29-WrongOffset.cpp
blob: 1b3be2132b185bdcf7c5a4ae0de9381e6103bb26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
// RUN: %llvmgxx %s -c -o /dev/null
// PR2917

#include <complex>
template < int Dim, class T, class EngineTag > class Engine;
template < class Subject, class Sub1, bool SV > struct View1Implementation;
template < class LayoutTag, class PatchTag > struct MultiPatch;
template < class LayoutTag, class PatchTag, int Dim2 > struct MultiPatchView;
template < class Engine, class SubDomain > struct NewEngine
{
};
template < class T > class DomainTraits;
template < class DomT, class T, int Dim > struct DomainTraitsDomain
{
  typedef DomT NewDomain1_t;
};
template < int Dim > class Interval;
template < int Dim > class Loc;
template < class DT > class DomainBase
{
};

template < int Dim, class DT > class Domain:public DomainBase < DT >
{
};
template < int Dim > struct DomainTraits <Interval < Dim >
  >:public DomainTraitsDomain < Interval < Dim >, int, Dim >
{
  enum
  {
    singleValued = false
  };
};
template < class T1 > struct NewDomain1
{
  typedef typename DomainTraits < T1 >::NewDomain1_t SliceType_t;
};
template < class Domain, class Sub > struct TemporaryNewDomain1
{
  typedef typename NewDomain1 < Sub >::SliceType_t SliceType_t;
};
template < int Dim > class Interval:public Domain < Dim,
  DomainTraits < Interval < Dim > > >
{
};
template < int Dim > class GuardLayers
{
};
template < class T > class Observer
{
};

template < class T > class Observable
{
private:T & observed_m;
  int count_m;
};

class RefCounted
{
};
template < class T > class RefCountedPtr
{
public:typedef RefCountedPtr < T > This_t;
  RefCountedPtr (T * const pT):ptr_m (pT)
  {
  }
  inline T *operator-> () const
  {
  }
  T *ptr_m;
};

template < class Dom, class T > class DomainMap
{
};

template < class LayoutTag, int Dim > struct MultiPatchLayoutTraits
{
};
template < int Dim > class LayoutBaseData
{
public:typedef Interval < Dim > Domain_t;
  Domain_t domain_m;
};
template < int Dim, class LBD > class LayoutBase
{
public:typedef LayoutBaseData < Dim > LayoutData_t;
  typedef typename LayoutData_t::Domain_t Domain_t;
  typedef GuardLayers < Dim > GuardLayers_t;
  inline const Domain_t & domain () const
  {
    return pdata_m->domain_m;
  }
  inline const Domain_t & innerDomain () const
  {
  }
  inline GuardLayers_t externalGuards () const
  {
  }
  RefCountedPtr < LBD > pdata_m;
};
template < class Tag > struct Remote;
struct Brick
{
};
template < class Thing, class Sub > struct View1
{
};
template < int Dim, class T, class LayoutTag,
  class PatchTag > struct NewEngine <Engine < Dim, T, MultiPatch < LayoutTag,
  PatchTag > >, Interval < Dim > >
{
  typedef Engine < Dim, T, MultiPatchView < LayoutTag, PatchTag,
    Dim > >Type_t;
};
template < int Dim, class T, class LayoutTag, class PatchTag,
  int Dim2 > struct NewEngine <Engine < Dim, T, MultiPatchView < LayoutTag,
  PatchTag, Dim2 > >, Interval < Dim > >
{
  typedef Engine < Dim, T, MultiPatchView < LayoutTag, PatchTag,
    Dim2 > >Type_t;
};
template < int Dim, class T, class LayoutTag,
  class PatchTag > class Engine < Dim, T, MultiPatch < LayoutTag,
  PatchTag > >:public Observer < typename MultiPatchLayoutTraits < LayoutTag,
  Dim >::Layout_t >
{
public:typedef MultiPatch < LayoutTag, PatchTag > Tag_t;
  typedef Interval < Dim > Domain_t;
};
template < int Dim, class T, class LayoutTag, class PatchTag,
  int Dim2 > class Engine < Dim, T, MultiPatchView < LayoutTag, PatchTag,
  Dim2 > >
{
public:typedef MultiPatchView < LayoutTag, PatchTag, Dim2 > Tag_t;
  typedef Interval < Dim > Domain_t;
  typedef T Element_t;
  enum
  {
    dimensions = Dim
  };
};
class Full;
template < int Dim, class T = double, class EngineTag = Full > class Vector {
};

template < int Dim > inline Interval < Dim >
shrinkRight (const Interval < Dim > &dom, int s)
{
}

template < int Dim > class GridLayout;
struct GridTag
{
};
template < int Dim > struct MultiPatchLayoutTraits <GridTag, Dim >
{
  typedef GridLayout < Dim > Layout_t;
};
template < int Dim > class GridLayoutData:public LayoutBaseData < Dim >,
  public RefCounted, public Observable < GridLayoutData < Dim > >
{
  typedef int AxisIndex_t;
  mutable DomainMap < Interval < 1 >, AxisIndex_t > mapAloc_m[Dim];
};
template < int Dim > class GridLayout:public LayoutBase < Dim,
  GridLayoutData < Dim > >, public Observable < GridLayout < Dim > >,
  public Observer < GridLayoutData < Dim > >
{
public:typedef GridLayout < Dim > This_t;
    GridLayout ();
};
template < class MeshTag, class T, class EngineTag > class Field;
enum CenteringType
{
  VertexType, EdgeType, FaceType, CellType
};
enum ContinuityType
{
  Continuous = 0, Discontinuous
};
template < int Dim > class Centering
{
public:typedef Loc < Dim > Orientation;
  inline int size () const
  {
  }
};
template < int Dim > const Centering < Dim >
canonicalCentering (const enum CenteringType type,
		    const enum ContinuityType discontinuous,
		    const int dimension = 0);
template < class Mesh, class T, class EngineTag > class FieldEngine
{
public:enum
  {
    dimensions = Mesh::dimensions
  };
  enum
  {
    Dim = dimensions
  };
  typedef Engine < Dim, T, EngineTag > Engine_t;
  typedef typename Engine_t::Domain_t Domain_t;
  typedef GuardLayers < Dim > GuardLayers_t;
template < class Layout2 > FieldEngine (const Centering < Dim > &centering, const Layout2 & layout, const Mesh & mesh, int materials = 1):num_materials_m (materials), centering_m (centering),
    stride_m (centering.size ()), physicalCellDomain_m (layout.domain ()),
    guards_m (layout.externalGuards ()), mesh_m (mesh)
  {
  }
  unsigned int num_materials_m;
  Centering < Dim > centering_m;
  int stride_m;
  Domain_t physicalCellDomain_m;
  GuardLayers_t guards_m;
  Mesh mesh_m;
};

template < class Subject > class SubFieldView;
template < class Mesh, class T,
  class EngineTag > class SubFieldView < Field < Mesh, T, EngineTag > >
{
public:typedef Field < Mesh, T, EngineTag > Type_t;
};

template < int Dim, class Mesh, class Domain > struct NewMeshTag
{
  typedef Mesh Type_t;
};
template < class Mesh, class T, class EngineTag,
  class Domain > struct View1Implementation <Field < Mesh, T, EngineTag >,
  Domain, false >
{
  typedef Field < Mesh, T, EngineTag > Subject_t;
  typedef typename Subject_t::Engine_t Engine_t;
  typedef typename NewEngine < Engine_t, Domain >::Type_t NewEngine_t;
  typedef typename NewEngine_t::Element_t NewT_t;
  typedef typename NewEngine_t::Tag_t NewEngineTag_t;
  typedef typename NewMeshTag < NewEngine_t::dimensions, Mesh,
    Domain >::Type_t NewMeshTag_t;
  typedef Field < NewMeshTag_t, NewT_t, NewEngineTag_t > Type_t;
};
template < class Mesh, class T, class EngineTag,
  class Sub1 > struct View1 <Field < Mesh, T, EngineTag >, Sub1 >
{
  typedef Field < Mesh, T, EngineTag > Subject_t;
  typedef typename Subject_t::Domain_t Domain_t;
  typedef TemporaryNewDomain1 < Domain_t, Sub1 > NewDomain_t;
  typedef typename NewDomain_t::SliceType_t SDomain_t;
  enum
  {
    sv = DomainTraits < SDomain_t >::singleValued
  };
  typedef View1Implementation < Subject_t, SDomain_t, sv > Dispatch_t;
  typedef typename Dispatch_t::Type_t Type_t;
};
template < class Mesh, class T = double, class EngineTag = Brick > class Field {
public:typedef Mesh MeshTag_t;
  typedef Mesh Mesh_t;
  typedef Field < Mesh, T, EngineTag > This_t;
  typedef FieldEngine < Mesh, T, EngineTag > FieldEngine_t;
  enum
  {
    dimensions = FieldEngine_t::dimensions
  };
  typedef Engine < dimensions, T, EngineTag > Engine_t;
  typedef typename Engine_t::Domain_t Domain_t;
  typedef Centering < dimensions > Centering_t;
  template < class Layout2 > Field (const Centering_t & centering,
				    const Layout2 & layout,
				    const Mesh_t &
				    mesh):fieldEngine_m (centering, layout,
							 mesh)
  {
  }
  inline typename SubFieldView < This_t >::Type_t center (int c) const
  {
  }
  inline typename View1 < This_t, Domain_t >::Type_t all () const
  {
  }
  template < class T1 > const This_t & operator= (const T1 & rhs) const
  {
  }
private:  FieldEngine_t fieldEngine_m;
};

struct UniformRectilinearTag
{
};
struct CartesianTag
{
};
template < class MeshTraits > struct CartesianURM;
template < class MeshTraits > class UniformRectilinearMeshData;
template < class MeshTraits > class UniformRectilinearMesh;
template < int Dim, typename T = double, class MeshTag =
  UniformRectilinearTag, class CoordinateSystemTag = CartesianTag, int CDim =
  Dim > struct MeshTraits;
template < int Dim, typename T, class MeshTag, class CoordinateSystemTag,
  int CDim > struct MeshTraitsBase
{
  typedef MeshTraits < Dim, T, MeshTag, CoordinateSystemTag,
    CDim > MeshTraits_t;
  enum
  {
    dimensions = Dim
  };
  typedef Vector < CDim, T > PointType_t;
};
template < int Dim, typename T, int CDim > struct MeshTraits <Dim, T,
  UniformRectilinearTag, CartesianTag, CDim >:public MeshTraitsBase < Dim, T,
  UniformRectilinearTag, CartesianTag, CDim >
{
  typedef typename MeshTraitsBase < Dim, T, UniformRectilinearTag,
    CartesianTag, CDim >::MeshTraits_t MeshTraits_t;
  typedef CartesianURM < MeshTraits_t > CoordinateSystem_t;
  typedef UniformRectilinearMeshData < MeshTraits_t > MeshData_t;
  typedef UniformRectilinearMesh < MeshTraits_t > Mesh_t;
  typedef Vector < CDim, T > SpacingsType_t;
};
template < int Dim > class NoMeshData:public RefCounted
{
public:NoMeshData ()
  {
  }
  template < class Layout >
    explicit NoMeshData (const Layout &
			 layout):physicalVertexDomain_m (layout.
							 innerDomain ()),
    physicalCellDomain_m (shrinkRight (physicalVertexDomain_m, 1)),
    totalVertexDomain_m (layout.domain ()),
    totalCellDomain_m (shrinkRight (totalVertexDomain_m, 1))
  {
  }
private:Interval < Dim > physicalVertexDomain_m, physicalCellDomain_m;
  Interval < Dim > totalVertexDomain_m, totalCellDomain_m;
};

template < class MeshTraits > class UniformRectilinearMeshData:public NoMeshData <
  MeshTraits::
  dimensions >
{
public:typedef typename
    MeshTraits::MeshData_t
    MeshData_t;
  typedef typename
    MeshTraits::PointType_t
    PointType_t;
  typedef typename
    MeshTraits::SpacingsType_t
    SpacingsType_t;
  enum
  {
    dimensions = MeshTraits::dimensions
  };
  template < class Layout > UniformRectilinearMeshData (const Layout & layout,
							const PointType_t &
							origin,
							const SpacingsType_t &
							spacings):
    NoMeshData <
  dimensions > (layout),
  origin_m (origin),
  spacings_m (spacings)
  {
  }
private:PointType_t origin_m;
  SpacingsType_t
    spacings_m;
};

template < class MeshTraits > class UniformRectilinearMesh:public MeshTraits::
  CoordinateSystem_t
{
public:typedef MeshTraits
    MeshTraits_t;
  typedef typename
    MeshTraits::MeshData_t
    MeshData_t;
  typedef typename
    MeshTraits::PointType_t
    PointType_t;
  typedef typename
    MeshTraits::SpacingsType_t
    SpacingsType_t;
  enum
  {
    dimensions = MeshTraits::dimensions
  };
  template < class Layout >
    inline UniformRectilinearMesh (const Layout & layout,
				   const PointType_t & origin,
				   const SpacingsType_t & spacings):
  data_m (new MeshData_t (layout, origin, spacings))
  {
  }
private:RefCountedPtr < MeshData_t > data_m;
};

template < class MeshTraits > struct GenericURM
{
};
template < class MeshTraits > struct CartesianURM:
  public
  GenericURM <
  MeshTraits >
{
};
template < int
  dim,
  class
  MeshTag = UniformRectilinearTag, class CoordinateSystemTag = CartesianTag > struct ParallelTraits {
  enum
  {
    Dim = dim
  };
  typedef
    GridLayout <
    dim >
    Layout_t;
  typedef
    MeshTraits <
    dim, double,
    MeshTag,
    CoordinateSystemTag >
    MeshTraits_t;
  typedef typename
    MeshTraits_t::Mesh_t
    Mesh_t;
  typedef
    MultiPatch <
    GridTag,
    Remote <
  Brick > >
    Engine_t;
};
template < class ComputeTraits > struct RhalkTraits:
  public
  ComputeTraits
{
  typedef typename
    ComputeTraits::Mesh_t
    Mesh_t;
  typedef typename
    ComputeTraits::Engine_t
    Engine_t;
  enum
  {
    Dim = ComputeTraits::Dim
  };
  typedef
    Centering <
    Dim >
    Centering_t;
  typedef typename
    Mesh_t::SpacingsType_t
    Spacings_t;
  typedef
    Field <
    Mesh_t, double,
    Engine_t >
    Scalar_t;
};
enum
{
  Dim = 3
};
typedef
  RhalkTraits <
  ParallelTraits <
  Dim,
  UniformRectilinearTag,
CartesianTag > >
  Traits_t;
Vector < Dim > origin;
Traits_t::Spacings_t spacings;
int
main (int argc, char **argv)
{
  Traits_t::Layout_t layout;
  Traits_t::Mesh_t mesh (layout, origin, spacings);
  Traits_t::Centering_t face =
    canonicalCentering < Traits_t::Dim > (FaceType, Continuous);
  Traits_t::Scalar_t v (face, layout, mesh);
  for (int i = 0; i < Dim; ++i)
    v.center (i).all () = std::numeric_limits < double >::signaling_NaN ();
}