partialFaceAreaWeightAMI.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) 2013-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 
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 template<class SourcePatch, class TargetPatch>
34 (
35  label& startSeedi,
36  label& srcFacei,
37  label& tgtFacei,
38  const boolList& mapFlag,
39  labelList& seedFaces,
40  const DynamicList<label>& visitedFaces,
41  const bool errorOnNotFound
42 ) const
43 {
44  faceAreaWeightAMI<SourcePatch, TargetPatch>::setNextFaces
45  (
46  startSeedi,
47  srcFacei,
48  tgtFacei,
49  mapFlag,
50  seedFaces,
51  visitedFaces,
52  false // no error on not found
53  );
54 }
55 
56 
57 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
58 
59 template<class SourcePatch, class TargetPatch>
62 (
63  const SourcePatch& srcPatch,
64  const TargetPatch& tgtPatch,
66  const bool reverseTarget,
67  const bool requireMatch
68 )
69 :
71  (
72  srcPatch,
73  tgtPatch,
74  triMode,
75  reverseTarget,
76  requireMatch
77  )
78 {}
79 
80 
81 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
82 
83 template<class SourcePatch, class TargetPatch>
86 {}
87 
88 
89 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90 
91 template<class SourcePatch, class TargetPatch>
93 {
94  return false;
95 }
96 
97 
98 template<class SourcePatch, class TargetPatch>
100 (
101  labelListList& srcAddress,
102  scalarListList& srcWeights,
103  labelListList& tgtAddress,
104  scalarListList& tgtWeights,
105  label srcFacei,
106  label tgtFacei
107 )
108 {
109  bool ok =
110  this->initialise
111  (
112  srcAddress,
113  srcWeights,
114  tgtAddress,
115  tgtWeights,
116  srcFacei,
117  tgtFacei
118  );
119 
120  if (!ok)
121  {
122  return;
123  }
124 
125  // temporary storage for addressing and weights
126  List<DynamicList<label>> srcAddr(this->srcPatch_.size());
127  List<DynamicList<scalar>> srcWght(srcAddr.size());
128  List<DynamicList<label>> tgtAddr(this->tgtPatch_.size());
129  List<DynamicList<scalar>> tgtWght(tgtAddr.size());
130 
132  (
133  srcAddr,
134  srcWght,
135  tgtAddr,
136  tgtWght,
137  srcFacei,
138  tgtFacei
139  );
140 
141  // transfer data to persistent storage
142  forAll(srcAddr, i)
143  {
144  srcAddress[i].transfer(srcAddr[i]);
145  srcWeights[i].transfer(srcWght[i]);
146  }
147  forAll(tgtAddr, i)
148  {
149  tgtAddress[i].transfer(tgtAddr[i]);
150  tgtWeights[i].transfer(tgtWght[i]);
151  }
152 }
153 
154 
155 template<class SourcePatch, class TargetPatch>
157 (
158  const TargetPatch& tgtPatch,
159  const mapDistribute& map,
160  scalarList& srcMagSf,
161  scalarList& tgtMagSf
162 ) const
163 {
164  srcMagSf = std::move(this->srcMagSf_);
165 
166  scalarList newTgtMagSf(std::move(this->tgtMagSf_));
167  map.reverseDistribute(tgtPatch.size(), newTgtMagSf);
168 
169  // Assign default sizes. Override selected values with
170  // calculated values. This is to support ACMI
171  // where some of the target faces are never used (so never get sent
172  // over and hence never assigned to)
173  tgtMagSf = tgtPatch.magFaceAreas();
174 
175  for (const labelList& smap : map.subMap())
176  {
177  UIndirectList<scalar>(tgtMagSf, smap) =
178  UIndirectList<scalar>(newTgtMagSf, smap);
179  }
180 }
181 
182 
183 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:74
Foam::mapDistributeBase::subMap
const labelListList & subMap() const
From subsetted data back to original data.
Definition: mapDistributeBase.H:282
Foam::partialFaceAreaWeightAMI::conformal
virtual bool conformal() const
Flag to indicate that interpolation patches are conformal.
Definition: partialFaceAreaWeightAMI.C:92
Foam::partialFaceAreaWeightAMI::~partialFaceAreaWeightAMI
virtual ~partialFaceAreaWeightAMI()
Destructor.
Definition: partialFaceAreaWeightAMI.C:85
Foam::faceAreaIntersect::triangulationMode
triangulationMode
Definition: faceAreaIntersect.H:62
Foam::boolList
List< bool > boolList
A List of bools.
Definition: List.H:72
Foam::partialFaceAreaWeightAMI::calculate
virtual void calculate(labelListList &srcAddress, scalarListList &srcWeights, labelListList &tgtAddress, scalarListList &tgtWeights, label srcFacei=-1, label tgtFacei=-1)
Update addressing and weights.
Definition: partialFaceAreaWeightAMI.C:100
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::faceAreaWeightAMI
Face area weighted Arbitrary Mesh Interface (AMI) method.
Definition: faceAreaWeightAMI.H:52
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::mapDistribute
Class containing processor-to-processor mapping information.
Definition: mapDistribute.H:163
Foam::List::transfer
void transfer(List< T > &list)
Definition: List.C:436
Foam::List< labelList >
Foam::mapDistribute::reverseDistribute
void reverseDistribute(const label constructSize, List< T > &, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType.
Definition: mapDistributeTemplates.C:182
Foam::UIndirectList
A List with indirect addressing.
Definition: fvMatrix.H:109
Foam::partialFaceAreaWeightAMI
Partial face area weighted Arbitrary Mesh Interface (AMI) method.
Definition: partialFaceAreaWeightAMI.H:52
Foam::partialFaceAreaWeightAMI::setMagSf
virtual void setMagSf(const TargetPatch &tgtPatch, const mapDistribute &map, scalarList &srcMagSf, scalarList &tgtMagSf) const
Set the face areas for parallel runs.
Definition: partialFaceAreaWeightAMI.C:157
partialFaceAreaWeightAMI.H