MapFvSurfaceField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011 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  (
51  Field<Type>& field,
52  const MeshMapper& mapper
53  ) const;
54 };
55 
56 
57 template<class Type, class MeshMapper>
59 (
60  Field<Type>& field,
61  const MeshMapper& mapper
62 ) const
63 {
64  if (field.size() != mapper.surfaceMap().sizeBeforeMapping())
65  {
67  (
68  "void MapInternalField<Type, MeshMapper, surfaceMesh>::operator()\n"
69  "(\n"
70  " Field<Type>& field,\n"
71  " const MeshMapper& mapper\n"
72  ") const"
73  ) << "Incompatible size before mapping. Field size: " << field.size()
74  << " map size: " << mapper.surfaceMap().sizeBeforeMapping()
75  << abort(FatalError);
76  }
77 
78  field.autoMap(mapper.surfaceMap());
79 
80  // Flip the flux
81  const labelList flipFaces = mapper.surfaceMap().flipFaceFlux().toc();
82 
83  forAll(flipFaces, i)
84  {
85  if (flipFaces[i] < field.size())
86  {
87  field[flipFaces[i]] *= -1.0;
88  }
89  }
90 }
91 
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 
95 } // End namespace Foam
96 
97 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98 
99 #endif
100 
101 // ************************************************************************* //
Mesh data needed to do the Finite Volume discretisation.
Definition: surfaceMesh.H:47
void size(const label)
Override size to be inconsistent with allocated storage.
Namespace for OpenFOAM.
Generic internal field mapper. For "real" mapping, add template specialisations for mapping of intern...
void autoMap(const FieldMapper &map)
Map from self.
Definition: Field.C:479
#define forAll(list, i)
Definition: UList.H:421
Pre-declare SubField and related Field type.
Definition: Field.H:57
errorManip< error > abort(error &err)
Definition: errorManip.H:131
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
error FatalError