divTemplates.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) 2012-2016 OpenFOAM Foundation
9 Copyright (C) 2019-2021 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 "fvcDiv.H"
30
31// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32
33template<class FieldType>
34bool Foam::functionObjects::div::calcDiv()
35{
36 const auto* fieldptr = cfindObject<FieldType>(fieldName_);
37
38 if (!fieldptr)
39 {
40 return false;
41 }
42
44 {
45 const fvMeshSubset& subsetter = zoneSubSetPtr_->subsetter();
46
47 return storeInDb
48 (
50 fvc::div(subsetter.interpolate(*fieldptr, false)),
51 subsetter.subMesh().thisDb()
52 );
53 }
54
55
56 return store
57 (
59 fvc::div(*fieldptr)
60 );
61}
62
63
64template<class Type>
65bool Foam::functionObjects::div::writeField()
66{
67 typedef GeometricField<Type, fvPatchField, volMesh> volFieldType;
68
69 const fvMesh& subMesh = zoneSubSetPtr_->subsetter().subMesh();
70 const auto* fieldptr = subMesh.findObject<volFieldType>(resultName_);
71
72 if (fieldptr)
73 {
74 tmp<volFieldType> tfield = zoneSubSetPtr_->mapToZone<Type>(*fieldptr);
75 tfield().write();
76
77 return true;
78 }
79
80 return false;
81}
82
83
84// ************************************************************************* //
word resultName_
Name of result field.
word fieldName_
Name of field to process.
autoPtr< Detail::zoneSubSet > zoneSubSetPtr_
Sub-set mesh.
bool store(word &fieldName, const tmp< ObjectType > &tfield, bool cacheable=false)
Store the field in the (sub) objectRegistry under the given name.
bool storeInDb(const word &fieldName, const tmp< ObjectType > &tfield, const objectRegistry &obr)
Store the field in an optional objectRegistry under the given name.
Calculate the divergence of the given field.
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:49