1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-6 H. Jasak All rights reserved
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 Template specialisation for scalar coefficients
32 Hrvoje Jasak, Wikki Ltd. All rights reserved.
37 \*---------------------------------------------------------------------------*/
39 #ifndef scalarCoeffField_H
40 #define scalarCoeffField_H
42 #include "CoeffField.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 class CoeffField<scalar>
59 typedef scalar scalarType;
60 typedef scalar linearType;
63 typedef scalarField scalarTypeField;
64 typedef scalarField linearTypeField;
67 // Static data members
69 static const char* const typeName;
74 //- Construct given size
75 explicit CoeffField<scalar>(const label size)
77 scalarField(size, pTraits<scalar>::zero)
81 CoeffField(const CoeffField<scalar>& f)
86 //- Construct from Istream
87 CoeffField(Istream& is)
95 //- Return active type
96 blockCoeffBase::activeLevel activeType() const;
98 //- Return the field transpose
99 tmp<CoeffField<scalar> > transpose() const;
102 // Return as typed. Fails when asked for the incorrect type
104 //- Return as scalar field
105 const scalarField& asScalar() const;
106 scalarField& asScalar();
108 //- Return as linear field. Equal to scalar field
109 const scalarField& asLinear() const;
110 scalarField& asLinear();
113 //- Return coefficient as a block
114 BlockCoeff<scalar> getCoeff(const label index) const;
116 //- Set coefficient from a block
117 void setCoeff(const label index, const BlockCoeff<scalar>& coeff);
122 //- Get subset with offset and size and store in given field
125 CoeffField<scalar>& f,
130 //- Get subset with addressing and store in given field
133 CoeffField<scalar>& f,
134 const labelList& addr
138 //- Set subset with offset and size from given field
141 const CoeffField<scalar>& f,
146 //- Get subset with addressing and store in target field
149 const CoeffField<scalar>& f,
150 const labelList& addr
153 //- Zero out subset with offset and size
160 //- Zero out subset with addressing
163 const labelList& addr
166 //- Add subset with addressing to field
169 const CoeffField<scalar>& f,
170 const labelList& addr
176 void operator=(const scalarField&);
177 void operator=(const tmp<scalarField>&);
180 // IOstream operators
182 friend Ostream& operator<<
185 const CoeffField<scalar>&
188 friend Ostream& operator<<
191 const tmp<CoeffField<scalar> >&
196 /* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */
199 tmp<CoeffField<scalar> > inv(const CoeffField<scalar>& f);
205 CoeffField<scalar>& f,
206 const CoeffField<scalar>& f1
214 const CoeffField<scalar>& f1,
223 const CoeffField<scalar>& f1,
224 const scalarField& f2
232 const scalarField& f1,
233 const CoeffField<scalar>& f2
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 } // End namespace Foam
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 // ************************************************************************* //