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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::IjkField
28
29Description
30 Generic templated field type with i-j-k addressing.
31
32SourceFiles
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
46namespace Foam
47{
48
49/*---------------------------------------------------------------------------*\
50 Class IjkField Declaration
51\*---------------------------------------------------------------------------*/
52
53template<class Type>
54class IjkField
55:
56 public Field<Type>
57{
58 // Private Data
59
60 //- The i-j-k addressing
61 ijkAddressing ijk_;
62
63
64public:
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
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// ************************************************************************* //
label k
Generic templated field type.
Definition: Field.H:82
friend Ostream & operator(Ostream &, const Field< Type > &)
Generic templated field type with i-j-k addressing.
Definition: IjkField.H:56
const ijkAddressing & ijk() const
Return i,j,k addressing.
Definition: IjkFieldI.H:135
IjkField()
Construct zero-sized.
Definition: IjkFieldI.H:31
const labelVector & sizes() const
Return i,j,k addressing sizes.
Definition: IjkFieldI.H:149
void operator=(const IjkField< Type > &rhs)
Copy assignment.
Definition: IjkField.C:124
void clear()
Clear dimensions and field.
Definition: IjkFieldI.H:173
void resize(const labelVector &newSizes)
Change dimensions. Fill new values with Zero.
Definition: IjkField.C:115
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
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
label size() const noexcept
The number of elements in the UList.
Definition: UListI.H:420
Extracts the components of elements of a field and outputs the result into new fields,...
Definition: components.H:188
A simple i-j-k (row-major order) to linear addressing.
Definition: ijkAddressing.H:52
A class for managing temporary objects.
Definition: tmp.H:65
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
rDeltaTY field()
Namespace for OpenFOAM.