1 // RUN: %llvmgxx %s -c -o /dev/null
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
12 template < class T
> class DomainTraits
;
13 template < class DomT
, class T
, int Dim
> struct DomainTraitsDomain
15 typedef DomT NewDomain1_t
;
17 template < int Dim
> class Interval
;
18 template < int Dim
> class Loc
;
19 template < class DT
> class DomainBase
23 template < int Dim
, class DT
> class Domain
:public DomainBase
< DT
>
26 template < int Dim
> struct DomainTraits
<Interval
< Dim
>
27 >:public DomainTraitsDomain
< Interval
< Dim
>, int, Dim
>
34 template < class T1
> struct NewDomain1
36 typedef typename DomainTraits
< T1
>::NewDomain1_t SliceType_t
;
38 template < class Domain
, class Sub
> struct TemporaryNewDomain1
40 typedef typename NewDomain1
< Sub
>::SliceType_t SliceType_t
;
42 template < int Dim
> class Interval
:public Domain
< Dim
,
43 DomainTraits
< Interval
< Dim
> > >
46 template < int Dim
> class GuardLayers
49 template < class T
> class Observer
53 template < class T
> class Observable
55 private:T
& observed_m
;
62 template < class T
> class RefCountedPtr
64 public:typedef RefCountedPtr
< T
> This_t
;
65 RefCountedPtr (T
* const pT
):ptr_m (pT
)
68 inline T
*operator-> () const
74 template < class Dom
, class T
> class DomainMap
78 template < class LayoutTag
, int Dim
> struct MultiPatchLayoutTraits
81 template < int Dim
> class LayoutBaseData
83 public:typedef Interval
< Dim
> Domain_t
;
86 template < int Dim
, class LBD
> class LayoutBase
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
93 return pdata_m
->domain_m
;
95 inline const Domain_t
& innerDomain () const
98 inline GuardLayers_t
externalGuards () const
101 RefCountedPtr
< LBD
> pdata_m
;
103 template < class Tag
> struct Remote
;
107 template < class Thing
, class Sub
> struct View1
110 template < int Dim
, class T
, class LayoutTag
,
111 class PatchTag
> struct NewEngine
<Engine
< Dim
, T
, MultiPatch
< LayoutTag
,
112 PatchTag
> >, Interval
< Dim
> >
114 typedef Engine
< Dim
, T
, MultiPatchView
< LayoutTag
, PatchTag
,
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
> >
121 typedef Engine
< Dim
, T
, MultiPatchView
< LayoutTag
, PatchTag
,
124 template < int Dim
, class T
, class LayoutTag
,
125 class PatchTag
> class Engine
< Dim
, T
, MultiPatch
< LayoutTag
,
126 PatchTag
> >:public Observer
< typename MultiPatchLayoutTraits
< LayoutTag
,
129 public:typedef MultiPatch
< LayoutTag
, PatchTag
> Tag_t
;
130 typedef Interval
< Dim
> Domain_t
;
132 template < int Dim
, class T
, class LayoutTag
, class PatchTag
,
133 int Dim2
> class Engine
< Dim
, T
, MultiPatchView
< LayoutTag
, PatchTag
,
136 public:typedef MultiPatchView
< LayoutTag
, PatchTag
, Dim2
> Tag_t
;
137 typedef Interval
< Dim
> Domain_t
;
145 template < int Dim
, class T
= double, class EngineTag
= Full
> class Vector
{
148 template < int Dim
> inline Interval
< Dim
>
149 shrinkRight (const Interval
< Dim
> &dom
, int s
)
153 template < int Dim
> class GridLayout
;
157 template < int Dim
> struct MultiPatchLayoutTraits
<GridTag
, Dim
>
159 typedef GridLayout
< Dim
> Layout_t
;
161 template < int Dim
> class GridLayoutData
:public LayoutBaseData
< Dim
>,
162 public RefCounted
, public Observable
< GridLayoutData
< Dim
> >
164 typedef int AxisIndex_t
;
165 mutable DomainMap
< Interval
< 1 >, AxisIndex_t
> mapAloc_m
[Dim
];
167 template < int Dim
> class GridLayout
:public LayoutBase
< Dim
,
168 GridLayoutData
< Dim
> >, public Observable
< GridLayout
< Dim
> >,
169 public Observer
< GridLayoutData
< Dim
> >
171 public:typedef GridLayout
< Dim
> This_t
;
174 template < class MeshTag
, class T
, class EngineTag
> class Field
;
177 VertexType
, EdgeType
, FaceType
, CellType
181 Continuous
= 0, Discontinuous
183 template < int Dim
> class Centering
185 public:typedef Loc
< Dim
> Orientation
;
186 inline int size () const
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
198 dimensions
= Mesh::dimensions
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
)
212 unsigned int num_materials_m
;
213 Centering
< Dim
> centering_m
;
215 Domain_t physicalCellDomain_m
;
216 GuardLayers_t guards_m
;
220 template < class Subject
> class SubFieldView
;
221 template < class Mesh
, class T
,
222 class EngineTag
> class SubFieldView
< Field
< Mesh
, T
, EngineTag
> >
224 public:typedef Field
< Mesh
, T
, EngineTag
> Type_t
;
227 template < int Dim
, class Mesh
, class Domain
> struct NewMeshTag
231 template < class Mesh
, class T
, class EngineTag
,
232 class Domain
> struct View1Implementation
<Field
< Mesh
, T
, EngineTag
>,
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
;
244 template < class Mesh
, class T
, class EngineTag
,
245 class Sub1
> struct View1
<Field
< Mesh
, T
, EngineTag
>, Sub1
>
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
;
253 sv
= DomainTraits
< SDomain_t
>::singleValued
255 typedef View1Implementation
< Subject_t
, SDomain_t
, sv
> Dispatch_t
;
256 typedef typename
Dispatch_t::Type_t Type_t
;
258 template < class Mesh
, class T
= double, class EngineTag
= Brick
> class Field
{
259 public:typedef Mesh MeshTag_t
;
261 typedef Field
< Mesh
, T
, EngineTag
> This_t
;
262 typedef FieldEngine
< Mesh
, T
, EngineTag
> FieldEngine_t
;
265 dimensions
= FieldEngine_t::dimensions
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
,
273 mesh
):fieldEngine_m (centering
, layout
,
277 inline typename SubFieldView
< This_t
>::Type_t
center (int c
) const
280 inline typename View1
< This_t
, Domain_t
>::Type_t
all () const
283 template < class T1
> const This_t
& operator= (const T1
& rhs
) const
286 private: FieldEngine_t fieldEngine_m
;
289 struct UniformRectilinearTag
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
304 typedef MeshTraits
< Dim
, T
, MeshTag
, CoordinateSystemTag
,
310 typedef Vector
< CDim
, T
> PointType_t
;
312 template < int Dim
, typename T
, int CDim
> struct MeshTraits
<Dim
, T
,
313 UniformRectilinearTag
, CartesianTag
, CDim
>:public MeshTraitsBase
< Dim
, T
,
314 UniformRectilinearTag
, CartesianTag
, CDim
>
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
;
323 template < int Dim
> class NoMeshData
:public RefCounted
328 template < class Layout
>
329 explicit NoMeshData (const Layout
&
330 layout
):physicalVertexDomain_m (layout
.
332 physicalCellDomain_m (shrinkRight (physicalVertexDomain_m
, 1)),
333 totalVertexDomain_m (layout
.domain ()),
334 totalCellDomain_m (shrinkRight (totalVertexDomain_m
, 1))
337 private:Interval
< Dim
> physicalVertexDomain_m
, physicalCellDomain_m
;
338 Interval
< Dim
> totalVertexDomain_m
, totalCellDomain_m
;
341 template < class MeshTraits
> class UniformRectilinearMeshData
:public NoMeshData
<
345 public:typedef typename
346 MeshTraits::MeshData_t
349 MeshTraits::PointType_t
352 MeshTraits::SpacingsType_t
356 dimensions
= MeshTraits::dimensions
358 template < class Layout
> UniformRectilinearMeshData (const Layout
& layout
,
361 const SpacingsType_t
&
364 dimensions
> (layout
),
366 spacings_m (spacings
)
369 private:PointType_t origin_m
;
374 template < class MeshTraits
> class UniformRectilinearMesh
:public MeshTraits::
377 public:typedef MeshTraits
380 MeshTraits::MeshData_t
383 MeshTraits::PointType_t
386 MeshTraits::SpacingsType_t
390 dimensions
= MeshTraits::dimensions
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
))
399 private:RefCountedPtr
< MeshData_t
> data_m
;
402 template < class MeshTraits
> struct GenericURM
405 template < class MeshTraits
> struct CartesianURM
:
414 MeshTag
= UniformRectilinearTag
, class CoordinateSystemTag
= CartesianTag
> struct ParallelTraits
{
427 CoordinateSystemTag
>
439 template < class ComputeTraits
> struct RhalkTraits
:
444 ComputeTraits::Mesh_t
447 ComputeTraits::Engine_t
451 Dim
= ComputeTraits::Dim
458 Mesh_t::SpacingsType_t
474 UniformRectilinearTag
,
477 Vector
< Dim
> origin
;
478 Traits_t::Spacings_t spacings
;
480 main (int argc
, char **argv
)
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 ();