refinementParameters.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 #include "refinementParameters.H"
27 #include "unitConversion.H"
28 #include "polyMesh.H"
29 #include "globalIndex.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 :
35  maxGlobalCells_(dict.lookup<label>("maxGlobalCells")),
36  maxLocalCells_(dict.lookup<label>("maxLocalCells")),
37  minRefineCells_(dict.lookup<label>("minRefinementCells")),
38  planarAngle_
39  (
40  dict.lookupOrDefault
41  (
42  "planarAngle",
43  dict.lookup<scalar>("resolveFeatureAngle")
44  )
45  ),
46  nBufferLayers_(dict.lookup<label>("nCellsBetweenLevels")),
47  keepPoints_(pointField(1, dict.lookup("locationInMesh"))),
48  allowFreeStandingZoneFaces_(dict.lookup("allowFreeStandingZoneFaces")),
49  useTopologicalSnapDetection_
50  (
51  dict.lookupOrDefault<bool>("useTopologicalSnapDetection", true)
52  ),
53  maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance", 0)),
54  handleSnapProblems_
55  (
56  dict.lookupOrDefault<Switch>("handleSnapProblems", true)
57  )
58 {
59  scalar featAngle(dict.lookup<scalar>("resolveFeatureAngle"));
60 
61  if (featAngle < 0 || featAngle > 180)
62  {
63  curvature_ = -great;
64  }
65  else
66  {
67  curvature_ = Foam::cos(degToRad(featAngle));
68  }
69 }
70 
71 
72 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73 
75 const
76 {
77  // Force calculation of tet-diag decomposition (for use in findCell)
78  (void)mesh.tetBasePtIs();
79 
80  // Global calculation engine
81  globalIndex globalCells(mesh.nCells());
82 
83  // Cell label per point
84  labelList cellLabels(keepPoints_.size());
85 
86  forAll(keepPoints_, i)
87  {
88  const point& keepPoint = keepPoints_[i];
89 
90  label localCelli = mesh.findCell(keepPoint);
91 
92  label globalCelli = -1;
93 
94  if (localCelli != -1)
95  {
96  globalCelli = globalCells.toGlobal(localCelli);
97  }
98 
99  reduce(globalCelli, maxOp<label>());
100 
101  if (globalCelli == -1)
102  {
104  << "Point " << keepPoint
105  << " is not inside the mesh or on a face or edge." << nl
106  << "Bounding box of the mesh:" << mesh.bounds()
107  << exit(FatalError);
108  }
109 
110 
111  label proci = globalCells.whichProcID(globalCelli);
112  label procCelli = globalCells.toLocal(proci, globalCelli);
113 
114  Info<< "Found point " << keepPoint << " in cell " << procCelli
115  << " on processor " << proci << endl;
116 
117 
118  if (globalCells.isLocal(globalCelli))
119  {
120  cellLabels[i] = localCelli;
121  }
122  else
123  {
124  cellLabels[i] = -1;
125  }
126  }
127  return cellLabels;
128 }
129 
130 
131 // ************************************************************************* //
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
Definition: polyMesh.C:848
Unit conversion functions.
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
label nCells() const
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
labelList findCells(const polyMesh &) const
Checks that cells are in mesh. Returns cells they are in.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:63
stressControl lookup("compactNormalStress") >> compactNormalStress
dynamicFvMesh & mesh
dimensionedScalar cos(const dimensionedScalar &ds)
static const char nl
Definition: Ostream.H:260
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
refinementParameters(const dictionary &dict)
Construct from dictionary - new syntax.
const boundBox & bounds() const
Return mesh bounding box.
Definition: polyMesh.H:440
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
Definition: polyMesh.C:1606
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844