1 // RUN: %llvmgxx %s -S -o /dev/null 2 // PR2917 3 4 #include <complex> 5 template < int Dim, class T, class EngineTag > class Engine; 6 template < class Subject, class Sub1, bool SV > struct View1Implementation; 7 template < class LayoutTag, class PatchTag > struct MultiPatch; 8 template < class LayoutTag, class PatchTag, int Dim2 > struct MultiPatchView; 9 template < class Engine, class SubDomain > struct NewEngine 10 { 11 }; 12 template < class T > class DomainTraits; 13 template < class DomT, class T, int Dim > struct DomainTraitsDomain 14 { 15 typedef DomT NewDomain1_t; 16 }; 17 template < int Dim > class Interval; 18 template < int Dim > class Loc; 19 template < class DT > class DomainBase 20 { 21 }; 22 23 template < int Dim, class DT > class Domain:public DomainBase < DT > 24 { 25 }; 26 template < int Dim > struct DomainTraits <Interval < Dim > 27 >:public DomainTraitsDomain < Interval < Dim >, int, Dim > 28 { 29 enum 30 { 31 singleValued = false 32 }; 33 }; 34 template < class T1 > struct NewDomain1 35 { 36 typedef typename DomainTraits < T1 >::NewDomain1_t SliceType_t; 37 }; 38 template < class Domain, class Sub > struct TemporaryNewDomain1 39 { 40 typedef typename NewDomain1 < Sub >::SliceType_t SliceType_t; 41 }; 42 template < int Dim > class Interval:public Domain < Dim, 43 DomainTraits < Interval < Dim > > > 44 { 45 }; 46 template < int Dim > class GuardLayers 47 { 48 }; 49 template < class T > class Observer 50 { 51 }; 52 53 template < class T > class Observable 54 { 55 private:T & observed_m; 56 int count_m; 57 }; 58 59 class RefCounted 60 { 61 }; 62 template < class T > class RefCountedPtr 63 { 64 public:typedef RefCountedPtr < T > This_t; 65 RefCountedPtr (T * const pT):ptr_m (pT) 66 { 67 } 68 inline T *operator-> () const 69 { 70 } 71 T *ptr_m; 72 }; 73 74 template < class Dom, class T > class DomainMap 75 { 76 }; 77 78 template < class LayoutTag, int Dim > struct MultiPatchLayoutTraits 79 { 80 }; 81 template < int Dim > class LayoutBaseData 82 { 83 public:typedef Interval < Dim > Domain_t; 84 Domain_t domain_m; 85 }; 86 template < int Dim, class LBD > class LayoutBase 87 { 88 public:typedef LayoutBaseData < Dim > LayoutData_t; 89 typedef typename LayoutData_t::Domain_t Domain_t; 90 typedef GuardLayers < Dim > GuardLayers_t; 91 inline const Domain_t & domain () const 92 { 93 return pdata_m->domain_m; 94 } 95 inline const Domain_t & innerDomain () const 96 { 97 } 98 inline GuardLayers_t externalGuards () const 99 { 100 } 101 RefCountedPtr < LBD > pdata_m; 102 }; 103 template < class Tag > struct Remote; 104 struct Brick 105 { 106 }; 107 template < class Thing, class Sub > struct View1 108 { 109 }; 110 template < int Dim, class T, class LayoutTag, 111 class PatchTag > struct NewEngine <Engine < Dim, T, MultiPatch < LayoutTag, 112 PatchTag > >, Interval < Dim > > 113 { 114 typedef Engine < Dim, T, MultiPatchView < LayoutTag, PatchTag, 115 Dim > >Type_t; 116 }; 117 template < int Dim, class T, class LayoutTag, class PatchTag, 118 int Dim2 > struct NewEngine <Engine < Dim, T, MultiPatchView < LayoutTag, 119 PatchTag, Dim2 > >, Interval < Dim > > 120 { 121 typedef Engine < Dim, T, MultiPatchView < LayoutTag, PatchTag, 122 Dim2 > >Type_t; 123 }; 124 template < int Dim, class T, class LayoutTag, 125 class PatchTag > class Engine < Dim, T, MultiPatch < LayoutTag, 126 PatchTag > >:public Observer < typename MultiPatchLayoutTraits < LayoutTag, 127 Dim >::Layout_t > 128 { 129 public:typedef MultiPatch < LayoutTag, PatchTag > Tag_t; 130 typedef Interval < Dim > Domain_t; 131 }; 132 template < int Dim, class T, class LayoutTag, class PatchTag, 133 int Dim2 > class Engine < Dim, T, MultiPatchView < LayoutTag, PatchTag, 134 Dim2 > > 135 { 136 public:typedef MultiPatchView < LayoutTag, PatchTag, Dim2 > Tag_t; 137 typedef Interval < Dim > Domain_t; 138 typedef T Element_t; 139 enum 140 { 141 dimensions = Dim 142 }; 143 }; 144 class Full; 145 template < int Dim, class T = double, class EngineTag = Full > class Vector { 146 }; 147 148 template < int Dim > inline Interval < Dim > 149 shrinkRight (const Interval < Dim > &dom, int s) 150 { 151 } 152 153 template < int Dim > class GridLayout; 154 struct GridTag 155 { 156 }; 157 template < int Dim > struct MultiPatchLayoutTraits <GridTag, Dim > 158 { 159 typedef GridLayout < Dim > Layout_t; 160 }; 161 template < int Dim > class GridLayoutData:public LayoutBaseData < Dim >, 162 public RefCounted, public Observable < GridLayoutData < Dim > > 163 { 164 typedef int AxisIndex_t; 165 mutable DomainMap < Interval < 1 >, AxisIndex_t > mapAloc_m[Dim]; 166 }; 167 template < int Dim > class GridLayout:public LayoutBase < Dim, 168 GridLayoutData < Dim > >, public Observable < GridLayout < Dim > >, 169 public Observer < GridLayoutData < Dim > > 170 { 171 public:typedef GridLayout < Dim > This_t; 172 GridLayout (); 173 }; 174 template < class MeshTag, class T, class EngineTag > class Field; 175 enum CenteringType 176 { 177 VertexType, EdgeType, FaceType, CellType 178 }; 179 enum ContinuityType 180 { 181 Continuous = 0, Discontinuous 182 }; 183 template < int Dim > class Centering 184 { 185 public:typedef Loc < Dim > Orientation; 186 inline int size () const 187 { 188 } 189 }; 190 template < int Dim > const Centering < Dim > 191 canonicalCentering (const enum CenteringType type, 192 const enum ContinuityType discontinuous, 193 const int dimension = 0); 194 template < class Mesh, class T, class EngineTag > class FieldEngine 195 { 196 public:enum 197 { 198 dimensions = Mesh::dimensions 199 }; 200 enum 201 { 202 Dim = dimensions 203 }; 204 typedef Engine < Dim, T, EngineTag > Engine_t; 205 typedef typename Engine_t::Domain_t Domain_t; 206 typedef GuardLayers < Dim > GuardLayers_t; 207 template < class Layout2 > FieldEngine (const Centering < Dim > ¢ering, const Layout2 & layout, const Mesh & mesh, int materials = 1):num_materials_m (materials), centering_m (centering), 208 stride_m (centering.size ()), physicalCellDomain_m (layout.domain ()), 209 guards_m (layout.externalGuards ()), mesh_m (mesh) 210 { 211 } 212 unsigned int num_materials_m; 213 Centering < Dim > centering_m; 214 int stride_m; 215 Domain_t physicalCellDomain_m; 216 GuardLayers_t guards_m; 217 Mesh mesh_m; 218 }; 219 220 template < class Subject > class SubFieldView; 221 template < class Mesh, class T, 222 class EngineTag > class SubFieldView < Field < Mesh, T, EngineTag > > 223 { 224 public:typedef Field < Mesh, T, EngineTag > Type_t; 225 }; 226 227 template < int Dim, class Mesh, class Domain > struct NewMeshTag 228 { 229 typedef Mesh Type_t; 230 }; 231 template < class Mesh, class T, class EngineTag, 232 class Domain > struct View1Implementation <Field < Mesh, T, EngineTag >, 233 Domain, false > 234 { 235 typedef Field < Mesh, T, EngineTag > Subject_t; 236 typedef typename Subject_t::Engine_t Engine_t; 237 typedef typename NewEngine < Engine_t, Domain >::Type_t NewEngine_t; 238 typedef typename NewEngine_t::Element_t NewT_t; 239 typedef typename NewEngine_t::Tag_t NewEngineTag_t; 240 typedef typename NewMeshTag < NewEngine_t::dimensions, Mesh, 241 Domain >::Type_t NewMeshTag_t; 242 typedef Field < NewMeshTag_t, NewT_t, NewEngineTag_t > Type_t; 243 }; 244 template < class Mesh, class T, class EngineTag, 245 class Sub1 > struct View1 <Field < Mesh, T, EngineTag >, Sub1 > 246 { 247 typedef Field < Mesh, T, EngineTag > Subject_t; 248 typedef typename Subject_t::Domain_t Domain_t; 249 typedef TemporaryNewDomain1 < Domain_t, Sub1 > NewDomain_t; 250 typedef typename NewDomain_t::SliceType_t SDomain_t; 251 enum 252 { 253 sv = DomainTraits < SDomain_t >::singleValued 254 }; 255 typedef View1Implementation < Subject_t, SDomain_t, sv > Dispatch_t; 256 typedef typename Dispatch_t::Type_t Type_t; 257 }; 258 template < class Mesh, class T = double, class EngineTag = Brick > class Field { 259 public:typedef Mesh MeshTag_t; 260 typedef Mesh Mesh_t; 261 typedef Field < Mesh, T, EngineTag > This_t; 262 typedef FieldEngine < Mesh, T, EngineTag > FieldEngine_t; 263 enum 264 { 265 dimensions = FieldEngine_t::dimensions 266 }; 267 typedef Engine < dimensions, T, EngineTag > Engine_t; 268 typedef typename Engine_t::Domain_t Domain_t; 269 typedef Centering < dimensions > Centering_t; 270 template < class Layout2 > Field (const Centering_t & centering, 271 const Layout2 & layout, 272 const Mesh_t & 273 mesh):fieldEngine_m (centering, layout, 274 mesh) 275 { 276 } 277 inline typename SubFieldView < This_t >::Type_t center (int c) const 278 { 279 } 280 inline typename View1 < This_t, Domain_t >::Type_t all () const 281 { 282 } 283 template < class T1 > const This_t & operator= (const T1 & rhs) const 284 { 285 } 286 private: FieldEngine_t fieldEngine_m; 287 }; 288 289 struct UniformRectilinearTag 290 { 291 }; 292 struct CartesianTag 293 { 294 }; 295 template < class MeshTraits > struct CartesianURM; 296 template < class MeshTraits > class UniformRectilinearMeshData; 297 template < class MeshTraits > class UniformRectilinearMesh; 298 template < int Dim, typename T = double, class MeshTag = 299 UniformRectilinearTag, class CoordinateSystemTag = CartesianTag, int CDim = 300 Dim > struct MeshTraits; 301 template < int Dim, typename T, class MeshTag, class CoordinateSystemTag, 302 int CDim > struct MeshTraitsBase 303 { 304 typedef MeshTraits < Dim, T, MeshTag, CoordinateSystemTag, 305 CDim > MeshTraits_t; 306 enum 307 { 308 dimensions = Dim 309 }; 310 typedef Vector < CDim, T > PointType_t; 311 }; 312 template < int Dim, typename T, int CDim > struct MeshTraits <Dim, T, 313 UniformRectilinearTag, CartesianTag, CDim >:public MeshTraitsBase < Dim, T, 314 UniformRectilinearTag, CartesianTag, CDim > 315 { 316 typedef typename MeshTraitsBase < Dim, T, UniformRectilinearTag, 317 CartesianTag, CDim >::MeshTraits_t MeshTraits_t; 318 typedef CartesianURM < MeshTraits_t > CoordinateSystem_t; 319 typedef UniformRectilinearMeshData < MeshTraits_t > MeshData_t; 320 typedef UniformRectilinearMesh < MeshTraits_t > Mesh_t; 321 typedef Vector < CDim, T > SpacingsType_t; 322 }; 323 template < int Dim > class NoMeshData:public RefCounted 324 { 325 public:NoMeshData () 326 { 327 } 328 template < class Layout > 329 explicit NoMeshData (const Layout & 330 layout):physicalVertexDomain_m (layout. 331 innerDomain ()), 332 physicalCellDomain_m (shrinkRight (physicalVertexDomain_m, 1)), 333 totalVertexDomain_m (layout.domain ()), 334 totalCellDomain_m (shrinkRight (totalVertexDomain_m, 1)) 335 { 336 } 337 private:Interval < Dim > physicalVertexDomain_m, physicalCellDomain_m; 338 Interval < Dim > totalVertexDomain_m, totalCellDomain_m; 339 }; 340 341 template < class MeshTraits > class UniformRectilinearMeshData:public NoMeshData < 342 MeshTraits:: 343 dimensions > 344 { 345 public:typedef typename 346 MeshTraits::MeshData_t 347 MeshData_t; 348 typedef typename 349 MeshTraits::PointType_t 350 PointType_t; 351 typedef typename 352 MeshTraits::SpacingsType_t 353 SpacingsType_t; 354 enum 355 { 356 dimensions = MeshTraits::dimensions 357 }; 358 template < class Layout > UniformRectilinearMeshData (const Layout & layout, 359 const PointType_t & 360 origin, 361 const SpacingsType_t & 362 spacings): 363 NoMeshData < 364 dimensions > (layout), 365 origin_m (origin), 366 spacings_m (spacings) 367 { 368 } 369 private:PointType_t origin_m; 370 SpacingsType_t 371 spacings_m; 372 }; 373 374 template < class MeshTraits > class UniformRectilinearMesh:public MeshTraits:: 375 CoordinateSystem_t 376 { 377 public:typedef MeshTraits 378 MeshTraits_t; 379 typedef typename 380 MeshTraits::MeshData_t 381 MeshData_t; 382 typedef typename 383 MeshTraits::PointType_t 384 PointType_t; 385 typedef typename 386 MeshTraits::SpacingsType_t 387 SpacingsType_t; 388 enum 389 { 390 dimensions = MeshTraits::dimensions 391 }; 392 template < class Layout > 393 inline UniformRectilinearMesh (const Layout & layout, 394 const PointType_t & origin, 395 const SpacingsType_t & spacings): 396 data_m (new MeshData_t (layout, origin, spacings)) 397 { 398 } 399 private:RefCountedPtr < MeshData_t > data_m; 400 }; 401 402 template < class MeshTraits > struct GenericURM 403 { 404 }; 405 template < class MeshTraits > struct CartesianURM: 406 public 407 GenericURM < 408 MeshTraits > 409 { 410 }; 411 template < int 412 dim, 413 class 414 MeshTag = UniformRectilinearTag, class CoordinateSystemTag = CartesianTag > struct ParallelTraits { 415 enum 416 { 417 Dim = dim 418 }; 419 typedef 420 GridLayout < 421 dim > 422 Layout_t; 423 typedef 424 MeshTraits < 425 dim, double, 426 MeshTag, 427 CoordinateSystemTag > 428 MeshTraits_t; 429 typedef typename 430 MeshTraits_t::Mesh_t 431 Mesh_t; 432 typedef 433 MultiPatch < 434 GridTag, 435 Remote < 436 Brick > > 437 Engine_t; 438 }; 439 template < class ComputeTraits > struct RhalkTraits: 440 public 441 ComputeTraits 442 { 443 typedef typename 444 ComputeTraits::Mesh_t 445 Mesh_t; 446 typedef typename 447 ComputeTraits::Engine_t 448 Engine_t; 449 enum 450 { 451 Dim = ComputeTraits::Dim 452 }; 453 typedef 454 Centering < 455 Dim > 456 Centering_t; 457 typedef typename 458 Mesh_t::SpacingsType_t 459 Spacings_t; 460 typedef 461 Field < 462 Mesh_t, double, 463 Engine_t > 464 Scalar_t; 465 }; 466 enum 467 { 468 Dim = 3 469 }; 470 typedef 471 RhalkTraits < 472 ParallelTraits < 473 Dim, 474 UniformRectilinearTag, 475 CartesianTag > > 476 Traits_t; 477 Vector < Dim > origin; 478 Traits_t::Spacings_t spacings; 479 int 480 main (int argc, char **argv) 481 { 482 Traits_t::Layout_t layout; 483 Traits_t::Mesh_t mesh (layout, origin, spacings); 484 Traits_t::Centering_t face = 485 canonicalCentering < Traits_t::Dim > (FaceType, Continuous); 486 Traits_t::Scalar_t v (face, layout, mesh); 487 for (int i = 0; i < Dim; ++i) 488 v.center (i).all () = std::numeric_limits < double >::signaling_NaN (); 489 } 490