Newer
Older
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "PointEdgeWave.H"
#include "pointMesh.H"
#include "processorPolyPatch.H"
#include "cyclicPolyPatch.H"
#include "OPstream.H"
#include "IPstream.H"
#include "PstreamCombineReduceOps.H"
#include "debug.H"
#include "typeInfo.H"
#include "ListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template <class Type>
Foam::scalar Foam::PointEdgeWave<Type>::propagationTol_ = 0.01;
// Offset labelList. Used for transferring from one cyclic half to the other.
template <class Type>
void Foam::PointEdgeWave<Type>::offset(const label val, labelList& elems)
{
forAll(elems, i)
{
elems[i] += val;
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Gets point-point correspondence. Is
// - list of halfA points (in cyclic patch points)
// - list of halfB points (can overlap with A!)
// - for every patchPoint its corresponding point
template <class Type>
void Foam::PointEdgeWave<Type>::calcCyclicAddressing()
{
const polyMesh& mesh = pMesh_();
label cycHalf = 0;
forAll(mesh.boundaryMesh(), patchI)
{
const polyPatch& patch = mesh.boundaryMesh()[patchI];
if (isA<cyclicPolyPatch>(patch))
{
label halfSize = patch.size()/2;
SubList<face> halfAFaces
(
mesh.faces(),
halfSize,
patch.start()
);
cycHalves_.set
(
cycHalf++,
new primitivePatch(halfAFaces, mesh.points())
);
SubList<face> halfBFaces
(
mesh.faces(),
halfSize,
patch.start() + halfSize
);
cycHalves_.set
(
cycHalf++,
new primitivePatch(halfBFaces, mesh.points())
);
}
}
}
// Handle leaving domain. Implementation referred to Type
template <class Type>
void Foam::PointEdgeWave<Type>::leaveDomain
(
const polyPatch& meshPatch,
const primitivePatch& patch,
const labelList& patchPointLabels,
List<Type>& pointInfo
) const
{
const labelList& meshPoints = patch.meshPoints();
forAll(patchPointLabels, i)
{
label patchPointI = patchPointLabels[i];
const point& pt = patch.points()[meshPoints[patchPointI]];
pointInfo[i].leaveDomain(meshPatch, patchPointI, pt);
}
}
// Handle entering domain. Implementation referred to Type
template <class Type>
void Foam::PointEdgeWave<Type>::enterDomain
(
const polyPatch& meshPatch,
const primitivePatch& patch,
const labelList& patchPointLabels,
List<Type>& pointInfo
) const
{
const labelList& meshPoints = patch.meshPoints();
forAll(patchPointLabels, i)
{
label patchPointI = patchPointLabels[i];
const point& pt = patch.points()[meshPoints[patchPointI]];
pointInfo[i].enterDomain(meshPatch, patchPointI, pt);
}
}
// Transform. Implementation referred to Type
template <class Type>
void Foam::PointEdgeWave<Type>::transform
(
const tensorField& rotTensor,
List<Type>& pointInfo
) const
{
if (rotTensor.size() == 1)
{
const tensor& T = rotTensor[0];
forAll(pointInfo, i)
{
pointInfo[i].transform(T);
}
}
else
{
FatalErrorIn
(
"PointEdgeWave<Type>::transform(const tensorField&, List<Type>&)"
) << "Parallel cyclics not supported" << abort(FatalError);
forAll(pointInfo, i)
{
pointInfo[i].transform(rotTensor[i]);
}
}
}
// Update info for pointI, at position pt, with information from
// neighbouring edge.
// Updates:
// - changedPoint_, changedPoints_, nChangedPoints_,
// - statistics: nEvals_, nUnvisitedPoints_
template <class Type>
bool Foam::PointEdgeWave<Type>::updatePoint
(
const label pointI,
const label neighbourEdgeI,
const Type& neighbourInfo,
const scalar tol,
Type& pointInfo
)
{
nEvals_++;
bool wasValid = pointInfo.valid();
bool propagate =
pointInfo.updatePoint
(
pMesh_(),
pointI,
neighbourEdgeI,
neighbourInfo,
tol
);
if (propagate)
{
if (!changedPoint_[pointI])
{
changedPoint_[pointI] = true;
changedPoints_[nChangedPoints_++] = pointI;
}
}
if (!wasValid && pointInfo.valid())
{
--nUnvisitedPoints_;
}
return propagate;
}
// Update info for pointI, at position pt, with information from
// same point.
// Updates:
// - changedPoint_, changedPoints_, nChangedPoints_,
// - statistics: nEvals_, nUnvisitedPoints_
template <class Type>
bool Foam::PointEdgeWave<Type>::updatePoint
(
const label pointI,
const Type& neighbourInfo,
const scalar tol,
Type& pointInfo
)
{
nEvals_++;
bool wasValid = pointInfo.valid();
bool propagate =
pointInfo.updatePoint
(
pMesh_(),
pointI,
neighbourInfo,
tol
);
if (propagate)
{
if (!changedPoint_[pointI])
{
changedPoint_[pointI] = true;
changedPoints_[nChangedPoints_++] = pointI;
}
}
if (!wasValid && pointInfo.valid())
{
--nUnvisitedPoints_;
}
return propagate;
}
// Update info for edgeI, at position pt, with information from
// neighbouring point.
// Updates:
// - changedEdge_, changedEdges_, nChangedEdges_,
// - statistics: nEvals_, nUnvisitedEdge_
template <class Type>
bool Foam::PointEdgeWave<Type>::updateEdge
(
const label edgeI,
const label neighbourPointI,
const Type& neighbourInfo,
const scalar tol,
Type& edgeInfo
)
{
nEvals_++;
bool wasValid = edgeInfo.valid();
bool propagate =
edgeInfo.updateEdge
(
pMesh_(),
edgeI,
neighbourPointI,
neighbourInfo,
tol
);
if (propagate)
{
if (!changedEdge_[edgeI])
{
changedEdge_[edgeI] = true;
changedEdges_[nChangedEdges_++] = edgeI;
}
}
if (!wasValid && edgeInfo.valid())
{
--nUnvisitedEdges_;
}
return propagate;
}
// Check if patches of given type name are present
template <class Type>
template <class PatchType>
Foam::label Foam::PointEdgeWave<Type>::countPatchType() const
{
label nPatches = 0;
forAll(pMesh_().boundaryMesh(), patchI)
{
if (isA<PatchType>(pMesh_().boundaryMesh()[patchI]))
{
nPatches++;
}
}
return nPatches;
}
// Collect changed patch points
template <class Type>
void Foam::PointEdgeWave<Type>::getChangedPatchPoints
(
const primitivePatch& patch,
DynamicList<Type>& patchInfo,
DynamicList<label>& patchPoints,
DynamicList<label>& owner,
DynamicList<label>& ownerIndex
) const
{
const labelList& meshPoints = patch.meshPoints();
const faceList& localFaces = patch.localFaces();
const labelListList& pointFaces = patch.pointFaces();
forAll(meshPoints, patchPointI)
{
label meshPointI = meshPoints[patchPointI];
if (changedPoint_[meshPointI])
{
patchInfo.append(allPointInfo_[meshPointI]);
patchPoints.append(patchPointI);
label patchFaceI = pointFaces[patchPointI][0];
const face& f = localFaces[patchFaceI];
label index = findIndex(f, patchPointI);
owner.append(patchFaceI);
ownerIndex.append(index);
}
}
patchInfo.shrink();
patchPoints.shrink();
owner.shrink();
ownerIndex.shrink();
}
// Update overall for changed patch points
template <class Type>
void Foam::PointEdgeWave<Type>::updateFromPatchInfo
(
const polyPatch& meshPatch,
const primitivePatch& patch,
const labelList& owner,
const labelList& ownerIndex,
List<Type>& patchInfo
)
{
const faceList& localFaces = patch.localFaces();
const labelList& meshPoints = patch.meshPoints();
// Get patch and mesh points.
labelList changedPatchPoints(patchInfo.size());
labelList changedMeshPoints(patchInfo.size());
forAll(owner, i)
{
label faceI = owner[i];
const face& f = localFaces[faceI];
label index = (f.size() - ownerIndex[i]) % f.size();
changedPatchPoints[i] = f[index];
changedMeshPoints[i] = meshPoints[f[index]];
}
// Adapt for entering domain
enterDomain(meshPatch, patch, changedPatchPoints, patchInfo);
// Merge received info
forAll(patchInfo, i)
{
updatePoint
(
changedMeshPoints[i],
patchInfo[i],
propagationTol_,
allPointInfo_[changedMeshPoints[i]]
);
}
}
// Transfer all the information to/from neighbouring processors
template <class Type>
void Foam::PointEdgeWave<Type>::handleProcPatches()
{
// 1. Send all point info on processor patches. Send as
// face label + offset in face.
forAll(mesh.boundaryMesh(), patchI)
{
const polyPatch& patch = mesh.boundaryMesh()[patchI];
if (isA<processorPolyPatch>(patch))
{
// Get all changed points in relative addressing
DynamicList<Type> patchInfo(patch.nPoints());
DynamicList<label> patchPoints(patch.nPoints());
DynamicList<label> owner(patch.nPoints());
DynamicList<label> ownerIndex(patch.nPoints());
getChangedPatchPoints
(
patch,
patchInfo,
patchPoints,
owner,
ownerIndex
);
// Adapt for leaving domain
leaveDomain(patch, patch, patchPoints, patchInfo);
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patch);
if (debug)
{
Pout<< "Processor patch " << patchI << ' ' << patch.name()
<< " communicating with " << procPatch.neighbProcNo()
<< " Sending:" << patchInfo.size() << endl;
}
{
OPstream toNeighbour
(
Pstream::blocking,
procPatch.neighbProcNo()
);
//
// 2. Receive all point info on processor patches.
//
forAll(mesh.boundaryMesh(), patchI)
{
const polyPatch& patch = mesh.boundaryMesh()[patchI];
if (isA<processorPolyPatch>(patch))
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patch);
List<Type> patchInfo;
labelList owner;
labelList ownerIndex;
fromNeighbour >> owner >> ownerIndex >> patchInfo;
}
if (debug)
{
Pout<< "Processor patch " << patchI << ' ' << patch.name()
<< " communicating with " << procPatch.neighbProcNo()
<< " Received:" << patchInfo.size() << endl;
// Apply transform to received data for non-parallel planes
if (!procPatch.parallel())
{
transform(procPatch.reverseT(), patchInfo);
}
updateFromPatchInfo
(
patch,
patch,
owner,
ownerIndex,
patchInfo
);
//
// 3. Handle all shared points
// (Note:irrespective if changed or not for now)
//
forAll(pd.sharedPointLabels(), i)
{
label meshPointI = pd.sharedPointLabels()[i];
// Fill my entries in the shared points
sharedData[pd.sharedPointAddr()[i]] = allPointInfo_[meshPointI];
}
// Combine on master. Reduce operator has to handle a list and call
// Type.updatePoint for all elements
combineReduce(sharedData, listUpdateOp<Type>());
forAll(pd.sharedPointLabels(), i)
{
label meshPointI = pd.sharedPointLabels()[i];
// Retrieve my entries from the shared points
updatePoint
(
meshPointI,
sharedData[pd.sharedPointAddr()[i]],
propagationTol_,
allPointInfo_[meshPointI]
);
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
}
}
template <class Type>
void Foam::PointEdgeWave<Type>::handleCyclicPatches()
{
const polyMesh& mesh = pMesh_();
// 1. Send all point info on cyclic patches. Send as
// face label + offset in face.
label cycHalf = 0;
forAll(mesh.boundaryMesh(), patchI)
{
const polyPatch& patch = mesh.boundaryMesh()[patchI];
if (isA<cyclicPolyPatch>(patch))
{
const primitivePatch& halfA = cycHalves_[cycHalf++];
const primitivePatch& halfB = cycHalves_[cycHalf++];
// HalfA : get all changed points in relative addressing
DynamicList<Type> halfAInfo(halfA.nPoints());
DynamicList<label> halfAPoints(halfA.nPoints());
DynamicList<label> halfAOwner(halfA.nPoints());
DynamicList<label> halfAIndex(halfA.nPoints());
getChangedPatchPoints
(
halfA,
halfAInfo,
halfAPoints,
halfAOwner,
halfAIndex
);
// HalfB : get all changed points in relative addressing
DynamicList<Type> halfBInfo(halfB.nPoints());
DynamicList<label> halfBPoints(halfB.nPoints());
DynamicList<label> halfBOwner(halfB.nPoints());
DynamicList<label> halfBIndex(halfB.nPoints());
getChangedPatchPoints
(
halfB,
halfBInfo,
halfBPoints,
halfBOwner,
halfBIndex
);
// HalfA : adapt for leaving domain
leaveDomain(patch, halfA, halfAPoints, halfAInfo);
// HalfB : adapt for leaving domain
leaveDomain(patch, halfB, halfBPoints, halfBInfo);
// Apply rotation for non-parallel planes
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(patch);
if (!cycPatch.parallel())
{
// received data from half1
transform(cycPatch.forwardT(), halfAInfo);
// received data from half2
transform(cycPatch.reverseT(), halfBInfo);
}
if (debug)
{
Pout<< "Cyclic patch " << patchI << ' ' << patch.name()
<< " Changed on first half : " << halfAInfo.size()
<< " Changed on second half : " << halfBInfo.size()
<< endl;
}
// Half1: update with data from halfB
updateFromPatchInfo
(
patch,
halfA,
halfBOwner,
halfBIndex,
halfBInfo
);
// Half2: update with data from halfA
updateFromPatchInfo
(
patch,
halfB,
halfAOwner,
halfAIndex,
halfAInfo
);
if (debug)
{
//checkCyclic(patch);
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Iterate, propagating changedPointsInfo across mesh, until no change (or
// maxIter reached). Initial point values specified.
template <class Type>
Foam::PointEdgeWave<Type>::PointEdgeWave
(
const pointMesh& pMesh,
const labelList& changedPoints,
const List<Type>& changedPointsInfo,
List<Type>& allPointInfo,
List<Type>& allEdgeInfo,
const label maxIter
)
:
pMesh_(pMesh),
allPointInfo_(allPointInfo),
allEdgeInfo_(allEdgeInfo),
changedPoint_(pMesh_().nPoints(), false),
changedPoints_(pMesh_().nPoints()),
nChangedPoints_(0),
changedEdge_(pMesh_().nEdges(), false),
changedEdges_(pMesh_().nEdges()),
nChangedEdges_(0),
nCyclicPatches_(countPatchType<cyclicPolyPatch>()),
cycHalves_(2*nCyclicPatches_),
nEvals_(0),
nUnvisitedPoints_(pMesh_().nPoints()),
nUnvisitedEdges_(pMesh_().nEdges())
{
if (allPointInfo_.size() != pMesh_().nPoints())
{
FatalErrorIn
(
"PointEdgeWave<Type>::PointEdgeWave"
"(const pointMesh&, const labelList&, const List<Type>,"
" List<Type>&, List<Type>&, const label maxIter)"
) << "size of pointInfo work array is not equal to the number"
<< " of points in the mesh" << endl
<< " pointInfo :" << allPointInfo_.size() << endl
<< " mesh.nPoints:" << pMesh_().nPoints()
<< exit(FatalError);
}
if (allEdgeInfo_.size() != pMesh_().nEdges())
{
FatalErrorIn
(
"PointEdgeWave<Type>::PointEdgeWave"
"(const pointMesh&, const labelList&, const List<Type>,"
" List<Type>&, List<Type>&, const label maxIter)"
) << "size of edgeInfo work array is not equal to the number"
<< " of edges in the mesh" << endl
<< " edgeInfo :" << allEdgeInfo_.size() << endl
<< " mesh.nEdges:" << pMesh_().nEdges()
<< exit(FatalError);
}
// Calculate cyclic halves addressing.
if (nCyclicPatches_ > 0)
{
calcCyclicAddressing();
}
// Set from initial changed points data
setPointInfo(changedPoints, changedPointsInfo);
if (debug)
{
Pout<< "Seed points : " << nChangedPoints_ << endl;
}
// Iterate until nothing changes
label iter = iterate(maxIter);
if ((maxIter > 0) && (iter >= maxIter))
{
FatalErrorIn
(
"PointEdgeWave<Type>::PointEdgeWave"
"(const pointMesh&, const labelList&, const List<Type>,"
" List<Type>&, List<Type>&, const label maxIter)"
) << "Maximum number of iterations reached. Increase maxIter." << endl
<< " maxIter:" << maxIter << endl
<< " nChangedPoints:" << nChangedPoints_ << endl
<< " nChangedEdges:" << nChangedEdges_ << endl
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template <class Type>
Foam::PointEdgeWave<Type>::~PointEdgeWave()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template <class Type>
Foam::label Foam::PointEdgeWave<Type>::getUnsetPoints() const
{
return nUnvisitedPoints_;
}
template <class Type>
Foam::label Foam::PointEdgeWave<Type>::getUnsetEdges() const
{
return nUnvisitedEdges_;
}
// Copy point information into member data
template <class Type>
void Foam::PointEdgeWave<Type>::setPointInfo
(
const labelList& changedPoints,
const List<Type>& changedPointsInfo
)
{
forAll(changedPoints, changedPointI)
{
label pointI = changedPoints[changedPointI];
bool wasValid = allPointInfo_[pointI].valid();
// Copy info for pointI
allPointInfo_[pointI] = changedPointsInfo[changedPointI];
// Maintain count of unset points
if (!wasValid && allPointInfo_[pointI].valid())
{
--nUnvisitedPoints_;
}
// Mark pointI as changed, both on list and on point itself.
if (!changedPoint_[pointI])
{
changedPoint_[pointI] = true;
changedPoints_[nChangedPoints_++] = pointI;
}
}
}
// Propagate information from edge to point. Return number of points changed.
template <class Type>
Foam::label Foam::PointEdgeWave<Type>::edgeToPoint()
{
for
(
label changedEdgeI = 0;
changedEdgeI < nChangedEdges_;
changedEdgeI++
)
{
label edgeI = changedEdges_[changedEdgeI];
if (!changedEdge_[edgeI])
{
FatalErrorIn("PointEdgeWave<Type>::edgeToPoint()")
<< "edge " << edgeI
<< " not marked as having been changed" << nl
<< "This might be caused by multiple occurences of the same"
<< " seed point." << abort(FatalError);
}
const Type& neighbourWallInfo = allEdgeInfo_[edgeI];
// Evaluate all connected points (= edge endpoints)
const edge& e = pMesh_().edges()[edgeI];
forAll(e, eI)
{
Type& currentWallInfo = allPointInfo_[e[eI]];
if (currentWallInfo != neighbourWallInfo)
{
updatePoint
(
e[eI],
edgeI,
neighbourWallInfo,
propagationTol_,
currentWallInfo
);
}
}
// Reset status of edge
changedEdge_[edgeI] = false;
}
// Handled all changed edges by now
nChangedEdges_ = 0;
if (nCyclicPatches_ > 0)
{
// Transfer changed points across cyclic halves
handleCyclicPatches();
}
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
{
// Transfer changed points from neighbouring processors.
handleProcPatches();
}
if (debug)
{
Pout<< "Changed points : " << nChangedPoints_ << endl;
}
// Sum nChangedPoints over all procs
label totNChanged = nChangedPoints_;
reduce(totNChanged, sumOp<label>());
return totNChanged;
}
// Propagate information from point to edge. Return number of edges changed.
template <class Type>
Foam::label Foam::PointEdgeWave<Type>::pointToEdge()
{
const labelListList& pointEdges = pMesh_().pointEdges();
for
(
label changedPointI = 0;
changedPointI < nChangedPoints_;
changedPointI++
)
{
label pointI = changedPoints_[changedPointI];
if (!changedPoint_[pointI])
{
FatalErrorIn("PointEdgeWave<Type>::pointToEdge()")
<< "Point " << pointI
<< " not marked as having been changed" << nl
<< "This might be caused by multiple occurences of the same"
<< " seed point." << abort(FatalError);
}
const Type& neighbourWallInfo = allPointInfo_[pointI];
// Evaluate all connected edges
const labelList& edgeLabels = pointEdges[pointI];
forAll(edgeLabels, edgeLabelI)
{
label edgeI = edgeLabels[edgeLabelI];
Type& currentWallInfo = allEdgeInfo_[edgeI];
if (currentWallInfo != neighbourWallInfo)
{
updateEdge
(
edgeI,
pointI,
neighbourWallInfo,
propagationTol_,
currentWallInfo
);
}
}
// Reset status of point
changedPoint_[pointI] = false;
}
// Handled all changed points by now
nChangedPoints_ = 0;
if (debug)
{
Pout<< "Changed edges : " << nChangedEdges_ << endl;
}
// Sum nChangedPoints over all procs
label totNChanged = nChangedEdges_;
reduce(totNChanged, sumOp<label>());
return totNChanged;
}
// Iterate
template <class Type>
Foam::label Foam::PointEdgeWave<Type>::iterate(const label maxIter)
{
if (nCyclicPatches_ > 0)
{
// Transfer changed points across cyclic halves
handleCyclicPatches();
}
{
// Transfer changed points from neighbouring processors.
handleProcPatches();
}