topoCellLooper.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  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "topoCellLooper.H"
30 #include "cellFeatures.H"
31 #include "polyMesh.H"
32 #include "unitConversion.H"
33 #include "DynamicList.H"
34 #include "ListOps.H"
35 #include "meshTools.H"
36 #include "hexMatcher.H"
38 
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 
41 namespace Foam
42 {
43  defineTypeNameAndDebug(topoCellLooper, 0);
44  addToRunTimeSelectionTable(cellLooper, topoCellLooper, word);
45 }
46 
47 // Angle for polys to be considered splitHexes.
48 const Foam::scalar Foam::topoCellLooper::featureCos = Foam::cos(degToRad(10.0));
49 
50 
51 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
52 
53 // In-memory truncate a list
54 template<class T>
55 void Foam::topoCellLooper::subsetList
56 (
57  const label startI,
58  const label freeI,
59  DynamicList<T>& lst
60 )
61 {
62  if (startI == 0)
63  {
64  // Truncate (setSize decides itself not to do anything if nothing
65  // changed)
66  if (freeI < 0)
67  {
69  << " lst:" << lst << abort(FatalError);
70  }
71  lst.setCapacity(freeI);
72  }
73  else
74  {
75  // Shift elements down
76  label newI = 0;
77  for (label elemI = startI; elemI < freeI; elemI++)
78  {
79  lst[newI++] = lst[elemI];
80  }
81 
82  if ((freeI - startI) < 0)
83  {
85  << " lst:" << lst << abort(FatalError);
86  }
87 
88  lst.setCapacity(freeI - startI);
89  }
90 }
91 
92 
93 // Returns label of edge nFeaturePts away from startEdge (in the direction of
94 // startVertI) and not counting non-featurePoints.
95 //
96 // When stepping to this face it can happen in 3 different ways:
97 //
98 // --|------
99 // |
100 // 1 | 0
101 // |A
102 // |
103 // |
104 // --|------
105 //
106 // A: jumping from face0 to face1 across edge A.
107 // startEdge != -1
108 // startVert == -1
109 //
110 // --|------
111 // |
112 // 1 | 0
113 // +B
114 // |
115 // |
116 // --|------
117 //
118 // B: jumping from face0 to face1 across (non-feature) point B
119 // startEdge == -1
120 // startVert != -1
121 //
122 // --|------
123 // 0 | 1
124 // |C
125 // --+
126 // |
127 // |
128 // --|------
129 //
130 // C: jumping from face0 to face1 across (feature) point C on edge.
131 // startEdge != -1
132 // startVert != -1
133 //
134 void Foam::topoCellLooper::walkFace
135 (
136  const cellFeatures& features,
137  const label facei,
138  const label startEdgeI,
139  const label startVertI,
140  const label nFeaturePts,
141 
142  label& edgeI,
143  label& vertI
144 ) const
145 {
146  const labelList& fEdges = mesh().faceEdges()[facei];
147 
148  edgeI = startEdgeI;
149 
150  vertI = startVertI;
151 
152  // Number of feature points crossed so far
153  label nVisited = 0;
154 
155  if (vertI == -1)
156  {
157  // Started on edge. Go to one of its endpoints.
158  vertI = mesh().edges()[edgeI].start();
159 
160  if (features.isFeatureVertex(facei, vertI))
161  {
162  nVisited++;
163  }
164  }
165 
166  if ((edgeI == -1) || !meshTools::edgeOnFace(mesh(), facei, edgeI))
167  {
168  // Either edge is not set or not on current face. Just take one of
169  // the edges on this face as starting edge.
170  edgeI = getFirstVertEdge(facei, vertI);
171  }
172 
173  // Now we should have starting edge on face and a vertex on that edge.
174 
175  do
176  {
177 
178  edgeI = meshTools::otherEdge(mesh(), fEdges, edgeI, vertI);
179 
180  if (nVisited == nFeaturePts)
181  {
182  break;
183  }
184 
185  vertI = mesh().edges()[edgeI].otherVertex(vertI);
186 
187  if (features.isFeatureVertex(facei, vertI))
188  {
189  nVisited++;
190  }
191  }
192  while (true);
193 }
194 
195 
196 // Returns list of vertices on 'superEdge' i.e. list of edges connected by
197 // non-feature points. First and last are feature points, ones inbetween are
198 // not.
199 Foam::labelList Foam::topoCellLooper::getSuperEdge
200 (
201  const cellFeatures& features,
202  const label facei,
203  const label startEdgeI,
204  const label startVertI
205 ) const
206 {
207  const labelList& fEdges = mesh().faceEdges()[facei];
208 
209  labelList superVerts(fEdges.size());
210  label superVertI = 0;
211 
212 
213  label edgeI = startEdgeI;
214 
215  label vertI = startVertI;
216 
217  superVerts[superVertI++] = vertI;
218 
219  label prevEdgeI = -1;
220 
221  do
222  {
223  vertI = mesh().edges()[edgeI].otherVertex(vertI);
224 
225  superVerts[superVertI++] = vertI;
226 
227  prevEdgeI = edgeI;
228 
229  edgeI = meshTools::otherEdge(mesh(), fEdges, edgeI, vertI);
230  }
231  while (!features.isFeaturePoint(prevEdgeI, edgeI));
232 
233  superVerts.setSize(superVertI);
234 
235  return superVerts;
236 }
237 
238 
239 // Return non-feature edge from cells' edges that is most perpendicular
240 // to refinement direction.
241 Foam::label Foam::topoCellLooper::getAlignedNonFeatureEdge
242 (
243  const vector& refDir,
244  const label celli,
245  const cellFeatures& features
246 ) const
247 {
248  const labelList& cEdges = mesh().cellEdges()[celli];
249 
250  const point& ctr = mesh().cellCentres()[celli];
251 
252  label cutEdgeI = -1;
253  scalar maxCos = -GREAT;
254 
255  forAll(cEdges, cEdgeI)
256  {
257  label edgeI = cEdges[cEdgeI];
258 
259  if (!features.isFeatureEdge(edgeI))
260  {
261  const edge& e = mesh().edges()[edgeI];
262 
263  // Get plane spanned by e.start, e.end and cell centre.
264  vector e0 = mesh().points()[e.start()] - ctr;
265  vector e1 = mesh().points()[e.end()] - ctr;
266 
267  const vector n = normalised(e0 ^ e1);
268 
269  scalar cosAngle = mag(refDir & n);
270 
271  if (cosAngle > maxCos)
272  {
273  maxCos = cosAngle;
274 
275  cutEdgeI = edgeI;
276  }
277  }
278  }
279 
280  return cutEdgeI;
281 }
282 
283 
284 // Starts from edge and vertex on edge on face (or neighbouring face)
285 // and steps either to existing vertex (vertI != -1) or to edge (vertI == -1)
286 // by walking point-edge and crossing nFeats featurePoints.
287 void Foam::topoCellLooper::walkAcrossFace
288 (
289  const cellFeatures& features,
290  const label facei,
291  const label startEdgeI,
292  const label startVertI,
293  const label nFeats,
294 
295  label& edgeI,
296  label& vertI
297 ) const
298 {
299  label oppositeVertI = -1;
300  label oppositeEdgeI = -1;
301 
302  // Go to oppositeEdge and a vertex on that.
303  walkFace
304  (
305  features,
306  facei,
307  startEdgeI,
308  startVertI,
309  nFeats,
310 
311  oppositeEdgeI,
312  oppositeVertI
313  );
314 
315  // Loop over super edge to find internal points if there are any.
316 
317  labelList superEdge =
318  getSuperEdge
319  (
320  features,
321  facei,
322  oppositeEdgeI,
323  oppositeVertI
324  );
325 
326  label sz = superEdge.size();
327 
328  if (sz == 2)
329  {
330  // No non-feature point inbetween feature points.
331  // Mark edge.
332 
333  vertI = -1;
334  edgeI = oppositeEdgeI;
335  }
336  else if (sz == 3)
337  {
338  vertI = superEdge[1];
339  edgeI = -1;
340  }
341  else
342  {
343  //Should choose acc. to geometry!
344  label index = sz/2;
345 
346  if (debug)
347  {
348  Pout<< " Don't know what to do. Stepped to non-feature point "
349  << "at index " << index << " in superEdge:" << superEdge
350  << endl;
351  }
352 
353  vertI = superEdge[index];
354  edgeI = -1;
355  }
356 }
357 
358 
359 // Walks cell circumference. Updates face, edge, vertex.
360 //
361 // Position on face is given by:
362 //
363 // vertI == -1, facei != -1, edgeI != -1
364 // on edge of face. Cross edge to neighbouring face.
365 //
366 // vertI != -1, edgeI != -1, facei == -1
367 // coming from edge onto vertex vertI. Need to step to one
368 // of the faces not using edgeI.
369 //
370 // vertI != -1, edgeI == -1, facei != -1
371 // coming from vertex on side of face. Step to one of the faces
372 // using vertI but not facei
373 void Foam::topoCellLooper::walkSplitHex
374 (
375  const label celli,
376  const cellFeatures& features,
377  const label fromFacei,
378  const label fromEdgeI,
379  const label fromVertI,
380 
381  DynamicList<label>& loop,
382  DynamicList<scalar>& loopWeights
383 ) const
384 {
385  // Work vars giving position on cell
386  label facei = fromFacei;
387  label edgeI = fromEdgeI;
388  label vertI = fromVertI;
389 
390  do
391  {
392  if (debug)
393  {
394  Pout<< "Entering walk with : cell:" << celli << " face:" << facei;
395  if (facei != -1)
396  {
397  Pout<< " verts:" << mesh().faces()[facei];
398  }
399  Pout<< " edge:" << edgeI;
400  if (edgeI != -1)
401  {
402  Pout<< " verts:" << mesh().edges()[edgeI];
403  }
404  Pout<< " vert:" << vertI << endl;
405  }
406 
407  label startLoop = -1;
408 
409  if
410  (
411  vertI != -1
412  && (startLoop = loop.find(vertToEVert(vertI))) != -1
413  )
414  {
415  // Breaking walk since vertI already cut
416  label firstFree = loop.size();
417 
418  subsetList(startLoop, firstFree, loop);
419  subsetList(startLoop, firstFree, loopWeights);
420 
421  break;
422  }
423  if
424  (
425  edgeI != -1
426  && (startLoop = loop.find(edgeToEVert(edgeI))) != -1
427  )
428  {
429  // Breaking walk since edgeI already cut
430  label firstFree = loop.size();
431 
432  subsetList(startLoop, firstFree, loop);
433  subsetList(startLoop, firstFree, loopWeights);
434 
435  break;
436  }
437 
438 
439  if (vertI == -1)
440  {
441  // On edge
442  if (edgeI == -1)
443  {
445  << abort(FatalError);
446  }
447 
448  loop.append(edgeToEVert(edgeI));
449  loopWeights.append(0.5);
450 
451  // Cross edge to next face
452  facei = meshTools::otherFace(mesh(), celli, facei, edgeI);
453 
454  if (debug)
455  {
456  Pout<< " stepped across edge " << mesh().edges()[edgeI]
457  << " to face " << facei << " verts:"
458  << mesh().faces()[facei] << endl;
459  }
460 
461  label nextEdgeI = -1;
462  label nextVertI = -1;
463 
464  // Walk face along its edges
465  walkAcrossFace
466  (
467  features,
468  facei,
469  edgeI,
470  vertI,
471  2,
472 
473  nextEdgeI,
474  nextVertI
475  );
476 
477  edgeI = nextEdgeI;
478  vertI = nextVertI;
479  }
480  else
481  {
482  // On vertex.
483 
484  loop.append(vertToEVert(vertI));
485  loopWeights.append(-GREAT);
486 
487  if (edgeI == -1)
488  {
489  // Normal vertex on edge of face. Get edges connected to it
490  // which are not on facei.
491  labelList nextEdges = getVertEdgesNonFace
492  (
493  celli,
494  facei,
495  vertI
496  );
497 
498  if (nextEdges.empty())
499  {
500  // Cross to other face (there is only one since no edges)
501  const labelList& pFaces = mesh().pointFaces()[vertI];
502 
503  forAll(pFaces, pFacei)
504  {
505  label thisFacei = pFaces[pFacei];
506 
507  if
508  (
509  (thisFacei != facei)
510  && meshTools::faceOnCell(mesh(), celli, thisFacei)
511  )
512  {
513  facei = thisFacei;
514  break;
515  }
516  }
517 
518  if (debug)
519  {
520  Pout<< " stepped from non-edge vertex " << vertI
521  << " to face " << facei << " verts:"
522  << mesh().faces()[facei]
523  << " since candidate edges:" << nextEdges << endl;
524  }
525 
526  label nextEdgeI = -1;
527  label nextVertI = -1;
528 
529  walkAcrossFace
530  (
531  features,
532  facei,
533  edgeI,
534  vertI,
535  2, // 2 vertices to cross
536 
537  nextEdgeI,
538  nextVertI
539  );
540 
541  edgeI = nextEdgeI;
542  vertI = nextVertI;
543  }
544  else if (nextEdges.size() == 1)
545  {
546  // One edge. Go along this one.
547  edgeI = nextEdges[0];
548 
549  if (debug)
550  {
551  Pout<< " stepped from non-edge vertex " << vertI
552  << " along edge " << edgeI << " verts:"
553  << mesh().edges()[edgeI]
554  << " out of candidate edges:"
555  << nextEdges << endl;
556  }
557 
558  vertI = mesh().edges()[edgeI].otherVertex(vertI);
559 
560  facei = -1;
561  }
562  else
563  {
564  // Multiple edges to choose from. Pick any one.
565  // (ideally should be geometric)
566 
567  label index = nextEdges.size()/2;
568 
569  edgeI = nextEdges[index];
570 
571  if (debug)
572  {
573  Pout<< " stepped from non-edge vertex " << vertI
574  << " along edge " << edgeI << " verts:"
575  << mesh().edges()[edgeI]
576  << " out of candidate edges:" << nextEdges << endl;
577  }
578 
579  vertI = mesh().edges()[edgeI].otherVertex(vertI);
580 
581  facei = -1;
582  }
583  }
584  else
585  {
586  // Get faces connected to startVertI but not startEdgeI
587  labelList nextFaces =
588  getVertFacesNonEdge
589  (
590  celli,
591  edgeI,
592  vertI
593  );
594 
595  if (nextFaces.size() == 1)
596  {
597  // Only one face to cross.
598  facei = nextFaces[0];
599 
600  label nextEdgeI = -1;
601  label nextVertI = -1;
602 
603  walkAcrossFace
604  (
605  features,
606  facei,
607  edgeI,
608  vertI,
609  2, // 2 vertices to cross
610 
611  nextEdgeI,
612  nextVertI
613  );
614 
615  edgeI = nextEdgeI;
616  vertI = nextVertI;
617  }
618  else if (nextFaces.size() == 2)
619  {
620  // Split face. Get edge inbetween.
621  facei = -1;
622 
623  edgeI =
625  (
626  mesh(),
627  nextFaces[0],
628  nextFaces[1]
629  );
630 
631  vertI = mesh().edges()[edgeI].otherVertex(vertI);
632  }
633  else
634  {
636  << "Choosing from more than "
637  << "two candidates:" << nextFaces
638  << " when coming from vertex " << vertI << " on cell "
639  << celli << abort(FatalError);
640  }
641  }
642  }
643 
644  if (debug)
645  {
646  Pout<< "Walked to : face:" << facei;
647  if (facei != -1)
648  {
649  Pout<< " verts:" << mesh().faces()[facei];
650  }
651  Pout<< " edge:" << edgeI;
652  if (edgeI != -1)
653  {
654  Pout<< " verts:" << mesh().edges()[edgeI];
655  }
656  Pout<< " vert:" << vertI << endl;
657  }
658  }
659  while (true);
660 }
661 
662 
663 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
664 
665 Foam::topoCellLooper::topoCellLooper(const polyMesh& mesh)
666 :
668 {}
669 
670 
671 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
672 
674 (
675  const vector& refDir,
676  const label celli,
677  const boolList& vertIsCut,
678  const boolList& edgeIsCut,
679  const scalarField& edgeWeight,
680 
681  labelList& loop,
682  scalarField& loopWeights
683 ) const
684 {
685  if (mesh().cellShapes()[celli].model() == hex_)
686  {
687  // Let parent handle hex case.
688  return
690  (
691  refDir,
692  celli,
693  vertIsCut,
694  edgeIsCut,
695  edgeWeight,
696  loop,
697  loopWeights
698  );
699  }
700  else
701  {
702  cellFeatures superCell(mesh(), featureCos, celli);
703 
704  if (hexMatcher::test(superCell.faces()))
705  {
706  label edgeI =
707  getAlignedNonFeatureEdge
708  (
709  refDir,
710  celli,
711  superCell
712  );
713 
714  label vertI = -1;
715 
716  label facei = -1;
717 
718  if (edgeI != -1)
719  {
720  // Found non-feature edge. Start walking from vertex on edge.
721  vertI = mesh().edges()[edgeI].start();
722  }
723  else
724  {
725  // No 'matching' non-feature edge found on cell. Get starting
726  // normal i.e. feature edge.
727  edgeI = getMisAlignedEdge(refDir, celli);
728 
729  // Get any face using edge
730  label face0;
731  label face1;
732  meshTools::getEdgeFaces(mesh(), celli, edgeI, face0, face1);
733 
734  facei = face0;
735  }
736 
737  label nEstCuts = 2*mesh().cells()[celli].size();
738 
739  DynamicList<label> localLoop(nEstCuts);
740  DynamicList<scalar> localLoopWeights(nEstCuts);
741 
742  walkSplitHex
743  (
744  celli,
745  superCell,
746  facei,
747  edgeI,
748  vertI,
749 
750  localLoop,
751  localLoopWeights
752  );
753 
754  if (localLoop.size() <=2)
755  {
756  return false;
757  }
758  else
759  {
760  loop.transfer(localLoop);
761  loopWeights.transfer(localLoopWeights);
762 
763  return true;
764  }
765  }
766  else
767  {
768  // Let parent handle poly case.
769  return hexCellLooper::cut
770  (
771  refDir,
772  celli,
773  vertIsCut,
774  edgeIsCut,
775  edgeWeight,
776  loop,
777  loopWeights
778  );
779  }
780  }
781 }
782 
783 
785 (
786  const plane& cutPlane,
787  const label celli,
788  const boolList& vertIsCut,
789  const boolList& edgeIsCut,
790  const scalarField& edgeWeight,
791 
792  labelList& loop,
793  scalarField& loopWeights
794 ) const
795 {
796  // Let parent handle cut with plane.
797  return
799  (
800  cutPlane,
801  celli,
802  vertIsCut,
803  edgeIsCut,
804  edgeWeight,
805 
806  loop,
807  loopWeights
808  );
809 }
810 
811 
812 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1069
meshTools.H
Foam::meshTools::getSharedEdge
label getSharedEdge(const primitiveMesh &mesh, const label f0, const label f1)
Return edge shared by two faces. Throws error if no edge found.
Definition: meshTools.C:408
Foam::topoCellLooper::featureCos
static const scalar featureCos
Cos of angle for feature recognition (of splitHexes)
Definition: topoCellLooper.H:163
Foam::meshTools::otherFace
label otherFace(const primitiveMesh &mesh, const label celli, const label facei, const label edgeI)
Return face on cell using edgeI but not facei. Throws error.
Definition: meshTools.C:555
Foam::DynamicList< label >
hexMatcher.H
Foam::primitiveMesh::pointFaces
const labelListList & pointFaces() const
Definition: primitiveMeshPointFaces.C:34
Foam::primitiveMesh::cells
const cellList & cells() const
Definition: primitiveMeshCells.C:138
Foam::hexMatcher::test
static bool test(const UList< face > &faces)
Definition: hexMatcher.C:87
unitConversion.H
Unit conversion functions.
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::primitiveMesh::edges
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
Definition: primitiveMeshEdges.C:505
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::meshTools::walkFace
label walkFace(const primitiveMesh &mesh, const label facei, const label startEdgeI, const label startVertI, const label nEdges)
Returns label of edge nEdges away from startEdge (in the direction.
Definition: meshTools.C:603
Foam::plane
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
Definition: plane.H:89
Foam::meshTools::faceOnCell
bool faceOnCell(const primitiveMesh &mesh, const label celli, const label facei)
Is face used by cell.
Definition: meshTools.C:330
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::Field< scalar >
Foam::primitiveMesh::cellEdges
const labelListList & cellEdges() const
Definition: primitiveMeshCellEdges.C:115
Foam::cellFeatures::faces
const faceList & faces() const
Definition: cellFeatures.H:141
Foam::List::transfer
void transfer(List< T > &list)
Definition: List.C:456
Foam::primitiveMesh::faceEdges
const labelListList & faceEdges() const
Definition: primitiveMeshEdges.C:528
Foam::meshTools::getEdgeFaces
void getEdgeFaces(const primitiveMesh &mesh, const label celli, const label edgeI, label &face0, label &face1)
Get faces on cell using edgeI. Throws error if no two found.
Definition: meshTools.C:479
Foam::topoCellLooper::cut
virtual bool cut(const vector &refDir, const label celli, const boolList &vertIsCut, const boolList &edgeIsCut, const scalarField &edgeWeight, labelList &loop, scalarField &loopWeights) const
Create cut along circumference of celli. Gets current mesh cuts.
Definition: topoCellLooper.C:674
Foam::FatalError
error FatalError
Foam::cellFeatures
Cell analysis class.
Definition: cellFeatures.H:63
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::meshTools::otherEdge
label otherEdge(const primitiveMesh &mesh, const labelList &edgeLabels, const label thisEdgeI, const label thisVertI)
Return label of other edge (out of candidates edgeLabels)
Definition: meshTools.C:521
cellFeatures.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::degToRad
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Definition: unitConversion.H:48
Foam::normalised
VectorSpace< Form, Cmpt, Ncmpts > normalised(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
Definition: VectorSpaceI.H:487
Foam::meshTools::edgeOnFace
bool edgeOnFace(const primitiveMesh &mesh, const label facei, const label edgeI)
Is edge used by face.
Definition: meshTools.C:319
Foam::primitiveMesh::cellCentres
const vectorField & cellCentres() const
Definition: primitiveMeshCellCentresAndVols.C:84
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1094
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
topoCellLooper.H
DynamicList.H
cellShapes
cellShapeList cellShapes
Definition: createBlockMesh.H:3
ListOps.H
Various functions to operate on Lists.
Foam::hexCellLooper::cut
virtual bool cut(const vector &refDir, const label celli, const boolList &vertIsCut, const boolList &edgeIsCut, const scalarField &edgeWeight, labelList &loop, scalarField &loopWeights) const
Create cut along circumference of celli. Gets current mesh cuts.
Definition: hexCellLooper.C:162
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::hexCellLooper
Implementation of cellLooper.
Definition: hexCellLooper.H:62
pFaces
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::HEX);labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells].reset(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< SLList< face > > pFaces[nBCs]
Definition: readKivaGrid.H:235
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:265
Foam::subsetList
List< T > subsetList(const UList< T > &input, const UnaryPredicate &pred, const bool invert=false)
Copy a subset of the input list when predicate is true.