1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "leastSquaresGrad.H"
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 // Store gradients of fields on the mesh prior to topology changes
35 template <class Type, class gradType>
36 void topoMapper::storeGradients
38 GradientTable& gradTable,
39 PtrList<gradType>& gradList
42 // Define a few typedefs for convenience
43 typedef GeometricField<Type, fvPatchField, volMesh> volType;
44 typedef const GeometricField<Type, fvPatchField, volMesh> constVolType;
46 typedef HashTable<constVolType*> volTypeTable;
48 // Fetch all fields from registry
49 volTypeTable fields(mesh_.objectRegistry::lookupClass<volType>());
54 // Store old-times before gradient computation
57 typename volTypeTable::iterator fIter = fields.begin();
58 fIter != fields.end();
62 fIter()->storeOldTimes();
67 gradList.setSize(nFields);
73 typename volTypeTable::const_iterator fIter = fields.begin();
74 fIter != fields.end();
78 const volType& field = *fIter();
80 // Compute the gradient.
82 // If the fvSolution dictionary contains an entry,
83 // use that, otherwise, default to leastSquares
84 word gradName("grad(" + field.name() + ')');
86 // Register field under a name that's unique
87 word registerName("remapGradient(" + field.name() + ')');
90 if (mesh_.schemesDict().subDict("gradSchemes").found(gradName))
100 mesh_.time().timeName(),
106 fvc::grad(field, gradName)()
120 mesh_.time().timeName(),
126 fv::leastSquaresGrad<Type>(mesh_).grad(field)()
135 GradientMap(registerName, fieldIndex++)
141 } // End namespace Foam
143 // ************************************************************************* //