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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 template<class Type>
30 {
31  switch (mode_)
32  {
34  {
35  lst = AMI().interpolateToSource(Field<Type>(std::move(lst)));
36  break;
37  }
38  default:
39  {
40  map().distribute(lst);
41  }
42  }
43 }
44 
45 
46 template<class Type, class CombineOp>
48 (
49  List<Type>& lst,
50  const CombineOp& cop
51 ) const
52 {
53  switch (mode_)
54  {
55  case NEARESTPATCHFACEAMI:
56  {
57  lst = AMI().interpolateToSource(Field<Type>(std::move(lst)), cop);
58  break;
59  }
60  default:
61  {
63  (
65  map().schedule(),
66  map().constructSize(),
67  map().subMap(),
68  false,
69  map().constructMap(),
70  false,
71  lst,
72  cop,
73  flipOp(),
74  Type(Zero)
75  );
76  }
77  }
78 }
79 
80 
81 template<class Type>
83 {
84  switch (mode_)
85  {
86  case NEARESTPATCHFACEAMI:
87  {
88  lst = AMI().interpolateToTarget(Field<Type>(std::move(lst)));
89  break;
90  }
91  default:
92  {
93  map().reverseDistribute(sampleSize(), lst);
94  break;
95  }
96  }
97 }
98 
99 
100 template<class Type, class CombineOp>
102 (
103  List<Type>& lst,
104  const CombineOp& cop
105 ) const
106 {
107  switch (mode_)
108  {
109  case NEARESTPATCHFACEAMI:
110  {
111  lst = AMI().interpolateToTarget(Field<Type>(std::move(lst)), cop);
112  break;
113  }
114  default:
115  {
116  label cSize = sampleSize();
118  (
120  map().schedule(),
121  cSize,
122  map().constructMap(),
123  false,
124  map().subMap(),
125  false,
126  lst,
127  cop,
128  flipOp(),
129  Type(Zero)
130  );
131  break;
132  }
133  }
134 }
135 
136 
137 // ************************************************************************* //
Foam::mappedPatchBase::NEARESTPATCHFACEAMI
nearest patch face + AMI interpolation
Definition: mappedPatchBase.H:117
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::mappedPatchBase::map
const mapDistribute & map() const
Return reference to the parallel distribution map.
Definition: mappedPatchBaseI.H:146
Foam::mapDistributeBase::distribute
static void distribute(const Pstream::commsTypes commsType, const List< labelPair > &schedule, const label constructSize, const labelListList &subMap, const bool subHasFlip, const labelListList &constructMap, const bool constructHasFlip, List< T > &, const negateOp &negOp, const int tag=UPstream::msgType())
Distribute data. Note:schedule only used for.
Definition: mapDistributeBaseTemplates.C:122
Foam::mappedPatchBase::mode_
const sampleMode mode_
What to sample.
Definition: mappedPatchBase.H:197
Foam::UPstream::defaultCommsType
static commsTypes defaultCommsType
Default commsType.
Definition: UPstream.H:273
Foam::label
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:62
Foam::AMIInterpolation::interpolateToSource
void interpolateToSource(const UList< Type > &fld, const CombineOp &cop, List< Type > &result, const UList< Type > &defaultValues=UList< Type >::null()) const
Definition: AMIInterpolation.C:1374
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::mappedPatchBase::distribute
void distribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
Definition: mappedPatchBaseTemplates.C:29
Foam::mapDistribute::distribute
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
Definition: mapDistributeTemplates.C:152
Foam::List< Type >
Foam::mappedPatchBase::AMI
const AMIPatchToPatchInterpolation & AMI(const bool forceUpdate=false) const
Return reference to the AMI interpolator.
Definition: mappedPatchBaseI.H:158
Foam::flipOp
Functor to negate primitives. Dummy for most other types.
Definition: flipOp.H:53
Foam::mappedPatchBase::reverseDistribute
void reverseDistribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
Definition: mappedPatchBaseTemplates.C:82