refinementParameters.C
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
00027 #include "refinementParameters.H"
00028 #include "mathematicalConstants.H"
00029 #include "polyMesh.H"
00030 #include "globalIndex.H"
00031
00032
00033
00034
00035 Foam::refinementParameters::refinementParameters
00036 (
00037 const dictionary& dict,
00038 const label dummy
00039 )
00040 :
00041 maxGlobalCells_(readLabel(dict.lookup("cellLimit"))),
00042 maxLocalCells_(readLabel(dict.lookup("procCellLimit"))),
00043 minRefineCells_(readLabel(dict.lookup("minimumRefine"))),
00044 curvature_(readScalar(dict.lookup("curvature"))),
00045 nBufferLayers_(readLabel(dict.lookup("nBufferLayers"))),
00046 keepPoints_(dict.lookup("keepPoints"))
00047 {}
00048
00049
00050 Foam::refinementParameters::refinementParameters(const dictionary& dict)
00051 :
00052 maxGlobalCells_(readLabel(dict.lookup("maxGlobalCells"))),
00053 maxLocalCells_(readLabel(dict.lookup("maxLocalCells"))),
00054 minRefineCells_(readLabel(dict.lookup("minRefinementCells"))),
00055 nBufferLayers_(readLabel(dict.lookup("nCellsBetweenLevels"))),
00056 keepPoints_(pointField(1, dict.lookup("locationInMesh")))
00057 {
00058 scalar featAngle(readScalar(dict.lookup("resolveFeatureAngle")));
00059
00060 if (featAngle < 0 || featAngle > 180)
00061 {
00062 curvature_ = -GREAT;
00063 }
00064 else
00065 {
00066 curvature_ = Foam::cos(featAngle*mathematicalConstant::pi/180.0);
00067 }
00068 }
00069
00070
00071
00072
00073 Foam::labelList Foam::refinementParameters::findCells(const polyMesh& mesh)
00074 const
00075 {
00076
00077 globalIndex globalCells(mesh.nCells());
00078
00079
00080 labelList cellLabels(keepPoints_.size());
00081
00082 forAll(keepPoints_, i)
00083 {
00084 const point& keepPoint = keepPoints_[i];
00085
00086 label localCellI = mesh.findCell(keepPoint);
00087
00088 label globalCellI = -1;
00089
00090 if (localCellI != -1)
00091 {
00092 Pout<< "Found point " << keepPoint << " in cell " << localCellI
00093 << " on processor " << Pstream::myProcNo() << endl;
00094 globalCellI = globalCells.toGlobal(localCellI);
00095 }
00096
00097 reduce(globalCellI, maxOp<label>());
00098
00099 if (globalCellI == -1)
00100 {
00101 FatalErrorIn
00102 (
00103 "refinementParameters::findCells(const polyMesh&) const"
00104 ) << "Point " << keepPoint
00105 << " is not inside the mesh or on a face or edge." << nl
00106 << "Bounding box of the mesh:" << mesh.bounds()
00107 << exit(FatalError);
00108 }
00109
00110 if (globalCells.isLocal(globalCellI))
00111 {
00112 cellLabels[i] = localCellI;
00113 }
00114 else
00115 {
00116 cellLabels[i] = -1;
00117 }
00118 }
00119 return cellLabels;
00120 }
00121
00122
00123
Copyright © 2000-2009 OpenCFD Ltd