IjkField.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2019-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::IjkField
28 
29 Description
30  Generic templated field type with i-j-k addressing.
31 
32 SourceFiles
33  IjkFieldI.H
34  IjkField.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef IjkField_H
39 #define IjkField_H
40 
41 #include "ijkAddressing.H"
42 #include "Field.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class IjkField Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template<class Type>
54 class IjkField
55 :
56  public Field<Type>
57 {
58  // Private Data
59 
60  //- The i-j-k addressing
61  ijkAddressing ijk_;
62 
63 
64 public:
65 
66  // Constructors
67 
68  //- Construct zero-sized
69  inline IjkField();
70 
71  //- Copy construct
72  inline IjkField(const IjkField<Type>& field);
73 
74  //- Move construct
75  inline IjkField(IjkField<Type>&& field);
76 
77  //- Construct with sizing information, leaving values uninitialized
78  inline explicit IjkField(const labelVector& ijk);
79 
80  //- Construct with sizing information and initial value
81  inline IjkField(const labelVector& ijk, const Type& val);
82 
83  //- Construct with sizing information and initial values of zero
84  inline IjkField(const labelVector& ijk, const Foam::zero);
85 
86  //- Copy construct from components
87  inline IjkField(const labelVector& ijk, const UList<Type>& list);
88 
89  //- Move construct from components
90  inline IjkField(const labelVector& ijk, Field<Type>&& field);
91 
92 
93  // Member Functions
94 
95  // Access
96 
97  //- Return i,j,k addressing
98  inline const ijkAddressing& ijk() const;
99 
100  //- Return i,j,k addressing for modification
101  inline ijkAddressing& ijk();
102 
103  //- Return i,j,k addressing sizes
104  inline const labelVector& sizes() const;
105 
106  //- Return i,j,k addressing sizes for modification
107  inline labelVector& sizes();
108 
109  //- The field size
110  using Field<Type>::size;
111 
112  //- The addressing dimension in the given direction
113  inline const label& size(const vector::components cmpt) const;
114 
115 
116  // Edit
117 
118  //- Clear dimensions and field
119  inline void clear();
120 
121  //- Change dimensions. Fill new values with Zero
122  void resize(const labelVector& newSizes);
123 
124  //- Change dimensions
125  void resize(const labelVector& newSizes, const Type& val);
126 
127 
128  // Access Operators
129 
130  //- Field access at given i-j-k position
131  inline const Type& operator()
132  (
133  const label i,
134  const label j,
135  const label k
136  ) const;
137 
138  //- Field access at given i-j-k position
139  inline Type& operator()
140  (
141  const label i,
142  const label j,
143  const label k
144  );
145 
146  //- Field access at given i-j-k position
147  inline const Type& operator()(const labelVector& ijk) const;
148 
149  //- Field access at given i-j-k position
150  inline Type& operator()(const labelVector& ijk);
151 
152 
153  // Member Operators
154 
155  //- Copy assignment
156  void operator=(const IjkField<Type>& rhs);
157  void operator=(const tmp<IjkField<Type>>& rhs);
158 
159  //- Move assignment
160  inline void operator=(IjkField<Type>&& rhs);
161 
162  //- Value assignment
163  inline void operator=(const Type& val);
164  inline void operator=(const Foam::zero);
165 
166 };
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #include "IjkFieldI.H"
176 
177 #ifdef NoRepository
178  #include "IjkField.C"
179 #endif
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 #endif
184 
185 // ************************************************************************* //
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::IjkField::size
const label & size(const vector::components cmpt) const
The addressing dimension in the given direction.
Definition: IjkFieldI.H:164
Foam::Field::operator
friend Ostream & operator(Ostream &, const Field< Type > &)
Foam::IjkField::IjkField
IjkField()
Construct zero-sized.
Definition: IjkFieldI.H:31
ijkAddressing.H
Foam::Vector< scalar >::components
components
Component labeling enumeration.
Definition: Vector.H:81
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::IjkField::resize
void resize(const labelVector &newSizes)
Change dimensions. Fill new values with Zero.
Definition: IjkField.C:115
Field.H
field
rDeltaTY field()
Foam::IjkField::sizes
const labelVector & sizes() const
Return i,j,k addressing sizes.
Definition: IjkFieldI.H:149
Foam::IjkField::operator=
void operator=(const IjkField< Type > &rhs)
Copy assignment.
Definition: IjkField.C:124
Foam::IjkField::clear
void clear()
Clear dimensions and field.
Definition: IjkFieldI.H:173
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::IjkField
Generic templated field type with i-j-k addressing.
Definition: IjkField.H:53
Foam::IjkField::operator()
const Type & operator()(const label i, const label j, const label k) const
Field access at given i-j-k position.
Definition: IjkFieldI.H:184
Foam::Vector< label >
Foam::UList< Type >
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
IjkFieldI.H
Foam::ijkAddressing
A simple i-j-k (row-major order) to linear addressing.
Definition: ijkAddressing.H:51
Foam::IjkField::ijk
const ijkAddressing & ijk() const
Return i,j,k addressing.
Definition: IjkFieldI.H:135
IjkField.C
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62