source: XIOS/dev/dev_olga/src/extern/blitz/include/blitz/array/geometry.h @ 1022

Last change on this file since 1022 was 1022, checked in by mhnguyen, 7 years ago
File size: 2.8 KB
Line 
1// -*- C++ -*-
2/***************************************************************************
3 * blitz/array/geometry.h  Basic mapping from Array to physical geometry,
4 *                         used for some stencil operations.
5 *
6 * $Id$
7 *
8 * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
9 *
10 * This file is a part of Blitz.
11 *
12 * Blitz is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation, either version 3
15 * of the License, or (at your option) any later version.
16 *
17 * Blitz is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with Blitz.  If not, see <http://www.gnu.org/licenses/>.
24 *
25 * Suggestions:          blitz-devel@lists.sourceforge.net
26 * Bugs:                 blitz-support@lists.sourceforge.net   
27 *
28 * For more information, please see the Blitz++ Home Page:
29 *    https://sourceforge.net/projects/blitz/
30 *
31 ****************************************************************************/
32#ifndef BZ_GEOMETRY_H
33#define BZ_GEOMETRY_H
34
35#ifndef BZ_ARRAY_H
36 #error <blitz/array/geometry.h> must be included after <blitz/array.h>
37#endif
38
39BZ_NAMESPACE(blitz)
40
41typedef double T_defaultSpatialCoordinate;
42
43template<int N_dim, typename T = T_defaultSpatialCoordinate>
44class UniformOrthoGeometry {
45public:
46};
47
48template<int N_dim, typename T = T_defaultSpatialCoordinate>
49class UniformCubicGeometry {
50    T h_;
51    T recip_h_;
52    T recip2_h_;
53    T recip3_h_;
54    TinyVector<T,N_dim> zero_;
55
56public:
57    typedef T T_coord;
58
59    UniformCubicGeometry()
60    {
61        h_ = 0.0;
62        recip_h_ = 0.0;
63        recip2_h_ = 0.0;
64        recip3_h_ = 0.0;
65        zero_ = 0.0;
66    }
67
68    UniformCubicGeometry(T spatialStep)
69    {
70        h_ = spatialStep;
71        zero_ = T(0);
72        setup();
73    }
74
75    UniformCubicGeometry(T spatialStep, TinyVector<T,N_dim> zeroCoordinates)
76    {   
77        h_ = spatialStep;
78        zero_ = zeroCoordinates;
79        setup();
80    }   
81
82    TinyVector<T,N_dim> toSpatial(TinyVector<int,N_dim> logicalCoord) const
83    {
84        return zero_ + h_ * logicalCoord;
85    }
86
87    T spatialStep() const
88    { return h_; }
89
90    T recipSpatialStep() const
91    { return recip_h_; }
92
93    T recipSpatialStepPow2() const
94    { return recip2_h_; }
95
96private:
97    void setup()
98    {
99        recip_h_ = 1.0 / h_;
100        recip2_h_ = 1.0 / pow2(h_);
101        recip3_h_ = 1.0 / pow3(h_);
102    }
103};
104
105template<int N_dim, typename T = T_defaultSpatialCoordinate>
106class TensorProductGeometry {
107public:
108};
109
110BZ_NAMESPACE_END
111
112#endif // BZ_GEOMETRY_H
Note: See TracBrowser for help on using the repository browser.