mappedPatchBaseTemplates.C
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-2012 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 template<class Type>
28 {
29  switch (mode_)
30  {
32  {
33  lst = AMI().interpolateToSource(Field<Type>(lst.xfer()));
34  break;
35  }
36  default:
37  {
38  map().distribute(lst);
39  }
40  }
41 }
42 
43 
44 template<class Type, class CombineOp>
46 (
47  List<Type>& lst,
48  const CombineOp& cop
49 ) const
50 {
51  switch (mode_)
52  {
54  {
55  lst = AMI().interpolateToSource
56  (
57  Field<Type>(lst.xfer()),
58  cop
59  );
60  break;
61  }
62  default:
63  {
64  map().distribute
65  (
67  map().schedule(),
68  map().constructSize(),
69  map().subMap(),
70  map().constructMap(),
71  lst,
72  cop,
74  );
75  }
76  }
77 }
78 
79 
80 template<class Type>
82 {
83  switch (mode_)
84  {
86  {
87  lst = AMI().interpolateToTarget(Field<Type>(lst.xfer()));
88  break;
89  }
90  default:
91  {
93  break;
94  }
95  }
96 }
97 
98 
99 template<class Type, class CombineOp>
101 (
102  List<Type>& lst,
103  const CombineOp& cop
104 ) const
105 {
106  switch (mode_)
107  {
108  case NEARESTPATCHFACEAMI:
109  {
110  lst = AMI().interpolateToTarget
111  (
112  Field<Type>(lst.xfer()),
113  cop
114  );
115  break;
116  }
117  default:
118  {
119  label cSize = sampleSize();
120  map().distribute
121  (
123  map().schedule(),
124  cSize,
125  map().constructMap(),
126  map().subMap(),
127  lst,
128  cop,
130  );
131  break;
132  }
133  }
134 }
135 
136 
137 // ************************************************************************* //
static void distribute(const Pstream::commsTypes commsType, const List< labelPair > &schedule, const label constructSize, const labelListList &subMap, const labelListList &constructMap, List< T > &, const int tag=UPstream::msgType())
Distribute data. Note:schedule only used for Pstream::scheduled.
Xfer< List< T > > xfer()
Transfer contents to the Xfer container.
Definition: ListI.H:90
void distribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void interpolateToTarget(const UList< Type > &fld, const CombineOp &cop, List< Type > &result, const UList< Type > &defaultValues=UList< Type >::null()) const
Interpolate from source to target with supplied op.
void interpolateToSource(const UList< Type > &fld, const CombineOp &cop, List< Type > &result, const UList< Type > &defaultValues=UList< Type >::null()) const
Interpolate from target to source with supplied op.
const mapDistribute & map() const
Return reference to the parallel distribution map.
void reverseDistribute(const label constructSize, List< T > &, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType.
const sampleMode mode_
What to sample.
Pre-declare SubField and related Field type.
Definition: Field.H:57
const AMIPatchToPatchInterpolation & AMI(const bool forceUpdate=false) const
Return reference to the AMI interpolator.
Traits class for primitives.
Definition: pTraits.H:50
void reverseDistribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
static commsTypes defaultCommsType
Default commsType.
Definition: UPstream.H:255
label sampleSize() const
Return size of mapped mesh/patch/boundary.