magSqrTemplates.C
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) 2016 OpenFOAM Foundation
9 Copyright (C) 2016-2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "volFields.H"
30#include "surfaceFields.H"
31#include "polySurfaceFields.H"
32
33// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
34
35template<class Type>
36bool Foam::functionObjects::magSqr::calcMagSqr()
37{
38 typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
39 typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
40 typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
41
42 if (foundObject<VolFieldType>(fieldName_, false))
43 {
44 return store
45 (
47 Foam::magSqr(lookupObject<VolFieldType>(fieldName_))
48 );
49 }
50 else if (foundObject<SurfaceFieldType>(fieldName_, false))
51 {
52 return store
53 (
55 Foam::magSqr(lookupObject<SurfaceFieldType>(fieldName_))
56 );
57 }
58 else if (foundObject<SurfFieldType>(fieldName_, false))
59 {
60 return store
61 (
63 Foam::magSqr(lookupObject<SurfFieldType>(fieldName_))
64 );
65 }
66
67 return false;
68}
69
70
71// ************************************************************************* //
word resultName_
Name of result field.
word fieldName_
Name of field to process.
bool store(word &fieldName, const tmp< ObjectType > &tfield, bool cacheable=false)
Store the field in the (sub) objectRegistry under the given name.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Fields (face and point) for polySurface.
Foam::surfaceFields.