OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
UniformCartesian.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  *
7  * Visit http://people.web.psi.ch/adelmann/ for more details
8  *
9  ***************************************************************************/
10 
11 #ifndef UNIFORM_CARTESIAN_H
12 #define UNIFORM_CARTESIAN_H
13 
14 // UniformCartesian.h
15 // UniformCartesian class - represents uniform-spacing cartesian meshes.
16 
17 // include files
18 #include "Meshes/Mesh.h"
19 #include "Meshes/Centering.h"
21 #include "AppTypes/Vektor.h"
22 
23 // forward declarations
24 template<class T, unsigned D> class BareField;
25 template<class T, unsigned D, class M, class C> class Field;
26 template <unsigned Dim, class MFLOAT> class UniformCartesian;
27 template <unsigned Dim, class MFLOAT>
28 std::ostream& operator<<(std::ostream&, const UniformCartesian<Dim,MFLOAT>&);
29 template <unsigned Dim, class MFLOAT>
30 Inform& operator<<(Inform&, const UniformCartesian<Dim,MFLOAT>&);
31 
32 template <unsigned Dim, class MFLOAT=double>
33 class UniformCartesian : public Mesh<Dim>
34 {
35 public:
36  //# public typedefs
38  typedef MFLOAT MeshValue_t;
40 
41  // Default constructor (use initialize() to make valid)
43  {
44  hasSpacingFields = false;
45  };
46  // Destructor
48  {
49  if (hasSpacingFields) {
50  delete VertSpacings;
51  delete CellSpacings;
52  delete FlVert;
53  delete FlCell;
54  }
55  };
56 
57  // Non-default constructors
58  UniformCartesian(const NDIndex<Dim>& ndi);
59  UniformCartesian(const Index& I);
60  UniformCartesian(const Index& I, const Index& J);
61  UniformCartesian(const Index& I, const Index& J, const Index& K);
62  // These also take a MFLOAT* specifying the mesh spacings:
63  UniformCartesian(const NDIndex<Dim>& ndi, MFLOAT* const delX);
64  UniformCartesian(const Index& I, MFLOAT* const delX);
65  UniformCartesian(const Index& I, const Index& J, MFLOAT* const delX);
66  UniformCartesian(const Index& I, const Index& J, const Index& K,
67  MFLOAT* const delX);
68  // These further take a Vektor<MFLOAT,Dim>& specifying the origin:
69  UniformCartesian(const NDIndex<Dim>& ndi, MFLOAT* const delX,
70  const Vektor<MFLOAT,Dim>& orig);
71  UniformCartesian(const Index& I, MFLOAT* const delX,
72  const Vektor<MFLOAT,Dim>& orig);
73  UniformCartesian(const Index& I, const Index& J, MFLOAT* const delX,
74  const Vektor<MFLOAT,Dim>& orig);
75  UniformCartesian(const Index& I, const Index& J, const Index& K,
76  MFLOAT* const delX, const Vektor<MFLOAT,Dim>& orig);
77 
78  // initialize functions
79  void initialize(const NDIndex<Dim>& ndi);
80  void initialize(const Index& I);
81  void initialize(const Index& I, const Index& J);
82  void initialize(const Index& I, const Index& J, const Index& K);
83  // These also take a MFLOAT* specifying the mesh spacings:
84  void initialize(const NDIndex<Dim>& ndi, MFLOAT* const delX);
85  void initialize(const Index& I, MFLOAT* const delX);
86  void initialize(const Index& I, const Index& J, MFLOAT* const delX);
87  void initialize(const Index& I, const Index& J, const Index& K,
88  MFLOAT* const delX);
89  // These further take a Vektor<MFLOAT,Dim>& specifying the origin:
90  void initialize(const NDIndex<Dim>& ndi, MFLOAT* const delX,
91  const Vektor<MFLOAT,Dim>& orig);
92  void initialize(const Index& I, MFLOAT* const delX,
93  const Vektor<MFLOAT,Dim>& orig);
94  void initialize(const Index& I, const Index& J, MFLOAT* const delX,
95  const Vektor<MFLOAT,Dim>& orig);
96  void initialize(const Index& I, const Index& J, const Index& K,
97  MFLOAT* const delX, const Vektor<MFLOAT,Dim>& orig);
98 
99 
100 private:
101 
102  // Private member data:
103  MFLOAT meshSpacing[Dim]; // delta-x, delta-y (>1D), delta-z (>2D)
104  MFLOAT volume; // Cell length(1D), area(2D), or volume (>2D)
105  Vektor<MFLOAT,Dim> origin; // Origin of mesh coordinates (vertices)
106  FieldLayout<Dim>* FlCell; // Layouts for BareField* CellSpacings
107  FieldLayout<Dim>* FlVert; // Layouts for BareField* VertSpacings
108 
109  // Private member functions:
110  void setup(); // Private function doing tasks common to all constructors.
111  // Set only the derivative constants, using pre-set spacings:
112  void set_Dvc();
113 
114 
115 public:
116 
117  // Public member data:
118  unsigned gridSizes[Dim]; // Sizes (number of vertices)
119  Vektor<MFLOAT,Dim> Dvc[1<<Dim]; // Constants for derivatives.
120  bool hasSpacingFields; // Flags allocation of the following:
123 
124  // Public member functions:
125 
126  // Create BareField's of vertex and cell spacings; allow for specifying
127  // layouts via the FieldLayout e_dim_tag and vnodes parameters (these
128  // get passed in to construct the FieldLayout used to construct the
129  // BareField's).
130  void storeSpacingFields(); // Default; will have default layout
131  // Special cases for 1-3 dimensions, ala FieldLayout ctors:
132  void storeSpacingFields(e_dim_tag p1, int vnodes=-1);
133  void storeSpacingFields(e_dim_tag p1, e_dim_tag p2, int vnodes=-1);
135  int vnodes=-1);
136  // Next we have one for arbitrary dimension, ala FieldLayout ctor:
137  // All the others call this one internally:
138  void storeSpacingFields(e_dim_tag *p, int vnodes=-1);
139 
140  // These specify both the total number of vnodes and the numbers of vnodes
141  // along each dimension for the partitioning of the index space. Obviously
142  // this restricts the number of vnodes to be a product of the numbers along
143  // each dimension (the constructor implementation checks this): Special
144  // cases for 1-3 dimensions, ala FieldLayout ctors (see FieldLayout.h for
145  // more relevant comments, including definition of recurse):
147  unsigned vnodes1,
148  bool recurse=false,
149  int vnodes=-1);
151  unsigned vnodes1, unsigned vnodes2,
152  bool recurse=false,int vnodes=-1);
154  unsigned vnodes1, unsigned vnodes2, unsigned vnodes3,
155  bool recurse=false, int vnodes=-1);
156  // Next we have one for arbitrary dimension, ala FieldLayout ctor:
157  // All the others call this one internally:
159  unsigned* vnodesPerDirection,
160  bool recurse=false, int vnodes=-1);
161 
162  // Accessor functions for member data:
163  // Get the origin of mesh vertex positions:
165  // Get the spacings of mesh vertex positions along specified direction:
166  MFLOAT get_meshSpacing(unsigned d) const;
167  // Get the cell volume:
168  MFLOAT get_volume() const;
169 
170  // Set functions for member data:
171  // Set the origin of mesh vertex positions:
172  void set_origin(const Vektor<MFLOAT,Dim>& o);
173  // Set the spacings of mesh vertex positions (recompute Dvc, cell volume):
174  void set_meshSpacing(MFLOAT* const del);
175 
176  // Formatted output of UniformCartesian object:
177  void print(std::ostream&);
178 
179  void print(Inform &);
180 
181  //----Other UniformCartesian methods:----------------------------------------
182  // Volume of single cell indexed by input NDIndex;
183  MFLOAT getCellVolume(const NDIndex<Dim>&) const;
184  // Field of volumes of all cells:
187  // Volume of range of cells bounded by verticies specified by input NDIndex:
188  MFLOAT getVertRangeVolume(const NDIndex<Dim>&) const;
189  // Volume of range of cells spanned by input NDIndex (index of cells):
190  MFLOAT getCellRangeVolume(const NDIndex<Dim>&) const;
191  // Nearest vertex index to (x,y,z):
193  // Nearest vertex index with all vertex coordinates below (x,y,z):
195  // NDIndex for cell in cell-ctrd Field containing the point (x,y,z):
196  inline
198  {
199  return getVertexBelow(x); // I think these functions are identical. -tjw
200  }
201  // (x,y,z) coordinates of indexed vertex:
203  // Field of (x,y,z) coordinates of all vertices:
207  // (x,y,z) coordinates of indexed cell:
209  // Field of (x,y,z) coordinates of all cells:
213  // Vertex-vertex grid spacing of indexed cell:
215  // Field of vertex-vertex grid spacings of all cells:
219  // Cell-cell grid spacing of indexed vertex:
221  // Field of cell-cell grid spacings of all vertices:
225  // Array of surface normals to cells adjoining indexed cell:
227  // Array of (pointers to) Fields of surface normals to all cells:
230  // Similar functions, but specify the surface normal to a single face, using
231  // the following numbering convention: 0 means low face of 1st dim, 1 means
232  // high face of 1st dim, 2 means low face of 2nd dim, 3 means high face of
233  // 2nd dim, and so on:
234  Vektor<MFLOAT,Dim> getSurfaceNormal(const NDIndex<Dim>&, unsigned) const;
237  UniformCartesian<Dim,MFLOAT>,Cell>&, unsigned) const;
238 
239 };
240 
241 // I/O
242 
243 // Stream formatted output of UniformCartesian object:
244 template< unsigned Dim, class MFLOAT >
245 inline
246 std::ostream& operator<<(std::ostream& out, const UniformCartesian<Dim,MFLOAT>& mesh)
247 {
249  const_cast<UniformCartesian<Dim,MFLOAT>&>(mesh);
250  ncmesh.print(out);
251  return out;
252 }
253 
254 template< unsigned Dim, class MFLOAT >
255 inline
256 Inform& operator<<(Inform& out, const UniformCartesian<Dim,MFLOAT>& mesh)
257 {
259  const_cast<UniformCartesian<Dim,MFLOAT>&>(mesh);
260  ncmesh.print(out);
261  return out;
262 }
263 
264 //*****************************************************************************
265 // Stuff taken from old Cartesian.h, which now applies to UniformCartesian:
266 //*****************************************************************************
267 
268 #ifndef CARTESIAN_STENCIL_SETUP_H
270 #endif
271 
272 //----------------------------------------------------------------------
273 //
274 //
275 // Definitions of stencils.
276 //
277 // For each one we have first we have the user level function that takes
278 // a Field argument and returns an expression template.
279 // This is the thing the user code sees.
280 // These could use some asserts to make sure the Fields have
281 // enough guard cells.
282 //
283 // Then we have the 'apply' function that gets used in the inner loop
284 // when evaluating the expression. This would be better done as a
285 // member function of the tags above, but that would require member
286 // function templates, which we are holding off on for now.
287 //
288 //----------------------------------------------------------------------
289 
290 //----------------------------------------------------------------------
291 //
292 // Divergence Vert->Cell
293 //
294 // First is the user function for any dimension and element types.
295 // it returns a unary element type.
296 //
297 //----------------------------------------------------------------------
298 #ifdef UNDEFINED
299 //
300 // T1: The element type for the Field
301 // T2: The data type for the UniformCartesian mesh
302 // Dim: the dimension of the Field and the Mesh.
303 //
304 template<class T1, class T2, unsigned Dim>
305 // Return a PETE_Expr wrapper on a StencilElem.
306 inline PETE_Expr<StencilElem<
307  // The iterator for the expression element
309  // The operator for the expression element.
311 > >
312 Div( Field< T1 , Dim , UniformCartesian<Dim,T2> , Vert >& x)
313 {
314  // Some typedefs to make the return expression easier.
317  typedef StencilElem<A,Op_t> Elem_t;
318  // Return the expression element.
319  return PETE_Expr<Elem_t>( Elem_t(x.begin() ) );
320 }
321 
322 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
323 // NOTE: this all doesn't work now because the mesh classes are
324 // no longer static, so things like Mesh::Dvc are wrong. For new Cartesian
325 // class, rather than this UniformCartesian class, Dvc is also now an array
326 // of arrays instead of just an array. Steve K. says he will rework all this
327 // later. For now, the non-stencil-expression version of Div(), etc.
328 // are okay. Comment out everything between "REIMPLEMENT..."
329 // --Tim Williams 2/25/97
330 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
331 
332 /* REIMPLEMENT THIS LATER (BEGIN COMMENTED-OUT REGION)
333 //----------------------------------------------------------------------
334 //
335 // Next are the elementwise 'apply' functions for Vert->Cell.
336 // These need to be specialized on dimension, but they are still
337 // for arbitrary element type.
338 //
339 // For each of these:
340 //
341 // A: The iterator type.
342 // a: The instance of the iterator being passed in.
343 // T2: The base type for the Mesh data.
344 //
345 //----------------------------------------------------------------------
346 
347 template<class A, class T2>
348 inline
349 UnaryReturn<Divergence<1>, A::return_type>::type
350 apply(CenteredDivergence<1,UniformCartesian<1,T2>,Vert,Cell>, A a, int i,int,int)
351 {
352  typedef UniformCartesian<1,T2> Mesh;
353  return
354  dot(a.offset( i ),Mesh::Dvc[0]) +
355  dot(a.offset(i+1),Mesh::Dvc[1]);
356 }
357 
358 template<class A, class T2>
359 inline
360 UnaryReturn<Divergence<2>, A::return_type>::type
361 apply(CenteredDivergence<2,UniformCartesian<2,T2>,Vert,Cell>, A a, int i,int j,int)
362 {
363  typedef UniformCartesian<2,T2> Mesh;
364  return
365  dot(a.offset( i , j ),Mesh::Dvc[0]) +
366  dot(a.offset(i+1, j ),Mesh::Dvc[1]) +
367  dot(a.offset( i ,j+1),Mesh::Dvc[2]) +
368  dot(a.offset(i+1,j+1),Mesh::Dvc[3]);
369 }
370 
371 template<class A, class T2>
372 inline
373 UnaryReturn<Divergence<3>, A::return_type>::type
374 apply(CenteredDivergence<3,UniformCartesian<3,T2>,Vert,Cell>, A a, int i,int j,int k)
375 {
376  typedef UniformCartesian<3,T2> Mesh;
377  return
378  dot(a.offset( i , j , k ),Mesh::Dvc[0]) +
379  dot(a.offset(i+1, j , k ),Mesh::Dvc[1]) +
380  dot(a.offset( i ,j+1, k ),Mesh::Dvc[2]) +
381  dot(a.offset(i+1,j+1, k ),Mesh::Dvc[3]) +
382  dot(a.offset( i , j ,k+1),Mesh::Dvc[4]) +
383  dot(a.offset(i+1, j ,k+1),Mesh::Dvc[5]) +
384  dot(a.offset( i ,j+1,k+1),Mesh::Dvc[6]) +
385  dot(a.offset(i+1,j+1,k+1),Mesh::Dvc[7]);
386 }
387 
388 //----------------------------------------------------------------------
389 //
390 // Divergence Cell->Vert
391 //
392 // First is the user function for any dimension and element types.
393 // it returns a stencil element type.
394 //
395 //----------------------------------------------------------------------
396 
397 //
398 // T1: The element type for the Field.
399 // T2: The base type for the mesh.
400 // Dim: The dimension of the Field and the mesh.
401 //
402 template<class T1, class T2, unsigned Dim>
403 // Return a PETE_Expr wrapped around a StencilElem.
404 inline PETE_Expr<StencilElem<
405  // The iterator for the expression.
406  Field<T1,Dim,UniformCartesian<Dim,T2>,Cell>::iterator,
407  // The operator tag.
408  CenteredDivergence<Dim,UniformCartesian<Dim,T2>,Cell,Vert>
409 > >
410 // The function signature is way down here.
411 Div( Field< T1 , Dim , UniformCartesian<Dim,T2> , Cell >& x)
412 {
413  // Some typedefs to make this a little easier to read.
414  typedef CenteredDivergence<Dim,UniformCartesian<Dim,T2>,Cell,Vert> Op_t;
415  typedef Field<T1,Dim,UniformCartesian<Dim,T2>,Cell>::iterator A;
416  typedef StencilElem<A,Op_t> Elem_t;
417  // Build and return the expression element.
418  return PETE_Expr<Elem_t>( Elem_t(x.begin() ) );
419 }
420 
421 //----------------------------------------------------------------------
422 //
423 // Next are the elementwise 'apply' functions for Cell->Vert.
424 // These need to be specialized on dimension, but they are still
425 // for arbitrary element type.
426 //
427 // For each of these:
428 //
429 // A: The iterator type.
430 // a: The instance of the iterator being passed in.
431 // T2: The base type for the Mesh data.
432 //
433 //----------------------------------------------------------------------
434 
435 template<class A, class T2>
436 inline
437 UnaryReturn<Divergence<1>, A::return_type>::type
438 apply(CenteredDivergence<1,UniformCartesian<1,T2>,Cell,Vert>, A a)
439 {
440  typedef UniformCartesian<1,T2> Mesh;
441  return
442  dot(a.offset(-1),Mesh::Dvc[0]) +
443  dot(a.offset( 0),Mesh::Dvc[1]);
444 }
445 
446 template<class A, class T2>
447 inline
448 UnaryReturn<Divergence<1>, A::return_type>::type
449 apply(CenteredDivergence<1,UniformCartesian<1,T2>,Cell,Vert>, A a,int i,int,int)
450 {
451  typedef UniformCartesian<1,T2> Mesh;
452  return
453  dot(a.offset(i-1),Mesh::Dvc[0]) +
454  dot(a.offset( i ),Mesh::Dvc[1]);
455 }
456 
457 template<class A, class T2>
458 inline
459 UnaryReturn<Divergence<2>, A::return_type>::type
460 apply(CenteredDivergence<2,UniformCartesian<2,T2>,Cell,Vert>, A a, int i,int j,int)
461 {
462  typedef UniformCartesian<2,T2> Mesh;
463  return
464  dot(a.offset(i-1,j-1),Mesh::Dvc[0]) +
465  dot(a.offset( i ,j-1),Mesh::Dvc[1]) +
466  dot(a.offset(i-1, j ),Mesh::Dvc[2]) +
467  dot(a.offset( i , j ),Mesh::Dvc[3]);
468 }
469 
470 template<class A, class T2>
471 inline
472 UnaryReturn<Divergence<3>, A::return_type>::type
473 apply(CenteredDivergence<3,UniformCartesian<3,T2>,Cell,Vert>, A a, int i,int j,int k)
474 {
475  typedef UniformCartesian<3,T2> Mesh;
476  return
477  dot(a.offset(i-1,j-1,k-1),Mesh::Dvc[0]) +
478  dot(a.offset( i ,j-1,k-1),Mesh::Dvc[1]) +
479  dot(a.offset(i-1, j ,k-1),Mesh::Dvc[2]) +
480  dot(a.offset( i , j ,k-1),Mesh::Dvc[3]) +
481  dot(a.offset(i-1,j-1, k ),Mesh::Dvc[4]) +
482  dot(a.offset( i ,j-1, k ),Mesh::Dvc[5]) +
483  dot(a.offset(i-1, j , k ),Mesh::Dvc[6]) +
484  dot(a.offset( i , j , k ),Mesh::Dvc[7]);
485 }
486 REIMPLEMENT THIS LATER (BEGIN COMMENTED-OUT END) */
487 #endif
488 
490 //
491 // Here are the old style definitions.
492 //
494 
495 //----------------------------------------------------------------------
496 // Divergence Vektor/Vert -> Scalar/Cell
497 //----------------------------------------------------------------------
498 template < class T, class MFLOAT >
502 //----------------------------------------------------------------------
503 template < class T, class MFLOAT >
507 //----------------------------------------------------------------------
508 template < class T, class MFLOAT >
512 //----------------------------------------------------------------------
513 // Divergence Vektor/Cell -> Scalar/Vert
514 //----------------------------------------------------------------------
515 template < class T, class MFLOAT >
519 //----------------------------------------------------------------------
520 template < class T, class MFLOAT >
524 //----------------------------------------------------------------------
525 template < class T, class MFLOAT >
529 //----------------------------------------------------------------------
530 // Divergence Vektor/Vert -> Scalar/Vert
531 //----------------------------------------------------------------------
532 template < class T, class MFLOAT >
536 //----------------------------------------------------------------------
537 template < class T, class MFLOAT >
541 //----------------------------------------------------------------------
542 template < class T, class MFLOAT >
546 //----------------------------------------------------------------------
547 // Divergence Vektor/Edge -> Scalar/Vert
548 //----------------------------------------------------------------------
549 template < class T, class MFLOAT >
553 //----------------------------------------------------------------------
554 template < class T, class MFLOAT >
558 //----------------------------------------------------------------------
559 template < class T, class MFLOAT >
563 //----------------------------------------------------------------------
564 // Divergence Vektor/Cell -> Scalar/Cell
565 //----------------------------------------------------------------------
566 template < class T, class MFLOAT >
570 //----------------------------------------------------------------------
571 template < class T, class MFLOAT >
575 //----------------------------------------------------------------------
576 template < class T, class MFLOAT >
580 //----------------------------------------------------------------------
581 // Divergence Tenzor/Vert -> Vektor/Cell
582 //----------------------------------------------------------------------
583 template < class T, class MFLOAT >
585 Div(Field<Tenzor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Vert>& x,
586  Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Cell>& r);
587 //----------------------------------------------------------------------
588 template < class T, class MFLOAT >
590 Div(Field<Tenzor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Vert>& x,
591  Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Cell>& r);
592 //----------------------------------------------------------------------
593 template < class T, class MFLOAT >
595 Div(Field<Tenzor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Vert>& x,
596  Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>& r);
597 //----------------------------------------------------------------------
598 // Divergence Tenzor/Cell -> Vektor/Vert
599 //----------------------------------------------------------------------
600 template < class T, class MFLOAT >
601 Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Vert>&
602 Div(Field<Tenzor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Cell>& x,
603  Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Vert>& r);
604 //----------------------------------------------------------------------
605 template < class T, class MFLOAT >
606 Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Vert>&
607 Div(Field<Tenzor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Cell>& x,
608  Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Vert>& r);
609 //----------------------------------------------------------------------
610 template < class T, class MFLOAT >
611 Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Vert>&
612 Div(Field<Tenzor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>& x,
613  Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Vert>& r);
614 
615 //----------------------------------------------------------------------
616 // Grad Scalar/Vert -> Vektor/Cell
617 //----------------------------------------------------------------------
618 template < class T, class MFLOAT >
619 Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Cell>&
620 Grad(Field<T,1U,UniformCartesian<1U,MFLOAT>,Vert>& x,
621  Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Cell>& r);
622 //----------------------------------------------------------------------
623 template < class T, class MFLOAT >
624 Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Cell>&
625 Grad(Field<T,2U,UniformCartesian<2U,MFLOAT>,Vert>& x,
626  Field<Vektor<T,2u>,2U,UniformCartesian<2U,MFLOAT>,Cell>& r);
627 //----------------------------------------------------------------------
628 
630 template < class T, class MFLOAT >
631 Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>&
632 Grad(Field<T,3U,UniformCartesian<3U,MFLOAT>,Vert>& x,
633  Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>& r);
634 
636 template < class T, class MFLOAT >
637 Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>&
638 Grad1Ord(Field<T,3U,UniformCartesian<3U,MFLOAT>,Vert>& x,
639  Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>& r);
640 //----------------------------------------------------------------------
641 // Grad Scalar/Vert -> Vektor/Edge
642 //----------------------------------------------------------------------
643 template < class T, class MFLOAT >
644 Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Edge>&
645 Grad(Field<T,1U,UniformCartesian<1U,MFLOAT>,Vert>& x,
646  Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Edge>& r);
647 //----------------------------------------------------------------------
648 template < class T, class MFLOAT >
649 Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Edge>&
650 Grad(Field<T,2U,UniformCartesian<2U,MFLOAT>,Vert>& x,
651  Field<Vektor<T,2u>,2U,UniformCartesian<2U,MFLOAT>,Edge>& r);
652 //----------------------------------------------------------------------
653 template < class T, class MFLOAT >
654 Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Edge>&
655 Grad(Field<T,3U,UniformCartesian<3U,MFLOAT>,Vert>& x,
656  Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Edge>& r);
657 //----------------------------------------------------------------------
658 // Grad Scalar/Cell -> Vektor/Vert
659 //----------------------------------------------------------------------
660 template < class T, class MFLOAT >
661 Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Vert>&
662 Grad(Field<T,1U,UniformCartesian<1U,MFLOAT>,Cell>& x,
663  Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Vert>& r);
664 //----------------------------------------------------------------------
665 template < class T, class MFLOAT >
666 Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Vert>&
667 Grad(Field<T,2U,UniformCartesian<2U,MFLOAT>,Cell>& x,
668  Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Vert>& r);
669 //----------------------------------------------------------------------
670 template < class T, class MFLOAT >
671 Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Vert>&
672 Grad(Field<T,3U,UniformCartesian<3U,MFLOAT>,Cell>& x,
673  Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Vert>& r);
674 //----------------------------------------------------------------------
675 // Grad Scalar/Vert -> Vektor/Vert
676 //----------------------------------------------------------------------
677 template < class T, class MFLOAT >
678 Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Vert>&
679 Grad(Field<T,1U,UniformCartesian<1U,MFLOAT>,Vert>& x,
680  Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Vert>& r);
681 //----------------------------------------------------------------------
682 template < class T, class MFLOAT >
683 Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Vert>&
684 Grad(Field<T,2U,UniformCartesian<2U,MFLOAT>,Vert>& x,
685  Field<Vektor<T,2u>,2U,UniformCartesian<2U,MFLOAT>,Vert>& r);
686 //----------------------------------------------------------------------
687 template < class T, class MFLOAT >
688 Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Vert>&
689 Grad(Field<T,3U,UniformCartesian<3U,MFLOAT>,Vert>& x,
690  Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Vert>& r);
691 //----------------------------------------------------------------------
692 // Grad Scalar/Cell -> Vektor/Cell
693 //----------------------------------------------------------------------
694 template < class T, class MFLOAT >
695 Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Cell>&
696 Grad(Field<T,1U,UniformCartesian<1U,MFLOAT>,Cell>& x,
697  Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Cell>& r);
698 //----------------------------------------------------------------------
699 template < class T, class MFLOAT >
700 Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Cell>&
701 Grad(Field<T,2U,UniformCartesian<2U,MFLOAT>,Cell>& x,
702  Field<Vektor<T,2u>,2U,UniformCartesian<2U,MFLOAT>,Cell>& r);
703 //----------------------------------------------------------------------
704 template < class T, class MFLOAT >
705 Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>&
706 Grad(Field<T,3U,UniformCartesian<3U,MFLOAT>,Cell>& x,
707  Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>& r);
708 //----------------------------------------------------------------------
709 // Grad Vektor/Vert -> Tenzor/Cell
710 //----------------------------------------------------------------------
711 template < class T, class MFLOAT >
712 Field<Tenzor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Cell>&
713 Grad(Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Vert>& x,
714  Field<Tenzor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Cell>& r);
715 //----------------------------------------------------------------------
716 template < class T, class MFLOAT >
717 Field<Tenzor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Cell>&
718 Grad(Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Vert>& x,
719  Field<Tenzor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Cell>& r);
720 //----------------------------------------------------------------------
721 template < class T, class MFLOAT >
722 Field<Tenzor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>&
723 Grad(Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Vert>& x,
724  Field<Tenzor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>& r);
725 //----------------------------------------------------------------------
726 // Grad Vektor/Cell -> Tenzor/Vert
727 //----------------------------------------------------------------------
728 template < class T, class MFLOAT >
729 Field<Tenzor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Vert>&
730 Grad(Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Cell>& x,
731  Field<Tenzor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Vert>& r);
732 //----------------------------------------------------------------------
733 template < class T, class MFLOAT >
734 Field<Tenzor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Vert>&
735 Grad(Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Cell>& x,
736  Field<Tenzor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Vert>& r);
737 //----------------------------------------------------------------------
738 template < class T, class MFLOAT >
739 Field<Tenzor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Vert>&
740 Grad(Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>& x,
741  Field<Tenzor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Vert>& r);
742 //----------------------------------------------------------------------
743 // Divergence SymTenzor/Vert -> Vektor/Cell
744 //----------------------------------------------------------------------
745 //----------------------------------------------------------------------
746 template < class T, class MFLOAT >
747 Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Cell>&
748 Div(Field<SymTenzor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Vert>& x,
749  Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Cell>& r);
750 //----------------------------------------------------------------------
751 template < class T, class MFLOAT >
752 Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>&
753 Div(Field<SymTenzor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Vert>& x,
754  Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>& r);
755 //----------------------------------------------------------------------
756 // Divergence SymTenzor/Cell -> Vektor/Vert
757 //----------------------------------------------------------------------
758 template < class T, class MFLOAT >
759 Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Vert>&
760 Div(Field<SymTenzor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Cell>& x,
761  Field<Vektor<T,1U>,1U,UniformCartesian<1U,MFLOAT>,Vert>& r);
762 //----------------------------------------------------------------------
763 template < class T, class MFLOAT >
764 Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Vert>&
765 Div(Field<SymTenzor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Cell>& x,
766  Field<Vektor<T,2U>,2U,UniformCartesian<2U,MFLOAT>,Vert>& r);
767 //----------------------------------------------------------------------
768 template < class T, class MFLOAT >
769 Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Vert>&
770 Div(Field<SymTenzor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Cell>& x,
771  Field<Vektor<T,3U>,3U,UniformCartesian<3U,MFLOAT>,Vert>& r);
772 
773 namespace IPPL {
774 
775 //----------------------------------------------------------------------
776 // Weighted average Cell to Vert
777 //----------------------------------------------------------------------
778 template < class T1, class T2, class MFLOAT >
780 Average(Field<T1,1U,UniformCartesian<1U,MFLOAT>,Cell>& x,
781  Field<T2,1U,UniformCartesian<1U,MFLOAT>,Cell>& w,
782  Field<T1,1U,UniformCartesian<1U,MFLOAT>,Vert>& r) ;
783 //----------------------------------------------------------------------
784 template < class T1, class T2, class MFLOAT >
786 Average(Field<T1,2U,UniformCartesian<2U,MFLOAT>,Cell>& x,
787  Field<T2,2U,UniformCartesian<2U,MFLOAT>,Cell>& w,
788  Field<T1,2U,UniformCartesian<2U,MFLOAT>,Vert>& r);
789 //----------------------------------------------------------------------
790 template < class T1, class T2, class MFLOAT >
792 Average(Field<T1,3U,UniformCartesian<3U,MFLOAT>,Cell>& x,
793  Field<T2,3U,UniformCartesian<3U,MFLOAT>,Cell>& w,
794  Field<T1,3U,UniformCartesian<3U,MFLOAT>,Vert>& r);
795 
796 //----------------------------------------------------------------------
797 // Weighted average Vert to Cell
798 //----------------------------------------------------------------------
799 template < class T1, class T2, class MFLOAT >
801 Average(Field<T1,1U,UniformCartesian<1U,MFLOAT>,Vert>& x,
802  Field<T2,1U,UniformCartesian<1U,MFLOAT>,Vert>& w,
803  Field<T1,1U,UniformCartesian<1U,MFLOAT>,Cell>& r) ;
804 //----------------------------------------------------------------------
805 template < class T1, class T2, class MFLOAT >
807 Average(Field<T1,2U,UniformCartesian<2U,MFLOAT>,Vert>& x,
808  Field<T2,2U,UniformCartesian<2U,MFLOAT>,Vert>& w,
809  Field<T1,2U,UniformCartesian<2U,MFLOAT>,Cell>& r);
810 //----------------------------------------------------------------------
811 template < class T1, class T2, class MFLOAT >
813 Average(Field<T1,3U,UniformCartesian<3U,MFLOAT>,Vert>& x,
814  Field<T2,3U,UniformCartesian<3U,MFLOAT>,Vert>& w,
815  Field<T1,3U,UniformCartesian<3U,MFLOAT>,Cell>& r);
816 
817 //----------------------------------------------------------------------
818 
819 //----------------------------------------------------------------------
820 // Unweighted average Cell to Vert
821 //----------------------------------------------------------------------
822 template < class T1, class MFLOAT >
824 Average(Field<T1,1U,UniformCartesian<1U,MFLOAT>,Cell>& x,
825  Field<T1,1U,UniformCartesian<1U,MFLOAT>,Vert>& r) ;
826 //----------------------------------------------------------------------
827 template < class T1, class MFLOAT >
829 Average(Field<T1,2U,UniformCartesian<2U,MFLOAT>,Cell>& x,
830  Field<T1,2U,UniformCartesian<2U,MFLOAT>,Vert>& r);
831 //----------------------------------------------------------------------
832 template < class T1, class MFLOAT >
834 Average(Field<T1,3U,UniformCartesian<3U,MFLOAT>,Cell>& x,
835  Field<T1,3U,UniformCartesian<3U,MFLOAT>,Vert>& r);
836 
837 //----------------------------------------------------------------------
838 // Unweighted average Vert to Cell
839 //----------------------------------------------------------------------
840 template < class T1, class MFLOAT >
842 Average(Field<T1,1U,UniformCartesian<1U,MFLOAT>,Vert>& x,
843  Field<T1,1U,UniformCartesian<1U,MFLOAT>,Cell>& r) ;
844 //----------------------------------------------------------------------
845 template < class T1, class MFLOAT >
847 Average(Field<T1,2U,UniformCartesian<2U,MFLOAT>,Vert>& x,
848  Field<T1,2U,UniformCartesian<2U,MFLOAT>,Cell>& r);
849 //----------------------------------------------------------------------
850 template < class T1, class MFLOAT >
852 Average(Field<T1,3U,UniformCartesian<3U,MFLOAT>,Vert>& x,
853  Field<T1,3U,UniformCartesian<3U,MFLOAT>,Cell>& r);
854 
855 //----------------------------------------------------------------------
856 }
857 
859 
860 #endif // UNIFORM_CARTESIAN_H
861 
862 /***************************************************************************
863  * $RCSfile: UniformCartesian.h,v $ $Author: adelmann $
864  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:28 $
865  * IPPL_VERSION_ID: $Id: UniformCartesian.h,v 1.1.1.1 2003/01/23 07:40:28 adelmann Exp $
866  ***************************************************************************/
Field< Vektor< MFLOAT, Dim >, Dim, UniformCartesian< Dim, MFLOAT >, Cell > & getCellPositionField(Field< Vektor< MFLOAT, Dim >, Dim, UniformCartesian< Dim, MFLOAT >, Cell > &) const
Definition: PETE.h:80
void print(std::ostream &)
FieldLayout< Dim > * FlCell
Definition: Mesh.h:35
Vektor< MFLOAT, Dim > getVertexPosition(const NDIndex< Dim > &) const
Vektor< MFLOAT, Dim > getDeltaCell(const NDIndex< Dim > &) const
Vektor< MFLOAT, Dim > get_origin() const
Definition: rbendmap.h:8
Vektor< MFLOAT, Dim > MeshVektor_t
BareField< Vektor< MFLOAT, Dim >, Dim > * CellSpacings
Definition: Centering.h:42
Vektor< MFLOAT, Dim > getSurfaceNormal(const NDIndex< Dim > &, unsigned) const
MFLOAT getVertRangeVolume(const NDIndex< Dim > &) const
Field< Vektor< MFLOAT, Dim >, Dim, UniformCartesian< Dim, MFLOAT >, Cell > & getSurfaceNormalField(Field< Vektor< MFLOAT, Dim >, Dim, UniformCartesian< Dim, MFLOAT >, Cell > &, unsigned) const
MFLOAT getCellRangeVolume(const NDIndex< Dim > &) const
Field< Vektor< T, 1U >, 1U, Cartesian< 1U, MFLOAT >, Cell > & Grad(Field< T, 1U, Cartesian< 1U, MFLOAT >, Vert > &x, Field< Vektor< T, 1U >, 1U, Cartesian< 1U, MFLOAT >, Cell > &r)
Definition: Cartesian.hpp:2709
Field< Vektor< MFLOAT, Dim >, Dim, UniformCartesian< Dim, MFLOAT >, Vert > & getVertexPositionField(Field< Vektor< MFLOAT, Dim >, Dim, UniformCartesian< Dim, MFLOAT >, Vert > &) const
Definition: Centering.h:49
Vektor< MFLOAT, Dim > origin
MFLOAT meshSpacing[Dim]
Definition: Index.h:236
MFLOAT get_volume() const
Vektor< MFLOAT, Dim > getCellPosition(const NDIndex< Dim > &) const
void getSurfaceNormalFields(Field< Vektor< MFLOAT, Dim >, Dim, UniformCartesian< Dim, MFLOAT >, Cell > **) const
FieldLayout< Dim > * FlVert
Definition: Centering.h:31
Vektor< MFLOAT, Dim > * getSurfaceNormals(const NDIndex< Dim > &) const
void set_origin(const Vektor< MFLOAT, Dim > &o)
NDIndex< Dim > getCellContaining(const Vektor< MFLOAT, Dim > &x) const
void initialize(const NDIndex< Dim > &ndi)
Field< T1, 1U, Cartesian< 1U, MFLOAT >, Vert > & Average(Field< T1, 1U, Cartesian< 1U, MFLOAT >, Cell > &x, Field< T2, 1U, Cartesian< 1U, MFLOAT >, Cell > &w, Field< T1, 1U, Cartesian< 1U, MFLOAT >, Vert > &r)
Definition: Cartesian.hpp:3120
Definition: FFT.h:30
Field< MFLOAT, Dim, UniformCartesian< Dim, MFLOAT >, Cell > & getCellVolumeField(Field< MFLOAT, Dim, UniformCartesian< Dim, MFLOAT >, Cell > &) const
Field< Vektor< T, 3U >, 3U, UniformCartesian< 3U, MFLOAT >, Cell > & Grad1Ord(Field< T, 3U, UniformCartesian< 3U, MFLOAT >, Vert > &x, Field< Vektor< T, 3U >, 3U, UniformCartesian< 3U, MFLOAT >, Cell > &r)
Old Grad operator.
MFLOAT get_meshSpacing(unsigned d) const
unsigned gridSizes[Dim]
NDIndex< Dim > getNearestVertex(const Vektor< MFLOAT, Dim > &) const
Vektor< MFLOAT, Dim > Dvc[1<< Dim]
e_dim_tag
Definition: FieldLayout.h:55
BareField< Vektor< MFLOAT, Dim >, Dim > * VertSpacings
std::string::iterator iterator
Definition: MSLang.h:16
void set_meshSpacing(MFLOAT *const del)
const unsigned Dim
#define K
Definition: integrate.cpp:118
Definition: Inform.h:41
Field< Vektor< MFLOAT, Dim >, Dim, UniformCartesian< Dim, MFLOAT >, Vert > & getDeltaCellField(Field< Vektor< MFLOAT, Dim >, Dim, UniformCartesian< Dim, MFLOAT >, Vert > &) const
Field< Vektor< MFLOAT, Dim >, Dim, UniformCartesian< Dim, MFLOAT >, Cell > & getDeltaVertexField(Field< Vektor< MFLOAT, Dim >, Dim, UniformCartesian< Dim, MFLOAT >, Cell > &) const
double Div(double a, double b)
MFLOAT getCellVolume(const NDIndex< Dim > &) const
NDIndex< Dim > getVertexBelow(const Vektor< MFLOAT, Dim > &) const
Vektor< MFLOAT, Dim > getDeltaVertex(const NDIndex< Dim > &) const