// Construct from components Foam::evaluateError::evaluateError ( const volScalarField& cellError, const volVectorField& gradTheta, const surfaceScalarField& faceError, const labelList& candidateFaces ) : unsplitFaces_(candidateFaces.size()), refCells_() { const polyMesh& mesh = cellError.mesh(); // picks up the error field and the gradient of the variable // and appends lists of cells to refine/unrefine based on the width of // standard deviation of the error distribution // calculate the average error scalar avgError = cellError.average().value(); scalar squareError = sqr(cellError)().average().value(); scalar deviation = sqrt(squareError - sqr(avgError)); Info<< "avgError:" << avgError << " squareError:" << squareError << " deviation:" << deviation << endl; scalar ref = avgError + deviation; scalar unref = avgError - deviation; Info<< "evaluateError : refinement criterion : " << ref << endl << " unrefinement criterion : " << unref << endl; // Coarsen mesh first. // Find out set of candidateFaces where error is above crit. // Construct to filter unrefinement pattern // removeFaces faceRemover(mesh); // Keep track of unrefinement pattern. boolList markedFace(mesh.nFaces(), false); label unsplitFaceI = 0; // Subset candidate faces and update refinement pattern interference pattern forAll(candidateFaces, candidateFaceI) { label faceI = candidateFaces[candidateFaceI]; if (markedFace[faceI]) { Info<< "evaluateError : protected candidate face:" << faceI << endl; } else { // if (faceError[faceI] < unref) if (unsplitFaceI < (candidateFaces.size()/2 + 1)) { unsplitFaces_[unsplitFaceI++] = faceI; // faceRemover.markAffectedFaces(faceI, markedFace); } } }