regionModelTemplates.C
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-2022 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 \*---------------------------------------------------------------------------*/
25 
26 #include "mappedPatchFieldBase.H"
27 
28 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const label regionPatchi,
34  List<Type>& regionField
35 ) const
36 {
37  forAll(intCoupledPatchIDs_, i)
38  {
39  if (intCoupledPatchIDs_[i] == regionPatchi)
40  {
41  const mappedPatchBase& mpb =
42  refCast<const mappedPatchBase>
43  (
44  regionMesh().boundaryMesh()[regionPatchi]
45  );
46  mpb.reverseDistribute(regionField);
47  return;
48  }
49  }
50 
52  << "Region patch ID " << regionPatchi << " not found in region mesh"
53  << abort(FatalError);
54 }
55 
56 
57 template<class Type, class CombineOp>
59 (
60  const label regionPatchi,
61  List<Type>& regionField,
62  const CombineOp& cop
63 ) const
64 {
65  forAll(intCoupledPatchIDs_, i)
66  {
67  if (intCoupledPatchIDs_[i] == regionPatchi)
68  {
69  const mappedPatchBase& mpb =
70  refCast<const mappedPatchBase>
71  (
72  regionMesh().boundaryMesh()[regionPatchi]
73  );
74  mpb.reverseDistribute(regionField, cop);
75  return;
76  }
77  }
78 
80  << "Region patch ID " << regionPatchi << " not found in region mesh"
81  << abort(FatalError);
82 }
83 
84 
85 template<class Type>
87 (
88  const label regionPatchi,
89  List<Type>& primaryField
90 ) const
91 {
92  forAll(intCoupledPatchIDs_, i)
93  {
94  if (intCoupledPatchIDs_[i] == regionPatchi)
95  {
96  const mappedPatchBase& mpb =
97  refCast<const mappedPatchBase>
98  (
99  regionMesh().boundaryMesh()[regionPatchi]
100  );
101  mpb.distribute(primaryField);
102  return;
103  }
104  }
105 
107  << "Region patch ID " << regionPatchi << " not found in region mesh"
108  << abort(FatalError);
109 }
110 
111 
112 template<class Type>
114 (
115  Field<Type>& regionField,
116  const label regionPatchi,
117  const fvPatchField<Type>& primaryPatchField
118 ) const
119 {
120  const polyPatch& regionPatch = regionMesh().boundaryMesh()[regionPatchi];
121  const mappedPatchBase& mpb = refCast<const mappedPatchBase>(regionPatch);
122 
123  mappedPatchFieldBase<Type> mpf(mpb, primaryPatchField);
124 
125  UIndirectList<Type>(regionField, regionPatch.faceCells())
126  = mpf.mappedField();
127 }
128 
129 
130 template<class Type>
132 (
133  Field<Type>& rf,
135 ) const
136 {
137  forAll(intCoupledPatchIDs_, i)
138  {
139  const label regionPatchi = intCoupledPatchIDs_[i];
140  const label primaryPatchi = primaryPatchIDs_[i];
141 
142  toRegion(rf, regionPatchi, pBf[primaryPatchi]);
143  }
144 }
145 
146 
147 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:297
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
void toPrimary(const label regionPatchi, List< Type > &regionField) const
Convert a local region field to the primary region.
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:340
Pre-declare SubField and related Field type.
Definition: Field.H:56
Determines a mapping between patch face centres and mesh cell or face centres and processors they&#39;re ...
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Functionality for sampling fields using mappedPatchBase. Every call to mappedField() returns a sample...
Generic GeometricBoundaryField class.
Definition: fvMesh.H:80
void distribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
A List with indirect addressing.
Definition: fvMatrix.H:106
void toRegion(const label regionPatchi, List< Type > &primaryFieldField) const
Convert a primary region field to the local region.
void reverseDistribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66