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