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 "evaluateError.H"
00027 #include <finiteVolume/volFields.H>
00028 #include <finiteVolume/surfaceFields.H>
00029 #include <dynamicMesh/refineCell.H>
00030
00031
00032
00033
00034
00035 Foam::evaluateError::evaluateError()
00036 :
00037 unsplitFaces_(),
00038 refCells_()
00039 {}
00040
00041
00042
00043 Foam::evaluateError::evaluateError
00044 (
00045 const volScalarField& cellError,
00046 const volVectorField& gradTheta,
00047 const surfaceScalarField& faceError,
00048 const labelList& candidateFaces
00049 )
00050 :
00051 unsplitFaces_(candidateFaces.size()),
00052 refCells_()
00053 {
00054 const polyMesh& mesh = cellError.mesh();
00055
00056
00057
00058
00059
00060
00061 scalar avgError = cellError.average().value();
00062
00063 scalar squareError = sqr(cellError)().average().value();
00064 scalar deviation = sqrt(squareError - sqr(avgError));
00065
00066 Info<< "avgError:" << avgError
00067 << " squareError:" << squareError
00068 << " deviation:" << deviation
00069 << endl;
00070
00071 scalar ref = avgError + deviation;
00072 scalar unref = avgError - deviation;
00073
00074 Info<< "evaluateError : refinement criterion : " << ref << endl
00075 << " unrefinement criterion : " << unref << endl;
00076
00077
00078
00079
00080
00081
00082
00083
00084 boolList markedFace(mesh.nFaces(), false);
00085
00086 label unsplitFaceI = 0;
00087
00088
00089 forAll(candidateFaces, candidateFaceI)
00090 {
00091 label faceI = candidateFaces[candidateFaceI];
00092
00093 if (markedFace[faceI])
00094 {
00095 Info<< "evaluateError : protected candidate face:" << faceI
00096 << endl;
00097 }
00098 else
00099 {
00100
00101 if (unsplitFaceI < (candidateFaces.size()/2 + 1))
00102 {
00103 unsplitFaces_[unsplitFaceI++] = faceI;
00104
00105
00106 }
00107 }
00108 }
00109
00110 unsplitFaces_.setSize(unsplitFaceI);
00111
00112
00113
00114
00115
00116
00117 boolList markedCells(mesh.nCells(), false);
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 label refCellI = 0;
00136
00137 forAll(cellError, cellI)
00138 {
00139 if ((cellError[cellI] > ref) && !markedCells[cellI])
00140 {
00141 refCellI++;
00142 }
00143 }
00144
00145 refCells_.setSize(refCellI);
00146
00147 refCellI = 0;
00148
00149 forAll(cellError, cellI)
00150 {
00151 if ((cellError[cellI] > ref) && !markedCells[cellI])
00152 {
00153 refCells_[refCellI++] = refineCell(cellI, gradTheta[cellI]);
00154 }
00155 }
00156
00157 Info<< "evaluateError : selected " << unsplitFaces_.size()
00158 << " faces out of " << candidateFaces.size() << " for removal" << endl;
00159 Info<< "evaluateError : selected " << refCells_.size()
00160 << " cells out of " << cellError.size() << " for refinement" << endl;
00161 }
00162
00163
00164