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-2026 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 "MapGeometricFields.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 template<class Type, class MeshMapper>
41 class MapInternalField<Type, MeshMapper, surfaceMesh>
42 {
43 public:
44 
46  {}
47 
48  void operator()
49  (
51  const MeshMapper& mapper
52  ) const;
53 };
54 
55 
56 template<class Type, class MeshMapper>
58 (
60  const MeshMapper& mapper
61 ) const
62 {
63  if (field.size() != mapper.surfaceMap().sizeBeforeMapping())
64  {
66  << "Incompatible size before mapping. Field size: " << field.size()
67  << " map size: " << mapper.surfaceMap().sizeBeforeMapping()
68  << abort(FatalError);
69  }
70 
71  mapper.surfaceMap()(field, field);
72 
73  // Flip the flux
74  if (isFlux(field))
75  {
76  const labelList flipFaces = mapper.surfaceMap().flipFaceFlux().toc();
77 
78  forAll(flipFaces, i)
79  {
80  if (flipFaces[i] < field.size())
81  {
82  field[flipFaces[i]] *= -1.0;
83  }
84  }
85  }
86 }
87 
88 
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90 
91 } // End namespace Foam
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 
95 #endif
96 
97 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Generic internal field mapper. For "real" mapping, add template specialisations for mapping of intern...
Mesh data for surface fields.
Definition: surfaceMesh.H:51
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
bool isFlux(const DimensionedField< Type, surfaceMesh > &df)
Check if surfaceField is a flux.
Definition: surfaceFields.H:54
error FatalError