Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "refinementParameters.H"
00027 #include <OpenFOAM/mathematicalConstants.H>
00028 #include <OpenFOAM/polyMesh.H>
00029 #include <OpenFOAM/globalIndex.H>
00030
00031
00032
00033
00034 Foam::refinementParameters::refinementParameters
00035 (
00036 const dictionary& dict,
00037 const label dummy
00038 )
00039 :
00040 maxGlobalCells_(readLabel(dict.lookup("cellLimit"))),
00041 maxLocalCells_(readLabel(dict.lookup("procCellLimit"))),
00042 minRefineCells_(readLabel(dict.lookup("minimumRefine"))),
00043 curvature_(readScalar(dict.lookup("curvature"))),
00044 nBufferLayers_(readLabel(dict.lookup("nBufferLayers"))),
00045 keepPoints_(dict.lookup("keepPoints")),
00046 allowFreeStandingZoneFaces_
00047 (
00048 dict.lookupOrDefault<Switch>
00049 (
00050 "allowFreeStandingZoneFaces",
00051 true
00052 )
00053 ),
00054 maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance",0))
00055 {}
00056
00057
00058 Foam::refinementParameters::refinementParameters(const dictionary& dict)
00059 :
00060 maxGlobalCells_(readLabel(dict.lookup("maxGlobalCells"))),
00061 maxLocalCells_(readLabel(dict.lookup("maxLocalCells"))),
00062 minRefineCells_(readLabel(dict.lookup("minRefinementCells"))),
00063 nBufferLayers_(readLabel(dict.lookup("nCellsBetweenLevels"))),
00064 keepPoints_(pointField(1, dict.lookup("locationInMesh"))),
00065 allowFreeStandingZoneFaces_
00066 (
00067 dict.lookupOrDefault<Switch>
00068 (
00069 "allowFreeStandingZoneFaces",
00070 true
00071 )
00072 ),
00073 maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance",0))
00074 {
00075 scalar featAngle(readScalar(dict.lookup("resolveFeatureAngle")));
00076
00077 if (featAngle < 0 || featAngle > 180)
00078 {
00079 curvature_ = -GREAT;
00080 }
00081 else
00082 {
00083 curvature_ = Foam::cos(featAngle*mathematicalConstant::pi/180.0);
00084 }
00085 }
00086
00087
00088
00089
00090 Foam::labelList Foam::refinementParameters::findCells(const polyMesh& mesh)
00091 const
00092 {
00093
00094 globalIndex globalCells(mesh.nCells());
00095
00096
00097 labelList cellLabels(keepPoints_.size());
00098
00099 forAll(keepPoints_, i)
00100 {
00101 const point& keepPoint = keepPoints_[i];
00102
00103 label localCellI = mesh.findCell(keepPoint);
00104
00105 label globalCellI = -1;
00106
00107 if (localCellI != -1)
00108 {
00109 Pout<< "Found point " << keepPoint << " in cell " << localCellI
00110 << " on processor " << Pstream::myProcNo() << endl;
00111 globalCellI = globalCells.toGlobal(localCellI);
00112 }
00113
00114 reduce(globalCellI, maxOp<label>());
00115
00116 if (globalCellI == -1)
00117 {
00118 FatalErrorIn
00119 (
00120 "refinementParameters::findCells(const polyMesh&) const"
00121 ) << "Point " << keepPoint
00122 << " is not inside the mesh or on a face or edge." << nl
00123 << "Bounding box of the mesh:" << mesh.bounds()
00124 << exit(FatalError);
00125 }
00126
00127 if (globalCells.isLocal(globalCellI))
00128 {
00129 cellLabels[i] = localCellI;
00130 }
00131 else
00132 {
00133 cellLabels[i] = -1;
00134 }
00135 }
00136 return cellLabels;
00137 }
00138
00139
00140