1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
// -*- C++ -*-
// -------------------------------------------------------------------
// MAdLib - Copyright (C) 2008-2009 Universite catholique de Louvain
//
// See the Copyright.txt and License.txt files for license information.
// You should have received a copy of these files along with MAdLib.
// If not, see <http://www.madlib.be/license/>
//
// Please report all bugs and problems to <contrib@madlib.be>
//
// Authors: Gaetan Compere, Jean-Francois Remacle
// -------------------------------------------------------------------
#ifndef _H_MESHQUALITYMANAGER
#define _H_MESHQUALITYMANAGER
#include "SizeFieldBase.h"
#include "ElementEvaluatorBase.h"
#include "MeshDataBaseInterface.h"
#include "MAdSingleton.h"
#include <iostream>
namespace MAd {
// -------------------------------------------------------------------
class MeshQualityManager {
public:
MeshQualityManager():evaluator(NULL), histogram(NULL), histogramAvg(NULL){};
~MeshQualityManager() {};
void initialize(pMesh m, DiscreteSF * sf, evaluationType type);
void setMesh(pMesh m);
void finalize();
// -------------------------------------------------------------------
public:
const pMeshDataId getShapeId() const { return shapeId; }
const elementEvaluatorBase * getElementEvaluator() const { return evaluator; }
// evaluate missing shapes
void evaluateAllShapes() const;
// evaluate all shapes, replace existing ones
void evaluateAndReplaceAllShapes() const;
// compute and return the shape of the face (no storage for faces)
// return 0 if the face is not acceptable, 1 otherwise
int getShape(pFace pf, double normal[3], double * result) const;
int getShapeWithDisp(pFace pf, double normal[3],
double disp[3][3], double * result) const;
// get the shape of the region, compute and store the shape if missing
// return 0 if the region is not acceptable, 1 otherwise
int getShape(pRegion pr, double * result) const;
int getShapeWithDisp(pRegion pr, double disp[4][3], double * result) const;
// delete all shapes
void clearAllShapes() const;
// delete the shape of this entity
void clearShape(pEntity pe) const;
// delete all shapes of the elements neighbouring the entity
void clearNeighbourShapes(pVertex pv) const;
void clearNeighbourShapes(pEdge pe) const;
// evaluate the worst shape of all elements surrounding one or several entities
int V_worstShape(pVertex v, double* result) const;
int E_worstShape(pEdge e, double* result) const;
int F_worstShape(pFace f, double* result) const;
// evaluate the worst shape in a list of elements
int FList_worstShape(pPList faces, double * result) const;
int RList_worstShape(pPList regions, double * result) const;
// check that the attached shapes are still correct (debugging function)
bool checkAttachedShapes() const;
private:
// attach a computed shape to the entity
void attachShape(pEntity pe, double shape) const;
// get the shape of an entity if it exists, return false otherwise
bool getAttachedShape(const pEntity pe, double* result) const;
public:
// Evaluate statistics about elements sizes
void evaluateSizes();
// Evaluate statistics about elements shapes
void evaluateShapes();
// Evaluate all statistics
void evaluateStatistics();
// get statistics ( evaluate it first )
double getMeanShape() const { return meanShape; }
double getWorstShape() const { return worstShape; }
double getMinSize() const { return minAbsoluteSize; }
double getMaxSize() const { return maxAbsoluteSize; }
void printStatistics(std::ostream& out) const;
// -------------------------------------------------------------------
private:
pMesh mesh;
int dim;
DiscreteSF * sizeField;
elementEvaluatorBase* evaluator;
pMeshDataId shapeId;
// --- statistics ---
// ------------------
int nbElem;
double worstShape;
double meanShape;
double minAbsoluteSize; // Area or volume of the smallest element in usual space (no metric)
double maxAbsoluteSize; // Area or volume of the biggest element in usual space (no metric)
double sizesSum;
int notAcpt; // number of non acceptable elements
int* histogram; // counters of elements with different qualities
double* histogramAvg; // proportion of elements with different qualities
};
// -------------------------------------------------------------------
typedef MAdSingleton<MeshQualityManager> MeshQualityManagerSgl;
}
#endif
|