MapFvSurfaceField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25  Map Surface internal field on topology change. This is a partial
26  template specialisation, see MapGeometricFields.
27 
28 \*---------------------------------------------------------------------------*/
29 
30 #ifndef MapFvSurfaceField_H
31 #define MapFvSurfaceField_H
32 
33 #include "Field.H"
34 #include "surfaceMesh.H"
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 
41 template<class Type, class MeshMapper>
42 class MapInternalField<Type, MeshMapper, surfaceMesh>
43 {
44 public:
45 
47  {}
48 
49  void operator()
50  (
52  const MeshMapper& mapper
53  ) const;
54 };
55 
56 
57 template<class Type, class MeshMapper>
59 (
61  const MeshMapper& mapper
62 ) const
63 {
64  if (field.size() != mapper.surfaceMap().sizeBeforeMapping())
65  {
67  << "Incompatible size before mapping. Field size: " << field.size()
68  << " map size: " << mapper.surfaceMap().sizeBeforeMapping()
69  << abort(FatalError);
70  }
71 
72  mapper.surfaceMap()(field, field);
73 
74  // Flip the flux
75  const labelList flipFaces = mapper.surfaceMap().flipFaceFlux().toc();
76 
77  forAll(flipFaces, i)
78  {
79  if (flipFaces[i] < field.size())
80  {
81  field[flipFaces[i]] *= -1.0;
82  }
83  }
84 }
85 
86 
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 
89 } // End namespace Foam
90 
91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
92 
93 #endif
94 
95 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Mesh data needed to do the Finite Volume discretisation.
Definition: surfaceMesh.H:47
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Pre-declare SubField and related Field type.
Definition: Field.H:56
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Generic internal field mapper. For "real" mapping, add template specialisations for mapping of intern...
rDeltaTY field()
Namespace for OpenFOAM.