VectorSpaceOps.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::VectorSpaceOps
26 
27 Description
28  Operator functions for VectorSpace.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #ifndef VectorSpaceOps_H
33 #define VectorSpaceOps_H
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 template<int N, int I>
43 class VectorSpaceOps
44 {
45 public:
46 
47  static const int endLoop = (I < N-1) ? 1 : 0;
48 
49  template<class V, class S, class EqOp>
50  static inline void eqOpS(V& vs, const S& s, EqOp eo)
51  {
52  eo(vs.v_[I], s);
53  VectorSpaceOps<endLoop*N, endLoop*(I+1)>::eqOpS(vs, s, eo);
54  }
55 
56  template<class S, class V, class EqOp>
57  static inline void SeqOp(S& s, const V& vs, EqOp eo)
58  {
59  eo(s, vs.v_[I]);
60  VectorSpaceOps<endLoop*N, endLoop*(I+1)>::SeqOp(s, vs, eo);
61  }
62 
63  template<class V1, class V2, class EqOp>
64  static inline void eqOp(V1& vs1, const V2& vs2, EqOp eo)
65  {
66  eo(vs1.v_[I], vs2.v_[I]);
67  VectorSpaceOps<endLoop*N, endLoop*(I+1)>::eqOp(vs1, vs2, eo);
68  }
69 
70 
71  template<class V, class V1, class S, class Op>
72  static inline void opVS(V& vs, const V1& vs1, const S& s, Op o)
73  {
74  vs.v_[I] = o(vs1.v_[I], s);
75  VectorSpaceOps<endLoop*N, endLoop*(I+1)>::opVS(vs, vs1, s, o);
76  }
77 
78  template<class V, class S, class V1, class Op>
79  static inline void opSV(V& vs, const S& s, const V1& vs1, Op o)
80  {
81  vs.v_[I] = o(s, vs1.v_[I]);
82  VectorSpaceOps<endLoop*N, endLoop*(I+1)>::opSV(vs, s, vs1, o);
83  }
84 
85  template<class V, class V1, class Op>
86  static inline void op(V& vs, const V1& vs1, const V1& vs2, Op o)
87  {
88  vs.v_[I] = o(vs1.v_[I], vs2.v_[I]);
89  VectorSpaceOps<endLoop*N, endLoop*(I+1)>::op(vs, vs1, vs2, o);
90  }
91 };
92 
93 
94 template<>
95 class VectorSpaceOps<0, 0>
96 {
97 public:
98 
99  template<class V, class S, class EqOp>
100  static inline void eqOpS(V&, const S&, EqOp)
101  {}
102 
103  template<class S, class V, class EqOp>
104  static inline void SeqOp(S&, const V&, EqOp)
105  {}
106 
107  template<class V1, class V2, class EqOp>
108  static inline void eqOp(V1&, const V2&, EqOp)
109  {}
110 
111 
112  template<class V, class V1, class S, class Op>
113  static inline void opVS(V& vs, const V1&, const S&, Op)
114  {}
115 
116  template<class V, class S, class V1, class Op>
117  static inline void opSV(V& vs, const S&, const V1&, Op)
118  {}
119 
120  template<class V, class V1, class Op>
121  static inline void op(V& vs, const V1&, const V1&, Op)
122  {}
123 };
124 
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 } // End namespace Foam
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 #endif
133 
134 // ************************************************************************* //
Foam::VectorSpaceOps::opSV
static void opSV(V &vs, const S &s, const V1 &vs1, Op o)
Definition: VectorSpaceOps.H:78
EqOp
#define EqOp(opName, op)
Definition: ops.H:46
Foam::VectorSpaceOps::endLoop
static const int endLoop
Definition: VectorSpaceOps.H:46
Foam::VectorSpaceOps< 0, 0 >::eqOpS
static void eqOpS(V &, const S &, EqOp)
Definition: VectorSpaceOps.H:99
Foam::VectorSpaceOps< 0, 0 >::SeqOp
static void SeqOp(S &, const V &, EqOp)
Definition: VectorSpaceOps.H:103
Foam::VectorSpaceOps::eqOpS
static void eqOpS(V &vs, const S &s, EqOp eo)
Definition: VectorSpaceOps.H:49
Foam::VectorSpaceOps::eqOp
static void eqOp(V1 &vs1, const V2 &vs2, EqOp eo)
Definition: VectorSpaceOps.H:63
Foam::VectorSpaceOps< 0, 0 >::opSV
static void opSV(V &vs, const S &, const V1 &, Op)
Definition: VectorSpaceOps.H:116
Foam::VectorSpaceOps::op
static void op(V &vs, const V1 &vs1, const V1 &vs2, Op o)
Definition: VectorSpaceOps.H:85
Foam::VectorSpaceOps< 0, 0 >::eqOp
static void eqOp(V1 &, const V2 &, EqOp)
Definition: VectorSpaceOps.H:107
Foam::VectorSpaceOps< 0, 0 >::opVS
static void opVS(V &vs, const V1 &, const S &, Op)
Definition: VectorSpaceOps.H:112
Foam::I
static const sphericalTensor I(1)
Foam::VectorSpaceOps::opVS
static void opVS(V &vs, const V1 &vs1, const S &s, Op o)
Definition: VectorSpaceOps.H:71
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
s
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Foam::VectorSpaceOps::SeqOp
static void SeqOp(S &s, const V &vs, EqOp eo)
Definition: VectorSpaceOps.H:56
Foam::VectorSpaceOps< 0, 0 >::op
static void op(V &vs, const V1 &, const V1 &, Op)
Definition: VectorSpaceOps.H:120
Foam::VectorSpaceOps
Operator functions for VectorSpace.
Definition: VectorSpaceOps.H:42
Op
#define Op(opName, op)
Definition: ops.H:99
N
label N
Definition: createFields.H:22