[Pkg-scicomp-commits] [SCM] MAdLib, a mesh adaptation library. branch, master, updated. debian/1.2.2-1-4-g31217cd
Christophe Prud'homme
prudhomm at debian.org
Sun Oct 11 10:14:52 UTC 2009
The following commit has been merged in the master branch:
commit 31217cd5a055ccea87d7132a6f6cc1fd83372c01
Author: Christophe Prud'homme <prudhomm at debian.org>
Date: Sun Oct 11 12:12:54 2009 +0200
cleanup
diff --git a/Adapt/AdaptInterface.cc b/Adapt/AdaptInterface.cc
deleted file mode 100644
index 9e47dd1..0000000
--- a/Adapt/AdaptInterface.cc
+++ /dev/null
@@ -1,1469 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "AdaptInterface.h"
-#include "CPUTimeManager.h"
-#include "MAdTimeManager.h"
-#include "NodalDataManager.h"
-#include "MAdStatistics.h"
-#include "ModelConstraintManager.h"
-#include "MAdMessage.h"
-#include "History.h"
-
-// standard C/C++
-#include <iostream>
-#include <stdlib.h>
-#include <fstream>
-
-#ifdef PARALLEL
-#include "mpi.h"
-#include "MeshDataBaseParallelInterface.h"
-#endif
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::set;
-using std::vector;
-using std::multiset;
-using std::string;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void MeshAdapterAbortFct(void * data) {
- ((MeshAdapter *) data) -> abort();
- }
-
- // -------------------------------------------------------------------
- MeshAdapter::MeshAdapter(pMesh m, pSField sf):
- mesh(m),
- eSplitOp(0), eCollapseOp(0), fCollapseOp(0), descOp(0),
- eSwapOp(0), fSwapOp(0), vMoveOp(0), rRegionOp(0), sliverFOp(0),
- sliverROp(0), geoTracker(0),
- mpm(MeshParametersManagerSgl::instance()),
- verbosity(2), outPrefix(""), debugLevel(0)
- {
- SFManager = new SizeFieldManager(mesh,sf);
-
- MAdMsgSgl ::instance().initialize();
- MAdMsgSgl ::instance().registerAbortFct(MeshAdapterAbortFct,this);
- MAdTimeManagerSgl ::instance().initialize();
- MAdStatisticsSgl ::instance().initialize();
- CallBackManagerSgl ::instance().initialize();
- NodalDataManagerSgl ::instance().initialize(mesh);
- MeshQualityManagerSgl::instance().initialize(mesh,SFManager->getSizeField(),MEANRATIO);
- HistorySgl ::instance().initialize();
- HistorySgl ::instance().closeJournal();
- CPUTimeManagerSgl ::instance().initialize();
- ModelConstraintManagerSgl::instance().initialize(M_model(mesh));
- MeshParametersManagerSgl::instance().initialize();
-
- if (mesh) buildOperators();
-
- setDefaultValues();
- }
-
- // -------------------------------------------------------------------
- MeshAdapter::~MeshAdapter()
- {
- removeOperators();
- if (geoTracker) delete geoTracker;
- if (SFManager) delete SFManager;
-
- MAdTimeManagerSgl ::instance().finalize();
- MAdStatisticsSgl ::instance().finalize();
- CallBackManagerSgl ::instance().finalize();
- NodalDataManagerSgl ::instance().finalize();
- MeshQualityManagerSgl::instance().finalize();
- HistorySgl ::instance().finalize();
- CPUTimeManagerSgl ::instance().finalize();
- ModelConstraintManagerSgl::instance().finalize();
- MeshParametersManagerSgl::instance().finalize();
- MAdMsgSgl ::instance().finalize();
- }
-
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- void MeshAdapter::setDefaultValues()
- {
- algorithm = CPS_SWP_SLV_SPT;
- maxIterationsNumber = 20;
-
- setEdgeLenSqBounds ( 0.25 , 2.56 ); // [ 0.5 ^ 2 , 1.6 ^ 2 ]
-
- if (M_dim(mesh) == 2) {
- setNoSwapQuality ( 0.2 );
- maxIterationsNumber = 10;
- }
- else { // to be checked
- setNoSwapQuality ( 0.1 );
- }
- mpm.setSwapMinImproveRatio ( 1.2 );
-
- mpm.setSliverTriBound ( 0.01 );
- mpm.setSliverTetBound ( 0.01 );
-
- // infinite loops control
- setSliverPermissionInESplit ( true, 10.24 ); // 3.2 ^2
- setSliverPermissionInECollapse ( true, 0.0625 ); // 0.25 ^2
-
- setCollapseOnBoundary ( false, 0. );
- setSwapOnBoundary ( false, 0. );
-
-#ifdef PARALLEL
- load_balance_algorithm = DEFAULT_ALGORITHM;
- dataEchangerPtr = NULL;
-#endif
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setEdgeLenSqBounds(double lower, double upper)
- {
- if ( sqrt(lower) > 0.5*sqrt(upper) ) {
- cout << "Warning: edge length interval is too small ("
- << sqrt(lower) << ", " << sqrt(upper) <<")\n";
- }
-
- mpm.setLowerLengthSqBound(lower);
- mpm.setUpperLengthSqBound(upper);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setCollapseOnBoundary(bool accept, double tolerance)
- {
- eCollapseOp->collapseOnBoundary(accept,tolerance);
- fCollapseOp->collapseOnBoundary(accept,tolerance);
- sliverROp ->collapseOnBoundary(accept,tolerance);
- sliverFOp ->collapseOnBoundary(accept,tolerance);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setSwapOnBoundary(bool accept, double tolerance)
- {
- eSwapOp ->swapOnBoundary(accept,tolerance);
- sliverROp->swapOnBoundary(accept,tolerance);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setMaxIterationsNumber(int max)
- {
- maxIterationsNumber = max;
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setNoSwapQuality(double noSwapQuality)
- {
- mpm.setNoSwapQuality(noSwapQuality);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setSwapMinImproveRatio(double ratio)
- {
- mpm.setSwapMinImproveRatio(ratio);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setSliverQuality(double sliverQuality)
- {
- mpm.setSliverTriBound(sliverQuality);
- mpm.setSliverTetBound(sliverQuality);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setSliverPermissionInESplit(bool perm, double bound)
- {
- mpm.setSliverPermissionInESplit(perm, bound);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setSliverPermissionInECollapse(bool perm, double bound)
- {
- mpm.setSliverPermissionInECollapse(perm, bound);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setGeoTracking(bool track, bool cavityEqualMesh,
- int cavityThickness, double chi)
- {
- if ( track && !geoTracker) {
- geoTracker = new geoMatcher(mesh);
- geoTracker->setCavityEqualMesh(cavityEqualMesh,cavityThickness);
- geoTracker->setStiffnessAlterationCoef(chi);
- }
- else if ( !track && geoTracker) {
- delete geoTracker;
- geoTracker = NULL;
- }
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setInfiniteLength(double length)
- {
- mpm.setBigLength(length);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setVerbosity(int _verbosity)
- {
- verbosity = _verbosity;
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::clearConstraints() const
- {
- DeleteConstraint(mesh);
- ModelConstraintManagerSgl::instance().clear();
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setConstraint(pEntity e) const
- {
- EN_constrain(e);
-
- switch (EN_type(e)) {
- case 1:
- EN_constrain( (pEntity)E_vertex((pEdge)e,0) );
- EN_constrain( (pEntity)E_vertex((pEdge)e,1) );
- break;
- case 2:
- setConstraint( (pEntity)F_edge((pFace)e,0) );
- setConstraint( (pEntity)F_edge((pFace)e,1) );
- setConstraint( (pEntity)F_edge((pFace)e,2) );
- break;
- case 3:
- setConstraint( (pEntity)R_face((pRegion)e,0) );
- setConstraint( (pEntity)R_face((pRegion)e,1) );
- setConstraint( (pEntity)R_face((pRegion)e,2) );
- setConstraint( (pEntity)R_face((pRegion)e,3) );
- break;
- }
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setConstraint(int type, int id) const
- {
- ModelConstraintManagerSgl::instance().constrain(type,id);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::removeConstraint(int type, int id) const
- {
- ModelConstraintManagerSgl::instance().unconstrain(type,id);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setConstraint(pGEntity e) const
- {
- ModelConstraintManagerSgl::instance().constrain(e);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::removeConstraint(pGEntity e) const
- {
- ModelConstraintManagerSgl::instance().unconstrain(e);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::removeOperators()
- {
- if (eSplitOp) { delete eSplitOp; eSplitOp=0; }
- if (eCollapseOp) { delete eCollapseOp; eCollapseOp=0; }
- if (fCollapseOp) { delete fCollapseOp; fCollapseOp=0; }
- if (descOp) { delete descOp; descOp=0; }
- if (eSwapOp) { delete eSwapOp; eSwapOp=0; }
- if (fSwapOp) { delete fSwapOp; fSwapOp=0; }
- if (vMoveOp) { delete vMoveOp; vMoveOp=0; }
- if (rRegionOp) { delete rRegionOp; rRegionOp=0; }
- if (sliverFOp) { delete sliverFOp; sliverFOp=0; }
- if (sliverROp) { delete sliverROp; sliverROp=0; }
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::buildOperators()
- {
- removeOperators();
-
- eSplitOp = new edgeSplitOp (mesh,SFManager->getSizeField());
- eCollapseOp = new edgeCollapseOp (mesh,SFManager->getSizeField());
- fCollapseOp = new faceCollapseOp (mesh,SFManager->getSizeField());
- descOp = new DESCOp (mesh,SFManager->getSizeField());
- eSwapOp = new edgeSwapOp (mesh,SFManager->getSizeField());
- fSwapOp = new faceSwapOp (mesh,SFManager->getSizeField());
- vMoveOp = new vertexMoveOp (mesh,SFManager->getSizeField(),false);
- rRegionOp = new regionRemoveOp (mesh,SFManager->getSizeField());
- sliverROp = new sliverRegionHandler (mesh,SFManager->getSizeField());
- sliverFOp = new sliverFaceHandler (mesh,SFManager->getSizeField());
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::addCallback(CBFunction CB, void* userData,
- CBFunc_move CB_move, void* userData_move)
- {
- CallBackManagerSgl::instance().registerCallBack(CB,userData);
- if (CB_move) {
- CallBackManagerSgl::instance().registerCallBackMove(CB_move,userData_move);
- }
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::addSizeField(pSField sf)
- {
- SFManager->addSizeField(sf);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setSizeFieldSmoothing(bool enable, double maxGrad)
- {
- SFManager->setSmoothing(enable,maxGrad);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::incrementTime(double dt)
- {
- MAdTimeManagerSgl::instance().incrementTime(dt);
- updateSizeField();
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setTime(double t)
- {
- MAdTimeManagerSgl::instance().setTime(t);
- updateSizeField();
- }
-
- // -------------------------------------------------------------------
- double MeshAdapter::getTime() const {
- return MAdTimeManagerSgl::instance().getTime();
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::updateSizeField()
- {
- SFManager->update();
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::storeInitialCoordinates()
- {
- if ( getTime() != 0. ) {
- cout << "Warning: storing coordinates at time " << getTime() << endl;
- }
- NodalDataManagerSgl::instance().storeCoordinates();
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::removeStoredCoordinates()
- {
- NodalDataManagerSgl::instance().removeCoordinates();
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::registerObjects(mobileObjectSet* objs)
- {
- set<mobileObject*> allObj = objs->getObjects();
-
- set<mobileObject*>::const_iterator it = allObj.begin();
- for (; it != allObj.end(); it++) {
- set<LocalSizeField* > sizes = (*it)->getSizes();
- set<LocalSizeField* >::iterator it = sizes.begin();
- for (; it != sizes.end(); it++) {
- SFManager->addSizeField(*it);
- }
- }
-
- objects = objs;
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::registerData (string name,
- const vector<double> data) const
- {
- NodalDataManagerSgl::instance().registerData(name,data);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::registerVData (string name,
- const vector<vector<double> > data) const
- {
- NodalDataManagerSgl::instance().registerVData(name,data);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::getMeshData (string name,
- vector<double> * data) const
- {
- NodalDataManagerSgl::instance().getMeshData(name,data);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::getMeshVData (string name,
- vector<vector<double> > * data) const
- {
- NodalDataManagerSgl::instance().getMeshVData(name,data);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::removeData (string name) const
- {
- NodalDataManagerSgl::instance().removeData(name);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::removeVData (string name) const
- {
- NodalDataManagerSgl::instance().removeVData(name);
- }
-
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- // LEVEL 1 OPERATIONS
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- bool MeshAdapter::splitEdge(pEdge edge, bool checkSize)
- {
- // set edge to split
- double reducSq = eSplitOp->setSplitEdge(edge);
-
- // check that the edge is not splitted in short edges
- if ( checkSize )
- {
- double lenSq = SFManager->getSizeField()->SF_E_lengthSq(edge);
- if ( ( reducSq * lenSq ) <= mpm.getLowerLengthSqBound() ) return false;
- }
-
- // do the checks
- double worstShape;
- if ( !eSplitOp->evaluate(&worstShape) ) return false;
-
- // check that we do not create a worse sliver ( if asked for )
- // if we can create new slivers, check that the edge is long enough to allow it
- if ( worstShape < mpm.getSliverTetBound() )
- {
- double oriWorst;
- MeshQualityManagerSgl::instance().E_worstShape(edge, &oriWorst);
- if ( worstShape < oriWorst ) {
- if ( !mpm.getSliverPermissionInESplit() ) return false;
- if ( mpm.getSliverUpperLengthSqBound() > 0. &&
- mpm.getSliverUpperLengthSqBound() > SFManager->getSizeField()->SF_E_lengthSq(edge) )
- {
- return false;
- }
- }
- }
-
- // do the job
- eSplitOp->apply();
- return true;
- }
-
- // -------------------------------------------------------------------
- bool MeshAdapter::collapseEdge(pEdge edge)
- {
- double shapes[2] = {-1.,-1.};
- int ok[2] = {0,0};
-
- for (int iDir=0; iDir<2; iDir++) {
-
- pVertex vDel = E_vertex(edge,iDir);
- pVertex vTgt = E_vertex(edge,1-iDir);
- eCollapseOp->setCollapseEdge(edge,vDel,vTgt);
-
- // eCollapseOp->setCollapseEdge(edge,iDir);
-
- // do the checks
- ok[iDir] = eCollapseOp->evaluate(&(shapes[iDir]));
-
- // check that we do not create a worse sliver ( if asked for )
- // if we can create new slivers, check that the edge is short enough to allow it
- if ( shapes[iDir] < mpm.getSliverTetBound() )
- {
- double oriWorst;
- MeshQualityManagerSgl::instance().E_worstShape(edge, &oriWorst);
- if ( shapes[iDir] < oriWorst ) {
- if ( !mpm.getSliverPermissionInECollapse() ) ok[iDir] = 0;
- if ( mpm.getSliverLowerLengthSqBound() > 0. &&
- mpm.getSliverLowerLengthSqBound() < SFManager->getSizeField()->SF_E_lengthSq(edge) )
- {
- ok[iDir] = 0;
- }
- }
- }
- }
-
- // find the best direction
- int best = -1; double worst = -1.;
- if ( ok[0] ) { best = 0; worst = shapes[0]; }
- if ( ok[1] && shapes[1] > worst ) {
- best = 1;
- worst = shapes[1];
- }
-
- // if possible apply an edge collapse
- if ( best >= 0 ) {
- pVertex vDel = E_vertex(edge,best);
- pVertex vTgt = E_vertex(edge,1-best);
- eCollapseOp->setCollapseEdge(edge,vDel,vTgt);
- eCollapseOp->apply();
- return true;
- }
-
- return false;
- }
-
- // -------------------------------------------------------------------
- bool MeshAdapter::collapseFace(pFace face, pEdge edge)
- {
- // for( int ClpsOnvt = 1; ClpsOnvt >=0; ClpsOnvt-- ) {
- for( int ClpsOnvt = 0; ClpsOnvt < 2; ClpsOnvt++ ) {
- fCollapseOp->reset(face, edge, ClpsOnvt);
-
- // do the checks
- double worstShape;
- if ( !fCollapseOp->evaluate(&worstShape) ) continue;
-
- // check that we do not create a sliver
- if ( worstShape < mpm.getSliverTetBound() ) continue;
-
- // do the job
- fCollapseOp->apply();
- return true;
- }
- return false;
- }
-
- // -------------------------------------------------------------------
- bool MeshAdapter::DSplitCollapseEdge(pRegion pr, pEdge edge1, pEdge edge2)
- {
- descOp->setDESC(pr,edge1,edge2);
-
- // do the checks
- double worstShape;
- if ( !descOp->evaluate(&worstShape) ) return false;
-
- // check that we do not create a sliver
- if ( worstShape < mpm.getSliverTetBound() ) return false;
-
- // do the job
- descOp->apply();
- return true;
- }
-
- // -------------------------------------------------------------------
- bool MeshAdapter::swapEdge(pEdge edge)
- {
- eSwapOp->setSwapEdge(edge);
-
- // do the checks
- double worstShape;
- if ( !eSwapOp->evaluate(&worstShape) ) return false;
-
- // check that we do not create a sliver
- if ( worstShape < mpm.getSliverTetBound() ) return false;
-
- // do the job
- eSwapOp->apply();
- return true;
- }
-
- // -------------------------------------------------------------------
- bool MeshAdapter::swapFace(pFace face)
- {
- fSwapOp->setSwapFace(face);
-
- // do the checks
- double worstShape;
- if ( !fSwapOp->evaluate(&worstShape) ) return false;
-
- // check that we do not create a sliver
- if ( worstShape < mpm.getSliverTetBound() ) return false;
-
- // do the job
- fSwapOp->apply();
- return true;
- }
-
- // -------------------------------------------------------------------
- bool MeshAdapter::moveVertex (pVertex v, double dxyz[3])
- {
- return vMoveOp->move(v,dxyz);
- }
-
- // -------------------------------------------------------------------
- bool MeshAdapter::removeRegion(pRegion region)
- {
- rRegionOp->setRegion(region);
-
- // do the checks
- double worstShape;
- if ( !rRegionOp->evaluate(&worstShape) ) return false;
-
- // check that we do not create a sliver
- if ( worstShape < mpm.getSliverTetBound() ) return false;
-
- // do the job
- rRegionOp->apply();
- return true;
- }
-
- // -------------------------------------------------------------------
- bool MeshAdapter::putVertex (pVertex v, double xyz[3])
- {
- double oriPos[3], dxyz[3];
- V_coord(v,oriPos);
- for (int i=0; i<3; i++) dxyz[i] = xyz[i] - oriPos[i];
- return moveVertex(v,dxyz);
- }
-
- // -------------------------------------------------------------------
- bool MeshAdapter::moveVertices (multiset<vDisplacement,vDisplacementLess>& vDisps)
- {
- return vMoveOp->move(vDisps);
- }
-
- // -------------------------------------------------------------------
- // LEVEL 2 OPERATIONS
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double MeshAdapter::LaplaceSmoothing(LaplSmooType type)
- {
- CPUTimeManager& tm = CPUTimeManagerSgl::instance();
- MAdStatistics& stat = MAdStatisticsSgl ::instance();
-
- double t0 = tm.getTime();
-
- double convergenceCriterion = 1e-2;
- double L2Disp = 0.;
- LaplaceSmoothingOp* laplOp = new LaplaceSmoothingOp(mesh,SFManager->getSizeField());
- laplOp->run(type,&L2Disp);
- double L2Disp0 = L2Disp; int i = 0;
- double L2DispTot = 0.;
- while ( ( L2Disp > convergenceCriterion * L2Disp0 ) && ( L2Disp > MAdTOL ) ) {
- laplOp->run(type,&L2Disp);
- i++;
- L2DispTot += L2Disp;
- }
- if (laplOp) delete laplOp;
-
- double dt = tm.getTime() - t0;
- if ( verbosity >= 2 ) {
- cout << "Performed a Laplace smoothing: total L2 norm of the displacements: "<<L2DispTot<<" in "<<dt<<" seconds\n";
- }
-
- if ( debugLevel >= 3 && !checkTheMesh() ) abort(__LINE__,__FILE__);
-
- return L2DispTot;
- }
-
- // -------------------------------------------------------------------
- int MeshAdapter::eSplitLoop()
- {
- CPUTimeManager& tm = CPUTimeManagerSgl::instance();
- MAdStatistics& stat = MAdStatisticsSgl ::instance();
-
- double t0 = tm.getTime();
-
- int nSplit = 0;
- int countE = 0; int oriNbEdges = M_numEdges(mesh);
- EIter ei = M_edgeIter(mesh);
- pEdge edge;
- while ( (countE < oriNbEdges) && ( edge = EIter_next(ei) ) ) {
- double lengthSq = SFManager->getSizeField()->SF_E_lengthSq(edge);
- if ( lengthSq > mpm.getUpperLengthSqBound() ) if (splitEdge(edge,true)) nSplit++;
- countE++;
- }
- EIter_delete(ei);
-
- double dt = tm.getTime() - t0;
- stat.addCPUESplits(dt);
- stat.addNumESplits(nSplit);
- if ( verbosity >= 2 ) {
- cout << "Performed "<< nSplit<<" edge splits in "<<dt<<" seconds\n";
- }
-
- if ( debugLevel >= 3 && !checkTheMesh() ) abort(__LINE__,__FILE__);
-
- // --- Geometry tracking ---
- if (nSplit) snapVertices();
-
- return nSplit;
- }
-
- // -------------------------------------------------------------------
- int MeshAdapter::eCollapseLoop()
- {
- CPUTimeManager& tm = CPUTimeManagerSgl::instance();
- MAdStatistics& stat = MAdStatisticsSgl ::instance();
-
- double t0 = tm.getTime();
-
- int nCollapse = 0;
- int countE = 0; int oriNbEdges = M_numEdges(mesh);
- EIter ei = M_edgeIter(mesh);
- pEdge edge;
- while ( (countE < oriNbEdges) && ( edge = EIter_next(ei) ) ) {
- double lengthSq = SFManager->getSizeField()->SF_E_lengthSq(edge);
- if ( lengthSq < mpm.getLowerLengthSqBound() ) if (collapseEdge(edge)) nCollapse++;
- countE++;
- }
- EIter_delete(ei);
-
- double dt = tm.getTime() - t0;
- stat.addCPUECollapses(dt);
- stat.addNumECollapses(nCollapse);
- if ( verbosity >= 2 ) {
- cout << "Performed "<< nCollapse<<" edge collapses in "<<dt<<" seconds\n";
- }
-
- if ( debugLevel >= 3 && !checkTheMesh() ) abort(__LINE__,__FILE__);
-
- return nCollapse;
- }
-
- // -------------------------------------------------------------------
- int MeshAdapter::eSplitCollapseLoop()
- {
- int nSplit = 0;
- int nCollapse = 0;
- int countE = 0; int oriNbEdges = M_numEdges(mesh);
- EIter ei = M_edgeIter(mesh);
- pEdge edge;
- while ( (countE < oriNbEdges) && ( edge = EIter_next(ei) ) ) {
- double lengthSq = SFManager->getSizeField()->SF_E_lengthSq(edge);
- if ( lengthSq > mpm.getUpperLengthSqBound() ) if (splitEdge(edge,true)) nSplit++;
- if ( lengthSq < mpm.getLowerLengthSqBound() ) if (collapseEdge(edge)) nCollapse++;
- countE++;
- }
- EIter_delete(ei);
-
- if ( debugLevel >= 3 && !checkTheMesh() ) abort(__LINE__,__FILE__);
-
- return nSplit+nCollapse;
- }
-
- // -------------------------------------------------------------------
- int MeshAdapter::edgeSwapLoop()
- {
- CPUTimeManager& tm = CPUTimeManagerSgl::instance();
- MAdStatistics& stat = MAdStatisticsSgl ::instance();
-
- double t0 = tm.getTime();
-
- int nb_eswap = 0;
- pEdge edge;
- EIter ei = M_edgeIter(mesh);
- int ne = M_numEdges(mesh);
- int i = 0;
- while( ( edge = EIter_next(ei) ) )
- {
- if( i > ne ) break;
- i++;
-
- if( EN_constrained((pEntity)edge) ) continue;
- if( E_numRegions(edge) > eSwapOp->getMaxNumRgns() ) continue;
-
- double worstShape;
- MeshQualityManagerSgl::instance().E_worstShape(edge, &worstShape);
-
- if( worstShape > mpm.getNoSwapQuality() ) continue;
-
- eSwapOp->setSwapEdge(edge);
-
- double newWorstShape;
- if( eSwapOp->evaluate(&newWorstShape) )
- {
- if( newWorstShape > mpm.getSwapMinImproveRatio()*worstShape )
- {
- if( ( eSwapOp->getMaxLenSq() < mpm.getUpperLengthSqBound() ) &&
- ( eSwapOp->getMinLenSq() > mpm.getLowerLengthSqBound() ) )
- {
- eSwapOp->apply();
- nb_eswap++;
- }
- }
- }
- }
- EIter_delete(ei);
-
- double dt = tm.getTime() - t0;
- stat.addCPUESwaps(dt);
- stat.addNumESwaps(nb_eswap);
- if ( verbosity >= 2 ) {
- cout << "Performed "<< nb_eswap<<" edge swaps in "<<dt<<" seconds\n";
- }
-
- if ( debugLevel >= 3 && !checkTheMesh() ) abort(__LINE__,__FILE__);
-
- return nb_eswap;
- }
-
- // -------------------------------------------------------------------
- int MeshAdapter::faceSwapLoop()
- {
- int nfswap = 0;
- pFace face;
- FIter fi = M_faceIter(mesh);
- int nf = M_numFaces(mesh);
- int i = 0;
- while ( ( face = FIter_next(fi) ) ) {
- if( i > nf ) break;
- i++;
-
- if( EN_constrained((pEntity)face) ) continue;
-
- double oriWorst;
- MeshQualityManagerSgl::instance().F_worstShape(face, &oriWorst);
-
- if ( oriWorst > mpm.getNoSwapQuality() ) continue;
-
- fSwapOp->setSwapFace(face);
- double newWorst;
- if( fSwapOp->evaluate(&newWorst) ) {
- if ( newWorst > mpm.getSwapMinImproveRatio()*oriWorst ) {
- fSwapOp->apply();
- nfswap++;
- }
- }
- }
- FIter_delete(fi);
-
- if ( debugLevel >= 3 && !checkTheMesh() ) abort(__LINE__,__FILE__);
-
- return nfswap;
- }
-
- // -------------------------------------------------------------------
- int MeshAdapter::splitEveryEdgeOnce()
- {
- CPUTimeManager& tm = CPUTimeManagerSgl::instance();
- double t0 = tm.getTime();
-
- // list initial edges
- std::set<pEdge> initEdges;
- EIter ei = M_edgeIter(mesh);
- pEdge edge;
- while ( ( edge = EIter_next(ei) ) ) initEdges.insert(edge);
- EIter_delete(ei);
-
- // split every edge
- int numOp = 0;
- std::set<pEdge>::const_iterator it = initEdges.begin();
- for (; it != initEdges.end(); it++ ) {
- if ( splitEdge( *it ) ) numOp++;
- }
-
- double dt = tm.getTime() - t0;
- if ( verbosity >= 2 ) {
- cout << "Performed "<< numOp<<" edge splits in "<<dt<<" seconds\n";
- }
-
- if ( debugLevel >= 3 && !checkTheMesh() ) abort(__LINE__,__FILE__);
-
- // --- Geometry tracking ---
- if (numOp) snapVertices();
-
- return numOp;
- }
-
- // -------------------------------------------------------------------
- int MeshAdapter::removeSlivers()
- {
- CPUTimeManager& tm = CPUTimeManagerSgl::instance();
- MAdStatistics& stat = MAdStatisticsSgl ::instance();
-
- double t0 = tm.getTime();
-
- int nbBefore, nbAfter;
- if (M_dim(mesh) == 3) sliverROp->removeSliverRegions(&nbBefore,&nbAfter);
- else sliverFOp->removeSliverFaces (&nbBefore,&nbAfter);
-
- double dt = tm.getTime() - t0;
- stat.addCPURSlivers(dt);
- if ( verbosity >= 2 ) {
- cout << "Removed slivers " << nbBefore << " -> " << nbAfter << " in "<<dt<<" seconds\n";
- }
-
- if ( debugLevel >= 3 && !checkTheMesh() ) abort(__LINE__,__FILE__);
-
- return ( nbBefore - nbAfter );
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::snapVertices()
- {
- if (geoTracker) {
- CPUTimeManager& tm = CPUTimeManagerSgl::instance();
- double t0 = tm.getTime();
-
- // --- prepare the node motion ---
- geoTracker->buildCavity();
- geoTracker->setDirichletBC();
- geoTracker->compute();
-
-// #warning "debug"
-// geoTracker->forceRelocation();
-
- // --- perform the node motion ---
- double ratio = 0.;
- int achieved = -1;
- while ( achieved != 2 )
- {
- achieved = geoTracker->advance(&ratio,1.e-12);
-
- if ( achieved == 0 ) {
- MAdMsgSgl::instance().warning(-1,__FILE__,
- "Could not advance snapping, achieved: %d, ratio: %f",achieved,ratio);
- }
- else {
- MAdMsgSgl::instance().info(-1,__FILE__,
- "Advance snapping, achieved: %d, ratio: %f",achieved,ratio);
- }
- if ( debugLevel >= 4 && !checkTheMesh() ) abort(__LINE__,__FILE__);
-
- if ( achieved <= 1 ) {
- // Apply the operations that do not add vertices or manage their
- // target locations (complicated!)
- bool slivR, slivF;
- if ( sliverROp ) slivR = sliverROp->getNewVertexPermission();
- if ( sliverFOp ) slivF = sliverFOp->getNewVertexPermission();
- if ( sliverROp ) sliverROp->newVertexPermission(false);
- if ( sliverFOp ) sliverFOp->newVertexPermission(false);
- if ( !removeSlivers() ) {
- if ( !optimiseElementShape() ) {
- string filename = outPrefix + "dirichlet.txt";
- std::ofstream dirichletOut(filename.c_str());
- geoTracker->printDirichlet(dirichletOut);
- dirichletOut.close();
- filename = outPrefix + "relocations.txt";
- std::ofstream relocationsOut(filename.c_str());
- geoTracker->printRelocations(relocationsOut);
- relocationsOut.close();
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Could not snap vertices, ratio reached: %f",ratio);
- }
- }
- if ( sliverROp ) sliverROp->newVertexPermission( slivR );
- if ( sliverFOp ) sliverFOp->newVertexPermission( slivF );
- if ( debugLevel >= 4 && !checkTheMesh() ) abort(__LINE__,__FILE__);
- }
- }
-
- geoTracker->clear();
-
- double dt = tm.getTime() - t0;
- MAdMsgSgl::instance().info(__LINE__,__FILE__,
- "Performed vertex snapping in %f seconds",dt);
- }
-
- if ( debugLevel >= 3 && !checkTheMesh() ) abort(__LINE__,__FILE__);
- }
-
- // -------------------------------------------------------------------
- // LEVEL 3 OPERATIONS
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- int MeshAdapter::optimiseEdgeLength()
- {
- int nbMaxItOptiLen = 10;
- int nSplColl = 0;
- for (int iter=0; iter < nbMaxItOptiLen; iter++ ) {
- int nSC = eSplitCollapseLoop();
- cout << "Applied "<<nSC<<" split or collapses\n";
- if (!nSC) break;
- nSplColl += nSC;
- }
- return nSplColl;
- }
-
- // -------------------------------------------------------------------
- int MeshAdapter::optimiseElementShape()
- {
- int nbMaxItOptiShp = 10;
- int nESwapTot = 0, nFSwapTot = 0;
- int nESwap = 0, nFSwap = 0;
- for (int iter=0; iter < nbMaxItOptiShp; iter++ ) {
- // find ill-shaped elements around each edge
- nESwap = edgeSwapLoop();
- cout << "Applied " << nESwap<< " edge swaps"<<endl;
- if ( M_dim(mesh) == 3 ) {
- // find ill-shaped elements around each face
- nFSwap = faceSwapLoop();
- cout << "Applied " << nFSwap<< " face swaps"<<endl;
- }
-
- if (nESwap+nFSwap == 0) break;
- nESwapTot += nESwap;
- nFSwapTot += nFSwap;
- }
- return ( nESwapTot + nFSwapTot );
- }
-
- // -------------------------------------------------------------------
- int MeshAdapter::splitLongestEdges()
- {
- CPUTimeManager& tm = CPUTimeManagerSgl::instance();
- MAdStatistics& stat = MAdStatisticsSgl ::instance();
-
- double t0 = tm.getTime();
-
- int nSplitTot = 0;
- double boundSq = 2.*mpm.getUpperLengthSqBound();
-
- while (1)
- {
- int nSplit = 0;
-
- EIter ei = M_edgeIter(mesh);
- pEdge edge;
- double lengthSq;
- while ( ( edge = EIter_next(ei) ) ) {
- lengthSq = SFManager->getSizeField()->SF_E_lengthSq(edge);
- if ( lengthSq > boundSq ) if (splitEdge(edge,true)) nSplit++;
- }
- EIter_delete(ei);
-
- nSplitTot += nSplit;
- if ( debugLevel >= 3 && !checkTheMesh() ) abort(__LINE__,__FILE__);
-
- if ( nSplit == 0 ) break;
- }
-
- double dt = tm.getTime() - t0;
- stat.addCPUESplits(dt);
- stat.addNumESplits(nSplitTot);
- if ( verbosity >= 2 ) {
- cout << "Performed "<< nSplitTot<<" (very long) edge splits in "<<dt<<" seconds\n";
- }
-
- // --- Geometry tracking ---
- if (nSplitTot) snapVertices();
-
- return nSplitTot;
- }
-
- // -------------------------------------------------------------------
- int MeshAdapter::runOneIter()
- {
- CPUTimeManager& tm = CPUTimeManagerSgl::instance();
-
- // --- constrain parallel interfaces ---
-#ifdef PARALLEL
- {
- double t0= tm.getTime();
- UpdateParallelConstraint(mesh);
- double dt = tm.getTime() - t0;
- MAdMsgSgl::instance().info(__LINE__,__FILE__,
- "Performed constraint of parallel interfaces in %f seconds",dt);
- MPI_Barrier(MPI_COMM_WORLD);
- }
-#endif
-
- // --- perform local mesh modifications ---
- int numTopoChg = 0;
-
- // first, split very long edges (avoid infinite loops split/collapse)
-// numTopoChg += splitLongestEdges();
-
- if ( algorithm == CPS_SWP_SLV_SPT )
- {
- numTopoChg += eCollapseLoop(); // Collapse short edges
- numTopoChg += edgeSwapLoop(); // Swap edges to improve elements quality
- numTopoChg += removeSlivers(); // Remove slivers
- numTopoChg += eSplitLoop(); // Split long edges
- }
-
- if ( algorithm == SPT_SWP_SLV_CPS )
- {
- numTopoChg += eSplitLoop(); // Split long edges
- numTopoChg += edgeSwapLoop(); // Swap edges to improve elements quality
- numTopoChg += removeSlivers(); // Remove slivers
- numTopoChg += eCollapseLoop(); // Collapse short edges
- }
-
- if ( algorithm == SLV_CPS_SWP_SPT )
- {
- numTopoChg += removeSlivers(); // Remove slivers
- numTopoChg += eCollapseLoop(); // Collapse short edges
- numTopoChg += edgeSwapLoop(); // Swap edges to improve elements quality
- numTopoChg += eSplitLoop(); // Split long edges
- }
-
- // --- Reposition the vertices ---
-// LaplaceSmoothing(OPTIMAL);
-// LaplaceSmoothing(FAST);
-
-#ifdef PARALLEL
- // --- move parallel interfaces ---
- {
- MPI_Barrier(MPI_COMM_WORLD);
- double t0= tm.getTime();
- DeleteParallelConstraint(mesh);
- double dt = tm.getTime() - t0;
- if( verbosity >= 2 ) {
- MAdMsgSgl::instance().info(__LINE__,__FILE__,
- "Performed unconstraint of parallel interface in %f seconds",dt);
- }
- if( numTopoChg !=0 ){
- t0= tm.getTime();
- switch( load_balance_algorithm ) {
- case DEFAULT_ALGORITHM:
- Balance2( mesh, *dataEchangerPtr );
- break;
- case METIS_ALGORITHM:
-#ifdef _HAVE_PARMETIS_
- BalanceMetis2( mesh, *dataEchangerPtr );
-#else
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Could not balance load: Parmetis not enabled");
-#endif
- break;
- default:
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Unknown load balancing algorithm: %d",
- load_balance_algorithm);
- }
- dt = tm.getTime() - t0;
- if( verbosity >= 2 ) {
- MAdMsgSgl::instance().info(__LINE__,__FILE__,
- "Performed load balancing in %f seconds",dt);
- }
- }
- }
-#endif
-
- // --- check the mesh (debug) ---
- if ( debugLevel >= 2 && !checkTheMesh() ) abort(__LINE__,__FILE__);
-
- return numTopoChg;
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::uglyTheMesh(double avgQualThresh, int maxIt)
- {
- MeshQualityManagerSgl::instance().evaluateStatistics();
- double meanQuality = MeshQualityManagerSgl::instance().getMeanShape();
-
- int iter = 0;
- while ( (meanQuality > avgQualThresh) && (iter < maxIt) ) {
-
- int numOp = 0;
- int oriNumFaces = M_numFaces(mesh);
- int count = 0;
- FIter fi = M_faceIter(mesh);
- pFace pf;
- while ( ( pf = FIter_next(fi) ) && ( count < oriNumFaces ) ) {
- int flag = 0;
- for (int j=0; j<3; j++) {
- pEdge pe = F_edge(pf,j);
- for( int ClpsOnvt = 0; ClpsOnvt < 2; ClpsOnvt++ ) {
- fCollapseOp->reset(pf, pe, ClpsOnvt);
- double worstShape;
- if ( fCollapseOp->evaluate(&worstShape) ) {
- fCollapseOp->apply();
- flag = 1;
- break;
- }
- }
- if ( flag ) {
- numOp++;
- break;
- }
- }
- count++;
- }
- FIter_delete(fi);
- cout << "Num face collapses: "<<numOp<<endl;
-
- meanQuality = MeshQualityManagerSgl::instance().getMeanShape();
- iter++;
- }
- }
-
- // -------------------------------------------------------------------
- //! Removes elements with negative volume and returns \ingroup adaptation
- //! number of remaining negative volumes
- int MeshAdapter::removeNegativeElements()
- {
- int nNeg = 0;
- int nRem = 0;
- RIter rIt= M_regionIter(mesh);
- while ( pRegion region = RIter_next(rIt) ) {
- if (R_volume(region) < 0.) {
- nNeg++;
- if ( removeRegion(region) ) nRem++;
- }
- }
- RIter_delete(rIt);
-
- cout << "Negative elements removal: "
- << nNeg << " detected, "
- << nRem << " removed\n";
-
- return (nNeg - nRem);
- }
-
- // -------------------------------------------------------------------
- // LEVEL 4 OPERATIONS
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- void MeshAdapter::run()
- {
- // --- Adaptation procedure ---
-
- cout << "\n +++ Starting a MDB mesh adaptation procedure +++\n";
- if ( verbosity >= 2 ) cout<<"\n";
-
- for (int iter=1; iter <= maxIterationsNumber; iter++) {
-
- if ( verbosity >= 1 ) {
- cout<<" --- Mesh adaptation iteration "<<iter<<" ---\n"<<endl;
- }
- int num = runOneIter();
- if ( verbosity >= 2 ) cout<<"\n";
- if ( num == 0 ) break;
-
- if ( iter == maxIterationsNumber && num != 0 )
- {
- MAdStatisticsSgl::instance().addInfiniteLoops(1);
- if ( verbosity >= 1 ) {
- MAdMsgSgl::instance().warning(__LINE__,__FILE__,
- "Infinite loop detected");
- }
- break;
- }
- }
-
- // --- Load balancing ---
-#ifdef PARALLEL
- if( load_balance_algorithm != METIS_ALGORITHM ) {
-#ifdef _HAVE_PARMETIS_
- BalanceMetis2( mesh, *dataEchangerPtr );
-#endif
- }
-#endif
- if ( debugLevel >= 1 && !checkTheMesh() ) abort(__LINE__,__FILE__);
- cout << "\n +++ Ending a MDB mesh adaptation procedure +++\n";
- if ( verbosity >= 2 ) cout<<"\n";
- }
-
-#ifdef PARALLEL
- // -------------------------------------------------------------------
- void MeshAdapter::setLoadBalancingAlgorithm( loadBalanceAlgorithm lbAlgo )
- {
- load_balance_algorithm = lbAlgo;
- }
- // -------------------------------------------------------------------
- void MeshAdapter::setDataExchanger( MDB_DataExchanger* dataExch_ptr )
- {
- dataEchangerPtr= dataExch_ptr;
- }
-#endif
-
- // -------------------------------------------------------------------
- int MeshAdapter::partlyMoveObjects(double t, double dt, double* part)
- {
- return objects->partlyMove(*vMoveOp,t,dt,part);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::moveObjectsAndReposition(double t, double dt,
- double chi, bool meshIsCavity,
- int cavityThickness)
- {
- objects->setupElasticRepositioning(mesh, t, dt, chi,
- meshIsCavity, cavityThickness);
- double ratio = 0.;
- int achieved = -1;
- while ( achieved != 2 ) {
- achieved = objects->reposition(&ratio);
- if ( achieved == 0 ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Could not advance objects, ratio reached: %f",ratio);
- }
- MAdMsgSgl::instance().info(-1,__FILE__,
- "Advanced repositioning, achieved: %d, ratio: %f",achieved,ratio);
-
- if ( debugLevel >= 3 && !checkTheMesh() ) abort(__LINE__,__FILE__);
- if ( achieved == 1 ) {
- removeSlivers();
- // optimiseElementShape();
- }
- }
-
- if ( debugLevel >= 1 && !checkTheMesh() ) abort(__LINE__,__FILE__);
- }
-
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
- void MeshAdapter::nodalDataDiagnostics(std::ostream& out) const
- {
- NodalDataManagerSgl::instance().diagnostics(out);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::openJournal() const
- {
- HistorySgl::instance().openJournal();
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::setReferenceJournal(std::string& name) const
- {
- HistorySgl::instance().loadJournal(name);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::flushJournal(std::ostream& out) const
- {
- HistorySgl::instance().flushJournal(out);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::enableSliverReports()
- {
- if ( !sliverROp ) {
- std::cerr<<"Error: no sliver region handler\n";
- exit(0);
- }
-
- sliverROp->enableReport(outPrefix);
-
- if ( !sliverFOp ) {
- std::cerr<<"Error: no sliver face handler\n";
- exit(0);
- }
-
- sliverFOp->enableReport(outPrefix);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::testSliverOperators(bool test)
- {
- sliverROp->setTestAllOperators(test);
- }
-
- // -------------------------------------------------------------------
- bool MeshAdapter::checkTheMesh(int verbosity, std::ostream& out,
- MeshStatus * status) const
- {
- MAdMsgSgl::instance().info(-1,__FILE__,
- "Checking mesh validity (debug level = %d)",
- debugLevel);
- return checkMesh(mesh,CHECK_ALL,verbosity,out,status);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::infoMobileObjects(std::ostream& out) const
- {
- objects->describe(out);
- }
-
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
-
- void MeshAdapter::setOutputPrefix(string prefix)
- {
- outPrefix = prefix;
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::writePos(string fn, MAdOutputData type) const
- {
- string fullName = outPrefix + fn;
- MAdGmshOutput(mesh, (const pSField) SFManager->getSizeField(),
- fullName.c_str(), type);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::writeMsh(string fn) const
- {
- string fullName = outPrefix + fn;
- M_writeMsh(mesh,fullName.c_str(),2,NULL);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::getStatistics(double * meanQuality,
- double * worstQuality) const
- {
- MeshQualityManagerSgl::instance().evaluateStatistics();
- *meanQuality = MeshQualityManagerSgl::instance().getMeanShape();
- *worstQuality = MeshQualityManagerSgl::instance().getWorstShape();
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::printStatistics(std::ostream& out) const
- {
- MeshQualityManagerSgl::instance().evaluateStatistics();
- MeshQualityManagerSgl::instance().printStatistics(out);
- out << "\n\n";
- MAdStatisticsSgl::instance().print(out);
- }
-
- // -------------------------------------------------------------------
- void MeshAdapter::printSliverRegionStatistics(std::ostream& out) const
- {
- if ( sliverROp ) sliverROp->printStats(out);
- // if ( sliverROp ) sliverROp->printOperatorsTest(out);
- }
- // -------------------------------------------------------------------
- void MeshAdapter::abort(int line, const char* file) const
- {
- cerr << "\n"
- << " ****************************\n"
- << " MeshAdapter is aborting... \n"
- << " ****************************\n\n";
-
- string stName = outPrefix + "aborted_statistics";
- std::ofstream stOut(stName.c_str());
- printStatistics(stOut);
-
- string slName = outPrefix + "aborted_slivers";
- std::ofstream slOut(slName.c_str());
- printSliverRegionStatistics(slOut);
-
- string jName = outPrefix + "aborted_journal";
- std::ofstream jOut(jName.c_str());
- flushJournal(jOut);
-
- writePos("aborted.pos",OD_MEANRATIO);
- writeMsh("aborted.msh");
-
- if ( file && line >=0 ) {
- MAdMsgSgl::instance().info(-1,__FILE__,
- "Abort function called from file %s (line %d)",
- file,line);
- }
- else {
- MAdMsgSgl::instance().info(-1,__FILE__,"Abort!");
- }
-
- flush(cout);
- flush(cerr);
-
- exit(EXIT_FAILURE);
- }
-
- // -------------------------------------------------------------------
-
-} // End of namespace MAd
-
diff --git a/Adapt/AdaptInterface.h b/Adapt/AdaptInterface.h
deleted file mode 100644
index db84fec..0000000
--- a/Adapt/AdaptInterface.h
+++ /dev/null
@@ -1,331 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_ADAPTINTERFACE
-#define _H_ADAPTINTERFACE
-
-// from Adapt
-#include "MAdOutput.h"
-#include "MobileObject.h"
-#include "MeshParametersManager.h"
-#include "SizeFieldManager.h"
-#include "CallBackManager.h"
-#include "CheckMesh.h"
-#include "GeoMatcher.h"
-
-// from Adapt - operators
-#include "MAdOperatorBase.h"
-#include "EdgeSplitOp.h"
-#include "EdgeCollapseOp.h"
-#include "FaceCollapseOp.h"
-#include "DESCOp.h"
-#include "EdgeSwapOp.h"
-#include "FaceSwapOp.h"
-#include "VertexMoveOp.h"
-#include "RegionRemoveOp.h"
-#include "SliverFaceHandler.h"
-#include "SliverRegionHandler.h"
-#include "NodesRepositioningOp.h"
-#include "LaplaceSmoothingOp.h"
-
-// from Mesh
-#include "MSops.h"
-#ifdef PARALLEL
-#include "MeshDataBaseComm.h"
-#endif
-
-#include <set>
-#include <string>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
-
- enum algorithmDefinition {
- SPT_SWP_SLV_CPS,
- CPS_SWP_SLV_SPT,
- SLV_CPS_SWP_SPT
- };
-#ifdef PARALLEL
- enum loadBalanceAlgorithm {
- DEFAULT_ALGORITHM,
- METIS_ALGORITHM
- };
-#endif
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
- class MeshAdapter {
-
- public:
-
- MeshAdapter(pMesh m, pSField sf=NULL);
- ~MeshAdapter();
-
- // --------------------------------------------
-
- void addCallback(CBFunction CB, void* userData,
- CBFunc_move CB_move=0, void* userData_move=0);
- void addSizeField(pSField sf);
-
- // whether or not the global size field is smoothed and maximum gradient
- void setSizeFieldSmoothing(bool, double maxGrad=1.);
-
- // set the maximum number of iterations available to reach the 'convergence'
- // of the global mesh adaptation procedure
- void setMaxIterationsNumber(int max);
-
-#ifdef PARALLEL
- // set load balancing algorithm
- void setLoadBalancingAlgorithm( loadBalanceAlgorithm lbAlgo );
- // set the data Exchanger
- void setDataExchanger( MDB_DataExchanger* dataExch_ptr);
-#endif
-
- // impose the interval governing edges length in the transformed space
- void setEdgeLenSqBounds(double lower, double upper);
-
- // set permission for operators to modify slightly boundaries
- // (default: false) and tolerance for the relative volume/area
- // modifications.
- // Edge collapse and face collapse:
- void setCollapseOnBoundary(bool accept=true, double tolerance=1.e-6);
- // Edge swap:
- void setSwapOnBoundary(bool accept=true, double tolerance=1.e-6);
-
- // impose the element quality from which a swap is not required
- void setNoSwapQuality(double noSwapQuality);
-
- // impose a threshold rate of improvement for edge and face swaps
- void setSwapMinImproveRatio(double ratio);
-
- // impose the maximum quality of a sliver
- void setSliverQuality(double sliverQuality);
-
- // Allow or forbid operations creating a sliver.
- // If allowed and a bound is prescribed, it is allowed only if the edge is
- // longer/shorter than the bound (bound is expressed as the square of
- // adimensional edge length)
- void setSliverPermissionInESplit (bool perm, double lenSqBound=-1.);
- void setSliverPermissionInECollapse(bool perm, double lenSqBound=-1.);
-
- // tell if you want to project new vertices on geometric entities
- void setGeoTracking(bool enable, bool cavityEqualMesh=false,
- int cavityThickness=2, double chi=1.0);
-
- // set a value for a very huge edge length (default=1.e14)
- void setInfiniteLength(double length);
-
- // Set verbosity:
- // < 0 : no detail
- // 1 : global procedure details
- // > 2 : iterations details
- void setVerbosity(int _verbosity);
-
- // constraint a mesh/geometric entity and all its downward entities
- void clearConstraints() const;
- void setConstraint(pEntity e) const;
- void setConstraint(pGEntity ge) const;
- void setConstraint(int type, int id) const;
- // unconstrain a geometric entity
- void removeConstraint(int type, int id) const;
- void removeConstraint(pGEntity ge) const;
-
- // manage the physical time
- void incrementTime(double dt);
- void setTime(double t);
- double getTime() const;
- void updateSizeField();
-
- // functions to keep track of the initial coordinates
- void storeInitialCoordinates();
- void removeStoredCoordinates();
-
- // add predefined mobile objects
- void registerObjects(mobileObjectSet* objs);
-
- // will attach/get the datas to the nodes of the mesh
- // order in vector is the node iterator order
- void registerData (std::string name, const std::vector<double>) const;
- void registerVData (std::string name, const std::vector<std::vector<double> >) const;
- void getMeshData (std::string name, std::vector<double> *) const;
- void getMeshVData (std::string name, std::vector<std::vector<double> > *) const;
- void removeData (std::string name) const;
- void removeVData (std::string name) const;
-
- public:
-
- // ---------------- OPERATIONS ----------------
-
- // ----- Level 1 -----
- // ---> Elementary operations
-
- // Split the edge and if 'checkSize' is true, check that the two resulting
- // edges are not short edges.
- bool splitEdge (pEdge e, bool checkSize=false);
- bool collapseEdge (pEdge e);
- bool collapseFace(pFace f, pEdge e);
- bool DSplitCollapseEdge(pRegion pr, pEdge edge1, pEdge edge2);
- bool swapEdge (pEdge e);
- bool swapFace (pFace f);
- bool removeRegion(pRegion region);
- bool moveVertex (pVertex v, double dxyz[3]);
- bool putVertex (pVertex v, double xyz[3]);
- bool moveVertices (std::multiset<vDisplacement,vDisplacementLess>& vDisps);
-
- // ----- Level 2 -----
- // ---> Loops on one elementary operation
-
- // node repositioning
- double LaplaceSmoothing(LaplSmooType type);
-
- // topology operations
- int eSplitLoop();
- int eCollapseLoop();
- int eSplitCollapseLoop();
- int edgeSwapLoop();
- int faceSwapLoop();
- int splitEveryEdgeOnce();
-
- // slivers handling
- int removeSlivers();
-
- // geometry matching
- void snapVertices();
-
- // ----- Level 3 -----
- // ---> Procedures with a global objective
- int optimiseEdgeLength();
- int optimiseElementShape();
- int splitLongestEdges();
- int runOneIter();
- void uglyTheMesh(double avgQualThresh, int maxIt);
- int removeNegativeElements();
-
- // ----- Level 4 -----
- // ---> Global procedure
- void run();
-
- // ----- objects motion -----
- // move boundaries without repositioning nodes in the volume
- int partlyMoveObjects (double t, double dt, double* part);
- // move boundaries and reposition all nodes with an elasticity analogy
- // chi: stiffness alteration coefficient (-1 = none)
- // meshIsCavity: true = elastic computation on whole mesh
- // cavityThickness: nb layers of elements if mesh is not the cavity
- void moveObjectsAndReposition (double t, double dt, double chi=-1.,
- bool meshIsCavity=true,
- int cavityThickness=3);
-
- // --------------------------------------------
-
- public:
-
- // ------ Diagnostics ------
-
- // get informations on mesh quality
- void getStatistics(double * meanQuality, double * worstQuality) const;
-
- // about all datas attached to the nodes
- void nodalDataDiagnostics(std::ostream& out) const;
-
- // journals listing all operations tested or applied
- void setDebugLevel(int debug) { debugLevel = debug; }
- void openJournal() const;
- void setReferenceJournal(std::string& name) const;
- void flushJournal(std::ostream& out) const;
-
- // sliver outputs
- void enableSliverReports();
- void testSliverOperators(bool test);
-
- // performs several checks to check the validity of the mesh
- bool checkTheMesh(int verbose=1,
- std::ostream& out=std::cout,
- MeshStatus * status=NULL) const;
-
- // get infos about mobile objects
- void infoMobileObjects(std::ostream& out=std::cout) const;
-
- public:
-
- // ------ Outputs ------
-
- // set the path to output directory
- void setOutputPrefix(std::string prefix);
-
- // write mesh with required postpro data in 'pos' format (Gmsh)
- void writePos(std::string fn, MAdOutputData type=OD_CONSTANT) const;
-
- // write mesh in 'msh' format (Gmsh)
- void writeMsh(std::string fn) const;
-
- // get global data over the mesh
- void printStatistics(std::ostream& out) const;
- void printSliverRegionStatistics(std::ostream& out) const;
-
- public:
-
- // save all available informations to output directory and abort
- void abort(int line=-1, const char* file=NULL) const;
-
- // --------------------------------------------
-
- private:
-
- void setDefaultValues();
- void buildOperators();
- void removeOperators();
-
- private:
-
- pMesh mesh;
- SizeFieldManager * SFManager;
-
- mobileObjectSet * objects;
-
- // ----- Local mesh modification operators -----
- edgeSplitOp * eSplitOp;
- edgeCollapseOp * eCollapseOp;
- faceCollapseOp * fCollapseOp;
- DESCOp * descOp;
- edgeSwapOp * eSwapOp;
- faceSwapOp * fSwapOp;
- vertexMoveOp * vMoveOp;
- regionRemoveOp * rRegionOp;
- sliverFaceHandler * sliverFOp;
- sliverRegionHandler * sliverROp;
-
- // ----- Geometry related -----
- geoMatcher * geoTracker;
-
- // ----- Adaptation parameters -----
- algorithmDefinition algorithm;
- int maxIterationsNumber;
- MeshParametersManager& mpm;
-#ifdef PARALLEL
- loadBalanceAlgorithm load_balance_algorithm;
- MDB_DataExchanger* dataEchangerPtr;
-#endif
-
- // ----- Output parameters -----
- int verbosity;
- std::string outPrefix;
- int debugLevel;
- };
-
- // -------------------------------------------------------------------
-
-} // End of namespace MAd
-
-#endif
-
diff --git a/Adapt/Makefile b/Adapt/Makefile
deleted file mode 100644
index 56f126d..0000000
--- a/Adapt/Makefile
+++ /dev/null
@@ -1,101 +0,0 @@
-# -------------------------------------------------------------------
-# 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 at madlib.be>
-#
-# Authors: Gaetan Compere, Jean-Francois Remacle
-# -------------------------------------------------------------------
-
-include ../variables
-
-LIB = ../lib/libMAdAdapt${LIBEXT}
-
-INC = ${MAdLib_INCLUDES}\
- ${DASH}I$(MAdROOT)/Geo\
- ${DASH}I$(MAdROOT)/Mesh\
- ${DASH}I$(MAdROOT)/Common\
- ${DASH}I$(MAdROOT)/Adapt\
- ${DASH}I$(MAdROOT)/Adapt/constraint\
- ${DASH}I$(MAdROOT)/Adapt/operator\
- ${DASH}I$(MAdROOT)/Adapt/output\
- ${DASH}I$(MAdROOT)/Adapt/quality\
- ${DASH}I$(MAdROOT)/Adapt/repositioning\
- ${DASH}I$(MAdROOT)/Adapt/sizeField\
- ${DASH}I$(MAdROOT)/Adapt/utils
-
-ALLFLAGS = ${OPTIM} ${CXXFLAGS} ${MAdLib_DEFS} ${FLAGS} ${INC} ${SYSINCLUDE}
-
-SRC = AdaptInterface.cc\
- MeshParametersManager.cc\
- constraint/Constraint.cc\
- constraint/ModelConstraintManager.cc\
- operator/DESCOp.cc\
- operator/EdgeCollapseOp.cc\
- operator/EdgeSplitOp.cc\
- operator/EdgeSwapConfig.cc\
- operator/EdgeSwapOp.cc\
- operator/FaceCollapseOp.cc\
- operator/FaceSwapOp.cc\
- operator/MAdOperatorBase.cc\
- operator/OperatorTools.cc\
- operator/RegionRemoveOp.cc\
- operator/SliverFaceHandler.cc\
- operator/SliverRegionHandler.cc\
- operator/VertexMoveOp.cc\
- output/MAdOutput.cc\
- quality/MeanRatioEvaluator.cc\
- quality/OrientedMeanRatioEvaluator.cc\
- quality/MeshQualityManager.cc\
- repositioning/GeoMatcher.cc\
- repositioning/LaplaceSmoothingOp.cc\
- repositioning/MAdElasticityOp.cc\
- repositioning/MobileObject.cc\
- sizeField/AnalyticalSField.cc\
- sizeField/AnisoMeshSize.cc\
- sizeField/DiscreteSF.cc\
- sizeField/IsoMeshSize.cc\
- sizeField/LocalSizeField.cc\
- sizeField/MeshSizeBase.cc\
- sizeField/NullSField.cc\
- sizeField/PWLinearSField.cc\
- sizeField/SizeFieldBase.cc\
- sizeField/SizeFieldManager.cc\
- utils/CallBackManager.cc\
- utils/CPUTimeManager.cc\
- utils/History.cc\
- utils/MAdStatistics.cc\
- utils/MAdTimeManager.cc\
- utils/NodalDataManager.cc\
- utils/DistanceFunction.cc\
- ../Contrib/mathex/mathex.cc
-
-OBJ = ${SRC:.cc=${OBJEXT}}
-
-.SUFFIXES: ${OBJEXT} .cc
-
-${LIB}: ${OBJ}
- ${AR} ${ARFLAGS} ${LIB} ${OBJ}
- ${RANLIB} ${LIB}
-
-cpobj: ${OBJ}
- cp -f ${OBJ} ${MAdLib_TMPDIR}/.
-
-.cc${OBJEXT}:
- ${CXX} ${ALLFLAGS} ${DASH}c $< ${DASH}o $@
-
-clean:
- ${RM} */*.o *.o *.obj
-
-purge:
-
-depend:
- (sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
- ${CXX} -MM ${ALLFLAGS} ${SRC} | sed 's/.o:/$${OBJEXT}:/g' \
- ) > Makefile.new
- cp Makefile Makefile.bak
- cp Makefile.new Makefile
- rm -f Makefile.new
\ No newline at end of file
diff --git a/Adapt/MeshParametersManager.cc b/Adapt/MeshParametersManager.cc
deleted file mode 100644
index 58c3664..0000000
--- a/Adapt/MeshParametersManager.cc
+++ /dev/null
@@ -1,161 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MeshParametersManager.h"
-#include "MAdMessage.h"
-
-// standart C/C++
-#include <iostream>
-using std::cout;
-using std::cerr;
-using std::endl;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- MeshParametersManager::MeshParametersManager():
- lowerLengthSqBound(-1.), upperLengthSqBound(-1.),
- sliverTetQualityBound(-1.), sliverTriQualityBound(-1.),
- sliverPermInESplit(false), sliverPermInECollapse(false),
- sliverLowerLengthSqBound(-1.),sliverUpperLengthSqBound(-1.),
- noSwapQuality(-1.),swapMinImproveRatio(-1.), bigLength(1.e14)
- {}
-
- // -------------------------------------------------------------------
- void MeshParametersManager::initialize()
- {
- }
-
- // -------------------------------------------------------------------
- void MeshParametersManager::finalize()
- {
- }
-
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
-
- void MeshParametersManager::setLowerLengthSqBound(double lSq)
- {
- lowerLengthSqBound = lSq;
- }
-
- // -------------------------------------------------------------------
-
- void MeshParametersManager::setUpperLengthSqBound(double lSq)
- {
- upperLengthSqBound = lSq;
- }
-
- // -------------------------------------------------------------------
- double MeshParametersManager::getSliverBound(int dim) const
- {
- if (dim==3) return getSliverTetBound();
- return getSliverTriBound();
- }
-
- // -------------------------------------------------------------------
- double MeshParametersManager::getSliverBound(const pMesh mesh) const
- {
- return getSliverBound(M_dim(mesh));
- }
-
- // -------------------------------------------------------------------
-
- void MeshParametersManager::setSliverTriBound(double bound)
- {
- sliverTriQualityBound = bound;
- }
-
- // -------------------------------------------------------------------
-
- void MeshParametersManager::setSliverTetBound(double bound)
- {
- sliverTetQualityBound = bound;
- }
-
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
-
- void MeshParametersManager::setSliverPermissionInESplit(bool perm,
- double bound)
- {
- sliverPermInESplit = perm;
- sliverUpperLengthSqBound = bound;
- if ( sliverUpperLengthSqBound > 0. &&
- sliverUpperLengthSqBound < upperLengthSqBound ) {
- MAdMsgSgl::instance().warning(__LINE__,__FILE__,
- "Incoherent parameters: upper length square bound for edge splits creating slivers (%f) is lower than the global upper legnth square bound (%f)",
- sliverUpperLengthSqBound,upperLengthSqBound);
- }
- }
-
- // -------------------------------------------------------------------
-
- void MeshParametersManager::setSliverPermissionInECollapse(bool perm,
- double bound)
- {
- sliverPermInECollapse = perm;
- sliverLowerLengthSqBound = bound;
- if ( sliverLowerLengthSqBound > 0. &&
- sliverLowerLengthSqBound > lowerLengthSqBound ) {
- MAdMsgSgl::instance().warning(__LINE__,__FILE__,
- "Incoherent parameters: lower length square bound for edge collapses creating slivers (%f) is bigger than the global lower legnth square bound (%f)",
- sliverLowerLengthSqBound,lowerLengthSqBound);
- }
- }
-
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
-
- void MeshParametersManager::diagnostics() const
- {
- cout << " *** Parameters for the mesh adaptation *** \n";
-
- cout << "\n";
-
- cout << "- Bounds of the edge length squared: \n";
- cout << "\t Lower: " << lowerLengthSqBound << "\n";
- cout << "\t Upper: " << upperLengthSqBound << "\n";
-
- cout << "\n";
-
- cout << "- Quality bound for the sliver triangles: "
- << sliverTriQualityBound << "\n";
-
- cout << "- Quality bound for the sliver tetrahedra: "
- << sliverTetQualityBound << "\n";
-
- cout << "\n";
-
- cout << "Edge splits can create slivers: ";
- if (sliverPermInESplit) {
- cout << "yes: ";
- if ( sliverUpperLengthSqBound < 0) cout << "for any edge.";
- else cout << "if the edge is longer than "<< sliverUpperLengthSqBound<<" (square of adimensional length)";
- }
- else cout << "no";
- cout << "\n";
- cout << "Edge collapses can create slivers: ";
- if (sliverPermInECollapse) {
- cout << "yes: ";
- if ( sliverLowerLengthSqBound < 0) cout << "for any edge.";
- else cout << "the edge is shorter than "<< sliverLowerLengthSqBound<<" (square of adimensional length)";
- }
- else cout << "no";
- cout << "\n";
-
- cout << "\n";
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/MeshParametersManager.h b/Adapt/MeshParametersManager.h
deleted file mode 100644
index adb0e84..0000000
--- a/Adapt/MeshParametersManager.h
+++ /dev/null
@@ -1,109 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MESHPARAMETERSMANAGER
-#define _H_MESHPARAMETERSMANAGER
-
-#include "MeshDataBaseInterface.h"
-#include "MAdOperatorBase.h"
-#include "MAdSingleton.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class MeshParametersManager {
-
- public:
-
- MeshParametersManager();
- ~MeshParametersManager() {};
-
- void initialize();
- void finalize();
-
- // ------------------------------------------
- public:
-
- void setLowerLengthSqBound(double);
- void setUpperLengthSqBound(double);
- void setSliverTriBound(double);
- void setSliverTetBound(double);
-
- double getLowerLengthSqBound() const {return lowerLengthSqBound;}
- double getUpperLengthSqBound() const {return upperLengthSqBound;}
- double getSliverBound(int dim) const;
- double getSliverBound(const pMesh) const;
- double getSliverTriBound() const {return sliverTriQualityBound;}
- double getSliverTetBound() const {return sliverTetQualityBound;}
-
- private:
-
- double lowerLengthSqBound, upperLengthSqBound;
- double sliverTetQualityBound;
- double sliverTriQualityBound;
-
- // ------------------------------------------
- public:
-
- void setSliverPermissionInESplit (bool, double bound=-1.);
- void setSliverPermissionInECollapse (bool, double bound=-1.);
-
- bool getSliverPermissionInESplit () const {return sliverPermInESplit;}
- bool getSliverPermissionInECollapse () const {return sliverPermInECollapse;}
-
- double getSliverLowerLengthSqBound () const {return sliverLowerLengthSqBound;}
- double getSliverUpperLengthSqBound () const {return sliverUpperLengthSqBound;}
-
- private:
-
- bool sliverPermInESplit, sliverPermInECollapse;
- double sliverLowerLengthSqBound, sliverUpperLengthSqBound;
-
- // ------------------------------------------
- public:
-
- void setNoSwapQuality(double noSwap) {noSwapQuality = noSwap;}
- void setSwapMinImproveRatio(double ratio) {swapMinImproveRatio = ratio;}
-
- double getNoSwapQuality() const {return noSwapQuality;}
- double getSwapMinImproveRatio() const {return swapMinImproveRatio;}
-
- private:
-
- double noSwapQuality;
- double swapMinImproveRatio;
-
- // ------------------------------------------
- public:
-
- void setBigLength(double len) { bigLength = len; }
- double getBigLength() { return bigLength; }
-
- private:
-
- double bigLength;
-
- // ------------------------------------------
- public:
-
- void diagnostics() const;
-
- };
-
- // -------------------------------------------------------------------
-
- typedef MAdSingleton<MeshParametersManager> MeshParametersManagerSgl;
-
-}
-
-#endif
diff --git a/Adapt/constraint/Constraint.cc b/Adapt/constraint/Constraint.cc
deleted file mode 100644
index 0691db3..0000000
--- a/Adapt/constraint/Constraint.cc
+++ /dev/null
@@ -1,429 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "Constraint.h"
-#include "ModelConstraintManager.h"
-
-#include "MeshDataBaseParallelInterface.h"
-
-static unsigned int CONSTRAIN_MARK_ID = 1687354269;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void EN_constrain(pEntity pE)
- {
- pE->attachInt(CONSTRAIN_MARK_ID,1);
- }
-
- // -------------------------------------------------------------------
- void EN_unconstrain(pEntity pE)
- {
- pE->attachInt(CONSTRAIN_MARK_ID,0);
- }
-
- // -------------------------------------------------------------------
- bool EN_constrained(pEntity pE)
- {
- if ( ModelConstraintManagerSgl::instance().constrained(EN_whatIn(pE)) ) {
- return true;
- }
-
- return (bool) pE->getAttachedInt(CONSTRAIN_MARK_ID);
- }
-
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- void DeleteConstraint(pMesh mesh) {
- VIter vit = M_vertexIter(mesh);
- pVertex pv;
- while ((pv = VIter_next(vit))) {
- EN_unconstrain((pEntity) pv);
- }
- VIter_delete(vit);
-
- EIter eit = M_edgeIter(mesh);
- pEdge ped;
- while ((ped = EIter_next(eit))) {
- EN_unconstrain((pEntity) ped);
- }
- EIter_delete(eit);
-
- FIter fit = M_faceIter(mesh);
- pFace pface;
- while ((pface = FIter_next(fit))) {
- EN_unconstrain((pEntity) pface);
- }
- FIter_delete(fit);
-
- RIter rit = M_regionIter(mesh);
- pRegion pregion;
- while ((pregion = RIter_next(rit))) {
- EN_unconstrain((pEntity) pregion);
- }
- RIter_delete(rit);
- }
-
- // -------------------------------------------------------------------
-#ifdef PARALLEL
- void DeleteParallelConstraint(pMesh mesh) {
-
- VIter vit = M_vertexIter(mesh);
- while ( pVertex pv = VIter_next(vit) ) {
- if ( V_isInterface(pv) ) EN_unconstrain((pEntity) pv);
- }
- VIter_delete(vit);
-
- EIter eit = M_edgeIter(mesh);
- while ( pEdge pe = EIter_next(eit) ) {
- if ( E_isInterface(mesh,pe) ) {
- EN_unconstrain((pEntity) pe);
- }
- }
- EIter_delete(eit);
- int dim = (mesh->tets.empty()) ? 2 : 3;
-
- if ( dim == 3 ) {
- FIter fit = M_faceIter(mesh);
- while ( pFace pf = FIter_next(fit) ) {
- if ( F_isInterface(mesh,pf) ) {
- EN_unconstrain((pEntity) pf);
- }
- }
- FIter_delete(fit);
- }
- }
- void UpdateParallelConstraint(pMesh mesh) {
-
- DeleteParallelConstraint(mesh);
- // DeleteConstraint(mesh);
- int dim = (mesh->tets.empty()) ? 2 : 3;
-
- if ( dim == 3 ) {
- FIter fit = M_faceIter(mesh);
- while ( pFace pf = FIter_next(fit) ) {
- if ( F_isInterface(mesh,pf) ) {
- EN_constrain((pEntity) pf);
- }
- }
- FIter_delete(fit);
- }
- EIter eit = M_edgeIter(mesh);
- while ( pEdge pe = EIter_next(eit) ) {
- if ( E_isInterface(mesh,pe) ) {
- EN_constrain((pEntity) pe);
- }
- }
- EIter_delete(eit);
- VIter vit = M_vertexIter(mesh);
- while ( pVertex pv = VIter_next(vit) ) {
- if ( V_isInterface(pv) ) EN_constrain((pEntity) pv);
- }
- VIter_delete(vit);
- }
-#endif
-
- // -------------------------------------------------------------------
- void UpdatePeriodicConstraint2d(pMesh mesh)
- {
- pMeshDataId tagPeriod = MD_lookupMeshDataId("PeriodicPoint");
-
- FIter fit = M_faceIter(mesh);
- pFace pface;
- while ((pface = FIter_next(fit))) {
- int ncount = 0;
- pEdge pe1 = F_edge(pface,0);
- pVertex p1 = E_vertex(pe1,0);
- pVertex p2 = E_vertex(pe1,1);
- void *temp_ptr1,*temp_ptr2;
- int isPeriodic1 = EN_getDataPtr((pEntity) p1 , tagPeriod, &temp_ptr1);
- int isPeriodic2 = EN_getDataPtr((pEntity) p2 , tagPeriod, &temp_ptr2);
- if(isPeriodic1) EN_constrain((pEntity) p1);
- if(isPeriodic2) EN_constrain((pEntity) p2);
- if(isPeriodic1 && isPeriodic2){
- /*est-ce que l'arete image de celle-ci existe ?*/
- /*ie est-ce l'arete Img(P1)-Img(P2) existe et est differente de ped ?*/
- const std::vector<std::pair<std::vector<int> , pVertex> > *recup = (std::vector<std::pair<std::vector<int> , pVertex> > *) temp_ptr1;
- const std::vector<std::pair<std::vector<int> , pVertex> > *recup2 = (std::vector<std::pair<std::vector<int> , pVertex> > *) temp_ptr2;
- int nump = EN_id(p2);
- unsigned int k=0;
- int exist=-1;
- for(k=0; k<(*recup).size() ; k++) {
- /*edge p1p2 = p1 Img(p1) ?*/
- pVertex n1 = (*recup)[k].second;
- if ( nump == EN_id(n1) ) {
- continue;
- }
- /*edge = Img(p1)Img(p2) existe ?*/
- unsigned int kk=0;
- std::vector<int> transfo1 = (*recup)[k].first;
- for(kk=0; kk<(*recup2).size() ; kk++) {
- std::vector<int> transfo2 = (*recup2)[kk].first;
- assert(transfo1.size()==transfo2.size());
- unsigned int kt = 0;
- for(kt = 0 ; kt < transfo1.size(); kt++) {
- if(transfo1[kt] != transfo2[kt]) break;
- }
- if(kt!=transfo1.size()) continue;
- pVertex n2 = (*recup2)[kk].second;
- if ( !E_exist(n1,n2) && !E_exist(n2,n1) ) {
- exist = 0;
- } else {
- exist = 1;
- }
- }
- }
- if(exist==1) {
- ncount++;
- EN_constrain((pEntity) pe1);
- }
- }
- pEdge pe2 = F_edge(pface,1);
- p1 = E_vertex(pe2,0);
- p2 = E_vertex(pe2,1);
- isPeriodic1 = EN_getDataPtr((pEntity) p1 , tagPeriod, &temp_ptr1);
- isPeriodic2 = EN_getDataPtr((pEntity) p2 , tagPeriod, &temp_ptr2);
- if(isPeriodic1) EN_constrain((pEntity) p1);
- if(isPeriodic2) EN_constrain((pEntity) p2);
- if(isPeriodic1 && isPeriodic2){
- /*est-ce que l'arete image de celle-ci existe ?*/
- /*ie est-ce l'arete Img(P1)-Img(P2) existe et est differente de ped ?*/
- const std::vector<std::pair<std::vector<int> , pVertex> > *recup = (std::vector<std::pair<std::vector<int> , pVertex> > *) temp_ptr1;
- const std::vector<std::pair<std::vector<int> , pVertex> > *recup2 = (std::vector<std::pair<std::vector<int> , pVertex> > *) temp_ptr2;
- int nump = EN_id(p2);
- unsigned int k=0;
- int exist=-1;
- for(k=0; k<(*recup).size() ; k++) {
- /*edge p1p2 = p1 Img(p1) ?*/
- pVertex n1 = (*recup)[k].second;
- if ( nump == EN_id(n1) ){
- continue;
- }
- /*edge = Img(p1)Img(p2) existe ?*/
- unsigned int kk=0;
- std::vector<int> transfo1 = (*recup)[k].first;
- for(kk=0; kk<(*recup2).size() ; kk++) {
- std::vector<int> transfo2 = (*recup2)[kk].first;
- assert(transfo1.size()==transfo2.size());
- unsigned int kt = 0;
- for(kt = 0 ; kt < transfo1.size(); kt++) {
- if(transfo1[kt] != transfo2[kt]) break;
- }
- if(kt!=transfo1.size()) continue;
- pVertex n2 = (*recup2)[kk].second;
- if ( !E_exist(n1,n2) && !E_exist(n2,n1) ) {
- exist = 0;
- } else {
- exist = 1;
- }
- }
- }
- if(exist==1) {
- ncount++;
- EN_constrain((pEntity) pe2);
- }
- }
- pEdge pe3 = F_edge(pface,2);
- p1 = E_vertex(pe3,0);
- p2 = E_vertex(pe3,1);
- isPeriodic1 = EN_getDataPtr((pEntity) p1 , tagPeriod, &temp_ptr1);
- isPeriodic2 = EN_getDataPtr((pEntity) p2 , tagPeriod, &temp_ptr2);
- if(isPeriodic1) EN_constrain((pEntity) p1);
- if(isPeriodic2) EN_constrain((pEntity) p2);
- if(isPeriodic1 && isPeriodic2){
- /*est-ce que l'arete image de celle-ci existe ?*/
- /*ie est-ce l'arete Img(P1)-Img(P2) existe et est differente de ped ?*/
- const std::vector<std::pair<std::vector<int> , pVertex> > *recup = (std::vector<std::pair<std::vector<int> , pVertex> > *) temp_ptr1;
- const std::vector<std::pair<std::vector<int> , pVertex> > *recup2 = (std::vector<std::pair<std::vector<int> , pVertex> > *) temp_ptr2;
- int nump = EN_id(p2);
- unsigned int k=0,exist=0;
- for(k=0; k<(*recup).size() ; k++) {
- /*edge p1p2 = p1 Img(p1) ?*/
- pVertex n1 = (*recup)[k].second;
- if ( nump == EN_id(n1) ){
- continue;
- }
- /*edge = Img(p1)Img(p2) existe ?*/
- unsigned int kk=0;
- std::vector<int> transfo1 = (*recup)[k].first;
- for(kk=0; kk<(*recup2).size() ; kk++) {
- std::vector<int> transfo2 = (*recup2)[kk].first;
- assert(transfo1.size()==transfo2.size());
- unsigned int kt = 0;
- for(kt = 0 ; kt < transfo1.size(); kt++) {
- if(transfo1[kt] != transfo2[kt]) break;
- }
- if(kt!=transfo1.size()) continue;
- pVertex n2 = (*recup2)[kk].second;
- if ( E_exist(n1,n2) || E_exist(n2,n1) ) {
- exist = 1;
- }
- }
- }
- if(exist==1) {
- ncount++;
- EN_constrain((pEntity) pe3);
- }
- }
- if(ncount==3) EN_constrain((pEntity) pface);
-
- }
- FIter_delete(fit);
- }
-
- // -------------------------------------------------------------------
- void UpdatePeriodicConstraint3d(pMesh mesh)
- {
- pMeshDataId tagPeriod = MD_lookupMeshDataId("PeriodicPoint");
-
- RIter rit = M_regionIter(mesh);
- pRegion pr;
- while ((pr = RIter_next(rit))) {
- int ncountr = 0;
- pFace pface[4];
- for(int i=0 ; i<4 ; i++) {
- int nbdry = 1;
- pface[i] = R_face(pr,i);
- /*Img(pface[i]) exist ?*/
- pVertex nod[3];
- int isPeriodic[3];
- void *tmp[3];
- unsigned int j=0;
- for(j=0 ; j<3 ; j++) {
- nod[j] = F_vertex(pface[i],j);
- isPeriodic[j] = EN_getDataPtr((pEntity) nod[j] , tagPeriod, &tmp[j]);
- if(!isPeriodic[j]) {
- nbdry=0;
- continue;
- }
- EN_constrain((pEntity) nod[j]);
- }
- if(nbdry) {
- /*find Img(nod[j])*/
- const std::vector<std::pair<std::vector<int> , pVertex> > *recup = (std::vector<std::pair<std::vector<int> , pVertex> > *) tmp[0];
- const std::vector<std::pair<std::vector<int> , pVertex> > *recup2 = (std::vector<std::pair<std::vector<int> , pVertex> > *) tmp[1];
- const std::vector<std::pair<std::vector<int> , pVertex> > *recup3 = (std::vector<std::pair<std::vector<int> , pVertex> > *) tmp[2];
- unsigned int k;
- int exist=-1,nfound=0;
- for(k=0; k<(*recup).size() ; k++) {
- pVertex n1 = (*recup)[k].second;
- /*ATTENTION CA PEUT ARRIVER DANS LES CAS 3_PERIODIQUES!!!if ( EN_id((pEntity) nod[1]) == EN_id((pEntity) n1) || EN_id((pEntity) nod[2]) == EN_id((pEntity) n1) ){
- continue;
- } */
- unsigned int kk=0;
- std::vector<int> transfo1 = (*recup)[k].first;
- for(kk=0; kk<(*recup2).size() ; kk++) {
- std::vector<int> transfo2 = (*recup2)[kk].first;
- assert(transfo1.size()==transfo2.size());
- unsigned int kt = 0;
- for(kt = 0 ; kt < transfo1.size(); kt++) {
- if(transfo1[kt] != transfo2[kt]) break;
- }
- if(kt!=transfo1.size()) continue;
- if(!nfound) nfound = 1;
- pVertex n2 = (*recup2)[kk].second;
- unsigned int kkk=0;
- for(kkk=0; kkk<(*recup3).size() ; kkk++) {
- std::vector<int> transfo2 = (*recup3)[kkk].first;
- unsigned int kt = 0;
- for(kt = 0 ; kt < transfo1.size(); kt++) {
- if(transfo1[kt] != transfo2[kt]) break;
- }
- if(kt!=transfo1.size()) continue;
- pVertex n3 = (*recup3)[kkk].second;
- nfound = 2;
- if ( F_exist(n1,n2,n3,0) || F_exist(n1,n3,n2,0) ||
- F_exist(n2,n1,n3,0) || F_exist(n2,n3,n1,0) ||
- F_exist(n3,n2,n1,0) || F_exist(n3,n1,n2,0) ) {
- exist = 1;
- }
- }/*end kkk*/
- }/*end kk*/
- }/*end k*/
- if(!nfound) nbdry=0;//printf("on n'a pas trouve la face\n");
- if(nfound==1) nbdry = 1;//printf("3 ou 2 ? %d\n",nfound);
- if(nfound==2) nbdry = 0;//printf("3 ou 2 ? %d\n",nfound);
-
- if(exist==1) {
- ncountr++;
- EN_constrain((pEntity) pface[i]);
- for(int j=0 ; j<3 ; j++) {
- EN_constrain((pEntity) F_edge(pface[i],j));
- /* pVertex p1 = F_edge(pface[i],j)->p1;
- pVertex p2 = F_edge(pface[i],j)->p2;
- double len = (p1->X-p2->X)*(p1->X-p2->X) + (p1->Y-p2->Y)*(p1->Y-p2->Y) +(p1->Z-p2->Z)*(p1->Z-p2->Z);
- printf("edge %d %d : %e\n",p1->iD,p2->iD,len); */
- }
- continue;
- } else{
- /* if(F_numRegions(pface[i]) != 2){ printf("pbs constraint %d %d %d\n",EN_id((pEntity) nod[0])
- ,EN_id((pEntity) nod[1]),EN_id((pEntity) nod[2]));exit(0); } */
- }
- }/*end nbdry*/
- /*face not constraint*/
- int ncount = 0;
- for(int j=0 ; j<3 ; j++) {
- pEdge ped = F_edge(pface[i],j);
- pVertex p1 = E_vertex(ped,0);
- pVertex p2 = E_vertex(ped,1);
- void *temp_ptr1,*temp_ptr2;
- int isPeriodic1 = EN_getDataPtr((pEntity) p1 , tagPeriod, &temp_ptr1);
- int isPeriodic2 = EN_getDataPtr((pEntity) p2 , tagPeriod, &temp_ptr2);
- if((isPeriodic1 && isPeriodic2)) {
- const std::vector<std::pair<std::vector<int> , pVertex> > *recup = (std::vector<std::pair<std::vector<int> , pVertex> > *) temp_ptr1;
- const std::vector<std::pair<std::vector<int> , pVertex> > *recup2 = (std::vector<std::pair<std::vector<int> , pVertex> > *) temp_ptr2;
- //int nump = EN_id(p2);
- int nfound = 0;
- unsigned int k=0;
- int exist=-1;
- for(k=0; k<(*recup).size() ; k++) {
- /*edge p1p2 = p1 Img(p1) ?*/
- pVertex n1 = (*recup)[k].second;
- /*if ( nump == EN_id(n1) ){
- continue;
- }*/
- /*edge = Img(p1)Img(p2) existe ?*/
- unsigned int kk=0;
- std::vector<int> transfo1 = (*recup)[k].first;
- for(kk=0; kk<(*recup2).size() ; kk++) {
- std::vector<int> transfo2 = (*recup2)[kk].first;
- assert(transfo1.size()==transfo2.size());
- unsigned int kt = 0;
- for(kt = 0 ; kt < transfo1.size(); kt++) {
- if(transfo1[kt] != transfo2[kt]) break;
- }
- if(kt!=transfo1.size()) continue;
- nfound = 1;
- pVertex n2 = (*recup2)[kk].second;
- if ( E_exist(n1,n2) || E_exist(n2,n1) ) {
- exist = 1;
- }
- }
- }/*end k*/
-
- if(exist==1) {
- ncount++;
- EN_constrain((pEntity) ped);
- }
- }
- }
- }
- if(ncountr==4) EN_constrain((pEntity) pr);
- }
- RIter_delete(rit);
-
- }
-
-}
-
-//#endif
diff --git a/Adapt/constraint/Constraint.h b/Adapt/constraint/Constraint.h
deleted file mode 100644
index deef2a6..0000000
--- a/Adapt/constraint/Constraint.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_CONSTRAINT
-#define _H_CONSTRAINT
-
-#include "MeshDataBaseInterface.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
-
- // --- entity level constraining ---
-
- void EN_constrain (pEntity);
- void EN_unconstrain (pEntity);
- bool EN_constrained (pEntity);
-
- // --- mesh level constraining ---
-
-#ifdef PARALLEL
- // Constrain parallel interface elements
- void UpdateParallelConstraint(pMesh mesh);
- // unConstrain parallel interface elements
- void DeleteParallelConstraint(pMesh mesh);
-#endif
-
- // Constrain periodic interface elements
- void UpdatePeriodicConstraint3d(pMesh mesh);
- void UpdatePeriodicConstraint2d(pMesh mesh);
-
- // Remove all constraints on elements (periodic, parallel and misc.)
- void DeleteConstraint(pMesh mesh);
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/constraint/ModelConstraintManager.cc b/Adapt/constraint/ModelConstraintManager.cc
deleted file mode 100644
index 6571169..0000000
--- a/Adapt/constraint/ModelConstraintManager.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "ModelConstraintManager.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void ModelConstraintManager::initialize(pGModel _model)
- {
- model = _model;
- }
-
- // -------------------------------------------------------------------
- void ModelConstraintManager::finalize()
- {
- }
-
- // -------------------------------------------------------------------
- void ModelConstraintManager::setModel(pGModel _model)
- {
- model = _model;
- }
-
- // -------------------------------------------------------------------
- void ModelConstraintManager::clear()
- {
- constrEntities.clear();
- }
-
- // -------------------------------------------------------------------
- void ModelConstraintManager::constrain(int type, int id)
- {
- pGEntity pGE = GM_entityByTag(model, type, id);
- constrain(pGE);
- }
-
- // -------------------------------------------------------------------
- void ModelConstraintManager::constrain(pGEntity pGE)
- {
- // constrain entity
- constrEntities.insert(pGE);
-
-#ifdef _HAVE_GMSH_
- // constrain lower geometrical levels
- std::list<pGEntity> subGE = GEN_closure(pGE);
- std::list<pGEntity>::const_iterator subIter = subGE.begin();
- for (; subIter != subGE.end(); subIter++) constrain(*subIter);
-#endif
- }
-
- // -------------------------------------------------------------------
- void ModelConstraintManager::unconstrain(int type, int id)
- {
- pGEntity pGE = GM_entityByTag(model, type, id);
- unconstrain(pGE);
- }
-
- // -------------------------------------------------------------------
- void ModelConstraintManager::unconstrain(pGEntity pGE)
- {
- std::set<pGEntity>::iterator eIter = constrEntities.find(pGE);
- if ( eIter != constrEntities.end() ) constrEntities.erase(eIter);
- }
-
- // -------------------------------------------------------------------
- bool ModelConstraintManager::constrained(pGEntity pGE)
- {
- //GCTODO: check upper-level geometric entities: need model with connectivity
-
- if ( constrEntities.find(pGE) != constrEntities.end() ) return true;
- return false;
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/constraint/ModelConstraintManager.h b/Adapt/constraint/ModelConstraintManager.h
deleted file mode 100644
index 1348d3f..0000000
--- a/Adapt/constraint/ModelConstraintManager.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MODELCONSTRAINTMANAGER
-#define _H_MODELCONSTRAINTMANAGER
-
-#include "ModelInterface.h"
-#include <set>
-
-#include "MAdSingleton.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
-
- class ModelConstraintManager {
-
- public:
-
- ModelConstraintManager() {};
- ~ModelConstraintManager() {};
-
- void initialize(pGModel);
- void finalize();
- void setModel(pGModel);
-
- public:
-
- void clear();
-
- void constrain (int type, int id);
- void constrain (pGEntity);
-
- void unconstrain(int type, int id);
- void unconstrain(pGEntity);
-
- bool constrained(pGEntity);
-
- private:
-
- pGModel model;
- std::set<pGEntity> constrEntities;
- };
-
- // -------------------------------------------------------------------
-
- typedef MAdSingleton<ModelConstraintManager> ModelConstraintManagerSgl;
-
-}
-
-#endif
diff --git a/Adapt/operator/DESCOp.cc b/Adapt/operator/DESCOp.cc
deleted file mode 100644
index 8ee3a71..0000000
--- a/Adapt/operator/DESCOp.cc
+++ /dev/null
@@ -1,204 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Olivier Pierard, Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "DESCOp.h"
-#include "OperatorTools.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void DESCOp::setDESC(pRegion r, pEdge e0, pEdge e1)
- {
- region = r;
- splitE[0] = e0;
- splitE[1] = e1;
- E_center(splitE[0],xyz); // Collapse on mid-edge e0 only
- }
-
- // -------------------------------------------------------------------
- bool DESCOp::checkConstraints() const
- {
- if ( EN_constrained((pEntity)splitE[0]) ||
- EN_constrained((pEntity)splitE[1]) ) {
- return false;
- }
- return true;
- }
-
- // -------------------------------------------------------------------
- bool DESCOp::checkGeometry()
- {
- if( E_whatInType(splitE[1]) != 3 ) return false;
-
- for( int i=0; i<2; i++ ) {
-
- int nbV = 0;
- pVertex verts[2];
- for(int iF=0; iF < R_numFaces(region); iF++) {
- pFace face = R_face(region,iF);
- if( F_inClosure(face,(pEntity)splitE[i]) ) {
- pRegion oppR = F_region(face,0);
- if( oppR == region ) oppR = F_region(face,1);
- if ( oppR ) {
- verts[nbV] = R_fcOpVt(oppR,face);
- nbV++;
- }
- }
- }
-
- pEdge edge = splitE[(i+1)%2];
- for( int j=0; j<E_numFaces(edge); j++ ) {
- pVertex oppV = F_edOpVt(E_face(edge,j),edge);
- for( int k=0; k<nbV; k++ ) {
- if( oppV == verts[k] ) return false;
- }
- }
- }
-
- return true;
- }
-
- // -------------------------------------------------------------------
- bool DESCOp::evaluateShapes()
- {
- double worstShape = mqm.getElementEvaluator()->bestShapeEver();
-
- pMSize xyzSize = sizeField->getSizeOnEntity((pEntity)region,xyz);
-
- for(int iE=0; iE<2; iE++) {
-
- pPList eRegs = E_regions(splitE[iE]);
-
- void * temp = NULL;
- while( pRegion pR = (pRegion)PList_next(eRegs,&temp) ) {
-
- if( pR == region ) continue;
-
- pPList rVerts = R_vertices(pR);
-
- // evaluate the two regions resulting from the split
- for( int iER=0; iER<2; iER++ ) {
-
- pVertex eV = E_vertex(splitE[iE],iER);
-
- pMSize rSizes[4];
- for (int idel = 0; idel<4; idel++) rSizes[idel] = NULL;
- double rCoords[4][3];
-
- pVertex pV = NULL;
- void * iter = NULL;
- for( int iERV=0; ( pV=(pVertex)PList_next(rVerts,&iter) ); iERV++ ) {
- if( pV == eV ) {
- rSizes[iERV] = xyzSize;
- rCoords[iERV][0] = xyz[0];
- rCoords[iERV][1] = xyz[1];
- rCoords[iERV][2] = xyz[2];
- }
- else {
- rSizes[iERV] = sizeField->findSize(pV);
- V_coord(pV,rCoords[iERV]);
- }
- }
-
- double rShape;
- if( !mqm.getElementEvaluator()->XYZ_R_shape(rCoords,rSizes,&rShape) ) {
- PList_delete (rVerts);
- if( xyzSize ) delete xyzSize;
- PList_delete(eRegs);
- return false;
- }
-
- if( worstShape > rShape ) worstShape = rShape;
- }
-
- PList_delete(rVerts);
- }
-
- PList_delete(eRegs);
- }
-
- if( xyzSize ) delete xyzSize;
-
- results->setWorstShape(worstShape);
-
- return true;
- }
-
- // -------------------------------------------------------------------
- void DESCOp::evaluateLengths() const
- {
- // get size at new point (interpolation)
- pMSize xyzSize = sizeField->getSizeOnEntity((pEntity)splitE[0],xyz);
-
- double lSqMin = MAdBIG, lSqMax = 0.;
-
- for( int iE=0; iE<2; iE++ ) {
- for( int i=0; i<E_numFaces(splitE[iE]); i++ ) {
-
- pVertex oppV = F_edOpVt( E_face(splitE[iE],i), splitE[iE] );
- const pMSize oppSize = sizeField->findSize(oppV);
-
- double xyzOpp[3];
- V_coord(oppV,xyzOpp);
- double lSq = sizeField->SF_XYZ_lengthSq(xyz, xyzOpp,
- xyzSize, oppSize);
- if( lSq > lSqMax ) lSqMax = lSq;
- if( lSq < lSqMin ) lSqMin = lSq;
- }
- }
-
- results->setMaxLenSq(lSqMax);
- results->setMinLenSq(lSqMin);
-
- if( xyzSize ) delete xyzSize;
- }
-
-
- // -------------------------------------------------------------------
- void DESCOp::getCavity(pPList * cavity) const
- {
- *cavity = PList_new();
- PList_append(*cavity,region);
-
- for(int i=0; i<2; i++) {
- pPList eRegs = E_regions(splitE[i]);
- void * iter = NULL;
- for(pRegion pR; ( pR=(pRegion)PList_next(eRegs,&iter) ); ) {
- if( pR != region ) {
- PList_append(*cavity,pR);
- }
- }
- PList_delete(eRegs);
- }
- }
-
- // -------------------------------------------------------------------
- void DESCOp::apply()
- {
- pVertex newV[2];
- for(int iE=0; iE<2; iE++) {
- newV[iE] = E_split(mesh, splitE[iE], xyz);
- }
-
- pVertex vTgt = newV[0];
-
- pEdge edgeDel = E_exist(vTgt,newV[1]);
- assert ( edgeDel );
-
- E_collapse(mesh, edgeDel, newV[1], vTgt);
-
- HistorySgl::instance().add((int)type(),OPERATOR_APPLY,1);
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/operator/DESCOp.h b/Adapt/operator/DESCOp.h
deleted file mode 100644
index c497537..0000000
--- a/Adapt/operator/DESCOp.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Olivier Pierard, Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_DESCOP
-#define _H_DESCOP
-
-#include "MAdOperatorBase.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class DESCOp: public MAdOperatorBase
- {
- public:
-
- DESCOp(pMesh, DiscreteSF *);
- DESCOp(const DESCOp &);
- ~DESCOp() {}
-
- operationType type() const { return MAd_DESPLTCLPS; }
-
- void setDESC(pRegion, pEdge, pEdge);
-
- void getCavity(pPList *) const;
-
- void apply();
-
- private:
-
- bool checkConstraints() const;
- bool checkGeometry();
- bool evaluateShapes();
- void evaluateLengths() const;
-
- private:
-
- pRegion region;
- pEdge splitE[2];
- double xyz[3];
- };
-
-
- // -------------------------------------------------------------------
- inline DESCOp::DESCOp(const DESCOp &_desc):
- MAdOperatorBase(_desc)
- {
- region = _desc.region;
- splitE[0] = _desc.splitE[0];
- splitE[1] = _desc.splitE[1];
-
- xyz[0] = _desc.xyz[0];
- xyz[1] = _desc.xyz[1];
- xyz[2] = _desc.xyz[2];
- }
-
- // -------------------------------------------------------------------
- inline DESCOp::DESCOp(pMesh _m, DiscreteSF * _sf):
- MAdOperatorBase(_m,_sf), region(NULL)
- {
- splitE[0] = NULL;
- splitE[1] = NULL;
-
- xyz[0] = 0.0;
- xyz[1] = 0.0;
- xyz[2] = 0.0;
- }
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/operator/EdgeCollapseOp.cc b/Adapt/operator/EdgeCollapseOp.cc
deleted file mode 100644
index 1e7d5e3..0000000
--- a/Adapt/operator/EdgeCollapseOp.cc
+++ /dev/null
@@ -1,376 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "EdgeCollapseOp.h"
-#include "OperatorTools.h"
-#include <map>
-
-using std::map;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- bool edgeCollapseOp::checkConstraints() const
- {
- if ( EN_constrained((pEntity)edgeDel) ) return false;
- if ( EN_constrained((pEntity)vDel ) ) return false;
- return true;
- }
-
- // -------------------------------------------------------------------
- bool edgeCollapseOp::checkGeometry()
- {
- int typeD = V_whatInType(vDel);
- if ( typeD == 0 ) return false;
-
- if ( constrainBoundary ) {
- switch( typeD ) {
- case 3: break;
- case 2:
- {
- bool ok = true;
- pPList eRgns = E_regions(edgeDel);
- if( PList_size(eRgns) != 0 ) ok = false;
- PList_delete(eRgns);
- if (!ok) return false;
- break;
- }
- case 1: return false;
- case 0: return false;
- }
- }
- else {
- if ( V_whatIn(vDel) != E_whatIn(edgeDel) ) return false;
-
- // check for surface dimension reduction by face contact
- if ( V_whatInType(vDel) <= 2 )
- {
- pEdge oppE;
- pFace newSurfaceFace;
-
- pPList vDelFaces = V_faces(vDel);
- void * temp = NULL;
- pFace pf;
- while ( ( pf = (pFace)PList_next(vDelFaces,&temp) ) ) {
- if ( F_inClosure(pf,edgeDel) ) continue;
- if ( F_whatInType(pf) == 2 ) {
- oppE = F_vtOpEd(pf,vDel);
- newSurfaceFace = F_exist(oppE,vTgt);
- if ( newSurfaceFace && EN_type(newSurfaceFace) == 2 ) {
- PList_delete(vDelFaces);
- return false;
- }
- }
- }
- PList_delete(vDelFaces);
- }
-
- // check for surface dimension reduction by edge contact
- if ( V_whatInType(vDel) == 2 )
- {
- pVertex oppV;
- pEdge newLineEdge;
-
- pPList vDelEdges = V_edges(vDel);
- void * temp = NULL;
- pEdge pe;
- while ( ( pe = (pEdge)PList_next(vDelEdges,&temp) ) ) {
- if ( pe == edgeDel ) continue;
- if ( E_whatInType(pe) <= 2 ) {
- oppV = E_otherVertex(pe,vDel);
- newLineEdge = E_exist(oppV,vTgt);
- if ( newLineEdge && E_whatInType(newLineEdge) == 2 ) {
- pFace delFace = F_exist(newLineEdge,vDel);
- if ( !delFace || ( delFace && F_whatInType(delFace) == 3 ) ) {
- PList_delete(vDelEdges);
- return false;
- }
- }
- }
- }
- PList_delete(vDelEdges);
- }
-
- // check for line dimension reduction
- if ( V_whatInType(vDel) <= 1 )
- {
- pVertex oppV;
- pEdge newLineEdge;
-
- pPList vDelEdges = V_edges(vDel);
- void * temp = NULL;
- pEdge pe;
- while ( ( pe = (pEdge)PList_next(vDelEdges,&temp) ) ) {
- if ( E_whatInType(pe) == 1 ) {
- oppV = E_otherVertex(pe,vDel);
- newLineEdge = E_exist(oppV,vTgt);
- if ( newLineEdge && E_whatInType(newLineEdge) == 1 ) {
- PList_delete(vDelEdges);
- return false;
- }
- }
- }
- PList_delete(vDelEdges);
- }
- }
-
- return true;
- }
-
- // -------------------------------------------------------------------
- bool edgeCollapseOp::evaluateShapes2D()
- {
- pPList vDelFaces = V_faces(vDel);
-
- double worstShape = mqm.getElementEvaluator()->bestShapeEver();
-
- map<pGEntity,double> area_after;
-
- void * temp1 = 0;
- while ( pFace face = (pFace)PList_next(vDelFaces,&temp1) ) {
-
- // Faces surrounding edgeDel will be deleted
- if (F_inClosure(face,(pEntity)edgeDel)) continue;
-
- // Gather the coordinates and sizes of the new face
- double xyz[3][3];
- pMSize fSizes[3] = {NULL,NULL,NULL};
-
- pPList fVerts = F_vertices(face,1);
- void * temp2 = 0;
- int iV = 0;
- while ( pVertex vertex = (pVertex)PList_next(fVerts, &temp2) ) {
- if (vertex == vDel) {
- fSizes[iV] = sizeField->findSize(vTgt);
- V_coord(vTgt,xyz[iV]);
- }
- else {
- fSizes[iV] = sizeField->findSize(vertex);
- V_coord(vertex,xyz[iV]);
- }
- iV++;
- }
- PList_delete(fVerts);
-
- // Check if the shape is acceptable and compare it to the worst shape
- double shape = 0.;
- double normalBefore[3];
- F_normal(face,normalBefore);
- if ( !mqm.getElementEvaluator()->XYZ_F_shape(xyz, fSizes, normalBefore, &shape) ) {
- PList_delete(vDelFaces);
- return false;
- }
- else {
- if ( shape < worstShape ) worstShape = shape;
- }
-
- // Compute the area of the new face
- if( !constrainBoundary && V_whatInType(vDel) < 2 ) {
-
- pGEntity g = F_whatIn(face);
- std::map<pGEntity,double>::iterator it = area_after.find( g );
- if( it != area_after.end() )
- (*it).second += XYZ_F_area(xyz,normalBefore);
- else
- area_after[g] = XYZ_F_area(xyz,normalBefore);
- }
- }
-
- // If the edge is on a boundary, check that the area of
- // the old and the new cavities are the same for each Geo entities
- if( !constrainBoundary && V_whatInType(vDel) < 2 ) {
- map< pGEntity,double> area_before;
- map<pGEntity,double>::iterator it, it2;
-
- void * temp3 = 0;
- while ( pFace face = (pFace)PList_next(vDelFaces,&temp3) ) {
- double normal[3];
- F_normal(face,normal);
- pGEntity g = F_whatIn(face);
- it = area_before.find( g );
- if( it != area_before.end() )
- (*it).second += F_area(face,normal);
- else
- area_before[g] = F_area(face,normal);
- }
-
- for( it=area_before.begin(); it!=area_before.end(); ++it )
- {
- double before = (*it).second;
- double after( 0.0 );
- it2 = area_after.find( (*it).first );
- if( it2 != area_after.end() )
- after = (*it2).second;
-
- // Check area change
- double dA = fabs( (before-after) / before );
- if( dA > dATol ) {
- PList_delete(vDelFaces);
- return false;
- }
- }
- }
- results->setWorstShape(worstShape);
-
- PList_delete(vDelFaces);
-
- return true;
- }
-
- // -------------------------------------------------------------------
- bool edgeCollapseOp::evaluateShapes()
- {
- pPList vDelRgns = V_regions(vDel);
-
- // 2D case
- if( PList_size(vDelRgns)==0 ) {
- bool flag = evaluateShapes2D();
- PList_delete(vDelRgns);
- return flag;
- }
-
- // 3D case
- else {
-
- double worstShape = mqm.getElementEvaluator()->bestShapeEver();
- double volAfter = 0.;
-
- void * temp1 = 0;
- while ( pRegion region = (pRegion)PList_next(vDelRgns,&temp1) ) {
-
- // Regions surrounding edgeDel will be deleted
- if (R_inClosure(region,(pEntity)edgeDel)) continue;
-
- // Gather the coordinates and sizes of the new region
- double xyz[4][3];
- pMSize rSizes[4] = {NULL,NULL,NULL,NULL};
-
- pPList rVerts = R_vertices(region);
- void * temp2 = 0;
- int iV = 0;
- while ( pVertex vertex = (pVertex)PList_next(rVerts, &temp2) ) {
- if (vertex == vDel) {
- rSizes[iV] = sizeField->findSize(vTgt);
- V_coord(vTgt,xyz[iV]);
- }
- else {
- rSizes[iV] = sizeField->findSize(vertex);
- V_coord(vertex,xyz[iV]);
- }
- iV++;
- }
- PList_delete(rVerts);
-
- // Check if the shape is acceptable and compare it to the worst shape
- double shape = 0.;
- if ( !mqm.getElementEvaluator()->XYZ_R_shape(xyz, rSizes, &shape) ) {
- PList_delete(vDelRgns);
- return false;
- }
- else {
- if ( shape < worstShape ) worstShape = shape;
- }
-
- // Compute the volume of the new region
- if( !constrainBoundary && V_whatInType(vDel)!=3 ) {
- volAfter += R_XYZ_volume (xyz);
- }
- }
-
- // If the edge is on a boundary, check that the volume of
- // the old and the new cavities are the same
- if( !constrainBoundary && V_whatInType(vDel)!=3 ) {
-
- double volBefore = 0.;
-
- void * temp3 = 0;
- while ( pRegion region = (pRegion)PList_next(vDelRgns,&temp3) ) {
- volBefore += R_volume (region);
- }
-
- double dV = fabs( (volBefore-volAfter) / volBefore );
- if( dV > dVTol ) {
- PList_delete(vDelRgns);
- return false;
- }
- }
-
- results->setWorstShape(worstShape);
- }
-
- PList_delete(vDelRgns);
-
- return true;
- }
-
- // -------------------------------------------------------------------
- void edgeCollapseOp::evaluateLengths() const
- {
- double minSq = MAdBIG, maxSq = 0.;
-
- double xyzTgt[3];
- V_coord(vTgt,xyzTgt);
- pMSize sizeTgt = sizeField->findSize(vTgt);
-
- // list nodes linked to target vertex by an edge
- std::set<pVertex> vTgtLinked;
- pPList vTgtEdges = V_edges(vTgt);
- void * temp1 = 0;
- while ( pEdge edge = (pEdge) PList_next(vTgtEdges,&temp1) ) {
- vTgtLinked.insert(E_vertex(edge,0));
- vTgtLinked.insert(E_vertex(edge,1));
- }
- PList_delete(vTgtEdges);
-
- // find nodes linked to vDel and not linked to vTgt
- pPList vDelEdges = V_edges(vDel);
- void * temp2 = 0;
- while ( pEdge edge = (pEdge) PList_next(vDelEdges,&temp2) ) {
- for (int iV=0; iV<2; iV++) {
- pVertex pV = E_vertex(edge,iV);
- if ( pV == vDel ) continue;
- if ( vTgtLinked.find(pV) != vTgtLinked.end() ) continue;
-
- double xyzV[3];
- V_coord(pV,xyzV);
- pMSize sizeV = sizeField->findSize(pV);
-
- double newSq = sizeField->SF_XYZ_lengthSq(xyzTgt,xyzV,sizeTgt,sizeV);
- if( newSq < minSq ) { minSq = newSq; }
- if( newSq > maxSq ) { maxSq = newSq; }
- }
- }
- PList_delete(vDelEdges);
-
- results->setMaxLenSq(maxSq);
- results->setMinLenSq(minSq);
- }
-
- // -------------------------------------------------------------------
- void edgeCollapseOp::getCavity(pPList * cavity) const
- {
- if ( dim == 3 ) *cavity = V_regions(vDel);
- else *cavity = V_faces(vDel);
- }
-
- // -------------------------------------------------------------------
- void edgeCollapseOp::apply()
- {
- E_collapse(mesh, edgeDel, vDel, vTgt);
-
- HistorySgl::instance().add((int)type(),OPERATOR_APPLY,1);
- }
-
- // -------------------------------------------------------------------
-
-}
-
diff --git a/Adapt/operator/EdgeCollapseOp.h b/Adapt/operator/EdgeCollapseOp.h
deleted file mode 100644
index 5790fc4..0000000
--- a/Adapt/operator/EdgeCollapseOp.h
+++ /dev/null
@@ -1,105 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_EDGECOLLAPSEOP
-#define _H_EDGECOLLAPSEOP
-
-#include "MAdOperatorBase.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class edgeCollapseOp: public MAdOperatorBase
- {
- public:
-
- edgeCollapseOp(pMesh, DiscreteSF *);
- edgeCollapseOp(const edgeCollapseOp &);
- ~edgeCollapseOp() {}
-
- operationType type() const { return MAd_ECOLLAPSE; }
-
- void collapseOnBoundary(bool, double);
- void setCollapseEdge(pEdge, pVertex, pVertex);
-
- void getCavity(pPList *) const;
-
- void apply();
-
- private:
-
- bool checkConstraints() const;
- bool checkGeometry();
- bool evaluateShapes();
- bool evaluateShapes2D();
- void evaluateLengths() const;
-
- private:
-
- pEdge edgeDel;
- pVertex vDel; // the vertex to be deleted
- pVertex vTgt; // the target vertex
-
- bool constrainBoundary;
- double dVTol, dATol; // tolerance on the relative change of volume or area
- };
-
- // -------------------------------------------------------------------
- inline edgeCollapseOp::edgeCollapseOp(const edgeCollapseOp & _ec):
- MAdOperatorBase(_ec)
- {
- edgeDel = _ec.edgeDel;
- vDel = _ec.vDel;
- vTgt = _ec.vTgt;
- constrainBoundary = _ec.constrainBoundary;
- dVTol = _ec.dVTol;
- dATol = _ec.dATol;
- }
-
- // -------------------------------------------------------------------
- inline edgeCollapseOp::edgeCollapseOp(pMesh _m, DiscreteSF * _sf):
- MAdOperatorBase(_m,_sf)
- {
- edgeDel = NULL;
- vDel = NULL;
- vTgt = NULL;
- constrainBoundary = true;
- dVTol = MAdTOL;
- dATol = MAdTOL;
- }
-
- // -------------------------------------------------------------------
- inline void edgeCollapseOp::collapseOnBoundary(bool cob, double tolerance)
- {
- constrainBoundary = !cob;
- dVTol = tolerance;
- dATol = tolerance;
- }
-
- // -------------------------------------------------------------------
- inline void edgeCollapseOp::setCollapseEdge(pEdge _edgeDel,
- pVertex _vDel,
- pVertex _vTgt)
- {
- edgeDel = _edgeDel;
- vDel = _vDel;
- vTgt = _vTgt;
- results->reset();
- }
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
-
diff --git a/Adapt/operator/EdgeSplitOp.cc b/Adapt/operator/EdgeSplitOp.cc
deleted file mode 100644
index 4590560..0000000
--- a/Adapt/operator/EdgeSplitOp.cc
+++ /dev/null
@@ -1,207 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Olivier Pierard, Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "EdgeSplitOp.h"
-#include "OperatorTools.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- bool edgeSplitOp::checkConstraints() const
- {
- if ( EN_constrained((pEntity)edge) ) return false;
- return true;
- }
-
- // -------------------------------------------------------------------
- bool edgeSplitOp::checkGeometry()
- {
- return true;
- }
-
- // -------------------------------------------------------------------
- bool edgeSplitOp::evaluateShapes()
- {
- pPList eRegs = E_regions(edge);
-
- // 2D case
- if ( PList_size(eRegs) == 0 ) {
- bool flag = evaluateShapes2D();
- PList_delete(eRegs);
- return flag;
- }
-
- // 3D case
- else {
-
- double worstShape = MAdBIG;
-
- void * temp = 0;
- while ( pRegion region = (pRegion)PList_next(eRegs,&temp) ) {
-
- pPList rVerts = R_vertices(region);
-
- // evaluate the two regions resulting from the split
- for( int iR=0; iR<2; iR++ ) {
-
- pVertex eV = E_vertex(edge,iR);
-
- pMSize rSizes[4] = { NULL, NULL, NULL, NULL };
- double rCoords[4][3];
-
- pVertex pV = NULL;
- void * iter = NULL;
- for( int iRV=0; (pV=(pVertex)PList_next(rVerts,&iter) ); iRV++ ) {
- if( pV == eV ) {
- rSizes[iRV] = xyzSize;
- rCoords[iRV][0] = xyz[0];
- rCoords[iRV][1] = xyz[1];
- rCoords[iRV][2] = xyz[2];
- }
- else {
- rSizes[iRV] = sizeField->findSize(pV);
- V_coord(pV,rCoords[iRV]);
- }
- }
-
- double rShape;
- if( !mqm.getElementEvaluator()->XYZ_R_shape(rCoords,rSizes,&rShape) ) {
- PList_delete (eRegs);
- PList_delete (rVerts);
- return false;
- }
-
- if( worstShape > rShape ) worstShape = rShape;
- }
- PList_delete(rVerts);
- }
-
- results->setWorstShape(worstShape);
- }
-
- PList_delete(eRegs);
-
- return true;
- }
-
- // -------------------------------------------------------------------
- bool edgeSplitOp::evaluateShapes2D()
- {
- double worstShape = MAdBIG;
-
- pPList eFaces = E_faces(edge);
-
- void * temp = NULL;
- while ( pFace face = (pFace)PList_next(eFaces,&temp) ) {
-
- pPList fVerts = F_vertices(face,1);
-
- // evaluate the two faces resulting from the split
- for( int iF=0; iF<2; iF++ ) {
-
- pVertex eV = E_vertex(edge,iF);
-
- pMSize fSizes[3] = { NULL, NULL, NULL };
- double fCoords[3][3];
-
- pVertex pV;
- void * iter = NULL;
- for( int iFV=0; (pV=(pVertex)PList_next(fVerts,&iter)); iFV++ ) {
- if( pV == eV ) {
- fSizes[iFV] = xyzSize;
- fCoords[iFV][0] = xyz[0];
- fCoords[iFV][1] = xyz[1];
- fCoords[iFV][2] = xyz[2];
- }
- else {
- fSizes[iFV] = sizeField->findSize(pV);
- V_coord(pV,fCoords[iFV]);
- }
- }
-
- double fShape;
- if( !mqm.getElementEvaluator()->XYZ_F_shape(fCoords,fSizes,0,&fShape) ) {
- PList_delete (eFaces);
- PList_delete (fVerts);
- return false;
- }
-
- if( worstShape > fShape ) worstShape = fShape;
- }
-
- PList_delete(fVerts);
- }
-
- PList_delete(eFaces);
-
- results->setWorstShape(worstShape);
-
- return true;
- }
-
- // -------------------------------------------------------------------
- void edgeSplitOp::evaluateLengths() const
- {
- pVertex verts[2];
- double vCoords[2][3];
- pMSize vSizes[2] = {NULL,NULL};
- for( int iV=0; iV<2; iV++ ) {
- verts[iV] = E_vertex(edge,iV);
- V_coord(verts[iV],vCoords[iV]);
- vSizes[iV] = sizeField->findSize(verts[iV]);
- }
-
- pMSize newSize = sizeField->getSizeOnEntity((pEntity)edge,xyz);
-
- double lSqMax = sizeField->SF_XYZ_lengthSq(xyz, vCoords[0],
- newSize, vSizes[0]);
- double lSqMin = lSqMax;
- double lSq = sizeField->SF_XYZ_lengthSq(xyz, vCoords[1],
- newSize, vSizes[1]);
- if( lSq > lSqMax ) lSqMax = lSq;
- if( lSq < lSqMin ) lSqMin = lSq;
-
- for( int i=0; i<E_numFaces(edge); i++ ) {
- pVertex oppV = F_edOpVt(E_face(edge,i), edge);
- pMSize oppSize = sizeField->findSize(oppV);
- double xyzOpp[3];
- V_coord(oppV,xyzOpp);
- lSq = sizeField->SF_XYZ_lengthSq(xyz, xyzOpp,
- newSize, oppSize);
- if( lSq > lSqMax ) lSqMax = lSq;
- if( lSq < lSqMin ) lSqMin = lSq;
- }
-
- if( newSize ) delete newSize;
-
- results->setMaxLenSq(lSqMax);
- results->setMinLenSq(lSqMin);
- }
-
- // -------------------------------------------------------------------
- void edgeSplitOp::getCavity(pPList * cavity) const
- {
- if ( dim == 3 ) *cavity = E_regions(edge);
- else *cavity = E_faces(edge);
- }
-
- // -------------------------------------------------------------------
- void edgeSplitOp::apply()
- {
- E_split(mesh,edge,xyz,u);
-
- HistorySgl::instance().add((int)type(),OPERATOR_APPLY,1);
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/operator/EdgeSplitOp.h b/Adapt/operator/EdgeSplitOp.h
deleted file mode 100644
index fa0becb..0000000
--- a/Adapt/operator/EdgeSplitOp.h
+++ /dev/null
@@ -1,92 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Olivier Pierard, Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_EDGESPLITOP
-#define _H_EDGESPLITOP
-
-#include "MAdOperatorBase.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class edgeSplitOp: public MAdOperatorBase
- {
- public:
-
- edgeSplitOp(pMesh, DiscreteSF *);
- edgeSplitOp(const edgeSplitOp &);
- ~edgeSplitOp() { if (xyzSize) delete xyzSize; }
-
- operationType type() const { return MAd_ESPLIT; }
-
- // stores the edge to be splitted, computes the location of the split
- // and returns the (unique) adimensional square length of the resulting edges
- double setSplitEdge(pEdge);
-
- void getCavity(pPList *) const;
-
- void apply();
-
- private:
-
- bool checkConstraints() const;
- bool checkGeometry();
- bool evaluateShapes();
- bool evaluateShapes2D();
- void evaluateLengths() const;
-
- private:
-
- pEdge edge;
- double xyz[3], u; // new vertex location: euclidian and edge parameter
- pMSize xyzSize; // size at the new vertex
- };
-
- // -------------------------------------------------------------------
- inline edgeSplitOp::edgeSplitOp(const edgeSplitOp & _es):
- MAdOperatorBase(_es)
- {
- edge = _es.edge;
- xyz[0] = _es.xyz[0];
- xyz[1] = _es.xyz[1];
- xyz[2] = _es.xyz[2];
- u = _es.u;
- xyzSize = MS_copy(_es.xyzSize);
- }
-
- // -------------------------------------------------------------------
- inline edgeSplitOp::edgeSplitOp(pMesh _m, DiscreteSF * _sf):
- MAdOperatorBase(_m,_sf), edge(NULL)
- {
- xyz[0] = 0.;
- xyz[1] = 0.;
- xyz[2] = 0.;
- u = -1.;
- xyzSize = NULL;
- }
-
- // -------------------------------------------------------------------
- inline double edgeSplitOp::setSplitEdge(pEdge _edge)
- {
- if ( xyzSize ) delete xyzSize;
- edge = _edge;
- double lenReduc;
- u = sizeField->SF_E_center(_edge,xyz,&lenReduc,&xyzSize);
- return lenReduc;
- }
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/operator/EdgeSwapConfig.cc b/Adapt/operator/EdgeSwapConfig.cc
deleted file mode 100644
index 53ff7e4..0000000
--- a/Adapt/operator/EdgeSwapConfig.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Arnaud Francois, Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "EdgeSwapConfig.h"
-#include <iostream>
-
-using namespace MAd;
-
-// -------------------------------------------------------------------
-// Edge swap template with 3 faces connected to the edge
-const int EdgeSwap3::triangles[1][3] = { { 0,1,2 } };
-const int EdgeSwap3::triangulations[1][1] = {{0}};
-
-// Edge swap template with 4 faces connected to the edge
-const int EdgeSwap4::triangles[4][3] = { {0,1,2}, {0,2,3}, {0,1,3}, {1,2,3} };
-const int EdgeSwap4::triangulations[2][2] = { {0, 1}, {2, 3} };
-
-// Edge swap template with 5 faces connected to the edge
-const int EdgeSwap5::triangles[10][3]= { {0,1,2}, {0,2,3}, {0,3,4}, {0,1,4}, {1,3,4},
- {1,2,3}, {2,3,4}, {0,2,4}, {0,1,3}, {1,2,4} };
-const int EdgeSwap5::triangulations[5][3] = { {0,1,2}, {3,4,5}, {0,6,7}, {2,5,8}, {3,6,9} } ;
-
-// Edge swap template with 6 faces connected to the edge
-const int EdgeSwap6::triangles[20][3]= { {0,1,2}, {0,2,3}, {0,3,4}, {0,4,5},
- {0,2,5}, {2,4,5}, {2,3,4}, {0,3,5}, {3,4,5}, {0,2,4}, {2,3,5}, {1,2,3},
- {0,1,3}, {0,1,5}, {1,4,5}, {1,3,4}, {0,1,4}, {1,3,5}, {1,2,4}, {1,2,5} };
-const int EdgeSwap6::triangulations[14][4] = { {0,1,2,3}, {0,4,5,6}, {0,1,7,8},
- {0,3,6,9}, {0,4,8,10}, {2,3,11,12}, {11,13,14,15}, {7,8,11,12}, {3,11,15,16},
- {8,11,13,17}, {6,13,14,18}, {3,6,16,18}, {5,6,13,19}, {8,10,13,19} };
-
-// Edge swap template with 7 faces connected to the edge
-const int EdgeSwap7::triangles[35][3] = { {0,1,2}, {0,2,3}, {0,3,4}, {0,4,5},
- {0,5,6}, {0,3,6}, {3,5,6}, {3,4,5}, {0,4,6}, {4,5,6}, {0,3,5}, {3,4,6},
- {0,2,4}, {2,3,4}, {0,2,6}, {2,5,6}, {2,4,5}, {0,2,5}, {2,4,6}, {2,3,5},
- {2,3,6}, {0,1,3}, {1,2,3}, {0,1,4}, {1,3,4}, {0,1,6}, {1,5,6}, {1,4,5},
- {0,1,5}, {1,4,6}, {1,3,5}, {1,3,6}, {1,2,4}, {1,2,5}, {1,2,6} };
-const int EdgeSwap7::triangulations[42][5] = { {0,1,2,3,4}, {0,1,5,6,7},
- {0,1,2,8,9}, {0,1,4,7,10}, {0,1,5,9,11}, {0,3,4,12,13}, {0,13,14,15,16},
- {0,8,9,12,13}, {0,4,13,16,17}, {0,9,13,14,18}, {0,7,14,15,19},{0,4,7,17,19},
- {0,6,7,14,20}, {0,9,11,14,20}, {2,3,4,21,22}, {5,6,7,21,22}, {2,8,9,21,22},
- {4,7,10,21,22}, {5,9,11,21,22}, {3,4,22,23,24}, {22,24,25,26,27},
- {8,9,22,23,24}, {4,22,24,27,28}, {9,22,24,25,29}, {7,22,25,26,30},
- {4,7,22,28,30}, {6,7,22,25,31}, {9,11,22,25,31}, {3,4,13,23,32},
- {13,25,26,27,32}, {8,9,13,23,32}, {4,13,27,28,32}, {9,13,25,29,32},
- {13,16,25,26,33}, {4,13,16,28,33}, {13,15,16,25,34}, {9,13,18,25,34},
- {7,19,25,26,33}, {4,7,19,28,33}, {7,15,19,25,34}, {6,7,20,25,34},
- {9,11,20,25,34} };
-
-// -------------------------------------------------------------------
-void EdgeSwapConfiguration::set( int i )
-{
- switch( i )
- {
- case 0: c = &cNull; break;
- case 3: c = &c3; break;
- case 4: c = &c4; break;
- case 5: c = &c5; break;
- case 6: c = &c6; break;
- case 7: c = &c7; break;
- default:
- std::cerr << "Error: Swap configuration not implemented for n="<< i << std::endl;
- throw;
- }
-}
-
-// -------------------------------------------------------------------
diff --git a/Adapt/operator/EdgeSwapConfig.h b/Adapt/operator/EdgeSwapConfig.h
deleted file mode 100644
index 975e8c0..0000000
--- a/Adapt/operator/EdgeSwapConfig.h
+++ /dev/null
@@ -1,173 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Arnaud Francois, Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_EDGESWAPCONFIG
-#define _H_EDGESWAPCONFIG
-
-namespace MAd
-{
- // -------------------------------------------------------------------
- class EdgeSwapTemplate // 3D case
- {
- public:
- EdgeSwapTemplate() {}
- virtual ~EdgeSwapTemplate() {}
- virtual int getConfig(){ return 0; } // nb of faces attached to edge
- virtual int nb_triangulations() = 0; // nb of possible triangulations
- virtual int nb_triangles() = 0; // nb of different triangles
- virtual int nb_tri_triangulation() = 0; // nb of triangles in a triangulation
- virtual const int* triangle( int i ) = 0; // return the triangle i
- virtual const int* triangulation( int i ) = 0; // return the triangulation i
- };
-
- // -------------------------------------------------------------------
- // Null edge swap template
- class EdgeSwap0 : public EdgeSwapTemplate
- {
- public:
- EdgeSwap0() { }
- int getConfig(){ return 0; }
- int nb_triangles(){ return -1; }
- int nb_triangulations(){ return -1; }
- int nb_tri_triangulation(){ return -1; }
- const int* triangle( int i) { return 0; }
- const int* triangulation( int i) { return 0; }
- };
-
- // -------------------------------------------------------------------
- // Edge swap template with 3 faces connected to the edge
- class EdgeSwap3 : public EdgeSwapTemplate
- {
- public:
- EdgeSwap3() { }
- int getConfig(){ return 3; }
- int nb_triangles(){ return 1; }
- int nb_triangulations(){ return 1; }
- int nb_tri_triangulation(){ return 1; }
- const int* triangle( int i) { return triangles[i]; }
- const int* triangulation( int i) { return triangulations[i]; }
- private:
- static const int triangles[1][3];
- static const int triangulations[1][1];
- };
-
- // -------------------------------------------------------------------
- // Edge swap template with 4 faces connected to the edge
- class EdgeSwap4 : public EdgeSwapTemplate
- {
- public:
- EdgeSwap4() { }
- int getConfig(){ return 4; }
- int nb_triangles(){ return 4; }
- int nb_triangulations(){ return 2; }
- int nb_tri_triangulation(){ return 2; }
- const int* triangle( int i) { return triangles[i]; }
- const int* triangulation( int i) { return triangulations[i]; }
- private:
- static const int triangles[4][3];
- static const int triangulations[2][2];
- };
-
- // -------------------------------------------------------------------
- // Edge swap template with 5 faces connected to the edge
- class EdgeSwap5 : public EdgeSwapTemplate
- {
- public:
- EdgeSwap5() { }
- int getConfig(){ return 5; }
- int nb_triangles(){ return 10; }
- int nb_triangulations(){ return 5; }
- int nb_tri_triangulation(){ return 3; }
- const int* triangle( int i) { return triangles[i]; }
- const int* triangulation( int i) { return triangulations[i]; }
- private:
- static const int triangles[10][3];
- static const int triangulations[5][3];
- };
-
- // -------------------------------------------------------------------
- // Edge swap template with 6 faces connected to the edge
- class EdgeSwap6 : public EdgeSwapTemplate
- {
- public:
- EdgeSwap6() { }
- int getConfig(){ return 6; }
- int nb_triangles(){ return 20; }
- int nb_triangulations(){ return 14; }
- int nb_tri_triangulation(){ return 4; }
- const int* triangle( int i) { return triangles[i]; }
- const int* triangulation( int i) { return triangulations[i]; }
- protected:
- static const int triangles[20][3];
- static const int triangulations[14][4];
- };
-
- // -------------------------------------------------------------------
- // Edge swap template with 7 faces connected to the edge
- class EdgeSwap7 : public EdgeSwapTemplate
- {
- public:
- EdgeSwap7() { }
- int getConfig(){ return 7; }
- int nb_triangles(){ return 35; }
- int nb_triangulations(){ return 42; }
- int nb_tri_triangulation(){ return 5; }
- const int* triangle( int i) { return triangles[i]; }
- const int* triangulation( int i) { return triangulations[i]; }
- protected:
- static const int triangles[35][3];
- static const int triangulations[42][5];
- };
-
- // -------------------------------------------------------------------
- // Interface
- class EdgeSwapConfiguration
- {
- public:
-
- EdgeSwapConfiguration( ) { set(0); }
- EdgeSwapConfiguration( int n ) { set( n ); }
- EdgeSwapConfiguration( const EdgeSwapConfiguration &x ) { set( x.get() ); }
- ~EdgeSwapConfiguration() { }
-
- // select edge swap template with n faces connected to the edge
- void set( int n );
-
- // return the nodes of triangle i for the selected configuration
- const int* triangle( int i ) const { return (*c).triangle(i); }
-
- // return the node j of triangle i for the selected configuration
- int triangle( int i, int j ) const { return (*c).triangle(i)[j]; }
-
- // return the triangle j of triangulation i
- int triangulation( int i, int j ) const { return (*c).triangulation(i)[j]; }
-
- int nb_triangles() const { return c->nb_triangles(); }
- int nb_triangulations() const { return c->nb_triangulations(); }
- int nb_tri_triangulation() const { return c->nb_tri_triangulation(); }
-
- int get() const { return c->getConfig(); }
-
- private:
- EdgeSwap0 cNull;
- EdgeSwap3 c3;
- EdgeSwap4 c4;
- EdgeSwap5 c5;
- EdgeSwap6 c6;
- EdgeSwap7 c7;
- EdgeSwapTemplate * c;
- };
-
- // -------------------------------------------------------------------
-}
-#endif
diff --git a/Adapt/operator/EdgeSwapOp.cc b/Adapt/operator/EdgeSwapOp.cc
deleted file mode 100644
index 6fe28d4..0000000
--- a/Adapt/operator/EdgeSwapOp.cc
+++ /dev/null
@@ -1,580 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Arnaud Francois, Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "EdgeSwapOp.h"
-#include "MAdDefines.h"
-#include "CallBackManager.h"
-#include "MAdOutput.h"
-#include "MathUtils.h"
-#include "MAdMessage.h"
-
-#include <iostream>
-#include <sstream>
-using std::cout;
-using std::endl;
-using std::cerr;
-using std::stringstream;
-#include <math.h>
-
-namespace MAd
-{
- // -------------------------------------------------------------------
- bool edgeSwapOp::checkConstraints() const
- {
- if( EN_constrained((pEntity)edge) ) return false;
- return true;
- }
-
- // -------------------------------------------------------------------
- bool edgeSwapOp::checkGeometry()
- {
- // set the available swap configurations for a given edge
- // regarding geometry
- if( M_numRegions(mesh)==0 ) return checkGeometry2D(); // 2D mesh
- else return checkGeometry3D(); // 3D mesh
- return false;
- }
-
- // -------------------------------------------------------------------
- bool edgeSwapOp::checkGeometry2D()
- {
- if ( E_numFaces(edge) != 2 ) return false;
- if ( E_whatInType(edge) <= 1 ) return false;
-
- // check for dimension reduction
- pFace face0 = E_face(edge,0);
- pVertex pv0 = F_edOpVt(face0,edge);
- pFace face1 = E_face(edge,1);
- pVertex pv1 = F_edOpVt(face1,edge);
- if ( E_exist(pv0,pv1) ) return false;
-
- return true;
- }
-
- // -------------------------------------------------------------------
- // Set the swap configuration to be used. Return false if the edge swap
- // operation is not allowed
- bool edgeSwapOp::checkGeometry3D()
- {
- int nbf = E_numFaces(edge); // nb of faces attached to the edge
- if( nbf < 3 || nbf >7 ) // check if swap configuration is implemented
- return false;
-
- // check the dimension of the geometrical entity on which edge is classified
- // If the edge is on a non-manifold face this case should be handled in
- // future developments (GC)
- bool boundarySwap = false;
- int gDim = E_whatInType(edge);
- if( gDim == 1 ) return false;
- else if ( gDim == 2 )
- {
- if ( constrainBoundary ) return false;
- else {
- checkVol = true;
- boundarySwap = true;
- }
- }
-
- // get 'face' that connects to edge. if one classified on a surface, take that
- // one, otherwise take any (e.g. last one)
- int nbBFaces = 0;
- pFace face;
- pFace bFace=NULL;
- for( int i=0; i < nbf; i++ )
- {
- face = E_face(edge,i);
- if( F_whatInType(face) == 2 ) {
- nbBFaces++;
- bFace = face;
- }
- }
- if (bFace) face = bFace;
-
- // reject swaps on non-manifold cavities
- if ( nbBFaces > 2 || nbBFaces == 1 ) {
- exportCavity("swap_nonmanif1.pos");
- MAdMsgSgl::instance().warning(__LINE__,__FILE__,
- "Found a non-manifold domain, rejecting edge swap");
- return false;
- }
-
- // get region connected to face
- pRegion region = F_region(face,0);
- if( !region ) region = F_region(face,1);
-
- // Get vertices of the polyhedron around 'edge'
- vertices.clear();
- vertices.resize(nbf);
- pFace current_face = face;
- pRegion current_region = region;
- for( int i=0; i < nbf; i++ )
- {
- vertices[i] = F_edOpVt(current_face, edge);
-
- if (i == (nbf-1)) {
- if ( boundarySwap && current_region != NULL ) {
- // non-manifold-domain: a geometrical face with 2 regions
- exportCavity("swap_nonmanif2.pos");
- MAdMsgSgl::instance().warning(__LINE__,__FILE__,
- "Found a non-manifold domain, rejecting edge swap");
- return false;
- }
- }
- else {
- pFace next_face = E_otherFace(edge, current_face, current_region);
- pRegion next_region = F_region(next_face, 0);
- if( next_region == current_region ) {
- next_region = F_region(next_face, 1);
- }
- current_face = next_face;
- current_region = next_region;
- }
- }
-
- // Special case: if swap on boundary, check that there is not a third
- // boundary face or edge that would use the first and last points of the crown.
- // If you like cerebral sport, try to figure out why...
- if ( boundarySwap ) {
- pEdge edgeTmp = E_exist(vertices[0],vertices[nbf-1]);
- if ( edgeTmp && E_whatInType(edgeTmp) <= 2 ) return false;
- }
-
- // Find top and bottom vertices from orientation of the polyhedron
- // v2 is top vertex if ( V01 x V02 ) . V32 > 0
- pVertex v0 = vertices[0];
- pVertex v1 = vertices[1];
- pVertex v2 = E_vertex(edge, 0);
- pVertex v3 = E_vertex(edge, 1);
-
- double p[4][3];
- V_coord( v0, p[0] );
- V_coord( v1, p[1] );
- V_coord( v2, p[2] );
- V_coord( v3, p[3] );
- double a[3] = { p[1][0]-p[0][0], p[1][1]-p[0][1], p[1][2]-p[0][2] };
- double b[3] = { p[2][0]-p[0][0], p[2][1]-p[0][1], p[2][2]-p[0][2] };
- double c[3] = { p[2][0]-p[3][0], p[2][1]-p[3][1], p[2][2]-p[3][2] };
- double ab[3] = { a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0] }; // a x b
- if( ab[0]*c[0] + ab[1]*c[1] + ab[2]*c[2] > 0.0 )
- {
- vt = v2;
- vb = v3;
- }
- else
- {
- vt = v3;
- vb = v2;
- }
-
- swap_config.set( nbf );
- return true;
- }
-
- // -------------------------------------------------------------------
- bool edgeSwapOp::evaluateShapes()
- {
- // select the best triangulation and evaluate worst shape
- if( M_numRegions(mesh)==0 ) return evaluateShapes2D();
- else return evaluateShapes3D();
- return false;
- }
-
- // -------------------------------------------------------------------
- // loop over all possible swap configurations and select the best triangulation
- bool edgeSwapOp::evaluateShapes3D()
- {
- // if edge is classified on face type need to check volume
- double volume = 0.0;
- if( checkVol )
- {
- pRegion region;
- pPList regions = E_regions (edge);
- void *temp=0;
- while( ( region = (pRegion)PList_next(regions, &temp) ) )
- volume += R_volume (region);
- PList_delete (regions);
- }
- int nb_triangles = swap_config.nb_triangles();
- // here nb_triangles is maximum 35 (for config = 7),
- // ansi c++ does not support variable lengths for arrays
- double shapes[35]; // worst shape for each configuration
- bool valid_shapes[35];
- double volumes[35]; // volumes of the new swap configurations
-
- // -- loop on all possible triangulations and compute associated element shapes --
- for( int i=0; i< nb_triangles; i++ )
- {
- double xyz[4][3];
- pMSize s[4];
-
- pVertex v0 = vertices[ swap_config.triangle(i,0) ];
- pVertex v1 = vertices[ swap_config.triangle(i,1) ];
- pVertex v2 = vertices[ swap_config.triangle(i,2) ];
-
- V_coord(v0, xyz[0]);
- V_coord(v1, xyz[1]);
- V_coord(v2, xyz[2]);
- V_coord(vt, xyz[3]);
-
- s[0] = sizeField->findSize(v0);
- s[1] = sizeField->findSize(v1);
- s[2] = sizeField->findSize(v2);
- s[3] = sizeField->findSize(vt);
-
- // evaluate 'top' Tet [v0,v1,v2,vt]
- double shape;
- bool shape_ok = mqm.getElementEvaluator()->XYZ_R_shape( xyz, s , &shape );
- valid_shapes[i] = shape_ok;
- shapes[i] = shape;
-
- if( !shape_ok ) // no need to compute shape of bottom tet since
- { // configuration will be rejected
- valid_shapes[i] = false;
- continue;
- }
-
- // evaluate 'bottom' Tet [v0,v2,v1,vb]
- V_coord(v2, xyz[1]);
- V_coord(v1, xyz[2]);
- V_coord(vb, xyz[3]);
- s[1] = sizeField->findSize(v2);
- s[2] = sizeField->findSize(v1);
- s[3] = sizeField->findSize(vb);
-
- valid_shapes[i] = mqm.getElementEvaluator()->XYZ_R_shape( xyz, s , &shape );
-
- // keep worst value of top-bottom tets for swap configuration i in shapes[i]
- if( shape < shapes[i] ) shapes[i] = shape;
-
- // volume computation
- if( checkVol )
- {
- volumes[i] = R_XYZ_volume( xyz ); // bottom tet
- V_coord(vt,xyz[3]);
- volumes[i] += R_XYZ_volume( xyz ); // top tet
- }
- }
-
- // -- Select best valid edge swap configuration --
- double optimum = 0.0;
- for( int i=0; i < swap_config.nb_triangulations(); i++ )
- {
- // find worst element shape of this configuration
- double worst_shape = MAdBIG; // assume the shape is always between 0.0 and 1.0
- bool valid;
- for( int j=0; j < swap_config.nb_tri_triangulation(); j++ )
- {
- int t = swap_config.triangulation(i,j); // test triangle t
- valid = valid_shapes[t];
- if( !valid )
- break;
-
- if( shapes[t] < worst_shape )
- worst_shape = shapes[t];
- }
-
- // if shape is not valid, check next swap configuration
- if( !valid )
- continue;
-
- // check volume change
- if( checkVol )
- {
- double new_volume = 0.0;
- for( int j=0; j < swap_config.nb_tri_triangulation(); j++ )
- new_volume += volumes[ swap_config.triangulation(i,j) ];
-
- if( fabs(volume-new_volume)/volume > dVTol )
- continue;
- }
-
- if( worst_shape > optimum )
- {
- optimum = worst_shape; // worst shape of the configuration
- conf = i; // best swap configuration
- }
- }
-
- // no valid swap configuration was found
- if( optimum <= MAdTOL ) return false;
-
- results->setWorstShape( optimum );
-
- return true;
- }
-
- // -------------------------------------------------------------------
- bool edgeSwapOp::evaluateShapes2D()
- {
- double worstShape = MAdBIG;
-
- // evaluate shape of new triangles
- pFace f0 = E_face(edge,0);
- pFace f1 = E_face(edge,1);
- pVertex v0 = E_vertex(edge,0);
- pVertex v1 = E_vertex(edge,1);
- pVertex v2 = F_edOpVt(f0, edge);
- pVertex v3 = F_edOpVt(f1, edge);
-
- double xyz[3][3];
- V_coord(v0, xyz[0]);
- V_coord(v2, xyz[1]);
- V_coord(v3, xyz[2]);
-
- pMSize s[3];
- s[0] = sizeField->findSize(v0);
- s[1] = sizeField->findSize(v2);
- s[2] = sizeField->findSize(v3);
-
- // evaluate shape of new triangles [v0,v2,v3] && [v1,v2,v3]
- double normal[3];
- double e02[3],e03[3];
- diffVec(xyz[1],xyz[0],e02);
- diffVec(xyz[2],xyz[0],e03);
- crossProd(e02,e03,normal);
- double shape;
- // [v0,v2,v3]
- if( !mqm.getElementEvaluator()->XYZ_F_shape(xyz, s, normal, &shape) ) return false;
- worstShape = shape;
-
- V_coord(v1, xyz[0]);
- s[0] = sizeField->findSize(v1);
-
- normal[0] = -normal[0];
- normal[1] = -normal[1];
- normal[2] = -normal[2];
-
- if( !mqm.getElementEvaluator()->XYZ_F_shape(xyz, s, normal, &shape) ) return false;
-
- if( worstShape > shape ) worstShape = shape;
-
- results->setWorstShape(worstShape);
- // check the area of the new faces in case of '3D' surf mesh
-
- return true;
- }
-
- // -------------------------------------------------------------------
- // calculate the max/min size after the modification is applied
- void edgeSwapOp::evaluateLengths() const
- {
- double maxSwap, minSwap;
-
- // consider the new edges created after swap
- if( M_numRegions(mesh) == 0 ) // 2D mesh
- {
- pFace face0 = E_face(edge, 0);
- pVertex v0 = F_edOpVt(face0,edge);
- pFace face1 = E_face(edge, 1);
- pVertex v1 = F_edOpVt(face1,edge);
- maxSwap = sizeField->SF_VV_lengthSq(v0,v1);
- minSwap = maxSwap;
- }
- else
- {
- // 3D mesh
- minSwap = MAdBIG;
- maxSwap = 0.;
-
- // evaluate the triangles of the c'th configuration
- pVertex v[3];
- for( int j=0; j < swap_config.nb_tri_triangulation(); j++ )
- {
- int t = swap_config.triangulation(conf,j);
- for( int i=0; i<3; i++ )
- {
- v[i] = vertices[ swap_config.triangle(t,i) ];
- }
-
- for( int i=0; i<3; i++ )
- {
- // (AF) we could also pre-define the new edges to be tested in the EdgeSwapConfig
- // to avoid the E_exist loop
- if( !E_exist(v[i],v[(i+1)%3]) ) /// 0-1,1-2,2-0
- {
- double lSq = sizeField->SF_VV_lengthSq(v[i], v[(i+1)%3]);
- if( lSq > maxSwap ) maxSwap = lSq;
- if( lSq < minSwap ) minSwap = lSq;
- }
- }
- }
- }
-
- // initialization
- double lMinSq = MAdBIG;
- double lMaxSq = 0.0;
- if( maxSwap > lMaxSq ) lMaxSq = maxSwap;
- if( minSwap < lMinSq ) lMinSq = minSwap;
-
- results->setMaxLenSq(lMaxSq);
- results->setMinLenSq(lMinSq);
- }
-
- // -------------------------------------------------------------------
- void edgeSwapOp::apply()
- {
- if( M_numRegions(mesh) !=0 ) apply3D();
- else apply2D();
- HistorySgl::instance().add((int)type(),OPERATOR_APPLY,1);
- }
-
- // -------------------------------------------------------------------
- int edgeSwapOp::apply2D()
- {
- // 2D mesh case
- pPList old_faces = PList_new();
- pPList new_faces = PList_new();
-
- pFace f0 = E_face(edge,0);
- pFace f1 = E_face(edge,1);
- pVertex v0 = E_vertex(edge,0);
- pVertex v1 = E_vertex(edge,1);
- pVertex v2 = F_edOpVt(f0, edge);
- pVertex v3 = F_edOpVt(f1, edge);
-
- pGEntity gface = F_whatIn(f0); // classification
-
- // new triangles [v0,v2,v3] && [v1,v2,v3]
- pEdge newe = M_createE(mesh, v2, v3, gface);
- pEdge e02 = mesh->find_edge( v0, v2, (MDB_Triangle*)f0 );
- pEdge e03 = mesh->find_edge( v0, v3, (MDB_Triangle*)f1 );
- pEdge e12 = mesh->find_edge( v1, v2, (MDB_Triangle*)f0 );
- pEdge e13 = mesh->find_edge( v1, v3, (MDB_Triangle*)f1 );
- pFace newf0 = mesh->add_triangle( e02, newe, e03, gface);
- pFace newf1 = mesh->add_triangle( e12, newe, e13, gface);
-
- PList_append(new_faces, newf0);
- PList_append(new_faces, newf1);
-
- // call callback
- CallBackManagerSgl::instance().callCallBacks(old_faces, new_faces, MAd_ESWAP, (pEntity)edge);
- PList_delete(old_faces);
- PList_delete(new_faces);
-
- // deletion
- M_removeFace(mesh,f0);
- M_removeFace(mesh,f1);
- M_removeEdge(mesh,edge);
-
- edge = 0;
- conf = -1;
-
- return 1;
-
- }
-
- // -------------------------------------------------------------------
- int edgeSwapOp::apply3D()
- {
- pPList eregs = E_regions(edge); // cavity before swap
- pGRegion greg = R_whatIn( (pRegion)PList_item(eregs, 0) );
-
- pPList newRegions = PList_new();
-
- if( conf < 0 ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Edge swap configuration not defined, call evaluate() first");
- }
-
- // create new regions for the selected swap configuration
- pVertex v[3];
- for( int i=0; i < swap_config.nb_tri_triangulation(); i++ )
- {
- int t = swap_config.triangulation(conf,i);
- for( int j=0; j<3; j++ )
- v[j] = vertices[ swap_config.triangle(t,j) ];
-
- //create new regions
- pRegion r1 = mesh->add_tet( v[0], v[1],v[2], vt, (pGEntity)greg );
- pRegion r2 = mesh->add_tet( v[0], v[2],v[1], vb, (pGEntity)greg );
- PList_append( newRegions, r1 );
- PList_append( newRegions, r2 );
- }
-
- // If swap on a boundary, classify new boundary entities (1 edge, 2 faces)
- if( E_whatInType(edge) == 2 )
- {
- pGEntity bgent = E_whatIn(edge);
-
- // the new edge to be classified is supposed to be between the first
- // and the last vertices of the configuration (we started to list nodes
- // at a classified face in checkGeometry)
- pEdge bEdge = E_exist(vertices[0],vertices[swap_config.get()-1]);
- E_setWhatIn(bEdge,bgent);
-
- // now classify the faces
- pPList eFaces = E_faces(bEdge);
- void * temp = NULL;
- pFace face;
- pVertex oppV;
- int count = 0;
- while ( ( face = (pFace)PList_next(eFaces,&temp) ) ) {
- oppV = F_edOpVt(face,bEdge);
- if ( oppV == vt || oppV == vb ) {
- assert ( F_numRegions(face) == 1 );
- F_setWhatIn(face,bgent);
- count++;
- }
- }
- PList_delete(eFaces);
- assert(count == 2);
- }
-
- // call callback
- CallBackManagerSgl::instance().callCallBacks(eregs, newRegions, MAd_ESWAP, (pEntity)edge );
- PList_delete(newRegions);
-
- // remove old regions connected to edge
- pRegion frgn;
- void *temp = 0;
- while( ( frgn = (pRegion)PList_next(eregs, &temp) ) )
- M_removeRegion(mesh,frgn);
- PList_delete(eregs);
-
- // remove old faces connected to edge
- pFace face;
- pPList faces = E_faces(edge);
- void *temp1 = 0;
- while( ( face = (pFace)PList_next(faces, &temp1) ) )
- M_removeFace(mesh, face);
- PList_delete(faces);
-
- // remove edge
- M_removeEdge(mesh, edge);
-
- edge = 0;
- conf = -1;
-
- return 1;
- }
-
- // -------------------------------------------------------------------
- void edgeSwapOp::getCavity(pPList * cavity) const
- {
- if ( dim == 3 ) *cavity = E_regions(edge);
- else *cavity = E_faces(edge);
- }
-
- // -------------------------------------------------------------------
- void edgeSwapOp::reportSwap( )
- {
- stringstream ss;
- std::string idStr; ss << reportId; ss >> idStr;
- std::string name = reportPrefix + "swap" + idStr + ".pos";
- pPList cavity = E_regions( edge );
- printPosEntities(cavity,name.c_str(),OD_CONSTANT, 0 );
- PList_delete(cavity);
- reportId++;
- }
-
- // -------------------------------------------------------------------
-}
diff --git a/Adapt/operator/EdgeSwapOp.h b/Adapt/operator/EdgeSwapOp.h
deleted file mode 100644
index e867ff7..0000000
--- a/Adapt/operator/EdgeSwapOp.h
+++ /dev/null
@@ -1,124 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Arnaud Francois, Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_EDGESWAPOP
-#define _H_EDGESWAPOP
-
-#include "MAdOperatorBase.h"
-#include "EdgeSwapConfig.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class edgeSwapOp : public MAdOperatorBase
- {
- public:
-
- edgeSwapOp();
- edgeSwapOp(pMesh, DiscreteSF *);
- edgeSwapOp(const edgeSwapOp &);
- ~edgeSwapOp() {}
-
- operationType type() const { return MAd_ESWAP; }
- int getMaxNumRgns() { return 7; }
-
- void setSwapEdge(pEdge);
- void swapOnBoundary(bool,double);
-
- void getCavity(pPList *) const;
-
- void apply();
-
- private:
-
- bool checkConstraints() const;
- bool checkGeometry();
- bool evaluateShapes();
- void evaluateLengths() const;
-
- bool checkGeometry2D();
- bool checkGeometry3D();
- bool evaluateShapes2D();
- bool evaluateShapes3D();
-
- int apply3D();
- int apply2D();
-
- pEdge edge; // the edge to be swapped
- int conf; // best swap configuration - set by geomCheck()
- pVertex vt; // top and bottom vertices of the edge (define the polygon orientation
- pVertex vb; // w/r to vertices)
- std::vector<pVertex> vertices; // oriented list of vertices defining the polygon
-
- EdgeSwapConfiguration swap_config;
-
- bool constrainBoundary;
- bool checkVol; // tells if it's interesting to compute the variation of
- // volume in the cavity (deduced from classif of edge
- // and constrainBoundary)
- double dVTol;
-
- // reporting
- void reportSwap( );
- bool report;
- int reportId;
- std::string reportPrefix;
-
- };
-
- // -------------------------------------------------------------------
- inline edgeSwapOp::edgeSwapOp(pMesh _m, DiscreteSF * _sf):
- MAdOperatorBase(_m,_sf), edge(0), conf(-1), vt(0), vb(0),
- constrainBoundary(true), checkVol(false), dVTol(MAdTOL),
- report(false), reportId(0), reportPrefix("")
- {
- vertices.reserve(7);
- }
-
- // -------------------------------------------------------------------
- inline edgeSwapOp::edgeSwapOp(const edgeSwapOp & _es):
- MAdOperatorBase(_es), swap_config( _es.swap_config )
- {
- edge = _es.edge;
- conf = _es.conf;
- vt = _es.vt;
- vb = _es.vb;
- vertices = _es.vertices;
-
- constrainBoundary = _es.constrainBoundary;
- checkVol = _es.checkVol;
- dVTol = _es.dVTol;
-
- report = _es.report;
- reportId = _es.reportId;
- reportPrefix = _es.reportPrefix;
- }
-
- // -------------------------------------------------------------------
- inline void edgeSwapOp::setSwapEdge(pEdge e)
- {
- edge = e;
- results->reset();
- conf = -1;
- checkVol = false;
- }
-
- // -------------------------------------------------------------------
- inline void edgeSwapOp::swapOnBoundary(bool eswapob, double dV)
- {
- constrainBoundary = !eswapob;
- dVTol = dV;
- }
-}
-// -------------------------------------------------------------------
-#endif
diff --git a/Adapt/operator/FaceCollapseOp.cc b/Adapt/operator/FaceCollapseOp.cc
deleted file mode 100644
index 0082c26..0000000
--- a/Adapt/operator/FaceCollapseOp.cc
+++ /dev/null
@@ -1,439 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Olivier Pierard, Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "FaceCollapseOp.h"
-#include "OperatorTools.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- bool faceCollapseOp::checkConstraints() const
- {
- // find the opposite vertex
- oppV = F_edOpVt(delFace,delEdge);
-
- if( EN_constrained((pEntity)delEdge)) return false;
- if( !clpsOnOppV && EN_constrained((pEntity)oppV) ) return false;
-
- return true;
- }
-
- // -------------------------------------------------------------------
- bool faceCollapseOp::checkGeometry()
- {
- pGEntity fGE = F_whatIn(delFace);
- if( clpsOnOppV ) {
- if( E_whatIn(delEdge) != fGE ) return false;
- }
- else {
- if( V_whatIn(oppV) != fGE ) return false;
- }
-
- // For 3D, check that the face is in a region or that we can
- // collapse on surfaces
- if( constrainBoundary &&
- dim == 3 &&
- GEN_type(fGE) != 3 ) return false;
-
- if ( !constrainBoundary &&
- dim == 3 &&
- GEN_type(fGE) == 2 ) checkVol = true;
-
- // Check for surface dimension reduction
- // There is a dimension reduction if these 2 conditions hold for
- // one of the regions bounding delFace:
- // Condition 1: the face containing delEdge and which is not
- // delFace is classified on a surface,
- // Condition 2: one of the 2 other faces is classified on a surface
- for (int iR=0; iR<2; iR++) {
- pRegion reg = F_region(delFace,iR);
- if ( !reg ) continue;
- bool cond1 = false, cond2 = false;
- for (int iF=0; iF<4; iF++) {
- pFace pf = R_face(reg,iF);
- if ( pf == delFace ) continue;
- if ( F_inClosure(pf,delEdge) ) if ( F_whatInType(pf)==2 ) cond1 = true;
- else if ( F_whatInType(pf)==2 ) cond2 = true;
- }
- if ( cond1 && cond2 ) {printf("denying a face collapse for dim reduct\n"); return false;}
- }
-
- return true;
- }
-
- // -------------------------------------------------------------------
- bool faceCollapseOp::evaluateShapes()
- {
- if( dim != 3 ) return evaluateShapes2D();
-
- double worstShape = mqm.getElementEvaluator()->bestShapeEver();
-
- pRegion delReg[2];
- delReg[0] = F_region(delFace,0);
- delReg[1] = F_region(delFace,1);
-
- double rCoords[4][3];
- pMSize rSizes[4] = {NULL, NULL, NULL, NULL};
-
- double volIn = 0.;
- double volOut = 0.;
-
- // 1°) General case valid for any clpsOnOppV
-
- pPList eRegs = E_regions(delEdge);
- void * temp = NULL;
- while( pRegion region = (pRegion)PList_next( eRegs, &temp ) ) {
-
- if (checkVol) { volIn += R_volume (region); }
-
- if( region==delReg[0] || region==delReg[1] ) continue;
-
- // check every tet resulting from the split
- for( int iR=0; iR<2; iR++ ) {
-
- pVertex eV = E_vertex(delEdge,iR);
-
- // Loop over all the vertices of region
- pVertex rV;
- for( int iRV=0; iRV < R_numVertices(region); iRV++ ) {
-
- rV = R_vertex( region, iRV );
-
- if ( rSizes[iRV] ) delete rSizes[iRV];
-
- if( rV == eV ) { // Set oppV size and pos. instead of end of delEdge
- if( clpsOnOppV ) { // Collapse on oppV
- double xyz[3];
- V_coord(oppV,xyz);
- for( int k=0; k<3; k++ ) rCoords[iRV][k] = xyz[k];
- rSizes[iRV] = sizeField->getSize(oppV);
- }
- else { // Collapse on newVt
- for( int k=0; k<3; k++ ) rCoords[iRV][k] = newVPos[k];
- rSizes[iRV] = sizeField->getSizeOnEntity((pEntity)delEdge,rCoords[iRV]);
- }
- }
- else {
- rSizes[iRV] = sizeField->getSize(rV);
- V_coord(rV,rCoords[iRV]);
- }
- }
-
- // Some cleaning and exit if new element is not acceptable
- double shape;
- if( ! mqm.getElementEvaluator()->XYZ_R_shape(rCoords,rSizes,&shape) ) {
- for (int i=0; i<4; i++) {
- if ( rSizes[i] ) delete rSizes[i];
- }
- PList_delete(eRegs);
- return false;
- }
-
- if( worstShape > shape ) worstShape = shape;
-
- if (checkVol) { volOut += R_XYZ_volume(rCoords); }
- } // End of loop on sub-tetra
- } // End loop on regions around delEdge
- PList_delete(eRegs);
-
- // 2°) Particular case if collapse edge on new vertex; need other checks
-
- if( !clpsOnOppV ) {
-
- // loop over the regions of oppV excepted delReg[0-1]
- pPList vRegs = V_regions(oppV);
- void * temp = NULL;
- while( pRegion region = (pRegion)PList_next(vRegs,&temp) ) {
-
- if( region==delReg[0] || region==delReg[1] ) continue;
-
- if (checkVol) { volIn += R_volume(region); }
-
- pVertex rV;
- for(int iRV=0; iRV < R_numVertices(region); iRV++) {
-
- rV = R_vertex(region, iRV);
-
- if ( rSizes[iRV] ) delete rSizes[iRV];
-
- if( rV == oppV ) { // Set size and pos. of new vertex on delEdge
- for(int iC=0; iC<3; iC++) rCoords[iRV][iC] = newVPos[iC];
- rSizes[iRV] = sizeField->getSizeOnEntity((pEntity)delEdge,rCoords[iRV]);
- }
- else {
- rSizes[iRV] = sizeField->getSize(rV);
- V_coord(rV,rCoords[iRV]);
- }
- }
-
- if (checkVol) { volOut += R_XYZ_volume(rCoords); }
-
- // Some cleaning and exit if new element is not acceptable
- double shape;
- if( ! mqm.getElementEvaluator()->XYZ_R_shape(rCoords,rSizes,&shape) ) {
- for (int i=0; i<4; i++) {
- if ( rSizes[i] ) delete rSizes[i];
- }
- PList_delete(vRegs);
- return false;
- }
-
- if( worstShape > shape ) worstShape = shape;
-
- } // End loop on vRegs
- PList_delete(vRegs);
- }
-
- for (int i=0; i<4; i++) {
- if ( rSizes[i] ) delete rSizes[i];
- }
-
- results->setWorstShape(worstShape);
-
- if (checkVol) {
- double dV = fabs( (volIn-volOut) / volIn );
- if( dV > dVTol ) return false;
- }
-
- return true;
- }
-
- // -------------------------------------------------------------------
- bool faceCollapseOp::evaluateShapes2D()
- {
- double worstShape = mqm.getElementEvaluator()->bestShapeEver();
-
- // get the normal to the del face
- double fNormal[3];
- F_normal(delFace,fNormal);
-
- double fCoords[3][3];
- pMSize fSizes[3] = {NULL, NULL, NULL};
-
- // 1°) General case valid for any clpsOnOppV
-
- for( int eF=0; eF < E_numFaces(delEdge); eF++ ) {
-
- pFace face = E_face(delEdge, eF);
-
- if( face == delFace ) continue;
-
- for( int iSubF=0; iSubF<2; iSubF++ ) {
-
- pVertex eV = E_vertex(delEdge,iSubF);
-
- // Loop over all the vertices of face
- pVertex fV;
- for( int iFV=0; iFV<F_numVertices(face); iFV++ ) {
-
- fV = F_vertex(face, iFV);
-
- if ( fSizes[iFV] ) delete fSizes[iFV];
-
- if( fV == eV ) { // Set oppV size and pos. instead of end of delEdge
- if( clpsOnOppV ) {
- double xyz[3];
- V_coord(oppV,xyz);
- for(int k=0; k<3; k++ ) fCoords[iFV][k] = xyz[k];
- fSizes[iFV] = sizeField->getSize(oppV);
- }
- else { // Collapse on newVt
- for(int k=0; k<3; k++) fCoords[iFV][k] = newVPos[k];
- fSizes[iFV] = sizeField->getSizeOnEntity((pEntity)delEdge,fCoords[iFV]);
- }
- }
- else {
- V_coord(fV,fCoords[iFV]);
- fSizes[iFV] = sizeField->getSize(fV);
- }
- }
-
- // Some cleaning and exit if new element is not acceptable
- double shape;
- if( ! mqm.getElementEvaluator()->XYZ_F_shape(fCoords,fSizes,fNormal,&shape) ) {
- for (int i = 0; i<3; i++) {
- if ( fSizes[i] ) delete fSizes[i];
- }
- return false;
- }
-
- if( worstShape > shape ) worstShape = shape;
- } // End of loop on sub-tetra
- } // End loop on regions around delEdge
-
-
- // 2°) Particular case if collapse edge on new vertex; need other checks
-
- if( !clpsOnOppV ) {
-
- pPList vFaces = V_faces(oppV);
- void * temp = NULL;
- while( pFace face = (pFace)PList_next( vFaces, &temp ) ) {
-
- if( face == delFace ) continue;
-
- pVertex fV;
- for( int k=0; k < F_numVertices(face); k++ ) {
-
- fV = F_vertex(face,k);
-
- if ( fSizes[k] ) delete fSizes[k];
-
- if( fV == oppV ) { // Set size and pos. of new vertex on delEdge
- for( int iC=0; iC<3; iC++ ) fCoords[k][iC] = newVPos[iC];
- fSizes[k] = sizeField->getSizeOnEntity((pEntity)delEdge,fCoords[k]);
- }
- else {
- V_coord(fV,fCoords[k]);
- fSizes[k] = sizeField->getSize(fV);
- }
- }
-
- // Some cleaning and exit if new element is not acceptable
- double shape;
- if( ! mqm.getElementEvaluator()->XYZ_F_shape(fCoords,fSizes,fNormal,&shape) ) {
- for (int i = 0; i<3; i++) {
- if ( fSizes[i] ) delete fSizes[i];
- }
- return false;
- }
-
- if( worstShape > shape ) worstShape = shape;
- } // End loop on vFaces
- PList_delete(vFaces);
- }
-
- for (int i = 0; i<3; i++) {
- if ( fSizes[i] ) delete fSizes[i];
- }
-
- results->setWorstShape(worstShape);
-
- return true;
- }
-
- // -------------------------------------------------------------------
- void faceCollapseOp::evaluateLengths() const
- {
- double minSq = MAdBIG;
- double maxSq = 0.;
-
- // Interpolate the desired size at splitting location (for !clpsOnOppV)
- pMSize sizeNewV = NULL;
- if (!clpsOnOppV) {
- sizeNewV = sizeField->getSizeOnEntity((pEntity)delEdge,newVPos);
- }
-
- // 1°) General case, all faces touching delEdge are modified for both types
-
- pFace face;
- for( int i=0; i<E_numFaces(delEdge); i++ ) {
-
- face = E_face(delEdge, i);
-
- if( face == delFace ) continue;
-
- pVertex vertex = F_edOpVt(face,delEdge);
-
- double lenSq;
- if( clpsOnOppV ) {
- lenSq = sizeField->SF_VV_lengthSq(oppV,vertex);
- }
- else {
- double vxyz[3];
- V_coord(vertex,vxyz);
- pMSize vSize = sizeField->findSize(vertex);
- lenSq = sizeField->SF_XYZ_lengthSq( newVPos, vxyz,
- sizeNewV, vSize );
- }
-
- if( lenSq > maxSq ) maxSq = lenSq;
- if( lenSq < minSq ) minSq = lenSq;
- }
-
- // 2°) For type 0 only, all edges touching oppV are affected as well
-
- if( !clpsOnOppV ) {
-
- for( int j=0; j<V_numEdges( oppV ); j++ )
- {
- pVertex vertex = E_otherVertex( V_edge(oppV, j), oppV );
- double vxyz[3];
- V_coord(vertex,vxyz);
- pMSize vSize = sizeField->findSize(vertex);
- double lenSq = sizeField->SF_XYZ_lengthSq( newVPos, vxyz,
- sizeNewV, vSize );
-
- if( lenSq > maxSq ) maxSq = lenSq;
- if( lenSq < minSq ) minSq = lenSq;
- }
- }
-
- results->setMaxLenSq(maxSq);
- results->setMinLenSq(minSq);
-
- if (sizeNewV) delete sizeNewV;
- }
-
- // -------------------------------------------------------------------
- void faceCollapseOp::getCavity(pPList * cavity) const
- {
- if( clpsOnOppV ) // Delete new vertex
- {
- if ( dim == 3 ) *cavity = E_regions(delEdge);
- else *cavity = E_faces(delEdge);
- }
- else // Delete existing vertex
- {
- if ( dim == 3 ) {
- *cavity = V_regions(oppV);
- pPList eRegs = E_regions(delEdge);
- void * temp = 0;
- while ( pRegion region = (pRegion)PList_next(eRegs,&temp) ) {
- if ( !PList_inList(*cavity,region) ) PList_append(*cavity,region);
- }
- PList_delete(eRegs);
- }
- else {
- *cavity = V_faces(oppV);
- pPList eFaces = E_faces(delEdge);
- void * temp = 0;
- while ( pFace face = (pFace)PList_next(eFaces,&temp) ) {
- if ( !PList_inList(*cavity,face) ) PList_append(*cavity,face);
- }
- PList_delete(eFaces);
-
- }
- }
- }
-
- // -------------------------------------------------------------------
- void faceCollapseOp::apply()
- {
- pVertex newV = E_split(mesh, delEdge, newVPos);
-
-
-
- // determine the edge collapse
- pEdge edgeDel = E_exist(oppV,newV);
- pVertex vDel, vTgt;
- if( clpsOnOppV ) { vDel = newV; vTgt = oppV; }
- else { vDel = oppV; vTgt = newV; }
-
- E_collapse(mesh,edgeDel,vDel,vTgt);
-
- HistorySgl::instance().add((int)type(),OPERATOR_APPLY,1);
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/operator/FaceCollapseOp.h b/Adapt/operator/FaceCollapseOp.h
deleted file mode 100644
index 116ef98..0000000
--- a/Adapt/operator/FaceCollapseOp.h
+++ /dev/null
@@ -1,127 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Olivier Pierard, Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_EDGESPLITCOLLAPSEOP
-#define _H_EDGESPLITCOLLAPSEOP
-
-#include "MAdOperatorBase.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class faceCollapseOp: public MAdOperatorBase
- {
- public:
-
- faceCollapseOp(pMesh, DiscreteSF *);
- faceCollapseOp(const faceCollapseOp &);
- ~faceCollapseOp() {}
-
- operationType type() const { return MAd_FCOLLAPSE; }
-
- void collapseOnBoundary(bool, double);
- void reset(pFace, pEdge, bool);
-
- void getCavity(pPList *) const;
-
- void apply();
-
- private:
-
- bool checkConstraints() const;
- bool checkGeometry();
- bool evaluateShapes();
- bool evaluateShapes2D();
- void evaluateLengths() const;
-
- private:
-
- pFace delFace;
- pEdge delEdge;
- bool clpsOnOppV;
- mutable pVertex oppV;
- double newVPos[3];
-
- bool constrainBoundary;
- bool checkVol;
- double dVTol; // tolerance on the relative change of volume
- };
-
-
- // -------------------------------------------------------------------
- inline faceCollapseOp::faceCollapseOp(const faceCollapseOp & _fc):
- MAdOperatorBase(_fc)
- {
- delFace = _fc.delFace;
- delEdge = _fc.delEdge;
- clpsOnOppV = _fc.clpsOnOppV;
- oppV = _fc.oppV;
- newVPos[0] = _fc.newVPos[0];
- newVPos[1] = _fc.newVPos[1];
- newVPos[2] = _fc.newVPos[2];
- constrainBoundary = _fc.constrainBoundary;
- checkVol = _fc.checkVol;
- dVTol = _fc.dVTol;
- }
-
- // -------------------------------------------------------------------
- inline faceCollapseOp::faceCollapseOp(pMesh _m, DiscreteSF * _sf):
- MAdOperatorBase(_m,_sf)
- {
- delFace = NULL;
- delEdge = NULL;
- clpsOnOppV = true;
- oppV = NULL;
- newVPos[0] = 0.;
- newVPos[1] = 0.;
- newVPos[2] = 0.;
- constrainBoundary = true;
- checkVol = false;
- dVTol = MAdTOL;
- }
-
- // -------------------------------------------------------------------
- // pFace: face which would dissapear
- // pEdge: Edge which would be split
- // clpsOnOppV: Edge collapse type
- // True if collapse from SplitEdge to existing vertex
- // False if collapse from existing vertex to SplitEdge
- // -------------------------------------------------------------------
- inline void faceCollapseOp::reset(pFace face, pEdge edge,
- bool typeClps)
- {
- delFace = face;
- delEdge = edge;
- clpsOnOppV = typeClps;
-
- double Exyz[2][3];
- V_coord(E_vertex(delEdge,0),Exyz[0]);
- V_coord(E_vertex(delEdge,1),Exyz[1]);
-
- for(int i=0; i<3; i++) {
- newVPos[i] = 0.5 * ( Exyz[0][i] + Exyz[1][i] );
- }
- }
-
- // -------------------------------------------------------------------
- inline void faceCollapseOp::collapseOnBoundary(bool cob, double tolerance)
- {
- constrainBoundary = !cob;
- dVTol = tolerance;
- }
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/operator/FaceSwapOp.cc b/Adapt/operator/FaceSwapOp.cc
deleted file mode 100644
index a21e1bf..0000000
--- a/Adapt/operator/FaceSwapOp.cc
+++ /dev/null
@@ -1,194 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "FaceSwapOp.h"
-#include "CallBackManager.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- bool faceSwapOp::checkConstraints() const
- {
- if ( EN_constrained((pEntity)face) ) return false;
- return true;
- }
-
- // -------------------------------------------------------------------
- bool faceSwapOp::checkGeometry()
- {
- if ( F_whatInType(face) != 3 ) return false;
- if ( !fRegions[0] || !fRegions[1] ) return false;
- if ( R_whatIn(fRegions[0]) != R_whatIn(fRegions[1]) ) return false;
- return true;
- }
-
- // -------------------------------------------------------------------
- bool faceSwapOp::evaluateShapes()
- {
- // this case would lead to an edge swap
- if ( E_exist(fOppVerts[0],fOppVerts[1]) ) return false;
-
- double worst = mqm.getElementEvaluator()->bestShapeEver();
-
- pPList r0Verts = R_vertices(fRegions[0]);
-
- // collect coordinates of the five vertices
- double xyzR0[4][3];
- void * temp1 = 0;
- int iV = 0;
- while( pVertex pV = (pVertex)PList_next(r0Verts,&temp1) ) {
- V_coord(pV,xyzR0[iV]);
- iV++;
- }
- double xyzV1[3];
- V_coord(fOppVerts[1],xyzV1);
-
- // calculate worst shape of the three new regions
- pPList fVerts = F_vertices(face,1);
- void * temp2 = 0;
- while( pVertex fVertex = (pVertex)PList_next(fVerts,&temp2) ) {
-
- double xyzNewR[4][3];
- pMSize newRSizes[4] = { NULL, NULL, NULL, NULL };
-
- void * temp3 = 0;
- int iR0V = 0;
- while( pVertex pVR0 = (pVertex)PList_next(r0Verts,&temp3) ) {
- if(pVR0 == fVertex) {
- newRSizes[iR0V] = sizeField->findSize(fOppVerts[1]);
- for (int iC=0; iC<3; iC++) xyzNewR[iR0V][iC] = xyzV1[iC];
- iR0V++;
- }
- else {
- newRSizes[iR0V] = sizeField->findSize(pVR0);
- for (int iC=0; iC<3; iC++) xyzNewR[iR0V][iC] = xyzR0[iR0V][iC];
- iR0V++;
- }
- }
-
- double shape;
- if( !mqm.getElementEvaluator()->XYZ_R_shape(xyzNewR,newRSizes,&shape) ) {
- PList_delete(fVerts);
- PList_delete(r0Verts);
- return false;
- }
- if(shape < worst) worst = shape;
- }
- PList_delete(fVerts);
- PList_delete(r0Verts);
-
- results->setWorstShape(worst);
-
- return true;
- }
-
- // -------------------------------------------------------------------
- void faceSwapOp::evaluateLengths() const
- {
- double xyz[2][3];
- pMSize sizes[2] = { NULL, NULL };
- for(int iV=0; iV<2; iV++) {
- V_coord(fOppVerts[iV],xyz[iV]);
- sizes[iV] = sizeField->findSize(fOppVerts[iV]);
- }
-
- double min = sizeField->SF_XYZ_lengthSq(xyz[0], xyz[1],
- sizes[0], sizes[1]);
- double max = min;
-
- results->setMinLenSq(min);
- results->setMaxLenSq(max);
- }
-
- // -------------------------------------------------------------------
- void faceSwapOp::getCavity(pPList * cavity) const
- {
- *cavity = PList_new();
- PList_append(*cavity, fRegions[0]);
- PList_append(*cavity, fRegions[1]);
- }
-
- // -------------------------------------------------------------------
- void faceSwapOp::apply()
- {
- pPList newRegions = PList_new();
-
- // get the geometric entity on which the cavity is classified
- pGRegion geoEntity = R_whatIn(fRegions[0]);
-
- // create new edge
- pEdge newEdge = M_createE(mesh,fOppVerts[0],fOppVerts[1],(pGEntity)geoEntity);
-
- // create new faces
- pFace newFaces[3];
- pPList fVerts = F_vertices(face,1);
- void * temp = 0;
- int iF = 0;
- while ( pVertex pV = (pVertex)PList_next(fVerts,&temp) ) {
-
- pEdge fEdges[3];
- fEdges[0] = E_exist(fOppVerts[0],pV);
- fEdges[1] = E_exist(pV,fOppVerts[1]);
- fEdges[2] = newEdge;
-
- newFaces[iF] = M_createF(mesh,3,fEdges,(pGEntity)geoEntity);
-
- iF++;
- }
-
- pFace boundaryFaces[2][3];
- for(int iR=0; iR<2; iR++) {
- for(int iV=0; iV<3; iV++) {
- boundaryFaces[iR][iV] = R_vtOpFc(fRegions[iR],(pVertex)PList_item(fVerts,iV));
- }
- }
- PList_delete(fVerts);
-
- // create new regions
- for (int iR=0; iR<3; iR++) {
-
- pFace rFaces[4];
- rFaces[0] = boundaryFaces[0][iR];
- rFaces[1] = boundaryFaces[1][iR];
- rFaces[2] = newFaces[(iR+1)%3];
- rFaces[3] = newFaces[(iR+2)%3];
-
- pRegion newR = M_createR(mesh,4,rFaces,(pGEntity)geoEntity);
- PList_append(newRegions, newR);
- }
-
- // list deleted regions
- pPList oldRegions = PList_new();
- PList_append(oldRegions,fRegions[0]);
- PList_append(oldRegions,fRegions[1]);
-
- // call callback functions
- CallBackManagerSgl::instance().callCallBacks(oldRegions,
- newRegions,
- MAd_FSWAP,
- (pEntity)face);
- PList_delete(oldRegions);
- PList_delete(newRegions);
-
- // delete old cavity
- M_removeRegion(mesh,fRegions[0]);
- M_removeRegion(mesh,fRegions[1]);
- M_removeFace(mesh,face);
-
- HistorySgl::instance().add((int)type(),OPERATOR_APPLY,1);
- }
-
- // -------------------------------------------------------------------
-
-}
-
-
diff --git a/Adapt/operator/FaceSwapOp.h b/Adapt/operator/FaceSwapOp.h
deleted file mode 100644
index 8dda9e9..0000000
--- a/Adapt/operator/FaceSwapOp.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_FACESWAPOP
-#define _H_FACESWAPOP
-
-#include "MAdOperatorBase.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class faceSwapOp: public MAdOperatorBase
- {
- public:
-
- faceSwapOp(pMesh, DiscreteSF *);
- faceSwapOp(const faceSwapOp &);
- ~faceSwapOp() {}
-
- operationType type() const { return MAd_FSWAP; }
-
- void setSwapFace(pFace);
-
- void getCavity(pPList *) const;
-
- void apply();
-
- private:
-
- bool checkConstraints() const;
- bool checkGeometry();
- bool evaluateShapes();
- void evaluateLengths() const;
-
- private:
-
- pFace face; // face to be swapped
- pRegion fRegions[2]; // its regions
- pVertex fOppVerts[2]; // opposite vertices in regions
- };
-
- // -------------------------------------------------------------------
- inline faceSwapOp::faceSwapOp(const faceSwapOp & _fs):
- MAdOperatorBase(_fs), face(_fs.face)
- {
- fRegions[0] = _fs.fRegions[0];
- fRegions[1] = _fs.fRegions[1];
- fOppVerts[0] = _fs.fOppVerts[0];
- fOppVerts[1] = _fs.fOppVerts[1];
- }
-
- // -------------------------------------------------------------------
- inline faceSwapOp::faceSwapOp(pMesh _m, DiscreteSF * _sf):
- MAdOperatorBase(_m,_sf), face(NULL)
- {
- fRegions[0] = NULL;
- fRegions[1] = NULL;
- fOppVerts[0] = NULL;
- fOppVerts[1] = NULL;
- }
-
- // -------------------------------------------------------------------
- inline void faceSwapOp::setSwapFace(pFace _face)
- {
- face = _face;
-
- for(int iR=0; iR<2; iR++) {
- fRegions[iR] = F_region(face,iR);
- if (fRegions[iR]) fOppVerts[iR] = R_fcOpVt(fRegions[iR],face);
- }
-
- results->reset();
- }
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/operator/MAdOperatorBase.cc b/Adapt/operator/MAdOperatorBase.cc
deleted file mode 100644
index 11a7d5f..0000000
--- a/Adapt/operator/MAdOperatorBase.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MAdOperatorBase.h"
-#include "MAdOutput.h"
-
-using std::string;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- bool MAdOperatorBase::evaluate(double * worstShape)
- {
- results->reset();
- *worstShape = mqm.getElementEvaluator()->worstShapeEver();
-
- History& history = HistorySgl::instance();
-
- // --- check 1: constraints ---
- if ( !checkConstraints() ) {
- history.add((int)type(),OP_CHECKCONSTRAINTS,0);
- return false;
- } else {
- history.add((int)type(),OP_CHECKCONSTRAINTS,1);
- }
-
- // --- check 2: geometric model ---
- if ( !checkGeometry() ) {
- history.add((int)type(),OP_CHECKGEOMETRY,0);
- return false;
- } else {
- history.add((int)type(),OP_CHECKGEOMETRY,1);
- }
-
- // --- check 3: elements validity and shapes ---
- if ( !evaluateShapes() ) {
- history.add((int)type(),OP_CHECKSHAPES,0);
- return false;
- } else {
- history.add((int)type(),OP_CHECKSHAPES,1);
- }
-
- // --- edge lengths ---
- evaluateLengths();
-
- *worstShape = results->getWorstShape();
-
- return true;
- }
-
- // -------------------------------------------------------------------
- void MAdOperatorBase::exportCavity(string filename) const
- {
- pPList cavity = PList_new();
- getCavity(&cavity);
- if ( dim == 3 ) {
- void * temp = NULL;
- pEntity pe;
- while ( ( pe = PList_next(cavity,&temp) ) ) {
- if ( EN_type(pe) != 3 ) continue;
- pRegion pr = (pRegion) pe;
- pPList rFaces = R_faces(pr);
- void * temp2 = NULL;
- pFace face;
- while ( ( face = (pFace)PList_next(rFaces,&temp2) ) ) {
- if ( F_whatInType(face) == 2 ) PList_appUnique(cavity,face);
- }
- PList_delete(rFaces);
- }
- }
- printPosEntities(cavity,filename,OD_DIMENSION,sizeField);
- PList_delete(cavity);
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/operator/MAdOperatorBase.h b/Adapt/operator/MAdOperatorBase.h
deleted file mode 100644
index 4a2f6f8..0000000
--- a/Adapt/operator/MAdOperatorBase.h
+++ /dev/null
@@ -1,149 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MADOPERATORBASE
-#define _H_MADOPERATORBASE
-
-#include "MAdDefines.h"
-#include "DiscreteSF.h"
-#include "ElementStatistics.h"
-#include "MeshQualityManager.h"
-#include "Constraint.h"
-#include "History.h"
-
-#include <string>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- typedef class MAdOperatorBase * pMAdOperator;
-
- // -------------------------------------------------------------------
- class MAdOperatorBase
- {
- public:
-
- MAdOperatorBase();
- MAdOperatorBase(const MAdOperatorBase &);
- MAdOperatorBase(pMesh, DiscreteSF *);
- virtual ~MAdOperatorBase();
-
- public:
-
- virtual operationType type() const = 0;
-
- void setSizeField(DiscreteSF *);
-
- double getWorstShape() const;
- double getMinLenSq() const;
- double getMaxLenSq() const;
-
- // get a list of all elements that will be modified
- virtual void getCavity(pPList *) const = 0;
- void exportCavity(std::string) const;
-
- // check if the operation can be performed and evaluate it
- bool evaluate(double *);
-
- // apply the operation
- virtual void apply() = 0;
-
- private:
-
- // --- Checks and evaluations ---
- // ! Supposed to be called in that order !
-
- // checks the operation regarding the constraints on mesh entities
- // and geometric entities
- virtual bool checkConstraints() const = 0;
-
- // checks compatibility of the operation with the geometric model
- virtual bool checkGeometry() = 0;
-
- // checks validity of the resulting elements and evaluates their
- // shapes (saves the worst)
- virtual bool evaluateShapes() = 0;
-
- // evaluates the resulting minimal and maximal edge lengths
- virtual void evaluateLengths() const = 0;
-
- // ------------------------------
-
- protected:
-
- pMesh mesh;
- DiscreteSF * sizeField;
-
- // quality evaluator
- MeshQualityManager& mqm;
-
- // storage for the results of the evaluation
- mutable ElementStatistics * results;
-
- // mesh dimension
- int dim;
-
- };
-
- // -------------------------------------------------------------------
- inline MAdOperatorBase::MAdOperatorBase():
- mesh(NULL), sizeField(NULL), mqm(MeshQualityManagerSgl::instance()),
- results(NULL), dim(0)
- {}
-
- // -------------------------------------------------------------------
- inline MAdOperatorBase::MAdOperatorBase(const MAdOperatorBase & _op):
- mesh(_op.mesh), sizeField(_op.sizeField),
- mqm(MeshQualityManagerSgl::instance())
- {
- results = new ElementStatistics(*(_op.results));
- dim = _op.dim;
- }
-
- // -------------------------------------------------------------------
- inline MAdOperatorBase::MAdOperatorBase(pMesh _mesh, DiscreteSF * _sf):
- mesh(_mesh), sizeField(_sf), mqm(MeshQualityManagerSgl::instance())
- {
- results = new ElementStatistics();
- dim = M_dim(mesh);
- }
-
- // -------------------------------------------------------------------
- inline MAdOperatorBase::~MAdOperatorBase()
- {
- if (results) delete results;
- }
-
- // -------------------------------------------------------------------
- inline void MAdOperatorBase::setSizeField(DiscreteSF * _sf)
- {
- sizeField = _sf;
- }
-
- // -------------------------------------------------------------------
- inline double MAdOperatorBase::getWorstShape() const
- { return results->getWorstShape(); }
-
- // -------------------------------------------------------------------
- inline double MAdOperatorBase::getMinLenSq() const
- { return results->getMinLenSq(); }
-
- // -------------------------------------------------------------------
- inline double MAdOperatorBase::getMaxLenSq() const
- { return results->getMaxLenSq(); }
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/operator/OperatorTools.cc b/Adapt/operator/OperatorTools.cc
deleted file mode 100644
index dd6ea96..0000000
--- a/Adapt/operator/OperatorTools.cc
+++ /dev/null
@@ -1,651 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Olivier Pierard, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "OperatorTools.h"
-#include "CallBackManager.h"
-#include "MAdMessage.h"
-
-#include <map>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- bool V_setPosition(pVertex vertex, double target[3])
- {
- if( EN_constrained((pEntity)vertex) ) return false;
- CallBackManagerSgl::instance().callCallBackMoves(vertex,target);
- pPoint point = V_point(vertex);
- P_setPos(point,target[0],target[1],target[2]);
- return true;
- }
-
- // -------------------------------------------------------------------
- void E_collapse(pMesh mesh,
- pEdge edgeDel,
- pVertex vDel,
- pVertex vTgt)
- {
- pPList eRegions = E_regions(edgeDel);
-
- // --- 2D collapse case ---
- if( PList_size(eRegions) == 0 ) {
- PList_delete(eRegions);
- E_collapseOnGFace(mesh,edgeDel,vDel,vTgt);
- return;
- }
-
- // --- build the new mesh ---
-
- pPList newRegions = PList_new();
- pPList vDelRegions = V_regions(vDel);
- void * temp = NULL;
- while ( pRegion region = (pRegion)PList_next(vDelRegions,&temp) )
- {
- if( PList_inList(eRegions,(pEntity)region) ) continue;
-
- pFace fExt = R_vtOpFc(region,vDel);
-
- // create the region
- pGEntity rGEntity = (pGEntity)R_whatIn(region);
- pRegion newR = mesh->add_tet(vTgt,F_vertex(fExt,0),F_vertex(fExt,1),F_vertex(fExt,2),rGEntity);
- PList_append(newRegions, newR);
- }
- PList_delete(eRegions);
-
- // --- classify new boundary entities ---
- int gDim = E_whatInType(edgeDel);
-
- // Classify edges on lines
- if ( gDim == 1 )
- {
- pPList vDelEdges = V_edges(vDel);
- temp = NULL;
- pEdge pe;
- int count = 0;
- while ( ( pe = (pEdge)PList_next(vDelEdges,&temp) ) ) {
- if ( pe == edgeDel ) continue;
- if ( E_whatInType(pe) == 1 ) {
- pGEntity gEdge2 = E_whatIn(pe);
- pVertex oppV = E_otherVertex(pe,vDel);
- pEdge newLineEdge = E_exist(vTgt,oppV);
- E_setWhatIn(newLineEdge,gEdge2);
- count++;
- }
- }
- PList_delete(vDelEdges);
- if ( count != 1 ) {
- V_info(vDel);
- E_info(edgeDel);
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Count should be equal to 1, count = %d",count);
- assert (count == 1);
- }
- }
-
- // classify faces on surfaces
- if ( gDim <= 2 )
- {
- pGEntity gFace;
- pEdge oppE;
- pFace newSurfaceFace;
-
- pPList vDelFaces = V_faces(vDel);
- temp = NULL;
- pFace pf;
- while ( ( pf = (pFace)PList_next(vDelFaces,&temp) ) ) {
- if ( F_inClosure(pf,edgeDel) ) continue;
- if ( F_whatInType(pf) == 2 ) {
- gFace = F_whatIn(pf);
- oppE = F_vtOpEd(pf,vDel);
- newSurfaceFace = F_exist(oppE,vTgt);
- F_setWhatIn(newSurfaceFace,gFace);
- }
- }
- PList_delete(vDelFaces);
- }
-
- // --- call callback functions ---
- CallBackManagerSgl::instance().callCallBacks(vDelRegions,
- newRegions,
- MAd_ECOLLAPSE,
- (pEntity)vDel);
- PList_delete(newRegions);
-
- // --- delete old cavity ---
- temp = NULL;
- while ( pRegion region = (pRegion)PList_next(vDelRegions,&temp) ) {
- M_removeRegion(mesh,region);
- }
- PList_delete(vDelRegions);
-
- pPList vFaces = V_faces(vDel);
- temp = NULL;
- while ( pFace face = (pFace)PList_next(vFaces,&temp) ) {
- M_removeFace(mesh,face);
- }
- PList_delete(vFaces);
-
- pPList vEdges = V_edges(vDel);
- temp = NULL;
- while ( pEdge edge = (pEdge)PList_next(vEdges,&temp) ) {
- M_removeEdge(mesh,edge);
- }
- PList_delete(vEdges);
-
- M_removeVertex(mesh,vDel);
- }
-
-
-
- /*
-// This is the old way to make a collapse
-
- pPList eRegions = E_regions(edgeDel);
-
- // --- 2D collapse case ---
- if( PList_size(eRegions) == 0 ) {
- PList_delete(eRegions);
- E_collapseOnGFace(mesh,edgeDel,vDel,vTgt);
- return;
- }
-
- // --- list faces to be merged ---
-
- std::map<pFace,pFace> fOldToNew; // deleted face -> corresponding new (or target) face
- std::map<pFace,bool> fDirs; // if direction of (deleted) face has to be changed
-
- void * temp1 = 0;
- while ( pRegion region = (pRegion)PList_next(eRegions,&temp1) ) {
-
- pFace fDel, fTgt;
-
- pPList rFaces = R_faces(region);
- void * temp2 = 0;
- while ( pFace face = (pFace)PList_next(rFaces, &temp2) ) {
- if (!F_inClosure(face,(pEntity)edgeDel)) {
- if (F_inClosure(face,(pEntity)vDel)) fDel = face; // deleted face
- else fTgt = face; // target face
- }
- }
- PList_delete(rFaces);
-
- fOldToNew[fDel] = fTgt;
-
- // Choose the direction and classification of target face
- pEdge edge = F_vtOpEd(fDel,vDel);
- if( F_whatInType(fDel) < F_whatInType(fTgt) ) {
- F_setWhatIn( fTgt, F_whatIn(fDel) );
- if( F_dirUsingEdge(fTgt,edge) != F_dirUsingEdge(fDel,edge) ) {
- F_chDir(fTgt);
- }
- }
- else {
- if( F_dirUsingEdge(fTgt,edge) == F_dirUsingEdge(fDel,edge) ) {
- fDirs[fDel] = true;
- }
- else {
- fDirs[fDel] = false;
- }
- }
- }
-
- // --- list edges to be merged ---
-
- std::map<pEdge,pEdge> eOldToNew; // deleted edge -> corresponding new (or target) edge
- std::map<pEdge,bool> eDirs; // if direction of (deleted) edge has to be changed
-
- pPList eFaces = E_faces(edgeDel);
- void * temp3 = 0;
- while ( pFace face = (pFace)PList_next(eFaces,&temp3) ) {
-
- pEdge eDel, eTgt;
-
- pPList fEdges = F_edges(face);
- void * temp4 = 0;
- while ( pEdge edge = (pEdge)PList_next(fEdges, &temp4) ) {
- if ( edge != edgeDel ) {
- if (E_inClosure(edge,(pEntity)vDel)) eDel = edge; // deleted edge
- else eTgt = edge; // target edge
- }
- }
- PList_delete(fEdges);
-
- eOldToNew[eDel] = eTgt;
-
- // Choose the classification of target edge
- if( E_whatInType(eDel) < E_whatInType(eTgt) ) {
- E_setWhatIn( eTgt, E_whatIn(eDel) );
- }
-
- // Choose the direction of target edge
- if( E_vertex(eDel,0) == E_vertex(eTgt,0) ||
- E_vertex(eDel,1) == E_vertex(eTgt,1) ) {
- eDirs[eDel] = true;
- }
- else {
- eDirs[eDel] = false;
- }
- }
- PList_delete(eFaces);
-
- // --- build the new mesh ---
-
- pPList newRegions = PList_new();
- pPList vDelRegions = V_regions(vDel);
- void * temp5 = 0;
- while ( pRegion region = (pRegion)PList_next(vDelRegions,&temp5) ) {
-
- if( PList_inList(eRegions,(pEntity)region) ) continue;
-
- // need to create a new region
- pFace rFaces[4];
-
- pFace fExt = R_vtOpFc(region,vDel);
-
- for(int iF=0; iF<4; iF++) {
-
- pFace face = R_face(region,iF);
-
- if( face == fExt ) {
- rFaces[iF] = face;
- continue;
- }
-
- if ( fOldToNew.find(face) != fOldToNew.end() ) {
- rFaces[iF] = fOldToNew.find(face)->second;
- }
- else {
- // need to create a new face
- pEdge fEdges[3];
-
- for(int iE=0; iE<3; iE++ ) {
-
- pEdge edge = F_edge(face,iE);
-
- if( F_inClosure(fExt,(pEntity)edge) ) {
- fEdges[iE] = edge;
- continue;
- }
-
- if ( eOldToNew.find(edge) != eOldToNew.end() ) {
- fEdges[iE] = eOldToNew.find(edge)->second;
- }
- else {
- // need to create a new edge
-
- pVertex eVertices[2];
- for(int iV=0; iV<2; iV++) {
- pVertex pV = E_vertex(edge,iV);
- if( pV == vDel ) eVertices[iV] = vTgt;
- else eVertices[iV] = pV;
- }
-
- // create the edge
- pGEntity eGEntity = E_whatIn(edge);
- fEdges[iE] = M_createE(mesh, eVertices[0], eVertices[1], eGEntity);
- eOldToNew[edge] = fEdges[iE];
- }
- }
-
- // create the face
- pGEntity fGEntity = F_whatIn(face);
- rFaces[iF] = M_createF(mesh, 3, fEdges, fGEntity);
- fOldToNew[face] = rFaces[iF];
- }
- }
-
- // create the region
- pGEntity rGEntity = (pGEntity)R_whatIn(region);
- pRegion newRegion = M_createR(mesh, 4, rFaces, rGEntity);
- PList_append(newRegions, newRegion);
- }
-
- PList_delete(eRegions);
-
- // --- call callback functions ---
- CallBackManagerSgl::instance().callCallBacks(vDelRegions,
- newRegions,
- MAd_ECOLLAPSE,
- (pEntity)vDel);
- PList_delete(newRegions);
-
- // --- delete old cavity ---
- void * temp = 0;
- while ( pRegion region = (pRegion)PList_next(vDelRegions,&temp) ) {
- M_removeRegion(mesh,region);
- }
- PList_delete(vDelRegions);
-
- pPList vFaces = V_faces(vDel);
- temp = 0;
- while ( pFace face = (pFace)PList_next(vFaces,&temp) ) {
- M_removeFace(mesh,face);
- }
- PList_delete(vFaces);
-
- pPList vEdges = V_edges(vDel);
- temp = 0;
- while ( pEdge edge = (pEdge)PList_next(vEdges,&temp) ) {
- M_removeEdge(mesh,edge);
- }
- PList_delete(vEdges);
-
- M_removeVertex(mesh,vDel);
-
- */
-
- // -------------------------------------------------------------------
- void E_collapseOnGFace(pMesh mesh,
- pEdge edgeDel,
- pVertex vDel,
- pVertex vTgt)
- {
- // --- list edges to be merged ---
-
- std::map<pEdge,pEdge> eOldToNew; // deleted edge -> corresponding new (or target) edge
- std::map<pEdge,bool> eDirs; // if direction of (deleted) edge has to be changed
-
- pPList eFaces = E_faces(edgeDel);
- void * temp1 = 0;
- while ( pFace face = (pFace)PList_next(eFaces,&temp1) ) {
-
- pEdge eDel, eTgt;
-
- pPList fEdges = F_edges(face);
- void * temp2 = 0;
- while ( pEdge edge = (pEdge)PList_next(fEdges, &temp2) ) {
- if ( edge != edgeDel ) {
- if (E_inClosure(edge,(pEntity)vDel)) eDel = edge; // deleted edge
- else eTgt = edge; // target edge
- }
- }
- PList_delete(fEdges);
-
- eOldToNew[eDel] = eTgt;
-
- // Choose the classification of target edge
- if( E_whatInType(eDel) < E_whatInType(eTgt) ) {
- E_setWhatIn( eTgt, E_whatIn(eDel) );
- }
-
- // Choose the direction of target edge
- if( E_vertex(eDel,0) == E_vertex(eTgt,0) ||
- E_vertex(eDel,1) == E_vertex(eTgt,1) ) {
- eDirs[eDel] = true;
- }
- else {
- eDirs[eDel] = false;
- }
- }
-
- // --- build the new mesh ---
-
- pPList newFaces = PList_new();
- pPList vDelFaces = V_faces(vDel);
- void * temp3 = 0;
- while ( pFace face = (pFace)PList_next(vDelFaces,&temp3) ) {
-
- if( PList_inList(eFaces,(pEntity)face) ) continue;
-
- // need to create a new face
- pEdge fEdges[3];
-
- pEdge eExt = F_vtOpEd(face,vDel);
-
- for(int iE=0; iE<3; iE++ ) {
-
- pEdge edge = F_edge(face,iE);
-
- if( edge == eExt ) {
- fEdges[iE] = edge;
- continue;
- }
-
- if ( eOldToNew.find(edge) != eOldToNew.end() ) {
- fEdges[iE] = eOldToNew.find(edge)->second;
- }
- else {
- // need to create a new edge
-
- pVertex eVertices[2];
- for(int iV=0; iV<2; iV++) {
- pVertex pV = E_vertex(edge,iV);
- if( pV == vDel ) eVertices[iV] = vTgt;
- else eVertices[iV] = pV;
- }
-
- // create the edge
- pGEntity eGEntity = E_whatIn(edge);
- fEdges[iE] = M_createE(mesh, eVertices[0], eVertices[1], eGEntity);
- eOldToNew[edge] = fEdges[iE];
- }
- }
-
- // create the face
- pGEntity fGEntity = F_whatIn(face);
- pFace newFace = M_createF(mesh, 3, fEdges, fGEntity);
- PList_append(newFaces,newFace);
- }
-
- PList_delete(eFaces);
-
- // --- call callback functions ---
- CallBackManagerSgl::instance().callCallBacks(vDelFaces,
- newFaces,
- MAd_ECOLLAPSE,
- (pEntity)vDel);
- PList_delete(newFaces);
-
- // --- delete old cavity ---
- void * temp = 0;
- while ( pFace face = (pFace)PList_next(vDelFaces,&temp) ) {
- M_removeFace(mesh,face);
- }
- PList_delete(vDelFaces);
-
- pPList vEdges = V_edges(vDel);
- temp = 0;
- while ( pEdge edge = (pEdge)PList_next(vEdges,&temp) ) {
- M_removeEdge(mesh,edge);
- }
- PList_delete(vEdges);
-
- M_removeVertex(mesh,vDel);
- }
-
-
- // -------------------------------------------------------------------
- pVertex E_split(pMesh mesh, pEdge edge, double xyz[3], double t)
- {
- // --- build the vertex ---
-
- pVertex newV = NULL; // the new vertex
-
- pGEntity edgeGE = E_whatIn(edge); // its classification
-
- double u[2][2];
- u[0][0] = -2.; u[0][1] = -2.; u[1][0] = -2.; u[1][1] = -2.;
- if ( E_params(edge,u) ) {
- double uV[2];
- if ( GEN_type(edgeGE) == 2 ) {
- GF_centerOnGeodesic( (pGFace)edgeGE, t, u, uV );
- }
- else {
- for (int iP=0; iP<2; iP++) uV[iP] = (1.-t) * u[0][iP] + t * u[1][iP];
- }
- newV = M_createVP(mesh, xyz[0], xyz[1], xyz[2], uV[0], uV[1], -1, edgeGE);
- }
- else {
- newV = M_createV(mesh, xyz[0], xyz[1], xyz[2], -1, edgeGE);
- }
-
- // --- build the edges ---
- pPList newEdges = PList_new();
- pEdge e1 = M_createE(mesh, E_vertex(edge,0), newV, edgeGE);
- PList_append(newEdges,e1);
- pEdge e2 = M_createE(mesh, newV, E_vertex(edge,1), edgeGE);
- PList_append(newEdges,e2);
-
- // --- build the faces bordered by new edges ---
- pPList newFaces = PList_new();
- pPList eFaces = E_faces(edge);
- void * temp = NULL;
- while( pFace face = (pFace)PList_next(eFaces,&temp) ) {
-
- pGEntity fGE = F_whatIn(face);
- pEdge newE = M_createE(mesh, newV, F_edOpVt(face,edge), fGE);
-
- int iEdge = 0;
- for( iEdge=0; iEdge< F_numEdges(face); iEdge++) {
- if( F_edge(face,iEdge) == edge ) break ;
- }
- pEdge fEdges[3];
- fEdges[0] = edge ;
- fEdges[1] = F_edge(face,(iEdge+1)%3);
- fEdges[2] = F_edge(face,(iEdge+2)%3);
-
- pFace newF1, newF2;
- if( F_edgeDir(face,iEdge) ) {
-
- pEdge newFEdges1[3] = {e1, newE, fEdges[2]};
- newF1 = M_createF(mesh, 3, newFEdges1, fGE);
- EN_attachDataP((pEntity)fEdges[2],"_EdgeSplitMarker_",(void *)newF1);
-
- pEdge newFEdges2[3] = {e2, fEdges[1], newE};
- newF2 = M_createF(mesh, 3, newFEdges2, fGE);
- EN_attachDataP((pEntity)fEdges[1],"_EdgeSplitMarker_",(void *)newF2);
- }
- else {
- pEdge newFEdges1[3] = {e1, fEdges[1], newE};
- newF1 = M_createF(mesh, 3, newFEdges1, fGE);
- EN_attachDataP((pEntity)fEdges[1],"_EdgeSplitMarker_",(void *)newF1);
-
- pEdge newFEdges2[3] = {e2, newE, fEdges[2]};
- newF2 = M_createF(mesh, 3, newFEdges2, fGE);
- EN_attachDataP((pEntity)fEdges[2],"_EdgeSplitMarker_",(void *)newF2);
- }
- EN_attachDataP((pEntity)face,"_EdgeSplitMarker_",(void *)newE);
- EN_attachDataP((pEntity)newF1,"_EdgeSplitMarker_",face);
- EN_attachDataP((pEntity)newF2,"_EdgeSplitMarker_",face);
-
- PList_append(newFaces,newF1);
- PList_append(newFaces,newF2);
- }
-
- pPList delRegs = PList_new();
- pPList eRegs = E_regions(edge);
- if (eRegs) {
-
- temp = NULL;
- while( pRegion region = (pRegion)PList_next(eRegs, &temp) ) {
-
- pGEntity rGE = (pGEntity)R_whatIn(region);
-
- pFace extFaces[2];
-
- // --- build the new face between the two new regions ---
- pEdge fEdges[3];
- for(int iF=0, eCount=0, fCount=0; iF<R_numFaces(region); iF++) {
- pFace face = R_face(region,iF);
- if( F_inClosure(face,(pEntity)edge) ) {
- fEdges[eCount++] = (pEdge)EN_dataP((pEntity)face,"_EdgeSplitMarker_");
- }
- else {
- extFaces[fCount++] = face;
- }
- }
- pEdge oppE = R_gtOppEdg(region,edge);
- fEdges[2] = oppE;
- // if( E_vertex(fEdges[0],1) != E_vertex(fEdges[1],0) &&
- // E_vertex(fEdges[0],1) != E_vertex(fEdges[1],1) ) {
- // pEdge tmpE = fEdges[1] ;
- // fEdges[1] = fEdges[2];
- // fEdges[2] = tmpE;
- // }
- pFace newF = M_createF(mesh, 3, fEdges, rGE);
-
- // -- build the regions ---
- pFace rFaces[4];
-
- rFaces[0] = extFaces[0] ;
- rFaces[1] = newF;
- int fIndex = 2;
- for(int i=0; i<F_numEdges(extFaces[0]); i++) {
- pEdge tmpE = F_edge(extFaces[0],i);
- if( tmpE != oppE ) {
- rFaces[fIndex] = (pFace)EN_dataP((pEntity)tmpE,"_EdgeSplitMarker_");
- fIndex++;
- }
- }
- M_createR(mesh, 4, rFaces, rGE);
-
- rFaces[0] = extFaces[1] ;
- rFaces[1] = newF;
- fIndex = 2;
- for( int i=0; i < F_numEdges(extFaces[1]); i++ ) {
- pEdge tmpE = F_edge(extFaces[1],i);
- if( tmpE != oppE ) {
- rFaces[fIndex] = (pFace)EN_dataP((pEntity)tmpE,"_EdgeSplitMarker_");
- fIndex++;
- }
- }
- M_createR(mesh, 4, rFaces, rGE);
-
- PList_append(delRegs,region);
- }
- }
- PList_delete(eRegs);
-
- pPList delEdge = PList_new();
- PList_append(delEdge,edge);
- CallBackManagerSgl::instance().callCallBacks(delEdge, newEdges,
- MAd_ESPLIT, (pEntity)newV);
- PList_delete(delEdge);
- PList_delete(newEdges);
-
- // --- remove regions ---
- temp = NULL;
- while( pRegion region = (pRegion)PList_next(delRegs,&temp) ) {
- M_removeRegion(mesh, region);
- }
- PList_delete(delRegs);
-
- // --- remove and clean faces ---
- temp = NULL;
- while( pFace face = (pFace)PList_next(eFaces,&temp) ) {
-
- EN_removeData((pEntity)face,"_EdgeSplitMarker_");
-
- for(int iE=0; iE<F_numEdges(face); iE++) {
- pEdge iEdge = F_edge(face,iE);
- if( iEdge != edge ) EN_removeData((pEntity)iEdge,"_EdgeSplitMarker_");
- }
-
- M_removeFace(mesh, face);
- }
- PList_delete(eFaces);
-
- temp = NULL;
- while( pFace face = (pFace)PList_next(newFaces,&temp) ) {
- EN_removeData((pEntity)face,"_EdgeSplitMarker_");
- }
- PList_delete(newFaces);
-
- // --- remove edge ---
- M_removeEdge(mesh,edge);
-
- return newV ;
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/operator/OperatorTools.h b/Adapt/operator/OperatorTools.h
deleted file mode 100644
index 1167260..0000000
--- a/Adapt/operator/OperatorTools.h
+++ /dev/null
@@ -1,48 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_OPERATORTOOLS
-#define _H_OPERATORTOOLS
-
-#include "MSops.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
-
- bool V_setPosition(pVertex, double[3]);
-
- // --- Related to edge collapse ---
-
- void E_collapse(pMesh, // the mesh
- pEdge, // the edge to be collapsed
- pVertex, // the vertex to be deleted
- pVertex // the target vertex
- );
-
- void E_collapseOnGFace(pMesh, // the mesh
- pEdge, // the edge to be collapsed
- pVertex, // the vertex to be deleted
- pVertex // the target vertex
- );
-
- // --- Related to edge split ---
-
- pVertex E_split(pMesh, pEdge, double[3], double t=0.5);
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
-
diff --git a/Adapt/operator/RegionRemoveOp.cc b/Adapt/operator/RegionRemoveOp.cc
deleted file mode 100644
index d31503f..0000000
--- a/Adapt/operator/RegionRemoveOp.cc
+++ /dev/null
@@ -1,184 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "RegionRemoveOp.h"
-#include "CallBackManager.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- bool regionRemoveOp::checkConstraints() const
- {
- return true;
- }
-
- // -------------------------------------------------------------------
- bool regionRemoveOp::checkGeometry()
- {
- // deny if a vertex is classified on a geometrical edge or vertex
- int nbClassVerts = 0;
- pPList rVerts = R_vertices(region);
- void * temp = NULL;
- while ( pVertex vert = (pVertex) PList_next(rVerts,&temp) ) {
- if ( EN_whatInType((pEntity)vert) < 2 ) nbClassVerts++;
- }
- PList_delete(rVerts);
- if ( nbClassVerts != 0 ) return false;
-
- // deny if an edge is classified on a geometrical edge
- int nbClassEdges = 0;
- pPList rEdges = R_edges(region);
- void * temp2 = NULL;
- while ( pEdge edge = (pEdge) PList_next(rEdges,&temp2) ) {
- if ( EN_whatInType((pEntity)edge) < 2 ) nbClassEdges++;
- }
- PList_delete(rEdges);
- if ( nbClassEdges != 0 ) return false;
-
- int nbExternalFaces = 0;
- for (int iF=0; iF < 4; iF++) {
-
- pFace face = R_face(region,iF);
-
- // see which faces will be deleted
- if ( F_numRegions(face) == 1 ) {
- nbExternalFaces++;
- delFace[iF] = true;
- }
- else {
- delFace[iF] = false;
- }
-
- // see on which geometric entity the new
- // boundary faces will be classified
- pGEntity pGE = EN_whatIn((pEntity)face);
- if ( GEN_type(pGE) == 2 ) {
- classifyFaces = true;
- geoFace = pGE;
- }
- }
- // ensure not to create a hole in a volume
- if ( nbExternalFaces == 0 ) return false;
-
- return false;
- }
-
- // -------------------------------------------------------------------
- bool regionRemoveOp::evaluateShapes()
- {
- double worstShape = mqm.getElementEvaluator()->bestShapeEver();
- results->setWorstShape( worstShape );
- return true;
- }
-
- // -------------------------------------------------------------------
- void regionRemoveOp::evaluateLengths() const
- {
- results->setMinLenSq(1.);
- results->setMaxLenSq(1.);
- }
-
- // -------------------------------------------------------------------
- void regionRemoveOp::apply()
- {
- // --- classify faces ---
- if (classifyFaces) {
- for (int iF=0; iF < 4; iF++) {
- if ( delFace[iF] == false ) {
- pFace face = R_face(region,iF);
- F_setWhatIn(face,geoFace);
- }
- }
- }
-
- // --- list faces to delete ---
- pPList delF = PList_new();
- for (int iF=0; iF < 4; iF++) {
- if ( delFace[iF] == true ) PList_append(delF,R_face(region,iF));
- }
-
- // --- list edges to delete ---
- pPList delE = PList_new();
- pPList rEdges = R_edges(region);
- void * temp = NULL;
- while ( pEdge edge = (pEdge) PList_next(rEdges,&temp) ) {
- bool toDel = true;
- pPList eFaces = E_faces(edge);
- void * temp2 = NULL;
- while ( pFace face = (pFace) PList_next(eFaces,&temp2) ) {
- if ( !PList_inList(delF,face) ) { toDel = false; break; }
- }
- PList_delete(eFaces);
- if (toDel) PList_append(delE,edge);
- }
- PList_delete(rEdges);
-
- // --- list vertices to delete ---
- pPList delV = PList_new();
- pPList rVerts = R_vertices(region);
- void * temp3 = NULL;
- while ( pVertex vert = (pVertex) PList_next(rVerts,&temp3) ) {
- bool toDel = true;
- pPList vEdges = V_edges(vert);
- void * temp4 = NULL;
- while ( pEdge edge = (pEdge) PList_next(vEdges,&temp4) ) {
- if ( !PList_inList(delE,edge) ) { toDel = false; break; }
- }
- if (toDel) PList_append(delV,vert);
- }
- PList_delete(rVerts);
-
-
- // --- call callback functions ---
- pPList emptyList;
- pPList delEn = PList_new();
- void * delTmp = NULL;
- while ( pFace face = (pFace) PList_next(delF,&delTmp) ) PList_append(delEn,face);
- delTmp = NULL;
- while ( pEdge edge = (pEdge) PList_next(delE,&delTmp) ) PList_append(delEn,edge);
- delTmp = NULL;
- while ( pVertex vert = (pVertex) PList_next(delV,&delTmp) ) PList_append(delEn,vert);
- CallBackManagerSgl::instance().callCallBacks(delEn,
- emptyList,
- MAd_RREMOVE,
- region);
- PList_delete(delEn);
-
- // --- delete entities ---
-
- M_removeRegion(mesh,region);
-
- void * delTmp2 = NULL;
- while ( pFace face = (pFace) PList_next(delF,&delTmp2) ) {
- M_removeFace(mesh,face);
- }
-
- delTmp2 = NULL;
- while ( pEdge edge = (pEdge) PList_next(delE,&delTmp2) ) {
- M_removeEdge(mesh,edge);
- }
-
- delTmp2 = NULL;
- while ( pVertex vertex = (pVertex) PList_next(delV,&delTmp2) ) {
- M_removeVertex(mesh,vertex);
- }
-
- PList_delete(delF);
- PList_delete(delE);
- PList_delete(delV);
-
- HistorySgl::instance().add((int)type(),OPERATOR_APPLY,1);
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/operator/RegionRemoveOp.h b/Adapt/operator/RegionRemoveOp.h
deleted file mode 100644
index 48ba6af..0000000
--- a/Adapt/operator/RegionRemoveOp.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_REGIONREMOVEOP
-#define _H_REGIONREMOVEOP
-
-#include "MAdOperatorBase.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class regionRemoveOp: public MAdOperatorBase
- {
- public:
-
- regionRemoveOp(pMesh, DiscreteSF *);
- regionRemoveOp(const regionRemoveOp &);
- ~regionRemoveOp() {}
-
- operationType type() const { return MAd_RREMOVE; }
-
- void setRegion(pRegion);
-
- void getCavity(pPList *) const;
-
- void apply();
-
- private:
-
- bool checkConstraints() const;
- bool checkGeometry();
- bool evaluateShapes();
- void evaluateLengths() const;
-
- private:
-
- pRegion region;
-
- bool classifyFaces;
- pGEntity geoFace;
-
- bool delFace[4];
- };
-
- // -------------------------------------------------------------------
- inline regionRemoveOp::regionRemoveOp(const regionRemoveOp & _rr):
- MAdOperatorBase(_rr), region(_rr.region),
- classifyFaces(_rr.classifyFaces), geoFace(_rr.geoFace)
- {
- for (int i=0; i<4; i++) delFace[i] = _rr.delFace[i];
- }
-
- // -------------------------------------------------------------------
- inline regionRemoveOp::regionRemoveOp(pMesh _m, DiscreteSF * _sf):
- MAdOperatorBase(_m,_sf), region(NULL),
- classifyFaces(false), geoFace(NULL)
- {
- for (int i=0; i<4; i++) delFace[i] = false;
- }
-
- // -------------------------------------------------------------------
- inline void regionRemoveOp::setRegion(pRegion _region)
- {
- region = _region;
- }
-
- // -------------------------------------------------------------------
- inline void regionRemoveOp::getCavity(pPList * cavity) const
- {
- PList_append(*cavity,region);
- }
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/operator/SliverFaceHandler.cc b/Adapt/operator/SliverFaceHandler.cc
deleted file mode 100644
index 920c9a7..0000000
--- a/Adapt/operator/SliverFaceHandler.cc
+++ /dev/null
@@ -1,275 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "SliverFaceHandler.h"
-#include "EdgeSwapOp.h"
-#include "EdgeCollapseOp.h"
-#include "FaceCollapseOp.h"
-#include "MeshParametersManager.h"
-#include "MAdOutput.h"
-
-// standard C/C++
-#include <set>
-using std::set;
-#include <sstream>
-using std::stringstream;
-using std::string;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void sliverFaceHandler::removeSliverFaces(int* nbSliverIn, int* nbSliverOut)
- {
- // --- list all slivers ---
-
- set<pFace> slivers;
- if (nbSliverIn) (*nbSliverIn) = 0;
- FIter fIter = M_faceIter(mesh);
- while( pFace face = FIter_next(fIter) ) {
- if ( F_isSliver(face) ) {
- slivers.insert(face);
- if (nbSliverIn) (*nbSliverIn)++;
- }
- }
- FIter_delete(fIter);
-
- // --- iterate on slivers elimination attempts ---
-
- int iter = 0;
- int maxIter = 5;
- bool eliminated = true;
- *nbSliverOut = *nbSliverIn;
- while ( ( eliminated ) &&
- ( *nbSliverOut > 0 ) &&
- ( iter < maxIter ) ) {
-
- eliminated = false;
-
- set<pFace> oldSlivers;
-
- // --- process the slivers list ---
- set<pFace>::iterator sIter = slivers.begin();
- set<pFace>::iterator sLast = slivers.end();
- for (; sIter != sLast; sIter++) {
-
- pFace sliver = *sIter;
-
- // --- check if the sliver still exists ---
- if ( oldSlivers.find(sliver) != oldSlivers.end() ) continue;
-
- // --- check if the sliver is still a sliver ---
- if ( !F_isSliver(sliver) ) {
- oldSlivers.insert(sliver);
- continue;
- }
-
- // --- find an appropriate modification ---
- pMAdOperator modif = NULL;
- int result = findOperation(sliver,&modif);
-
- if ( result <= 0 && reportFailures ) reportSliver(sliver);
-
- if ( result >= 1 && modif ) {
-
- // --- prepare to remove deleted faces from sliver list ---
- pPList cavity;
- modif->getCavity(&cavity);
- void * tmp = 0;
- while( pFace pf = (pFace)PList_next(cavity,&tmp) ) {
- oldSlivers.insert(pf);
- }
- PList_delete(cavity);
-
- // --- eliminate the sliver ---
- modif->apply();
- eliminated = true;
- oldSlivers.insert(sliver);
- }
-
- if (modif) delete modif;
- }
-
- // --- count remaining and list slivers ---
- slivers.clear();
- if (nbSliverOut) (*nbSliverOut) = 0;
- fIter = M_faceIter(mesh);
- while( pFace face = FIter_next(fIter) ) {
- if ( F_isSliver(face) ) {
- slivers.insert(face);
- if (nbSliverOut) (*nbSliverOut)++;
- }
- }
- FIter_delete(fIter);
-
- iter++;
- }
- }
-
- // -------------------------------------------------------------------
- // Try to find a modification that eliminates the sliver triangle.
- // Return:
- // 0: no modification found
- // 1: a modification is found but with a resulting sliver (with better shape)
- // 2: a modification is found with no remaining sliver
- int sliverFaceHandler::findOperation(pFace face,
- pMAdOperator* modification)
- {
- MeshParametersManager& mpm = MeshParametersManagerSgl::instance();
-
- *modification = NULL;
-
- double bestShape = 0.;
- mqm.getShape(face,0,&bestShape);
-
- if ( bestShape >= mpm.getSliverTriBound() ) {
- printf ("Warning: processing a face which is not a sliver in findOperation\n");
- return 0;
- }
-
- // check edge swaps
- // -----------------
-
- edgeSwapOp eSwap(mesh,sizeField);
-// if( collapseOnBdry ) eSwap.setCheckVolume(0.,dATol);
-
- for (int i=0; i<3; i++) {
-
- eSwap.setSwapEdge(F_edge(face,i));
-
- double worst;
- if ( eSwap.evaluate(&worst) && worst > bestShape ) {
- bestShape = worst;
- if (*modification) delete *modification;
- *modification = new edgeSwapOp(eSwap);
- if (bestShape > mpm.getSliverTriBound()) return 2;
- }
- }
-
- // check edge collapses
- // ---------------------
-
- edgeCollapseOp eCollapse(mesh,sizeField);
- eCollapse.collapseOnBoundary(collapseOnBdry,dATol);
-
- for(int i=0; i<3; i++) {
-
- pEdge edge = F_edge(face,i);
-
- for (int j=0; j<2; j++) {
-
- eCollapse.setCollapseEdge(edge,E_vertex(edge,j),E_vertex(edge,(j+1)%2));
-
- double worst;
- if (eCollapse.evaluate(&worst) && worst > bestShape ) {
- bestShape = worst;
- if (*modification) delete *modification;
- *modification = new edgeCollapseOp(eCollapse);
- if (bestShape > mpm.getSliverTriBound()) return 2;
- // if (bestShape > mpm.getSliverTriBound()) { printf("Applied edge collapse\n"); return 2;}
- }
- }
- }
-
- // check face collapse
- // --------------------
-
- if ( addNodes )
- {
- faceCollapseOp fCollapse(mesh,sizeField);
- fCollapse.collapseOnBoundary(collapseOnBdry,dATol);
-
- for(int iE=0; iE<3; iE++) {
-
- pEdge edge = F_edge(face,iE);
-
- for (int iDir=0; iDir<2; iDir++) {
-
- fCollapse.reset(face,edge,(bool)iDir);
-
- double worst;
- if (fCollapse.evaluate(&worst) && worst > bestShape ) {
- bestShape = worst;
- if (*modification) delete *modification;
- *modification = new faceCollapseOp(fCollapse);
- if (bestShape > mpm.getSliverTriBound()) return 2;
- // if (bestShape > mpm.getSliverTriBound()) { printf("Applied face collapse\n"); return 2;}
- }
- }
- }
- }
-
- if( *modification ) return 1;
-
- return 0;
- }
-
- // -------------------------------------------------------------------
- bool sliverFaceHandler::F_isSliver(pFace face)
- {
- MeshParametersManager& mpm = MeshParametersManagerSgl::instance();
-
- double shape;
- mqm.getShape(face,0,&shape);
-
- if( shape < mpm.getSliverTriBound() )
- return true;
-
- return false;
- }
-
- // -------------------------------------------------------------------
- bool sliverFaceHandler::F_isSliver(pFace face, double * shape)
- {
- MeshParametersManager& mpm = MeshParametersManagerSgl::instance();
-
- mqm.getShape(face,0,shape);
-
- if( *shape < mpm.getSliverTriBound() )
- return true;
-
- return false;
- }
-
- // -------------------------------------------------------------------
- void sliverFaceHandler::reportSliver(pFace face)
- {
- stringstream ss;
- string idStr; ss << reportId; ss >> idStr;
-
- string name = reportPrefix + "sliver" + idStr + ".pos";
-
- pPList cavity = PList_new();
-
- PList_append(cavity,face);
-
- for (int iV=0; iV<F_numVertices(face); iV++) {
-
- pVertex vertex = F_vertex(face, iV);
-
- pPList vFaces = V_faces(vertex);
- void * temp = 0;
- while ( pFace pf = (pFace)PList_next(vFaces,&temp) ) {
- PList_appUnique(cavity,pf);
- }
- PList_delete(vFaces);
- }
-
- printPosEntities(cavity,name.c_str(),OD_MEANRATIO,sizeField);
-
- PList_delete(cavity);
-
- reportId++;
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/operator/SliverFaceHandler.h b/Adapt/operator/SliverFaceHandler.h
deleted file mode 100644
index 53287a0..0000000
--- a/Adapt/operator/SliverFaceHandler.h
+++ /dev/null
@@ -1,111 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_SLIVERFACEHANDLER
-#define _H_SLIVERFACEHANDLER
-
-#include "MAdOperatorBase.h"
-
-#include <string>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class sliverFaceHandler {
-
- public:
-
- sliverFaceHandler(pMesh, DiscreteSF *);
- ~sliverFaceHandler() {}
-
- public:
-
- void removeSliverFaces(int * nbIn=NULL, int * nbOut=NULL);
-
- void setSizeField(DiscreteSF *);
-
- // whether we can use operations on boundaries
- void collapseOnBoundary(bool, double);
-
- // whether we can use operations that add nodes
- void newVertexPermission(bool);
- bool getNewVertexPermission() const { return addNodes; }
-
- void enableReport(std::string);
-
- private:
-
- int findOperation(pFace, pMAdOperator *);
-
- bool F_isSliver(pFace);
- bool F_isSliver(pFace, double *);
-
- void reportSliver(pFace);
-
- private:
-
- pMesh mesh;
- DiscreteSF * sizeField;
- MeshQualityManager& mqm;
-
- bool collapseOnBdry;
- double dATol;
-
- bool addNodes; // whether or not we can use operators that add nodes
- // (edge split)
-
- bool reportFailures;
- int reportId;
- std::string reportPrefix;
-
- };
-
- // -------------------------------------------------------------------
- inline sliverFaceHandler::sliverFaceHandler(pMesh m, DiscreteSF * sf):
- mesh(m),sizeField(sf), mqm(MeshQualityManagerSgl::instance()),
- collapseOnBdry(false), dATol(MAdTOL), addNodes(true),
- reportFailures(false),reportId(0),reportPrefix("")
- {}
-
- // -------------------------------------------------------------------
- inline void sliverFaceHandler::setSizeField(DiscreteSF * sf)
- {
- sizeField = sf;
- }
-
- // -------------------------------------------------------------------
- inline void sliverFaceHandler::collapseOnBoundary(bool cob, double tolerance)
- {
- collapseOnBdry = cob;
- dATol = tolerance;
- }
-
- // -------------------------------------------------------------------
- inline void sliverFaceHandler::newVertexPermission(bool allow)
- {
- addNodes = allow;
- }
-
- // -------------------------------------------------------------------
- inline void sliverFaceHandler::enableReport(std::string prefix)
- {
- reportFailures = true;
- reportPrefix = prefix;
- }
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
-
diff --git a/Adapt/operator/SliverRegionHandler.cc b/Adapt/operator/SliverRegionHandler.cc
deleted file mode 100644
index 17138e8..0000000
--- a/Adapt/operator/SliverRegionHandler.cc
+++ /dev/null
@@ -1,1265 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "SliverRegionHandler.h"
-#include "EdgeSplitOp.h"
-#include "EdgeCollapseOp.h"
-#include "FaceCollapseOp.h"
-#include "DESCOp.h"
-#include "EdgeSwapOp.h"
-#include "FaceSwapOp.h"
-#include "VertexMoveOp.h"
-#include "MeshParametersManager.h"
-#include "MAdOutput.h"
-#include "MathUtils.h"
-
-#include <sstream>
-using std::stringstream;
-using std::set;
-using std::ostream;
-using std::string;
-using std::endl;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void sliverRegionHandler::removeSliverRegions(int* nbSliverIn, int* nbSliverOut)
- {
- // --- list all slivers ---
-
- set<pRegion> slivers;
- if (nbSliverIn) (*nbSliverIn) = 0;
- RIter rIter = M_regionIter(mesh);
- while( pRegion region = RIter_next(rIter) ) {
- if ( R_isSliver(region) ) {
- slivers.insert(region);
- if (nbSliverIn) (*nbSliverIn)++;
- }
- }
- RIter_delete(rIter);
-
- // --- iterate on slivers elimination attempts ---
-
- int iter = 0;
- int maxIter = 5;
- bool eliminated = true;
- *nbSliverOut = *nbSliverIn;
- while ( ( eliminated ) &&
- ( *nbSliverOut > 0 ) &&
- ( iter < maxIter ) ) {
-
- eliminated = false;
-
- set<pRegion> oldSlivers;
-
- // --- process the slivers list ---
- set<pRegion>::iterator sIter = slivers.begin();
- set<pRegion>::iterator sLast = slivers.end();
- for (; sIter != sLast; sIter++) {
-
- pRegion sliver = *sIter;
-
- // --- check if the sliver still exists ---
- if ( oldSlivers.find(sliver) != oldSlivers.end() ) continue;
-
- // --- check if the sliver is still a sliver ---
- if ( !R_isSliver(sliver) ) {
- oldSlivers.insert(sliver);
- continue;
- }
-
- // --- find an appropriate modification ---
- pMAdOperator modif = NULL;
- int result = findOperation(sliver,&modif);
-
- if ( testOperators ) testOperations(sliver);
-
- if ( result <= 0 && reportFailures ) reportSliver(sliver);
-
- if ( result >= 1 ) {
-
- assert(modif);
-
- // --- prepare to remove deleted regions from sliver list ---
- pPList affReg;
- modif->getCavity(&affReg);
- void * tmp = 0;
- while( pRegion pr = (pRegion)PList_next(affReg,&tmp) ) {
- oldSlivers.insert(pr);
- }
- PList_delete(affReg);
-
- // --- eliminate the sliver ---
- modif->apply();
- eliminated = true;
- oldSlivers.insert(sliver);
- }
-
- if (modif) delete modif;
- }
-
- // --- count remaining and list slivers ---
- slivers.clear();
- if (nbSliverOut) (*nbSliverOut) = 0;
- rIter = M_regionIter(mesh);
- while( pRegion region = RIter_next(rIter) ) {
- if ( R_isSliver(region) ) {
- slivers.insert(region);
- if (nbSliverOut) (*nbSliverOut)++;
- }
- }
- RIter_delete(rIter);
-
- iter++;
- }
- }
-
- // -------------------------------------------------------------------
- // Try to find an operation that eliminates the sliver.
- // Returns:
- // 0: no modification found
- // 1: a modification is found but with a resulting sliver (with better shape)
- // 2: a modification is found with no remaining sliver
- int sliverRegionHandler::findOperation(pRegion region,
- pMAdOperator* operation)
- {
- MeshParametersManager& mpm = MeshParametersManagerSgl::instance();
-
- *operation = NULL;
-
- double bestShape = 0.;
- mqm.getShape(region,&bestShape);
-
- if ( bestShape >= mpm.getSliverTetBound() ) {
- printf ("Warning: processing a tet which is not a sliver in handleSliverTet\n");
- return 0;
- }
-
- edgeCollapseOp eCollOp (mesh,sizeField);
- eCollOp.collapseOnBoundary(collapseOnBdry,dVTolClps);
-
- faceCollapseOp fCollOp (mesh,sizeField);
- fCollOp.collapseOnBoundary(collapseOnBdry,dVTolClps);
-
- edgeSwapOp eSwapOp (mesh,sizeField);
- eSwapOp.swapOnBoundary(swapOnBdry,dVTolSwap);
-
- DESCOp descOp (mesh,sizeField);
- edgeSplitOp eSplitOp(mesh,sizeField);
- faceSwapOp fSwapOp (mesh,sizeField);
- vertexMoveOp vMoveOp (mesh,sizeField,false);
-
- pEntity keyEnts[4];
- int sType = getSliverType(region, keyEnts);
- if( sType == 0 ) return 0;
-
- double worst;
-
- // --- TYPE I slivers ---
- if( sType == 1 )
- {
-#ifdef MAKESTATS
- numTypeI_In++;
-#endif
-
- // check split
- // ------------
- if ( addNodes ) {
- for(int i=0; i<2; i++) {
-#ifdef MAKESTATS
- numSplitTested_I++;
-#endif
- eSplitOp.setSplitEdge((pEdge)keyEnts[i]);
-
- if( E_whatInType((pEdge)keyEnts[i]) != 3 ) continue;
-
- // determine the position of the new vertex
-// double newPos[3];
-// E_cavityCenter( (pEdge)keyEnts[i], newPos );
-// double t = E_linearParams((pEdge)keyEnts[i],newPos);
-// if( t>1. || t<0. ) continue;
-// eSplitOp.setSplitPos(newPos);
-
- worst = -1.;
- if( eSplitOp.evaluate(&worst) && worst > bestShape &&
- eSplitOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- eSplitOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- bestShape = worst;
- if(*operation) delete *operation;
- *operation = new edgeSplitOp(eSplitOp);
-#ifdef MAKESTATS
- numSplitAvailable_I++;
- if (bestShape < mpm.getSliverTetBound()) numSplitToSliver_I++;
-#endif
- if (bestShape > mpm.getSliverTetBound()) break;
- }
- }
- if( *operation && bestShape > mpm.getSliverTetBound() ) {
-#ifdef MAKESTATS
- numSplitOperated_I++;
-#endif
- return 2;
- }
- }
-
- // check edge collapses
- // ---------------------
- for(int i=0; i<6; i++) {
- pEdge edge = R_edge(region,i);
- for (int j=0; j<2; j++) {
-#ifdef MAKESTATS
- numEClpsTested_I++;
-#endif
- eCollOp.setCollapseEdge(edge,E_vertex(edge,j),E_vertex(edge,1-j));
-
- worst = -1.;
- if ( eCollOp.evaluate(&worst) && worst > bestShape &&
- eCollOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- eCollOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- bestShape = worst;
- if (*operation) delete *operation;
- *operation = new edgeCollapseOp(eCollOp);
-#ifdef MAKESTATS
- numEClpsAvailable_I++;
- if (worst < mpm.getSliverTetBound()) numEClpsToSliver_I++;
-#endif
- if (bestShape > mpm.getSliverTetBound()) break;
- }
- }
- if (bestShape > mpm.getSliverTetBound()) break;
- }
- if( *operation && bestShape > mpm.getSliverTetBound() ) {
-#ifdef MAKESTATS
- numEClpsOperated_I++;
-#endif
- return 2;
- }
-
- // check double edge split collapse
- // ---------------------------------
- if ( addNodes ) {
- for(int i=0; i<2; i++) {
-#ifdef MAKESTATS
- numDESCTested_I++;
-#endif
- descOp.setDESC(region,(pEdge)keyEnts[i%2],(pEdge)keyEnts[(i+1)%2]);
-
- worst = -1.;
- if( descOp.evaluate(&worst) && worst > bestShape &&
- descOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- descOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- bestShape = worst;
- if(*operation) delete *operation;
- *operation = new DESCOp(descOp);
-#ifdef MAKESTATS
- numDESCAvailable_I++;
- if (worst < mpm.getSliverTetBound()) numDESCToSliver_I++;
-#endif
- }
- if( *operation && bestShape > mpm.getSliverTetBound() ) {
-#ifdef MAKESTATS
- numDESCOperated_I++;
-#endif
- return 2;
- }
- }
- }
-
- // check face collapse
- // --------------------
- if ( addNodes ) {
- for(int i=0; i<2; i++) {
- for( int ClpsOnvt=1; ClpsOnvt>=0; ClpsOnvt-- ) {
-#ifdef MAKESTATS
- numFClpsTested_I++;
-#endif
- fCollOp.reset((pFace)keyEnts[i+2],(pEdge)keyEnts[i], ClpsOnvt);
-
- worst = -1.;
- if( fCollOp.evaluate(&worst) && worst > bestShape &&
- fCollOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- fCollOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- bestShape = worst;
- if (*operation) delete *operation;
- *operation = new faceCollapseOp(fCollOp);
-#ifdef MAKESTATS
- numFClpsAvailable_I++;
- if (worst < mpm.getSliverTetBound()) {
- numFClpsToSliver_I++;
- }
-#endif
- if( *operation && bestShape > mpm.getSliverTetBound() ) {
-#ifdef MAKESTATS
- numFClpsOperated_I++;
-#endif
- return 2;
- }
- }
- }
- }
- }
-
- // check edge swaps
- // -----------------
- for(int i=0; i<2; i++) {
-#ifdef MAKESTATS
- numSwapTested_I++;
-#endif
- eSwapOp.setSwapEdge((pEdge)keyEnts[i]);
-
- worst = -1.;
- if( eSwapOp.evaluate(&worst) && worst > bestShape &&
- eSwapOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- eSwapOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- bestShape = worst;
- if (*operation) delete *operation;
- *operation = new edgeSwapOp(eSwapOp);
-#ifdef MAKESTATS
- numSwapAvailable_I++;
- if (worst < mpm.getSliverTetBound()) numSwapToSliver_I++;
-#endif
- if (bestShape > mpm.getSliverTetBound()) break;
- }
- }
- if( *operation && bestShape > mpm.getSliverTetBound() ) {
-#ifdef MAKESTATS
- numSwapOperated_I++;
-#endif
- return 2;
- }
-
- // check vertex move
- // ------------------
- pPList verts = R_vertices(region);
- void * temp = NULL;
- while ( pVertex pv = (pVertex)PList_next(verts,&temp) ) {
-#ifdef MAKESTATS
- numVMoveTested_I++;
-#endif
- if( V_whatInType(pv) != 3 ) continue;
-
- vMoveOp.setPositionToOptimal(pv);
-
- worst = -1.;
- if( vMoveOp.evaluate(&worst) && worst > bestShape &&
- vMoveOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- vMoveOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- bestShape = worst;
- if(*operation) delete *operation;
- *operation = new vertexMoveOp(vMoveOp);
-#ifdef MAKESTATS
- numVMoveAvailable_I++;
- if (bestShape < mpm.getSliverTetBound()) numVMoveToSliver_I++;
-#endif
- }
- }
- PList_delete(verts);
- if( *operation && bestShape > mpm.getSliverTetBound() ) {
-#ifdef MAKESTATS
- numVMoveOperated_I++;
-#endif
- return 2;
- }
-
-
-#ifdef MAKESTATS
- if( *operation ) {
- switch ((*operation)->type()) {
- case MAd_ECOLLAPSE: { numEClpsOperated_I++; break; }
- case MAd_ESWAP: { numSwapOperated_I++; break; }
- case MAd_FCOLLAPSE: { numFClpsOperated_I++; break; }
- case MAd_DESPLTCLPS: { numDESCOperated_I++; break; }
- case MAd_ESPLIT: { numSplitOperated_I++; break; }
- case MAd_VERTEXMOVE: { numVMoveOperated_I++; break; }
- default: throw;
- }
- }
-#endif
-
- if( *operation ) return 1;
-
-#ifdef MAKESTATS
- set<pRegion>::const_iterator sIter = sliversOut.find(region);
- if (sIter == sliversOut.end() ) {
- sliversOut.insert(region);
- numTypeI_Out++;
- }
-#endif
- }
-
- // --- TYPE II slivers ---
- else
- {
-#ifdef MAKESTATS
- numTypeII_In++;
-#endif
-
- // check edge collapses
- // ---------------------
- for(int i=0; i<6; i++) {
-#ifdef MAKESTATS
- numEClpsTested_II++;
-#endif
- pEdge edge = R_edge(region,i);
- for (int j=0; j<2; j++) {
- eCollOp.setCollapseEdge(edge,E_vertex(edge,j),E_vertex(edge,(j+1)%2));
-
- worst = -1.;
- if( eCollOp.evaluate(&worst) && worst > bestShape &&
- eCollOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- eCollOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- bestShape = worst;
- if (*operation) delete *operation;
- *operation = new edgeCollapseOp(eCollOp);
-#ifdef MAKESTATS
- numEClpsAvailable_II++;
- if (worst < mpm.getSliverTetBound()) numEClpsToSliver_II++;
-#endif
- if (bestShape > mpm.getSliverTetBound()) break;
- }
- }
- if (bestShape > mpm.getSliverTetBound()) break;
- }
- if( *operation && bestShape > mpm.getSliverTetBound() ) {
-#ifdef MAKESTATS
- numEClpsOperated_II++;
-#endif
- return 2;
- }
-
- // check face collapse
- // --------------------
- if ( addNodes ) {
- for( int ClpsOnvt=1; ClpsOnvt>=0; ClpsOnvt-- ) {
-#ifdef MAKESTATS
- numFClpsTested_II++;
-#endif
- fCollOp.reset((pFace)keyEnts[2],(pEdge)keyEnts[1], ClpsOnvt);
-
- worst = -1.;
- if( fCollOp.evaluate(&worst) && worst > bestShape &&
- fCollOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- fCollOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- bestShape = worst;
- if (*operation) delete *operation;
- *operation = new faceCollapseOp(fCollOp);
-#ifdef MAKESTATS
- numFClpsAvailable_II++;
- if (bestShape < mpm.getSliverTetBound()) numFClpsToSliver_II++;
-#endif
- }
- if( *operation && bestShape > mpm.getSliverTetBound() ) {
-#ifdef MAKESTATS
- numFClpsOperated_II++;
-#endif
- return 2;
- }
- }
- }
-
- // check edge swaps
- // -----------------
- for(int i=0; i<3; i++) {
-#ifdef MAKESTATS
- numSwapTested_II++;
-#endif
- pEdge edge = F_edge((pFace)keyEnts[0],i);
- eSwapOp.setSwapEdge(edge);
-
- worst=-1.;
- if( eSwapOp.evaluate(&worst) && worst > bestShape &&
- eSwapOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- eSwapOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- bestShape = worst;
- if (*operation) delete *operation;
- *operation = new edgeSwapOp(eSwapOp);
-#ifdef MAKESTATS
- numSwapAvailable_II++;
- if (worst < mpm.getSliverTetBound()) numSwapToSliver_II++;
-#endif
- if (bestShape > mpm.getSliverTetBound()) break;
- }
- }
- if( *operation && bestShape > mpm.getSliverTetBound() ) {
-#ifdef MAKESTATS
- numSwapOperated_II++;
-#endif
- return 2;
- }
-
- // check face swap on the key face
- // --------------------------------
-#ifdef MAKESTATS
- numFSwapTested_II++;
-#endif
- fSwapOp.setSwapFace((pFace)keyEnts[0]);
-
- worst = -1.;
- if( fSwapOp.evaluate(&worst) && worst > bestShape &&
- fSwapOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- fSwapOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- bestShape = worst;
- if(*operation) delete *operation;
- *operation = new faceSwapOp(fSwapOp);
-#ifdef MAKESTATS
- numFSwapAvailable_II++;
- if (bestShape < mpm.getSliverTetBound()) numFSwapToSliver_II++;
-#endif
- }
- if( *operation && bestShape > mpm.getSliverTetBound() ) {
-#ifdef MAKESTATS
- numFSwapOperated_II++;
-#endif
- return 2;
- }
-
- // check vertex move
- // ------------------
- pPList verts = R_vertices(region);
- void * temp = NULL;
- while ( pVertex pv = (pVertex)PList_next(verts,&temp) ) {
-#ifdef MAKESTATS
- numVMoveTested_II++;
-#endif
- if( V_whatInType(pv) != 3 ) continue;
-
- vMoveOp.setPositionToOptimal(pv);
-
- worst = -1.;
- if( vMoveOp.evaluate(&worst) && worst > bestShape &&
- vMoveOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- vMoveOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- bestShape = worst;
- if(*operation) delete *operation;
- *operation = new vertexMoveOp(vMoveOp);
-#ifdef MAKESTATS
- numVMoveAvailable_II++;
- if (bestShape < mpm.getSliverTetBound()) numVMoveToSliver_II++;
-#endif
- }
- }
- PList_delete(verts);
- if( *operation && bestShape > mpm.getSliverTetBound() ) {
-#ifdef MAKESTATS
- numVMoveOperated_II++;
-#endif
- return 2;
- }
-
-#ifdef MAKESTATS
- if( *operation ) {
- switch ((*operation)->type()) {
- case MAd_ECOLLAPSE: { numEClpsOperated_II++; break; }
- case MAd_ESWAP: { numSwapOperated_II++; break; }
- case MAd_FSWAP: { numFSwapOperated_II++; break; }
- case MAd_FCOLLAPSE: { numFClpsOperated_II++; break; }
- case MAd_VERTEXMOVE: { numVMoveOperated_II++; break; }
- default: throw;
- }
- }
-#endif
-
- if( *operation ) return 1;
-
-#ifdef MAKESTATS
- set<pRegion>::const_iterator sIter = sliversOut.find(region);
- if (sIter == sliversOut.end() ) {
- sliversOut.insert(region);
- numTypeII_Out++;
- }
-#endif
- }
-
- return 0;
- }
-
- // -------------------------------------------------------------------
- bool sliverRegionHandler::R_isSliver(pRegion region, double* shape)
- {
- MeshParametersManager& mpm = MeshParametersManagerSgl::instance();
-
- mqm.getShape(region,shape);
-
- if( *shape < mpm.getSliverTetBound() ) return true;
- return false;
- }
-
- // -------------------------------------------------------------------
- bool sliverRegionHandler::R_isSliver(pRegion region)
- {
- MeshParametersManager& mpm = MeshParametersManagerSgl::instance();
-
- double shape;
- mqm.getShape(region,&shape);
-
- if( shape < mpm.getSliverTetBound() ) return true;
- return false;
- }
-
- // -------------------------------------------------------------------
- // Gets the type of sliver and the related key entities.
- // Returns 0 : failure
- // 1 : type I
- // 2 : type II
- int sliverRegionHandler::getSliverType(const pRegion region,
- pEntity keyEnts[4])
- {
- pFace base = R_face(region,0);
- pVertex oppV = R_fcOpVt(region,base);
-
- pEdge edges[6]; // the three ordered edges of the tet with base to be base
- pVertex verts[3]; // the three ordered vertices of the face
- double fxyz[3][3]; // coordinates of the three vertices of the face
- double pxyz[3]; // coordinates of the opposite vertex
- pFace faces[4]; // ordered faces of the tet
- double area[4]; // areas of the faces
-
- for(int i=0; i<3; i++) {
- edges[i] = F_edge(base,i);
- if(F_edgeDir(base,i)) verts[i] = E_vertex(edges[i],0);
- else verts[i] = E_vertex(edges[i],1);
- V_coord(verts[i],fxyz[i]);
- }
-
- faces[0] = base;
- for(int i=0; i<4; i++) {
- pFace face = R_face(region,i);
- if( face == base ) continue;
- if( F_inClosure(face,(pEntity)edges[0]) ) { faces[1]=face; continue; }
- if( F_inClosure(face,(pEntity)edges[1]) ) { faces[2]=face; continue; }
- if( F_inClosure(face,(pEntity)edges[2]) ) faces[3]=face;
- }
-
- for(int i=1; i<3; i++) {
- for(int j=0; j<3; j++) {
- pEdge edge = F_edge(faces[i],j);
- if( edge == edges[i-1] ) continue;
- if( E_inClosure(edge,(pEntity)verts[0]) ) { edges[3]=edge; continue; }
- if( E_inClosure(edge,(pEntity)verts[1]) ) { edges[4]=edge; continue; }
- if( E_inClosure(edge,(pEntity)verts[2]) ) edges[5]=edge;
- }
- }
-
- // project oppV onto base
- double temp[3];
- V_coord(oppV,pxyz);
- pointToPlane(fxyz,pxyz,temp);
- pxyz[0] = temp[0];
- pxyz[1] = temp[1];
- pxyz[2] = temp[2];
-
- // find if the projection coincides with any of the 3 points
- for(int i=0; i<3; i++) {
- if( distanceSq(pxyz,fxyz[i]) < MAdTOL ) {
-// printf("Info: project onto a vertex\n");
- return 0;
- }
- }
-
- // find normal to the plane
- double v01[3], v02[3], norm[3];
- diffVec(fxyz[1],fxyz[0],v01);
- diffVec(fxyz[2],fxyz[0],v02);
- crossProd(v01,v02,norm);
-
- double ri[3], rj[3], rk[3];
- diffVec(pxyz,fxyz[0],ri);
- diffVec(pxyz,fxyz[1],rj);
- diffVec(pxyz,fxyz[2],rk);
-
- // determine which side of the edges does the point R lie.
- // First get normal vectors
- double normi[3], normj[3], normk[3];
- crossProd(v01,ri,normi);
- diffVec(fxyz[2],fxyz[1],temp);
- crossProd(temp,rj,normj);
- diffVec(fxyz[0],fxyz[2],temp);
- crossProd(temp,rk,normk);
-
- double mag[3];
- mag[0] = dotProd(normi,norm);
- mag[1] = dotProd(normj,norm);
- mag[2] = dotProd(normk,norm);
-
- area[0] = dotProd(norm,norm);
- area[1] = dotProd(normi,normi);
- area[2] = dotProd(normj,normj);
- area[3] = dotProd(normk,normk);
-
- int filter[] = {1,2,4};
- int bit=0;
- for(int i=0; i<3; i++){
- if( mag[i] > 0. ) {
- bit = bit | filter[i];
- }
- }
-
- // 010=2 | 011=3 / 001=1
- // | /
- // ------------+--e2--+-----------
- // v0| /v2
- // | 7 /
- // 110=6 e0 e1
- // | /
- // | / 101=5
- // |/
- // v1+
- // /|
- // / |
- // 4
-
-
- // determine the key entities
- switch( bit ) {
- case 1:{
- int Emap[] = {0,4,3};
- int Fmap[] = {0,2,3};
- keyEnts[0] = (pEntity)faces[1];
- int index = indexOfMin(area[0],area[2],area[3]);
- keyEnts[1] = (pEntity)edges[Emap[index]];
- keyEnts[2] = (pEntity)faces[Fmap[index]];
- break;
- }
- case 2: {
- int Emap[] = {1,4,5};
- int Fmap[] = {0,1,3};
- keyEnts[0] = (pEntity)faces[2];
- int index = indexOfMin(area[0],area[1],area[3]);
- keyEnts[1] = (pEntity)edges[Emap[index]];
- keyEnts[2] = (pEntity)faces[Fmap[index]];
- break;
- }
- case 3: {
- keyEnts[0] = (pEntity)edges[2];
- keyEnts[1] = (pEntity)edges[4];
- keyEnts[2] = (pEntity)( (area[0]<area[3]) ? faces[0]:faces[3] );
- keyEnts[3] = (pEntity)( (area[1]<area[2]) ? faces[1]:faces[2] );
- break;
- }
- case 4: {
- int Emap[] = {2,3,5};
- int Fmap[] = {0,1,2};
- keyEnts[0] = (pEntity)faces[3];
- int index = indexOfMin(area[0],area[1],area[2]);
- keyEnts[1] = (pEntity)edges[Emap[index]];
- keyEnts[2] = (pEntity)faces[Fmap[index]];
- break;
- }
- case 5: {
- keyEnts[0] = (pEntity)edges[1];
- keyEnts[1] = (pEntity)edges[3];
- keyEnts[2] = (pEntity)( (area[0]<area[2]) ? faces[0]:faces[2] );
- keyEnts[3] = (pEntity)( (area[1]<area[3]) ? faces[1]:faces[3] );
- break;
- }
- case 6: {
- keyEnts[0] = (pEntity)edges[0];
- keyEnts[1] = (pEntity)edges[5];
- keyEnts[2] = (pEntity)( (area[0]<area[1]) ? faces[0]:faces[1] );
- keyEnts[3] = (pEntity)( (area[2]<area[3]) ? faces[2]:faces[3] );
- break;
- }
- case 7: {
- int Emap[] = {0,1,2};
- int Fmap[] = {1,2,3};
- keyEnts[0] = (pEntity)faces[0];
- int index = indexOfMin(area[1],area[2],area[3]);
- keyEnts[1] = (pEntity)edges[Emap[index]];
- keyEnts[2] = (pEntity)faces[Fmap[index]];
- break;
- }
- default:
- printf("Error in getSliverType: not a valid value %d\n",bit);
- throw;
- }
-
- if ( bit==0 ) return 0;
- if ( bit==3 || bit==5 || bit==6 ) return 1;
- return 2;
- }
-
- // -------------------------------------------------------------------
- void sliverRegionHandler::printStats(ostream& out) const {
-
-#ifdef MAKESTATS
- out << "\n*** Statistics about the sliverRegionHandler ***\n\n";
- out << "Slivers considered: " << numTypeI_In+numTypeII_In<<endl;
- out << " - Type I: \t"<< numTypeI_In << " ( " << numTypeI_Out << " not resolved )\n";
- out << " - Type II:\t"<< numTypeII_In << " ( " << numTypeII_Out << " not resolved )\n\n";
-
- out << " \n--- Type I slivers ---\n\n";
- out << "\t nbTestedOp\t nbAvailableOp \t nbOperated \t nbLeadToASliver\n";
- out << "ESplit:\t\t"<<numSplitTested_I << "\t\t" << numSplitAvailable_I<< "\t\t" << numSplitOperated_I<< "\t\t" <<numSplitToSliver_I << "\n";
- out << "EClps:\t\t"<< numEClpsTested_I << "\t\t" << numEClpsAvailable_I << "\t\t" << numEClpsOperated_I<< "\t\t" <<numEClpsToSliver_I << "\n";
- out << "DESpltClps:\t"<<numDESCTested_I << "\t\t" << numDESCAvailable_I << "\t\t" <<numDESCOperated_I << "\t\t" <<numDESCToSliver_I << "\n";
- out << "FClps:\t\t"<<numFClpsTested_I << "\t\t" << numFClpsAvailable_I<< "\t\t" << numFClpsOperated_I<< "\t\t" <<numFClpsToSliver_I << "\n";
- out << "ESwap:\t\t"<< numSwapTested_I << "\t\t" << numSwapAvailable_I << "\t\t" << numSwapOperated_I<< "\t\t" <<numSwapToSliver_I << "\n";
- out << "VMove:\t\t"<<numVMoveTested_I << "\t\t" << numVMoveAvailable_I<< "\t\t" << numVMoveOperated_I<< "\t\t" <<numVMoveToSliver_I << "\n";
-
- out << " \n--- Type II slivers ---\n\n";
- out << "\t nbTestedOp\t nbAvailableOp \t nbOperated \t nbLeadToASliver\n";
- out << "EClps:\t\t"<<numEClpsTested_II << "\t\t" << numEClpsAvailable_II<< "\t\t" << numEClpsOperated_II<< "\t\t" <<numEClpsToSliver_II << "\n";
- out << "FClps:\t\t"<<numFClpsTested_II << "\t\t" << numFClpsAvailable_II << "\t\t" <<numFClpsOperated_II << "\t\t" << numFClpsToSliver_II<< "\n";
- out << "ESwap:\t\t"<<numSwapTested_II << "\t\t" << numSwapAvailable_II<< "\t\t" << numSwapOperated_II<< "\t\t" <<numSwapToSliver_II << "\n";
- out << "FSwap:\t\t"<<numFSwapTested_II << "\t\t" << numFSwapAvailable_II << "\t\t" <<numFSwapOperated_II << "\t\t" << numFSwapToSliver_II<< "\n";
- out << "VMove:\t\t"<<numVMoveTested_II << "\t\t" << numVMoveAvailable_II<< "\t\t" << numVMoveOperated_II<< "\t\t" <<numVMoveToSliver_II << "\n";
-
- out << "\n\n";
-
-#else
-
- cout << "Could not write slivers statistics because SliverRegionHandler was compiled without the flag 'MAKESTATS'\n";
-
-#endif
-
- }
-
-
- // -------------------------------------------------------------------
- void sliverRegionHandler::testOperations(pRegion region)
- {
- if (!R_isSliver(region)) return;
-
- bool solvedSlivGlob = false;
- bool solvedGlob = false;
-
- bool solvedSliv = false;
- bool solved = false;
-
- double bestShape = 0.;
- mqm.getShape(region,&bestShape);
-
- MeshParametersManager& mpm = MeshParametersManagerSgl::instance();
-
- edgeCollapseOp eCollOp (mesh,sizeField);
- eCollOp.collapseOnBoundary(collapseOnBdry,dVTolClps);
-
- faceCollapseOp fCollOp (mesh,sizeField);
- fCollOp.collapseOnBoundary(collapseOnBdry,dVTolClps);
-
- edgeSwapOp eSwapOp (mesh,sizeField);
- eSwapOp.swapOnBoundary(swapOnBdry,dVTolSwap);
-
- DESCOp descOp(mesh,sizeField);
- edgeSplitOp eSplitOp(mesh,sizeField);
- faceSwapOp fSwapOp(mesh,sizeField);
- vertexMoveOp vMoveOp(mesh,sizeField,false);
-
- pEntity keyEnts[4];
- int sType = getSliverType(region, keyEnts);
- if( sType == 0 ) return;
-
- double worst;
-
- // --- TYPE I slivers ---
- if( sType == 1 )
- {
- tested_I++;
-
- // check split
- // ------------
- solvedSliv = false;
- solved = false;
- for(int i=0; i<2; i++) {
-
- eSplitOp.setSplitEdge((pEdge)keyEnts[i]);
-
- if( E_whatInType((pEdge)keyEnts[i]) != 3 ) continue;
-
- // determine the position of the new vertex
-// double newPos[3];
-// E_cavityCenter( (pEdge)keyEnts[i], newPos );
-// double t = E_linearParams((pEdge)keyEnts[i],newPos);
-// if( t>1. || t<0. ) continue;
-// eSplitOp.setSplitPos(newPos);
-
- worst = -1.;
- if( eSplitOp.evaluate(&worst) && worst > bestShape &&
- eSplitOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- eSplitOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- if (worst < mpm.getSliverTetBound()) {
- solvedSliv = true;
- }
- else {
- solved = true;
- break;
- }
- }
- }
- if ( solved ) { solvedGlob=true; splitSolves_I++; }
- else if ( solvedSliv ) { solvedSlivGlob=true; splitSolvesToSliver_I++; }
-
- // check edge collapses
- // ---------------------
- solvedSliv = false;
- solved = false;
- for(int i=0; i<6; i++) {
- pEdge edge = R_edge(region,i);
- for (int j=0; j<2; j++) {
- eCollOp.setCollapseEdge(edge,E_vertex(edge,j),E_vertex(edge,1-j));
-
- worst = -1.;
- if ( eCollOp.evaluate(&worst) && worst > bestShape &&
- eCollOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- eCollOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- if (worst < mpm.getSliverTetBound()) {
- solvedSliv = true;
- }
- else {
- solved = true;
- break;
- }
- }
- }
- if (worst > mpm.getSliverTetBound()) break;
- }
- if ( solved ) { solvedGlob=true; clpsSolves_I++; }
- else if ( solvedSliv ) { solvedSlivGlob=true; clpsSolvesToSliver_I++; }
-
- // check double edge split collapse
- // ---------------------------------
- solvedSliv = false;
- solved = false;
- for(int i=0; i<2; i++) {
- descOp.setDESC(region,(pEdge)keyEnts[i%2],(pEdge)keyEnts[(i+1)%2]);
-
- worst = -1.;
- if( descOp.evaluate(&worst) && worst > bestShape &&
- descOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- descOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- if (worst < mpm.getSliverTetBound()) {
- solvedSliv = true;
- }
- else {
- solved = true;
- }
- }
- }
- if ( solved ) { solvedGlob=true; descSolves_I++; }
- else if ( solvedSliv ) { solvedSlivGlob=true; descSolvesToSliver_I++; }
-
- // check face collapse
- // --------------------
- solvedSliv = false;
- solved = false;
- for(int i=0; i<2; i++) {
- for( int ClpsOnvt=1; ClpsOnvt>=0; ClpsOnvt-- ) {
- fCollOp.reset((pFace)keyEnts[i+2],(pEdge)keyEnts[i], ClpsOnvt);
-
- worst = -1.;
- if( fCollOp.evaluate(&worst) && worst > bestShape &&
- fCollOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- fCollOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- if (worst < mpm.getSliverTetBound()) {
- solvedSliv = true;
- }
- else {
- solved = true;
- break;
- }
- }
- }
- if( worst > mpm.getSliverTetBound() ) break;
- }
- if ( solved ) { solvedGlob=true; fclpsSolves_I++; }
- else if ( solvedSliv ) { solvedSlivGlob=true; fclpsSolvesToSliver_I++; }
-
- // check edge swaps (2 edges)
- // ---------------------------
- solvedSliv = false;
- solved = false;
- for(int i=0; i<2; i++) {
- eSwapOp.setSwapEdge((pEdge)keyEnts[i]);
-
- worst = -1.;
- if( eSwapOp.evaluate(&worst) && worst > bestShape &&
- eSwapOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- eSwapOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- if (worst < mpm.getSliverTetBound()) {
- solvedSliv = true;
- }
- else {
- solved = true;
- break;
- }
- }
- }
- if ( solved ) { solvedGlob=true; swapSolves_I++; }
- else if ( solvedSliv ) { solvedSlivGlob=true; swapSolvesToSliver_I++; }
-
- // check vertex move
- // ------------------
- solvedSliv = false;
- solved = false;
- pPList verts = R_vertices(region);
- void * temp = NULL;
- while ( pVertex pv = (pVertex)PList_next(verts,&temp) ) {
- if( V_whatInType(pv) != 3 ) continue;
-
- vMoveOp.setPositionToOptimal(pv);
-
- worst = -1.;
- if( vMoveOp.evaluate(&worst) && worst > bestShape &&
- vMoveOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- vMoveOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- if (worst < mpm.getSliverTetBound()) {
- solvedSliv = true;
- }
- else {
- solved = true;
- break;
- }
- }
- }
- PList_delete(verts);
- if ( solved ) { solvedGlob=true; nodeSolves_I++; }
- else if ( solvedSliv ) { solvedSlivGlob=true; nodeSolvesToSliver_I++; }
-
- if (!solvedGlob) {
- set<pRegion>::const_iterator sIter = notSolved.find(region);
- if (sIter == notSolved.end() ) {
- notSolved.insert(region);
- notSolved_I++;
- if (solvedSlivGlob) solvedWithSliver_I++;
- }
- else {
- notSolvedDuplicated_I++;
- if (solvedSlivGlob) solvedWithSliverDuplicated_I++;
- }
- }
-
- }
-
- // --- TYPE II slivers ---
- else
- {
- tested_II++;
-
- // check edge collapses
- // ---------------------
- solvedSliv = false;
- solved = false;
- for(int i=0; i<6; i++) {
- pEdge edge = R_edge(region,i);
- for (int j=0; j<2; j++) {
- eCollOp.setCollapseEdge(edge,E_vertex(edge,j),E_vertex(edge,(j+1)%2));
-
- worst = -1.;
- if ( eCollOp.evaluate(&worst) && worst > bestShape &&
- eCollOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- eCollOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- if (worst < mpm.getSliverTetBound()) {
- solvedSliv = true;
- }
- else {
- solved = true;
- break;
- }
- }
- }
- if (worst > mpm.getSliverTetBound()) break;
- }
- if ( solved ) { solvedGlob=true; clpsSolves_II++; }
- else if ( solvedSliv ) { solvedSlivGlob=true; clpsSolvesToSliver_II++; }
-
- // check face collapse
- // --------------------
-
- solvedSliv = false;
- solved = false;
- for( int ClpsOnvt=1; ClpsOnvt>=0; ClpsOnvt-- ) {
- fCollOp.reset((pFace)keyEnts[2],(pEdge)keyEnts[1], ClpsOnvt);
-
- worst = -1.;
- if( fCollOp.evaluate(&worst) && worst > bestShape &&
- fCollOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- fCollOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- if (worst < mpm.getSliverTetBound()) {
- solvedSliv = true;
- break;
- }
- else {
- solved = true;
- break;
- }
- }
- }
- if ( solved ) { solvedGlob=true; fclpsSolves_II++; }
- else if ( solvedSliv ) { solvedSlivGlob=true; fclpsSolvesToSliver_II++; }
-
- // check edge swaps
- // -----------------
- solvedSliv = false;
- solved = false;
- for(int i=0; i<3; i++) {
- pEdge edge = F_edge((pFace)keyEnts[0],i);
- eSwapOp.setSwapEdge(edge);
-
- worst = -1.;
- if( eSwapOp.evaluate(&worst) && worst > bestShape &&
- eSwapOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- eSwapOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- if (worst < mpm.getSliverTetBound()) {
- solvedSliv = true;
- }
- else {
- solved = true;
- break;
- }
- }
- }
- if ( solved ) { solvedGlob=true; swapSolves_II++; }
- else if ( solvedSliv ) { solvedSlivGlob=true; swapSolvesToSliver_II++; }
-
- // check face swap
- // ----------------
- solvedSliv = false;
- solved = false;
- fSwapOp.setSwapFace((pFace)keyEnts[0]);
-
- worst = -1.;
- if( fSwapOp.evaluate(&worst) && worst > bestShape &&
- fSwapOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- fSwapOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- if (worst < mpm.getSliverTetBound()) solvedSliv = true;
- else solved = true;
- }
- if ( solved ) { solvedGlob=true; fswapSolves_II++; }
- else if ( solvedSliv ) { solvedSlivGlob=true; fswapSolvesToSliver_II++; }
-
- // check vertex move
- // ------------------
- solvedSliv = false;
- solved = false;
- pPList verts = R_vertices(region);
- void * temp = NULL;
- while ( pVertex pv = (pVertex)PList_next(verts,&temp) ) {
- if( V_whatInType(pv) != 3 ) continue;
-
- vMoveOp.setPositionToOptimal(pv);
-
- worst = -1.;
- if( vMoveOp.evaluate(&worst) && worst > bestShape &&
- vMoveOp.getMinLenSq() > mpm.getSliverLowerLengthSqBound() &&
- vMoveOp.getMaxLenSq() < mpm.getSliverUpperLengthSqBound() ) {
- if (worst < mpm.getSliverTetBound()) {
- solvedSliv = true;
- }
- else {
- solved = true;
- break;
- }
- }
- }
- PList_delete(verts);
- if ( solved ) { solvedGlob=true; nodeSolves_II++; }
- else if ( solvedSliv ) { solvedSlivGlob=true; nodeSolvesToSliver_II++; }
-
- if (!solvedGlob) {
- set<pRegion>::const_iterator sIter = notSolved.find(region);
- if (sIter == notSolved.end() ) {
- notSolved.insert(region);
- notSolved_II++;
- if (solvedSlivGlob) solvedWithSliver_II++;
- }
- else {
- notSolvedDuplicated_II++;
- if (solvedSlivGlob) solvedWithSliverDuplicated_II++;
- }
- }
- }
-
- }
-
- // -------------------------------------------------------------------
- void sliverRegionHandler::printOperatorsTest(ostream& out) const
- {
- int testedUnique_I = tested_I-solvedWithSliverDuplicated_I-notSolvedDuplicated_I;
- int solved_I = tested_I-solvedWithSliver_I-notSolved_I-solvedWithSliverDuplicated_I-notSolvedDuplicated_I;
- int testedUnique_II = tested_II-solvedWithSliverDuplicated_II-notSolvedDuplicated_II;
- int solved_II = tested_II-solvedWithSliver_II-notSolved_II-solvedWithSliverDuplicated_II-notSolvedDuplicated_II;
-
- out << "\n*** SliverRegionHandler statistics (every operation is tested) ***\n\n";
- out << "Slivers considered: " << testedUnique_I+testedUnique_II<<endl;
- out << "\t Tested\t Tested dupl.\t Solved \t New sliver\t New sl. dupl.\t Not solved\t Not solved dupl.\n";
- out << " - Type I: \t"<< testedUnique_I
- << "\t\t" << tested_I-testedUnique_I
- << "\t\t" << solved_I
- << "\t\t" << solvedWithSliver_I
- << "\t\t" << solvedWithSliverDuplicated_I
- << "\t\t" << notSolved_I
- << "\t\t" << notSolvedDuplicated_I
- << "\n";
- out << " - Type II: \t"<< testedUnique_II
- << "\t\t" << tested_II-testedUnique_II
- << "\t\t" << solved_II
- << "\t\t" << solvedWithSliver_II
- << "\t\t" << solvedWithSliverDuplicated_II
- << "\t\t" << notSolved_II
- << "\t\t" << notSolvedDuplicated_II
- << "\n";
-
- out << " \n--- Type I slivers ---\n\n";
- out << "\t Solved\t Solved with a sliver\n";
- out << "ESwap:\t\t"<< swapSolves_I << "\t\t" << swapSolvesToSliver_I << "\n";
- out << "EClps:\t\t"<< clpsSolves_I << "\t\t" << clpsSolvesToSliver_I << "\n";
- out << "FClps:\t\t"<< fclpsSolves_I << "\t\t" << fclpsSolvesToSliver_I << "\n";
- out << "DESpltClps:\t"<< descSolves_I << "\t\t" << descSolvesToSliver_I << "\n";
- out << "ESplt:\t\t"<< splitSolves_I << "\t\t" << splitSolvesToSliver_I << "\n";
- out << "Reloc:\t\t"<< nodeSolves_I << "\t\t" << nodeSolvesToSliver_I << "\n";
-
- out << " \n--- Type II slivers ---\n\n";
- out << "\t Solved\t Solved with a sliver\n";
- out << "ESwap:\t\t"<< swapSolves_II << "\t\t" << swapSolvesToSliver_II << "\n";
- out << "FSwap:\t\t"<< fswapSolves_II << "\t\t" << fswapSolvesToSliver_II << "\n";
- out << "EClps:\t\t"<< clpsSolves_II << "\t\t" << clpsSolvesToSliver_II << "\n";
- out << "FClps:\t\t"<< fclpsSolves_II << "\t\t" << fclpsSolvesToSliver_II << "\n";
- out << "Reloc:\t\t"<< nodeSolves_II << "\t\t" << nodeSolvesToSliver_II << "\n";
-
- out << "\n\n";
-
- }
-
- // -------------------------------------------------------------------
- void sliverRegionHandler::reportSliver(pRegion region)
- {
- stringstream ss;
- string idStr; ss << reportId; ss >> idStr;
-
- string name = reportPrefix + "sliver" + idStr + ".pos";
-
- pPList cavity = PList_new();
-
- PList_append(cavity,region);
-
- for (int iV=0; iV<R_numVertices(region); iV++) {
-
- pVertex vertex = R_vertex(region, iV);
-
- pPList vRegs = V_regions(vertex);
- void * temp = 0;
- while ( pRegion pr = (pRegion)PList_next(vRegs,&temp) ) {
- PList_appUnique(cavity,pr);
- }
- PList_delete(vRegs);
- }
-
- printPosEntities(cavity,name.c_str(),OD_MEANRATIO,sizeField);
-
- PList_delete(cavity);
-
- reportId++;
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/operator/SliverRegionHandler.h b/Adapt/operator/SliverRegionHandler.h
deleted file mode 100644
index d2ace63..0000000
--- a/Adapt/operator/SliverRegionHandler.h
+++ /dev/null
@@ -1,200 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_SLIVERREGIONHANDLER
-#define _H_SLIVERREGIONHANDLER
-
-#include "MAdOperatorBase.h"
-
-#include <set>
-#include <iostream>
-#include <string>
-
-#define MAKESTATS 1
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class sliverRegionHandler {
-
- public:
-
- sliverRegionHandler(pMesh, DiscreteSF *);
- ~sliverRegionHandler() {}
-
- public:
-
- void removeSliverRegions(int * nbIn=NULL, int * nbOut=NULL);
-
- void setSizeField(DiscreteSF *);
-
- // whether we can use operations on boundaries
- void collapseOnBoundary(bool, double);
- void swapOnBoundary(bool, double);
-
- // whether we can use operations that add nodes
- void newVertexPermission(bool);
- bool getNewVertexPermission() const { return addNodes; }
-
- void enableReport(std::string);
- void setTestAllOperators(bool);
-
- private:
-
- int findOperation(pRegion, pMAdOperator *);
- bool R_isSliver(pRegion);
- bool R_isSliver(pRegion, double *);
-
- int getSliverType(const pRegion, pEntity[4]);
-
- void reportSliver(pRegion);
-
- private:
-
- pMesh mesh;
- DiscreteSF * sizeField;
-
- MeshQualityManager& mqm;
-
- bool collapseOnBdry; // whether or not we can collapse boundary edges
- double dVTolClps;
- bool swapOnBdry; // whether or not we can swap boundary edges
- double dVTolSwap;
-
- bool addNodes; // whether or not we can use operators that add nodes
- // (edge split, face collapse, DESC)
-
- bool reportFailures;
- int reportId;
- std::string reportPrefix;
-
- bool testOperators;
-
-#ifdef MAKESTATS
-
- private:
-
- // statistics:
-
- int numTypeI_In, numTypeI_Out, numTypeII_In, numTypeII_Out;
- int numSwapTested_I, numSwapAvailable_I, numSwapOperated_I, numSwapToSliver_I;
- int numEClpsTested_I, numEClpsAvailable_I, numEClpsOperated_I, numEClpsToSliver_I;
- int numFClpsTested_I, numFClpsAvailable_I, numFClpsOperated_I, numFClpsToSliver_I;
- int numDESCTested_I, numDESCAvailable_I, numDESCOperated_I, numDESCToSliver_I;
- int numSplitTested_I, numSplitAvailable_I, numSplitOperated_I, numSplitToSliver_I;
- int numVMoveTested_I, numVMoveAvailable_I, numVMoveOperated_I, numVMoveToSliver_I;
-
- int numSwapTested_II, numSwapAvailable_II, numSwapOperated_II, numSwapToSliver_II;
- int numEClpsTested_II, numEClpsAvailable_II, numEClpsOperated_II, numEClpsToSliver_II;
- int numFSwapTested_II, numFSwapAvailable_II, numFSwapOperated_II, numFSwapToSliver_II;
- int numFClpsTested_II, numFClpsAvailable_II, numFClpsOperated_II, numFClpsToSliver_II;
- int numVMoveTested_II, numVMoveAvailable_II, numVMoveOperated_II, numVMoveToSliver_II;
-
- // remaining slivers
- std::set<pRegion> sliversOut;
-
-#endif
-
- // test operators
- std::set<pRegion> sliversIn;
- int tested_I, tested_II, notSolved_I, notSolved_II, solvedWithSliver_I, solvedWithSliver_II;
- int notSolvedDuplicated_I, notSolvedDuplicated_II, solvedWithSliverDuplicated_I, solvedWithSliverDuplicated_II;
-
- int swapSolves_I,clpsSolves_I,fclpsSolves_I,descSolves_I,splitSolves_I,nodeSolves_I;
- int swapSolvesToSliver_I,clpsSolvesToSliver_I,fclpsSolvesToSliver_I,descSolvesToSliver_I,splitSolvesToSliver_I,nodeSolvesToSliver_I;
-
- int swapSolves_II, fswapSolves_II, clpsSolves_II, fclpsSolves_II, nodeSolves_II;
- int swapSolvesToSliver_II, fswapSolvesToSliver_II, clpsSolvesToSliver_II, fclpsSolvesToSliver_II, nodeSolvesToSliver_II;
-
- // remaining slivers
- std::set<pRegion> notSolved;
-
- public:
-
- void testOperations(pRegion);
-
- void printStats(std::ostream&) const;
- void printOperatorsTest(std::ostream&) const;
-
- };
-
- // -------------------------------------------------------------------
- inline sliverRegionHandler::sliverRegionHandler(pMesh m, DiscreteSF * sf):
- mesh(m),sizeField(sf), mqm(MeshQualityManagerSgl::instance()),
- collapseOnBdry(false),dVTolClps(MAdTOL),swapOnBdry(false),dVTolSwap(MAdTOL),
- addNodes(true),
- reportFailures(false),reportId(0),reportPrefix(""),testOperators(false)
-#ifdef MAKESTATS
- , numTypeI_In(0), numTypeI_Out(0), numTypeII_In(0), numTypeII_Out(0),
- numSwapTested_I(0), numSwapAvailable_I(0), numSwapOperated_I(0), numSwapToSliver_I(0),
- numEClpsTested_I(0), numEClpsAvailable_I(0), numEClpsOperated_I(0), numEClpsToSliver_I(0),
- numFClpsTested_I(0), numFClpsAvailable_I(0), numFClpsOperated_I(0), numFClpsToSliver_I(0),
- numDESCTested_I(0), numDESCAvailable_I(0), numDESCOperated_I(0), numDESCToSliver_I(0),
- numSplitTested_I(0), numSplitAvailable_I(0), numSplitOperated_I(0), numSplitToSliver_I(0),
- numVMoveTested_I(0), numVMoveAvailable_I(0), numVMoveOperated_I(0), numVMoveToSliver_I(0),
- numSwapTested_II(0), numSwapAvailable_II(0), numSwapOperated_II(0), numSwapToSliver_II(0),
- numEClpsTested_II(0), numEClpsAvailable_II(0), numEClpsOperated_II(0), numEClpsToSliver_II(0),
- numFSwapTested_II(0), numFSwapAvailable_II(0), numFSwapOperated_II(0), numFSwapToSliver_II(0),
- numFClpsTested_II(0), numFClpsAvailable_II(0), numFClpsOperated_II(0), numFClpsToSliver_II(0),
- numVMoveTested_II(0), numVMoveAvailable_II(0), numVMoveOperated_II(0), numVMoveToSliver_II(0),
-#endif
- tested_I(0), tested_II(0), notSolved_I(0), notSolved_II(0), solvedWithSliver_I(0), solvedWithSliver_II(0),
- notSolvedDuplicated_I(0), notSolvedDuplicated_II(0), solvedWithSliverDuplicated_I(0), solvedWithSliverDuplicated_II(0),
- swapSolves_I(0),clpsSolves_I(0),fclpsSolves_I(0),descSolves_I(0),splitSolves_I(0),nodeSolves_I(0), swapSolvesToSliver_I(0),clpsSolvesToSliver_I(0),fclpsSolvesToSliver_I(0),descSolvesToSliver_I(0),splitSolvesToSliver_I(0),nodeSolvesToSliver_I(0),
- swapSolves_II(0), fswapSolves_II(0), clpsSolves_II(0), fclpsSolves_II(0), nodeSolves_II(0), swapSolvesToSliver_II(0), fswapSolvesToSliver_II(0), clpsSolvesToSliver_II(0), fclpsSolvesToSliver_II(0), nodeSolvesToSliver_II(0)
- {}
-
- // -------------------------------------------------------------------
- inline void sliverRegionHandler::setSizeField(DiscreteSF * sf)
- {
- sizeField = sf;
- }
-
- // -------------------------------------------------------------------
- inline void sliverRegionHandler::collapseOnBoundary(bool cob, double tolerance)
- {
- collapseOnBdry = cob;
- dVTolClps = tolerance;
- }
-
- // -------------------------------------------------------------------
- inline void sliverRegionHandler::swapOnBoundary(bool sob, double tolerance)
- {
- swapOnBdry = sob;
- dVTolSwap = tolerance;
- }
-
- // -------------------------------------------------------------------
- inline void sliverRegionHandler::newVertexPermission(bool allow)
- {
- addNodes = allow;
- }
-
- // -------------------------------------------------------------------
- inline void sliverRegionHandler::enableReport(std::string prefix)
- {
- reportFailures = true;
- reportPrefix = prefix;
- }
-
- // -------------------------------------------------------------------
- inline void sliverRegionHandler::setTestAllOperators(bool test)
- {
- testOperators = test;
- }
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/operator/VertexMoveOp.cc b/Adapt/operator/VertexMoveOp.cc
deleted file mode 100644
index 10ff469..0000000
--- a/Adapt/operator/VertexMoveOp.cc
+++ /dev/null
@@ -1,421 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "VertexMoveOp.h"
-#include "OperatorTools.h"
-#include "MathUtils.h"
-
-#include <iostream>
-using std::cerr;
-#include <queue>
-using std::queue;
-using std::multiset;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- vDisplacement::vDisplacement(const vDisplacement& _vDisp)
- {
- pv = _vDisp.pv;
- for(int i=0; i<3; i++) dxyz[i] = _vDisp.dxyz[i];
- }
-
- // -------------------------------------------------------------------
- vDisplacement::vDisplacement(pVertex v, double disp[3])
- {
- pv = v;
- for(int i=0; i<3; i++) dxyz[i] = disp[i];
- }
-
- // -------------------------------------------------------------------
- void vDisplacement::scale(double factor)
- {
- for(int i=0; i<3; i++) dxyz[i] = factor * dxyz[i];
- }
-
- // -------------------------------------------------------------------
- bool vDisplacementLess::operator() (const vDisplacement& vd1,
- const vDisplacement& vd2) const
- {
- if (vd1.pv == vd2.pv)
- if (vd1.dxyz[0] == vd2.dxyz[0])
- if (vd1.dxyz[1] == vd2.dxyz[1])
- return (vd1.dxyz[2] < vd2.dxyz[2]);
- else return (vd1.dxyz[1] < vd2.dxyz[1]);
- else return (vd1.dxyz[0] < vd2.dxyz[0]);
- else return (vd1.pv < vd2.pv);
-
- return false;
- }
-
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- bool vertexMoveOp::move(multiset<vDisplacement,vDisplacementLess>& _vDisps,
- double factor)
- {
- resetDisplacements();
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDIt = _vDisps.begin();
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDEnd = _vDisps.end();
- for (; vDIt != vDEnd; vDIt++) {
- vDisplacement vDisp = *vDIt;
- vDisp.scale(factor);
- vDisps.insert(vDisp);
- }
- return operate();
- }
-
- // -------------------------------------------------------------------
- bool vertexMoveOp::move(pVertex v, double disp[3])
- {
- return move( vDisplacement(v,disp) );
- }
-
- // -------------------------------------------------------------------
- bool vertexMoveOp::move(vDisplacement vDisp)
- {
- resetDisplacements();
- addVDisplacement(vDisp);
- return operate();
- }
-
- // -------------------------------------------------------------------
- bool vertexMoveOp::operate()
- {
- double shape;
- if ( !evaluate(&shape) ) return false;
- apply();
- return true;
- }
-
- // -------------------------------------------------------------------
- void vertexMoveOp::addVDisplacement(pVertex v, double disp[3])
- {
- vDisplacement vDisp(v,disp);
- addVDisplacement(vDisp);
- }
-
- // -------------------------------------------------------------------
- void vertexMoveOp::addVDisplacement(vDisplacement vDisp)
- {
- vDisps.insert(vDisp);
- }
-
- // -------------------------------------------------------------------
- void vertexMoveOp::resetDisplacements()
- {
- vDisps.clear();
- }
-
- // -------------------------------------------------------------------
- void vertexMoveOp::setDisplacement(pVertex v, double disp[3])
- {
- resetDisplacements();
- addVDisplacement(v,disp);
- }
-
- // -------------------------------------------------------------------
- void vertexMoveOp::setPosition(pVertex v, double pos[3])
- {
- double xyz0[3], dxyz[3];
- V_coord(v,xyz0);
- diffVec(pos,xyz0,dxyz);
- setDisplacement(v,dxyz);
- }
-
- // -------------------------------------------------------------------
- void vertexMoveOp::setPositionToOptimal(pVertex v)
- {
- double opt[3];
- if (computeOptimalLocation(v, opt)) setPosition(v, opt);
- }
-
- // -------------------------------------------------------------------
- bool vertexMoveOp::computeOptimalLocation(pVertex vt, double opt[3]) const
- {
- if ( V_whatInType(vt) != dim ) return false;
-
- bool flag = false;
-
- // --- get original coordinates ---
- double ori[3]; V_coord(vt,ori);
-
- // --- get connected faces ---
- std::set<pFace> fSet;
- pPList faces = V_faces(vt);
- void * temp = 0;
- while ( pFace pf = (pFace) PList_next(faces,&temp) ) fSet.insert(pf);
- PList_delete(faces);
-
- // --- get original worst volume ratio ---
- double oriWorstRatio = F_worstVolumeRatio(fSet);
-
- // --- set first trial: the center of the cavity ---
- V_cavityCenter(vt,opt);
-
- int iter = 0;
- while ( iter < 3 && dotProd(opt,ori) > MAdTOL ) {
-
- // --- get worst vol ratio if we move to optimal ---
- V_setPosition(vt,opt);
- double optWorstRatio = F_worstVolumeRatio(fSet);
-
- // --- if it does not improve volume ratio ---
- // --- move it if increasing shape ---
- if( fabs(oriWorstRatio-optWorstRatio) < OPTILOC_MIN_IMPROVE_RATIO ) {
-
- V_setPosition(vt,ori);
- double oriWorstShp;
- mqm.V_worstShape(vt,&oriWorstShp);
-
- V_setPosition(vt,opt);
- double optWorstShp;
- mqm.V_worstShape(vt,&optWorstShp);
-
- if( (optWorstShp-oriWorstShp) > OPTILOC_MIN_IMPROVE_SHAPE ) {
- flag = true; break;
- }
- }
-
- // --- if it improves volume ratio ---
- if( (oriWorstRatio-optWorstRatio) > OPTILOC_MIN_IMPROVE_RATIO &&
- optWorstRatio != -1. ) {
- flag = true; break;
- }
-
- // --- underrelax solution ---
- for(int i=0; i<3; i++)
- opt[i] = 0.5*(opt[i]+ori[i]);
-
- iter++;
- }
-
- // --- put back the vertex at its original location ---
- V_setPosition(vt,ori);
-
- // --- no improvement found ---
- if (!flag) V_coord(vt,opt);
-
- return flag;
- }
-
- // -------------------------------------------------------------------
- bool vertexMoveOp::checkConstraints() const
- {
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDIt = vDisps.begin();
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDEnd = vDisps.end();
- for (; vDIt != vDEnd; vDIt++) {
- vDisplacement vd = *vDIt;
- if ( EN_constrained((pEntity)(vd.pv)) ) return false;
- }
- return true;
- }
-
- // -------------------------------------------------------------------
- bool vertexMoveOp::checkGeometry()
- {
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDIt = vDisps.begin();
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDEnd = vDisps.end();
- for (; vDIt != vDEnd; vDIt++) {
- vDisplacement vd = *vDIt;
- // check vertex is not on a boundary (if requested)
- if (fixedBndry) if ( V_whatInType(vd.pv) < dim ) return false;
- }
- return true;
- }
-
- // -------------------------------------------------------------------
- bool vertexMoveOp::evaluateShapes2D()
- {
- pPList faces;
- getCavity(&faces);
-
- double worstShape = mqm.getElementEvaluator()->bestShapeEver();
-
- void * temp = NULL;
- while( pFace face = (pFace) PList_next(faces,&temp) ) {
-
- double fCoords[3][3];
- pMSize fSizes[3] = {NULL,NULL,NULL};
-
- double fOriNor[3];
- F_normal(face,fOriNor);
-
- pPList fVerts = F_vertices(face,1);
- void * temp2 = NULL;
- int iNode = 0;
- while ( pVertex pV = (pVertex)PList_next(fVerts,&temp2) ) {
-
- V_coord(pV,fCoords[iNode]);
-
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDIt = vDisps.begin();
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDEnd = vDisps.end();
- for (; vDIt != vDEnd; vDIt++) {
- if ( (*vDIt).pv == pV ) {
- for (int iC=0; iC<3; iC++) fCoords[iNode][iC] += (*vDIt).dxyz[iC];
- }
- }
-
- fSizes[iNode] = sizeField->findSize(pV);
-
- iNode++;
- }
- PList_delete(fVerts);
-
- // Check if the shape is acceptable and compare it to the worst shape
- double shape = 0.;
- if ( !mqm.getElementEvaluator()->XYZ_F_shape(fCoords, fSizes, fOriNor, &shape) ) {
- PList_delete(faces);
- return false;
- }
- else {
- if ( shape < worstShape ) worstShape = shape;
- }
- }
- PList_delete(faces);
-
- results->setWorstShape(worstShape);
-
- return true;
- }
-
- // -------------------------------------------------------------------
- bool vertexMoveOp::evaluateShapes()
- {
- if (dim == 2) return evaluateShapes2D();
-
- pPList regs;
- getCavity(®s);
-
- double worstShape = mqm.getElementEvaluator()->bestShapeEver();
-
- void * temp = NULL;
- while( pRegion region = (pRegion) PList_next(regs,&temp) ) {
-
- double rCoords[4][3];
- pMSize rSizes[4] = {NULL,NULL,NULL,NULL};
-
- pPList rVerts = R_vertices(region);
- void * temp2 = NULL;
- int iNode = 0;
- while ( pVertex pV = (pVertex)PList_next(rVerts,&temp2) ) {
-
- V_coord(pV,rCoords[iNode]);
-
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDIt = vDisps.begin();
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDEnd = vDisps.end();
- for (; vDIt != vDEnd; vDIt++) {
- if ( (*vDIt).pv == pV ) {
- for (int iC=0; iC<3; iC++) rCoords[iNode][iC] += (*vDIt).dxyz[iC];
- }
- }
-
- rSizes[iNode] = sizeField->findSize(pV);
-
- iNode++;
- }
- PList_delete(rVerts);
-
- // Check if the shape is acceptable and compare it to the worst shape
- double shape = 0.;
- if ( !mqm.getElementEvaluator()->XYZ_R_shape(rCoords, rSizes, &shape) ) {
- PList_delete(regs);
- return false;
- }
- else {
- if ( shape < worstShape ) worstShape = shape;
- }
- }
- PList_delete(regs);
-
- results->setWorstShape(worstShape);
-
- return true;
- }
-
- // -------------------------------------------------------------------
- void vertexMoveOp::evaluateLengths() const
- {
- double minSq = MAdBIG;
- double maxSq = 0.;
-
- pPList edges;
- getAffectedEdges(&edges);
-
- void* tmp=0;
- while ( pEdge pe = (pEdge)PList_next(edges,&tmp) ) {
- double lSq = sizeField->SF_E_lengthSq(pe);
- if ( lSq > maxSq ) maxSq = lSq;
- if ( lSq < minSq ) minSq = lSq;
- }
-
- PList_delete(edges);
-
- results->setMaxLenSq(maxSq);
- results->setMinLenSq(minSq);
- }
-
- // -------------------------------------------------------------------
- void vertexMoveOp::getAffectedEdges(pPList * edges) const
- {
- *edges = PList_new();
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDIt = vDisps.begin();
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDEnd = vDisps.end();
- for (; vDIt != vDEnd; vDIt++) {
- pPList vEdges = V_edges(vDIt->pv);
- (*edges) = PList_appPListUnique(*edges,vEdges);
- PList_delete(vEdges);
- }
- }
-
- // -------------------------------------------------------------------
- void vertexMoveOp::getCavity(pPList * cavity) const
- {
- *cavity = PList_new();
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDIt = vDisps.begin();
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDEnd = vDisps.end();
- for (; vDIt != vDEnd; vDIt++) {
- if ( dim == 3 ) {
- pPList vRegs = V_regions(vDIt->pv);
- (*cavity) = PList_appPListUnique(*cavity,vRegs);
- PList_delete(vRegs);
- }
- else {
- pPList vFaces = V_faces(vDIt->pv);
- (*cavity) = PList_appPListUnique(*cavity,vFaces);
- PList_delete(vFaces);
- }
- }
- }
-
- // -------------------------------------------------------------------
- void vertexMoveOp::apply()
- {
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDIt = vDisps.begin();
- multiset<vDisplacement,vDisplacementLess>::const_iterator vDEnd = vDisps.end();
- for (; vDIt != vDEnd; vDIt++) {
- vDisplacement vd = *vDIt;
-
- double target[3]; V_coord(vd.pv,target);
- for (int i=0; i < 3; i++) target[i] += vd.dxyz[i];
-
- if ( !V_setPosition(vd.pv,target) ) {
- cerr << "Error: could not move vertex\n"; throw;
- }
- }
- HistorySgl::instance().add((int)type(),OPERATOR_APPLY,1);
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/operator/VertexMoveOp.h b/Adapt/operator/VertexMoveOp.h
deleted file mode 100644
index 1a596f3..0000000
--- a/Adapt/operator/VertexMoveOp.h
+++ /dev/null
@@ -1,111 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_VERTEXMOVEOP
-#define _H_VERTEXMOVEOP
-
-#include "MAdOperatorBase.h"
-
-#include <set>
-
-#define OPTILOC_MIN_IMPROVE_RATIO 1.e-3
-#define OPTILOC_MIN_IMPROVE_SHAPE 1.e-3
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- // GCTODO: rewrite it simpler
- struct vDisplacement
- {
- vDisplacement(const vDisplacement&);
- vDisplacement(pVertex, double[3]);
- void scale(double);
- pVertex pv;
- double dxyz[3]; // displacement
- };
-
- struct vDisplacementLess
- {
- bool operator() (const vDisplacement&, const vDisplacement&) const;
- };
-
- // -------------------------------------------------------------------
- class vertexMoveOp : public MAdOperatorBase
- {
- public:
-
- vertexMoveOp(pMesh, DiscreteSF *, bool _fixBndry=true);
- vertexMoveOp(const vertexMoveOp &);
- ~vertexMoveOp() {}
-
- operationType type() const { return MAd_VERTEXMOVE; }
-
- void setFixedBndry(bool);
-
- void resetDisplacements();
- void addVDisplacement(pVertex, double[3]);
- void addVDisplacement(vDisplacement);
- void setDisplacement(pVertex, double[3]);
- void setPosition(pVertex, double[3]);
- void setPositionToOptimal(pVertex);
-
- bool computeOptimalLocation(pVertex, double[3]) const;
-
- void getAffectedEdges(pPList *) const;
- void getCavity(pPList *) const;
-
- void apply();
- bool move (std::multiset<vDisplacement,vDisplacementLess>&, double factor=1.0);
- bool move (pVertex, double[3]);
- bool move (vDisplacement);
- bool operate ();
-
- private:
-
- bool checkConstraints() const;
- bool checkGeometry();
- bool evaluateShapes();
- bool evaluateShapes2D();
- void evaluateLengths() const;
-
- private:
-
- std::multiset<vDisplacement,vDisplacementLess> vDisps;
- bool fixedBndry; // indicates if the boundary vertices can move
- };
-
- // -------------------------------------------------------------------
- inline vertexMoveOp::vertexMoveOp(const vertexMoveOp & _vm):
- MAdOperatorBase(_vm)
- {
- vDisps = _vm.vDisps;
- fixedBndry = _vm.fixedBndry;
- }
-
- // -------------------------------------------------------------------
- inline vertexMoveOp::vertexMoveOp(pMesh _m, DiscreteSF * _sf,
- bool _fixBndry):
- MAdOperatorBase(_m,_sf), fixedBndry(_fixBndry)
- {}
-
- // -------------------------------------------------------------------
- inline void vertexMoveOp::setFixedBndry(bool fixed)
- {
- fixedBndry = fixed;
- }
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/output/MAdOutput.cc b/Adapt/output/MAdOutput.cc
deleted file mode 100644
index fd97add..0000000
--- a/Adapt/output/MAdOutput.cc
+++ /dev/null
@@ -1,709 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MAdOutput.h"
-#include "MeanRatioEvaluator.h"
-#include "OrientedMeanRatioEvaluator.h"
-#include "MAdMessage.h"
-#include "MathUtils.h"
-
-#include <iostream>
-using std::cout;
-using std::cerr;
-using std::endl;
-#include <vector>
-using std::vector;
-using std::string;
-using std::set;
-
-namespace MAd {
-
- enum dataType {
- SCALAR,
- VECTORIAL
- };
-
- dataType getOutputDataType(MAdOutputData t) {
- switch (t) {
- case OD_CONSTANT:
- case OD_MEANRATIO:
- case OD_ISOSIZEFIELD:
- case OD_DIMENSION:
- case OD_ITERORDER:
- case OD_CURVATURE_DIV:
- case OD_CURVATURE_MAX:
- case OD_CURVATURE_MIN:
- { return SCALAR; break; }
- case OD_CURVATURE_MAX_VEC:
- case OD_CURVATURE_MIN_VEC:
- case OD_ANISO_SF_AXIS0:
- case OD_ANISO_SF_AXIS1:
- case OD_ANISO_SF_AXIS2:
- { return VECTORIAL; break; }
- }
- };
-
- // ----------------------------------------------------------------------
- double* getData(MAdOutputData type, const pEntity pe, const pSField sf=NULL, int id=0)
- {
- int dim = EN_type(pe);
- double * result;
-
- switch (type) {
-
- case OD_DIMENSION: {
- result = new double[4];
- for (int i=0; i<4; i++) result[i] = (double)dim;
- return result;
- }
-
- case OD_CONSTANT: {
- result = new double[4];
- for (int i=0; i<4; i++) result[i] = 1.;
- return result;
- }
-
- case OD_MEANRATIO: {
- if ( !sf ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "No size field given to compute mean ratio");
- }
- if ( sf->getType() != DISCRETESFIELD ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Discrete size field required for quality evaluation");
- }
- meanRatioEvaluator evalu((DiscreteSF*)sf);
- double tmp;
- switch (dim) {
- case 3:
- result = new double[4];
- evalu.R_shape((pRegion)pe,&tmp);
- for (int i=0; i<4; i++) result[i] = tmp;
- return result;
- case 2:
- result = new double[3];
- evalu.F_shape((pFace)pe,0,&tmp);
- for (int i=0; i<3; i++) result[i] = tmp;
- return result;
- default:
- cerr << "Error in outputs: getData on an element if dimension inferior to 2\n";
- throw;
- }
- }
-
- case OD_ORIENTEDMEANRATIO: {
- if ( !sf ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "No size field given to compute mean ratio");
- }
- if ( sf->getType() != DISCRETESFIELD ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Discrete size field required for quality evaluation");
- }
- orientedMeanRatioEvaluator evalu((DiscreteSF*)sf);
- double tmp;
- switch (dim) {
- case 3:
- result = new double[4];
- evalu.R_shape((pRegion)pe,&tmp);
- for (int i=0; i<4; i++) result[i] = tmp;
- return result;
- case 2:
- result = new double[3];
- evalu.F_shape((pFace)pe,0,&tmp);
- for (int i=0; i<3; i++) result[i] = tmp;
- return result;
- default:
- cerr << "Error in outputs: getData on an element if dimension inferior to 2\n";
- throw;
- }
- }
-
- case OD_ITERORDER: {
- result = new double[4];
- for (int i=0; i<4; i++) result[i] = (double)id;
- return result;
- }
-
- case OD_ISOSIZEFIELD: {
- if ( !sf ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "No size field given");
- }
- void * temp;
- pPList verts;
- int k;
- pVertex pv;
- switch (dim) {
- case 3:
- result = new double[4];
- verts = R_vertices((pRegion)pe);
- temp = 0 ; k=0;
- while ( ( pv = (pVertex)PList_next(verts,&temp) ) )
- {
- pMSize size = sf->getSize(pv);
- double h = size->getMeanLength();
- if (size) delete size;
- result[k] = h;
- k++;
- }
- PList_delete(verts);
- return result;
- case 2:
- result = new double[3];
- verts = F_vertices( (pFace)pe, 1);
- temp = 0 ; k=0;
- while ( ( pv = (pVertex)PList_next(verts,&temp) ) )
- {
- pMSize size = sf->getSize(pv);
- double h = size->getMeanLength();
- if (size) delete size;
- result[k] = h;
- k++;
- }
- PList_delete(verts);
- return result;
- default:
- cerr << "Error in outputs: getData on an element if dimension inferior to 2\n";
- throw;
- }
- }
-
- case OD_CURVATURE_DIV: {
-#ifdef _HAVE_GMSH_
- if ( dim != 2 ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Cannot output curvatures on other entities than faces");
- }
- result = new double[4];
- pGEntity pge = EN_whatIn(pe);
- if ( GEN_type(pge) != 2 ) {
- for (int i=0; i<4; i++) result[i] = -1.;
- return result;
- }
- double u[4][2];
- F_params((pFace)pe,u);
- for (int iV=0; iV<F_numVertices((pFace)pe); iV++)
- {
- result[iV] = GF_curvatureDiv((pGFace)pge, u[iV], 1.e6);
- }
- return result;
-#else
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Gmsh required for curvature");
-#endif
- }
-
- case OD_CURVATURE_MAX: {
-#ifdef _HAVE_GMSH_
- if ( dim != 2 ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Cannot output curvatures on other entities than faces");
- }
- result = new double[4];
- pGEntity pge = EN_whatIn(pe);
- if ( GEN_type(pge) != 2 ) {
- for (int i=0; i<4; i++) result[i] = -1.;
- return result;
- }
- double u[4][2];
- F_params((pFace)pe,u);
- for (int iV=0; iV<F_numVertices((pFace)pe); iV++)
- {
- double dirMax[3], dirMin[3], curvMax, curvMin;
- GF_curvatures((pGFace)pge, u[iV],
- dirMax, dirMin, &curvMax, &curvMin, 1.e6);
- result[iV] = curvMax;
- }
- return result;
-#else
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Gmsh required for curvature");
-#endif
- }
-
- case OD_CURVATURE_MIN: {
-#ifdef _HAVE_GMSH_
- if ( dim != 2 ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Cannot output curvatures on other entities than faces");
- }
- result = new double[4];
- pGEntity pge = EN_whatIn(pe);
- if ( GEN_type(pge) != 2 ) {
- for (int i=0; i<4; i++) result[i] = -1.;
- return result;
- }
- double u[4][2];
- F_params((pFace)pe,u);
- for (int iV=0; iV<F_numVertices((pFace)pe); iV++)
- {
- double dirMax[3], dirMin[3], curvMax, curvMin;
- GF_curvatures((pGFace)pge, u[iV],
- dirMax, dirMin, &curvMax, &curvMin, 1.e6);
- result[iV] = curvMin;
- }
- return result;
-#else
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Gmsh required for curvature");
-#endif
- }
-
- case OD_CURVATURE_MAX_VEC: {
-#ifdef _HAVE_GMSH_
- if ( dim != 2 ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Cannot output curvatures on other entities than faces");
- }
- result = new double[9];
- pGEntity pge = EN_whatIn(pe);
- if ( GEN_type(pge) != 2 ) {
- for (int i=0; i<9; i++) result[i] = -1.;
- return result;
- }
- double u[3][2];
- F_params((pFace)pe,u);
- for (int iV=0; iV<3; iV++)
- {
- double dirMax[3], dirMin[3], curvMax, curvMin;
- GF_curvatures((pGFace)pge, u[iV],
- dirMax, dirMin, &curvMax, &curvMin, 1.e6);
- normalizeVec(dirMax,dirMax);
- for (int iC=0; iC<3; iC++) result[3*iV+iC] = dirMax[iC] * curvMax;
- }
- return result;
-#else
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Gmsh required for curvature");
-#endif
- }
-
- case OD_CURVATURE_MIN_VEC: {
-#ifdef _HAVE_GMSH_
- if ( dim != 2 ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Cannot output curvatures on other entities than faces");
- }
- result = new double[9];
- pGEntity pge = EN_whatIn(pe);
- if ( GEN_type(pge) != 2 ) {
- for (int i=0; i<9; i++) result[i] = -1.;
- return result;
- }
- double u[3][2];
- F_params((pFace)pe,u);
- for (int iV=0; iV<3; iV++)
- {
- double dirMax[3], dirMin[3], curvMax, curvMin;
- GF_curvatures((pGFace)pge, u[iV],
- dirMax, dirMin, &curvMax, &curvMin, 1.e6);
- normalizeVec(dirMin,dirMin);
- for (int iC=0; iC<3; iC++) result[3*iV+iC] = dirMin[iC] * curvMin;
- }
- return result;
-#else
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Gmsh required for curvature");
-#endif
- }
-
- case OD_ANISO_SF_AXIS0:
- case OD_ANISO_SF_AXIS1:
- case OD_ANISO_SF_AXIS2:
- {
- if ( !sf ) MAdMsgSgl::instance().error(__LINE__,__FILE__,"No size field given");
-
- void * temp;
- pPList verts;
- int k;
- pVertex pv;
- switch (dim) {
- case 3:
- result = new double[12];
- verts = R_vertices((pRegion)pe);
- temp = 0 ; k=0;
- while ( ( pv = (pVertex)PList_next(verts,&temp) ) )
- {
- pMSize size = sf->getSize(pv);
- double h, dir[3];
- if ( type == OD_ANISO_SF_AXIS0 ) h = size->direction(0,dir);
- if ( type == OD_ANISO_SF_AXIS1 ) h = size->direction(1,dir);
- if ( type == OD_ANISO_SF_AXIS2 ) h = size->direction(2,dir);
- if (size) delete size;
- for (int iC=0; iC<3; iC++) result[3*k+iC] = h * dir[iC];
- k++;
- }
- PList_delete(verts);
- return result;
- case 2:
- result = new double[9];
- verts = F_vertices( (pFace)pe, 1);
- temp = 0 ; k=0;
- while ( ( pv = (pVertex)PList_next(verts,&temp) ) )
- {
- pMSize size = sf->getSize(pv);
- double h, dir[3];
- if ( type == OD_ANISO_SF_AXIS0 ) h = size->direction(0,dir);
- if ( type == OD_ANISO_SF_AXIS1 ) h = size->direction(1,dir);
- if ( type == OD_ANISO_SF_AXIS2 ) h = size->direction(2,dir);
- if (size) delete size;
- for (int iC=0; iC<3; iC++) result[3*k+iC] = h * dir[iC];
- k++;
- }
- PList_delete(verts);
- return result;
- default:
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Dimension < 2: %d",dim);
- }
- }
-
- default:
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Data type not handled in switch");
- }
- return 0;
- }
-
- // ----------------------------------------------------------------------
- void writeFaces (const pMesh m, const pSField sf, FILE *f, MAdOutputData type)
- {
- int count = 0;
- FIter fit = M_faceIter(m);
- while (pFace pf = FIter_next(fit))
- {
- double xyz[3][3];
- F_coordP1(pf, xyz);
- double* data = getData(type,(pEntity)pf,sf,count);
- if ( getOutputDataType(type) == SCALAR ) {
- fprintf (f,"ST(%g,%g,%g,%g,%g,%g,%g,%g,%g) {%g,%g,%g};\n",
- xyz[0][0],xyz[0][1],xyz[0][2],
- xyz[1][0],xyz[1][1],xyz[1][2],
- xyz[2][0],xyz[2][1],xyz[2][2],
- data[0],data[1],data[2]);
- }
- if ( getOutputDataType(type) == VECTORIAL ) {
- fprintf (f,"VT(%g,%g,%g,%g,%g,%g,%g,%g,%g) {%g,%g,%g,%g,%g,%g,%g,%g,%g};\n",
- xyz[0][0],xyz[0][1],xyz[0][2],
- xyz[1][0],xyz[1][1],xyz[1][2],
- xyz[2][0],xyz[2][1],xyz[2][2],
- data[0],data[1],data[2],
- data[3],data[4],data[5],
- data[6],data[7],data[8]);
- }
- delete [] data;
- count++;
- }
- FIter_delete(fit);
- }
-
- // ----------------------------------------------------------------------
- void writeRegions (const pMesh m, const pSField sf, FILE *f, MAdOutputData type)
- {
- int count = 0;
- RIter rit = M_regionIter(m);
- while (pRegion pr = RIter_next(rit))
- {
- double xyz[4][3];
- R_coordP1(pr, xyz);
- double* data = getData(type,(pEntity)pr,sf,count);
- if ( getOutputDataType(type) == SCALAR ) {
- fprintf (f,"SS(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g) {%g,%g,%g,%g};\n",
- xyz[0][0],xyz[0][1],xyz[0][2],
- xyz[1][0],xyz[1][1],xyz[1][2],
- xyz[2][0],xyz[2][1],xyz[2][2],
- xyz[3][0],xyz[3][1],xyz[3][2],
- data[0],data[1],data[2],data[3]);
- }
- if ( getOutputDataType(type) == VECTORIAL ) {
- fprintf (f,"VS(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g) {%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g};\n",
- xyz[0][0],xyz[0][1],xyz[0][2],
- xyz[1][0],xyz[1][1],xyz[1][2],
- xyz[2][0],xyz[2][1],xyz[2][2],
- xyz[3][0],xyz[3][1],xyz[3][2],
- data[0],data[1],data[2],data[3],
- data[4],data[5],data[6],data[7],
- data[8],data[9],data[10],data[11]);
- }
- delete [] data;
- count++;
- }
- RIter_delete(rit);
- }
-
- // ----------------------------------------------------------------------
- void MAdGmshOutput (const pMesh m, const pSField sf, const char *fn, MAdOutputData type)
- {
- if ( type == OD_ISOSIZEFIELD && sf->getType() == NULLSFIELD ) return;
-
- FILE *f = fopen (fn, "w");
- if ( !f ) {
- cerr << "Error: could not open file " << fn << endl; throw;
- }
-
- fprintf (f,"View\" mesh \" {\n");
-
- if (M_dim(m)==2) writeFaces(m,sf,f,type);
- else writeRegions(m,sf,f,type);
-
- fprintf (f,"};\n");
- fclose (f);
- }
-
- // ----------------------------------------------------------------------
-
- void MAdAttachedNodalDataOutput(const pMesh m, const char *fn, pMeshDataId id)
- {
- FILE *f = fopen (fn, "w");
- if ( !f ) {
- cerr << "Error: could not open file " << fn << endl; throw;
- }
-
- fprintf (f,"View\" mesh \" {\n");
-
- if (M_dim(m)==2) {
-
- FIter fit = M_faceIter(m);
- while (pFace pf = FIter_next(fit))
- {
- // get the coordinates
- double xyz[3][3];
- F_coordP1(pf, xyz);
-
- // get the data at nodes
- double data[3];
- pPList verts = F_vertices(pf,1);
- void* tmp = 0;
- int i = 0;
- while ( pEntity pv = PList_next(verts,&tmp) ) {
- EN_getDataDbl((pEntity)pv,id,&(data[i]));
- i++;
- }
- PList_delete(verts);
-
- // write an element
- fprintf (f,"ST(%g,%g,%g,%g,%g,%g,%g,%g,%g) {%g,%g,%g};\n",
- xyz[0][0],xyz[0][1],xyz[0][2],
- xyz[1][0],xyz[1][1],xyz[1][2],
- xyz[2][0],xyz[2][1],xyz[2][2],
- data[0],data[1],data[2]);
- }
- FIter_delete(fit);
- }
- else {
-
- RIter rit = M_regionIter(m);
- while (pRegion pr = RIter_next(rit))
- {
- // get the coordinates
- double xyz[4][3];
- R_coordP1(pr, xyz);
-
- // get the data at nodes
- double data[4];
- pPList verts = R_vertices(pr);
- void* tmp = 0;
- int i = 0;
- while ( pEntity pv = PList_next(verts,&tmp) ) {
- EN_getDataDbl((pEntity)pv,id,&(data[i]));
- i++;
- }
- PList_delete(verts);
-
- // write an element
- fprintf (f,"SS(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g) {%g,%g,%g,%g};\n",
- xyz[0][0],xyz[0][1],xyz[0][2],
- xyz[1][0],xyz[1][1],xyz[1][2],
- xyz[2][0],xyz[2][1],xyz[2][2],
- xyz[3][0],xyz[3][1],xyz[3][2],
- data[0],data[1],data[2],data[3]);
- }
- RIter_delete(rit);
-
- }
-
- fprintf (f,"};\n");
- fclose (f);
- }
-
- // ----------------------------------------------------------------------
-
- void MAdAttachedNodalDataVecOutput(const pMesh m, const char *fn, pMeshDataId id)
- {
- FILE *f = fopen (fn, "w");
- if ( !f ) {
- cerr << "Error: could not open file " << fn << endl; throw;
- }
-
- fprintf (f,"View\" mesh \" {\n");
-
- if (M_dim(m)==2) {
-
- FIter fit = M_faceIter(m);
- while (pFace pf = FIter_next(fit))
- {
- // get the coordinates
- double xyz[3][3];
- F_coordP1(pf, xyz);
-
- // get the data at nodes
- double data[3][3];
- pPList verts = F_vertices(pf,1);
- void* tmp = 0;
- int i = 0;
- while ( pEntity pv = PList_next(verts,&tmp) ) {
- void * tmpDat = NULL;
- EN_getDataPtr((pEntity)pv,id,&tmpDat);
-// vector<double> * vec = (vector<double>*) tmpDat;
-// for (int j=0; j<3; j++) data[i][j] = (*vec)[j];
- for (int j=0; j<3; j++) data[i][j] = ((double*)tmpDat)[j];
- i++;
- }
- PList_delete(verts);
-
- // write an element
- fprintf (f,"VT(%g,%g,%g,%g,%g,%g,%g,%g,%g) {%g,%g,%g,%g,%g,%g,%g,%g,%g};\n",
- xyz[0][0],xyz[0][1],xyz[0][2],
- xyz[1][0],xyz[1][1],xyz[1][2],
- xyz[2][0],xyz[2][1],xyz[2][2],
- data[0][0],data[0][1],data[0][2],
- data[1][0],data[1][1],data[1][2],
- data[2][0],data[2][1],data[2][2]);
- }
- FIter_delete(fit);
- }
- else {
-
- RIter rit = M_regionIter(m);
- while (pRegion pr = RIter_next(rit))
- {
- // get the coordinates
- double xyz[4][3];
- R_coordP1(pr, xyz);
-
- // get the data at nodes
- double data[4][3];
- pPList verts = R_vertices(pr);
- void* tmp = 0;
- int i = 0;
- while ( pEntity pv = PList_next(verts,&tmp) ) {
- void * tmpDat = NULL;
- EN_getDataPtr((pEntity)pv,id,&tmpDat);
-// vector<double> * vec = (vector<double>*) tmpDat;
-// for (int j=0; j<3; j++) data[i][j] = (*vec)[j];
- for (int j=0; j<3; j++) data[i][j] = ((double*)tmpDat)[j];
- i++;
- }
- PList_delete(verts);
-
- // write an element
- fprintf (f,"VS(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g) {%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g};\n",
- xyz[0][0],xyz[0][1],xyz[0][2],
- xyz[1][0],xyz[1][1],xyz[1][2],
- xyz[2][0],xyz[2][1],xyz[2][2],
- xyz[3][0],xyz[3][1],xyz[3][2],
- data[0][0],data[0][1],data[0][2],
- data[1][0],data[1][1],data[1][2],
- data[2][0],data[2][1],data[2][2],
- data[3][0],data[3][1],data[3][2]);
- }
- RIter_delete(rit);
-
- }
-
- fprintf (f,"};\n");
- fclose (f);
- }
-
- // -------------------------------------------------------------------
- void printPosRegions(const set<pRegion> regs, string fn, MAdOutputData type,
- const pSField sf, int id)
- {
- FILE *f = fopen (fn.c_str(), "w");
- fprintf (f,"View\" mesh \" {\n");
-
- set<pRegion>::const_iterator rIter = regs.begin();
- for (; rIter != regs.end(); rIter++) {
- double* data = getData(type,*rIter,sf);
- double xyz[4][3];
- R_coordP1(*rIter, xyz);
- fprintf (f,"SS(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g) {%g,%g,%g,%g};\n",
- xyz[0][0],xyz[0][1],xyz[0][2],
- xyz[1][0],xyz[1][1],xyz[1][2],
- xyz[2][0],xyz[2][1],xyz[2][2],
- xyz[3][0],xyz[3][1],xyz[3][2],
- data[0],data[1],data[2],data[3]);
- delete [] data;
- }
-
- fprintf (f,"};\n");
- fclose (f);
- }
-
- // -------------------------------------------------------------------
- void printPosEntities(const pPList ents, string fn, MAdOutputData type,
- const pSField sf, int id)
- {
- FILE *f = fopen (fn.c_str(), "w");
- fprintf (f,"View\" mesh \" {\n");
-
- void *iter=0;
- while( pEntity ent = PList_next(ents,&iter) ) {
- double* data = getData(type,ent,sf);
- switch ( EN_type(ent) ) {
- case 0:
- {
- double xyz[3];
- V_coord((pVertex)ent, xyz);
- fprintf (f,"SP(%g,%g,%g) {%g};\n",
- xyz[0],xyz[1],xyz[2],
- data[0]);
- break;
- }
- case 1:
- {
- double xyz[2][3];
- E_coordP1((pEdge)ent, xyz);
- fprintf (f,"SL(%g,%g,%g,%g,%g,%g) {%g,%g};\n",
- xyz[0][0],xyz[0][1],xyz[0][2],
- xyz[1][0],xyz[1][1],xyz[1][2],
- data[0],data[1]);
- break;
- }
- case 2:
- {
- double xyz[3][3];
- F_coordP1((pFace)ent, xyz);
- fprintf (f,"ST(%g,%g,%g,%g,%g,%g,%g,%g,%g) {%g,%g,%g};\n",
- xyz[0][0],xyz[0][1],xyz[0][2],
- xyz[1][0],xyz[1][1],xyz[1][2],
- xyz[2][0],xyz[2][1],xyz[2][2],
- data[0],data[1],data[2]);
- break;
- }
- case 3:
- {
- double xyz[4][3];
- R_coordP1((pRegion)ent, xyz);
- fprintf (f,"SS(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g) {%g,%g,%g,%g};\n",
- xyz[0][0],xyz[0][1],xyz[0][2],
- xyz[1][0],xyz[1][1],xyz[1][2],
- xyz[2][0],xyz[2][1],xyz[2][2],
- xyz[3][0],xyz[3][1],xyz[3][2],
- data[0],data[1],data[2],data[3]);
- break;
- }
- }
- delete [] data;
- }
-
- fprintf (f,"};\n");
- fclose (f);
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/output/MAdOutput.h b/Adapt/output/MAdOutput.h
deleted file mode 100644
index b8ec261..0000000
--- a/Adapt/output/MAdOutput.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MADOUTPUT
-#define _H_MADOUTPUT
-
-#include "SizeFieldBase.h"
-#include "MSops.h"
-
-#include <string>
-#include <set>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- typedef enum MAdOutputData {
- OD_CONSTANT,
- OD_MEANRATIO,
- OD_ORIENTEDMEANRATIO,
- OD_ISOSIZEFIELD,
- OD_DIMENSION,
- OD_ITERORDER, // for debugging
- OD_CURVATURE_DIV,
- OD_CURVATURE_MAX,
- OD_CURVATURE_MIN,
- OD_CURVATURE_MAX_VEC,
- OD_CURVATURE_MIN_VEC,
- OD_ANISO_SF_AXIS0,
- OD_ANISO_SF_AXIS1,
- OD_ANISO_SF_AXIS2
- } MAdOutputData;
-
- // -------------------------------------------------------------------
-
- void MAdGmshOutput(const pMesh m, const pSField sf,
- const char *fn, MAdOutputData type);
-
- void MAdAttachedNodalDataOutput (const pMesh m, const char *fn,
- pMeshDataId id);
- void MAdAttachedNodalDataVecOutput(const pMesh m, const char *fn,
- pMeshDataId id);
-
- void printPosEntities(const pPList ents, std::string fn, MAdOutputData type,
- const pSField sf=NULL, int id=0);
-
- void printPosRegions(const std::set<pRegion>, std::string fn, MAdOutputData type,
- const pSField sf=NULL, int id=0);
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/quality/ElementEvaluatorBase.h b/Adapt/quality/ElementEvaluatorBase.h
deleted file mode 100644
index 75c7329..0000000
--- a/Adapt/quality/ElementEvaluatorBase.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_ELEMENTEVALUATORBASE
-#define _H_ELEMENTEVALUATORBASE
-
-#include "DiscreteSF.h"
-#include "MeshDataBaseInterface.h"
-
-#include <string>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- enum evaluationType {
- UNKNOWNEVALTYPE,
- MEANRATIO,
- ORIENTEDMEANRATIO
- };
-
- // -------------------------------------------------------------------
- class elementEvaluatorBase {
-
- public:
-
- elementEvaluatorBase(const DiscreteSF * f): sizeField(f) { setDefaultAcptValue(); }
- virtual ~elementEvaluatorBase() {};
-
- void setSizeField(const DiscreteSF * sf) {sizeField = sf;}
-
- virtual int R_shape(const pRegion r, double * result) const = 0;
- virtual int F_shape(const pFace f, const double normal[3], double * result) const = 0;
- virtual int XYZ_R_shape(const double[4][3], const pMSize[4], double * result) const = 0;
- virtual int XYZ_F_shape(const double[3][3], const pMSize[3], const double normal[3], double * result) const = 0;
-
- virtual inline double worstShapeEver() const {return 0.;}
- virtual inline double bestShapeEver() const {return 1.;}
- virtual inline double whatsWorst(double shp1, double shp2) const {return std::min(shp1,shp2);}
-
- virtual evaluationType getType () const = 0;
- virtual std::string getName () const = 0;
-
- double getAcceptableValue() { return acptValue; }
- void setAcptValue(double t) { acptValue = t; }
- void setDefaultAcptValue() { acptValue = 1.0e-10; }
-
- protected:
-
- const DiscreteSF * sizeField;
- double acptValue;
- };
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/quality/ElementStatistics.h b/Adapt/quality/ElementStatistics.h
deleted file mode 100644
index 39798f1..0000000
--- a/Adapt/quality/ElementStatistics.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_ELEMENTSTATISTICS
-#define _H_ELEMENTSTATISTICS
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class ElementStatistics {
-
- public:
-
- ElementStatistics();
- ElementStatistics(const ElementStatistics &);
- ~ElementStatistics() {};
-
- // interface to set information
- void reset();
- void setWorstShape(double v) { worstShape = v; }
- void setMaxLenSq(double v) { maxLenSq = v; }
- void setMinLenSq(double v) { minLenSq = v; }
-
- // interface to get information
- double getWorstShape() const { return worstShape; }
- double getMaxLenSq() const { return maxLenSq; }
- double getMinLenSq() const { return minLenSq; }
-
- private:
-
- double worstShape;
- double minLenSq, maxLenSq;
- };
-
- // -------------------------------------------------------------------
- inline ElementStatistics::ElementStatistics()
- {
- reset();
- }
-
- // -------------------------------------------------------------------
- inline ElementStatistics::ElementStatistics(const ElementStatistics & eq)
- {
- worstShape = eq.worstShape;
- minLenSq = eq.minLenSq;
- maxLenSq = eq.maxLenSq;
- }
-
- // -------------------------------------------------------------------
- inline void ElementStatistics::reset()
- {
- worstShape = MAdBIG;
- minLenSq = MAdBIG;
- maxLenSq = 0.0;
- }
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/quality/MeanRatioEvaluator.cc b/Adapt/quality/MeanRatioEvaluator.cc
deleted file mode 100644
index d41e5d7..0000000
--- a/Adapt/quality/MeanRatioEvaluator.cc
+++ /dev/null
@@ -1,169 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MeanRatioEvaluator.h"
-
-#include <iostream>
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::string;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- meanRatioEvaluator::meanRatioEvaluator(const DiscreteSF * f):
- elementEvaluatorBase(f)
- {}
-
- // -------------------------------------------------------------------
- int meanRatioEvaluator::F_shape(const pFace face, const double normal[3],
- double * shape) const
- {
- double fxyz[3][3];
- pMSize pS[3];
-
- void *iter=0;
- int i = 0;
- pPList fvts=F_vertices(face,1);
- while( pVertex vt=(pVertex)PList_next(fvts,&iter) ) {
- pS[i]=sizeField->findSize(vt);
- V_coord(vt,fxyz[i++]);
- }
- PList_delete(fvts);
-
- return XYZ_F_shape(fxyz,pS,normal,shape);
- }
-
- // -------------------------------------------------------------------
- int meanRatioEvaluator::XYZ_F_shape(const double xyz[3][3], const pMSize pS[3],
- const double nor[3], double * shape) const
- {
- if( sizeField->getType() == NULLSFIELD ) {
- if( ! XYZ_F_shape(xyz,pS[0],nor,shape) )
- { *shape=0; return 0; }
- return 1;
- }
-
- // use central size to compute shape
- pMSize pSZ = MS_interpolate(pS[0], pS[1], pS[2], 0.33, 0.33);
- int res = XYZ_F_shape(xyz, pSZ, nor, shape);
- if ( pSZ ) delete pSZ;
- return res;
-
-// // compute shapes using sizes at every vertex and retain the worst one
-// double shp[3];
-// for(int i=0; i<3; i++) {
-// if( ! XYZ_F_shape(xyz, pS[i], nor, &shp[i]) )
-// { *shape = 0.; return 0; }
-// }
-// *shape = std::min(std::min(shp[0],shp[1]),shp[2]);
-// return 1;
- }
-
- // -------------------------------------------------------------------
- int meanRatioEvaluator::XYZ_F_shape(const double xyz[3][3], const pMSize pS,
- const double nor[3], double * shape) const
- {
- double aSq,sumSq;
-
- aSq = sizeField->SF_XYZ_areaSq(xyz,pS,nor);
-
- if( aSq <= 0. ) { *shape = 0.; return 0; }
-
- sumSq = sizeField->SF_XYZ_lengthSq(xyz[1],xyz[0],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[2],xyz[0],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[1],xyz[2],pS);
-
- *shape = 48.*aSq/(sumSq*sumSq);
-
- if(*shape < acptValue) return 0;
- else if (*shape > (1.+MAdTOL) ) *shape = 1.;
-
- return 1;
- }
-
- // -------------------------------------------------------------------
- int meanRatioEvaluator::R_shape(const pRegion rgn, double * shape) const
- {
- double rxyz[4][3];
- pMSize pS[4];
-
- void *iter=0;
- int i=0;
- pPList verts=R_vertices(rgn);
- while( pVertex vt=(pVertex)PList_next(verts,&iter) ) {
- pS[i]=sizeField->findSize(vt);
- V_coord(vt,rxyz[i++]);
- }
- PList_delete(verts);
-
- return XYZ_R_shape(rxyz,pS,shape);
- }
-
- // -------------------------------------------------------------------
- int meanRatioEvaluator::XYZ_R_shape(const double xyz[4][3], const pMSize pS[4],
- double * shape) const
- {
- if( sizeField->getType() == NULLSFIELD ) {
- if( ! XYZ_R_shape(xyz,pS[0],shape) )
- { *shape=0.; return 0; }
- return 1;
- }
-
- // use central size
- pMSize pSZ = MS_interpolate(pS[0], pS[1], pS[2], pS[3], 0.25, 0.25, 0.25);
-
- // use minimal size
-// pMSize pSZ;
-// double hmin = MAdBIG;
-// for(int i=0; i<4; i++) {
-// if( pS[i] ) {
-// double s = pS[i]->minSize();
-// if( s < hmin ) { hmin = s; pSZ = pS[i]; }
-// }
-// }
-// assert( hmin != MAdBIG );
-
- int res = XYZ_R_shape(xyz,pSZ,shape);
- if ( pSZ ) delete pSZ;
- return res;
- }
-
- // -------------------------------------------------------------------
- int meanRatioEvaluator::XYZ_R_shape(const double xyz[4][3], const pMSize pS,
- double * shape) const
- {
- double vol,sumSq;
-
- vol = sizeField->SF_XYZ_volume(xyz,pS);
-
- if ( vol < 0. ) { *shape = 0.; return 0; }
-
- sumSq = sizeField->SF_XYZ_lengthSq(xyz[1],xyz[0],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[2],xyz[0],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[3],xyz[0],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[3],xyz[1],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[3],xyz[2],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[1],xyz[2],pS);
-
- *shape = 15552.*vol*vol/(sumSq*sumSq*sumSq);
-
- if(*shape < acptValue) return 0;
- else if (*shape > (1.+MAdTOL) ) *shape = 1.;
-
- return 1;
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/quality/MeanRatioEvaluator.h b/Adapt/quality/MeanRatioEvaluator.h
deleted file mode 100644
index 018242c..0000000
--- a/Adapt/quality/MeanRatioEvaluator.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MEANRATIOEVALUATOR
-#define _H_MEANRATIOEVALUATOR
-
-#include "ElementEvaluatorBase.h"
-
-/* -------------------------------------------------------------------
-
-Computes the cubic of the mean ratio of any element of the mesh (tri or tet)
-The mean ratio is expressed as:
-
-For tetrahedrons:
-
-eta = 12 * ( ( 3*Volume ) ^ (2/3) ) / ( sum(edgeLength^2) )
-
-or equivalently:
-
-eta ^ 3 = 15552 * (Volume) ^ 2 / ( sum(edgeLength^2) ) ^ 3
-
-For triangles:
-
-eta ^ 2 = 48 * ( Area ^ 2 ) / ( sum(edgeLength^2) ) ^ 2
-
-This ensures ratios ranging from 0 (flat element) to 1 (equilateral)
-
-------------------------------------------------------------------- */
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class meanRatioEvaluator : public elementEvaluatorBase
- {
- public:
- meanRatioEvaluator(const DiscreteSF * f);
- virtual ~meanRatioEvaluator() {}
-
- virtual int F_shape(const pFace pf, const double normal[3], double * result) const;
- virtual int R_shape(const pRegion pr, double * result) const;
- virtual int XYZ_F_shape(const double[3][3], const pMSize[3], const double normal[3], double * result) const;
- virtual int XYZ_R_shape(const double[4][3], const pMSize[4], double * result) const;
-
- virtual evaluationType getType () const {return MEANRATIO;}
- virtual std::string getName () const {return "Mean ratio";}
-
- protected:
- virtual int XYZ_F_shape(const double[3][3], const pMSize pS, const double normal[3], double * result) const;
- virtual int XYZ_R_shape(const double[4][3], const pMSize pS, double * result) const;
- };
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/quality/MeshQualityManager.cc b/Adapt/quality/MeshQualityManager.cc
deleted file mode 100644
index 03acff6..0000000
--- a/Adapt/quality/MeshQualityManager.cc
+++ /dev/null
@@ -1,678 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MeshQualityManager.h"
-#include "MeanRatioEvaluator.h"
-#include "OrientedMeanRatioEvaluator.h"
-#include "CallBackManager.h"
-
-#include <iostream>
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::ostream;
-#include <iomanip>
-#include <math.h>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void QualityDeletingCBFunctionMove (pVertex pv, double *, void *)
- {
- MeshQualityManagerSgl::instance().clearNeighbourShapes(pv);
- }
-
- // -------------------------------------------------------------------
- void QualityDeletingCBFunction (pPList before, pPList after, void *,
- operationType type , pEntity ppp)
- {
- switch (type) {
- case MAd_ESPLIT: {
- // In the edge split case, we have to delete the shapes associated to the old elements
-
- // find the old edge
- void *tmp=0;
- pEntity pE = PList_next(before,&tmp);
-
- // clear all shapes in the neighbour of the edge
- MeshQualityManagerSgl::instance().clearNeighbourShapes((pEdge) pE);
-
- break;
- }
- case MAd_ECOLLAPSE: {
- // In the edge collapse case, we have to delete the shapes attached to the neighbour elements of the deleted node.
- // clear all shapes in the neighbour of the deleted node
- MeshQualityManagerSgl::instance().clearNeighbourShapes((pVertex) ppp);
-
- break;
- }
- case MAd_FSWAP:{
- // In the face swap case, we have to delete the shapes associated to the old elements
- void * temp = NULL;
- while ( pEntity ent = PList_next(before,&temp) ) {
- MeshQualityManagerSgl::instance().clearShape(ent);
- }
- break;
- }
- case MAd_ESWAP: {
- // In the edge swap case, we have to delete the shapes associated to the old elements
- void * temp = NULL;
- while ( pEntity ent = PList_next(before,&temp) ) {
- MeshQualityManagerSgl::instance().clearShape(ent);
- }
- break;
- }
- case MAd_RREMOVE: {
- // delete the shape associated to the deleted region
- MeshQualityManagerSgl::instance().clearShape(ppp);
- break;
- }
- default: {
- printf("Error in MeshQualityManager: Callback function not implemented for mesh modification %d",
- type);
- throw;
- }
- }
- }
-
- // -------------------------------------------------------------------
- void MeshQualityManager::initialize(pMesh m, DiscreteSF * sf, evaluationType type)
- {
- mesh = m;
- sizeField = sf;
-
- dim = M_dim(mesh);
- shapeId = MD_newMeshDataId("");
-
- switch(type) {
- case MEANRATIO: {
- if(!evaluator) {
- evaluator = new meanRatioEvaluator(sizeField);
- }
- break;
- }
- default: {
- cerr << "Error: unknown evaluation type when initializing the mesh quality manager\n";
- throw;
- }
- }
-
- CallBackManagerSgl::instance().registerCallBack(QualityDeletingCBFunction,NULL);
- CallBackManagerSgl::instance().registerCallBackMove(QualityDeletingCBFunctionMove,NULL);
-
- if(!histogram) {
- histogram = new int[10];
- }
- if(!histogramAvg) {
- histogramAvg = new double[10];
- }
- }
-
- // -------------------------------------------------------------------
- void MeshQualityManager::setMesh(pMesh m)
- {
- mesh = m;
- dim = M_dim(mesh);
- }
-
- // -------------------------------------------------------------------
- void MeshQualityManager::finalize()
- {
- clearAllShapes();
- MD_deleteMeshDataId(shapeId);
- if (evaluator) {
- delete evaluator;
- evaluator=NULL;
- }
- if (histogram) {
- delete [] histogram;
- histogram=NULL;
- }
- if (histogramAvg) {
- delete [] histogramAvg;
- histogramAvg=NULL;
- }
- }
-
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- void MeshQualityManager::evaluateAllShapes() const
- {
- if (!mesh) {
- cout << "Warning: Could not evaluate shapes in the element evaluator: no mesh specified\n";
- return;
- }
-
- if ( dim == 3 ) {
- RIter rit = M_regionIter(mesh);
- while ( pRegion pr = RIter_next(rit) ) {
- double tmp;
- if ( !getAttachedShape((pEntity)pr,&tmp) ) {
- double shape;
- evaluator->R_shape(pr,&shape);
- attachShape((pEntity)pr, shape);
- }
- }
- RIter_delete(rit);
- }
- else {
- FIter fit = M_faceIter(mesh);
- while ( pFace pf = FIter_next(fit) ) {
- double tmp;
- if ( !getAttachedShape((pEntity)pf,&tmp) ) {
- double shape;
- evaluator->F_shape(pf,0,&shape);
- attachShape((pEntity)pf, shape);
- }
- }
- FIter_delete(fit);
- }
- }
-
- // -------------------------------------------------------------------
- void MeshQualityManager::evaluateAndReplaceAllShapes() const
- {
- if (!mesh) {
- cout << "Warning: Could not evaluate shapes in the element evaluator: no mesh specified\n";
- return;
- }
-
- if ( dim == 3 ) {
- RIter rit = M_regionIter(mesh);
- while ( pRegion pr = RIter_next(rit) ) {
- double shape;
- evaluator->R_shape(pr,&shape);
- attachShape((pEntity)pr, shape);
- }
- RIter_delete(rit);
- }
- else {
- FIter fit = M_faceIter(mesh);
- while ( pFace pf = FIter_next(fit) ) {
- double shape;
- evaluator->F_shape(pf,0,&shape);
- attachShape((pEntity)pf, shape);
- }
- FIter_delete(fit);
- }
- }
-
- // -------------------------------------------------------------------
- int MeshQualityManager::getShape(pFace pf, double normal[3], double * result) const
- {
- return evaluator->F_shape(pf,normal,result);
- }
-
- // -------------------------------------------------------------------
- int MeshQualityManager::getShape(pRegion pr, double * result) const
- {
- // return evaluator->R_shape(pr,result);
- if ( !getAttachedShape((pEntity)pr, result) ) {
- int flag = evaluator->R_shape(pr,result);
- attachShape((pEntity)pr,*result);
- return flag;
- }
-
- if ( *result < evaluator->getAcceptableValue() ) return 0;
- return 1;
- }
-
- // -------------------------------------------------------------------
- void MeshQualityManager::clearAllShapes() const
- {
- if (!mesh) {
- cout << "Warning: Could not clear shapes in the element evaluator: no mesh specified\n";
- return;
- }
-
- if ( dim == 3 ) {
- RIter rit = M_regionIter(mesh);
- while ( pRegion pr = RIter_next(rit) ) {
- clearShape((pEntity)pr);
- }
- RIter_delete(rit);
- }
- else {
- FIter fit = M_faceIter(mesh);
- while ( pFace pf = FIter_next(fit) ) {
- clearShape((pEntity)pf);
- }
- FIter_delete(fit);
- }
- }
-
- // -------------------------------------------------------------------
- void MeshQualityManager::clearShape(pEntity pe) const
- {
- EN_deleteData(pe, shapeId);
- }
-
- // -------------------------------------------------------------------
- void MeshQualityManager::clearNeighbourShapes(pVertex pv) const
- {
- if ( dim==3 ) {
- pPList regs = V_regions(pv);
- void* temp=0;
- while ( pEntity region = PList_next(regs,&temp) ) {
- clearShape( region );
- }
- PList_delete(regs);
- }
- else {
- pPList faces = V_faces(pv);
- void* temp=0;
- while ( pEntity face = PList_next(faces,&temp) ) {
- clearShape( face );
- }
- PList_delete(faces);
- }
- }
-
- // -------------------------------------------------------------------
- void MeshQualityManager::clearNeighbourShapes(pEdge pe) const
- {
- if ( dim==3 ) {
- pPList regs = E_regions(pe);
- void* temp=0;
- while ( pEntity region = PList_next(regs,&temp) ) {
- clearShape( region );
- }
- PList_delete(regs);
- }
- else {
- pPList faces = E_faces(pe);
- void* temp=0;
- while ( pEntity face = PList_next(faces,&temp) ) {
- clearShape( face );
- }
- PList_delete(faces);
- }
- }
-
- // -------------------------------------------------------------------
- int MeshQualityManager::V_worstShape(pVertex vt, double* result) const
- {
- pRegion region;
- pPList rlist = V_regions(vt);
- double worst = evaluator->bestShapeEver();
- double shape_1;
-
- double mtol = evaluator->getAcceptableValue();
- void *temp=0;
-
- if( PList_size(rlist)==0 ) {
- // 2D case
- pPList flist = V_faces(vt);
- pFace face;
- while( ( face = (pFace)PList_next(flist,&temp) ) ) {
- getShape(face,0,&shape_1);
- if( shape_1 <= mtol ) {
- PList_delete(flist);
- *result = shape_1;
- return 0;
- }
- if(shape_1 < worst)
- worst = shape_1;
- }
- PList_delete(flist);
- }
- else {
- // 3D case
- while( ( region = (pRegion)PList_next(rlist,&temp) ) ) {
- getShape(region,&shape_1);
- if( shape_1 <= mtol ) {
- PList_delete(rlist);
- *result = shape_1;
- return 0;
- }
- if(shape_1 < worst)
- worst = shape_1;
- }
- }
-
- PList_delete(rlist);
- *result = worst;
- return 1;
- }
-
- // -------------------------------------------------------------------
-
- int MeshQualityManager::E_worstShape(pEdge e, double* result) const {
-
- double worst = evaluator->bestShapeEver();
- double shape_1;
- double mtol = evaluator->getAcceptableValue();
-
- // 2D case
- if( E_numRegions(e)==0 ) {
- pFace face;
- for( int i=0; i<E_numFaces(e); i++ ) {
- face=E_face(e,i);
- if (!getShape(face,0,&shape_1) || shape_1 <= mtol ) {
- *result = 0.0; return 0;
- }
- if( shape_1 < worst) worst = shape_1;
- }
- }
- // 3D case
- else {
- pPList rlist = E_regions(e);
- pRegion region; void *temp=0;
- while( ( region=(pRegion)PList_next(rlist,&temp) ) ) {
- if ( !getShape(region,&shape_1) || shape_1 <= mtol ) {
- PList_delete(rlist); *result = 0.0; return 0;
- }
- if( shape_1 < worst) worst = shape_1;
- }
- PList_delete(rlist);
- }
-
- *result = worst;
- return 1;
- }
-
- // -------------------------------------------------------------------
-
- int MeshQualityManager::F_worstShape(pFace f, double* result) const {
-
- double worst = evaluator->bestShapeEver();
- double shape_1;
- double mtol = evaluator->getAcceptableValue();
-
- pPList rlist = F_regions(f);
- pRegion region; void *temp=0;
- while( ( region=(pRegion)PList_next(rlist,&temp) ) ) {
- if ( !getShape(region,&shape_1) || shape_1 <= mtol ) {
- PList_delete(rlist); *result = 0.0; return 0;
- }
- if( shape_1 < worst) worst = shape_1;
- }
- PList_delete(rlist);
-
- *result = worst;
- return 1;
- }
-
- // -------------------------------------------------------------------
- int MeshQualityManager::FList_worstShape(pPList faces, double * result) const
- {
- double worst = evaluator->bestShapeEver();
-
- void* tmp=0;
- while( pEntity pe = PList_next(faces,&tmp) ) {
-
- if ( EN_type(pe) != 2 ) {
- cerr << "Error: Received an entity of dimension " << EN_type(pe) << " in FList_worstShape\n";
- throw;
- }
-
- double shape;
- if ( !getShape( (pFace)pe, 0, &shape) ) {
- *result = 0;
- return 0;
- }
- else {
- worst = evaluator->whatsWorst(shape, worst);
- }
- }
-
- *result = worst;
-
- return 1;
- }
-
- // -------------------------------------------------------------------
- int MeshQualityManager::RList_worstShape(pPList regions, double * result) const
- {
- double worst = evaluator->bestShapeEver();
-
- void* tmp=0;
- while( pEntity pe = PList_next(regions,&tmp) ) {
-
- if ( EN_type(pe) != 3 ) {
- cerr << "Error: Received an entity of dimension " << EN_type(pe) << " in RList_worstShape\n";
- throw;
- }
-
- double shape;
- if ( !getShape( (pRegion)pe, &shape) ) {
- *result = 0.;
- return 0;
- }
- else {
- worst = evaluator->whatsWorst(shape, worst);
- }
- }
-
- *result = worst;
-
- return 1;
- }
-
- // -------------------------------------------------------------------
- void MeshQualityManager::attachShape(pEntity pe, double shape) const
- {
- EN_modifyDataDbl(pe, shapeId, shape);
- }
-
- // -------------------------------------------------------------------
- bool MeshQualityManager::getAttachedShape(const pEntity pe, double* result) const
- {
- if ( !EN_getDataDbl(pe, shapeId, result) ) return false;
- return true;
- }
-
- // -------------------------------------------------------------------
- bool MeshQualityManager::checkAttachedShapes() const
- {
- bool ok = true;
-
- int noData = 0;
- int dataOK = 0;
- int wrongData = 0;
-
- if (dim == 3) {
- RIter rit = M_regionIter(mesh);
- while ( pRegion pr = RIter_next(rit) ) {
- double attachedShape;
- if ( !getAttachedShape((pEntity)pr,&attachedShape) ) noData++;
- else {
- double shape;
- evaluator->R_shape(pr,&shape);
- if ( fabs(shape - attachedShape) <= 1.e-12 ) dataOK++;
- else {
- cout<<"Warning: wrong shape found: attached: "<<attachedShape<<", real: "<<shape<<endl;
- wrongData++;
- ok = false;
- }
- }
- }
- RIter_delete(rit);
- }
- else {
- FIter fit = M_faceIter(mesh);
- while ( pFace pf = FIter_next(fit) ) {
- double attachedShape;
- if ( !getAttachedShape((pEntity)pf,&attachedShape) ) noData++;
- else {
- double shape;
- evaluator->F_shape(pf,0,&shape);
- if ( fabs(shape - attachedShape) <= 1.e-12 ) dataOK++;
- else {
- cout<<"Warning: wrong shape found: attached: "<<attachedShape<<", real: "<<shape<<endl;
- wrongData++;
- ok = false;
- }
- }
- }
- FIter_delete(fit);
- }
-
- cout << "\nAttached shapes report:\n\n";
- cout << "Elements checked: "<<noData+dataOK+wrongData<<endl;
- cout << "Elements with no attached shape: "<<noData<<endl;
- cout << "Elements with a correct shape: "<<dataOK<<endl;
- cout << "Elements with a wrong shape: "<<wrongData<<endl;
- cout<<endl;
-
- return ok;
- }
-
- // -------------------------------------------------------------------
- void MeshQualityManager::evaluateSizes()
- {
- minAbsoluteSize = MAdBIG;
- maxAbsoluteSize = 0.;
- sizesSum = 0.;
-
- switch( dim )
- {
- case 3: {
- RIter rit = M_regionIter(mesh);
- while ( pRegion r = RIter_next(rit) )
- {
- double vol = R_volume(r);
- minAbsoluteSize = std::min(minAbsoluteSize,vol);
- maxAbsoluteSize = std::max(maxAbsoluteSize,vol);
- sizesSum += vol;
- }
- RIter_delete(rit);
- break;
- }
- case 2: {
- FIter fit = M_faceIter(mesh);
- while ( pFace f = FIter_next(fit) )
- {
- double area = F_area(f,0);
- minAbsoluteSize = std::min(minAbsoluteSize,area);
- maxAbsoluteSize = std::max(maxAbsoluteSize,area);
- sizesSum += area;
- }
- FIter_delete(fit);
- break;
- }
- default: {
- cerr << "Dimension " << dim << " not handled by meshEvaluator\n";
- throw;
- }
- }
- }
-
- // -------------------------------------------------------------------
- void MeshQualityManager::evaluateShapes()
- {
- worstShape = evaluator->bestShapeEver();
- meanShape = 0.;
- for (int i=0; i<10; i++) histogram[i]=0;
- notAcpt = 0;
-
- switch( dim )
- {
- case 3: {
- nbElem = M_numRegions(mesh);
- RIter rit = M_regionIter(mesh);
- while ( pRegion r = RIter_next(rit) )
- {
- double shape;
- if ( !getShape(r,&shape) ) notAcpt++;
- else if (shape < 0.) {cerr << "Error: element with negative quality\n"; throw;}
- else {
- if (shape >= 1.) { shape = 1.-MAdTOL; }
- unsigned int qualityLevel = (unsigned int)floor(shape*10.);
- if ( qualityLevel == 10 ) qualityLevel = 9;
- histogram[qualityLevel]++;
- }
- meanShape += shape;
- worstShape = evaluator->whatsWorst(worstShape,shape);
- }
- RIter_delete(rit);
- break;
- }
- case 2: {
- nbElem = M_numFaces(mesh);
- FIter fit = M_faceIter(mesh);
- while ( pFace f = FIter_next(fit) ) {
- double shape;
- if ( !getShape(f,0,&shape)) histogram[0]++;
- else if (shape < 0.) {cerr << "Error: element with negative quality\n"; throw;}
- else if (shape > 1.) { shape = 1.; }
- else {
- unsigned int qualityLevel = (unsigned int)floor(shape*10);
- histogram[qualityLevel]++;
- }
- meanShape += shape;
- worstShape = evaluator->whatsWorst(worstShape,shape);
- }
- FIter_delete(fit);
- break;
- }
- default: {
- cerr << "Dimension " << dim << " not handled by meshEvaluator\n";
- throw;
- }
- }
-
- meanShape /= nbElem;
- for (int i=0; i<10; i++) histogramAvg[i] = (double)histogram[i] / nbElem;
- }
-
- // -------------------------------------------------------------------
- void MeshQualityManager::evaluateStatistics()
- {
- evaluateSizes();
- evaluateShapes();
- }
-
- // -------------------------------------------------------------------
- void MeshQualityManager::printStatistics(ostream& out) const
- {
- out << "\n ---------- Mesh quality report ----------\n\n";
- out << "Criterion: " << evaluator->getName() << "\n\n";
- out << " Average element quality\t"<<std::setprecision(4)<<meanShape<<"\n";
- out << " Worst element quality\t\t"<<std::setprecision(4)<<worstShape<<"\n";
- out << " Non acceptable elements\t"<< notAcpt << " \n";
- out << std::setprecision(2) << std::setw(0);
- out << std::fixed;
-
- out << "\n --- Histogram ---\n\n";
-
- for (int i = 0; i < 10; i++) {
- out <<std::setprecision(1)
- << " " << ((double)i)/10. << " < Q < " << ((double)(i+1))/10. << " : "
- <<std::setprecision(2)<<std::setw(5)
- << (histogramAvg[i])*100. <<" % "<<std::setw(7)<< histogram[i]<<" elements\n";
- }
- out<<endl;
-
- out << std::setprecision(6) << std::setw(0); // return to default values
- out.unsetf(std::ios::floatfield); // return to default values
-
- out<<" Smallest ";
- if (dim == 3) out <<"volume ";
- else out<<"area ";
- out <<"(absolute space)\t"<< minAbsoluteSize << "\n";
- out<<" Biggest ";
- if (dim == 3) out <<"volume ";
- else out<<"area ";
- out <<"(absolute space)\t"<< maxAbsoluteSize << "\n";
- out<<" Total ";
- if (dim == 3) out <<"volume ";
- else out<<"area ";
- out <<" (absolute space)\t"<< sizesSum << "\n\n";
- }
-
- // -------------------------------------------------------------------
-
-}
-
diff --git a/Adapt/quality/MeshQualityManager.h b/Adapt/quality/MeshQualityManager.h
deleted file mode 100644
index d7cb5fc..0000000
--- a/Adapt/quality/MeshQualityManager.h
+++ /dev/null
@@ -1,139 +0,0 @@
-// -*- 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 at 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;
-
- // 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;
-
- // 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
diff --git a/Adapt/quality/OrientedMeanRatioEvaluator.cc b/Adapt/quality/OrientedMeanRatioEvaluator.cc
deleted file mode 100644
index 0e09bf6..0000000
--- a/Adapt/quality/OrientedMeanRatioEvaluator.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "OrientedMeanRatioEvaluator.h"
-#include "AnisoMeshSize.h"
-
-#include <iostream>
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::string;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- orientedMeanRatioEvaluator::orientedMeanRatioEvaluator(const DiscreteSF * f):
- meanRatioEvaluator(f)
- {}
-
- // -------------------------------------------------------------------
- int orientedMeanRatioEvaluator::XYZ_F_shape(const double xyz[3][3], const pMSize pS,
- const double nor[3], double * shape) const
- {
- double aSq,sumSq;
-
- aSq = sizeField->SF_XYZ_areaSq(xyz,pS,nor);
-
- if( aSq <= 0. ) { *shape = 0.; return 0; }
-
- sumSq = sizeField->SF_XYZ_lengthSq(xyz[1],xyz[0],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[2],xyz[0],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[1],xyz[2],pS);
-
- *shape = 48.*aSq/(sumSq*sumSq);
-
- if ( pS->getType() == ANISOTROPIC )
- {
- double tmp[3]; diffVec(xyz[1],xyz[0],tmp);
- double cosa = fabs( ((AnisoMeshSize*)pS)->angleWithDir0(tmp) );
- *shape *= ( fabs( cosa - 0.5 ) + 0.5 );
- diffVec(xyz[2],xyz[0],tmp);
- cosa = fabs( ((AnisoMeshSize*)pS)->angleWithDir0(tmp) );
- *shape *= ( fabs( cosa - 0.5 ) + 0.5 );
- diffVec(xyz[2],xyz[1],tmp);
- cosa = fabs( ((AnisoMeshSize*)pS)->angleWithDir0(tmp) );
- *shape *= ( fabs( cosa - 0.5 ) + 0.5 );
- }
-
- if(*shape < acptValue) return 0;
- else if (*shape > (1.+MAdTOL) ) *shape = 1.;
-
- return 1;
- }
-
- // -------------------------------------------------------------------
- int orientedMeanRatioEvaluator::XYZ_R_shape(const double xyz[4][3], const pMSize pS,
- double * shape) const
- {
- double vol,sumSq;
-
- vol = sizeField->SF_XYZ_volume(xyz,pS);
-
- if ( vol < 0. ) { *shape = 0.; return 0; }
-
- sumSq = sizeField->SF_XYZ_lengthSq(xyz[1],xyz[0],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[2],xyz[0],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[3],xyz[0],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[3],xyz[1],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[3],xyz[2],pS);
- sumSq += sizeField->SF_XYZ_lengthSq(xyz[1],xyz[2],pS);
-
- *shape = 15552.*vol*vol/(sumSq*sumSq*sumSq);
-
- if ( pS->getType() == ANISOTROPIC )
- {
- double dir0[3]; pS->direction(0,dir0); normalizeVec(dir0,dir0);
- double orientFactor = 1.;
-
- double tmp[3]; diffVec(xyz[1],xyz[0],tmp); normalizeVec(tmp,tmp);
- double cosa = fabs( dotProd(dir0,tmp) );
- orientFactor *= ( fabs( cosa - 0.5 ) + 0.5 );
-
- diffVec(xyz[2],xyz[0],tmp); normalizeVec(tmp,tmp);
- cosa = fabs( dotProd(dir0,tmp) );
- orientFactor *= ( fabs( cosa - 0.5 ) + 0.5 );
-
- diffVec(xyz[3],xyz[0],tmp); normalizeVec(tmp,tmp);
- cosa = fabs( dotProd(dir0,tmp) );
- orientFactor *= ( fabs( cosa - 0.5 ) + 0.5 );
-
- diffVec(xyz[2],xyz[1],tmp); normalizeVec(tmp,tmp);
- cosa = fabs( dotProd(dir0,tmp) );
- orientFactor *= ( fabs( cosa - 0.5 ) + 0.5 );
-
- diffVec(xyz[3],xyz[1],tmp); normalizeVec(tmp,tmp);
- cosa = fabs( dotProd(dir0,tmp) );
- orientFactor *= ( fabs( cosa - 0.5 ) + 0.5 );
-
- diffVec(xyz[3],xyz[2],tmp); normalizeVec(tmp,tmp);
- cosa = fabs( dotProd(dir0,tmp) );
- orientFactor *= ( fabs( cosa - 0.5 ) + 0.5 );
-
- *shape *= orientFactor;
- }
-
- if(*shape < acptValue) return 0;
- else if (*shape > (1.+MAdTOL) ) *shape = 1.;
-
- return 1;
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/quality/OrientedMeanRatioEvaluator.h b/Adapt/quality/OrientedMeanRatioEvaluator.h
deleted file mode 100644
index c7d4cbb..0000000
--- a/Adapt/quality/OrientedMeanRatioEvaluator.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_ORIENTEDMEANRATIOEVALUATOR
-#define _H_ORIENTEDMEANRATIOEVALUATOR
-
-#include "MeanRatioEvaluator.h"
-
-/* -------------------------------------------------------------------
-
-Computes the cubic of the mean ratio of any element of the
-mesh (tri or tet) penalised (for every edge 'e') by a factor
-
- | |cos(alpha_e)| - 0.5 | + 0.5
-
-where 'alpha_e' is the angle of 'e' with the direction of the minimal
-size. This is equivalent to the mean ratio for isotropic sizes.
-
-The mean ratio is expressed as:
-
-For tetrahedrons:
-
- eta = 12 * ( ( 3*Volume ) ^ (2/3) ) / ( sum(edgeLength^2) )
-
-or equivalently:
-
- eta ^ 3 = 15552 * (Volume) ^ 2 / ( sum(edgeLength^2) ) ^ 3
-
-For triangles:
-
- eta ^ 2 = 48 * ( Area ^ 2 ) / ( sum(edgeLength^2) ) ^ 2
-
-This ensures ratios ranging from 0 (flat element) to 1 (equilateral)
-
-------------------------------------------------------------------- */
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class orientedMeanRatioEvaluator : public meanRatioEvaluator
- {
- public:
- orientedMeanRatioEvaluator(const DiscreteSF * f);
- virtual ~orientedMeanRatioEvaluator() {}
-
- virtual evaluationType getType () const {return ORIENTEDMEANRATIO;}
- virtual std::string getName () const {return "Oriented mean ratio";}
-
- protected:
- virtual int XYZ_F_shape(const double[3][3], const pMSize pS, const double normal[3], double * result) const;
- virtual int XYZ_R_shape(const double[4][3], const pMSize pS, double * result) const;
- };
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/repositioning/GeoMatcher.cc b/Adapt/repositioning/GeoMatcher.cc
deleted file mode 100644
index 2c33cf9..0000000
--- a/Adapt/repositioning/GeoMatcher.cc
+++ /dev/null
@@ -1,135 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "GeoMatcher.h"
-#include "CallBackManager.h"
-#include "MathUtils.h"
-#include "ModelInterface.h"
-#include "MAdMessage.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void GeoMatcherCBFunction (pPList before, pPList after, void * data,
- operationType type , pEntity ppp)
- {
-#ifdef _HAVE_GMSH_
- geoMatcher * gm = (geoMatcher *)(data);
-
- switch (type) {
- case MAd_ESPLIT: {
-
- if ( gm->relocationsComputed() ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Applying an edge split during a geometry snapping procedure");
- }
-
- // if new point is on a line or surface, you need to find its
- // projection on the geometrical entity and impose its new
- // location as a Dirichlet BC in the elastic model
-
- pGEntity pGE = V_whatIn( (pVertex)ppp );
- int dimBnd = GEN_type(pGE);
- if ( dimBnd < 3 ) {
-
- double xyz[3]; // current position of the new point
- V_coord( (pVertex)ppp, xyz );
-// printVec(xyz,"Original location");
-
- double u,v;
- if ( !V_params((pVertex)ppp,&u,&v) ) {
- V_info((pVertex)ppp);
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Not a parametric point");
- }
-
- double tgt[3]; // the target location
- switch (dimBnd) {
- case 2: { // on a surface
- GF_xyz((pGFace)pGE, u, v, tgt);
- break;
- }
- case 1: { // on a line
- GE_xyz((pGEdge)pGE, u, tgt);
- break;
- }
- default: {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Unexpected geometric entity dimension for a new vertex: %d",
- dimBnd);
- }
- }
-// printVec(tgt,"Target location");
-
- // compute the difference with the current position
- double dx[3];
- diffVec(tgt,xyz,dx);
-// printVec(dx,"DISPLACEMENT");
-
- // impose the motion as a Dirichlet BC in the elastic model
- smallVector dxVec(3);
- for (int i=0; i<3; i++) dxVec(i) = dx[i];
- gm->addDirichlet( (pVertex)ppp, dxVec );
- }
- break;
- }
- case MAd_ECOLLAPSE: {
- gm->delDirichlet( (pVertex)ppp );
- gm->delRelocation( (pVertex)ppp );
- break;
- }
- case MAd_FSWAP:
- case MAd_ESWAP: {
- break;
- }
- case MAd_RREMOVE: {
- throw; // some nodes could become parametric: to be checked
- void * temp = NULL;
- while ( pEntity pE = PList_next(before,&temp) ) {
- if ( EN_type(pE) == 0 ) {
- gm->delDirichlet( (pVertex)pE );
- }
- }
- break;
- }
- default: {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Callback function not implemented for mesh modification %d",
- type);
- }
- }
-#endif
- }
-
- // -------------------------------------------------------------------
- geoMatcher::geoMatcher(pMesh _mesh):
- MAdElasticityOp(_mesh)
- {
- CallBackManagerSgl::instance().registerCallBack(GeoMatcherCBFunction,this);
- }
-
- // -------------------------------------------------------------------
- geoMatcher::geoMatcher(const geoMatcher& gm):
- MAdElasticityOp(gm)
- {
- CallBackManagerSgl::instance().registerCallBack(GeoMatcherCBFunction,this);
- }
-
- // -------------------------------------------------------------------
- geoMatcher::~geoMatcher()
- {
- CallBackManagerSgl::instance().unregisterCallBack(GeoMatcherCBFunction,this);
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/repositioning/GeoMatcher.h b/Adapt/repositioning/GeoMatcher.h
deleted file mode 100644
index 79e4b71..0000000
--- a/Adapt/repositioning/GeoMatcher.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_GEOMATCHER
-#define _H_GEOMATCHER
-
-#include "MAdElasticityOp.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class geoMatcher: public MAdElasticityOp
- {
-
- public:
-
- geoMatcher(pMesh);
- geoMatcher(const geoMatcher&);
- ~geoMatcher();
-
- };
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/repositioning/LaplaceSmoothingOp.cc b/Adapt/repositioning/LaplaceSmoothingOp.cc
deleted file mode 100644
index 872c794..0000000
--- a/Adapt/repositioning/LaplaceSmoothingOp.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "LaplaceSmoothingOp.h"
-#include "VertexMoveOp.h"
-#include "MeshParametersManager.h"
-#include "MathUtils.h"
-
-#include <vector>
-using std::vector;
-#include <math.h>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- LaplaceSmoothingOp::LaplaceSmoothingOp(pMesh m, DiscreteSF * sf):
- nodesRepositioningOp(m,sf)
- {}
-
- // -------------------------------------------------------------------
- int LaplaceSmoothingOp::run(double * L2Norm)
- {
- return run(OPTIMAL,L2Norm);
- }
-
- // -------------------------------------------------------------------
- int LaplaceSmoothingOp::run(LaplSmooType type, double * L2Norm)
- {
- *L2Norm = 0.0;
-
- vertexMoveOp * vMove = new vertexMoveOp(mesh,sizeField,true);
-
- VIter vit = M_vertexIter(mesh);
- while( pVertex pv = VIter_next(vit) ) {
-
- if ( V_whatInType(pv) != dim ) continue;
-
- double ori[3];
- V_coord(pv,ori);
-
- double opt[3];
- if ( type == OPTIMAL ) {
- if (vMove->computeOptimalLocation(pv, opt)) vMove->setPosition(pv, opt);
- } else {
- V_cavityCenter(pv,opt);
- vMove->setPosition(pv, opt);
- }
-
- double worst;
- if( vMove->evaluate(&worst) ) {
- vMove->apply();
- double disp[3];
- diffVec(ori,opt,disp);
- *L2Norm += dotProd(disp,disp);
- }
-
- vMove->resetDisplacements();
- }
-
- return 1;
- }
-
- // -------------------------------------------------------------------
-
-}
-
diff --git a/Adapt/repositioning/LaplaceSmoothingOp.h b/Adapt/repositioning/LaplaceSmoothingOp.h
deleted file mode 100644
index ce4804d..0000000
--- a/Adapt/repositioning/LaplaceSmoothingOp.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_LAPLACESMOOTHINGOP
-#define _H_LAPLACESMOOTHINGOP
-
-#include "NodesRepositioningOp.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- enum LaplSmooType {
- FAST,
- OPTIMAL
- };
-
- // -------------------------------------------------------------------
- class LaplaceSmoothingOp : public nodesRepositioningOp {
-
- public:
-
- LaplaceSmoothingOp(pMesh m, DiscreteSF * sf);
- ~LaplaceSmoothingOp() {}
-
- public:
-
- virtual int run(double * L2Norm);
- virtual int run(LaplSmooType type, double * L2Norm);
-
- };
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/repositioning/MAdElasticityOp.cc b/Adapt/repositioning/MAdElasticityOp.cc
deleted file mode 100644
index a5a23c1..0000000
--- a/Adapt/repositioning/MAdElasticityOp.cc
+++ /dev/null
@@ -1,947 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MAdElasticityOp.h"
-#include "CPUTimeManager.h"
-#include "OperatorTools.h"
-#include "MathUtils.h"
-#include "MAdOutput.h"
-#include "CallBackManager.h"
-
-#include <iostream>
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::make_pair;
-using std::map;
-using std::set;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void ElasticityOpCBFunction (pPList before, pPList after, void * data,
- operationType type , pEntity ppp)
- {
- MAdElasticityOp * elast = (MAdElasticityOp *)(data);
- if ( !(elast->relocationsComputed()) ) return;
-
- switch (type) {
- case MAd_ESPLIT: {
-
- // find the old edge
- void * temp = NULL;
- pEntity pE = PList_next(before,&temp);
-
- // take the interpolated displacements between the extremities
- // of the edge for the new vertex
- elast->addVertexOnEdge( (pVertex)ppp, (pEdge)pE );
-
- break;
- }
- case MAd_ECOLLAPSE: {
- elast->removeVertex( (pVertex)ppp );
- break;
- }
- case MAd_FSWAP:
- case MAd_ESWAP: {
- break;
- }
- case MAd_RREMOVE: {
- void * temp = NULL;
- while ( pEntity pE = PList_next(before,&temp) ) {
- if ( EN_type(pE) == 0 ) {
- elast->removeVertex( (pVertex)pE );
- }
- }
- break;
- }
- default: {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Callback function not implemented for mesh modification %d",
- type);
- }
- }
- }
-
- // -------------------------------------------------------------------
- MAdElasticityOp::MAdElasticityOp(pMesh m):
- mesh(m), E(1.), nu(0.45), chi(1.0), computed(false),
- cavityEqualMesh(false), cavityThickness(3)
- {
- dim = M_dim(mesh);
- CallBackManagerSgl::instance().registerCallBack(ElasticityOpCBFunction,this);
- }
-
- // -------------------------------------------------------------------
- MAdElasticityOp::MAdElasticityOp(const MAdElasticityOp& eop):
- mesh(eop.mesh), dim(eop.dim),
- E(eop.E), nu(eop.nu), chi(eop.chi),
- computed(eop.computed),
- cavityEqualMesh(eop.cavityEqualMesh),
- cavityThickness(eop.cavityThickness)
- {
- localIds = eop.localIds;
- dirichlet = eop.dirichlet;
- CallBackManagerSgl::instance().registerCallBack(ElasticityOpCBFunction,this);
- }
-
- // -------------------------------------------------------------------
- MAdElasticityOp::~MAdElasticityOp()
- {
- CallBackManagerSgl::instance().unregisterCallBack(ElasticityOpCBFunction,this);
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::setMaterials(double _E, double _nu)
- {
- E = _E; nu = _nu;
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::setStiffnessAlterationCoef(double _chi)
- {
- chi = _chi;
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::clear()
- {
- localIds.clear();
- cavity.clear();
- dirichlet.clear();
- relocations.clear();
- computed = false;
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::buildCavity()
- {
- computed = false;
-
- if ( cavityEqualMesh ) return;
-
- int nVertInit = dirichlet.size();
-
- cavity.clear();
-
- if ( cavityThickness < 1 ) return;
-
- set<pVertex> innerNodes; // nodes inside the cavity and dirichlet
- set<pRegion> prevLayer;
-
- // --- first layer ---
- pRegion pr;
- pVertex pv;
- map<pVertex,smallVector>::const_iterator dIter = dirichlet.begin();
- for (; dIter != dirichlet.end(); dIter++) {
- pv = (*dIter).first;
- pPList vRegs = V_regions(pv);
- void * temp = NULL;
- while ( ( pr = (pRegion)PList_next(vRegs,&temp) ) ) {
- cavity.insert(pr);
- prevLayer.insert(pr);
- }
- PList_delete(vRegs);
- innerNodes.insert(pv);
- }
-
- // --- next layers ---
- for (int iL=1; iL < cavityThickness; iL++) {
- set<pRegion> curLayer;
- set<pRegion>::const_iterator rIter = prevLayer.begin();
- for (; rIter != prevLayer.end(); rIter++ ) {
- pPList rVerts = R_vertices(*rIter);
- void * temp = NULL;
- while ( ( pv = (pVertex)PList_next(rVerts,&temp) ) ) {
- if ( innerNodes.find(pv) == innerNodes.end() ) {
- pPList vRegs = V_regions(pv);
- void * temp = NULL;
- while ( ( pr = (pRegion)PList_next(vRegs,&temp) ) ) {
- if ( cavity.find(pr) == cavity.end() ) {
- cavity.insert(pr);
- curLayer.insert(pr);
- }
- }
- PList_delete(vRegs);
- innerNodes.insert(pv);
- }
- }
- PList_delete(rVerts);
- }
- prevLayer.clear();
- prevLayer.insert(curLayer.begin(),curLayer.end());
- curLayer.clear();
- }
-
- printf("Built a cavity with %d elements, dirichlet size: %d\n",cavity.size(),dirichlet.size());
-
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::setHomogDirichletBC()
- {
- dirichlet.clear();
- setDirichletBC();
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::setDirichletBC()
- {
- computed = false;
- smallVector zero(3); zero.set_all(0.);
-
- set<pVertex> verts;
- collectBCVertices(&verts);
-
- set<pVertex>::const_iterator vIter = verts.begin();
- set<pVertex>::const_iterator vLast = verts.end();
- for (; vIter != vLast; vIter++) {
- addDirichlet(*vIter,zero);
- }
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::collectBCVertices(set<pVertex> * bcVerts)
- {
- if ( cavityEqualMesh )
- {
- FIter fit = M_faceIter(mesh);
- while ( pFace pf = FIter_next(fit) ) {
- if ( EN_whatInType((pEntity)pf) == 2 ) {
- pPList fV = F_vertices(pf,1);
- void* tmp=0;
- while ( pVertex pv = (pVertex)PList_next(fV,&tmp) ) {
- (*bcVerts).insert(pv);
- }
- PList_delete(fV);
- }
- }
- FIter_delete(fit);
- }
- else
- {
- set<pRegion>::const_iterator cavIter = cavity.begin();
- for (; cavIter != cavity.end(); cavIter++) {
- pPList rFaces = R_faces(*cavIter);
- void * temp = NULL;
- pFace pf;
- while ( ( pf = (pFace)PList_next(rFaces,&temp) ) ) {
- pRegion otherR = F_otherRegion(pf,*cavIter);
- if ( !otherR || cavity.find(otherR) == cavity.end() ) {
- pPList fVerts = F_vertices(pf,1);
- void * temp2 = NULL;
- pVertex pv;
- while ( ( pv = (pVertex)PList_next(fVerts,&temp2) ) ) {
- (*bcVerts).insert(pv);
- }
- PList_delete(fVerts);
- }
- }
- PList_delete(rFaces);
- }
- }
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::addDirichlet(pVertex pv, smallVector& dxyz)
- {
- map<pVertex,smallVector>::iterator dIter = dirichlet.find(pv);
- if ( dIter != dirichlet.end() ) {
- smallVector dxyz1 = (*dIter).second;
- dxyz1.add(dxyz);
- dirichlet.erase(dIter);
- dirichlet.insert(make_pair(pv,dxyz1));
- }
- else {
- dirichlet.insert(make_pair(pv,dxyz));
- }
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::delDirichlet(pVertex pv)
- {
- map<pVertex,smallVector>::iterator dIter = dirichlet.find(pv);
- if ( dIter != dirichlet.end() ) {
- dirichlet.erase(dIter);
- }
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::delRelocation(pVertex pv)
- {
- map<pVertex,smallVector>::iterator dIter = relocations.find(pv);
- if ( dIter != relocations.end() ) {
- relocations.erase(dIter);
- }
- }
-
- // -------------------------------------------------------------------
- // Generates table of vertex pointers to local ids and returns number
- // of vertices in the cavity.
- int MAdElasticityOp::generateVertexIds()
- {
- computed = false;
- localIds.clear();
-
- int id = 0;
-
- if (cavityEqualMesh) {
- VIter vit = M_vertexIter(mesh);
- while ( pVertex pv = VIter_next(vit) ) {
- localIds[pv] = id;
- id++;
- }
- VIter_delete(vit);
- }
- else {
- set<pVertex> verts;
- set<pRegion>::const_iterator cavIter = cavity.begin();
- for (; cavIter != cavity.end(); cavIter++) {
- pPList rVerts = R_vertices(*cavIter);
- void * temp = NULL;
- while ( pVertex pv = (pVertex)PList_next(rVerts,&temp) ) {
- if ( verts.find(pv) == verts.end() ) {
- localIds[pv] = id;
- id++;
- verts.insert(pv);
- }
- }
- PList_delete(rVerts);
- }
- }
- return id;
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::addToMatrix(const pRegion pr,
- int nbVert,
- MAdLinearSystemDef * lsys)
- {
- int rNodes = R_numVertices(pr);
- int locSyze = rNodes*dim;
-
- smallMatrix locK(locSyze,locSyze);
- element3DMatrix(pr, locK);
-
- pPList vertsI = R_vertices(pr);
- pPList vertsJ = R_vertices(pr);
- void* tmpI = 0;
- int i = 0;
- while ( pVertex pvI = (pVertex)PList_next(vertsI,&tmpI) ) {
-
- int locIdI = localIds[pvI];
-
- void* tmpJ = 0;
- int j = 0;
- while ( pVertex pvJ = (pVertex)PList_next(vertsJ,&tmpJ) ) {
-
- int locIdJ = localIds[pvJ];
-
- for (int k=0; k<dim; k++) {
- for (int l=0; l<dim; l++) {
- lsys->addToMatrix(nbVert*k + locIdI, nbVert*l+locIdJ, locK(k*rNodes+i,l*rNodes+j));
- }
- }
- j++;
- }
- i++;
- }
- PList_delete(vertsI);
- PList_delete(vertsJ);
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::allocateMatrix(int nbVert, MAdLinearSystemDef * lsys)
- {
- if (cavityEqualMesh) {
- VIter vit2 = M_vertexIter(mesh);
- while ( pVertex pv2 = VIter_next(vit2) ) {
- int locId = localIds[pv2];
- int nbNeighbors = V_numEdges(pv2);
- for (int iDir=0; iDir<3; iDir++) {
- int row = nbVert*iDir + locId;
- lsys->set_nnz(row,(nbNeighbors+1)*3);// A node is coupled with all its neighbors, and don't forget himself
- }
- }
- VIter_delete(vit2);
- }
- else {
- map<pVertex,set<pVertex> > conn;
- set<pRegion>::const_iterator cIter = cavity.begin();
- for (; cIter != cavity.end(); cIter++) {
- pPList rEdges = R_edges(*cIter);
- void * temp = NULL;
- pEdge edge;
- pVertex v0, v1;
- while ( ( edge = (pEdge)PList_next(rEdges,&temp)) ) {
- v0 = E_vertex(edge,0);
- v1 = E_vertex(edge,1);
- conn[v0].insert(v1);
- conn[v1].insert(v0);
- }
- PList_delete(rEdges);
- }
-
- pVertex pv;
- map<pVertex,set<pVertex> >::const_iterator conIter = conn.begin();
- for (; conIter != conn.end(); conIter++) {
- pv = conIter->first;
- int locId = localIds[pv];
- int nbNeighbors = conIter->second.size();
- for (int iDir=0; iDir<3; iDir++) {
- int row = nbVert*iDir + locId;
- lsys->set_nnz(row,(nbNeighbors+1)*3);// A node is coupled with all its neighbors, and don't forget himself
- }
- }
- }
-
- lsys->allocate_matrix();
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::addVertexOnEdge(pVertex pv, pEdge pe)
- {
- if ( computed == true )
- {
- double t = E_linearParams(pe,pv);
-
- smallVector dx0, dx1;
- for (int i=0; i<2; i++)
- {
- pVertex vi = E_vertex(pe,i);
- std::map<pVertex,smallVector >::iterator iter = relocations.find(pv);
- if ( iter != relocations.end() ) {
- if (i==0) dx0 = (*iter).second;
- else dx1 = (*iter).second;
- }
- else return;
- }
- smallVector newDx(3);
- for (int i=0; i<3; i++) newDx(i) = (1.-t) * dx0(i) + t * dx1(i);
- relocations[pv] = newDx;
- }
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::removeVertex(pVertex pv)
- {
- if ( computed == true )
- {
- std::map<pVertex,smallVector >::iterator iter = relocations.find(pv);
- if ( iter != relocations.end() ) {
- relocations.erase(iter);
- }
- }
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::setVertexResult(int nbVert, pVertex pv,
- const MAdLinearSystemDef * lsys)
- {
- // get the vertex id
- map<pVertex,int>::const_iterator itId = localIds.find(pv);
- int id = (*itId).second;
-
- // get the dx
- smallVector dX(3);
- for (int iDir=0; iDir<3; iDir++) {
- int row = nbVert*iDir + id;
- dX(iDir) = lsys->getFromSolution(row);
- }
-
- relocations[pv] = dX;
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::setResults(int nbVert,
- const MAdLinearSystemDef * lsys)
- {
- relocations.clear();
-
- if (cavityEqualMesh) {
- pVertex pv;
- VIter vit = M_vertexIter(mesh);
- while ( ( pv = VIter_next(vit) ) ) {
- setVertexResult(nbVert,pv,lsys);
- }
- VIter_delete(vit);
- }
- else {
- set<pVertex> vertices;
- set<pRegion>::const_iterator cIter = cavity.begin();
- for (; cIter != cavity.end(); cIter++) {
- pPList rVerts = R_vertices(*cIter);
- void * temp = NULL;
- pVertex pv;
- while ( ( pv = (pVertex)PList_next(rVerts,&temp) ) ) {
- vertices.insert(pv);
- }
- PList_delete(rVerts);
- }
-
- set<pVertex>::const_iterator vIter = vertices.begin();
- for (; vIter != vertices.end(); vIter++) {
- setVertexResult(nbVert,*vIter,lsys);
- }
- }
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::printRelocations(std::ostream& out) const
- {
- out << "Printing relocation: "<<relocations.size()<<" vertices relocated\n";
- std::map<pVertex,smallVector>::const_iterator iter = relocations.begin();
- for(; iter != relocations.end(); iter++)
- {
- pVertex pv = (*iter).first;
- int id = EN_id(pv);
- pGEntity ge = V_whatIn(pv);
- int gdim = GEN_type(ge);
- int gtag = GEN_tag(ge);
- smallVector dX = (*iter).second;
- out <<"Vertex "<<pv<<" with id "<<id<<" and class ("<<gdim<<","<<gtag<<"): "<<dX(0)<<" "<<dX(1)<<" "<<dX(2)<<"\n";
- }
-
- out << "Printed relocation: "<<relocations.size()<<" vertices relocated\n";
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::printDirichlet(std::ostream& out) const
- {
- out << "Printing dirichlet BCs: "<<dirichlet.size()<<" vertices\n";
- std::map<pVertex,smallVector>::const_iterator iter = dirichlet.begin();
- for(; iter != dirichlet.end(); iter++)
- {
- pVertex pv = (*iter).first;
- int id = EN_id(pv);
- pGEntity ge = V_whatIn(pv);
- int gdim = GEN_type(ge);
- int gtag = GEN_tag(ge);
- smallVector dX = (*iter).second;
- out <<"Vertex "<<pv<<" with id "<<id<<" and class ("<<gdim<<","<<gtag<<"): "<<dX(0)<<" "<<dX(1)<<" "<<dX(2)<<"\n";
- }
-
- out << "Printed dirichlet BCs: "<<dirichlet.size()<<" vertices\n";
- }
-
- // -------------------------------------------------------------------
- int MAdElasticityOp::compute()
- {
- CPUTimeManager& tm = CPUTimeManagerSgl::instance();
-
- relocations.clear();
-
- // --------------------------------------------
- // If there is no element in the cavity, just
- // prescribed node relocations (dirichlet) ...
- // --------------------------------------------
- if ( !cavityEqualMesh && cavity.empty() ) {
- MAdMsgSgl::instance().info(__LINE__,__FILE__,
- "Empty cavity for elastic computation");
- relocations = dirichlet;
- }
-
- // --------------------------------------------------
- // ... if an elastic computation has to be performed
- // --------------------------------------------------
- else {
-
- if ( dim != 3 ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Elasticity model only implemented for dimension 3, current dimension is %d",
- dim);
- }
-
- MeshQualityManagerSgl::instance().evaluateSizes(); // required for detJ0
-
- // --- produce the mapping pVertex -> localId ---
- int nbVert = generateVertexIds();
-
- // --- create the linear system ---
- double t_sys0 = tm.getTime();
- int sysSize = dim * nbVert;
- MAdLinearSystemDef * lsys = new MAdLinearSystemDef();
- lsys->allocate(sysSize);
-
- lsys->setSolver(CG);
- lsys->setFillIn(4);
- lsys->setEps(1.e-12);
-
- lsys->setPrec(1.e-12); // for gmm only
- lsys->setNoisy(1); // for gmm only
-
- // --- allocate the matrix ---
- allocateMatrix(nbVert,lsys); // for PETSc only
-
- lsys->zeroMatrix();
- lsys->zeroRightHandSide();
-
- double dt_sys = tm.getTime() - t_sys0;
- MAdMsgSgl::instance().info(-1,__FILE__,
- "Created the system in %f seconds",dt_sys);
-
- // --- assemble the matrix ---
- double t_ass0 = tm.getTime();
- if (cavityEqualMesh) {
- RIter rit = M_regionIter(mesh);
- while ( pRegion pr = RIter_next(rit) ) addToMatrix(pr,nbVert,lsys);
- RIter_delete(rit);
- }
- else {
- set<pRegion>::const_iterator cavIter = cavity.begin();
- for (; cavIter != cavity.end(); cavIter++) addToMatrix(*cavIter,nbVert,lsys);
- }
- double dt_ass = tm.getTime() - t_ass0;
- MAdMsgSgl::instance().info(-1,__FILE__,
- "Assembled the matrix in %f seconds",dt_ass);
-
- // --- apply bc (ugly but it works hum) ---
- double t_bc0 = tm.getTime();
- map<pVertex,smallVector>::iterator dIter = dirichlet.begin();
- map<pVertex,smallVector>::iterator dLast = dirichlet.end();
- for (; dIter != dLast; dIter++) {
-
- pVertex pv = (*dIter).first;
- smallVector dxyz = (*dIter).second;
-
- // get the vertex id
- map<pVertex,int>::const_iterator itId = localIds.find(pv);
- int id = (*itId).second;
-
- for (int iDir=0; iDir<3; iDir++) {
- int row = nbVert*iDir + id;
- const double BIG = /*lsys->getFromMatrix(row,row) * */1.e12;
- lsys->addToMatrix(row,row,BIG);
- lsys->addToRightHandSide(row,BIG * dxyz(iDir));
- }
-
- }
- double dt_bc = tm.getTime() - t_bc0;
- MAdMsgSgl::instance().info(-1,__FILE__,
- "Applied boundary conditions in %f seconds",dt_bc);
-
- // --- reorder matrix ---
- lsys->reorder();
-
- // --- solve the system ---
- double t_slv0 = tm.getTime();
- int converged = lsys->systemSolve();
- double dt_slv = tm.getTime() - t_slv0;
- MAdMsgSgl::instance().info(-1,__FILE__,
- "Solved the elastic system (convergence flag: %d) in %f seconds",
- converged,dt_slv);
-
-
- // --- fill relocations with the results ---
- setResults(nbVert,lsys);
-
- localIds.clear();
- delete lsys;
- }
-
- dirichlet.clear();
- cavity.clear();
-
- computed = true;
-
- return 1;
- }
-
-
- // -------------------------------------------------------------------
- bool MAdElasticityOp::checkArea(const pFace pf, double ratio)
- {
- bool inCavity = false;
-
- double fxyz[3][3];
- F_coordP1(pf,fxyz);
- double oriNorm[3];
- XYZ_F_normal(fxyz,oriNorm);
-
- pPList fVerts = F_vertices(pf,1);
- void * temp = NULL;
- int i = 0;
- pVertex pv;
- while ( ( pv = (pVertex)PList_next(fVerts,&temp) ) ) {
- std::map<pVertex,smallVector>::const_iterator iter = relocations.find(pv);
- if ( iter != relocations.end() ) {
- inCavity = true;
- for (int j=0; j<3; j++) fxyz[i][j] += ratio * (*iter).second(j);
- }
- i++;
- }
- PList_delete(fVerts);
-
- // Do the check only if one of the nodes moved
- if ( inCavity ) {
- double tgtNorm[3];
- XYZ_F_normal(fxyz,tgtNorm);
- double prod = oriNorm[0] * tgtNorm[0] + oriNorm[1] * tgtNorm[1] + oriNorm[2] * tgtNorm[2];
- if ( prod <= 0. ) return false;
- }
-
- return true;
- }
-
- // -------------------------------------------------------------------
- // Cannot use 'cavity': it is hard to maintain if mesh modifications
- // occur during advancement so it is cleared in 'compute()'.
- bool MAdElasticityOp::checkAreas(double ratio)
- {
- pFace pf;
- FIter fit = M_faceIter(mesh);
- while ( ( pf = FIter_next(fit) ) ) {
- if ( !checkArea(pf,ratio) ) {
- FIter_delete(fit);
- return false;
- }
- }
- FIter_delete(fit);
-
- return true;
- }
-
- // -------------------------------------------------------------------
- bool MAdElasticityOp::checkVolume(const pRegion pr, double ratio)
- {
- bool inCavity = false;
-
- double rxyz[4][3];
- R_coordP1(pr,rxyz);
-
- pPList rVerts = R_vertices(pr);
- void * temp = NULL;
- int i = 0;
- pVertex pv;
- while ( ( pv = (pVertex)PList_next(rVerts,&temp) ) ) {
- std::map<pVertex,smallVector>::const_iterator iter = relocations.find(pv);
- if ( iter != relocations.end() ) {
- inCavity = true;
- for (int j=0; j<3; j++) rxyz[i][j] += ratio * (*iter).second(j);
- }
- i++;
- }
- PList_delete(rVerts);
-
- // Do the check only if one of the nodes moved
- if ( inCavity && R_XYZ_volume(rxyz) <= MAdTOL ) return false;
-
- return true;
- }
-
- // -------------------------------------------------------------------
- // Cannot use 'cavity': it is hard to maintain if mesh modifications
- // occur during advancement so it is cleared in 'compute()'.
- bool MAdElasticityOp::checkVolumes(double ratio)
- {
- pRegion pr;
- RIter rit = M_regionIter(mesh);
- while ( ( pr = RIter_next(rit) ) ) {
- if ( !checkVolume(pr,ratio) ) {
- RIter_delete(rit);
- return false;
- }
- }
- RIter_delete(rit);
-
- return true;
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::relocate(double ratio)
- {
- pVertex pv;
- double xyz[3];
-
- std::map<pVertex,smallVector>::const_iterator iter = relocations.begin();
- for(; iter != relocations.end(); iter++)
- {
- pv = (*iter).first;
- V_coord(pv,xyz);
-
- smallVector dX = (*iter).second;
-
- xyz[0] += ratio * dX(0);
- xyz[1] += ratio * dX(1);
- xyz[2] += ratio * dX(2);
- if ( !V_setPosition(pv,xyz) ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Could not relocate a node");
-
- }
- }
- }
-
- // -------------------------------------------------------------------
- // Advances the relocation as far as possible
- // Returns:
- // - 0: no relocation possible
- // - 1: advanced but not to the final position
- // - 2: reached the full prescribed relocation
- int MAdElasticityOp::advance(double * ratio, double tolerance)
- {
- if ( *ratio >= 1.-tolerance ) {
- *ratio = 1.;
- return 2;
- }
-
- int achieved = 0; // the result returned
-
- int subIter = 0;
- const int nbMaxIter = 6;
-
- double margin = 1. - *ratio; // in [0;1] : the rest of the motion to be performed
- double curRatio = 1.; // in [0;1] : the part of the margin that will be tested next
- double delta = 0.5; // in [0;1] : the increment/decrement of ratio at next iteration
- double best = -1.; // in [0;1] : the best current ratio with positive volumes
-
- while ( subIter < nbMaxIter )
- {
- double totalAdvancement = curRatio * margin + *ratio;
- bool check;
- if ( dim == 3 ) check = checkVolumes( curRatio * margin );
- else check = checkAreas ( curRatio * margin );
- if ( !check ) {
- curRatio -= delta;
- }
- else {
- best = curRatio;
- if ( totalAdvancement + tolerance >= 1. ) { achieved = 2; break; }
- else { achieved = 1; curRatio += delta; }
- }
-
- subIter++;
- delta *= 0.5;
-// printf("Ratio: %f, margin: %f, achieved: %d, subIter: %d, best: %f, curRatio: %f, delta: %f\n",
-// *ratio, margin, achieved, subIter, best, curRatio, delta);
- }
-
- double moveRatio = 0.;
- if ( achieved == 2 ) {
- moveRatio = ( 1. - *ratio );
- relocate(moveRatio);
- *ratio = 1.;
- }
- else if ( achieved == 1 ) {
- moveRatio = best * margin;
- relocate(moveRatio);
- *ratio += moveRatio;
- }
-
- return achieved;
- }
-
- // -------------------------------------------------------------------
- // Force the relocation even if it leads to negative volumes
- void MAdElasticityOp::forceRelocation()
- {
- relocate(1.);
- }
-
- // -------------------------------------------------------------------
- void MAdElasticityOp::element3DMatrix(pRegion pr, smallMatrix& m) const
- {
- int nbNodes = 4;
- double xyz[4][3];
- R_coordP1(pr,xyz);
-
- double FACT = E / (1 + nu);
- double C11 = FACT * (1 - nu) / (1 - 2 * nu);
- double C12 = FACT * nu / (1 - 2 * nu);
- double C44 = (C11 - C12) / 2;
- const double C[6][6] =
- { {C11, C12, C12, 0, 0, 0},
- {C12, C11, C12, 0, 0, 0},
- {C12, C12, C11, 0, 0, 0},
- { 0, 0, 0, C44, 0, 0},
- { 0, 0, 0, 0, C44, 0},
- { 0, 0, 0, 0, 0, C44} };
-
- smallMatrix H (6,6);
- for (int i=0;i<6;i++)
- for (int j=0;j<6;j++)
- H(i,j) = C[i][j];
-
- smallMatrix B (6,3*nbNodes);
- smallMatrix BTH (3*nbNodes,6);
- smallMatrix BT (3*nbNodes,6);
-
- const double gradShpFct[4][3] =
- { {-1., -1., -1.},
- { 1., 0., 0.},
- { 0., 1., 0.},
- { 0., 0., 1.} };
-
- double jac [3][3];
- jac[0][0] = jac[0][1] = jac[0][2] = 0.;
- jac[1][0] = jac[1][1] = jac[1][2] = 0.;
- jac[2][0] = jac[2][1] = jac[2][2] = 0.;
- for(int i = 0; i < nbNodes; i++) {
- jac[0][0] += xyz[i][0] * gradShpFct[i][0]; jac[0][1] += xyz[i][1] * gradShpFct[i][0]; jac[0][2] += xyz[i][2] * gradShpFct[i][0];
- jac[1][0] += xyz[i][0] * gradShpFct[i][1]; jac[1][1] += xyz[i][1] * gradShpFct[i][1]; jac[1][2] += xyz[i][2] * gradShpFct[i][1];
- jac[2][0] += xyz[i][0] * gradShpFct[i][2]; jac[2][1] += xyz[i][1] * gradShpFct[i][2]; jac[2][2] += xyz[i][2] * gradShpFct[i][2];
- }
- const double detJ = fabs(jac[0][0] * jac[1][1] * jac[2][2] + jac[0][2] * jac[1][0] * jac[2][1] +
- jac[0][1] * jac[1][2] * jac[2][0] - jac[0][2] * jac[1][1] * jac[2][0] -
- jac[0][0] * jac[1][2] * jac[2][1] - jac[0][1] * jac[1][0] * jac[2][2]);
-
- double invjac [3][3];
- inverseMat (jac, invjac) ;
-
- double Grads[4][3];
-
- B.set_all(0.0);
- BT.set_all(0.0);
-
- for (int j=0;j<nbNodes;j++){
-
- Grads[j][0] = invjac[0][0] * gradShpFct[j][0] + invjac[0][1] * gradShpFct[j][1] + invjac[0][2] * gradShpFct[j][2];
- Grads[j][1] = invjac[1][0] * gradShpFct[j][0] + invjac[1][1] * gradShpFct[j][1] + invjac[1][2] * gradShpFct[j][2];
- Grads[j][2] = invjac[2][0] * gradShpFct[j][0] + invjac[2][1] * gradShpFct[j][1] + invjac[2][2] * gradShpFct[j][2];
-
- BT(j,0) = B(0,j) = Grads[j][0];
- BT(j,3) = B(3,j) = Grads[j][1];
- BT(j,4) = B(4,j) = Grads[j][2];
-
- BT(j+nbNodes,1) = B(1,j+nbNodes) = Grads[j][1];
- BT(j+nbNodes,3) = B(3,j+nbNodes) = Grads[j][0];
- BT(j+nbNodes,5) = B(5,j+nbNodes) = Grads[j][2];
-
- BT(j+2*nbNodes,2) = B(2,j+2*nbNodes) = Grads[j][2];
- BT(j+2*nbNodes,4) = B(4,j+2*nbNodes) = Grads[j][0];
- BT(j+2*nbNodes,5) = B(5,j+2*nbNodes) = Grads[j][1];
- }
-
- BTH.set_all(0.0);
- BTH.blas_dgemm (BT,H);
-
- m.set_all(0.0);
- m.blas_dgemm (BTH,B,detJ,1.0);
-
- // --- Selective element stiffening ---
- // reference:
- // Stein, Tezduyar, Benney "Mesh Moving Techniques for FSI with Large Displacement", ASME, 2003.
-
- double detJ0 = MeshQualityManagerSgl::instance().getMaxSize();
- if ( detJ0 <= 0. ) detJ0 = 1.;
-
- double scaleFactor = pow( detJ0 / detJ, chi);
- if ( scaleFactor > 1.e12 || scaleFactor < 1.e-12 ) {
- cout <<"Warning in MAdElasticity: scale factor for element stiffness is "<<scaleFactor<<endl;
- }
-
- m.scale ( scaleFactor );
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/repositioning/MAdElasticityOp.h b/Adapt/repositioning/MAdElasticityOp.h
deleted file mode 100644
index 5dd9fa3..0000000
--- a/Adapt/repositioning/MAdElasticityOp.h
+++ /dev/null
@@ -1,144 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MADELASTICITYOP
-#define _H_MADELASTICITYOP
-
-#include "MAdMatrix.h"
-#include "VertexMoveOp.h"
-#include "MAdLinearSystem.h"
-
-#include <map>
-#include <set>
-
-/*
- This operator uses an analogy with an elastic medium in order to compute
- the displacements of the vertices resulting from a prescribed displacement
- of the boundaries.
-
- The steps to make a computation are the following:
-
- 1. Choose a set of nodal displacements by calling 'addDirichlet'
- --> build part of 'dirichlet'
- 2. Build a cavity around the nodes for which you prescribed a displacement
- --> build 'cavity'
- 3. Impose homogenous Dirichlet boudnary conditions to the boundaries
- of the cavity with 'setDirichletBC()' (except the nodes with a
- prescribed displacement)
- --> finish building 'dirichlet'
- 4. Compute the displacements with 'compute'
- --> build 'relocations'
- --> clear 'cavity' and 'dirichlet'
- --> 'computed' set to 'true'
- 5. Apply a part of the displacement to the mesh with 'advance'
- (as much as you can)
- 6. Once nodes are fully relocated, call 'clear'
- --> clear all
- --> computed set to 'false'
-*/
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class MAdElasticityOp {
-
- public:
-
- MAdElasticityOp(pMesh m);
- MAdElasticityOp(const MAdElasticityOp&);
- virtual ~MAdElasticityOp();
-
- public:
-
- void clear();
-
- int meshDim() const { return dim; }
-
- void setMaterials(double _E, double _nu);
- void setStiffnessAlterationCoef(double _chi);
-
- void setCavityEqualMesh(bool _m, int thickness)
- {
- cavityEqualMesh = _m;
- cavityThickness = thickness;
- }
-
- void buildCavity();
-
- void setDirichletBC();
- void setHomogDirichletBC();
- void addDirichlet(pVertex pv, smallVector& dxyz);
- void delDirichlet(pVertex pv);
-
- int compute();
- bool relocationsComputed() const { return computed; }
- void delRelocation(pVertex pv);
-
- int advance(double * ratio, double tolerance=MAdTOL);
- void forceRelocation();
-
- void removeVertex(pVertex);
- void addVertexOnEdge(pVertex, pEdge);
-
- // debugging functions
- void printRelocations(std::ostream& out) const;
- void printDirichlet(std::ostream& out) const;
-
- private:
-
- int generateVertexIds();
- void collectBCVertices(std::set<pVertex> * bcVerts);
-
- void element3DMatrix (pRegion pr, smallMatrix& m) const;
- void addToMatrix(const pRegion, int, MAdLinearSystemDef *);
- void allocateMatrix(int, MAdLinearSystemDef *);
-
- void setVertexResult(int, pVertex, const MAdLinearSystemDef *);
- void setResults(int, const MAdLinearSystemDef *);
-
- bool checkArea(const pFace, double ratio);
- bool checkAreas(double ratio);
- bool checkVolume(const pRegion, double ratio);
- bool checkVolumes(double ratio);
- void relocate(double ratio);
-
- private:
-
- pMesh mesh;
- int dim;
-
- double E, nu;
-
- // exponent of the alteration of stiffness based on elements size:
- // chi=0 => no alteration
- // chi increases => smaller elements stiffer
- double chi;
-
- bool computed;
-
- std::map<pVertex,int> localIds;
-
- bool cavityEqualMesh;
- int cavityThickness;
- std::set<pRegion> cavity;
-
- std::map<pVertex,smallVector > dirichlet;
- std::map<pVertex,smallVector > relocations;
-
- };
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/repositioning/MobileObject.cc b/Adapt/repositioning/MobileObject.cc
deleted file mode 100644
index 77e054c..0000000
--- a/Adapt/repositioning/MobileObject.cc
+++ /dev/null
@@ -1,492 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MobileObject.h"
-#include "NodalDataManager.h"
-
-#include <iostream>
-using std::cerr;
-using std::cout;
-using std::endl;
-#include <string.h>
-using std::set;
-using std::multiset;
-using std::list;
-using std::pair;
-using std::vector;
-using std::string;
-
-namespace MAd {
-
- // ----------------------------------------------------------------------
- mobileObject::mobileObject(const pMesh m, string _name):
- mesh(m),name(_name),prescribeType(""),DxParsed(NULL),
- velType(NOFORMULATION),VParsed(NULL)//, Cxyz(NULL), Vxyz(NULL)
- {
- }
-
- // ----------------------------------------------------------------------
- mobileObject::~mobileObject()
- {
- if (DxParsed) { delete DxParsed; DxParsed = NULL; }
- if (VParsed) { delete VParsed; VParsed = NULL; }
- }
-
- // ----------------------------------------------------------------------
- void mobileObject::setDxKinematics(vector<string> _str)
- {
- if ( strcmp(prescribeType.c_str(),"") ) {
- cerr << "Error: imposing a position on an object with another imposed movement: "<<prescribeType<<"\n";
- throw;
- }
- prescribeType = "Displacement";
-
- if (DxParsed) delete DxParsed;
- DxParsed = new MAdStringFieldEvaluator(_str);
- }
-
- // ----------------------------------------------------------------------
- void mobileObject::setVKinematics(velocityFormulation type, double V[3],
- double C[3], vector<string> _str)
- {
- if ( strcmp(prescribeType.c_str(),"") ) {
- cerr << "Error: imposing a velocity on an object with another imposed movement: "<<prescribeType<<"\n";
- throw;
- }
- prescribeType = "Velocity";
-
- velType = type;
- if ( V ) {
- for (int i=0; i<3; i++) Vxyz[i] = V[i];
- }
- if ( C ) {
- for (int i=0; i<3; i++) Cxyz[i] = C[i];
- }
- if (type == PARSED) VParsed = new MAdStringFieldEvaluator(_str);
- }
-
- // ----------------------------------------------------------------------
- void mobileObject::addLocalSField(LocalSizeField* lsf)
- {
- sizes.insert(lsf);
- }
-
- // ----------------------------------------------------------------------
- void mobileObject::addGEntity(int type, int tag)
- {
- geomEntities.push_back(std::make_pair(type,tag));
- addVerticesOnGEntity(type,tag);
- }
-
- // ----------------------------------------------------------------------
- void mobileObject::reAddVertices()
- {
- vertices.clear();
- list<pair<int,int> >::const_iterator it = geomEntities.begin();
- list<pair<int,int> >::const_iterator itEnd = geomEntities.end();
- for (; it != itEnd; it++) addVerticesOnGEntity(it->first, it->second);
- }
-
- // ----------------------------------------------------------------------
- void mobileObject::addVerticesOnGEntity(int type, int tag)
- {
- switch (type) {
- case 0:
- {
- VIter vit = M_vertexIter(mesh);
- while (pVertex pv = VIter_next(vit))
- {
- pGEntity pg = EN_whatIn((pEntity)pv);
- int pgType = EN_whatInType( (pEntity) pv );
- if(pg)
- if (GEN_tag(pg) == tag && pgType == 0)
- {
- vertices.insert(pv);
- }
- }
- VIter_delete(vit);
- break;
- }
- case 1:
- {
- EIter eit = M_edgeIter(mesh);
- while (pEdge pe = EIter_next(eit))
- {
- pGEntity pg = EN_whatIn((pEntity)pe);
- int pgType = EN_whatInType( (pEntity) pe );
- if(pg)
- if (GEN_tag(pg) == tag && pgType == 1)
- {
- vertices.insert(E_vertex (pe,0));
- vertices.insert(E_vertex (pe,1));
- }
- }
- EIter_delete(eit);
- }
- case 2:
- {
- FIter fit = M_faceIter(mesh);
- while (pFace pf = FIter_next(fit))
- {
- pGEntity pg = EN_whatIn((pEntity)pf);
- int pgType = EN_whatInType( (pEntity) pf );
- if(pg)
- if (GEN_tag(pg) == tag && pgType == 2)
- {
- vertices.insert(F_vertex (pf,0));
- vertices.insert(F_vertex (pf,1));
- vertices.insert(F_vertex (pf,2));
- }
- }
- FIter_delete(fit);
- }
- case 3:
- {
- RIter rit = M_regionIter(mesh);
- while (pRegion pr = RIter_next(rit))
- {
- pGEntity pg = EN_whatIn((pEntity)pr);
- int pgType = EN_whatInType( (pEntity) pr );
- if(pg)
- if (GEN_tag(pg) == tag && pgType == 3)
- {
- vertices.insert(R_vertex (pr,0));
- vertices.insert(R_vertex (pr,1));
- vertices.insert(R_vertex (pr,2));
- vertices.insert(R_vertex (pr,3));
- }
- }
- RIter_delete(rit);
- }
- }
- }
-
- // ----------------------------------------------------------------------
- void mobileObject::computePrescribedDisplacement (double t, double dt)
- {
- if ( !(NodalDataManagerSgl::instance().isCoordinates()) ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Allocate initial coordinates before making any move (use AdaptInterface::storeInitialCoordinates())");
- }
-
- prescribedDisplacement.clear();
- reAddVertices();
-
- if ( !strcmp(prescribeType.c_str(),"Velocity") )
- {
- double V[3]; V[0]=0.; V[1]=0.; V[2]=0.;
- if (velType == RANDOM_TRANSLATION)
- randomVelocity(V);
- set<pVertex> :: iterator itV = vertices.begin();
- set<pVertex> :: iterator itVEnd = vertices.end();
- for ( ; itV != itVEnd ; ++itV)
- {
- double dx[3];
- double xyz[3]; V_coord (*itV,xyz);
- if ( velType != RANDOM_TRANSLATION)
- velocityFunction(xyz,t,V);
- dx[0] = V[0] * dt;
- dx[1] = V[1] * dt;
- dx[2] = V[2] * dt;
-
- vDisplacement disp(*itV,dx);
- prescribedDisplacement.insert(disp);
- }
- }
-
- else if ( !strcmp(prescribeType.c_str(),"Displacement") )
- {
- set<pVertex> :: iterator itV = vertices.begin();
- set<pVertex> :: iterator itVEnd = vertices.end();
- for ( ; itV != itVEnd ; ++itV)
- {
- // get initial position
- vector<double> xyz0;
- NodalDataManagerSgl::instance().getStoredCoordinates(*itV,xyz0);
-
- // get prescribed displacement (relative to and evaluated on initial position)
- double dx0[3];
- DxParsed->eval(xyz0,t,dx0);
-
- // get current position
- double xyz[3]; V_coord (*itV,xyz);
-
- // get new position
- double xyznew[3];
- for (int i=0; i<3; i++) xyznew[i] = xyz0[i] + dx0[i];
-
- // compute the displacement
- double dx[3];
- dx[0] = xyznew[0] - xyz[0];
- dx[1] = xyznew[1] - xyz[1];
- dx[2] = xyznew[2] - xyz[2];
-
- vDisplacement disp(*itV,dx);
- prescribedDisplacement.insert(disp);
- }
- }
-
- else {
- cerr<< "Error: no kinematics specified for this object\n";
- throw;
- }
- }
-
- // ----------------------------------------------------------------------
- void mobileObject::describe (std::ostream& out) const
- {
- out << "Object \'" << name.c_str() << "\' carries "
- << vertices.size() << " nodes with xyz velocity:\n"
- << " * Vx: "<<Vxyz[0]<<"\n"
- << " * Vy: "<<Vxyz[1]<<"\n"
- << " * Vz: "<<Vxyz[2]<<"\n"
- << " and analytical velocity formulation "<<velType<<"\n\n";
- }
-
- // ----------------------------------------------------------------------
- // generates velocities between -1 and 1
- void mobileObject::randomVelocity(double* V)
- {
- V[0] = ( ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) ) - 0.5 ) * 2.;
- V[1] = ( ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) ) - 0.5 ) * 2.;
- V[2] = ( ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) ) - 0.5 ) * 2.;
- }
-
- // ----------------------------------------------------------------------
- void mobileObject::velocityFunction(double* xyz, double t, double* V)
- {
- double x = xyz[0];
- double y = xyz[1];
- double z = xyz[2];
-
- switch (velType)
- {
- case NOFORMULATION:
- {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Velocity formulation: NOFORMULATION");
- }
- case PARSED:
- {
- VParsed->eval(xyz,t,V);
- break;
- }
- case TRANSLATION:
- {
- V[0] = Vxyz[0]; V[1] = Vxyz[1]; V[2] = Vxyz[2];
- break;
- }
- case FULLRANDOM:
- {
- randomVelocity(V);
- break;
- }
- case RANDOM_TRANSLATION:
- {
- MAdMsgSgl::instance().warning(__LINE__,__FILE__,
- "VelocityFunction with tag RANDOM_TRANSLATION should not be used");
- randomVelocity(V);
- break;
- }
- case ISOMETRY: // expansion
- {
- V[0] = Vxyz[0] * ( x - Cxyz[0] );
- V[1] = Vxyz[1] * ( y - Cxyz[1] );
- V[2] = Vxyz[2] * ( z - Cxyz[2] );
- break;
- }
- case ROTATION: // rotation
- {
- double velYZ = Vxyz[0];
- double velZX = Vxyz[1];
- double velXY = Vxyz[2];
- double rYZ = sqrt ( (y - Cxyz[1])*(y - Cxyz[1]) + (z - Cxyz[2])*(z - Cxyz[2]) );
- double rZX = sqrt ( (x - Cxyz[0])*(x - Cxyz[0]) + (z - Cxyz[2])*(z - Cxyz[2]) );
- double rXY = sqrt ( (x - Cxyz[0])*(x - Cxyz[0]) + (y - Cxyz[1])*(y - Cxyz[1]) );
- double angleYZ = atan2((y - Cxyz[1]), (z - Cxyz[2]));
- double angleZX = atan2((z - Cxyz[2]), (x - Cxyz[0]));
- double angleXY = atan2((x - Cxyz[0]), (y - Cxyz[1]));
- V[0] = 0 - velZX * rZX * sin(angleZX) + velXY * rXY * cos(angleXY) ;
- V[1] = 0 + velYZ * rYZ * cos(angleYZ) - velXY * rXY * sin(angleXY) ;
- V[2] = 0 - velYZ * rYZ * sin(angleYZ) + velZX * rZX * cos(angleZX) ;
- break;
- }
- case SHEAR_YZ: // shear plane YZ
- {
- V[0] = Vxyz[0] * ( x - Cxyz[0] );
- V[1] = Vxyz[1] * ( x - Cxyz[0] );
- V[2] = Vxyz[2] * ( x - Cxyz[0] );
- break;
- }
- case SHEAR_ZX: // shear plane ZX
- {
- V[0] = Vxyz[0] * ( y - Cxyz[1] );
- V[1] = Vxyz[1] * ( y - Cxyz[1] );
- V[2] = Vxyz[2] * ( y - Cxyz[1] );
- break;
- }
- case SHEAR_XY: // shear plane XY
- {
- V[0] = Vxyz[0] * ( z - Cxyz[2] );
- V[1] = Vxyz[1] * ( z - Cxyz[2] );
- V[2] = Vxyz[2] * ( z - Cxyz[2] );
- break;
- }
- case BENCH2: // bench 2
- {
- double Xmax0 = 10.;
- double X = Xmax0 + Vxyz[0] * t;
- V[0] = Vxyz[0] * x / X;
- V[1] = 0.0;
- V[2] = 0.0;
- break;
- }
- case CROSS_EXPANSION_WITH_ROTATION: // cross expantion with rotation
- {
- double cx = 0.45;
- double cy = 0.35 ;
- double r = sqrt ((x - cx)*(x - cx) + (y - cy)*(y - cy));
- double tt = atan2((x - cx), (y - cy));
- V[0] = 0 + 4*r * cos(tt) + sin(tt) * .3;
- V[1] = 0 - 4*r * sin(tt) + cos(tt) * .3;
- V[2] = 0;
- break;
- }
- default:
- {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Unknowm velocity formulation %d",velType);
- }
- }
- }
-
- // ----------------------------------------------------------------------
- // ----------------------- MOBILE OBJECTS SET ---------------------------
- // ----------------------------------------------------------------------
- mobileObjectSet::mobileObjectSet(): elasticOp(NULL)
- {
- }
-
- // ----------------------------------------------------------------------
- mobileObjectSet::~mobileObjectSet()
- {
- clear();
- if (elasticOp) delete elasticOp;
- }
-
- // ----------------------------------------------------------------------
- void mobileObjectSet::clear()
- {
- mobSet.clear();
- }
-
- // ----------------------------------------------------------------------
- void mobileObjectSet::insert(mobileObject* mob)
- {
- mobSet.insert(mob);
- }
-
- // ----------------------------------------------------------------------
- void mobileObjectSet::describe(std::ostream& out) const
- {
- out << "\n--- Mobile objects set description ---\n\n";
- set<mobileObject*>::const_iterator groupIt = mobSet.begin();
- set<mobileObject*>::const_iterator groupItEnd = mobSet.end();
- for ( ; groupIt != groupItEnd ; ++groupIt) {
- (*groupIt)->describe(out);
- }
- }
-
- // ----------------------------------------------------------------------
- void mobileObjectSet::computePrescribedDisplacement (double t, double dt)
- {
- prescribedDisplacement.clear();
-
- set<mobileObject*>::const_iterator groupIt = mobSet.begin();
- set<mobileObject*>::const_iterator groupItEnd = mobSet.end();
- for ( ; groupIt != groupItEnd ; ++groupIt) {
-
- // compute the forced displacement for each object
- (*groupIt)->computePrescribedDisplacement (t,dt);
-
- // gather all displacements
- multiset<vDisplacement,vDisplacementLess> objDisp = (*groupIt)->getPrescribedDisplacement();
- multiset<vDisplacement,vDisplacementLess>::const_iterator itObjDx = objDisp.begin();
- for(; itObjDx != objDisp.end(); itObjDx++) {
- vDisplacement vdisp(*itObjDx);
- prescribedDisplacement.insert(vdisp);
- }
- }
- }
-
- // ----------------------------------------------------------------------
- int mobileObjectSet::partlyMove(vertexMoveOp& vMoveOp, double t, double dt, double * part)
- {
- computePrescribedDisplacement(t, dt);
-
- int ok = 0;
- const int maxNumReduct = 8;
- const double reductFactor = 0.5;
- *part = 1.0;
- cout<<"Attempts to move vertices: [ ";
- for (int i=0; i < maxNumReduct; i++) {
- cout <<"* ";
- if (!vMoveOp.move(prescribedDisplacement,*part)) *part *= reductFactor;
- else { ok = 1; break;}
- }
- cout << "]\n";
- return ok;
- }
-
- // ----------------------------------------------------------------------
- void mobileObjectSet::setupElasticRepositioning(pMesh mesh, double t, double dt,
- double chi, bool meshIsCavity,
- int cavityThickness)
- {
- if ( mobSet.empty() ) return;
-
- // setup the elastic operator
- if (elasticOp) { delete elasticOp; elasticOp = NULL; }
- elasticOp = new MAdElasticityOp(mesh);
- if ( chi >= 0. ) elasticOp->setStiffnessAlterationCoef(chi);
- elasticOp->setCavityEqualMesh(meshIsCavity,cavityThickness);
-
- // prescribe bcs
- computePrescribedDisplacement(t, dt);
- multiset<vDisplacement,vDisplacementLess>::const_iterator dIter = prescribedDisplacement.begin();
- multiset<vDisplacement,vDisplacementLess>::const_iterator dLast = prescribedDisplacement.end();
- for (; dIter != dLast; dIter++) {
- pVertex vert = (*dIter).pv;
- smallVector disp(3);
- for (int i=0; i<3; i++) disp(i) = (*dIter).dxyz[i];
- elasticOp->addDirichlet(vert,disp);
- }
-
- elasticOp->buildCavity();
- elasticOp->setDirichletBC();
-
- // compute elastic repositioning
- elasticOp->compute();
- }
-
- // ----------------------------------------------------------------------
- int mobileObjectSet::reposition(double * ratio)
- {
- if ( mobSet.empty() ) return true;
- int flag = elasticOp->advance(ratio);
- if ( flag == 2 ) elasticOp->clear();
- return flag;
- }
-
- // ----------------------------------------------------------------------
-
-}
diff --git a/Adapt/repositioning/MobileObject.h b/Adapt/repositioning/MobileObject.h
deleted file mode 100644
index 96cce57..0000000
--- a/Adapt/repositioning/MobileObject.h
+++ /dev/null
@@ -1,143 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MOBILEOBJECT
-#define _H_MOBILEOBJECT
-
-#include "VertexMoveOp.h"
-#include "MAdStringFieldEvaluator.h"
-#include "LocalSizeField.h"
-#include "MSops.h"
-#include "MAdElasticityOp.h"
-
-#include <set>
-#include <list>
-#include <utility>
-#include <vector>
-#include <string>
-
-namespace MAd {
-
- // ----------------------------------------------------------------------
- enum velocityFormulation {
- NOFORMULATION,
- PARSED,
- TRANSLATION,
- FULLRANDOM,
- RANDOM_TRANSLATION,
- ISOMETRY,
- ROTATION,
- SHEAR_YZ,
- SHEAR_ZX,
- SHEAR_XY,
- BENCH2,
- CROSS_EXPANSION_WITH_ROTATION
- };
-
- // ----------------------------------------------------------------------
- class mobileObject {
-
- public:
-
- mobileObject(const pMesh m,std::string _name="");
- mobileObject(const mobileObject & mob);
- ~mobileObject();
-
- void setName(std::string nm) {name = nm;}
- void setDxKinematics(std::vector<std::string> _Vstr);
- void setVKinematics(velocityFormulation type, double V[3],
- double C[3], std::vector<std::string> _Vstr);
- void addLocalSField(LocalSizeField* lsf);
- void addGEntity(int type, int tag);
- void reAddVertices();
-
- void computePrescribedDisplacement (double t, double dt);
-
- void describe (std::ostream& out=std::cout) const;
- const std::set<pVertex> getVertices() const {return vertices;}
- std::multiset<vDisplacement,vDisplacementLess> getPrescribedDisplacement () const {return prescribedDisplacement;}
- std::set<LocalSizeField* > getSizes() const { return sizes; }
-
- private:
-
- void addVerticesOnGEntity(int type, int tag);
- void clearDisplacement();
-
- void randomVelocity(double* V);
- void velocityFunction(double xyz[3], double t, double* V);
-
- private:
-
- const pMesh mesh;
- std::string name;
- std::list<std::pair<int,int> > geomEntities; // list of (type,tag)
- std::set<pVertex> vertices;
-
- // Parameters describing the kinematics
- std::string prescribeType;
- // for position ...
- MAdStringFieldEvaluator* DxParsed; // displacement relative to and evaluated on initial position
- // ... or velocity
- velocityFormulation velType;
- double Cxyz[3], Vxyz[3];
- MAdStringFieldEvaluator* VParsed; // velocity evaluated on current position
-
- // // Parameters describing the size around
- std::set<LocalSizeField* > sizes;
-
- std::multiset<vDisplacement,vDisplacementLess> prescribedDisplacement;
- };
-
- // ----------------------------------------------------------------------
- class mobileObjectSet {
-
- public:
-
- mobileObjectSet();
- ~mobileObjectSet();
-
- // larger possible motion by trials without volume nodes repositioning
- int partlyMove(vertexMoveOp& vMoveOp, double t, double dt, double * part);
-
- // move objects and reposition volume nodes. Needs the elastic operator.
- void setupElasticRepositioning(pMesh mesh, double t, double dt,double chi=-1,
- bool meshIsCavity=true, int cavityThickness=3);
- int reposition(double * ratio);
-
- // empty or fill the set
- void clear();
- void insert(mobileObject*);
-
- std::multiset<vDisplacement,vDisplacementLess> getPrescribedDisplacement () const {return prescribedDisplacement;}
- std::set<mobileObject*> getObjects() const {return mobSet;}
-
- void describe(std::ostream& out=std::cout) const;
-
- private:
-
- // compute the objects displacement in a time interval
- void computePrescribedDisplacement (double t, double dt) ;
-
- private:
-
- std::set<mobileObject*> mobSet;
- std::multiset<vDisplacement,vDisplacementLess> prescribedDisplacement;
-
- MAdElasticityOp * elasticOp;
- };
-
- // ----------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/repositioning/NodesRepositioningOp.h b/Adapt/repositioning/NodesRepositioningOp.h
deleted file mode 100644
index ef5daf4..0000000
--- a/Adapt/repositioning/NodesRepositioningOp.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_NODESREPOSITIONINGOP
-#define _H_NODESREPOSITIONINGOP
-
-#include "DiscreteSF.h"
-#include "MeshQualityManager.h"
-#include "MeshDataBaseInterface.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- enum repositionType {
- LAPLACE_FAST,
- LAPLACE_OPTIMAL
- };
-
- // -------------------------------------------------------------------
- class nodesRepositioningOp {
-
- public:
-
- nodesRepositioningOp(pMesh m, DiscreteSF * sf):
- mesh(m), sizeField(sf), mqm(MeshQualityManagerSgl::instance())
- {
- dim = 3;
- if ( M_numRegions(mesh) == 0 ) dim = 2;
- }
- virtual ~nodesRepositioningOp() {}
-
- public:
-
- virtual int run(double * L2Norm)=0;
-
- protected:
-
- pMesh mesh;
- int dim;
- DiscreteSF * sizeField;
- MeshQualityManager& mqm;
-
- };
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/sizeField/AnalyticalSField.cc b/Adapt/sizeField/AnalyticalSField.cc
deleted file mode 100644
index 28f5b4a..0000000
--- a/Adapt/sizeField/AnalyticalSField.cc
+++ /dev/null
@@ -1,382 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "AnalyticalSField.h"
-#include "MAdTimeManager.h"
-#include "IsoMeshSize.h"
-#include "AnisoMeshSize.h"
-#include "MathUtils.h"
-#include "MAdMessage.h"
-
-#include <math.h>
-#include <stdio.h>
-#include <iostream>
-using std::cout;
-using std::cerr;
-using std::endl;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- // Constructors / destructors
- // -------------------------------------------------------------------
- AnalyticalSField::AnalyticalSField():
- SizeFieldBase(), sFct(NULL), isotropic(true), evaluator(NULL)
- {
- setSize("1.");
- }
-
- // -------------------------------------------------------------------
- AnalyticalSField::AnalyticalSField(std::string h):
- SizeFieldBase(), sFct(NULL), isotropic(true), evaluator(NULL)
- {
- setSize(h);
- }
-
- // -------------------------------------------------------------------
- AnalyticalSField::AnalyticalSField(std::vector<std::string> _h,
- std::vector<std::string> _e0,
- std::vector<std::string> _e1,
- std::vector<std::string> _e2):
- SizeFieldBase(), sFct(NULL), isotropic(false), evaluator(NULL)
- {
- setSize(_h,_e0,_e1,_e2);
- }
-
- // -------------------------------------------------------------------
- AnalyticalSField::AnalyticalSField(sizeFunction f):
- SizeFieldBase(), sFct(f), isotropic(false),
- evaluator(NULL)
- {}
-
- // -------------------------------------------------------------------
- AnalyticalSField::~AnalyticalSField()
- {
- if (evaluator) delete evaluator;
- }
-
- // -------------------------------------------------------------------
- void AnalyticalSField::describe() const {
-
- cout << "\nDescribing analytical size field: \n\n";
-
- cout << " Orientation: \t";
- if (isotropic) cout << "Isotropic\n\n";
- else cout << "Anisotropic\n\n";
-
- cout << " Representation:\t";
- if (sFct) cout << "Size Function\n\n";
- else {
- if (isotropic) {
- cout << "String:\n";
- cout << " Size: " << h0 << "\n\n";
- }
- else {
- cout << "Strings:\n";
-
- cout << " - Sizes:\n";
- cout << " * " << h0 << "\n";
- cout << " * " << h1 << "\n";
- cout << " * " << h2 << "\n";
-
- cout << " - Vectors:\n";
- cout << " * " << e0[0] <<"\t" << e0[1] <<"\t" << e0[2] <<"\n";
- cout << " * " << e1[0] <<"\t" << e1[1] <<"\t" << e1[2] <<"\n";
- cout << " * " << e2[0] <<"\t" << e2[1] <<"\t" << e2[2] <<"\n";
-
- cout << "\n";
- }
- }
-
- }
-
- // -------------------------------------------------------------------
- // Size imposition
- // -------------------------------------------------------------------
- void AnalyticalSField::setSize(const std::string h)
- {
- if (sFct) throw;
-
- isotropic = true;
-
- h0 = h;
- h1 = h;
- h2 = h;
- e0.resize(3);
- e1.resize(3);
- e2.resize(3);
- e0[0] = "1."; e0[1] = "0."; e0[2] = "0.";
- e1[0] = "0."; e1[1] = "1."; e1[2] = "0.";
- e2[0] = "0."; e2[1] = "0."; e2[2] = "1.";
-
- if(evaluator) delete evaluator;
- evaluator = new MAdStringFieldEvaluator(1,h.c_str());
- }
-
- // -------------------------------------------------------------------
- void AnalyticalSField::setSize(std::vector<std::string> _h,
- std::vector<std::string> _e0,
- std::vector<std::string> _e1,
- std::vector<std::string> _e2)
- {
- if (sFct) throw;
-
- isotropic = false;
-
- h0 = _h[0];
- h1 = _h[1];
- h2 = _h[2];
- e0 = _e0;
- e1 = _e1;
- e2 = _e2;
-
- if(evaluator) delete evaluator;
- evaluator = new MAdStringFieldEvaluator(12,
- h0.c_str(), h1.c_str(), h2.c_str(),
- e0[0].c_str(), e0[1].c_str(), e0[2].c_str(),
- e1[0].c_str(), e1[1].c_str(), e1[2].c_str(),
- e2[0].c_str(), e2[1].c_str(), e2[2].c_str());
- }
-
- // -------------------------------------------------------------------
- void AnalyticalSField::setSize(sizeFunction f)
- {
- if (evaluator) throw;
- sFct = f;
- }
-
- // -------------------------------------------------------------------
- // Evaluate a local size
- // -------------------------------------------------------------------
- pMSize AnalyticalSField::eval(const double xyz[3]) const
- {
- double time = MAdTimeManagerSgl::instance().getTime();
-
- if(sFct) return (*sFct)(xyz,time);
-
- else {
- if (isotropic) {
- double h;
- evaluator->eval(xyz,time,&h);
- return new IsoMeshSize(h);
- }
- else {
- double vals[12];
- evaluator->eval(xyz,time,vals);
- double h[3] = {vals[0], vals[1], vals[2]};
- double e[3][3] = { {vals[3], vals[4], vals[5]},
- {vals[6], vals[7], vals[8]},
- {vals[9], vals[10], vals[11]} };
- return new AnisoMeshSize(e,h);
- }
- }
- return NULL;
- }
-
- // -------------------------------------------------------------------
- pMSize AnalyticalSField::getSize(const pVertex pv) const
- {
- double xyz[3];
- V_coord(pv,xyz);
- return eval(xyz);
- }
-
- // -------------------------------------------------------------------
- pMSize AnalyticalSField::getSizeOnEntity(const pEntity,
- const double xyz[3]) const
- {
- return eval(xyz);
- }
-
- // -------------------------------------------------------------------
- // Length squared computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double AnalyticalSField::SF_VV_lengthSq(const pVertex pV0,
- const pVertex pV1) const
- {
- double xyz[2][3];
- V_coord(pV0,xyz[0]);
- V_coord(pV1,xyz[1]);
-
- pMSize pS[2];
- pS[0] = getSize(pV0);
- pS[1] = getSize(pV1);
-
- double lSq = SF_XYZ_lengthSq(xyz[0],xyz[1],pS[0],pS[1]);
-
- if ( pS[0] ) delete pS[0];
- if ( pS[1] ) delete pS[1];
-
- return lSq;
- }
-
- // -------------------------------------------------------------------
- double AnalyticalSField::SF_XYZ_lengthSq(const double xyz0[3],
- const double xyz1[3],
- const pMSize pS0,
- const pMSize pS1) const
- {
- if( pS0 )
- {
- double e[3];
- diffVec(xyz0,xyz1,e);
- double lenSq0 = pS0->normSq(e);
- if ( pS1 )
- {
- double lenSq1 = pS1->normSq(e);
- return sqrt(lenSq0*lenSq1);
- }
- else return lenSq0;
- }
- else {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"No size defined");
- }
- return 0.;
- }
-
- // -------------------------------------------------------------------
- // Area squared computation
- // -------------------------------------------------------------------
-
- double AnalyticalSField::SF_F_areaSq(const pFace face) const
- {
- double area = 0.;
-
- double xyz[3][3];
- F_coordP1(face,xyz);
-
- void * temp = 0;
- pPList fVerts = F_vertices(face,1);
- while( pVertex pV = (pVertex)PList_next(fVerts,&temp) )
- {
- pMSize pS = getSize(pV);
- area += SF_XYZ_areaSq(xyz,pS,0);
- if (pS) delete pS;
- }
- PList_delete(fVerts);
-
- area /= F_numVertices(face);
-
- return area;
- }
-
- // -------------------------------------------------------------------
- double AnalyticalSField::SF_XYZ_areaSq(const double fxyz[3][3],
- const pMSize pS,
- const double norDir[3]) const
- {
- if( !pS ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"No size defined");
- }
-
- // get the two first edges
- double e01[3],e02[3];
- diffVec(fxyz[1],fxyz[0],e01);
- diffVec(fxyz[2],fxyz[0],e02);
-
- double nor[3];
- crossProd(e01,e02,nor);
-
- double l1SqInv = 1. / pS->lengthSqInDir(e01);
- double l2SqInv = 1. / pS->lengthSqInDir(e02);
-
- if( norDir && dotProd(norDir,nor) < MAdTOL ) return 0.;
-
- double areaSq = 0.25 * dotProd(nor,nor) * l1SqInv * l2SqInv;
- if( areaSq < MAdTOL ) return 0.;
-
- return areaSq;
- }
-
- // -------------------------------------------------------------------
- // Volume computation
- // -------------------------------------------------------------------
-
- double AnalyticalSField::SF_R_volume(const pRegion region) const
- {
- double vol = 0.;
-
- double xyz[4][3];
- R_coordP1(region,xyz);
-
- pPList rVerts = R_vertices(region);
- void * temp = 0;
- while( pVertex pV = (pVertex)PList_next(rVerts,&temp) )
- {
- pMSize pS = getSize(pV);
- vol += SF_XYZ_volume(xyz,pS);
- if (pS) delete pS;
- }
- PList_delete(rVerts);
-
- vol /= R_numVertices(region);
-
- return vol;
- }
-
- // -------------------------------------------------------------------
- double AnalyticalSField::SF_XYZ_volume(const double xyz[4][3],
- const pMSize pS) const
- {
- if( !pS ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"No size defined");
- }
-
- double physVol = R_XYZ_volume(xyz);
-
- return ( physVol / (pS->size(0)*pS->size(1)*pS->size(2)) );
- }
-
- // -------------------------------------------------------------------
- // Center of edge computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double AnalyticalSField::SF_E_center(const pEdge edge, double center[3],
- double * reducSq, pMSize * cSize) const
- {
- return SF_VV_center(E_vertex(edge,0),E_vertex(edge,1),center,reducSq,cSize);
- }
-
- // -------------------------------------------------------------------
- double AnalyticalSField::SF_VV_center(const pVertex v0, const pVertex v1,
- double center[3], double * reducSq,
- pMSize * cSize) const
- {
- double xyz[2][3];
- V_coord(v0,xyz[0]);
- V_coord(v1,xyz[1]);
-
- pMSize pS[2];
- pS[0] = getSize(v0);
- pS[1] = getSize(v1);
-
- double cParam = SF_XYZ_center(xyz,pS,center,reducSq,cSize);
-
- if ( pS[0] ) delete pS[0];
- if ( pS[1] ) delete pS[1];
-
- return cParam;
- }
-
- // -------------------------------------------------------------------
- void AnalyticalSField::scale(double fact)
- {
- printf("Not implemented (AnalyticalSField::scale)\n");
- throw;
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/sizeField/AnalyticalSField.h b/Adapt/sizeField/AnalyticalSField.h
deleted file mode 100644
index 8fb179f..0000000
--- a/Adapt/sizeField/AnalyticalSField.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_ANALYTICALSFIELD
-#define _H_ANALYTICALSFIELD
-
-#include "SizeFieldBase.h"
-#include "MAdStringFieldEvaluator.h"
-
-#include <vector>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- typedef pMSize (*sizeFunction)(const double[3],double);
-
- // -------------------------------------------------------------------
- class AnalyticalSField: public SizeFieldBase
- {
- public:
-
- AnalyticalSField();
- AnalyticalSField(std::string);
- AnalyticalSField(std::vector<std::string>,std::vector<std::string>,
- std::vector<std::string>,std::vector<std::string>);
- AnalyticalSField(sizeFunction);
- ~AnalyticalSField();
-
- public:
-
- sFieldType getType() const { return ANALYTICALSFIELD; }
- void describe() const;
-
- void scale(double);
-
- // set the size
- void setSize(sizeFunction);
- void setSize(const std::string);
- void setSize(std::vector<std::string>,std::vector<std::string>,
- std::vector<std::string>,std::vector<std::string>);
-
- // get the size at a location (allocate space!)
- pMSize getSize(const pVertex) const;
- pMSize getSizeOnEntity(const pEntity, const double[3]) const;
-
- // edge length (squared)
- double SF_VV_lengthSq(const pVertex, const pVertex) const;
- double SF_XYZ_lengthSq(const double[3], const double[3],
- const pMSize, const pMSize=NULL) const;
-
- // face area (squared)
- double SF_F_areaSq(const pFace) const;
- double SF_XYZ_areaSq(const double[3][3], const pMSize,
- const double[3]) const;
-
- // region volume
- double SF_R_volume(const pRegion) const;
- double SF_XYZ_volume(const double[4][3], const pMSize) const;
-
- // center and its associated size
- double SF_E_center(const pEdge, double[3], double * reducSq, pMSize *) const;
- double SF_VV_center(const pVertex, const pVertex,
- double[3], double * reducSq, pMSize *) const;
-
- private:
-
- // description of the sizes if we use functions
- sizeFunction sFct;
-
- // description of the sizes if we use strings
- bool isotropic;
- std::string h0, h1, h2;
- std::vector<std::string> e0, e1, e2;
- MAdStringFieldEvaluator * evaluator;
-
- private:
-
- pMSize eval(const double[3]) const;
- };
-
-}
-
-// -------------------------------------------------------------------
-#endif
diff --git a/Adapt/sizeField/AnisoMeshSize.cc b/Adapt/sizeField/AnisoMeshSize.cc
deleted file mode 100644
index fd557c0..0000000
--- a/Adapt/sizeField/AnisoMeshSize.cc
+++ /dev/null
@@ -1,260 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "AnisoMeshSize.h"
-#include "MathUtils.h"
-#include "MAdMessage.h"
-#include "MAdDefines.h"
-#include "MeshParametersManager.h"
-
-#include <iostream>
-using std::string;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- AnisoMeshSize::AnisoMeshSize(double dirs[3][3], double _h[3]):
- MeshSizeBase()
- {
- if( _h[0] <= 0. || _h[1] <= 0. || _h[2] <= 0. ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Negative size(s): %f %f %f",
- _h[0], _h[1], _h[2]);
- }
-
- double t1[3], t2[3], t3[3];
- double l1,l2,l3;
-
- // sort the sizes from lowest to highest and fill first direction (GCRemark: not useful)
- int hMin = indexOfMin(_h[0], _h[1], _h[2]);
- l1 = 1. / (_h[hMin] * _h[hMin]);
- double normInv = 1. / sqrt ( dirs[hMin][0] * dirs[hMin][0] +
- dirs[hMin][1] * dirs[hMin][1] +
- dirs[hMin][2] * dirs[hMin][2] );
- for (int i=0; i<3; i++) t1[i] = dirs[hMin][i] * normInv;
-
- hMin++;
- if( _h[(hMin+1)%3] > _h[(hMin)%3] )
- {
- l2 = 1. / (_h[hMin%3] * _h[hMin%3]);
- l3 = 1. / (_h[(hMin+1)%3] * _h[(hMin+1)%3]);
- hMin = hMin%3;
- }
- else
- {
- l2 = 1. / (_h[(hMin+1)%3] * _h[(hMin+1)%3]);
- l3 = 1. / (_h[hMin%3] * _h[hMin%3]);
- hMin = (hMin+1)%3;
- }
-
- // project dir 1 so that it is perpendicular to dir 0
- double cosa = dotProd(t1,dirs[hMin]);
- double vec[3];
- for( int i=0; i<3; i++ ) vec[i] = dirs[hMin][i] - cosa * t1[i];
- normInv = 1. / sqrt ( vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] );
- for (int i=0; i<3; i++) t2[i] = vec[i] * normInv;
-
- // find last dir as the direction orthogonal to the two previous ones
- crossProd(t1,t2,t3);
-
- // build the metric
- M = MAdMetric(l1,l2,l3,t1,t2,t3);
- }
-
- // -------------------------------------------------------------------
- AnisoMeshSize::AnisoMeshSize(double dir[3], double hDir, double hTg):
- MeshSizeBase()
- {
- if( hDir <= 0. || hTg <= 0. ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Negative size(s): %f %f",
- hDir, hTg);
- }
-
- double e[3][3];
- double len[3];
-
- // see if 'dir' is the direction of the minimal length
- int iDir = 0;
- if ( hDir > hTg ) iDir = 2;
-
- // set the 'dir' direction and its length
- normalizeVec(dir,e[iDir]);
- len[iDir] = 1. / ( hDir * hDir );
-
- // set other sizes in the right order
- len[(iDir+1)%3] = 1. / ( hTg * hTg );
- len[(iDir+2)%3] = len[(iDir+1)%3];
-
- // find a perpendicular direction to dir
- double dummy[3];
- dummy[0] = 2. * ( e[iDir][0] + 1.3654364 );
- dummy[1] = 3. * ( e[iDir][1] + 3.1368136 );
- dummy[2] = 5. * ( e[iDir][2] + 7.3683686 );
- normalizeVec(dummy,dummy);
- double cosa = dotProd(e[iDir],dummy);
- for( int i=0; i<3; i++ ) dummy[i] -= cosa * e[iDir][i];
- normalizeVec(dummy,e[(iDir+1)%3]);
-
- // find last dir as the direction orthogonal to the two previous ones
- crossProd(e[iDir],e[(iDir+1)%3],e[(iDir+2)%3]);
-
- // build the metric
- M = MAdMetric(len[0],len[1],len[2],e[0],e[1],e[2]);
- }
-
- // -------------------------------------------------------------------
- AnisoMeshSize::AnisoMeshSize(double h):
- MeshSizeBase()
- {
- M = MAdMetric( 1./(h*h) );
- }
-
- // -------------------------------------------------------------------
- AnisoMeshSize::AnisoMeshSize(const AnisoMeshSize &pm):
- MeshSizeBase()
- {
- M = pm.M;
- }
-
- // -------------------------------------------------------------------
- MeshSizeType AnisoMeshSize::getType() const
- {
- return ANISOTROPIC;
- }
-
- // -------------------------------------------------------------------
- void AnisoMeshSize::intersect(const pMSize pMS1, const pMSize pMS2)
- {
- M = intersection(pMS1->getMetric(),pMS2->getMetric());
- }
-
- // -------------------------------------------------------------------
- void AnisoMeshSize::interpolate(const pMSize pMS0, const pMSize pMS1,
- double param)
- {
- M = interpolation(pMS0->getMetric(),pMS1->getMetric(),param);
- }
-
- // -------------------------------------------------------------------
- void AnisoMeshSize::interpolate(const pMSize pMS0, const pMSize pMS1,
- const pMSize pMS2, double u, double v)
- {
- M = interpolation(pMS0->getMetric(), pMS1->getMetric(),
- pMS2->getMetric(), u, v);
- }
-
- // -------------------------------------------------------------------
- void AnisoMeshSize::interpolate(const pMSize pMS0, const pMSize pMS1,
- const pMSize pMS2, const pMSize pMS3,
- double u, double v, double w)
- {
- M = interpolation(pMS0->getMetric(), pMS1->getMetric(),
- pMS2->getMetric(), pMS3->getMetric(),
- u, v, w);
- }
-
- // -------------------------------------------------------------------
- double AnisoMeshSize::size(int i) const
- {
- doubleMatrix V = doubleMatrix(3,3);
- doubleVector S = doubleVector(3);
- M.eig(V,S,true);
- double s = 1. / sqrt( S(i) );
- if ( isnan(s) ) return MeshParametersManagerSgl::instance().getBigLength();
- return s;
- }
-
- // -------------------------------------------------------------------
- void AnisoMeshSize::sizes(double _h[3]) const
- {
- doubleMatrix V = doubleMatrix(3,3);
- doubleVector S = doubleVector(3);
- M.eig(V,S,true);
- for (int i=0; i<3; i++) {
- _h[i] = ( 1. / sqrt( S(i) ) );
- if ( isnan(_h[i]) ) _h[i] = MeshParametersManagerSgl::instance().getBigLength();
- }
- }
-
- // -------------------------------------------------------------------
- double AnisoMeshSize::direction(int i, double dir[3]) const
- {
- doubleMatrix V = doubleMatrix(3,3);
- doubleVector S = doubleVector(3);
- M.eig(V,S,true); // each column of V is a direction, S gives corresponding 1/h^2
- for (int iC=0; iC<3; iC++) dir[iC] = V(iC,i);
- double s = 1. / sqrt( S(i) );
- if ( isnan(s) ) return MeshParametersManagerSgl::instance().getBigLength();
- return s;
- }
-
- // -------------------------------------------------------------------
- void AnisoMeshSize::scale(int dir, double factor)
- {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Not implemented");
- }
-
- // -------------------------------------------------------------------
- void AnisoMeshSize::scale(double factor)
- {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Not implemented");
- }
-
- // -------------------------------------------------------------------
- double AnisoMeshSize::getMeanLength() const
- {
- doubleMatrix V = doubleMatrix(3,3);
- doubleVector S = doubleVector(3);
- M.eig(V,S,false);
- double mean = 0.;
- for (int i=0; i<3; i++) mean += 1. / sqrt( S(i) );
- return ( MAdTHIRD * mean );
- }
-
- // -------------------------------------------------------------------
- // get the square of the norm in the metric
- double AnisoMeshSize::normSq(const double vec[3]) const
- {
- return dot(vec,M,vec);
- }
-
- // -------------------------------------------------------------------
- // get the square of desired edge length along 'vec'
- double AnisoMeshSize::lengthSqInDir(const double vec[3]) const
- {
- double tmp[3];
- normalizeVec(vec,tmp);
- return ( 1. / dot(tmp,M,tmp) );
- }
-
- // -------------------------------------------------------------------
- // get the cosine of the angle with the direction of the minimal size
- double AnisoMeshSize::angleWithDir0(const double dir[3]) const
- {
- double tmp[3];
- normalizeVec(dir,tmp);
- double dir0[3];
- direction(0,dir0);
- normalizeVec(dir0,dir0);
- return dotProd(tmp,dir0);
- }
-
- // -------------------------------------------------------------------
- void AnisoMeshSize::print(string name) const
- {
- std::cout<<"Printing AnisoMeshSize \'"<<name<<"\' ("<<this<<")\n";
- M.print("Mesh size metric");
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/sizeField/AnisoMeshSize.h b/Adapt/sizeField/AnisoMeshSize.h
deleted file mode 100644
index 6f4d337..0000000
--- a/Adapt/sizeField/AnisoMeshSize.h
+++ /dev/null
@@ -1,77 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_ANISOMESHSIZE
-#define _H_ANISOMESHSIZE
-
-#include "MeshSizeBase.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- // This class stores an anisotropic mesh size (prescribed edge length)
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- class AnisoMeshSize : public MeshSizeBase {
-
- public:
-
- AnisoMeshSize(double e[3][3], double _h[3]);
- AnisoMeshSize(double e[3], double hDir, double hTg);
- AnisoMeshSize(double h=1.);
- AnisoMeshSize(const AnisoMeshSize &);
- ~AnisoMeshSize() {};
-
- public:
-
- MeshSizeType getType() const;
- MAdMetric getMetric() const { return M; }
-
- void intersect(const pMSize pMS0, const pMSize pMS1);
-
- void interpolate(const pMSize, const pMSize, double);
- void interpolate(const pMSize, const pMSize, const pMSize,
- double, double);
- void interpolate(const pMSize, const pMSize, const pMSize, const pMSize,
- double, double, double);
-
- double direction(int i, double dir[3]) const;
- double size(int i=0) const;
- void sizes(double _h[3]) const;
-
- // get the square of the norm in the metric
- double normSq(const double vec[3]) const;
-
- double lengthSqInDir(const double dir[3]) const ;
-
- // get the cosine of the angle with the direction of the minimal size
- double angleWithDir0(const double dir[3]) const;
-
- double getMeanLength() const;
-
- void scale(int, double);
- void scale(double);
-
- void print(std::string name="") const;
-
- private:
-
- MAdMetric M;
- };
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/sizeField/DiscreteSF.cc b/Adapt/sizeField/DiscreteSF.cc
deleted file mode 100644
index 668a051..0000000
--- a/Adapt/sizeField/DiscreteSF.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "DiscreteSF.h"
-#include "IsoMeshSize.h"
-#include "AnisoMeshSize.h"
-
-using namespace MAd;
-
-// -------------------------------------------------------------------
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- DiscreteSF::DiscreteSF(pMesh m): SizeFieldBase()
- {
- mesh = m;
- dim = M_dim(mesh);
-
- pMSizeFieldId = MD_newMeshDataId("");
- }
-
- // -------------------------------------------------------------------
- DiscreteSF::~DiscreteSF()
- {
- MD_deleteMeshDataId(pMSizeFieldId);
- }
-
- // -------------------------------------------------------------------
- void DiscreteSF::deleteSize(pEntity entity)
- {
- void * temp;
- if( EN_getDataPtr(entity,pMSizeFieldId,&temp) ) {
- EN_deleteData(entity,pMSizeFieldId);
- delete (pMSize)temp;
- }
- }
-
- // -------------------------------------------------------------------
- void DiscreteSF::setSize(pEntity ent,
- double dirs[3][3],
- double h[3])
- {
- pMSize pS = new AnisoMeshSize(dirs,h);
- setSize(ent,pS);
- }
-
-
- // -------------------------------------------------------------------
- void DiscreteSF::setSize(pEntity ent, double h)
- {
- pMSize pS = new IsoMeshSize(h);
- setSize(ent,pS);
- }
-
- // -------------------------------------------------------------------
- void DiscreteSF::setSize(pEntity pEnt, pMSize pS)
- {
- void * temp;
- if( EN_getDataPtr(pEnt,pMSizeFieldId,&temp) ) {
- delete (pMSize)temp;
- EN_modifyDataPtr(pEnt,pMSizeFieldId,pS);
- }
- else {
- EN_attachDataPtr(pEnt,pMSizeFieldId,pS);
- }
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/sizeField/DiscreteSF.h b/Adapt/sizeField/DiscreteSF.h
deleted file mode 100644
index c411c41..0000000
--- a/Adapt/sizeField/DiscreteSF.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_DISCRETESF
-#define _H_DISCRETESF
-
-#include "SizeFieldBase.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- enum DiscreteSFType {
- UNKNOWN_DSFTYPE,
- VERTEX_P1_DSFTYPE
- };
-
- // -------------------------------------------------------------------
- class DiscreteSF : public SizeFieldBase
- {
- public:
-
- DiscreteSF(pMesh);
- ~DiscreteSF();
-
- sFieldType getType() const { return DISCRETESFIELD; }
- virtual DiscreteSFType discretization() const = 0;
- pMesh getMesh() { return mesh; }
-
- // delete sizes
- virtual void cleanUp() = 0;
- void deleteSize(pEntity);
-
- // Intersect with another size field
- virtual void intersect(const pSField) = 0;
-
- // smooth the size field
- virtual void smooth(double) = 0;
-
- // set a size at all vertices
- virtual void setCurrentSize() = 0;
- virtual void setCurvatureSize(bool aniso,
- double alpha=2., // prescribe 2*PI*alpha edges around a circle
- double hMin=1.e-4) = 0; // minimal size
- virtual void setAllVSizes(pMSize) = 0;
- virtual void setAllVSizes(double[3][3], double[3]) = 0;
- virtual void setAllVSizes(double) = 0;
- virtual void scale(double) = 0;
-
- // set the size at a vertex
- void setSize(pEntity, double[3][3], double[3]);
- void setSize(pEntity, pMSize);
- void setSize(pEntity, double);
-
- // get the size at a location (allocate space!)
- virtual pMSize getSize(const pVertex) const = 0;
- virtual pMSize getSizeOnEntity(const pEntity, const double[3]) const = 0;
-
- // get the size at a vertex (do not allocate space)
- virtual const pMSize findSize(const pVertex) const = 0;
- virtual pMSize findSize(const pVertex) = 0;
-
- // edge length (squared)
- virtual double SF_VV_lengthSq(const pVertex, const pVertex) const = 0;
- virtual double SF_XYZ_lengthSq(const double[3], const double[3],
- const pMSize, const pMSize=NULL) const = 0;
-
- // face area (squared)
- virtual double SF_F_areaSq(const pFace) const = 0;
- virtual double SF_XYZ_areaSq(const double[3][3], const pMSize,
- const double[3]) const = 0;
-
- // region volume
- virtual double SF_R_volume(const pRegion) const = 0;
- virtual double SF_XYZ_volume(const double[4][3], const pMSize) const = 0;
-
- // center and its associated size
- virtual double SF_E_center(const pEdge, double[3], double *reducSq, pMSize *) const = 0;
- virtual double SF_VV_center(const pVertex, const pVertex,
- double[3], double *reducSq, pMSize *) const = 0;
-
- protected:
-
- pMesh mesh;
- int dim;
- pMeshDataId pMSizeFieldId;
-
- };
-
-}
-
-// -------------------------------------------------------------------
-
-#endif
diff --git a/Adapt/sizeField/IsoMeshSize.cc b/Adapt/sizeField/IsoMeshSize.cc
deleted file mode 100644
index 82626a2..0000000
--- a/Adapt/sizeField/IsoMeshSize.cc
+++ /dev/null
@@ -1,164 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "IsoMeshSize.h"
-#include "MathUtils.h"
-#include "MAdMessage.h"
-
-#include <stdio.h>
-#include <iostream>
-#include <stdlib.h>
-using std::string;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- IsoMeshSize::IsoMeshSize(double _h):
- MeshSizeBase()
- {
- h = _h;
- }
-
- // -------------------------------------------------------------------
- IsoMeshSize::IsoMeshSize(const IsoMeshSize &pm):
- MeshSizeBase()
- {
- h = pm.size();
- }
-
- // -------------------------------------------------------------------
- MeshSizeType IsoMeshSize::getType() const
- {
- return ISOTROPIC;
- }
-
- // -------------------------------------------------------------------
- void IsoMeshSize::intersect(const pMSize pMS0, const pMSize pMS1)
- {
- if ( pMS0->getType() != ISOTROPIC ||
- pMS1->getType() != ISOTROPIC ) {
- printf("Error: intersecting anisotropic sizes in isotropic mesh size\n");
- exit(1);
- }
-
- double h0 = ((IsoMeshSize*)pMS0)->size();
- double h1 = ((IsoMeshSize*)pMS1)->size();
- h = std::min(h0,h1);
- }
-
- // -------------------------------------------------------------------
- void IsoMeshSize::interpolate(const pMSize pMS0, const pMSize pMS1,
- double param)
- {
- if ( pMS0->getType() != ISOTROPIC ||
- pMS1->getType() != ISOTROPIC ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Anisotropic size(s)");
- }
-
- double h0 = ((IsoMeshSize*)pMS0)->size();
- double h1 = ((IsoMeshSize*)pMS1)->size();
- h = h0 + param * ( h1 - h0 );
- }
-
- // -------------------------------------------------------------------
- void IsoMeshSize::interpolate(const pMSize pMS0, const pMSize pMS1,
- const pMSize pMS2, double u, double v)
- {
- if ( pMS0->getType() != ISOTROPIC ||
- pMS1->getType() != ISOTROPIC ||
- pMS2->getType() != ISOTROPIC ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Anisotropic size(s)");
- }
-
- double h0 = ((IsoMeshSize*)pMS0)->size();
- double h1 = ((IsoMeshSize*)pMS1)->size();
- double h2 = ((IsoMeshSize*)pMS2)->size();
- h = (1.-u-v) * h0 + u * h1 + v * h2;
- }
-
- // -------------------------------------------------------------------
- void IsoMeshSize::interpolate(const pMSize pMS0, const pMSize pMS1,
- const pMSize pMS2, const pMSize pMS3,
- double u, double v, double w)
- {
- if ( pMS0->getType() != ISOTROPIC ||
- pMS1->getType() != ISOTROPIC ||
- pMS2->getType() != ISOTROPIC ||
- pMS3->getType() != ISOTROPIC ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Anisotropic size(s)");
- }
-
- double h0 = ((IsoMeshSize*)pMS0)->size();
- double h1 = ((IsoMeshSize*)pMS1)->size();
- double h2 = ((IsoMeshSize*)pMS2)->size();
- double h3 = ((IsoMeshSize*)pMS3)->size();
- h = (1.-u-v-w) * h0 + u * h1 + v * h2 + w * h3;
- }
-
- // -------------------------------------------------------------------
- double IsoMeshSize::direction(int i, double dir[3]) const
- {
- for (int c=0; c<3; c++) dir[c] = 0.;
- dir[i] = 1.;
- return h;
- }
-
- // -------------------------------------------------------------------
- double IsoMeshSize::size(int i) const {
- return h;
- }
-
- // -------------------------------------------------------------------
- void IsoMeshSize::sizes(double _h[3]) const {
- _h[0] = _h[1] = _h[2] = h;
- }
-
- // -------------------------------------------------------------------
- double IsoMeshSize::getMeanLength() const
- {
- return h;
- }
-
- // -------------------------------------------------------------------
- void IsoMeshSize::setSize(double _h)
- {
- h = _h;
- }
-
- // -------------------------------------------------------------------
- void IsoMeshSize::scale(double factor)
- {
- h *= factor;
- }
-
- // -------------------------------------------------------------------
- double IsoMeshSize::normSq(const double vec[3]) const
- {
- return ( dotProd(vec,vec) / (h*h) );
- }
-
- // -------------------------------------------------------------------
- double IsoMeshSize::lengthSqInDir(const double vec[3]) const
- {
- return h*h;
- }
-
- // -------------------------------------------------------------------
- void IsoMeshSize::print(string name) const
- {
- std::cout<<"Printing IsoMeshSize \'"<<name<<"\' ("<<this<<")\n";
- std::cout<<" h:\t"<<h<<"\n";
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/sizeField/IsoMeshSize.h b/Adapt/sizeField/IsoMeshSize.h
deleted file mode 100644
index 2aaf1a7..0000000
--- a/Adapt/sizeField/IsoMeshSize.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_ISOMESHSIZE
-#define _H_ISOMESHSIZE
-
-#include "MeshSizeBase.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- // This class stores an isotropic mesh size (prescribed edge length)
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- class IsoMeshSize : public MeshSizeBase {
-
- public:
-
- IsoMeshSize(double _h=-1.);
- IsoMeshSize(const IsoMeshSize &);
- ~IsoMeshSize() {};
-
- public:
-
- MeshSizeType getType() const;
- MAdMetric getMetric() const { return MAdMetric(1./(h*h)); }
-
- void intersect(const pMSize pMS0, const pMSize pMS1);
- void intersect(const pMSize pMS);
-
- void interpolate(const pMSize, const pMSize, double);
- void interpolate(const pMSize, const pMSize, const pMSize,
- double, double);
- void interpolate(const pMSize, const pMSize, const pMSize, const pMSize,
- double, double, double);
-
- double direction(int i, double dir[3]) const;
- double size(int i=0) const;
- void sizes(double _h[3]) const;
- double normSq(const double vec[3]) const;
- double lengthSqInDir(const double dir[3]) const ;
- double getMeanLength() const;
-
- void setSize(double);
-
- void scale(int, double);
- void scale(double);
-
- void print(std::string name="") const;
-
- private:
-
- double h;
- };
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/sizeField/LocalSizeField.cc b/Adapt/sizeField/LocalSizeField.cc
deleted file mode 100644
index 91ce927..0000000
--- a/Adapt/sizeField/LocalSizeField.cc
+++ /dev/null
@@ -1,424 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "LocalSizeField.h"
-#include "IsoMeshSize.h"
-#include "AnisoMeshSize.h"
-#include "MathUtils.h"
-#include "MAdMessage.h"
-#include "MeshParametersManager.h"
-
-#include <iostream>
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::set;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- LocalSizeField::LocalSizeField(pMesh m):
- SizeFieldBase(), mesh(m),
- isotropic(true), radius(-1.), sFct(NULL), tgSize(-1.),
- dFct(mesh)
- {
- }
-
- // -------------------------------------------------------------------
- LocalSizeField::LocalSizeField(const LocalSizeField& _lsf): dFct(NULL)
- {
- throw;
- }
-
- // -------------------------------------------------------------------
- LocalSizeField::~LocalSizeField()
- {
- if ( sFct ) delete sFct;
- }
-
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
- void LocalSizeField::addGeometricEntity(int type, int tag)
- {
- geomEntities.insert( std::make_pair(type,tag) );
- }
-
- // -------------------------------------------------------------------
- void LocalSizeField::setIsoSize(double rad, FUNCTION_TYPE type,
- double sizeIn, double sizeOut)
- {
- isotropic = true;
- radius = rad;
- if ( sFct ) delete sFct;
- if ( type == FT_LINEAR ) sFct = new linearFct( ( sizeOut-sizeIn ) / radius, sizeIn );
- else sFct = new sqrtFct( ( sizeOut-sizeIn ) / sqrt(radius), sizeIn );
- tgSize = -1.;
- }
-
- // -------------------------------------------------------------------
- void LocalSizeField::setAnisoSize(double rad, FUNCTION_TYPE type,
- double sizeIn, double sizeOut,
- double _tgSize)
- {
- isotropic = false;
- radius = rad;
- if ( sFct ) delete sFct;
- if ( type == FT_LINEAR ) sFct = new linearFct( ( sizeOut-sizeIn ) / radius, sizeIn );
- else sFct = new sqrtFct( ( sizeOut-sizeIn ) / sqrt(radius), sizeIn );
- tgSize = _tgSize;
- }
-
- // -------------------------------------------------------------------
- pMSize LocalSizeField::getSize(const pVertex pv) const
- {
- double dist = dFct.getDistance(pv);
-
- pMSize theSize;
-
- if (dist >= radius) {
- theSize = new IsoMeshSize (MeshParametersManagerSgl::instance().getBigLength());
- }
- else {
- if ( isotropic ) {
- theSize = new IsoMeshSize( sFct->y(dist) );
- }
- else {
- double nor[3];
- if ( !dFct.getGradient(pv,nor) ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Gradient not available for vertex %p",pv);
- }
- if ( fabs(nor[0]) <= MAdTOL && fabs(nor[1]) <= MAdTOL && fabs(nor[2]) <= MAdTOL ) {
- theSize = new IsoMeshSize( sFct->y(dist) );
- }
- else {
- theSize = new AnisoMeshSize( nor, sFct->y(dist), tgSize );
- }
- }
- }
- return theSize;
- }
-
- // -------------------------------------------------------------------
- pMSize LocalSizeField::getSizeOnEntity(const pEntity pe,
- const double xyz[3]) const
- {
- double dist = dFct.computeDistance(xyz);
-
- pMSize theSize;
-
- if (dist > radius) {
- theSize = new IsoMeshSize (MeshParametersManagerSgl::instance().getBigLength());
- }
- else {
- if ( isotropic ) {
- theSize = new IsoMeshSize( sFct->y(dist) );
- }
- else {
- double nor[3];
- if ( !dFct.getGradientOnEntity(pe,xyz,nor) ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Gradient not available for entity %p",pe);
- }
- if ( fabs(nor[0]) <= MAdTOL && fabs(nor[1]) <= MAdTOL && fabs(nor[2]) <= MAdTOL ) {
- theSize = new IsoMeshSize( sFct->y(dist) );
- }
- else {
- theSize = new AnisoMeshSize( nor, sFct->y(dist), tgSize );
- }
- }
- }
- return theSize;
- }
-
- // ----------------------------------------------------------------------
- double LocalSizeField::getDistance(const double xyz[3]) const
- {
- return dFct.computeDistance(xyz);
- }
-
- // -------------------------------------------------------------------
- // Length squared computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double LocalSizeField::SF_VV_lengthSq(const pVertex pV0, const pVertex pV1) const
- {
- double xyz[2][3];
- V_coord(pV0,xyz[0]);
- V_coord(pV1,xyz[1]);
-
- pMSize pS[2];
- pS[0] = getSize(pV0);
- pS[1] = getSize(pV1);
-
- double lSq = SF_XYZ_lengthSq(xyz[0],xyz[1],pS[0],pS[1]);
-
- if ( pS[0] ) delete pS[0];
- if ( pS[1] ) delete pS[1];
-
- return lSq;
- }
-
- // -------------------------------------------------------------------
- double LocalSizeField::SF_XYZ_lengthSq(const double xyz0[3],
- const double xyz1[3],
- const pMSize pS0,
- const pMSize pS1) const
- {
- if( pS0 )
- {
- double e[3];
- diffVec(xyz0,xyz1,e);
- double lenSq0 = pS0->normSq(e);
- if ( pS1 )
- {
- double lenSq1 = pS1->normSq(e);
- return sqrt(lenSq0*lenSq1);
- }
- else return lenSq0;
- }
- else {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"No size defined");
- }
- return 0.;
- }
-
- // -------------------------------------------------------------------
- // Area squared computation
- // -------------------------------------------------------------------
-
- double LocalSizeField::SF_F_areaSq(const pFace face) const
- {
- double area = 0.;
-
- double xyz[3][3];
- F_coordP1(face,xyz);
-
- void * temp = 0;
- pPList fVerts = F_vertices(face,1);
- while( pVertex pV = (pVertex)PList_next(fVerts,&temp) )
- {
- pMSize pS = getSize(pV);
- area += SF_XYZ_areaSq(xyz,pS,0);
- if (pS) delete pS;
- }
- PList_delete(fVerts);
-
- area /= F_numVertices(face);
-
- return area;
- }
-
- // -------------------------------------------------------------------
- double LocalSizeField::SF_XYZ_areaSq(const double fxyz[3][3],
- const pMSize pS,
- const double norDir[3]) const
- {
- if( !pS ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"No size defined");
- }
-
- // get the two first edges
- double e01[3],e02[3];
- diffVec(fxyz[1],fxyz[0],e01);
- diffVec(fxyz[2],fxyz[0],e02);
-
- double nor[3];
- crossProd(e01,e02,nor);
-
- double l1SqInv = 1. / pS->lengthSqInDir(e01);
- double l2SqInv = 1. / pS->lengthSqInDir(e02);
-
- if( norDir && dotProd(norDir,nor) < MAdTOL ) return 0.;
-
- double areaSq = 0.25 * dotProd(nor,nor) * l1SqInv * l2SqInv;
- if( areaSq < MAdTOL ) return 0.;
-
- return areaSq;
- }
-
- // -------------------------------------------------------------------
- // Volume computation
- // -------------------------------------------------------------------
-
- double LocalSizeField::SF_R_volume(const pRegion region) const
- {
- double vol = 0.;
-
- double xyz[4][3];
- R_coordP1(region,xyz);
-
- pPList rVerts = R_vertices(region);
- void * temp = 0;
- while( pVertex pV = (pVertex)PList_next(rVerts,&temp) )
- {
- pMSize pS = getSize(pV);
- vol += SF_XYZ_volume(xyz,pS);
- if (pS) delete pS;
- }
- PList_delete(rVerts);
-
- vol /= R_numVertices(region);
-
- return vol;
- }
-
- // -------------------------------------------------------------------
- double LocalSizeField::SF_XYZ_volume(const double xyz[4][3], const pMSize pS) const
- {
- if( !pS ) {
- printf("Error in LocalSizeField::volume: no size given\n");
- throw;
- }
-
- double physVol = R_XYZ_volume(xyz);
-
- return ( physVol / (pS->size(0)*pS->size(1)*pS->size(2)) );
- }
-
- // -------------------------------------------------------------------
- // Center of edge computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double LocalSizeField::SF_E_center(const pEdge edge, double center[3],
- double * reducSq, pMSize * cSize) const
- {
- return SF_VV_center(E_vertex(edge,0),E_vertex(edge,1),center,reducSq,cSize);
- }
-
- // -------------------------------------------------------------------
- double LocalSizeField::SF_VV_center(const pVertex v0, const pVertex v1,
- double center[3], double * reducSq,
- pMSize * cSize) const
- {
- double xyz[2][3];
- V_coord(v0,xyz[0]);
- V_coord(v1,xyz[1]);
-
- pMSize pS[2];
- pS[0] = getSize(v0);
- pS[1] = getSize(v1);
-
- double cParam = SF_XYZ_center(xyz,pS,center,reducSq,cSize);
-
- if ( pS[0] ) delete pS[0];
- if ( pS[1] ) delete pS[1];
-
- return cParam;
- }
-
- // ----------------------------------------------------------------------
- // -------------------------------------------------------------------
- void LocalSizeField::scale(double fact)
- {
- printf("Not implemented (LocalSizeField::scale)\n");
- throw;
- }
-
- // ----------------------------------------------------------------------
- // ----------------------------------------------------------------------
- void LocalSizeField::updateTree()
- {
- set<pVertex> vertices = collectVertices();
- dFct.computeTree(vertices);
- if ( !isotropic ) dFct.computeGradientAtVertices();
- }
-
- // ----------------------------------------------------------------------
- set<pVertex> LocalSizeField::collectVertices() const
- {
- set<pVertex> vertices;
-
- set<std::pair<int,int> >::const_iterator it = geomEntities.begin();
- set<std::pair<int,int> >::const_iterator itEnd = geomEntities.end();
- for (; it != itEnd; it++) addVerticesOnGEntity(it->first, it->second, &vertices);
-
- return vertices;
- }
-
- // ----------------------------------------------------------------------
- void LocalSizeField::addVerticesOnGEntity(int type, int tag, set<pVertex> * verts) const
- {
- switch (type) {
- case 0:
- {
- VIter vit = M_vertexIter(mesh);
- while (pVertex pv = VIter_next(vit))
- {
- pGEntity pg = EN_whatIn((pEntity)pv);
- int pgType = EN_whatInType( (pEntity) pv );
- if(pg)
- if (GEN_tag(pg) == tag && pgType == 0)
- {
- verts->insert(pv);
- }
- }
- VIter_delete(vit);
- break;
- }
- case 1:
- {
- EIter eit = M_edgeIter(mesh);
- while (pEdge pe = EIter_next(eit))
- {
- pGEntity pg = EN_whatIn((pEntity)pe);
- int pgType = EN_whatInType( (pEntity) pe );
- if(pg)
- if (GEN_tag(pg) == tag && pgType == 1)
- {
- verts->insert(E_vertex (pe,0));
- verts->insert(E_vertex (pe,1));
- }
- }
- EIter_delete(eit);
- }
- case 2:
- {
- FIter fit = M_faceIter(mesh);
- while (pFace pf = FIter_next(fit))
- {
- pGEntity pg = EN_whatIn((pEntity)pf);
- int pgType = EN_whatInType( (pEntity) pf );
- if(pg)
- if (GEN_tag(pg) == tag && pgType == 2)
- {
- verts->insert(F_vertex (pf,0));
- verts->insert(F_vertex (pf,1));
- verts->insert(F_vertex (pf,2));
- }
- }
- FIter_delete(fit);
- }
- case 3:
- {
- RIter rit = M_regionIter(mesh);
- while (pRegion pr = RIter_next(rit))
- {
- pGEntity pg = EN_whatIn((pEntity)pr);
- int pgType = EN_whatInType( (pEntity) pr );
- if(pg)
- if (GEN_tag(pg) == tag && pgType == 3)
- {
- verts->insert(R_vertex (pr,0));
- verts->insert(R_vertex (pr,1));
- verts->insert(R_vertex (pr,2));
- verts->insert(R_vertex (pr,3));
- }
- }
- RIter_delete(rit);
- }
- }
- }
-
- // ----------------------------------------------------------------------
-
-}
diff --git a/Adapt/sizeField/LocalSizeField.h b/Adapt/sizeField/LocalSizeField.h
deleted file mode 100644
index 9baea72..0000000
--- a/Adapt/sizeField/LocalSizeField.h
+++ /dev/null
@@ -1,137 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_LOCALSIZEFIELD
-#define _H_LOCALSIZEFIELD
-
-#include "SizeFieldBase.h"
-#include "DistanceFunction.h"
-
-#include <set>
-#include <utility>
-
-// -------------------------------------------------------------------
-/*
- This class stores a size field around an object.
- The object is defined by a set of geometrical entities.
- The sizes are determined according to 3 values:
- - the size on the object
- - the thickness of the zone on which the local size field is acting
- - the size at the external boundary of that zone
- The value of the size at a point located in the zone is obtained by a
- linear interpolation. Outside the zone, it returns a huge size.
-*/
-// -------------------------------------------------------------------
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- enum FUNCTION_TYPE {
- FT_LINEAR,
- FT_SQRT
- };
-
- class function {
- public:
- function() {}
- virtual FUNCTION_TYPE type() const = 0;
- virtual double y(double x) const = 0;
- };
-
- class linearFct : public function { // y = a*x + b
- public:
- linearFct(double _a, double _b): function(), a(_a), b(_b) {}
- virtual FUNCTION_TYPE type() const { return FT_LINEAR; };
- virtual double y(double x) const { return (a*x+b); }
- private:
- double a, b;
- };
-
- class sqrtFct : public function { // y = a*sqrt(x) + b
- public:
- sqrtFct(double _a, double _b): function(), a(_a), b(_b) {}
- virtual FUNCTION_TYPE type() const { return FT_SQRT; };
- virtual double y(double x) const { return (a*sqrt(x)+b); }
- private:
- double a, b;
- };
-
- // -------------------------------------------------------------------
- class LocalSizeField : public SizeFieldBase {
-
- public:
-
- LocalSizeField(pMesh m);
- LocalSizeField(const LocalSizeField& _lsf);
- ~LocalSizeField();
-
- sFieldType getType() const { return LOCALSFIELD; }
-
- void scale(double);
-
- void addGeometricEntity(int type, int tag);
- void updateTree();
-
- void setIsoSize(double rad, FUNCTION_TYPE type,
- double sizeIn, double sizeOut);
- void setAnisoSize(double rad, FUNCTION_TYPE type,
- double sizeIn, double sizeOut, double _tgSize);
-
- // get the size at a location (allocate space!)
- pMSize getSize(const pVertex) const;
- pMSize getSizeOnEntity(const pEntity, const double[3]) const;
-
- // edge length (squared)
- double SF_VV_lengthSq(const pVertex, const pVertex) const;
- double SF_XYZ_lengthSq(const double[3], const double[3],
- const pMSize, const pMSize=NULL) const;
-
- // face area (squared)
- double SF_F_areaSq(const pFace) const;
- double SF_XYZ_areaSq(const double[3][3], const pMSize,
- const double[3]) const;
-
- // region volume
- double SF_R_volume(const pRegion) const;
- double SF_XYZ_volume(const double[4][3], const pMSize) const;
-
- // center and its associated size
- double SF_E_center(const pEdge, double[3], double * reducSq, pMSize *) const;
- double SF_VV_center(const pVertex, const pVertex,
- double[3], double * reducSq, pMSize *) const;
-
- private:
-
- std::set<pVertex> collectVertices() const;
- void addVerticesOnGEntity(int type, int tag, std::set<pVertex> * verts) const;
-
- double getDistance(const double[3]) const;
-
- private:
-
- pMesh mesh;
-
- std::set<std::pair<int,int> > geomEntities; // set of (type,tag)
-
- bool isotropic;
- double radius;
- function * sFct;
- double tgSize;
-
- distanceFunction dFct;
- };
-
-}
-
-// -------------------------------------------------------------------
-#endif
diff --git a/Adapt/sizeField/MeshSizeBase.cc b/Adapt/sizeField/MeshSizeBase.cc
deleted file mode 100644
index 904dec9..0000000
--- a/Adapt/sizeField/MeshSizeBase.cc
+++ /dev/null
@@ -1,104 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MeshSizeBase.h"
-#include "IsoMeshSize.h"
-#include "AnisoMeshSize.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- pMSize MS_copy(const pMSize pMS)
- {
- MeshSizeType type = pMS->getType();
- switch (type) {
- case ISOTROPIC:
- return new IsoMeshSize((IsoMeshSize&)(*pMS));
- break;
- case ANISOTROPIC:
- return new AnisoMeshSize((AnisoMeshSize&)(*pMS));
- break;
- default:
- throw;
- }
- }
-
- // -------------------------------------------------------------------
- pMSize MS_intersect(const pMSize pMS0, const pMSize pMS1)
- {
- pMSize newS;
- if ( pMS0->getType() == ISOTROPIC &&
- pMS1->getType() == ISOTROPIC ) {
- newS = new IsoMeshSize();
- }
- else {
- newS = new AnisoMeshSize();
- }
- newS->intersect(pMS0,pMS1);
-
- return newS;
- }
-
- // -------------------------------------------------------------------
- pMSize MS_interpolate(const pMSize pMS0, const pMSize pMS1, double param)
- {
- pMSize newS;
- if ( pMS0->getType() == ISOTROPIC &&
- pMS1->getType() == ISOTROPIC ) {
- newS = new IsoMeshSize();
- }
- else {
- newS = new AnisoMeshSize();
- }
- newS->interpolate(pMS0,pMS1,param);
- return newS;
- }
-
- // -------------------------------------------------------------------
- pMSize MS_interpolate(const pMSize pMS0, const pMSize pMS1,
- const pMSize pMS2, double u, double v)
- {
- pMSize newS;
- if ( pMS0->getType() == ISOTROPIC &&
- pMS1->getType() == ISOTROPIC &&
- pMS2->getType() == ISOTROPIC ) {
- newS = new IsoMeshSize();
- }
- else {
- newS = new AnisoMeshSize();
- }
- newS->interpolate(pMS0,pMS1,pMS2,u,v);
- return newS;
- }
-
- // -------------------------------------------------------------------
- pMSize MS_interpolate(const pMSize pMS0, const pMSize pMS1,
- const pMSize pMS2, const pMSize pMS3,
- double u, double v, double w)
- {
- pMSize newS;
- if ( pMS0->getType() == ISOTROPIC &&
- pMS1->getType() == ISOTROPIC &&
- pMS2->getType() == ISOTROPIC &&
- pMS3->getType() == ISOTROPIC ) {
- newS = new IsoMeshSize();
- }
- else {
- newS = new AnisoMeshSize();
- }
- newS->interpolate(pMS0,pMS1,pMS2,pMS3,u,v,w);
- return newS;
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/sizeField/MeshSizeBase.h b/Adapt/sizeField/MeshSizeBase.h
deleted file mode 100644
index b8e3245..0000000
--- a/Adapt/sizeField/MeshSizeBase.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MESHSIZEBASE
-#define _H_MESHSIZEBASE
-
-#include "MAdMetric.h"
-
-#include <string>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- enum MeshSizeType {
- ISOTROPIC,
- ANISOTROPIC
- };
-
- // -------------------------------------------------------------------
- typedef class MeshSizeBase * pMSize;
-
- // -------------------------------------------------------------------
- pMSize MS_copy(const pMSize pMS);
- pMSize MS_intersect(const pMSize pMS0, const pMSize pMS1);
- // interpolate on an edge
- pMSize MS_interpolate(const pMSize, const pMSize, double);
- // interpolate on a triangle
- pMSize MS_interpolate(const pMSize, const pMSize, const pMSize,
- double, double);
- // interpolate on a tetrahedron
- pMSize MS_interpolate(const pMSize, const pMSize, const pMSize, const pMSize,
- double, double, double);
-
- // -------------------------------------------------------------------
- // This class stores a mesh size (prescribed edge length)
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- class MeshSizeBase
- {
- public:
-
- MeshSizeBase() {};
- virtual ~MeshSizeBase() {};
-
- public:
-
- virtual MeshSizeType getType() const = 0;
- virtual MAdMetric getMetric() const = 0;
-
- // this becomes the minimum size between two sizes
- virtual void intersect(const pMSize pMS0, const pMSize pMS1) = 0;
-
- // this becomes the interpolation between two sizes
- virtual void interpolate(const pMSize, const pMSize, double) = 0;
- // this becomes the interpolation between three sizes
- virtual void interpolate(const pMSize, const pMSize, const pMSize,
- double, double) = 0;
- // this becomes the interpolation between four sizes
- virtual void interpolate(const pMSize, const pMSize, const pMSize, const pMSize,
- double, double, double) = 0;
-
- // get a principle direction (eigenvectors of the metric)
- virtual double direction(int i, double dir[3]) const = 0;
-
- // get the desired size in a principle direction (eigenvalues)
- virtual double size(int i=0) const = 0;
-
- // get the desired size in the 3 directions (eigenvalues)
- virtual void sizes(double _h[3]) const = 0;
-
- // get the square norm of the vector in the metric
- virtual double normSq(const double vec[3]) const = 0;
-
- // get the desired size in the given direction
- virtual double lengthSqInDir(const double dir[3]) const = 0;
-
- // get the mean size
- virtual double getMeanLength() const = 0;
-
- // scale the size
- virtual void scale(double) = 0;
-
- // print info
- virtual void print(std::string name="") const = 0;
-
- };
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/sizeField/NullSField.cc b/Adapt/sizeField/NullSField.cc
deleted file mode 100644
index 3bd1d8b..0000000
--- a/Adapt/sizeField/NullSField.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "NullSField.h"
-#include "MathUtils.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- // Length squared computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double NullSField::SF_VV_lengthSq(const pVertex v0, const pVertex v1) const
- {
- double xyz[2][3];
- V_coord(v0,xyz[0]);
- V_coord(v1,xyz[1]);
-
- return SF_XYZ_lengthSq(xyz[0],xyz[1],NULL,NULL);
- }
-
- // -------------------------------------------------------------------
- double NullSField::SF_XYZ_lengthSq(const double xyz0[3], const double xyz1[3],
- const pMSize, const pMSize) const
- {
- double vec[3];
- diffVec(xyz0,xyz1,vec);
-
- return dotProd(vec,vec);
- }
-
- // -------------------------------------------------------------------
- // Area squared computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double NullSField::SF_F_areaSq(const pFace face) const
- {
- double xyz[3][3];
- F_coordP1(face,xyz);
-
- return SF_XYZ_areaSq(xyz,NULL,NULL);
- }
-
- // -------------------------------------------------------------------
- double NullSField::SF_XYZ_areaSq(const double xyz[3][3], const pMSize,
- const double norDir[3]) const
- {
- return XYZ_F_areaSq(xyz,norDir);
- }
-
- // -------------------------------------------------------------------
- // Volume computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double NullSField::SF_R_volume(const pRegion r) const
- {
- return R_volume(r);
- }
-
- // -------------------------------------------------------------------
- double NullSField::SF_XYZ_volume(const double xyz[4][3],
- const pMSize) const
- {
- return R_XYZ_volume(xyz);
- }
-
- // -------------------------------------------------------------------
- // Center of edge computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double NullSField::SF_E_center(const pEdge edge,
- double center[3], double * reducSq,
- pMSize *) const
- {
- return SF_VV_center(E_vertex(edge,0),E_vertex(edge,1),center,reducSq,NULL);
- }
-
- // -------------------------------------------------------------------
- double NullSField::SF_VV_center(const pVertex v0, const pVertex v1,
- double center[3], double * reducSq,
- pMSize *) const
- {
- double xyz[2][3];
- V_coord(v0,xyz[0]);
- V_coord(v1,xyz[1]);
-
- for(int i=0; i<3; i++) center[i] = 0.5*(xyz[0][i]+xyz[1][i]);
- *reducSq = 0.5;
- return 0.5;
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/sizeField/NullSField.h b/Adapt/sizeField/NullSField.h
deleted file mode 100644
index ff1e9b3..0000000
--- a/Adapt/sizeField/NullSField.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_NULLSFIELD
-#define _H_NULLSFIELD
-
-#include "SizeFieldBase.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class NullSField : public SizeFieldBase
- {
- public:
-
- NullSField(): SizeFieldBase() {}
- ~NullSField() {}
-
- sFieldType getType() const { return NULLSFIELD; }
-
- // edge length (squared)
- double SF_VV_lengthSq(const pVertex, const pVertex) const;
- double SF_XYZ_lengthSq(const double[3], const double[3],
- const pMSize, const pMSize=NULL) const;
-
- // face area (squared)
- double SF_F_areaSq(const pFace) const;
- double SF_XYZ_areaSq(const double[3][3], const pMSize,
- const double[3]) const;
-
- // region volume
- double SF_R_volume(const pRegion) const;
- double SF_XYZ_volume(const double[4][3], const pMSize) const;
-
- // center and its associated size
- double SF_E_center(const pEdge, double[3], double * reducSq, pMSize *) const;
- double SF_VV_center(const pVertex, const pVertex,
- double[3], double * reducSq, pMSize *) const;
-
- public: // functions that have no sense here...
-
- void scale(double) {return;}
-
- void setSize(pEntity, pMSize) {return;}
- void setSize(pEntity, double) {return;}
- void deleteSize(pEntity) {return;}
-
- pMSize getSize(const pVertex) const {return NULL;}
- pMSize getSizeOnEntity(const pEntity, const double[3]) const {return NULL;};
- };
-
-}
-
-// -------------------------------------------------------------------
-
-#endif
diff --git a/Adapt/sizeField/PWLinearSField.cc b/Adapt/sizeField/PWLinearSField.cc
deleted file mode 100644
index 11ab5b8..0000000
--- a/Adapt/sizeField/PWLinearSField.cc
+++ /dev/null
@@ -1,590 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "PWLinearSField.h"
-#include "CallBackManager.h"
-#include "IsoMeshSize.h"
-#include "AnisoMeshSize.h"
-#include "MathUtils.h"
-#include "MAdMessage.h"
-#include "MeshParametersManager.h"
-
-#include <stdio.h>
-#include <math.h>
-#include <iostream>
-using std::cout;
-using std::cerr;
-using std::endl;
-#include <queue>
-
-using namespace MAd;
-
-// -------------------------------------------------------------------
-void PWLinearSFCBFunction (pPList before, pPList after, void * data,
- operationType type , pEntity ppp)
-{
- PWLSField * pwl = (PWLSField *)(data);
-
- switch (type) {
- case MAd_ESPLIT: {
-
- double xyz[3];
- V_coord((pVertex)ppp,xyz);
-
- // find the old edge
- void *tmp=0;
- pEntity pE = PList_next(before,&tmp);
-
- // interpolate size at new location
- pMSize newSize = pwl->getSizeOnEntity(pE,xyz);
-
- pwl->setSize(ppp,newSize);
- break;
- }
- case MAd_ECOLLAPSE: {
- pwl->deleteSize(ppp);
- break;
- }
- case MAd_FSWAP:
- case MAd_ESWAP: {
- break;
- }
- case MAd_RREMOVE: {
- void * temp = NULL;
- while ( pEntity pE = PList_next(before,&temp) ) {
- if ( EN_type(pE) == 0 ) {
- pwl->deleteSize( (pVertex)pE );
- }
- }
- break;
- }
- default: {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Not implemented for mesh modification %d",
- type);
- }
- }
-}
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- PWLSField::PWLSField(pMesh m): DiscreteSF(m)
- {
- CallBackManagerSgl::instance().registerCallBack(PWLinearSFCBFunction,this);
- }
-
- // -------------------------------------------------------------------
- PWLSField::~PWLSField()
- {
- cleanUp();
- CallBackManagerSgl::instance().unregisterCallBack(PWLinearSFCBFunction,this);
- }
-
- // -------------------------------------------------------------------
- void PWLSField::cleanUp()
- {
- VIter iter = M_vertexIter(mesh);
- while( pVertex pV = VIter_next(iter) ) deleteSize((pEntity)pV);
- VIter_delete(iter);
- }
-
- // -------------------------------------------------------------------
- void PWLSField::intersect(const pSField extField)
- {
- VIter iter = M_vertexIter(mesh);
- while( pVertex pV = VIter_next(iter) )
- {
- // get the size for the extern size field
- pMSize extS = extField->getSize(pV);
- if (!extS) continue;
-
- // get the size for this size field
- pMSize intS = this->findSize(pV);
- if (!intS) {
- setSize((pEntity)pV,extS);
- }
- else {
- pMSize newS = MS_intersect(intS,extS);
- delete extS;
- setSize(pV,newS);
- }
- }
- VIter_delete(iter);
- }
-
- // -------------------------------------------------------------------
- // Smooth the size field by limiting the size gradient along an edge
- // to maxGrad
- void PWLSField::smooth(double maxGrad)
- {
- // edges still to be checked
- std::queue<pEdge> toCheck;
-
- // check every edge at least once
- EIter eIt = M_edgeIter(mesh);
- while( pEdge edge = EIter_next(eIt) ) toCheck.push(edge);
- EIter_delete(eIt);
-
- while ( !toCheck.empty() ) {
-
- std::set<pEdge> toAdd;
-
- // check the content of toCheck
- while ( !toCheck.empty() ) {
- smoothOnEdge(toCheck.front(),maxGrad,&toAdd);
- toCheck.pop();
- }
-
- // move content of toAdd to toCheck
- std::set<pEdge>::const_iterator eIter = toAdd.begin();
- for (; eIter != toAdd.end(); eIter++ ) toCheck.push(*eIter);
- toAdd.clear();
- }
- }
-
- // -------------------------------------------------------------------
- void PWLSField::smoothOnEdge(const pEdge edge, double maxGrad,
- std::set<pEdge>* toAdd)
- {
- pVertex pV[2];
- pMSize pMS[2];
- double h[2];
- for (int iV=0; iV<2; iV++) {
- pV[iV] = E_vertex(edge,iV);
- pMS[iV] = findSize(pV[iV]);
- if ( pMS[iV]->getType() != ISOTROPIC ) {
- printf("Error: PWLSField::smoothOnEdge not implemented for anisotropic sizes\n");
- exit(1);
- }
- h[iV] = ( (IsoMeshSize*)(pMS[iV]) )->size();
- }
-
- double physLength = E_length(edge);
-
- double grad = fabs( h[1] - h[0] ) / physLength;
- if ( grad > maxGrad ) {
-
- int toScale = 1;
- if ( h[0] > h[1] ) toScale = 0;
-
- double maxSize = maxGrad * physLength + h[1-toScale];
- ( (IsoMeshSize*)(pMS[toScale]) )->setSize(maxSize-MAdTOL);
-
- for( int iE=0; iE<V_numEdges(pV[toScale]); iE++ ) {
- pEdge newEdge = V_edge(pV[toScale],iE);
- if ( newEdge == edge ) continue;
- toAdd->insert(newEdge);
- }
- }
- }
-
- // -------------------------------------------------------------------
- void PWLSField::setCurrentSize()
- {
- VIter vi = M_vertexIter(mesh);
- while ( pVertex vert = VIter_next(vi) ) {
- double lenSq = V_meanEdgeLenSq(vert);
- pMSize pSV = new IsoMeshSize(sqrt(lenSq));
- setSize((pEntity)vert,pSV);
- }
- VIter_delete(vi);
- }
-
- // -------------------------------------------------------------------
- void PWLSField::setCurvatureSize(bool aniso, double alpha, double hMin)
- {
- if ( !(mesh->isParametric()) ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Curvature not available without a geometry (mesh is not parametric");
- }
-
-#ifdef _HAVE_GMSH_
- double bigLen = MeshParametersManagerSgl::instance().getBigLength();
- double curvMaxBound = 10. / hMin;
- pVertex vert;
- VIter vi = M_vertexIter(mesh);
- while ( ( vert = VIter_next(vi) ) )
- {
- pGEntity pge = V_whatIn(vert);
- int gdim = GEN_type(pge);
- pMSize pSV;
- if ( aniso && gdim==2 )
- {
- double u[2];
- V_params(vert,&(u[0]),&(u[1]));
- double dir[3][3], curv[3];
- GF_curvatures((pGFace)pge, u, dir[0], dir[1], &(curv[0]), &(curv[1]), curvMaxBound);
- crossProd(dir[0],dir[1],dir[2]);
- curv[2] = -1.;
-
- double h[3] = { -1., -1., -1. };
- for (int iD=0; iD<3; iD++) {
- if ( curv[iD] <= MAdTOL ) h[iD] = bigLen;
- else {
- h[iD] = 1. / ( curv[iD] * alpha );
- h[iD] = std::min(std::max(h[iD],hMin),bigLen);
- }
- }
-
- pSV = new AnisoMeshSize(dir,h);
- }
- else
- {
- double curv = -1.;
- switch(gdim) {
- case 3: break;
- case 2: {
- double u[2];
- V_params(vert,&(u[0]),&(u[1]));
- curv = GF_curvatureDiv((pGFace)pge, u, curvMaxBound);
- break;
- }
- case 1: {
- double u, tmp;
- V_params(vert,&u,&tmp);
- curv = GE_curvature((pGEdge)pge, u, curvMaxBound);
- break;
- }
- case 0: {
- curv = -1.;
- std::list<pGEdge> gEdges = GV_edges((pGVertex)pge);
- std::list<pGEdge>::const_iterator eIter = gEdges.begin();
- for (; eIter != gEdges.end(); eIter++) {
- pGEdge pGEd = *eIter;
- double u;
- GV_reparamOnEdge((pGVertex)pge, pGEd, &u);
- double tmpcurv = GE_curvature(pGEd, u, curvMaxBound);
- if ( tmpcurv > curv ) curv = tmpcurv;
- }
- break;
- }
- }
-
- double h = -1.;
- if ( curv <= MAdTOL ) h = bigLen;
- else {
- h = 1. / ( curv * alpha );
- h = std::min(std::max(h,hMin),bigLen);
- }
- pSV = new IsoMeshSize(h);
- }
- setSize((pEntity)vert,pSV);
- }
- VIter_delete(vi);
-#else
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Curvature not available without Gmsh");
-#endif
- }
-
- // -------------------------------------------------------------------
- void PWLSField::setAllVSizes(pMSize pS)
- {
- VIter vi = M_vertexIter(mesh);
- while ( pVertex vert = VIter_next(vi) ) {
- pMSize pSCopy = MS_copy(pS);
- setSize((pEntity)vert,pSCopy);
- }
- VIter_delete(vi);
- }
-
- // -------------------------------------------------------------------
- void PWLSField::setAllVSizes(double dirs[3][3], // three unit vectors
- double h[3])
- {
- pMSize pS = new AnisoMeshSize(dirs,h);
- setAllVSizes(pS);
- }
-
- // -------------------------------------------------------------------
- void PWLSField::setAllVSizes(double h)
- {
- pMSize pS = new IsoMeshSize(h);
- setAllVSizes(pS);
- }
-
- // -------------------------------------------------------------------
- void PWLSField::scale(double fact)
- {
- VIter vIter = M_vertexIter(mesh);
- while( pVertex pV = VIter_next(vIter) )
- {
- pMSize pS = findSize(pV);
- pS->scale(fact);
- }
- VIter_delete(vIter);
- }
-
- // -------------------------------------------------------------------
- // Length squared computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double PWLSField::SF_VV_lengthSq(const pVertex v0, const pVertex v1) const
- {
- double xyz[2][3];
- V_coord(v0,xyz[0]);
- V_coord(v1,xyz[1]);
-
- pMSize pS[2];
- pS[0] = findSize(v0);
- pS[1] = findSize(v1);
-
- return SF_XYZ_lengthSq(xyz[0],xyz[1],pS[0],pS[1]);
- }
-
- // -------------------------------------------------------------------
- double PWLSField::SF_XYZ_lengthSq(const double xyz0[3], const double xyz1[3],
- const pMSize pS0, const pMSize pS1) const
- {
- if( pS0 )
- {
- double e[3];
- diffVec(xyz0,xyz1,e);
- double lenSq0 = pS0->normSq(e);
- if ( pS1 )
- {
- double lenSq1 = pS1->normSq(e);
- return sqrt(lenSq0*lenSq1);
- }
- else return lenSq0;
- }
- else {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"No size defined");
- }
- return 0.;
- }
-
- // -------------------------------------------------------------------
- // Area squared computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double PWLSField::SF_F_areaSq(const pFace face) const
- {
- double area = 0.;
-
- double xyz[3][3];
- F_coordP1(face,xyz);
-
- void * temp = 0;
- pPList fVerts = F_vertices(face,1);
- while( pVertex pV = (pVertex)PList_next(fVerts,&temp) )
- {
- pMSize pS = findSize(pV);
- area += SF_XYZ_areaSq(xyz,pS,0);
- }
- PList_delete(fVerts);
-
- area /= F_numVertices(face);
-
- return area;
- }
-
- // -------------------------------------------------------------------
- double PWLSField::SF_XYZ_areaSq(const double fxyz[3][3], const pMSize pS,
- const double norDir[3]) const
- {
- if( !pS ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"No size defined");
- }
-
- // get the two first edges
- double e01[3],e02[3];
- diffVec(fxyz[1],fxyz[0],e01);
- diffVec(fxyz[2],fxyz[0],e02);
-
- double nor[3];
- crossProd(e01,e02,nor);
-
- double l1SqInv = 1. / pS->lengthSqInDir(e01);
- double l2SqInv = 1. / pS->lengthSqInDir(e02);
-
- if( norDir && dotProd(norDir,nor) < MAdTOL ) return 0.;
-
- double areaSq = 0.25 * dotProd(nor,nor) * l1SqInv * l2SqInv;
- if( areaSq < MAdTOL ) return 0.;
-
- return areaSq;
- }
-
- // -------------------------------------------------------------------
- // Volume computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double PWLSField::SF_R_volume(const pRegion region) const
- {
- double vol = 0.;
-
- double xyz[4][3];
- R_coordP1(region,xyz);
-
- pPList rVerts = R_vertices(region);
- void * temp = 0;
- while( pVertex pV = (pVertex)PList_next(rVerts,&temp) )
- {
- pMSize pS = findSize(pV);
- vol += SF_XYZ_volume(xyz,pS);
- }
- PList_delete(rVerts);
-
- vol /= R_numVertices(region);
-
- return vol;
- }
-
- // -------------------------------------------------------------------
- double PWLSField::SF_XYZ_volume(const double xyz[4][3], const pMSize pS) const
- {
- if( !pS ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"No size defined");
- }
-
- double physVol = R_XYZ_volume(xyz);
- double h[3];
- pS->sizes(h);
- return ( physVol / ( h[0] * h[1] * h[2]) );
- }
-
- // -------------------------------------------------------------------
- // Center of edge computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double PWLSField::SF_E_center(const pEdge edge, double center[3],
- double * reducSq, pMSize * cSize) const
- {
- return SF_VV_center(E_vertex(edge,0),E_vertex(edge,1),center,reducSq,cSize);
- }
-
- // -------------------------------------------------------------------
- double PWLSField::SF_VV_center(const pVertex v0, const pVertex v1,
- double center[3], double * reducSq,
- pMSize * cSize) const
- {
- double xyz[2][3];
- V_coord(v0,xyz[0]);
- V_coord(v1,xyz[1]);
-
- pMSize pS[2];
- pS[0] = findSize(v0);
- pS[1] = findSize(v1);
-
- return SF_XYZ_center(xyz,pS,center,reducSq,cSize);
- }
-
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- const pMSize PWLSField::findSize(const pVertex pV) const
- {
- void * size;
- if( EN_getDataPtr( (pEntity)pV, pMSizeFieldId, &size) ) return (pMSize)size;
- return NULL;
- }
-
- // -------------------------------------------------------------------
- pMSize PWLSField::findSize(const pVertex pV)
- {
- void * size;
- if( EN_getDataPtr( (pEntity)pV, pMSizeFieldId, &size) ) return (pMSize)size;
- return NULL;
- }
-
- // -------------------------------------------------------------------
- pMSize PWLSField::getSize(const pVertex pV) const
- {
- void * temp;
- if( EN_getDataPtr((pEntity)pV,pMSizeFieldId,&temp) ) {
- return MS_copy((pMSize)temp);
- }
- return NULL;
- }
-
- // -------------------------------------------------------------------
- pMSize PWLSField::getSizeOnEntity(const pEntity entity,
- const double xyz[3]) const
- {
- int type = EN_type(entity);
- switch(type) {
- case 0: return getSize((pVertex)entity);
- case 1: return getSizeOnEdge((pEdge)entity,xyz);
- case 2: return getSizeOnFace((pFace)entity,xyz);
- case 3: return getSizeOnRegion((pRegion)entity,xyz);
- }
- return NULL;
- }
-
- // -------------------------------------------------------------------
- pMSize PWLSField::getSizeOnEdge(const pEdge edge,
- const double xyz[3]) const
- {
- double u = E_linearParams(edge,xyz);
- return getSizeOnEdgeParam(edge,u);
- }
-
- // -------------------------------------------------------------------
- pMSize PWLSField::getSizeOnEdgeParam(const pEdge pE,
- const double u) const
- {
- pMSize pS0 = findSize( E_vertex(pE,0) );
- pMSize pS1 = findSize( E_vertex(pE,1) );
-
- return MS_interpolate( pS0, pS1, u );
- }
-
- // -------------------------------------------------------------------
- pMSize PWLSField::getSizeOnFace(const pFace face,
- const double xyz[3]) const
- {
- double u[2];
- F_linearParams(face,xyz,u);
- return getSizeOnFaceParam(face,u);
- }
-
- // -------------------------------------------------------------------
- pMSize PWLSField::getSizeOnFaceParam(const pFace face,
- const double u[2]) const
- {
- pMSize pS0 = findSize( F_vertex(face,0) );
- pMSize pS1 = findSize( F_vertex(face,1) );
- pMSize pS2 = findSize( F_vertex(face,2) );
-
- return MS_interpolate( pS0, pS1, pS2, u[0], u[1] );
- }
-
- // -------------------------------------------------------------------
- pMSize PWLSField::getSizeOnRegion(const pRegion region,
- const double xyz[3]) const
- {
- double u[3];
- R_linearParams(region, xyz, u);
- return getSizeOnRegionParam(region, u);
- }
-
- // -------------------------------------------------------------------
- pMSize PWLSField::getSizeOnRegionParam(const pRegion region,
- const double u[3]) const
- {
- pMSize pS0 = findSize( R_vertex(region,0) );
- pMSize pS1 = findSize( R_vertex(region,1) );
- pMSize pS2 = findSize( R_vertex(region,2) );
- pMSize pS3 = findSize( R_vertex(region,3) );
-
- return MS_interpolate( pS0, pS1, pS2, pS3, u[0], u[1], u[2] );
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/sizeField/PWLinearSField.h b/Adapt/sizeField/PWLinearSField.h
deleted file mode 100644
index baf5da3..0000000
--- a/Adapt/sizeField/PWLinearSField.h
+++ /dev/null
@@ -1,96 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_PWLINEARSFIELD
-#define _H_PWLINEARSFIELD
-
-#include "DiscreteSF.h"
-
-#include <set>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class PWLSField : public DiscreteSF
- {
- public:
-
- PWLSField(pMesh);
- ~PWLSField();
-
- DiscreteSFType discretization() const { return VERTEX_P1_DSFTYPE; }
-
- // delete sizes
- void cleanUp();
-
- // Intersect with another size field
- void intersect(const pSField);
-
- // smooth the size field
- void smooth(double);
-
- // set a size at all vertices
- void setCurrentSize();
- void setCurvatureSize(bool aniso,
- double alpha=2., // prescribe 2*PI*alpha edges around a circle
- double hMin=1.e-4); // minimal size
- void setAllVSizes(pMSize);
- void setAllVSizes(double[3][3], double[3]);
- void setAllVSizes(double);
- void scale(double);
-
- // get the size at a location (allocate space!)
- pMSize getSize(const pVertex) const;
- pMSize getSizeOnEntity(const pEntity, const double[3]) const;
-
- // get the size at a vertex (do not allocate space)
- const pMSize findSize(const pVertex) const;
- pMSize findSize(const pVertex);
-
- // edge length (squared)
- double SF_VV_lengthSq(const pVertex, const pVertex) const;
- double SF_XYZ_lengthSq(const double[3], const double[3],
- const pMSize, const pMSize=NULL) const;
-
- // face area (squared)
- double SF_F_areaSq(const pFace) const;
- double SF_XYZ_areaSq(const double[3][3], const pMSize,
- const double[3]) const;
-
- // region volume
- double SF_R_volume(const pRegion) const;
- double SF_XYZ_volume(const double[4][3], const pMSize) const;
-
- // center and its associated size
- double SF_E_center(const pEdge, double[3], double * reducSq, pMSize *) const;
- double SF_VV_center(const pVertex, const pVertex,
- double[3], double * reducSq, pMSize *) const;
-
- protected:
-
- pMSize getSizeOnEdge(const pEdge, const double[3]) const;
- pMSize getSizeOnEdgeParam(const pEdge, const double) const;
- pMSize getSizeOnFace(const pFace, const double[3]) const;
- pMSize getSizeOnFaceParam(const pFace, const double[2]) const;
- pMSize getSizeOnRegion(const pRegion, const double[3]) const;
- pMSize getSizeOnRegionParam(const pRegion, const double[3]) const;
-
- void smoothOnEdge(const pEdge, double, std::set<pEdge>*);
-
- };
-
-}
-
-// -------------------------------------------------------------------
-
-#endif
diff --git a/Adapt/sizeField/SizeFieldBase.cc b/Adapt/sizeField/SizeFieldBase.cc
deleted file mode 100644
index fe92001..0000000
--- a/Adapt/sizeField/SizeFieldBase.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "SizeFieldBase.h"
-#include "MAdOutput.h"
-#include "MathUtils.h"
-
-using std::string;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- // Length squared computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double SizeFieldBase::SF_E_lengthSq(const pEdge edge) const
- {
- return SF_VV_lengthSq(E_vertex(edge,0),E_vertex(edge,1));
- }
-
- // -------------------------------------------------------------------
- // Center of edge computation
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- double SizeFieldBase::SF_XYZ_center(const double xyz[2][3], const pMSize pS[2],
- double center[3], double * reducSq,
- pMSize * cSize) const
- {
- if( !pS[0] || !pS[1] ) {
- printf("Error in SizeFieldBase::SF_XYZ_center: one of the sizes is NULL\n");
- throw;
- }
-
- double vec[3];
- diffVec(xyz[1],xyz[0],vec);
-
- double lenSq[2];
- lenSq[0] = pS[0]->lengthSqInDir(vec);
- lenSq[1] = pS[1]->lengthSqInDir(vec);
- double lenRatSqrt = pow(lenSq[1]/lenSq[0],0.25);
-
- double cParam = 1. / ( 1. + lenRatSqrt );
- *reducSq = 1. / ( 1./lenRatSqrt + lenRatSqrt + 2 );
-
-// double len[2];
-// len[0] = sqrt(pS[0]->lengthSqInDir(vec));
-// len[1] = sqrt(pS[1]->lengthSqInDir(vec));
-
-// double cParam = len[0] / ( len[0] + len[1] );
-
- for (int i=0; i<3; i++) {
- center[i] = cParam * xyz[1][i] + (1-cParam) * xyz[0][i];
- }
-
- *cSize = MS_interpolate(pS[0],pS[1],cParam);
-
- return cParam;
- }
-
- // -------------------------------------------------------------------
- void SizeFieldBase::printPosIsotropic(const pMesh mesh, const string name)
- {
- MAdGmshOutput(mesh, this, name.c_str(), OD_ISOSIZEFIELD);
- }
-
- // -------------------------------------------------------------------
- void SizeFieldBase::printPosAnisotropic(const pMesh mesh, const string baseName)
- {
- string name0 = baseName + "0.pos";
- MAdGmshOutput(mesh, this, name0.c_str(), OD_ANISO_SF_AXIS0);
- string name1 = baseName + "1.pos";
- MAdGmshOutput(mesh, this, name1.c_str(), OD_ANISO_SF_AXIS1);
- string name2 = baseName + "2.pos";
- MAdGmshOutput(mesh, this, name2.c_str(), OD_ANISO_SF_AXIS2);
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/sizeField/SizeFieldBase.h b/Adapt/sizeField/SizeFieldBase.h
deleted file mode 100644
index 8247db6..0000000
--- a/Adapt/sizeField/SizeFieldBase.h
+++ /dev/null
@@ -1,96 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_SIZEFIELDBASE
-#define _H_SIZEFIELDBASE
-
-#include "MeshSizeBase.h"
-#include "MSops.h"
-#include "MAdDefines.h"
-
-#include <string>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- enum sFieldType {
- UNKNOWNSFIELDTYPE,
- NULLSFIELD,
- DISCRETESFIELD,
- ANALYTICALSFIELD,
- LOCALSFIELD
- };
-
- // -------------------------------------------------------------------
- typedef class SizeFieldBase * pSField;
-
- // -------------------------------------------------------------------
- class SizeFieldBase
- {
- public:
-
- SizeFieldBase() {};
- virtual ~SizeFieldBase() {};
-
- public:
-
- virtual sFieldType getType() const = 0 ;
-
- virtual void scale(double) = 0;
-
- public:
-
- // edge length (squared)
- virtual double SF_E_lengthSq(const pEdge) const;
- virtual double SF_VV_lengthSq(const pVertex,const pVertex) const = 0;
- virtual double SF_XYZ_lengthSq(const double[3], const double[3],
- const pMSize, const pMSize=NULL) const = 0;
-
- // face area (squared)
- virtual double SF_F_areaSq(const pFace) const = 0;
- virtual double SF_XYZ_areaSq(const double[3][3], const pMSize,
- const double[3]) const = 0;
-
- // region volume
- virtual double SF_R_volume(const pRegion) const = 0;
- virtual double SF_XYZ_volume(const double[4][3], const pMSize) const = 0;
-
- // center and its associated size
- virtual double SF_E_center(const pEdge, double[3], double * reducSq, pMSize *) const = 0;
- virtual double SF_VV_center(const pVertex, const pVertex,
- double[3], double * reducSq, pMSize *) const = 0;
- virtual double SF_XYZ_center(const double[2][3], const pMSize[2],
- double[3], double * reducSq, pMSize *) const;
-
- public:
-
- // get the size at a location
- // --- Memory is allocated ! ---
- virtual pMSize getSize(const pVertex) const = 0;
- virtual pMSize getSizeOnEntity(const pEntity,
- const double[3]) const = 0;
-
- public:
-
- // visualisation of the isotropic size in a .pos file
- void printPosIsotropic (const pMesh mesh, const std::string name);
- // visualisation of the anisotropic size in a .pos file
- void printPosAnisotropic(const pMesh mesh, const std::string baseName);
-
- };
-
-}
-
-// -------------------------------------------------------------------
-
-#endif
diff --git a/Adapt/sizeField/SizeFieldManager.cc b/Adapt/sizeField/SizeFieldManager.cc
deleted file mode 100644
index 57a8b10..0000000
--- a/Adapt/sizeField/SizeFieldManager.cc
+++ /dev/null
@@ -1,175 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "SizeFieldManager.h"
-#include "NullSField.h"
-#include "MAdTimeManager.h"
-#include "MeshQualityManager.h"
-#include "MAdMessage.h"
-
-#include <iostream>
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::set;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- SizeFieldManager::SizeFieldManager(pMesh m, pSField psf):
- localTime(-1.),smooth(false),maxGradient(1.)
- {
- if (!m) return;
- mesh = m;
-
- mainSF = new PWLSField(mesh);
-
- localTime = MAdTimeManagerSgl::instance().getTime();
-
- if (!psf) MAdMsgSgl::instance().warning(__LINE__,__FILE__,"No size field registered");
-
- else {
-
- mainSF->intersect(psf);
-
- sFieldType type = psf->getType();
- switch (type) {
- case NULLSFIELD: {
- break;
- }
- case DISCRETESFIELD: {
- assert ( ((DiscreteSF*)psf)->discretization() == VERTEX_P1_DSFTYPE );
- PWLSField* linsf = static_cast<PWLSField*>(psf);
- addPWLinearSF( linsf );
- break;
- }
- case ANALYTICALSFIELD: {
- AnalyticalSField* asf = static_cast<AnalyticalSField*>(psf);
- addAnalyticalSF( asf );
- break;
- }
- case LOCALSFIELD: {
- LocalSizeField* locsf = static_cast<LocalSizeField*>(psf);
- addLocalSF( locsf );
- break;
- }
- default: {
- cerr <<"Error: unknown size field type "<<type<<"\n"; throw;
- }
- }
- }
- }
-
- // -------------------------------------------------------------------
- SizeFieldManager::~SizeFieldManager() {
-
- if (mainSF) delete mainSF;
- linears.clear();
- analyticals.clear();
- locals.clear();
- }
-
- // -------------------------------------------------------------------
- void SizeFieldManager::setMesh(pMesh m)
- {
- mesh = m;
- mainSF = new PWLSField(mesh);
- MAdMsgSgl::instance().warning(__LINE__,__FILE__,"No size field registered");
- }
-
- // -------------------------------------------------------------------
- void SizeFieldManager::intersect(const pSField sf) {
- mainSF->intersect(sf);
- }
-
- // -------------------------------------------------------------------
- void SizeFieldManager::addSizeField(pSField sf) {
-
- mainSF->intersect(sf);
-
- sFieldType type = sf->getType();
- switch (type) {
- case NULLSFIELD: {
- break;
- }
- case DISCRETESFIELD: {
- assert ( ((DiscreteSF*)sf)->discretization() == VERTEX_P1_DSFTYPE );
- PWLSField* linsf = static_cast<PWLSField*>(sf);
- addPWLinearSF( linsf );
- break;
- }
- case ANALYTICALSFIELD: {
- AnalyticalSField* asf = static_cast<AnalyticalSField*>(sf);
- addAnalyticalSF( asf );
- break;
- }
- case LOCALSFIELD: {
- LocalSizeField* locsf = static_cast<LocalSizeField*>(sf);
- addLocalSF( locsf );
- break;
- }
- default: {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Unknown size field type %d",type);
- }
- }
- }
-
- // -------------------------------------------------------------------
- void SizeFieldManager::addPWLinearSF(PWLSField* sf) {
- linears.insert(sf);
- }
-
- // -------------------------------------------------------------------
- void SizeFieldManager::addAnalyticalSF(AnalyticalSField* sf) {
- analyticals.insert(sf);
- }
-
- // -------------------------------------------------------------------
- void SizeFieldManager::addLocalSF(LocalSizeField* sf) {
- locals.insert(sf);
- }
-
- // -------------------------------------------------------------------
- void SizeFieldManager::update()
- {
- MeshQualityManagerSgl::instance().clearAllShapes(); // not useful in isotropic case (be careful about the hypothesis)
-
- mainSF->cleanUp();
-
- set<PWLSField*>::const_iterator linIter = linears.begin();
- set<PWLSField*>::const_iterator linLast = linears.end();
- for (; linIter != linLast; linIter++) {
- mainSF->intersect(*linIter);
- }
-
- set<AnalyticalSField*>::const_iterator aIter = analyticals.begin();
- set<AnalyticalSField*>::const_iterator aLast = analyticals.end();
- for (; aIter != aLast; aIter++) {
- mainSF->intersect(*aIter);
- }
-
- set<LocalSizeField*>::iterator locIter = locals.begin();
- set<LocalSizeField*>::iterator locLast = locals.end();
- for (; locIter != locLast; locIter++) {
- (*locIter)->updateTree();
- mainSF->intersect(*locIter);
- }
-
- if ( smooth ) mainSF->smooth(maxGradient);
-
- localTime = MAdTimeManagerSgl::instance().getTime();
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/sizeField/SizeFieldManager.h b/Adapt/sizeField/SizeFieldManager.h
deleted file mode 100644
index c21310f..0000000
--- a/Adapt/sizeField/SizeFieldManager.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_SIZEFIELDMANAGER
-#define _H_SIZEFIELDMANAGER
-
-#include "SizeFieldBase.h"
-#include "PWLinearSField.h"
-#include "LocalSizeField.h"
-#include "AnalyticalSField.h"
-
-#include <set>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- // This class lists, intersects and updates all size fields
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
-
- class SizeFieldManager {
-
- public:
-
- SizeFieldManager(pMesh m, pSField psf=NULL);
- ~SizeFieldManager();
-
- public:
-
- void setMesh(pMesh m);
- void setSmoothing(bool enable, double maxGrad)
- {
- smooth = enable;
- maxGradient = maxGrad;
- }
-
- void intersect(const pSField sf);
-
- void addSizeField(pSField sf);
-
- void update();
-
- DiscreteSF* getSizeField() { return mainSF; }
- const DiscreteSF* getSizeField() const { return mainSF; }
-
- private:
-
- void addPWLinearSF(PWLSField * sf);
- void addAnalyticalSF(AnalyticalSField * sf);
- void addLocalSF(LocalSizeField * sf);
-
- private:
-
- DiscreteSF* mainSF;
-
- std::set<PWLSField *> linears;
- std::set<AnalyticalSField *> analyticals;
- std::set<LocalSizeField *> locals;
-
- pMesh mesh;
-
- double localTime;
-
- bool smooth;
- double maxGradient;
- };
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/utils/CPUTimeManager.cc b/Adapt/utils/CPUTimeManager.cc
deleted file mode 100644
index dc7f7b0..0000000
--- a/Adapt/utils/CPUTimeManager.cc
+++ /dev/null
@@ -1,121 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "CPUTimeManager.h"
-
-#ifdef PARALLEL
-#include <mpi.h>
-#else
-#ifndef _WIN_
-#include <sys/time.h>
-#else
-#include <time.h>
-#include <windows.h>
-#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
-#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
-#else
-#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
-#endif
-
-struct timezone
-{
- int tz_minuteswest; /* minutes W of Greenwich */
- int tz_dsttime; /* type of dst correction */
-};
-
-int get_time_of_day(struct timeval *tv, struct timezone *tz)
-{
- FILETIME ft;
- unsigned __int64 tmpres = 0;
- static int tzflag;
-
- if (NULL != tv)
- {
- GetSystemTimeAsFileTime(&ft);
-
- tmpres |= ft.dwHighDateTime;
- tmpres <<= 32;
- tmpres |= ft.dwLowDateTime;
-
- // converting file time
- tmpres -= DELTA_EPOCH_IN_MICROSECS;
- tmpres /= 10; // convert into microseconds
- tv->tv_sec = (long)(tmpres / 1000000UL);
- tv->tv_usec = (long)(tmpres % 1000000UL);
- }
-
- if (NULL != tz)
- {
- if (!tzflag)
- {
- _tzset();
- tzflag++;
- }
- tz->tz_minuteswest = _timezone / 60;
- tz->tz_dsttime = _daylight;
- }
-
- return 0;
-}
-#endif
-
-#endif
-#ifdef PARALLEL
-#include "mpi.h"
-#endif
-
-#ifdef PARALLEL
-#include <mpi.h>
-#endif
-
-// -------------------------------------------------------------------
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void CPUTimeManager::initialize()
- {
- }
-
- // -------------------------------------------------------------------
- void CPUTimeManager::finalize()
- {
- }
-
- // -------------------------------------------------------------------
- double CPUTimeManager::getTime() const {
-
-#ifdef PARALLEL
- return MPI_Wtime();
-#else
- struct timeval tp;
- struct timezone tz;
-#ifdef _WIN_
- get_time_of_day(&tp,&tz);
-#else
- gettimeofday(&tp,&tz);
-#endif
-
- return ((double) tp.tv_sec +
- (double) ((double) .000001 * (double) tp.tv_usec));
-#endif
- }
-
- // -------------------------------------------------------------------
- double CPUTimeManager::elapsedTime() const {
-
- return ( getTime() - initialTime );
-
- }
-}
-
-// -------------------------------------------------------------------
diff --git a/Adapt/utils/CPUTimeManager.h b/Adapt/utils/CPUTimeManager.h
deleted file mode 100644
index ab8217a..0000000
--- a/Adapt/utils/CPUTimeManager.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_CPUTIMEMANAGER
-#define _H_CPUTIMEMANAGER
-
-#include "MAdSingleton.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class CPUTimeManager {
-
- public:
-
- CPUTimeManager() { reset(); };
- ~CPUTimeManager() {};
-
- void initialize();
- void finalize();
-
- void reset() { initialTime = getTime(); };
- double elapsedTime() const;
- double getTime() const;
-
- private:
-
- double initialTime;
-
- };
-
- // -------------------------------------------------------------------
-
- typedef MAdSingleton<CPUTimeManager> CPUTimeManagerSgl;
-}
-
-#endif
diff --git a/Adapt/utils/CallBackManager.cc b/Adapt/utils/CallBackManager.cc
deleted file mode 100644
index e69b8da..0000000
--- a/Adapt/utils/CallBackManager.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "CallBackManager.h"
-
-using std::list;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void CallBackManager::initialize()
- {
- }
-
- // -------------------------------------------------------------------
- void CallBackManager::finalize()
- {
- CB.clear();
- CBMove.clear();
- }
-
- // -------------------------------------------------------------------
- void CallBackManager::registerCallBack(CBFunction CBFct,
- void* userData)
- {
- CBStructure cb;
- cb.function = CBFct;
- cb.data = userData;
- CB.push_back(cb);
- }
-
- // -------------------------------------------------------------------
- void CallBackManager::registerCallBackMove(CBFunc_move CB_move,
- void* userData_move)
- {
- CBStructureMove cbm;
- cbm.function = CB_move;
- cbm.data = userData_move;
- CBMove.push_back(cbm);
- }
-
- // -------------------------------------------------------------------
- void CallBackManager::unregisterCallBack(CBFunction CBFct,
- void* userData)
- {
- CBStructure cb;
- cb.function = CBFct;
- cb.data = userData;
- CB.remove(cb);
- }
-
- // -------------------------------------------------------------------
- void CallBackManager::unregisterCallBackMove(CBFunc_move CB_move,
- void* userData_move)
- {
- CBStructureMove cbm;
- cbm.function = CB_move;
- cbm.data = userData_move;
- CBMove.remove(cbm);
- }
-
- // -------------------------------------------------------------------
- void CallBackManager::callCallBacks(pPList before, pPList after,
- operationType type , pEntity ppp)
- {
- list<CBStructure>::const_iterator cbIter = CB.begin();
- list<CBStructure>::const_iterator cbLast = CB.end();
-
- for (; cbIter != cbLast; cbIter++) {
- CBFunction f = (*cbIter).function;
- void * userData = (*cbIter).data;
- f(before,after,userData,type,ppp);
- }
- }
-
- // -------------------------------------------------------------------
- void CallBackManager::callCallBackMoves(pVertex pv, double * xyz)
- {
- list<CBStructureMove>::const_iterator cbIterM = CBMove.begin();
- list<CBStructureMove>::const_iterator cbLastM = CBMove.end();
-
- for (; cbIterM != cbLastM; cbIterM++) {
- CBFunc_move fM = (*cbIterM).function;
- void * userDataM = (*cbIterM).data;
- fM(pv,xyz,userDataM);
- }
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/utils/CallBackManager.h b/Adapt/utils/CallBackManager.h
deleted file mode 100644
index 2adb42a..0000000
--- a/Adapt/utils/CallBackManager.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_CALLBACKMANAGER
-#define _H_CALLBACKMANAGER
-
-#include "MAdOperatorBase.h"
-
-#include "MAdSingleton.h"
-
-#include "MSops.h"
-#include <list>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- // callback functions
- typedef void (*CBFunction)(pPList, pPList,
- void *, operationType, pEntity);
- typedef void (*CBFunc_move)(pVertex, double *, void *);
-
- // -------------------------------------------------------------------
- struct CBStructure {
-
- CBFunction function;
- void* data;
-
- bool operator== (CBStructure cb) const {
- if ( function==cb.function && data==cb.data) return true;
- return false;
- }
- };
-
- // -------------------------------------------------------------------
- struct CBStructureMove {
- CBFunc_move function;
- void* data;
-
- bool operator== (CBStructureMove cbm) const {
- if ( function==cbm.function && data==cbm.data) return true;
- return false;
- }
- };
-
- // -------------------------------------------------------------------
- class CallBackManager {
-
- public:
-
- CallBackManager() {};
- ~CallBackManager() {};
-
- void initialize();
- void finalize();
-
- void registerCallBack(CBFunction CB, void* userData);
- void registerCallBackMove(CBFunc_move CB_move, void* userData_move);
-
- void unregisterCallBack(CBFunction CB, void* userData);
- void unregisterCallBackMove(CBFunc_move CB_move, void* userData_move);
-
- void callCallBacks(pPList before, pPList after,
- operationType type , pEntity ppp);
- void callCallBackMoves(pVertex, double *);
-
- private:
-
- std::list<CBStructure> CB;
- std::list<CBStructureMove> CBMove;
-
- };
-
- // -------------------------------------------------------------------
-
- typedef MAdSingleton<CallBackManager> CallBackManagerSgl;
-
-}
-
-#endif
diff --git a/Adapt/utils/DistanceFunction.cc b/Adapt/utils/DistanceFunction.cc
deleted file mode 100644
index 227eef9..0000000
--- a/Adapt/utils/DistanceFunction.cc
+++ /dev/null
@@ -1,438 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "DistanceFunction.h"
-#include "MAdOutput.h"
-#include "CallBackManager.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void DistFct_CBMoveFct(pVertex pv, double * target, void * data)
- {
- distanceFunction * dFct = (distanceFunction *) data;
- dFct->clearVertexData(pv);
- }
-
- // -------------------------------------------------------------------
- void DistFct_CBFct(pPList before, pPList after, void * data,
- operationType type , pEntity ppp)
- {
- distanceFunction * dFct = (distanceFunction *) data;
-
- switch (type) {
- case MAd_ESPLIT: {
- // In the edge split case, we have to interpolate the data at the new node
-
- if ( dFct->gradientAvailable() )
- {
- double grads[2][3];
-
- // find the old edge
- void * tmp = 0;
- pEdge pe = (pEdge)PList_next(before,&tmp);
- double t = E_linearParams(pe,(pVertex)ppp);
-
- // get datas at nodes
- dFct->getGradient( E_vertex((pEdge)pe, 0), grads[0] );
- dFct->getGradient( E_vertex((pEdge)pe, 1), grads[1] );
-
- double * newGrad = new double[3];
- for (int i=0; i<3; i++) newGrad[i] = (1.-t) * grads[0][i] + t * grads[1][i];
-
- // attach it
- dFct->attachGradient((pVertex)ppp, newGrad);
- }
- break;
- }
- case MAd_ECOLLAPSE: {
- // In the edge collapse case, we have to delete the datas attached to the deleted node
- dFct->clearVertexData((pVertex)ppp);
- break;
- }
- case MAd_ESWAP:
- case MAd_FSWAP: {
- // nothing to be done (no modification at nodes)
- break;
- }
- case MAd_RREMOVE: {
- void * temp = NULL;
- while ( pEntity pE = PList_next(before,&temp) ) {
- if ( EN_type(pE) == 0 ) {
- dFct->clearVertexData((pVertex)pE);
- }
- }
- break;
- }
- case MAd_UNKNOWNOPERATION:
- case MAd_VERTEXMOVE:
- case MAd_FCOLLAPSE:
- case MAd_DESPLTCLPS:
- default: {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Not implemented for mesh modification %d", type);
- }
- }
- }
-
- // -------------------------------------------------------------------
- distanceFunction::distanceFunction(pMesh m): mesh(m), gradComputed(false)
- {
- distId = MD_newMeshDataId();
- vGradId = MD_newMeshDataId();
- rGradId = MD_newMeshDataId();
- kdSearch = new SearchTool();
-
- CallBackManagerSgl::instance().registerCallBackMove(DistFct_CBMoveFct,this);
- CallBackManagerSgl::instance().registerCallBack(DistFct_CBFct,this);
- }
-
- // -------------------------------------------------------------------
- distanceFunction::~distanceFunction()
- {
- clearDistances();
- MD_deleteMeshDataId(distId);
-
- clearGradientAtVertices();
- MD_deleteMeshDataId(vGradId);
-
- clearGradientInElements();
- MD_deleteMeshDataId(rGradId);
-
- if (kdSearch) delete kdSearch;
-
- CallBackManagerSgl::instance().unregisterCallBackMove(DistFct_CBMoveFct,this);
- CallBackManagerSgl::instance().unregisterCallBack(DistFct_CBFct,this);
- }
-
- // -------------------------------------------------------------------
- void distanceFunction::computeTree(const std::set<pVertex>& vertices)
- {
- kdSearch->reset();
-
- int nbVert = vertices.size();
- kdSearch->allocatePoints(nbVert);
-
- std::set<pVertex> :: const_iterator itV = vertices.begin();
- std::set<pVertex> :: const_iterator itVEnd = vertices.end();
- int k = 0;
- for ( ; itV != itVEnd ; ++itV)
- {
- double coord[3]; V_coord(*itV,coord);
- kdSearch->addPoint(k,coord);
- k++;
- }
-
- kdSearch->allocateTree(nbVert);
-
- clearDistances();
- clearGradientAtVertices();
- clearGradientInElements();
-
- gradComputed = false;
- }
-
- // -------------------------------------------------------------------
- void distanceFunction::computeAllDistances() const
- {
- pVertex pv;
- VIter vit = M_vertexIter(mesh);
- while ( ( pv = VIter_next(vit) ) )
- {
- computeDistance(pv);
- }
- VIter_delete(vit);
- }
-
- // -------------------------------------------------------------------
- double distanceFunction::computeDistance(pVertex pv) const
- {
- double xyz[3]; V_coord(pv,xyz);
- double dist = sqrt(kdSearch->computeDistanceSq(xyz));
- EN_attachDataDbl((pEntity)pv,distId,dist);
- return dist;
- }
-
- // -------------------------------------------------------------------
- double distanceFunction::computeDistance(const double xyz[3]) const
- {
- return sqrt(kdSearch->computeDistanceSq(xyz));
- }
-
- // -------------------------------------------------------------------
- double distanceFunction::computeDistSq(const double xyz[3]) const
- {
- return kdSearch->computeDistanceSq(xyz);
- }
-
- // -------------------------------------------------------------------
- double distanceFunction::getDistance(pVertex pv) const
- {
- double dist;
- if ( EN_getDataDbl((pEntity)pv,distId,&dist) ) return dist;
- return computeDistance(pv);
- }
-
- // -------------------------------------------------------------------
- void distanceFunction::clearDistances() const
- {
- pVertex pv;
- VIter vit = M_vertexIter(mesh);
- while ( ( pv = VIter_next(vit) ) )
- {
- EN_deleteData((pEntity)pv,distId);
- }
- VIter_delete(vit);
- }
-
- // -------------------------------------------------------------------
- void distanceFunction::computeGradientInElements() const
- {
- double gsf[4][3] = {
- {-1., -1., -1.},
- { 1., 0., 0.},
- { 0., 1., 0.},
- { 0., 0., 1.},
- };
-
- pRegion pr;
- RIter rit = M_regionIter(mesh);
- while ( ( pr = RIter_next(rit) ) )
- {
- pPList rVerts = R_vertices(pr);
- double dist[4];
- void * temp = NULL;
- pVertex pv;
- int i = 0;
- while ( ( pv = (pVertex)PList_next(rVerts,&temp) ) )
- {
- dist[i] = getDistance(pv);
- i++;
- }
- PList_delete(rVerts);
-
- double ijac[3][3], detj;
- detj = R_invJacobian(pr,ijac);
-
- void * del;
- if ( EN_getDataPtr((pEntity)pr,rGradId,&del) && del ) delete [] (double*)del;
- double * grad = new double[3];
- for ( int iC=0; iC<3; iC++)
- {
- grad[iC] = 0.;
- for (int iSF=0; iSF<4; iSF++) {
- grad[iC] += dist[iSF] * ( gsf[iSF][0] * ijac[0][iC] +
- gsf[iSF][1] * ijac[1][iC] +
- gsf[iSF][2] * ijac[2][iC] );
- }
- }
-
- EN_attachDataPtr((pEntity)pr,rGradId,grad);
- }
- RIter_delete(rit);
- }
-
- // -------------------------------------------------------------------
- void distanceFunction::clearGradientInElements() const
- {
- pRegion pr;
- RIter rit = M_regionIter(mesh);
- while ( ( pr = RIter_next(rit) ) )
- {
- EN_deleteData((pEntity)pr,rGradId);
- }
- RIter_delete(rit);
- }
-
- // -------------------------------------------------------------------
- void distanceFunction::computeGradientAtVertices()
- {
- computeGradientInElements();
-
- pVertex pv;
- VIter vit = M_vertexIter(mesh);
- while ( ( pv = VIter_next(vit) ) )
- {
- void * del;
- if ( EN_getDataPtr((pEntity)pv,vGradId,&del) && del ) delete [] (double*)del;
- double * grad = new double[3];
- for (int i=0; i<3; i++) grad[i] = 0.;
-
- pPList vRegs = V_regions(pv);
- void * temp = NULL;
- void * rGrad = NULL;
- pRegion pr;
- while ( pr = (pRegion)PList_next(vRegs,&temp) )
- {
- if ( !EN_getDataPtr((pEntity)pr,rGradId,&rGrad) ) throw;
- grad[0] += ((double*)rGrad)[0];
- grad[1] += ((double*)rGrad)[1];
- grad[2] += ((double*)rGrad)[2];
- }
-
- int nRegs = PList_size(vRegs);
- PList_delete(vRegs);
- double invNRegs = 1. / (double)nRegs;
- for (int i=0; i<3; i++) grad[i] *= invNRegs;
-
- EN_attachDataPtr((pEntity)pv,vGradId,grad);
- }
- VIter_delete(vit);
-
- clearGradientInElements();
-
- gradComputed = true;
- }
-
- // -------------------------------------------------------------------
- void distanceFunction::clearGradientAtVertices()
- {
- pVertex pv;
- VIter vit = M_vertexIter(mesh);
- while ( ( pv = VIter_next(vit) ) )
- {
- EN_deleteData((pEntity)pv,vGradId);
- }
- VIter_delete(vit);
-
- gradComputed = false;
- }
-
- // -------------------------------------------------------------------
- bool distanceFunction::getGradient(const pVertex pv, double grad[3]) const
- {
- void * tmp;
- if ( !EN_getDataPtr((pEntity)pv,vGradId,&tmp) ) return false;
- for (int i=0; i<3; i++) grad[i] = ((double*) tmp)[i];
- return true;
- }
-
- // -------------------------------------------------------------------
- bool distanceFunction::getGradientOnEntity(const pEntity entity,
- const double xyz[3],
- double grad[3]) const
- {
- int type = EN_type(entity);
- switch(type) {
- case 0: return getGradient((pVertex)entity,grad);
- case 1: return getGradientOnEdge((pEdge)entity,xyz,grad);
- case 2: return getGradientOnFace((pFace)entity,xyz,grad);
- case 3: return getGradientOnRegion((pRegion)entity,xyz,grad);
- default: throw;
- }
- }
-
- // -------------------------------------------------------------------
- bool distanceFunction::getGradientOnEdge(const pEdge edge,
- const double xyz[3],
- double grad[3]) const
- {
- double u = E_linearParams(edge,xyz);
- return getGradientOnEdgeParam(edge,u,grad);
- }
-
- // -------------------------------------------------------------------
- bool distanceFunction::getGradientOnEdgeParam(const pEdge pE,
- const double u,
- double grad[3]) const
- {
- double g0[3], g1[3];
- if ( !getGradient(E_vertex(pE,0), g0) ||
- !getGradient(E_vertex(pE,1), g1) ) return false;
-
- for (int i=0; i<3; i++) grad[i] = (1.-u) * g0[i] + u * g1[i];
- return true;
- }
-
- // -------------------------------------------------------------------
- bool distanceFunction::getGradientOnFace(const pFace face,
- const double xyz[3],
- double grad[3]) const
- {
- double u[2];
- F_linearParams(face,xyz,u);
- return getGradientOnFaceParam(face,u,grad);
- }
-
- // -------------------------------------------------------------------
- bool distanceFunction::getGradientOnFaceParam(const pFace face,
- const double u[2],
- double grad[3]) const
- {
- double g0[3], g1[3], g2[3];
- if ( !getGradient(F_vertex(face,0), g0) ||
- !getGradient(F_vertex(face,1), g1) ||
- !getGradient(F_vertex(face,2), g2) ) return false;
-
- for (int i=0; i<3; i++) grad[i] = (1.-u[0]-u[1]) * g0[i] + u[0] * g1[i] + u[1] * g2[i];
- return true;
- }
-
- // -------------------------------------------------------------------
- bool distanceFunction::getGradientOnRegion(const pRegion region,
- const double xyz[3],
- double grad[3]) const
- {
- double u[3];
- R_linearParams(region, xyz, u);
- return getGradientOnRegionParam(region, u, grad);
- }
-
- // -------------------------------------------------------------------
- bool distanceFunction::getGradientOnRegionParam(const pRegion region,
- const double u[3],
- double grad[3]) const
- {
- double g0[3], g1[3], g2[3], g3[3];
- if ( !getGradient(R_vertex(region,0), g0) ||
- !getGradient(R_vertex(region,1), g1) ||
- !getGradient(R_vertex(region,2), g2) ||
- !getGradient(R_vertex(region,3), g3) ) return false;
-
- for (int i=0; i<3; i++) {
- grad[i] = (1.-u[0]-u[1]-u[2]) * g0[i] + u[0] * g1[i] + u[1] * g2[i] + u[2] * g3[i];
- }
- return true;
- }
-
- // -------------------------------------------------------------------
- void distanceFunction::attachGradient(pVertex pv, double grad[3]) const
- {
- EN_attachDataPtr((pEntity)pv,vGradId,grad);
- }
-
- // -------------------------------------------------------------------
- void distanceFunction::outputDistance(const char * fn) const
- {
- MAdAttachedNodalDataOutput(mesh, fn, distId);
- }
-
- // -------------------------------------------------------------------
- void distanceFunction::outputGradAtVertices(const char * fn) const
- {
- if ( !gradComputed ) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Distance gradients are not computed");
- }
- MAdAttachedNodalDataVecOutput(mesh, fn, vGradId);
- }
-
- // -------------------------------------------------------------------
- void distanceFunction::clearVertexData(pVertex pv) const
- {
- EN_deleteData((pEntity)pv, vGradId);
- EN_deleteData((pEntity)pv, distId);
- }
-
- // -------------------------------------------------------------------
-}
diff --git a/Adapt/utils/DistanceFunction.h b/Adapt/utils/DistanceFunction.h
deleted file mode 100644
index fcc76e2..0000000
--- a/Adapt/utils/DistanceFunction.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_DISTANCEFUNCTION
-#define _H_DISTANCEFUNCTION
-
-#include "MeshDataBaseInterface.h"
-#include "DistanceToPoints.h"
-#include <set>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- // This class computes and stores (as attached double) the distance to a
- // set of vertices and the gradient of the distance (as attached pointer).
- // -------------------------------------------------------------------
- class distanceFunction {
-
- public:
-
- distanceFunction(pMesh m);
- ~distanceFunction();
-
- bool gradientAvailable() const { return gradComputed; }
-
- void computeTree(const std::set<pVertex>&);
-
- void computeAllDistances() const;
- double computeDistance(pVertex pv) const;
- double computeDistance(const double xyz[3]) const;
- double computeDistSq (const double xyz[3]) const;
- double getDistance(pVertex pv) const;
- void clearDistances() const;
- void clearVertexData(pVertex pv) const;
-
- void computeGradientAtVertices();
- void clearGradientAtVertices();
- bool getGradient(const pVertex pv, double grad[3]) const;
- bool getGradientOnEntity(const pEntity entity,
- const double xyz[3],
- double grad[3]) const;
- void attachGradient(pVertex pv, double grad[3]) const;
-
- void outputDistance(const char * fn) const;
- void outputGradAtVertices(const char * fn) const;
-
- private:
-
- void computeGradientInElements() const;
- void clearGradientInElements() const;
-
- bool getGradientOnEdge(const pEdge edge,
- const double xyz[3],
- double grad[3]) const;
- bool getGradientOnEdgeParam(const pEdge pE,
- const double u,
- double grad[3]) const;
- bool getGradientOnFace(const pFace face,
- const double xyz[3],
- double grad[3]) const;
- bool getGradientOnFaceParam(const pFace face,
- const double u[2],
- double grad[3]) const;
- bool getGradientOnRegion(const pRegion region,
- const double xyz[3],
- double grad[3]) const;
- bool getGradientOnRegionParam(const pRegion region,
- const double u[3],
- double grad[3]) const;
-
- private:
-
- pMesh mesh;
- pMeshDataId distId, vGradId, rGradId;
- bool gradComputed;
- SearchTool * kdSearch;
-
- };
-
- // -------------------------------------------------------------------
-}
-
-#endif
diff --git a/Adapt/utils/DistanceToPoints.h b/Adapt/utils/DistanceToPoints.h
deleted file mode 100644
index 8df66c5..0000000
--- a/Adapt/utils/DistanceToPoints.h
+++ /dev/null
@@ -1,147 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_DISTANCETOPOINTS
-#define _H_DISTANCETOPOINTS
-
-#ifdef _HAVE_ANN_
-#include <ANN/ANN.h>
-#endif
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class MAd_searchTool {
-
- public:
- MAd_searchTool() {
- printf("Error: no search tool implemented: flag _HAVE_ANN_ not set\n");
- throw;
- }
- void reset() { throw; }
- void allocatePoints(int n) { throw; }
- void addPoint(int index, double xyz[3]) { throw; }
- void allocateTree(int n) { throw; }
- double computeDistanceSq(const double xyz[3]) const { throw; }
- };
-
- // -------------------------------------------------------------------
-#ifdef _HAVE_ANN_
- class ANN_searchTool {
-
- public:
-
- ANN_searchTool()
- {
- kdTree = NULL;
- points = NULL;
- }
-
- ~ANN_searchTool()
- {
- if (kdTree) { delete kdTree; kdTree = NULL; }
- if (points) { annDeallocPts(points); points = NULL; }
- annClose();
- }
-
- void reset()
- {
- if (kdTree) { delete kdTree; kdTree = NULL; }
- if (points) { annDeallocPts(points); points = NULL; }
- }
-
- void allocatePoints(int n)
- {
- if (points) annDeallocPts(points);
- points = annAllocPts(n,3);
- }
-
- void addPoint(int index, double xyz[3])
- {
- for (int i=0; i<3; i++) points[index][i] = xyz[i];
- }
-
- void allocateTree(int n)
- {
- if (kdTree) delete kdTree;
- kdTree = new ANNkd_tree(points, n, 3);
- }
-
- double computeDistanceSq(const double xyz[3]) const
- {
- if (!kdTree) {
- printf("Error: no research tree built\n");
- throw;
- }
-
- double xyz_copy[3]; // because the first argument of annkSearch is not const
- for (int i=0; i<3; i++) xyz_copy[i] = xyz[i];
- int maxpts = 1;
- // the use of allocation is done due to ms visual c++ compiler
- // that do not support c99 standard (it uses the c95 et c++98 standards)
- ANNidx* index= new ANNidx[maxpts];
- ANNdist* distSq= new ANNdist[maxpts];
- kdTree->annkSearch(xyz_copy, maxpts, index, distSq);
- double theDistSq = distSq[0];
- delete [] index;
- delete [] distSq;
- return theDistSq;
- }
-
- // Compute gradient of the square distance to the cloud of points
- // by non-centered differences. Central differences would lead to
- // zero gradients for points located on the walls (distance is not signed).
- double gradDistanceSq(const double xyz[3], double grad[3]) const
- {
- double dSq = computeDistanceSq(xyz);
- double eps = 1.e-3;
- double dEps[2];
-
- int maxpts = 1;
- ANNidx* index= new ANNidx[maxpts];
- ANNdist* distSq= new ANNdist[maxpts];
- double tmp[3];
- tmp[0] = xyz[0]; tmp[1] = xyz[1]; tmp[2] = xyz[2];
- for (int i=0; i<3; i++) {
- tmp[i] += eps;
- kdTree->annkSearch(tmp, maxpts, index, distSq);
- dEps[0] = distSq[0];
- tmp[i] -= 2*eps;
- kdTree->annkSearch(tmp, maxpts, index, distSq);
- dEps[1] = distSq[1];
- tmp[i] += eps;
- grad[i] = 1000. * ( dEps[1] - dEps[0] );
- }
- }
-
- private:
-
- ANNkd_tree * kdTree;
- ANNpoint * points;
- };
-
- typedef ANN_searchTool SearchTool;
-
- // -------------------------------------------------------------------
-#else
-
- typedef MAd_searchTool SearchTool;
-
- // -------------------------------------------------------------------
-#endif
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Adapt/utils/History.cc b/Adapt/utils/History.cc
deleted file mode 100644
index a783c30..0000000
--- a/Adapt/utils/History.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "History.h"
-
-#include <stdarg.h>
-#include <fstream>
-#include <iostream>
-#include <stdlib.h>
-using std::ostream;
-
-namespace MAd {
-
- static int actionIntParameters[UNKNOWN_ACTION] = {1,1,1,1,1};
-
- // -------------------------------------------------------------------
- void History::initialize()
- {
- open = false;
- refCount = -1;
- }
-
- // -------------------------------------------------------------------
- void History::finalize()
- {
- journal.clear();
- refJournal.clear();
- }
-
- // -------------------------------------------------------------------
- void History::add(int ot, actionType at, ...)
- {
- if ( !open ) return;
-
- va_list ap;
- va_start(ap, at);
-
- std::vector<int> intParams;
- for (int iInt=0; iInt < actionIntParameters[at]; iInt++) {
- intParams.push_back(va_arg(ap, int));
- }
-
- va_end(ap);
-
- action act;
- act.opType = ot;
- act.actType = at;
- act.intParams = intParams;
-
- add(act);
- }
-
- // -------------------------------------------------------------------
- void History::add(action act)
- {
- if ( !open ) return;
-
- journal.push_back(act);
-
- if ( !compare() ) {
- std::cerr << "Error in History: operations are not the same as in the reference journal\n";
- flushJournal("journal_for_diff");
- exit(1);
- }
- }
-
- // -------------------------------------------------------------------
- bool History::compare()
- {
- if ( !open ) return false;
-
- if ( refJournal.empty() || refCount >= (int) refJournal.size() ) return true;
-
- for (; refCount < (int) journal.size(); refCount++) {
- if ( journal[refCount] != refJournal[refCount] ) return false;
- }
-
- return true;
- }
-
- // -------------------------------------------------------------------
- void History::loadJournal(std::string name)
- {
- FILE * f = fopen(name.c_str(),"r");
- if ( !f ) {
- std::cerr << "Error: could not open file " << name << std::endl; throw;
- }
-
- int opType;
- int actType;
- while ( fscanf(f,"%d %d",&opType,&actType) != EOF ) {
-
- std::vector<int> intParams;
- int par;
- for (int iPar=0; iPar<actionIntParameters[actType]; iPar++) {
- fscanf(f,"%d",&par);
- intParams.push_back(par);
- }
-
- action act;
- act.opType = opType;
- act.actType = (actionType) actType;
- act.intParams = intParams;
-
- refJournal.push_back(act);
- }
-
- fclose(f);
-
- refCount = 0;
- }
-
- // -------------------------------------------------------------------
- void History::flushJournal(ostream& out) const
- {
- for (int iAct=0; iAct < (int) journal.size(); iAct++) {
- action act = journal[iAct];
- out << act.opType << "\t" << act.actType;
- for (int iP=0; iP<actionIntParameters[act.actType]; iP++) {
- out << "\t"<< act.intParams[iP];
- }
- out << "\n";
- }
- }
-
- // -------------------------------------------------------------------
- void History::flushJournal(std::string name) const
- {
- std::ofstream fileOut(name.c_str());
- flushJournal(fileOut);
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/utils/History.h b/Adapt/utils/History.h
deleted file mode 100644
index 435c743..0000000
--- a/Adapt/utils/History.h
+++ /dev/null
@@ -1,91 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_HISTORY
-#define _H_HISTORY
-
-#include "MAdSingleton.h"
-
-#include <vector>
-#include <ostream>
-#include <string>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- enum actionType {
- OP_CHECKCONSTRAINTS = 0,
- OP_CHECKGEOMETRY = 1,
- OP_CHECKSHAPES = 2,
- OPERATOR_APPLY = 3,
- OPERATOR_UNAPPLY = 4,
- UNKNOWN_ACTION = 5
- };
-
- struct action {
- int opType;
- actionType actType;
- std::vector<int> intParams;
-
- bool operator!=(const action& other) {
- if ( opType != other.opType ) return true;
- if ( actType != other.actType ) return true;
- if ( intParams.size() != other.intParams.size() ) return true;
- for (unsigned int i=0; i<intParams.size(); i++) {
- if ( intParams[i] != other.intParams[i] ) return true;
- }
- return false;
- }
- };
-
- // -------------------------------------------------------------------
- class History {
-
- public:
-
- History() {};
- ~History() {};
-
- void initialize();
- void finalize();
-
- void openJournal() { open = true; };
- void closeJournal() { open = false; };
-
- void add(int, actionType,...);
- void add(action);
-
- bool compare();
-
- void flushJournal(std::ostream& out) const;
- void flushJournal(std::string name) const;
-
- void loadJournal(std::string name);
-
- private:
-
- bool open; // indicates if the journal is in use
-
- std::vector<action> journal; // list of actions
-
- std::vector<action> refJournal; // journal to compare with
- int refCount; // position of the next action to compare
- };
-
- // -------------------------------------------------------------------
-
- typedef MAdSingleton<History> HistorySgl;
-
-}
-
-#endif
diff --git a/Adapt/utils/MAdLinearSystem.h b/Adapt/utils/MAdLinearSystem.h
deleted file mode 100644
index 7e6e58e..0000000
--- a/Adapt/utils/MAdLinearSystem.h
+++ /dev/null
@@ -1,126 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_LINEARSYSTEM_MAD
-#define _H_LINEARSYSTEM_MAD
-
-namespace MAd {
-
- // A class that encapsulates a linear system solver interface :
- // building a sparse matrix, solving a linear system
-
- // -------------------------------------------------------------------
- enum SolverType { GMRES, CG };
-
- // -------------------------------------------------------------------
- class MAdLinearSystem {
-
- public:
-
- MAdLinearSystem (): sType(GMRES),fill(0),eps(1.e-12) {}
- virtual ~MAdLinearSystem () {}
-
- public:
-
- virtual bool isAllocated () const = 0;
- virtual void allocate (int nbRows) = 0;
- virtual void addToMatrix (int _row, int _col, double val) = 0;
- virtual double getFromMatrix (int _row, int _col) const = 0;
- virtual void addToRightHandSide (int _row, double val) = 0;
- virtual double getFromRightHandSide (int _row) const = 0;
- virtual double getFromSolution (int _row) const = 0;
- virtual void zeroMatrix () = 0;
- virtual void zeroRightHandSide () = 0;
- virtual void reorder() = 0;
- virtual int systemSolve () = 0;
- virtual void set_nnz(int row,int nz){}
- virtual void allocate_matrix(){}
-
- virtual void setSolver(SolverType _type) {sType = _type;}
- void setFillIn(int _k) {fill=_k;}
- void setEps(double _eps) {eps=_eps;}
- virtual void setPrec(double){}
- virtual void setNoisy(int){}
-
- protected:
-
- SolverType sType;
- int fill;
- double eps;
-
- };
-
- // -------------------------------------------------------------------
- class MAdLinearSystemNull : public MAdLinearSystem {
-
- public:
-
- MAdLinearSystemNull ()
- {
- printf("Error: no linear systems solver available\n");
- throw;
- }
-
- public:
-
- bool isAllocated () const { return false; }
- void allocate (int nbRows) {}
- void addToMatrix (int _row, int _col, double val) {}
- double getFromMatrix (int _row, int _col) const { return 0.; }
- void addToRightHandSide (int _row, double val) {}
- double getFromRightHandSide (int _row) const { return 0.; }
- double getFromSolution (int _row) const { return 0.; }
- void zeroMatrix () {}
- void zeroRightHandSide () {}
- void reorder() {}
- int systemSolve () { return 0; }
- };
-
- // -------------------------------------------------------------------
-
-}
-
-// -------------------------------------------------------------------
-
-#ifdef _HAVE_PETSC_
-#include "MAdLinearSystemPETSc.h"
-namespace MAd {
- typedef MAdLinearSystemPETSc MAdLinearSystemDef;
-}
-#else
-
-#ifdef _HAVE_SPARSKIT_
-#include "MAdLinearSystemSparskit.h"
-namespace MAd {
- typedef MAdLinearSystemSparskit MAdLinearSystemDef;
-}
-#else
-
-#ifdef _HAVE_GMM_
-#include "MAdLinearSystemGmm.h"
-namespace MAd {
- typedef MAdLinearSystemGmm MAdLinearSystemDef;
-}
-#else
-namespace MAd {
- typedef MAdLinearSystemNull MAdLinearSystemDef;
-}
-#endif // end gmm
-#endif // end sparskit
-#endif // end PETSc
-
-// -------------------------------------------------------------------
-
-#endif
-
-
diff --git a/Adapt/utils/MAdLinearSystemGmm.h b/Adapt/utils/MAdLinearSystemGmm.h
deleted file mode 100644
index c2d986b..0000000
--- a/Adapt/utils/MAdLinearSystemGmm.h
+++ /dev/null
@@ -1,111 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_LINEARSYSTEMGMM_MAD
-#define _H_LINEARSYSTEMGMM_MAD
-
-#ifdef _HAVE_GMM_
-
-// Interface to GMM++
-
-#include "MAdLinearSystem.h"
-
-#include <gmm.h>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class MAdLinearSystemGmm : public MAdLinearSystem {
-
- public :
-
- MAdLinearSystemGmm () : MAdLinearSystem(), _a(0), _b(0), _x(0), _prec(1.e-8), _noisy(0) {}
- ~MAdLinearSystemGmm ()
- {
- delete _a;
- delete _b;
- delete _x;
- }
-
- public:
-
- bool isAllocated () const {return _a != 0;}
- void allocate (int _nbRows)
- {
- if (_a) delete _a;
- if (_x) delete _x;
- if (_b) delete _b;
- _a = new gmm::row_matrix< gmm::wsvector<double> >(_nbRows,_nbRows);
- _b = new std::vector<double>(_nbRows);
- _x = new std::vector<double>(_nbRows);
- }
- void addToMatrix (int _row, int _col, double _val)
- {
- if (_val != 0.0) (*_a)(_row, _col) += _val;
- }
- double getFromMatrix (int _row, int _col) const
- {
- return (*_a)(_row, _col);
- }
- void addToRightHandSide (int _row, double _val)
- {
- if (_val != 0.0) (*_b)[_row]+=_val;
- }
- double getFromRightHandSide (int _row) const
- {
- return (*_b)[_row];
- }
- double getFromSolution (int _row) const
- {
- return (*_x)[_row];
- }
- void zeroMatrix ()
- {
- gmm::clear(*_a);
- }
- void zeroRightHandSide ()
- {
- for (unsigned int i = 0; i < _b->size(); i++) (*_b)[i] = 0;
- }
- void reorder () {
-
- }
- void setPrec(double p){_prec=p;}
- void setNoisy(int n){_noisy=n;}
- int systemSolve ()
- {
- //gmm::ilut_precond< gmm::row_matrix< gmm::wsvector<double> > > P(*_a, fill, _prec);
- gmm::ildltt_precond< gmm::row_matrix< gmm::wsvector<double> > > P(*_a, fill, _prec);
- gmm::iteration iter(eps);
- iter.set_noisy(_noisy);
- // gmm::sequential_additive_schwarz(*_a, *_x, *_b, P, vB, iter, local_solver, global_solver)
- if (sType==GMRES)gmm::gmres(*_a, *_x, *_b, P, 100, iter); // execute the GMRES algorithm
- else gmm::cg(*_a, *_x, *_b, P, iter); // execute the CG algorithm
- return 1;
- }
-
- private:
-
- gmm::row_matrix<gmm::wsvector<double> > *_a;
- std::vector<double> *_b, *_x;
- double _prec;
- int _noisy;
- };
-
- // -------------------------------------------------------------------
-
-#endif
-
-}
-
-#endif
diff --git a/Adapt/utils/MAdLinearSystemPETSc.h b/Adapt/utils/MAdLinearSystemPETSc.h
deleted file mode 100644
index f5a68e0..0000000
--- a/Adapt/utils/MAdLinearSystemPETSc.h
+++ /dev/null
@@ -1,215 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Richard Comblen, Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_LINEARSYSTEMPETSC_MAD
-#define _H_LINEARSYSTEMPETSC_MAD
-
-// -------------------------------------------------------------------
-// Interface to PETSc
-// -------------------------------------------------------------------
-
-#ifdef _HAVE_PETSC_
-
-#include "MAdLinearSystem.h"
-#include "petsc.h"
-#include "petscksp.h"
-#include "petscmat.h"
-#include "petscvec.h"
-#include <iostream>
-
-namespace MAd {
- class MAdLinearMatrixPETSc {
- private:
- int * nnz;
- int local_size, global_size;
- bool allocated, assembled;
- public:
- Mat mat;
- MAdLinearMatrixPETSc(int _local_size, int _global_size) {
- local_size = _local_size;
- global_size = _global_size;
- nnz = new int[local_size];
- mat = NULL;
- allocated = false;
- assembled = false;
- }
- ~MAdLinearMatrixPETSc() {
- if(mat) MatDestroy(mat);
- delete [] nnz;
- }
- void set_nnz(int row, int nz){
- nnz[row] = nz;
- }
- // You must call set_nnz before!
- void allocate(){
- if(!allocated){
- MatCreate(PETSC_COMM_WORLD, &mat);
- MatSetSizes(mat,local_size,local_size,global_size,global_size);
- MatSetFromOptions(mat);
- // MatMPIAIJSetPreallocationCSR(mat,sparsity->rowstart,sparsity->colind,NULL);
- MatSeqAIJSetPreallocation(mat,0,nnz);
- allocated=true;
- }
- }
- void add(int row, int col, double val){
- MatSetValue(mat, row, col, val, ADD_VALUES);
- assembled = false;
- }
- void assemble()
- {
- if(assembled) return;
- MatAssemblyBegin(mat, MAT_FINAL_ASSEMBLY);
- MatAssemblyEnd (mat, MAT_FINAL_ASSEMBLY);
-#if PETSC_VERSION_MAJOR==3
- MatSetOption(mat, MAT_NEW_NONZERO_LOCATIONS,PETSC_FALSE);
- MatSetOption(mat, MAT_NEW_NONZERO_LOCATION_ERR,PETSC_TRUE);
-#else
- MatSetOption(mat, MAT_NO_NEW_NONZERO_LOCATIONS);
-#endif
- assembled = true;
- }
- void zero(){
- //assemble();
- MatZeroEntries(mat);
- }
- };
- class MAdLinearVectorPETSc {
- private:
- int local_size, global_size, nghosts;
- double * entries;
- public:
- Vec vec;
- MAdLinearVectorPETSc(int _local_size, int _global_size){
- global_size = _global_size;
- local_size = _local_size;
- nghosts = 0;
- entries = new double[local_size+nghosts];
- VecCreateMPIWithArray(MPI_COMM_WORLD,local_size,global_size,entries,&vec);
- VecAssemblyBegin(vec);
- VecAssemblyEnd(vec);
- VecSet(vec, 0);
- get_array();
- }
- ~MAdLinearVectorPETSc(){
- VecDestroy(vec);
- delete []entries;// Check whether Petsc does destroy it or not...
- }
- inline double& operator()(int row){
- return entries[row];
- }
- void zero(){
- for(int i=0;i<local_size+nghosts;i++){
- entries[i]=0;
- }
- }
- void gather(){
- // To be implemented - see slim_vector.cc
- }
- void scatter(){
- // To be implemented - see slim_vector.cc
- }
- void get_array(){
- VecGetArray(vec,&entries);
- }
- void restore_array(){
- VecRestoreArray(vec,&entries);
- }
- };
-
- // -------------------------------------------------------------------
- class MAdLinearSystemPETSc : public MAdLinearSystem {
-
- private:
- MAdLinearMatrixPETSc * matrix;
- MAdLinearVectorPETSc * rhs;
- MAdLinearVectorPETSc * X;
- KSP ksp;
-
- public:
-
- MAdLinearSystemPETSc():
- MAdLinearSystem()
- {
- PetscInitialize(0,NULL, NULL, NULL);
- KSPCreate(PETSC_COMM_WORLD, &ksp);
- }
- ~MAdLinearSystemPETSc ()
- {
- KSPDestroy(ksp);
- delete matrix;
- delete rhs;
- delete X;
- }
- bool isAllocated () const {throw;}
- void allocate (int nbRows){
- int local_size, global_size;
- local_size = global_size = nbRows;
- matrix = new MAdLinearMatrixPETSc(local_size, global_size);
- rhs = new MAdLinearVectorPETSc(local_size, global_size);
- X = new MAdLinearVectorPETSc(local_size, global_size);
- }
- void addToMatrix (int row, int col, double val) {
- matrix->add(row,col,val);
- }
- double getFromMatrix (int _row, int _col) const {
- throw;
- }
- void addToRightHandSide (int row, double val) {
- (*rhs)(row) += val;
- }
- double getFromRightHandSide (int row) const {
- return (*rhs)(row);
- }
- double getFromSolution (int row) const {
- return (*X)(row);
- }
- void zeroMatrix () {
- matrix->zero();
- }
- void zeroRightHandSide () {
- rhs->zero();
- }
- void reorder () {
- }
- void set_nnz(int row,int nz){
- matrix->set_nnz(row,nz);
- }
- void allocate_matrix(){
- matrix->allocate();
- }
- void setSolver(SolverType _type) {
- }
- int systemSolve () {
- rhs->restore_array();
- X->restore_array();
- matrix->assemble();
- std::string options;
- options="-pc_type bjacobi -sub_pc_type icc -ksp_type cg -ksp_rtol 1e-6";
-// options="-pc_type hypre -pc_hypre_type boomeramg -pc_hypre_boomeramg_print_statistics -ksp_type gmres -ksp_rtol 1e-7 -ksp_monitor";
- PetscOptionsInsertString(options.c_str());
- KSPSetFromOptions(ksp);
- KSPSetOperators (ksp, matrix->mat, matrix->mat, DIFFERENT_NONZERO_PATTERN);
- KSPSolve(ksp, rhs->vec, X->vec);
-
- X->get_array();
- rhs->get_array();
- KSPConvergedReason reason;
- return KSPGetConvergedReason(ksp,&reason);
- }
-
- };
-}
-
-#endif
-
-#endif
diff --git a/Adapt/utils/MAdLinearSystemSparskit.h b/Adapt/utils/MAdLinearSystemSparskit.h
deleted file mode 100644
index a578c1e..0000000
--- a/Adapt/utils/MAdLinearSystemSparskit.h
+++ /dev/null
@@ -1,106 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_LINEARSYSTEMSPARSKIT_MAD
-#define _H_LINEARSYSTEMSPARSKIT_MAD
-
-// -------------------------------------------------------------------
-// Interface to Y Saad's sparskit lib
-// -------------------------------------------------------------------
-
-#ifdef _HAVE_SPARSKIT_
-
-#include "MAdLinearSystem.h"
-#include "MAdMessage.h"
-
-#include "CSR_Matrix.h"
-#include "CSR_Vector.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class MAdLinearSystemSparskit : public MAdLinearSystem {
-
- public:
-
- MAdLinearSystemSparskit ():
- MAdLinearSystem(),_a(0),_b(0),_x(0)
- {
- }
- ~MAdLinearSystemSparskit ()
- {
- delete _a;
- delete _b;
- delete _x;
- }
- bool isAllocated () const {return _a != 0;}
- void allocate (int _nbRows)
- {
- if (_a) delete _a;
- if (_b) delete _b;
- if (_x) delete _x;
- _a = new CSR_Matrix (_nbRows);
- _b = new CSR_Vector (_nbRows);
- _x = new CSR_Vector (_nbRows);
- }
- void addToMatrix (int _row, int _col, double _val) {
- if (_val != 0.0) _a->AddMatrix (_row+1, _col+1, _val);
- }
- double getFromMatrix (int _row, int _col) const {
- return _a->GetMatrix (_row+1,_col+1);
- }
- void addToRightHandSide (int _row, double _val) {
- if (_val != 0.0) _b->AddVal(_row+1, _val);
- }
- double getFromRightHandSide (int _row) const {
- return _b->GetVal (_row+1);
- }
- double getFromSolution (int _row) const {
- return _x->GetVal (_row+1);
- }
- void zeroMatrix () {
- _a->ZeroMatrix();
- }
- void zeroRightHandSide () {
- _b->ZeroArray();
- }
- void reorder () {
-
- }
- void setSolver(SolverType _type) {
- MAdMsgSgl::instance().warning(__LINE__,__FILE__,"CG not available in Sparskit, GMRES will be used\n");
- sType = GMRES;
- }
- int systemSolve () {
- _a->EndOfAssembly();
- std::string solver = "gmres";
- // if (sType == CG) solver = "cg";
- SPARSKIT_LINEAR_SOLVER_ ( "rcmk","ilut",solver,fill,eps,*_a,*_b,*_x);
- return 1;
- }
-
- private:
-
- CSR_Matrix *_a;
- CSR_Vector *_b;
- CSR_Vector *_x;
-
- };
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
-
-#endif
diff --git a/Adapt/utils/MAdStatistics.cc b/Adapt/utils/MAdStatistics.cc
deleted file mode 100644
index 5269899..0000000
--- a/Adapt/utils/MAdStatistics.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MAdStatistics.h"
-
-using std::ostream;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void MAdStatistics::initialize()
- {
- t_eSplits = 0.;
- t_eCollapses = 0.;
- t_eSwaps = 0.;
- t_rSlivers = 0.;
- t_fSlivers = 0.;
-
- num_eSplits = 0;
- num_eCollapses = 0;
- num_eSwaps = 0;
-
- numInfLoops = 0;
- }
-
- // -------------------------------------------------------------------
- void MAdStatistics::finalize()
- {
- }
-
- // -------------------------------------------------------------------
- void MAdStatistics::print(ostream& out) const
- {
- out << "\n*** Statistics about local mesh modifications *** \n\n";
-
- out << "Time spent in the different operators:\n";
- double t_Total = t_eSplits + t_eCollapses + t_eSwaps + t_rSlivers + t_fSlivers;
- out << "Edge splits\tEdge collapses\tEdge swaps\tSlivers\tTotal\n"
- << t_eSplits <<"\t"<< t_eCollapses <<"\t"<< t_eSwaps <<"\t"
- << t_rSlivers+t_fSlivers <<"\t"<< t_Total <<"\n\n";
-
- out << "Number of elementary operations (excluding sliver handling):\n";
- out << "Edge splits\tEdge collapses\tEdge swaps\n"
- << num_eSplits <<"\t"<< num_eCollapses <<"\t"<< num_eSwaps << "\n\n";
-
- out << "Number of infinite loops:\t" << numInfLoops << "\n\n";
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/utils/MAdStatistics.h b/Adapt/utils/MAdStatistics.h
deleted file mode 100644
index df95304..0000000
--- a/Adapt/utils/MAdStatistics.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MADSTATISTICS
-#define _H_MADSTATISTICS
-
-#include "MAdSingleton.h"
-
-#include <iostream>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class MAdStatistics {
-
- public:
-
- MAdStatistics() {};
- ~MAdStatistics() {};
-
- void initialize();
- void finalize();
-
- void print(std::ostream& out) const;
-
- // -----------------------
- // CPU time
- // -----------------------
-
- private:
-
- double t_eSplits, t_eCollapses, t_eSwaps, t_rSlivers, t_fSlivers;
-
- public:
-
- void addCPUESplits (double dt) { t_eSplits += dt; }
- void addCPUECollapses (double dt) { t_eCollapses += dt; }
- void addCPUESwaps (double dt) { t_eSwaps += dt; }
- void addCPURSlivers (double dt) { t_rSlivers += dt; }
- void addCPUFSlivers (double dt) { t_fSlivers += dt; }
-
- double getCPUESplits () const { return t_eSplits; }
- double getCPUECollapses () const { return t_eCollapses; }
- double getCPUESwaps () const { return t_eSwaps; }
- double getCPURSlivers () const { return t_rSlivers; }
- double getCPUFSlivers () const { return t_fSlivers; }
-
-
- // -----------------------------
- // Elementary operations count
- // -----------------------------
-
- private:
-
- int num_eSplits, num_eCollapses, num_eSwaps;
-
- public:
-
- void addNumESplits (int num) { num_eSplits += num; }
- void addNumECollapses (int num) { num_eCollapses += num; }
- void addNumESwaps (int num) { num_eSwaps += num; }
-
-
- // -----------------------------
- // Others
- // -----------------------------
-
- private:
-
- int numInfLoops;
-
- public:
-
- void addInfiniteLoops(int num) { numInfLoops += num; }
-
- };
-
- // -------------------------------------------------------------------
-
- typedef MAdSingleton<MAdStatistics> MAdStatisticsSgl;
-
-}
-
-#endif
diff --git a/Adapt/utils/MAdTimeManager.cc b/Adapt/utils/MAdTimeManager.cc
deleted file mode 100644
index ea341e7..0000000
--- a/Adapt/utils/MAdTimeManager.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MAdTimeManager.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void MAdTimeManager::initialize()
- {
- time = 0.;
- }
-
- // -------------------------------------------------------------------
- void MAdTimeManager::finalize()
- {
- }
-
- // -------------------------------------------------------------------
- void MAdTimeManager::setTime(double _t)
- {
- time = _t;
- }
-
- // -------------------------------------------------------------------
- void MAdTimeManager::incrementTime(double dt)
- {
- time += dt;
- }
-
- // -------------------------------------------------------------------
- double MAdTimeManager::getTime() const
- {
- return time;
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/utils/MAdTimeManager.h b/Adapt/utils/MAdTimeManager.h
deleted file mode 100644
index c745d90..0000000
--- a/Adapt/utils/MAdTimeManager.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MADTIMEMANAGER
-#define _H_MADTIMEMANAGER
-
-#include "MAdSingleton.h"
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- class MAdTimeManager {
-
- public:
-
- MAdTimeManager() {};
- ~MAdTimeManager() {};
-
- void initialize();
- void finalize();
-
- void setTime(double);
- void incrementTime(double);
-
- double getTime() const;
-
- private:
-
- double time;
-
- };
-
- // -------------------------------------------------------------------
-
- typedef MAdSingleton<MAdTimeManager> MAdTimeManagerSgl;
-
-}
-
-#endif
diff --git a/Adapt/utils/NodalDataManager.cc b/Adapt/utils/NodalDataManager.cc
deleted file mode 100644
index cad2d15..0000000
--- a/Adapt/utils/NodalDataManager.cc
+++ /dev/null
@@ -1,614 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "NodalDataManager.h"
-#include "CallBackManager.h"
-#include "MAdOutput.h"
-
-#include "MSops.h"
-
-#include <iostream>
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::vector;
-using std::set;
-using std::ostream;
-using std::string;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- void P1CBFunction (pPList before, pPList after, void *dataNames,
- operationType type , pEntity ppp) {
-
- set<string>* knownDataNames = static_cast<set<string>*>(dataNames);
-
- switch (type) {
- case MAd_ESPLIT: {
- // In the edge split case, we have to interpolate the data at the new node
-
- set<string>::const_iterator tIter = (*knownDataNames).begin();
- set<string>::const_iterator tLast = (*knownDataNames).end();
- for (; tIter != tLast; tIter++ ) {
-
- pMeshDataId dataId = MD_lookupMeshDataId((*tIter).c_str());
-
- // find the old edge
- void *tmp=0;
- pEntity pE = PList_next(before,&tmp);
- double t = E_linearParams((pEdge)pE,(pVertex)ppp);
-
- // get datas at old nodes
- double data0 = 0.;
- pVertex pV0 = E_vertex((pEdge)pE, 0);
- int gotit0 = EN_getDataDbl((pEntity)pV0, dataId, &data0);
-
- double data1 = 0.;
- pVertex pV1 = E_vertex((pEdge)pE, 1);
- int gotit1 = EN_getDataDbl((pEntity)pV1, dataId, &data1);
-
- if (!gotit0 || !gotit1) {
- printf("Error: one of the nodes has no data attached to with name %s",
- (*tIter).c_str());
- throw;
- }
-
- // Interpolate the data at the new node.
- double newData = (1.-t) * data0 + t * data1;
-
- // attach it
- EN_attachDataDbl(ppp, dataId, newData);
- }
-
- break;
- }
- case MAd_ECOLLAPSE: {
- // In the edge collapse case, we have to delete the datas attached to the deleted node
-
- set<string>::const_iterator tIter = (*knownDataNames).begin();
- set<string>::const_iterator tLast = (*knownDataNames).end();
- for (; tIter != tLast; tIter++ ) {
-
- pMeshDataId dataId = MD_lookupMeshDataId((*tIter).c_str());
- EN_deleteData(ppp, dataId);
- }
-
- break;
- }
- case MAd_ESWAP:
- case MAd_FSWAP: {
- // nothing to be done (no modification at nodes)
- break;
- }
- case MAd_RREMOVE: {
- void * temp = NULL;
- while ( pEntity pE = PList_next(before,&temp) ) {
- if ( EN_type(pE) == 0 ) {
- set<string>::const_iterator tIter = (*knownDataNames).begin();
- set<string>::const_iterator tLast = (*knownDataNames).end();
- for (; tIter != tLast; tIter++ ) {
- pMeshDataId dataId = MD_lookupMeshDataId((*tIter).c_str());
- EN_deleteData( (pVertex)pE, dataId);
- }
- }
- }
- break;
- }
- case MAd_UNKNOWNOPERATION:
- case MAd_VERTEXMOVE:
- case MAd_FCOLLAPSE:
- case MAd_DESPLTCLPS:
- default: {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Not implemented for mesh modification %d",
- type);
- }
- }
-
- }
-
- // -------------------------------------------------------------------
- void P1VecCBFunction (pPList before, pPList after, void *dataNames,
- operationType type , pEntity ppp) {
-
- set<string>* knownDataNames = static_cast<set<string>*>(dataNames);
-
- switch (type) {
- case MAd_ESPLIT: {
- // In the edge split case, we have to interpolate the data at the new node
-
- set<string>::const_iterator tIter = (*knownDataNames).begin();
- set<string>::const_iterator tLast = (*knownDataNames).end();
- for (; tIter != tLast; tIter++ ) {
-
- pMeshDataId dataId = MD_lookupMeshDataId((*tIter).c_str());
-
- // find the old edge
- void *tmp=0;
- pEntity pE = PList_next(before,&tmp);
- double t = E_linearParams((pEdge)pE,(pVertex)ppp);
-
- // get coordinates and datas at old nodes
- void * data0 = NULL;
- pVertex pV0 = E_vertex((pEdge)pE, 0);
- int gotit0 = EN_getDataPtr((pEntity)pV0, dataId, &data0);
- vector<double> * vec0 = (vector<double>*) data0;
-
- void * data1 = NULL;
- pVertex pV1 = E_vertex((pEdge)pE, 1);
- int gotit1 = EN_getDataPtr((pEntity)pV1, dataId, &data1);
- vector<double> * vec1 = (vector<double>*) data1;
-
- if (!gotit0 || !gotit1) {
- printf("Error: one of the nodes has no data attached to with name %s",
- (*tIter).c_str());
- throw;
- }
-
- // Interpolate the data at the new node.
- vector<double> * newData = new vector<double>;
- for (int i=0; i<3; i++) (*newData).push_back( (1.-t) * (*vec0)[i] + t * (*vec1)[i] );
-
- // attach it
- EN_attachDataPtr(ppp, dataId, newData);
- }
-
- break;
- }
- case MAd_ECOLLAPSE: {
- // In the edge collapse case, we have to delete the datas attached to the deleted node
-
- set<string>::const_iterator tIter = (*knownDataNames).begin();
- set<string>::const_iterator tLast = (*knownDataNames).end();
- for (; tIter != tLast; tIter++ ) {
-
- pMeshDataId dataId = MD_lookupMeshDataId((*tIter).c_str());
- void * data = NULL;
- int gotit = EN_getDataPtr((pEntity)ppp, dataId, &data);
- vector<double> * vec = (vector<double>*) data;
- if (gotit && vec) delete vec;
- EN_deleteData(ppp, dataId);
- }
-
- break;
- }
- case MAd_ESWAP:
- case MAd_FSWAP: {
- // nothing to be done (no modification at nodes)
- break;
- }
- case MAd_RREMOVE: {
- void * temp = NULL;
- while ( pEntity pE = PList_next(before,&temp) ) {
- if ( EN_type(pE) == 0 ) {
- set<string>::const_iterator tIter = (*knownDataNames).begin();
- set<string>::const_iterator tLast = (*knownDataNames).end();
- for (; tIter != tLast; tIter++ ) {
- pMeshDataId dataId = MD_lookupMeshDataId((*tIter).c_str());
- void * data = NULL;
- int gotit = EN_getDataPtr((pEntity)ppp, dataId, &data);
- vector<double> * vec = (vector<double>*) data;
- if (gotit && vec) delete vec;
- EN_deleteData((pVertex)pE, dataId);
- }
- }
- }
- break;
- }
- case MAd_UNKNOWNOPERATION:
- case MAd_VERTEXMOVE:
- case MAd_FCOLLAPSE:
- case MAd_DESPLTCLPS:
- default: {
- printf("Error in NodalDataManager: Callback function not implemented for mesh modification %d",
- type);
- throw;
- }
- }
-
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::initialize(pMesh m)
- {
- mesh = m;
-
- prefix = "NodalDataManagerId_";
- prefixVec = prefix + "Vec_";
-
- coordNameBase = "StoredCoordinates__";
-
- if(knownDataNames )
- {
- knownDataNames->clear();
- }
- else
- {
- knownDataNames= new set<string>();
- }
- if ( knownDataVecNames )
- {
- knownDataVecNames->clear();
- }
- else
- {
- knownDataVecNames = new set<string>();
- }
-
- CallBackManagerSgl::instance().registerCallBack(P1CBFunction, knownDataNames );
- CallBackManagerSgl::instance().registerCallBack(P1VecCBFunction,knownDataVecNames);
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::setMesh(pMesh m)
- {
- mesh = m;
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::finalize()
- {
- removeAllData();
- if (knownDataNames)
- {
- delete knownDataNames;
- knownDataNames = NULL;
- }
- if (knownDataVecNames)
- {
- delete knownDataVecNames;
- knownDataVecNames = NULL;
- }
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::diagnostics (ostream& out) const
- {
- out << "\nContent of the nodal data manager:\n";
-
- out << "\n - Double scalar : " << knownDataNames->size() << " fields:\n";
- set<string>::iterator iIter;
- set<string>::iterator iLast;
- iIter = (*knownDataNames).begin();
- iLast = (*knownDataNames).end();
- for (; iIter != iLast; iIter++) {
- out << " - "<< *iIter << "\n";
- }
-
- out << "\n - Double vector : " << knownDataVecNames->size() << " vector fields:\n";
- iIter = (*knownDataVecNames).begin();
- iLast = (*knownDataVecNames).end();
- for (; iIter != iLast; iIter++) {
- out << " - "<< *iIter << "\n";
- }
-
- out << "\n" << endl;
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::removeAllData()
- {
- set<string>::iterator iIter;
- set<string>::iterator iLast;
-
- iIter = (*knownDataNames).begin();
- iLast = (*knownDataNames).end();
- for (; iIter != iLast; iIter++) removeData(*iIter);
-
- iIter = (*knownDataVecNames).begin();
- iLast = (*knownDataVecNames).end();
- for (; iIter != iLast; iIter++) removeVData(*iIter);
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::registerData(string name, const vector<double> datas)
- {
- string dataName = prefix + name;
-
- // check that this name doesn't exists yet
- if ( nameExists(dataName,0) ) {
- cerr << "Error: this scalar data \'"<<name<<"\' is already registered in the NodalDataManager\n";
- throw;
- }
-
- // check that the number of datas is equal to the number of nodes in the mesh
- int nbDatas = datas.size();
- if ( nbDatas != M_numVertices(mesh) ) {
- cerr<< "Error: wrong number of datas ("<<nbDatas<<") with "<<M_numVertices(mesh)<<" nodes\n";
- throw;
- }
-
- // add this name to the list
- (*knownDataNames).insert(dataName);
-
- // attach the data at nodes
- pMeshDataId id = MD_lookupMeshDataId( dataName.c_str() );
- int i = 0;
- VIter vit = M_vertexIter(mesh);
- while (pVertex pv = VIter_next(vit))
- {
- EN_attachDataDbl((pEntity)pv,id,datas[i]);
- i++;
- }
- VIter_delete(vit);
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::registerVData(string name,
- const vector<vector<double> > datas)
- {
- string dataName = prefixVec + name;
-
- // check that this name doesn't exists yet
- if ( nameExists(dataName,1) ) {
- cerr << "Error: this vectorial data \'"<<name<<"\' is already registered in the NodalDataManager\n";
- throw;
- }
-
- // check that the number of datas is equal to the number of nodes in the mesh
- int nbDatas = datas.size();
- if ( nbDatas != M_numVertices(mesh) ) {
- cerr<< "Error: wrong number of datas ("<<nbDatas<<") with "<<M_numVertices(mesh)<<" nodes\n";
- throw;
- }
-
- // add this name to the list
- (*knownDataVecNames).insert(dataName);
-
- // attach the data at nodes
- pMeshDataId id = MD_lookupMeshDataId( dataName.c_str() );
- int i = 0;
- VIter vit = M_vertexIter(mesh);
- while (pVertex pv = VIter_next(vit))
- {
- vector<double> * copy = new vector<double>(datas[i]);
- EN_attachDataPtr((pEntity)pv,id,copy);
- i++;
- }
- VIter_delete(vit);
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::getMeshData(string name, vector<double> * result) const
- {
- string dataName = prefix + name;
-
- // check that this name exists
- if ( !nameExists(dataName,0) ) {
- cerr << "Error: this scalar data \'"<<name<<"\' is not registered in the NodalDataManager\n";
- throw;
- }
-
- result->clear();
-
- pMeshDataId id = MD_lookupMeshDataId( dataName.c_str() );
-
- int i = 0;
- VIter vit = M_vertexIter(mesh);
- while (pVertex pv = VIter_next(vit))
- {
- double theDbl;
- EN_getDataDbl((pEntity)pv,id,&theDbl);
- result->push_back(theDbl);
- i++;
- }
- VIter_delete(vit);
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::getMeshVData(string name, vector<vector<double> > * result) const
- {
- string dataName = prefixVec + name;
-
- // check that this name exists
- if ( !nameExists(dataName,1) ) {
- cerr << "Error: this vectorial data \'"<<name<<"\' is not registered in the NodalDataManager\n";
- throw;
- }
-
- result->clear();
-
- pMeshDataId id = MD_lookupMeshDataId( dataName.c_str() );
-
- int i = 0;
- VIter vit = M_vertexIter(mesh);
- while (pVertex pv = VIter_next(vit))
- {
- void * tmp = 0;
- EN_getDataPtr((pEntity)pv,id,&tmp);
- vector<double> * vec = (vector<double>*) tmp;
- result->push_back(*vec);
- i++;
- }
- VIter_delete(vit);
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::getData(string name, pVertex pv, double* res) const
- {
- string dataName = prefix + name;
-
- // check that this name exists
- if ( !nameExists(dataName,0) ) {
- cerr << "Error: this scalar data \'"<<name<<"\' is not registered in the NodalDataManager\n";
- throw;
- }
-
- pMeshDataId id = MD_lookupMeshDataId( dataName.c_str() );
-
- EN_getDataDbl((pEntity)pv,id,res);
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::getVData(string name, pVertex pv, vector<double>& res) const
- {
- string dataName = prefixVec + name;
-
- // check that this name exists
- if ( !nameExists(dataName,1) ) {
- cerr << "Error: this vectorial data \'"<<name<<"\' is not registered in the NodalDataManager\n";
- throw;
- }
-
- pMeshDataId id = MD_lookupMeshDataId( dataName.c_str() );
-
- void * tmp = 0;
- EN_getDataPtr((pEntity)pv,id,&tmp);
- res.clear();
- for (int i=0; i<3; i++) res.push_back( (*( (vector<double>*) tmp))[i] );
-
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::removeData(string name)
- {
- string dataName = prefix + name;
-
- if ( !nameExists(dataName,0) ) return;
-
- // remove it from the list of names
- set<string>::iterator iIter = (*knownDataNames).find(dataName);
- (*knownDataNames).erase(iIter);
-
- // delete the datas at nodes
- pMeshDataId id = MD_lookupMeshDataId( (dataName).c_str() );
- VIter vit = M_vertexIter(mesh);
- while (pVertex pv = VIter_next(vit))
- {
- EN_deleteData((pEntity)pv,id);
- }
- VIter_delete(vit);
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::removeVData(string name)
- {
- string dataName = prefixVec + name;
-
- if ( !nameExists(dataName,1) ) return;
-
- // remove it from the list of names
- set<string>::iterator iIter = (*knownDataVecNames).find(dataName);
- (*knownDataVecNames).erase(iIter);
-
- // delete the datas at nodes
- pMeshDataId id = MD_lookupMeshDataId( dataName.c_str() );
- VIter vit = M_vertexIter(mesh);
- while (pVertex pv = VIter_next(vit))
- {
- void * data = NULL;
- int gotit = EN_getDataPtr((pEntity)pv, id, &data);
- vector<double> * vec = (vector<double>*) data;
- if (gotit && vec) delete vec;
- EN_deleteData((pEntity)pv, id);
- }
- VIter_delete(vit);
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::writeData(string name, const char *fn)
- {
- string dataName = prefix + name;
-
- // check that this name exists
- if ( !nameExists(dataName,0) ) {
- cerr << "Error: this data \'"<<name<<"\' is not registered in the NodalDataManager\n";
- throw;
- }
-
- pMeshDataId id = MD_lookupMeshDataId( dataName.c_str() );
-
- MAdAttachedNodalDataOutput(mesh, fn, id);
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::writeVData(string name, const char *fn)
- {
- string dataName = prefixVec + name;
-
- // check that this name exists
- if ( !nameExists(dataName,1) ) {
- cerr << "Error: this data \'"<<name<<"\' is not registered in the NodalDataManager\n";
- throw;
- }
-
- pMeshDataId id = MD_lookupMeshDataId( dataName.c_str() );
-
- MAdMsgSgl::instance().warning(__LINE__,__FILE__,
- "Output for vectorial attached data is not implemented");
- // it is implemented for double arrays, not vectors.
- // This class should store double arrays too, to be done (GC).
- // MAdAttachedNodalDataVecOutput(mesh, fn, id);
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::storeCoordinates()
- {
- removeCoordinates();
-
- // add the coordinates name to the list
- string coordName = prefixVec + coordNameBase;
- (*knownDataVecNames).insert(coordName);
-
- // attach the data at nodes
- pMeshDataId id = MD_lookupMeshDataId( coordName.c_str() );
- VIter vit = M_vertexIter(mesh);
- while (pVertex pv = VIter_next(vit))
- {
- double xyz[3]; V_coord(pv,xyz);
- vector<double> * vec = new vector<double>;
- for (int j = 0; j<3; j++) (*vec).push_back(xyz[j]);
- EN_attachDataPtr((pEntity)pv,id,vec);
- }
- VIter_delete(vit);
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::getStoredCoordinates(pVertex pv, vector<double>& res)
- {
- getVData(coordNameBase,pv,res);
- }
-
- // -------------------------------------------------------------------
- void NodalDataManager::removeCoordinates()
- {
- removeVData(coordNameBase);
- }
-
- // -------------------------------------------------------------------
- bool NodalDataManager::isCoordinates()
- {
- string coordName = prefixVec + coordNameBase;
- return nameExists(coordName,1);
- }
-
- // -------------------------------------------------------------------
-
- bool NodalDataManager::nameExists(string dataName, int vec) const
- {
- if ( vec == 0 ) {
- set<string>::iterator iIter = (*knownDataNames).find(dataName);
- if ( iIter == (*knownDataNames).end() ) return false;
- else return true;
- }
- if ( vec == 1 ) {
- set<string>::iterator iIter = (*knownDataVecNames).find(dataName);
- if ( iIter == (*knownDataVecNames).end() ) return false;
- else return true;
- }
- return true;
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Adapt/utils/NodalDataManager.h b/Adapt/utils/NodalDataManager.h
deleted file mode 100644
index ad4cbd7..0000000
--- a/Adapt/utils/NodalDataManager.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_NODALDATAMANAGER
-#define _H_NODALDATAMANAGER
-
-#include "MSops.h"
-
-#include "MAdSingleton.h"
-
-#include <vector>
-#include <string>
-#include <set>
-#include <iostream>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
-
- class NodalDataManager {
-
- public:
-
- NodalDataManager():mesh(NULL),
- knownDataNames(NULL), knownDataVecNames(NULL){};
- ~NodalDataManager() {};
-
- void initialize(pMesh m);
- void setMesh(pMesh m);
- void finalize();
-
- void removeAllData();
-
- void diagnostics (std::ostream& out) const;
-
- // will attach the datas to the nodes of the mesh
- // order in vector is the node iterator order
- void registerData (std::string name, const std::vector<double>);
- void registerVData (std::string name, const std::vector<std::vector<double> >);
-
- // will fill the variable with the datas attached to the nodes
- // this function does not allocate memory
- // order in vector is the node iterator order
- void getMeshData (std::string name, std::vector<double> *) const;
- void getMeshVData (std::string name, std::vector<std::vector<double> > *) const;
-
- // get the data at a node
- void getData (std::string name, pVertex pv, double* res) const;
- void getVData (std::string name, pVertex pv, std::vector<double>& res) const;
-
- // will delete the data attached to the nodes
- void removeData (std::string name);
- void removeVData (std::string name);
-
- // write the data in a postprocessing file
- void writeData (std::string name, const char *fn);
- void writeVData (std::string name, const char *fn);
-
- // functions to keep track of the initial coordinates
- void storeCoordinates();
- void getStoredCoordinates(pVertex pv, std::vector<double>& res);
- void removeCoordinates();
- bool isCoordinates();
-
- private:
-
- pMesh mesh;
-
- // prefix for identification of the datas from this manager
- // ensures there is no clash with other datas
- std::string prefix;
- std::string prefixVec;
-
- // identifier for the coordinates
- std::string coordNameBase;
-
- // stored with the prefix
- std::set<std::string>* knownDataNames;
- std::set<std::string>* knownDataVecNames;
-
- private:
-
- bool nameExists(std::string name, int vec) const;
-
- };
-
- // -------------------------------------------------------------------
-
- typedef MAdSingleton<NodalDataManager> NodalDataManagerSgl;
-
-}
-
-#endif
diff --git a/Common/MAdDefines.h b/Common/MAdDefines.h
deleted file mode 100644
index b0faeca..0000000
--- a/Common/MAdDefines.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// -*- C++ -*-
-
-#ifndef _H_MADDEFINES
-#define _H_MADDEFINES
-
-#define MAdTHIRD 0.33333333333333
-#define MAdSIXTH 0.16666666666667
-
-#define MAdPI 3.14159265358979
-#define MAdPITH 0.31830988618379
-
-#define MAdBIG 1.e14
-#define MAdTOL 1.e-12
-#define MAdTOLSQ 1.e-24
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- enum operationType {
- MAd_UNKNOWNOPERATION = 0,
- MAd_VERTEXMOVE = 1,
- MAd_ESPLIT = 2,
- MAd_ECOLLAPSE = 3,
- MAd_FCOLLAPSE = 4,
- MAd_DESPLTCLPS = 5,
- MAd_ESWAP = 6,
- MAd_FSWAP = 7,
- MAd_RREMOVE = 8
- };
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Common/MAdFieldEvaluator.h b/Common/MAdFieldEvaluator.h
deleted file mode 100644
index 5b2da8e..0000000
--- a/Common/MAdFieldEvaluator.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MADFIELDEVALUATORBASE
-#define _H_MADFIELDEVALUATORBASE
-
-#include <ostream>
-#include <string>
-
-namespace MAd {
-
- // ----------------------------------------------------------------------
- class MAdFieldEvaluator{
- public:
- virtual bool eval (const double space[3], double time, double* val) const = 0;
- virtual int order () const = 0;
- virtual int nbVar () const = 0;
- virtual ~MAdFieldEvaluator(){};
-
- virtual void describe(std::ostream& out, const std::string& prefix) const {out << prefix << "Dummy field evaluator \n";}
- };
-
- // ----------------------------------------------------------------------
- class MAdConstantScalar : public MAdFieldEvaluator
- {
- double X;
- public :
- MAdConstantScalar(double v):X(v){}
- inline bool eval (const double space[3], double time, double* val) const {
- val[0] = X;
- return true;
- }
- inline int order() const{
- return 0;
- }
- virtual int nbVar () const {return 1;}
-
- virtual void describe(std::ostream& out,const std::string& prefix="") const{
- out << prefix << "Constant scalar field evaluator u(x,y,z,t) = " << X << "\n";
- }
-
- };
-
- // ----------------------------------------------------------------------
- class MAdConstantVector : public MAdFieldEvaluator
- {
- double U,V,W;
- public:
- MAdConstantVector(double ux=0,double uy=0,double uz=0):U(ux),V(uy),W(uz){}
- inline bool eval (const double space[3], double time, double* val) const{
- val[0] = U;
- val[1] = V;
- val[2] = W;
- return true;
- }
- inline int order() const{
- return 0;
- }
- virtual int nbVar () const {return 3;}
-
- virtual void describe(std::ostream& out,const std::string& prefix="") const{
- out << prefix << "Constant vector field evaluator u(x,y,z,t) = (" << U << "," << V << "," << W << ")\n";
- }
-
- };
-
- // ----------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Common/MAdLib.cc b/Common/MAdLib.cc
deleted file mode 100644
index 9a5fb61..0000000
--- a/Common/MAdLib.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifdef _HAVE_GMSH_
-#include "gmsh/Gmsh.h"
-#endif
-
-#include <string>
-using std::string;
-
-void MAdLibInitialize(int argc, char* argv[])
-{
-#ifdef _HAVE_GMSH_
- char * tmp[1];
- tmp[0] = (char*)" ";
- GmshInitialize(1,tmp);
- GmshSetOption("General","Terminal",1);
-#endif
-}
-
-void MAdLibFinalize()
-{
-#ifdef _HAVE_GMSH_
- GmshFinalize();
-#endif
-}
-
diff --git a/Common/MAdLib.h b/Common/MAdLib.h
deleted file mode 100644
index 7f74ee1..0000000
--- a/Common/MAdLib.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MAD_MADLIB
-#define _H_MAD_MADLIB
-
-// interface to the geometrical model
-#include "ModelInterface.h"
-
-// interface to the mesh
-#include "MeshDataBaseInterface.h"
-
-// interface to mesh adaptation
-#include "AdaptInterface.h"
-
-//! Needed with the Gmsh geometrical model
-void MAdLibInitialize(int argc, char* argv[]);
-void MAdLibFinalize();
-
-#endif
-
diff --git a/Common/MAdMatrix.cc b/Common/MAdMatrix.cc
deleted file mode 100644
index 52ceed6..0000000
--- a/Common/MAdMatrix.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MAdMatrix.h"
-
-namespace MAd {
-
-#if defined(HAVE_LAPACK)
-
- template<>
- bool MAd_BLASLAPACK_Matrix<double>::eig(MAd_BLASLAPACK_Matrix<double> &VL, // left eigenvectors
- MAd_BLASLAPACK_Vector<double> &DR, // Real part of eigenvalues
- MAd_BLASLAPACK_Vector<double> &DI, // Im part of eigenvalues
- MAd_BLASLAPACK_Matrix<double> &VR,
- bool sortRealPart ) // if true: sorted from max '|DR|' to min '|DR|'
- {
- int N = size1(), info;
- int LWORK = 10*N;
- double * work = new double[LWORK];
-
- dgeev_("V","V",
- &N,_data,
- &N,DR.data,DI.data,
- VL._data,&N,
- VR._data,&N,
- work,&LWORK,&info);
-
- delete [] work;
-
- if(info == 0)
- {
- if (sortRealPart) {
- double tmp[8];
- // do permutations
- for (int i=0; i<(size1()-1); i++) {
- int maxR = i;
- for (int j=i+1; j<size1(); j++) if ( fabs(DR(j)) > fabs(DR(maxR)) ) maxR = j;
- if ( maxR != i )
- {
- tmp[0] = DR(i); tmp[1] = DI(i);
- tmp[2] = VL(0,i); tmp[3] = VL(1,i); tmp[4] = VL(2,i);
- tmp[5] = VR(0,i); tmp[6] = VR(1,i); tmp[7] = VR(2,i);
-
- DR(i) = DR(maxR); DI(i) = DI(maxR);
- VL(0,i) = VL(0,maxR); VL(1,i) = VL(1,maxR); VL(2,i) = VL(2,maxR);
- VR(0,i) = VR(0,maxR); VR(1,i) = VR(1,maxR); VR(2,i) = VR(2,maxR);
-
- DR(maxR) = tmp[0]; DI(maxR) = tmp[1];
- VL(0,maxR) = tmp[2]; VL(1,maxR) = tmp[3]; VL(2,maxR) = tmp[4];
- VR(0,maxR) = tmp[5]; VR(1,maxR) = tmp[6]; VR(2,maxR) = tmp[7];
- }
- }
- }
- return true;
- }
- if(info > 0)
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "QR Algorithm failed to compute all the eigenvalues (info = %d)", info);
- else
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Wrong %d-th argument in eig (info = %d)", -info);
-
- return false;
- }
-
-#endif
-}
diff --git a/Common/MAdMatrix.h b/Common/MAdMatrix.h
deleted file mode 100644
index d7f4c70..0000000
--- a/Common/MAdMatrix.h
+++ /dev/null
@@ -1,923 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MATRIX_MAD
-#define _H_MATRIX_MAD
-
-#include "MAdMessage.h"
-
-#include <assert.h>
-#include <math.h>
-#include <iostream>
-
-#if defined(_HAVE_GSL_)
-#include <gsl/gsl_linalg.h>
-#include <gsl/gsl_matrix.h>
-#include <gsl/gsl_vector.h>
-#include <gsl/gsl_blas.h>
-#endif
-
-// -------------------------------------------------------------------
-#if defined(HAVE_BLAS)
-extern "C" {
- void dgemm_(const char *transa, const char *transb, int *m, int *n, int *k,
- double *alpha, double *a, int *lda, double *b, int *ldb,
- double *beta, double *c, int *ldc);
- void dgemv_(const char *trans, int *m, int *n, double *alpha, double *a,
- int *lda, double *x, int *incx, double *beta, double *y, int *incy);
-}
-#endif
-
-// -------------------------------------------------------------------
-#if defined(HAVE_LAPACK)
-extern "C" {
- void dgesv_(int *N, int *nrhs, double *A, int *lda, int *ipiv,
- double *b, int *ldb, int *info);
- void dgetrf_(int *M, int *N, double *A, int *lda, int *ipiv, int *info);
- void dgesvd_(const char* jobu, const char *jobvt, int *M, int *N,
- double *A, int *lda, double *S, double* U, int *ldu,
- double *VT, int *ldvt, double *work, int *lwork, int *info);
- void dgeev_(const char *jobvl, const char *jobvr,
- int *n, double *a, int *lda,
- double *wr, double *wi,
- double *vl, int *ldvl,
- double *vr, int *ldvr,
- double *work, int *lwork,
- int *info);
-}
-#endif
-
-// -------------------------------------------------------------------
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- // Basic vector / matrix
- // -------------------------------------------------------------------
- template <class SCALAR>
- class MAd_Vector
- {
- private:
- int r;
- public:
- inline int size() const { return r; }
- SCALAR *data;
- ~MAd_Vector() { if(data) delete [] data; }
- MAd_Vector() : r(0)
- {
- data = 0;
- }
- MAd_Vector(int R) : r(R)
- {
- data = new SCALAR[r];
- scale(0);
- }
- MAd_Vector(const MAd_Vector<SCALAR> &other) : r(other.r)
- {
- data = new SCALAR[r];
- for (int i = 0; i < r; ++i) data[i] = other.data[i];
- }
- inline MAd_Vector<SCALAR> operator= (const MAd_Vector<SCALAR> &other)
- {
- if ( this != &other ) {
- r = other.r;
- if (data) delete [] data;
- data = new SCALAR[r];
- for (int i = 0; i < r; ++i) data[i] = other.data[i];
- }
- return *this;
- }
- inline SCALAR operator () (int i) const
- {
- return data[i];
- }
- inline SCALAR & operator () (int i)
- {
- return data[i];
- }
- inline double norm()
- {
- double n = 0.;
- for(int i = 0; i < r; ++i) n += data[i] * data[i];
- return sqrt(n);
- }
- inline void scale(const SCALAR s)
- {
- for (int i = 0; i < r; ++i) data[i] *= s;
- }
- inline void set_all(const double &m)
- {
- for (int i = 0; i < r; ++i) data[i] = m;
- }
- inline void add(const MAd_Vector &v)
- {
- for (int i = 0; i < r; ++i) data[i] += v(i);
- }
- void print(std::string name) const
- {
- printf("Vector %s:\n ",name.c_str());
- for (int i = 0; i < r; ++i) printf("%12.5E ",data[i]);
- printf("\n");
- }
- };
-
- // -------------------------------------------------------------------
- template <class SCALAR>
- class MAd_Matrix
- {
- private:
- int _r, _c; // r = nb rows, c = nb columns
- SCALAR *_data;
-
- public:
-
- MAd_Matrix(int R,int C) : _r(R), _c(C)
- {
- _data = new SCALAR[_r * _c];
- scale(0.);
- }
- MAd_Matrix(const MAd_Matrix<SCALAR> &other) : _r(other._r), _c(other._c)
- {
- _data = new double[_r * _c];
- memcpy(other);
- }
- MAd_Matrix() : _r(0), _c(0), _data(0) {}
- ~MAd_Matrix() { delete [] _data; }
-
- public:
-
- void print()const {
- printf("matrix(%d,%d)",_r,_c);
- for(int i=0;i<_r;i++){
- for(int j=0;j<_c;j++){
- printf("%0.3e\t",_data[i + _r * j]);
- }
- printf("\n");
- }
- printf("--------\n");
- }
-
- inline int size1() const { return _r; }
- inline int size2() const { return _c; }
-
- inline SCALAR operator () (int i, int j) const
- {
- return _data[i + _r * j];
- }
- inline SCALAR & operator () (int i, int j)
- {
- return _data[i + _r * j];
- }
-
- MAd_Matrix<SCALAR> & operator = (const MAd_Matrix<SCALAR> &other)
- {
- if(this != &other){
- _r = other._r;
- _c = other._c;
- _data = new SCALAR[_r * _c];
- memcpy(other);
- }
- return *this;
- }
- void memcpy(const MAd_Matrix &other)
- {
- for (int i = 0; i < _r * _c; ++i) _data[i] = other._data[i];
- }
-
- void copy(const MAd_Matrix<SCALAR> &a, int i0, int ni, int j0, int nj,
- int desti0, int destj0)
- {
- for(int i = i0, desti = desti0; i < i0 + ni; i++, desti++)
- for(int j = j0, destj = destj0; j < j0 + nj; j++, destj++)
- (*this)(desti, destj) = a(i, j);
- }
-
- // c = c + data * b
- inline void mult(const MAd_Matrix<SCALAR> &b, MAd_Matrix<SCALAR> &c)
- {
- c.scale(0.);
- for(int i = 0; i < _r; i++)
- for(int j = 0; j < b.size2(); j++)
- for(int k = 0; k < _c; k++)
- c._data[i + _r * j] += (*this)(i, k) * b(k, j);
- }
-
- // y = y + data * x
- inline void mult(const MAd_Vector<SCALAR> &x, MAd_Vector<SCALAR> &y)
- {
- y.scale(0.);
- for(int i = 0; i < _r; i++)
- for(int j = 0; j < _c; j++)
- y._data[i] += (*this)(i, j) * x(j);
- }
-
- // data = alpha * ( a * b ) + beta * data
- inline void blas_dgemm(MAd_Matrix<SCALAR> &a, MAd_Matrix<SCALAR> &b,
- SCALAR alpha=1., SCALAR beta=1.)
- {
- MAd_Matrix<SCALAR> temp(a.size1(), b.size2()); // temp = 0;
- a.mult(b, temp); // temp = a * b
- temp.scale(alpha); // temp = alpha * ( a * b )
- scale(beta);
- add(temp);
- }
-
- inline void set_all(const double &m)
- {
- for (int i = 0; i < _r * _c; ++i) _data[i] = m;
- }
- inline void setValues(const SCALAR *M[])
- {
- for (int i = 0; i < _r ; ++i)
- for (int j = 0; j < _c ; ++j) _data[i + _r * j] = M[i][j];
- }
- inline void scale(const double s)
- {
- if(s == 0.)
- for(int i = 0; i < _r * _c; ++i) _data[i] = 0.;
- else
- for(int i = 0; i < _r * _c; ++i) _data[i] *= s;
- }
- inline void add(const double &a)
- {
- for(int i = 0; i < _r * _c; ++i) _data[i] += a;
- }
- inline void add(const MAd_Matrix<SCALAR> &m)
- {
- for(int i = 0; i < size1(); i++)
- for(int j = 0; j < size2(); j++)
- (*this)(i, j) += m(i, j);
- }
-
- inline MAd_Matrix<SCALAR> transpose()
- {
- MAd_Matrix<SCALAR> T(size2(), size1());
- for(int i = 0; i < size1(); i++)
- for(int j = 0; j < size2(); j++)
- T(j, i) = (*this)(i, j);
- return T;
- }
- inline bool lu_solve(const MAd_Vector<SCALAR> &rhs, MAd_Vector<SCALAR> &result)
- {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"LU factorization requires LAPACK");
- return false;
- }
- MAd_Matrix<SCALAR> cofactor(int i, int j) const
- {
- int ni = size1();
- int nj = size2();
- MAd_Matrix<SCALAR> cof(ni - 1, nj - 1);
- for(int I = 0; I < ni; I++){
- for(int J = 0; J < nj; J++){
- if(J != j && I != i)
- cof(I < i ? I : I - 1, J < j ? J : J - 1) = (*this)(I, J);
- }
- }
- return cof;
- }
- SCALAR determinant() const
- {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Determinant computation requires LAPACK");
- return 0.;
- }
- bool svd(MAd_Matrix<SCALAR> &V, MAd_Vector<SCALAR> &S)
- {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Singular value decomposition requires LAPACK");
- return false;
- }
- bool eig(MAd_Matrix<double> &VL, // left eigenvectors
- MAd_Vector<double> &DR, // Real part of eigenvalues
- MAd_Vector<double> &DI, // Im part of eigenvalues
- MAd_Matrix<double> &VR,
- bool sortRealPart=false )
- {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Eigen vectors computation requires LAPACK");
- return false;
- }
- void print(std::string name) const
- {
- printf("Matrix %s (%d, %d):\n ",name.c_str(),_r,_c);
- for(int i = 0; i < _r ; ++i) {
- for(int j = 0; j < _c ; ++j) printf("%12.5E ",(*this)(i, j));
- printf("\n");
- }
- }
- };
-
-
-// -------------------------------------------------------------------
-// With BLAS / LAPACK
-// -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- template <class SCALAR>
- class MAd_BLASLAPACK_Vector
- {
- private:
- int r;
- public:
- inline int size() const { return r; }
- SCALAR *data;
- ~MAd_BLASLAPACK_Vector() { delete [] data; }
- MAd_BLASLAPACK_Vector() : r(0)
- {
- data = 0;
- }
- MAd_BLASLAPACK_Vector(int R) : r(R)
- {
- data = new SCALAR[r];
- scale(0);
- }
- MAd_BLASLAPACK_Vector(const MAd_BLASLAPACK_Vector<SCALAR> &other) : r(other.r)
- {
- data = new double[r];
- for (int i = 0; i < r; ++i) data[i] = other.data[i];
- }
- inline SCALAR operator () (int i) const
- {
- return data[i];
- }
- inline SCALAR & operator () (int i)
- {
- return data[i];
- }
- inline double norm()
- {
- double n = 0.;
- for(int i = 0; i < r; ++i) n += data[i] * data[i];
- return sqrt(n);
- }
- inline void scale(const SCALAR s)
- {
- for (int i = 0; i < r; ++i) data[i] *= s;
- }
- inline void set_all(const double &m)
- {
- for (int i = 0; i < r; ++i) data[i] = m;
- }
- inline void add(const MAd_BLASLAPACK_Vector &v)
- {
- for (int i = 0; i < r; ++i) data[i] += v(i);
- }
- void print(std::string name) const
- {
- printf("Vector %s:\n ",name.c_str());
- for (int i = 0; i < r; ++i) printf("%12.5E ",data[i]);
- printf("\n");
- }
- };
-
- // -------------------------------------------------------------------
- template <class SCALAR>
- class MAd_BLASLAPACK_Matrix
- {
- private:
- int _r, _c; // r = nb rows, c = nb columns
- SCALAR *_data;
-
- public:
-
- MAd_BLASLAPACK_Matrix(int R,int C) : _r(R), _c(C)
- {
- _data = new SCALAR[_r * _c];
- scale(0.);
- }
- MAd_BLASLAPACK_Matrix(const MAd_BLASLAPACK_Matrix<SCALAR> &other) : _r(other._r), _c(other._c)
- {
- _data = new double[_r * _c];
- memcpy(other);
- }
- MAd_BLASLAPACK_Matrix() : _r(0), _c(0), _data(0) {}
- ~MAd_BLASLAPACK_Matrix() { delete [] _data; }
-
- public:
-
- inline int size1() const { return _r; }
- inline int size2() const { return _c; }
-
- inline SCALAR operator () (int i, int j) const
- {
- return _data[i + _r * j];
- }
- inline SCALAR & operator () (int i, int j)
- {
- return _data[i + _r * j];
- }
-
- MAd_BLASLAPACK_Matrix<SCALAR> & operator = (const MAd_BLASLAPACK_Matrix<SCALAR> &other)
- {
- if(this != &other){
- _r = other._r;
- _c = other._c;
- _data = new SCALAR[_r * _c];
- memcpy(other);
- }
- return *this;
- }
- void memcpy(const MAd_BLASLAPACK_Matrix &other)
- {
- for (int i = 0; i < _r * _c; ++i) _data[i] = other._data[i];
- }
-
- void copy(const MAd_BLASLAPACK_Matrix<SCALAR> &a, int i0, int ni, int j0, int nj,
- int desti0, int destj0)
- {
- for(int i = i0, desti = desti0; i < i0 + ni; i++, desti++)
- for(int j = j0, destj = destj0; j < j0 + nj; j++, destj++)
- (*this)(desti, destj) = a(i, j);
- }
-
- // c = c + data * b
- inline void mult(const MAd_BLASLAPACK_Matrix<SCALAR> &b, MAd_BLASLAPACK_Matrix<SCALAR> &c)
- {
-#if defined(HAVE_BLAS)
- int M = c.size1(), N = c.size2(), K = _c;
- int LDA = _r, LDB = b.size1(), LDC = c.size1();
- double alpha = 1., beta = 0.;
- dgemm_("N", "N", &M, &N, &K, &alpha, _data, &LDA, b._data, &LDB,
- &beta, c._data, &LDC);
-#else
- c.scale(0.);
- for(int i = 0; i < _r; i++)
- for(int j = 0; j < b.size2(); j++)
- for(int k = 0; k < _c; k++)
- c._data[i + _r * j] += (*this)(i, k) * b(k, j);
-#endif
- }
-
- // y = y + data * x
- inline void mult(const MAd_BLASLAPACK_Vector<SCALAR> &x, MAd_BLASLAPACK_Vector<SCALAR> &y)
- {
-#if defined(HAVE_BLAS)
- int M = _r, N = _c, LDA = _r, INCX = 1, INCY = 1;
- double alpha = 1., beta = 0.;
- dgemv_("N", &M, &N, &alpha, _data, &LDA, x._data, &INCX,
- &beta, y._data, &INCY);
-#else
- y.scale(0.);
- for(int i = 0; i < _r; i++)
- for(int j = 0; j < _c; j++)
- y._data[i] += (*this)(i, j) * x(j);
-#endif
- }
-
- // data = alpha * ( a * b ) + beta * data
- inline void blas_dgemm(MAd_BLASLAPACK_Matrix<SCALAR> &a, MAd_BLASLAPACK_Matrix<SCALAR> &b,
- SCALAR alpha=1., SCALAR beta=1.)
- {
-#if defined(HAVE_BLAS)
- int M = size1(), N = size2(), K = a.size2();
- int LDA = a.size1(), LDB = b.size1(), LDC = size1();
- dgemm_("N", "N", &M, &N, &K, &alpha, a._data, &LDA, b._data, &LDB,
- &beta, _data, &LDC);
-#else
- MAd_BLASLAPACK_Matrix<SCALAR> temp(a.size1(), b.size2()); // temp = 0;
- a.mult(b, temp); // temp = a * b
- temp.scale(alpha); // temp = alpha * ( a * b )
- scale(beta);
- add(temp);
-#endif
- }
-
- inline void set_all(const double &m)
- {
- for (int i = 0; i < _r * _c; ++i) _data[i] = m;
- }
- inline void setValues(const SCALAR *M[])
- {
- for (int i = 0; i < _r ; ++i)
- for (int j = 0; j < _c ; ++j) _data[i + _r * j] = M[i][j];
- }
- inline void scale(const double s)
- {
- if(s == 0.)
- for(int i = 0; i < _r * _c; ++i) _data[i] = 0.;
- else
- for(int i = 0; i < _r * _c; ++i) _data[i] *= s;
- }
- inline void add(const double &a)
- {
- for(int i = 0; i < _r * _c; ++i) _data[i] += a;
- }
- inline void add(const MAd_BLASLAPACK_Matrix<SCALAR> &m)
- {
- for(int i = 0; i < size1(); i++)
- for(int j = 0; j < size2(); j++)
- (*this)(i, j) += m(i, j);
- }
-
- inline MAd_BLASLAPACK_Matrix<SCALAR> transpose()
- {
- MAd_BLASLAPACK_Matrix<SCALAR> T(size2(), size1());
- for(int i = 0; i < size1(); i++)
- for(int j = 0; j < size2(); j++)
- T(j, i) = (*this)(i, j);
- return T;
- }
- inline bool lu_solve(const MAd_BLASLAPACK_Vector<SCALAR> &rhs, MAd_BLASLAPACK_Vector<SCALAR> &result)
- {
-#if defined(HAVE_LAPACK)
- int N = size1(), nrhs = 1, lda = N, ldb = N, info;
- int *ipiv = new int[N];
- for(int i = 0; i < N; i++) result(i) = rhs(i);
- dgesv_(&N, &nrhs, _data, &lda, ipiv, result._data, &ldb, &info);
- delete [] ipiv;
- if(info == 0) return true;
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Problem in LAPACK LU (info=%d)", info);
-#else
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"LU factorization requires LAPACK");
-#endif
- return false;
- }
- MAd_BLASLAPACK_Matrix<SCALAR> cofactor(int i, int j) const
- {
- int ni = size1();
- int nj = size2();
- MAd_BLASLAPACK_Matrix<SCALAR> cof(ni - 1, nj - 1);
- for(int I = 0; I < ni; I++){
- for(int J = 0; J < nj; J++){
- if(J != j && I != i)
- cof(I < i ? I : I - 1, J < j ? J : J - 1) = (*this)(I, J);
- }
- }
- return cof;
- }
- SCALAR determinant() const
- {
-#if defined(HAVE_LAPACK)
- MAd_BLASLAPACK_Matrix<SCALAR> tmp(*this);
- int M = size1(), N = size2(), lda = size1(), info;
- int *ipiv = new int[std::min(M, N)];
- dgetrf_(&M, &N, tmp._data, &lda, ipiv, &info);
- SCALAR det = 1.;
- for(int i = 0; i < size1(); i++){
- det *= tmp(i, i);
- if(ipiv[i] != i + 1) det = -det;
- }
- return det;
-#else
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Determinant computation requires LAPACK");
- return 0.;
-#endif
- }
- bool svd(MAd_BLASLAPACK_Matrix<SCALAR> &V, MAd_BLASLAPACK_Vector<SCALAR> &S)
- {
-#if defined(HAVE_LAPACK)
- MAd_BLASLAPACK_Matrix<SCALAR> VT(V.size2(), V.size1());
- int M = size1(), N = size2(), LDA = size1(), LDVT = VT.size1(), info;
- int LWORK = std::max(3 * std::min(M, N) + std::max(M, N), 5 * std::min(M, N));
- MAd_BLASLAPACK_Vector<SCALAR> WORK(LWORK);
- dgesvd_("O", "A", &M, &N, _data, &LDA, S._data, _data, &LDA,
- VT._data, &LDVT, WORK._data, &LWORK, &info);
- V = VT.transpose();
- if(info == 0) return true;
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Problem in LAPACK SVD (info=%d)", info);
-#else
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Singular value decomposition requires LAPACK");
-#endif
- return false;
- }
- bool eig(MAd_BLASLAPACK_Matrix<double> &VL, // left eigenvectors
- MAd_BLASLAPACK_Vector<double> &DR, // Real part of eigenvalues
- MAd_BLASLAPACK_Vector<double> &DI, // Im part of eigenvalues
- MAd_BLASLAPACK_Matrix<double> &VR,
- bool sortRealPart=false ) // if true: sorted from max '|DR|' to min '|DR|'
-#if defined(HAVE_LAPACK)
- ;
-#else
- {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Eigen vectors computation requires LAPACK");
- return false;
- }
-#endif
- void print(std::string name) const
- {
- printf("Matrix %s (%d, %d):\n ",name.c_str(),_r,_c);
- for(int i = 0; i < _r ; ++i) {
- for(int j = 0; j < _c ; ++j) printf("%12.5E ",(*this)(i, j));
- printf("\n");
- }
- }
- };
-
-// -------------------------------------------------------------------
-// With GSL
-// -------------------------------------------------------------------
-#ifdef _HAVE_GSL_
-
- class MAd_GSL_Vector
- {
- private:
- int _r;
- gsl_vector *_data;
- friend class MAd_GSL_Matrix;
-
- public:
-
- MAd_GSL_Vector(int r) : _r(r)
- {
- _data = gsl_vector_calloc(_r);
- }
- MAd_GSL_Vector(const MAd_GSL_Vector &other) : _r(other._r)
- {
- _data = gsl_vector_calloc(_r);
- gsl_vector_memcpy(_data, other._data);
- }
- ~MAd_GSL_Vector() { gsl_vector_free(_data); }
-
- inline int size() const { return _r; }
-
- inline double operator () (int i) const
- {
- return gsl_vector_get(_data, i);
- }
- inline double & operator () (int i)
- {
- return *gsl_vector_ptr(_data, i);
- }
- inline double norm()
- {
- return gsl_blas_dnrm2(_data);
- }
- inline void scale(const double s)
- {
- if(s == 0.) gsl_vector_set_zero(_data);
- else gsl_vector_scale(_data, s);
- }
- inline void set_all(const double &m)
- {
- gsl_vector_set_all(_data, m);
- }
- inline void add(const MAd_GSL_Vector &v)
- {
- gsl_vector_add (_data, v._data);
- }
- void print(std::string name) const
- {
- printf("Vector %s:\n ",name.c_str());
- for (int i = 0; i < r; ++i) printf("%12.5E ",data[i]);
- printf("\n");
- }
- };
-
- // -------------------------------------------------------------------
- class MAd_GSL_Matrix
- {
- private:
- gsl_matrix *_data;
-
- public:
- MAd_GSL_Matrix(int r, int c) { _data = gsl_matrix_calloc(r, c); }
- MAd_GSL_Matrix(const MAd_GSL_Matrix &other) : _data(0)
- {
- if(_data) gsl_matrix_free(_data);
- _data = gsl_matrix_calloc(other._data->size1, other._data->size2);
- gsl_matrix_memcpy(_data, other._data);
- }
- MAd_GSL_Matrix() : _data(0) {}
- ~MAd_GSL_Matrix() { if(_data && _data->owner == 1) gsl_matrix_free(_data); }
-
- public:
- inline int size1() const { return _data->size1; }
- inline int size2() const { return _data->size2; }
- MAd_GSL_Matrix & operator = (const MAd_GSL_Matrix &other)
- {
- if(&other != this){
- if(_data) gsl_matrix_free(_data);
- _data = gsl_matrix_calloc(other._data->size1, other._data->size2);
- gsl_matrix_memcpy(_data, other._data);
- }
- return *this;
- }
- void memcpy(const MAd_GSL_Matrix &other)
- {
- gsl_matrix_memcpy(_data, other._data);
- }
- inline double operator () (int i, int j) const
- {
- return gsl_matrix_get(_data, i, j);
- }
- inline double & operator () (int i, int j)
- {
- return *gsl_matrix_ptr(_data, i, j);
- }
- void copy(const MAd_GSL_Matrix &a, int i0, int ni, int j0, int nj,
- int desti0, int destj0)
- {
- for(int i = i0, desti = desti0; i < i0 + ni; i++, desti++)
- for(int j = j0, destj = destj0; j < j0 + nj; j++, destj++)
- (*this)(desti, destj) = a(i, j);
- }
- inline void mult(const MAd_GSL_Matrix &b, MAd_GSL_Matrix &c)
- {
- gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1., _data, b._data, 0., c._data);
- }
- inline void mult(const MAd_GSL_Vector &x, MAd_GSL_Vector &y)
- {
- gsl_blas_dgemv(CblasNoTrans, 1., _data, x._data, 0., y._data);
- }
- inline void blas_dgemm(MAd_GSL_Matrix &a, MAd_GSL_Matrix &b,
- double alpha=1., double beta=1.)
- {
- gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, alpha, a._data, b._data, beta, _data);
- }
- inline void set_all(const double &m)
- {
- gsl_matrix_set_all(_data, m);
- }
- inline void setValues(const double *M[])
- {
- for (int i = 0; i < size1() ; ++i)
- for (int j = 0; j < size2() ; ++j) *gsl_matrix_ptr(_data, i, j) = M[i][j];
- }
- inline void scale(const double s)
- {
- if(s == 0.) gsl_matrix_set_zero(_data);
- else gsl_matrix_scale(_data, s);
- }
- inline void add(const double &a)
- {
- gsl_matrix_add_constant(_data, a);
- }
- inline void add(const MAd_GSL_Matrix &m)
- {
- gsl_matrix_add(_data, m._data);
- }
- inline MAd_GSL_Matrix transpose()
- {
- MAd_GSL_Matrix T(size2(), size1());
- for(int i = 0; i < size1(); i++)
- for(int j = 0; j < size2(); j++)
- T(j, i) = (*this)(i, j);
- return T;
- }
- inline bool lu_solve(const MAd_GSL_Vector &rhs, MAd_GSL_Vector &result)
- {
- int s;
- gsl_permutation *p = gsl_permutation_alloc(size1());
- gsl_linalg_LU_decomp(_data, p, &s);
- gsl_linalg_LU_solve(_data, p, rhs._data, result._data);
- gsl_permutation_free(p);
- return true;
- }
- MAd_GSL_Matrix cofactor(int i, int j) const
- {
- int ni = size1();
- int nj = size2();
- MAd_GSL_Matrix cof(ni - 1, nj - 1);
- for(int I = 0; I < ni; I++){
- for(int J = 0; J < nj; J++){
- if(J != j && I != i)
- cof(I < i ? I : I - 1, J < j ? J : J - 1) = (*this)(I, J);
- }
- }
- return cof;
- }
- double determinant() const
- {
- MAd_GSL_Matrix tmp = *this;
- gsl_permutation *p = gsl_permutation_alloc(size1());
- int s;
- gsl_linalg_LU_decomp(tmp._data, p, &s);
- gsl_permutation_free(p);
- return gsl_linalg_LU_det(tmp._data, s);
- }
- bool svd(MAd_GSL_Matrix &V, MAd_GSL_Vector &S)
- {
- MAd_GSL_Vector tmp(S.size());
- gsl_linalg_SV_decomp(_data, V._data, S._data, tmp._data);
- return true;
- }
- inline void invert ()
- {
- int s;
- gsl_permutation *p = gsl_permutation_alloc (size1());
- gsl_linalg_LU_decomp(_data, p, &s);
- gsl_matrix *data_inv = gsl_matrix_calloc(size1(), size2());
- gsl_linalg_LU_invert(_data, p, data_inv) ;
- gsl_matrix_memcpy(_data, data_inv);
- gsl_matrix_free(data_inv);
- gsl_permutation_free(p);
- }
- inline bool invertSecure(double &det)
- {
- int s;
- gsl_permutation *p = gsl_permutation_alloc (size1());
- gsl_linalg_LU_decomp(_data, p, &s);
- det = gsl_linalg_LU_det(_data, s);
- gsl_matrix *data_inv = gsl_matrix_calloc(size1(), size2());
- gsl_linalg_LU_invert(_data, p, data_inv);
- gsl_matrix_memcpy(_data, data_inv);
- gsl_matrix_free(data_inv);
- gsl_permutation_free(p);
- return (det != 0.);
- }
- bool eig(MAd_GSL_Matrix &VL, // left eigenvectors
- MAd_GSL_Vector &DR, // Real part of eigenvalues
- MAd_GSL_Vector &DI, // Im part of eigenvalues
- MAd_GSL_Matrix &VR,
- bool sortRealPart=false )
- {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,"Eigen vectors computation requires LAPACK");
- return false;
- }
- void print(std::string name) const
- {
- printf("Matrix %s (%d, %d):\n ",name.c_str(),_r,_c);
- for(int i = 0; i < _r ; ++i) {
- for(int j = 0; j < _c ; ++j) printf("%12.5E ",(*this)(i, j));
- printf("\n");
- }
- }
- };
-
-#endif
-
- // -------------------------------------------------------------------
- // -------------------------------------------------------------------
-
-#if defined(HAVE_LAPACK)
- typedef MAd_BLASLAPACK_Matrix<double> doubleMatrix;
- typedef MAd_BLASLAPACK_Vector<double> doubleVector;
-#else
- #if defined(_HAVE_GSL_)
- typedef MAd_GSL_Matrix doubleMatrix;
- typedef MAd_GSL_Vector doubleVector;
- #else
- typedef MAd_Matrix<double> doubleMatrix;
- typedef MAd_Vector<double> doubleVector;
- #endif
-#endif
-
- // -------------------------------------------------------------------
-
- // Should be used for operations on small matrices
- typedef MAd_Matrix<double> smallMatrix;
- typedef MAd_Vector<double> smallVector;
-
- // -------------------------------------------------------------------
-
-}
-
-// -------------------------------------------------------------------
-// Gmsh matrices
-// -------------------------------------------------------------------
-
-#ifdef _HAVE_GMSH_
-
-#include "gmsh/GmshMatrix.h"
-namespace MAd {
- typedef gmshMatrix<double> gmshMat;
- typedef gmshVector<double> gmshVec;
-}
-
-#else
-
-namespace MAd {
-
- class nullVector {
- public:
- nullVector() {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Not implemented, Gmsh required");
- }
- nullVector(double) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Not implemented, Gmsh required");
- }
- inline double operator () (int i) const { return -1.; }
- void print(const char * name="") const {}
- };
- class nullMatrix {
- public:
- nullMatrix() {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Not implemented, Gmsh required");
- }
- nullMatrix(double, double) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Not implemented, Gmsh required");
- }
- inline double operator () (int i, int j) const { return -1.; }
- void print(const char * name="") const {}
- };
-
- typedef nullMatrix gmshMat;
- typedef nullVector gmshVec;
-}
-
-#endif
-
- // -------------------------------------------------------------------
-
-#endif
diff --git a/Common/MAdMessage.cc b/Common/MAdMessage.cc
deleted file mode 100644
index ee81ca5..0000000
--- a/Common/MAdMessage.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MAdMessage.h"
-
-#include <cstdarg>
-#include <iostream>
-#include <sstream>
-#include <stdlib.h>
-
-using std::stringstream;
-using std::string;
-using std::ostream;
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- MAdMsg::MAdMsg()
- {
- outStream = &std::cout;
- errStream = &std::cerr;
- }
-
- // -------------------------------------------------------------------
- void MAdMsg::initialize()
- {
- }
-
- // -------------------------------------------------------------------
- void MAdMsg::finalize()
- {
- }
-
- // -------------------------------------------------------------------
- void MAdMsg::registerAbortFct(AbortFunction fct, void * data)
- {
- abortFcts.push_back(std::make_pair(fct,data));
- }
-
- // -------------------------------------------------------------------
- void MAdMsg::info(int line,
- const char* file,
- const char* fmt,...) const
- {
- char buff[1024];
- va_list args;
- va_start (args, fmt);
- vsprintf(buff, fmt, args);
- va_end (args);
-
- if ( line >= 0 ) {
- *outStream << "Info: " << buff << writePosition(line,file) << "" << std::endl;
- }
- else {
- *outStream << "Info: " << buff << std::endl;
- }
- }
-
- // -------------------------------------------------------------------
- void MAdMsg::warning(int line,
- const char* file,
- const char* fmt,...) const
- {
- char buff[1024];
- va_list args;
- va_start (args, fmt);
- vsprintf(buff, fmt, args);
- va_end (args);
-
- *outStream << "WARNING: " << buff << writePosition(line,file) << "" << std::endl;
- }
-
- // -------------------------------------------------------------------
- void MAdMsg::error(int line,
- const char* file,
- const char* fmt,...) const
- {
- char buff[1024];
- va_list args;
- va_start (args, fmt);
- vsprintf(buff, fmt, args);
- va_end (args);
-
- *outStream << "ERROR: " << buff << writePosition(line,file) << "" << std::endl;
-
- // call abort functions
- std::list<std::pair<AbortFunction,void*> >::const_iterator iter = abortFcts.begin();
- for (; iter != abortFcts.end(); iter++) {
- AbortFunction fct = (*iter).first;
- void * data = (*iter).second;
- fct(data);
- }
-
- abort();
- }
-
- // -------------------------------------------------------------------
- string MAdMsg::writePosition(int line, const char* file) const
- {
- stringstream ss;
- string iStr; ss << line; ss >> iStr;
- return " (line " + iStr + " in file \'" + file + "\')";
- }
-
- // -------------------------------------------------------------------
-
-}
diff --git a/Common/MAdMessage.h b/Common/MAdMessage.h
deleted file mode 100644
index 89c931f..0000000
--- a/Common/MAdMessage.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MESSAGE_MAD_
-#define _H_MESSAGE_MAD_
-
-#include "MAdSingleton.h"
-
-#include <ostream>
-#include <list>
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- // abort function
- typedef void (*AbortFunction)(void *);
-
- // -------------------------------------------------------------------
- class MAdMsg {
-
- public:
-
- MAdMsg();
- ~MAdMsg() {}
-
- void initialize();
- void finalize();
-
- void registerAbortFct(AbortFunction, void *);
-
- void info (int, const char*, const char*,...) const;
- void warning(int, const char*, const char*,...) const;
- void error (int, const char*, const char*,...) const;
-
- private:
-
- std::string writePosition(int, const char*) const;
-
- private:
-
- std::ostream* outStream;
- std::ostream* errStream;
-
- std::list<std::pair<AbortFunction,void*> > abortFcts;
-
- };
-
- // -------------------------------------------------------------------
-
- typedef MAdSingleton<MAdMsg> MAdMsgSgl;
-
-}
-
-#endif
diff --git a/Common/MAdMetric.cc b/Common/MAdMetric.cc
deleted file mode 100644
index 416dfb3..0000000
--- a/Common/MAdMetric.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MAdMetric.h"
-
-namespace MAd {
-
- MAdMetric::MAdMetric(const double l1, // (h_1)^-2
- const double l2,
- const double l3,
- const double t1[3],
- const double t2[3],
- const double t3[3])
- {
- // M = e^1 * diag * e^1^t
- // where the elements of diag are l_i = h_i^-2
- // and the rows of e are the UNIT and ORTHOGONAL directions
-
- double e[3][3];
- e[0][0] = t1[0]; e[0][1] = t1[1]; e[0][2] = t1[2];
- e[1][0] = t2[0]; e[1][1] = t2[1]; e[1][2] = t2[2];
- e[2][0] = t3[0]; e[2][1] = t3[1]; e[2][2] = t3[2];
- invertMat(e);
-
- double tmp[3][3];
- tmp[0][0] = l1 * e[0][0]; tmp[0][1] = l2 * e[0][1]; tmp[0][2] = l3 * e[0][2];
- tmp[1][0] = l1 * e[1][0]; tmp[1][1] = l2 * e[1][1]; tmp[1][2] = l3 * e[1][2];
- tmp[2][0] = l1 * e[2][0]; tmp[2][1] = l2 * e[2][1]; tmp[2][2] = l3 * e[2][2];
-
- transpose(e);
-
- _val[0] = tmp[0][0] * e[0][0] + tmp[0][1] * e[1][0] + tmp[0][2] * e[2][0];
- _val[1] = tmp[1][0] * e[0][0] + tmp[1][1] * e[1][0] + tmp[1][2] * e[2][0];
- _val[2] = tmp[1][0] * e[0][1] + tmp[1][1] * e[1][1] + tmp[1][2] * e[2][1];
- _val[3] = tmp[2][0] * e[0][0] + tmp[2][1] * e[1][0] + tmp[2][2] * e[2][0];
- _val[4] = tmp[2][0] * e[0][1] + tmp[2][1] * e[1][1] + tmp[2][2] * e[2][1];
- _val[5] = tmp[2][0] * e[0][2] + tmp[2][1] * e[1][2] + tmp[2][2] * e[2][2];
- }
-// MAdMetric(const double l1, // (h_1)^-2
-// const double l2,
-// const double l3,
-// const double t1[3],
-// const double t2[3],
-// const double t3[3]){
-// double t1b[3], t2b[3], t3b[3];
-// t1b[0] = t1[0] * l1; t2b[0] = t2[0] * l1; t3b[0] = t3[0] * l1;
-// t1b[1] = t1[1] * l2; t2b[1] = t2[1] * l2; t3b[1] = t3[1] * l2;
-// t1b[2] = t1[2] * l3; t2b[2] = t2[2] * l3; t3b[2] = t3[2] * l3;
-// _val[0] = dotProd (t1b,t1);
-// _val[1] = dotProd (t2b,t1);
-// _val[2] = dotProd (t2b,t2);
-// _val[3] = dotProd (t3b,t1);
-// _val[4] = dotProd (t3b,t2);
-// _val[5] = dotProd (t3b,t3);
-// }
-
- void MAdMetric::print (const char *s) const
- {
- printf(" metric %s : %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E \n",s,
- (*this)(0,0),(*this)(1,1),(*this)(2,2),
- (*this)(0,1),(*this)(0,2),(*this)(1,2));
- }
-
-
- MAdMetric intersection (const MAdMetric &m1, const MAdMetric &m2)
- {
- MAdMetric im1 = m1.invert();
- doubleMatrix V(3,3);
- doubleVector S(3);
- im1 *= m2;
- im1.eig(V,S,true);
- double v0[3]; v0[0] = V(0,0); v0[1] = V(1,0); v0[2] = V(2,0);
- double v1[3]; v1[0] = V(0,1); v1[1] = V(1,1); v1[2] = V(2,1);
- double v2[3]; v2[0] = V(0,2); v2[1] = V(1,2); v2[2] = V(2,2);
- double l0 = std::max(dot(v0,m1,v0),dot(v0,m2,v0));
- double l1 = std::max(dot(v1,m1,v1),dot(v1,m2,v1));
- double l2 = std::max(dot(v2,m1,v2),dot(v2,m2,v2));
- MAdMetric iv(l0,l1,l2,v0,v1,v2);
- return iv;
- }
-
- // (1-t) * m1 + t * m2
- MAdMetric interpolation (const MAdMetric &m1,
- const MAdMetric &m2,
- const double t)
- {
- MAdMetric im1 = m1.invert();
- MAdMetric im2 = m2.invert();
- im1 *= (1.-t);
- im2 *= t;
- im1 += im2;
- return im1.invert();
- }
-
- MAdMetric interpolation (const MAdMetric &m1,
- const MAdMetric &m2,
- const MAdMetric &m3,
- const double u,
- const double v)
- {
- MAdMetric im1 = m1.invert();
- MAdMetric im2 = m2.invert();
- MAdMetric im3 = m3.invert();
- im1 *= (1.-u-v);
- im2 *= u;
- im3 *= v;
- im1 += im2;
- im1 += im3;
- return im1.invert();
- }
-
- MAdMetric interpolation (const MAdMetric &m1,
- const MAdMetric &m2,
- const MAdMetric &m3,
- const MAdMetric &m4,
- const double u,
- const double v,
- const double w)
- {
- MAdMetric im1 = m1.invert();
- MAdMetric im2 = m2.invert();
- MAdMetric im3 = m3.invert();
- MAdMetric im4 = m4.invert();
- im1 *= (1.-u-v-w);
- im2 *= u;
- im3 *= v;
- im4 *= w;
- im1 += im2;
- im1 += im3;
- im1 += im4;
- return im1.invert();
- }
-
-}
diff --git a/Common/MAdMetric.h b/Common/MAdMetric.h
deleted file mode 100644
index 4160c3e..0000000
--- a/Common/MAdMetric.h
+++ /dev/null
@@ -1,151 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MADMETRIC
-#define _H_MADMETRIC
-
-#include "MAdMatrix.h"
-#include "MathUtils.h"
-
-namespace MAd {
-
- // class for symmetric positive definite 3x3 matrix
- class MAdMetric {
-
- protected:
- // lower diagonal storage
- // 00 10 11 20 21 22
- double _val[6];
-
- public:
-
- inline int getIndex(int i, int j) const{
- static int _index[3][3] = {{0,1,3},{1,2,4},{3,4,5}};
- return _index[i][j];
- }
- void getMat (doubleMatrix & mat) const{
- for (int i=0;i<3;i++){
- for (int j=0;j<3;j++){
- mat(i,j) = _val[getIndex(i,j)];
- }
- }
- }
- void getMat (double mat[3][3]) const{
- for (int i=0;i<3;i++){
- for (int j=0;j<3;j++){
- mat[i][j] = _val[getIndex(i,j)];
- }
- }
- }
- void setMat (const double mat[3][3]){
- for (int i=0;i<3;i++)
- for (int j=i;j<3;j++)
- _val[getIndex(i,j)] = mat[i][j];
- }
- MAdMetric(const MAdMetric& m){
- for (int i=0; i<6; i++) _val[i]=m._val[i];
- }
- // default constructor, identity
- MAdMetric(const double v = 1.0){
- _val[0] = _val[2] = _val[5] = v;
- _val[1] = _val[3] = _val[4] = 0.0;
- }
- MAdMetric(const double l1, // (h_1)^-2
- const double l2,
- const double l3,
- const double t1[3],
- const double t2[3],
- const double t3[3]);
- inline double &operator()(int i, int j){
- return _val[getIndex(i,j)];
- }
- inline double operator()(int i, int j) const{
- return _val[getIndex(i,j)];
- }
- MAdMetric invert () const {
- double m[3][3];
- getMat(m);
- invertMat(m);
- MAdMetric ithis;
- ithis.setMat(m);
- return ithis;
- }
- MAdMetric operator + (const MAdMetric &other) const {
- MAdMetric res(*this);
- for (int i=0;i<6;i++) res._val[i] += other._val[i];
- return res;
- }
- MAdMetric& operator += (const MAdMetric &other) {
- for (int i=0;i<6;i++) _val[i] += other._val[i];
- return *this;
- }
- MAdMetric& operator *= (const double &other) {
- for (int i=0;i<6;i++) _val[i] *= other;
- return *this;
- }
- MAdMetric& operator *= (const MAdMetric &other) {
- double m1[3][3], m2[3][3], m3[3][3];
- getMat(m1);
- other.getMat(m2);
- matMat(m1,m2,m3);
- setMat(m3);
- return *this;
- }
- MAdMetric transform (double V[3][3]){
- double m[3][3], result[3][3], temp[3][3];
- getMat(m);
- transpose(V);
- matMat(V,m,temp);
- matMat(temp,V,result);
- MAdMetric a; a.setMat(result);
- return a;
- }
- // s: true if eigenvalues are sorted (from max to min of the absolute value of the REAL part)
- void eig (doubleMatrix &V, doubleVector &S, bool s=false) const {
- doubleMatrix me(3,3),right(3,3);
- doubleVector im(3);
- getMat(me);
- me.eig(V,S,im,right,s);
- }
- void print(const char *) const;
- };
-
- // scalar product with respect to the metric
- inline double dot(const double a[3], const MAdMetric &m, const double b[3])
- { return
- b[0] * ( m(0,0) * a[0] + m(1,0) * a[1] + m(2,0) * a[2] ) +
- b[1] * ( m(0,1) * a[0] + m(1,1) * a[1] + m(2,1) * a[2] ) +
- b[2] * ( m(0,2) * a[0] + m(1,2) * a[1] + m(2,2) * a[2] ) ;}
-
- // compute the largest inscribed ellipsoid...
- MAdMetric intersection (const MAdMetric &m1,
- const MAdMetric &m2);
- MAdMetric interpolation (const MAdMetric &m1,
- const MAdMetric &m2,
- const double t);
- MAdMetric interpolation (const MAdMetric &m1,
- const MAdMetric &m2,
- const MAdMetric &m3,
- const double u,
- const double v);
- MAdMetric interpolation (const MAdMetric &m1,
- const MAdMetric &m2,
- const MAdMetric &m3,
- const MAdMetric &m4,
- const double u,
- const double v,
- const double w);
-
-}
-
-#endif
diff --git a/Common/MAdSingleton.h b/Common/MAdSingleton.h
deleted file mode 100644
index 4e37ec4..0000000
--- a/Common/MAdSingleton.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// -*- C++ -*-
-
-#ifndef MAD_H_MADSINGLETON
-#define MAD_H_MADSINGLETON
-
-template<typename T> class MAdSingleton
-{
- public:
-
- static T& instance()
- {
- static T theSingleInstance; // suppose T has a default constructor
- return theSingleInstance;
- }
-
- private:
- MAdSingleton();
-};
-
-#endif
diff --git a/Common/MAdStringFieldEvaluator.cc b/Common/MAdStringFieldEvaluator.cc
deleted file mode 100644
index 7a76953..0000000
--- a/Common/MAdStringFieldEvaluator.cc
+++ /dev/null
@@ -1,143 +0,0 @@
-// -------------------------------------------------------------------
-// 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifdef _HAVE_MATHEX_
-
-#include "MAdStringFieldEvaluator.h"
-
-#include <iostream>
-#include <iomanip>
-#include <stdlib.h>
-using std::list;
-using std::vector;
-using std::string;
-
-namespace MAd {
-
- // ----------------------------------------------------------------------
- MAdStringFieldEvaluator :: MAdStringFieldEvaluator (int numberOfStrings, ...):
- MAdFieldEvaluator()
- {
- vector<string> exp;
-
- va_list ap;
- va_start(ap,numberOfStrings);
- for (int i=0;i<numberOfStrings;i++){
- const char *s = va_arg(ap,const char *);
- string str = s;
- exp.push_back(str);
- }
- va_end(ap);
-
- buildEvaluators(exp);
- }
-
- // ----------------------------------------------------------------------
- MAdStringFieldEvaluator::MAdStringFieldEvaluator(const vector<string>& exp):
- MAdFieldEvaluator()
- {
- buildEvaluators(exp);
- }
-
- // ----------------------------------------------------------------------
- void MAdStringFieldEvaluator::buildEvaluators(const vector<string>& exp)
- {
- vector<string>::const_iterator eIter = exp.begin();
- for (;eIter!=exp.end();eIter++) {
-
- smlib::mathex * expr = new smlib::mathex();
- expr->addvar("x",&x);
- expr->addvar("y",&y);
- expr->addvar("z",&z);
- expr->addvar("t",&t);
-
- bool success = false;
- bool parsed = false;
- try {
- expr->expression(*eIter);
- expr->parse();
- parsed = true;
- success = true;
- }
- catch(smlib::mathex::error e) {
- std::cout << e.what() << std::endl;
- if(!parsed) {
- std::cout << *eIter << std::endl;
- std::cout << std::setw(expr->stopposition()) << "^" << std::endl;
- }
- }
- if ( !success ){
- std::cerr << "Error when parsing string field evaluator: possible symbols are exp, log, log10, sqrt, sin, cos, tan, sinh, cosh, tanh, asin, acos, atan, abs, round, floor, ceil, trunc, deg, fac, rad\n";
- exit(0);
- }
- expressions.push_back(expr);
- }
- }
-
- // ----------------------------------------------------------------------
- MAdStringFieldEvaluator::~MAdStringFieldEvaluator()
- {
- std::list<smlib::mathex*>::iterator it = expressions.begin();
- for (; it!=expressions.end(); ++it) {
- delete(*it);
- }
- }
-
- // ----------------------------------------------------------------------
- bool MAdStringFieldEvaluator::eval(const vector<double> space,
- double time,
- double * val) const
- {
- if (space.size() != 3) throw;
-
- double spaceTbl[3];
- for (int i=0; i<3; i++) spaceTbl[i] = space[i];
-
- return eval(spaceTbl, time, val);
- }
-
- // ----------------------------------------------------------------------
- bool MAdStringFieldEvaluator::eval(const double space[3],
- double time,
- double * val) const
- {
- x = space[0];
- y = space[1];
- z = space[2];
- t = time;
-
- int i = 0;
- std::list<smlib::mathex*>::const_iterator it = expressions.begin();
- for (; it!=expressions.end(); ++it) {
- val[i++] = (*it)->eval();
- }
-
- return true;
- }
-
- // ----------------------------------------------------------------------
- int MAdStringFieldEvaluator::nbVar() const
- {
- return expressions.size();
- }
-
- // ----------------------------------------------------------------------
- int MAdStringFieldEvaluator::order() const
- {
- return 3;
- }
-
- // ----------------------------------------------------------------------
-
-}
-
-#endif
diff --git a/Common/MAdStringFieldEvaluator.h b/Common/MAdStringFieldEvaluator.h
deleted file mode 100644
index d65e964..0000000
--- a/Common/MAdStringFieldEvaluator.h
+++ /dev/null
@@ -1,108 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MADSTRINGFIELDEVALUATOR
-#define _H_MADSTRINGFIELDEVALUATOR
-
-#include "MAdFieldEvaluator.h"
-
-#ifdef _HAVE_MATHEX_
-
-#include "mathex.h"
-
-#include <list>
-#include <cstdarg>
-#include <string>
-#include <vector>
-
-namespace MAd {
-
- // ----------------------------------------------------------------------
- class MAdStringFieldEvaluator : public MAdFieldEvaluator
- {
-
- public:
-
- ~MAdStringFieldEvaluator ();
- // int numberOfStrings is the number of "const char *" given in "..."
- MAdStringFieldEvaluator (int numberOfStrings, ...);
- MAdStringFieldEvaluator(const std::vector<std::string>&);
-
- private:
-
- void buildEvaluators(const std::vector<std::string>& exp);
-
- public:
-
- bool eval (const double space[3], double time, double * val) const ;
- bool eval (const std::vector<double> space, double time, double * val) const ;
-
- int nbVar() const;
- int order() const;
-
- private:
-
- mutable double x,y,z,t;
- std::list<smlib::mathex*> expressions;
-
- };
-
-}
-
-#else
-
-#include "MAdMessage.h"
-
-namespace MAd {
-
- // ----------------------------------------------------------------------
- class MAdStringFieldEvaluator : public MAdFieldEvaluator
- {
-
- public:
-
- ~MAdStringFieldEvaluator () {}
- MAdStringFieldEvaluator (int, ...)
- {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "No string evaluation library available");
- }
- MAdStringFieldEvaluator(const std::vector<std::string>&)
- {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "No string evaluation library available");
- }
-
- private:
-
- void buildEvaluators(const std::vector<std::string>&) { throw; }
-
- public:
-
- bool eval (const double space[3], double time, double * val) const
- { throw; return false; }
- bool eval (const std::vector<double> space, double time, double * val) const
- { throw; return false; }
-
- int nbVar() const { throw; return -1; }
- int order() const { throw; return -1; }
-
- };
-
- // ----------------------------------------------------------------------
-
-}
-
-#endif
-
-#endif
diff --git a/Common/MAdTime.h b/Common/MAdTime.h
deleted file mode 100644
index 6a70279..0000000
--- a/Common/MAdTime.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include <sys/time.h>
-
-#ifdef PARALLEL
-#include "mpi.h"
-#endif
-
-namespace MAd {
-
- // ----------------------------------------------------------------------
- double CPUTime() {
-
-#ifdef PARALLEL
- return MPI_Wtime();
-#else
- struct timeval tp;
- struct timezone tz;
-
- gettimeofday(&tp,&tz);
-
- return ((double) tp.tv_sec +
- (double) ((double) .000001 * (double) tp.tv_usec));
-#endif
- }
-
- // ----------------------------------------------------------------------
-
-}
-
diff --git a/Common/MAdVector3.h b/Common/MAdVector3.h
deleted file mode 100644
index b93120b..0000000
--- a/Common/MAdVector3.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// -*- C++ -*-
-
-#ifndef _H_MADVECTOR3
-#define _H_MADVECTOR3
-
-#ifdef _HAVE_GMSH_
-
-#include "gmsh/SVector3.h"
-namespace MAd {
- typedef SVector3 vec3;
-}
-
-#else
-
-#include "MAdMessage.h"
-
-namespace MAd {
-
- class MAdVector3
- {
- public:
- MAdVector3() {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Metric not implemented in MAdLib, Gmsh required");
- }
- MAdVector3(double x, double y, double z) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Metric not implemented in MAdLib, Gmsh required");
- }
- MAdVector3(double v) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Metric not implemented in MAdLib, Gmsh required");
- }
- MAdVector3(const double *array) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Metric not implemented in MAdLib, Gmsh required");
- }
- MAdVector3(const MAdVector3& v) {
- MAdMsgSgl::instance().error(__LINE__,__FILE__,
- "Metric not implemented in MAdLib, Gmsh required");
- }
- inline double x(void) const { return -1.; }
- inline double y(void) const { return -1.; }
- inline double z(void) const { return -1.; }
- inline double norm() { return -1.; }
- inline double normSq() { return -1.; }
- double normalize() { return -1.; }
- void negate() {}
- double &operator[](int i){ }
- double operator[](int i) const { return -1.; }
- double &operator()(int i){ }
- double operator()(int i) const { return -1.; }
- MAdVector3 & operator += (const MAdVector3 &a) { return *this; }
- MAdVector3 & operator -= (const MAdVector3 &a) { return *this; }
- MAdVector3 & operator *= (const MAdVector3 &a) { return *this; }
- MAdVector3 & operator *= (const double v) { return *this; }
- MAdVector3 & operator = (double v) { return *this; }
- operator double *() { return NULL; }
- void print(std::string name="") const {}
- };
-
- typedef MAdVector3 vec3;
-
- inline MAdVector3 crossprod(const MAdVector3 &a, const MAdVector3 &b)
- { return MAdVector3(); }
-
-}
-
-#endif
-
-#endif
diff --git a/Common/Makefile b/Common/Makefile
deleted file mode 100644
index a448057..0000000
--- a/Common/Makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-# -------------------------------------------------------------------
-# 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 at madlib.be>
-#
-# Authors: Gaetan Compere, Jean-Francois Remacle
-# -------------------------------------------------------------------
-
-include ../variables
-
-LIB = ../lib/libMAdCommon${LIBEXT}
-
-INC = ${MAdLib_INCLUDES}
-
-ALLFLAGS = ${OPTIM} ${CXXFLAGS} ${MAdLib_DEFS} ${FLAGS} ${INC} ${SYSINCLUDE}
-
-SRC = MathUtils.cc\
- MAdStringFieldEvaluator.cc\
- MAdMessage.cc\
- MAdMatrix.cc\
- MAdMetric.cc\
- MAdLib.cc
-
-OBJ = ${SRC:.cc=${OBJEXT}}
-
-.SUFFIXES: ${OBJEXT} .cc
-
-${LIB}: ${OBJ}
- ${AR} ${ARFLAGS} ${LIB} ${OBJ}
- ${RANLIB} ${LIB}
-
-cpobj: ${OBJ}
- cp -f ${OBJ} ${MAdLib_TMPDIR}/.
-
-.cc${OBJEXT}:
- ${CXX} ${ALLFLAGS} ${DASH}c $< ${DASH}o $@
-
-clean:
- ${RM} */*.o *.o *.obj
-
-purge:
-
-depend:
- (sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
- ${CXX} -MM ${ALLFLAGS} ${SRC} | sed 's/.o:/$${OBJEXT}:/g' \
- ) > Makefile.new
- cp Makefile Makefile.bak
- cp Makefile.new Makefile
- rm -f Makefile.new
\ No newline at end of file
diff --git a/Common/MathUtils.cc b/Common/MathUtils.cc
deleted file mode 100644
index 368d912..0000000
--- a/Common/MathUtils.cc
+++ /dev/null
@@ -1,464 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#include "MathUtils.h"
-#include "MAdMessage.h"
-#include "MAdDefines.h"
-
-#include <stdio.h>
-#include <math.h>
-
-#ifdef _HAVE_GSL_
-#include <gsl/gsl_math.h>
-#include <gsl/gsl_eigen.h>
-#endif
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- // VECTORS
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- void diffVec(const double v1[3], const double v0[3], double v01[3])
- {
- v01[0] = v1[0] - v0[0];
- v01[1] = v1[1] - v0[1];
- v01[2] = v1[2] - v0[2];
- }
-
- // -------------------------------------------------------------------
- double dotProd(const double v1[3], const double v2[3])
- {
- return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
- }
-
- // -------------------------------------------------------------------
- void crossProd(const double v1[3], const double v2[3], double cp[3])
- {
- cp[0] = v1[1]*v2[2] - v1[2]*v2[1];
- cp[1] = v1[2]*v2[0] - v1[0]*v2[2];
- cp[2] = v1[0]*v2[1] - v1[1]*v2[0];
- }
-
- // -------------------------------------------------------------------
- void normalizeVec(const double v[3], double nv[3])
- {
- double lSq = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
- if ( lSq <= MAdTOLSQ ) {
- MAdMsgSgl::instance().warning(__LINE__,__FILE__,
- "Normalization called for a zero vector");
- nv[0] = v[0];
- nv[1] = v[1];
- nv[2] = v[2];
- }
- double invNorm = 1. / sqrt( lSq );
- nv[0] = v[0] * invNorm ;
- nv[1] = v[1] * invNorm ;
- nv[2] = v[2] * invNorm ;
- }
-
- // -------------------------------------------------------------------
- void printVec(const double vec[3], const char * name)
- {
- printf("\nPrinting vector %s\n",name);
- for (int i=0; i<3; i++) printf(" %g",vec[i]);
- printf("\n\n");
- }
-
- // -------------------------------------------------------------------
- bool isNanVec (const double vec[3])
- {
- if ( isnan(vec[0]) || isnan(vec[1]) || isnan(vec[2]) ) return true;
- return false;
- }
-
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- // MATRICES
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- void transpose(double mat[3][3])
- {
- double tmp;
- tmp = mat[0][1]; mat[0][1] = mat[1][0]; mat[1][0] = tmp;
- tmp = mat[0][2]; mat[0][2] = mat[2][0]; mat[2][0] = tmp;
- tmp = mat[1][2]; mat[1][2] = mat[2][1]; mat[2][1] = tmp;
- }
-
- // -------------------------------------------------------------------
- void transpMat(const double mat[3][3], double matT[3][3])
- {
- for(int i=0; i<3; i++) for(int j=0; j<3; j++)
- matT[i][j] = mat[j][i];
- }
-
- // -------------------------------------------------------------------
- double detMat(const double mat[3][3])
- {
- return (mat[0][0] * (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) -
- mat[0][1] * (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0]) +
- mat[0][2] * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]));
- }
-
- // -------------------------------------------------------------------
- double traceMat(const double mat[3][3])
- {
- return mat[0][0] + mat[1][1] + mat[2][2];
- }
-
- // -------------------------------------------------------------------
- double traceMatMat(const double mat[3][3])
- {
- double a00 = mat[0][0] * mat[0][0] + mat[1][0] * mat[0][1] + mat[2][0] * mat[0][2];
- double a11 = mat[1][0] * mat[0][1] + mat[1][1] * mat[1][1] + mat[1][2] * mat[2][1];
- double a22 = mat[2][0] * mat[0][2] + mat[2][1] * mat[1][2] + mat[2][2] * mat[2][2];
-
- return a00 + a11 + a22;
- }
-
- // -------------------------------------------------------------------
- void vecMat(const double vec[3], const double mat[3][3], double res[3])
- {
- res[0] = mat[0][0] * vec[0] + mat[1][0] * vec[1] + mat[2][0] * vec[2];
- res[1] = mat[0][1] * vec[0] + mat[1][1] * vec[1] + mat[2][1] * vec[2];
- res[2] = mat[0][2] * vec[0] + mat[1][2] * vec[1] + mat[2][2] * vec[2];
- }
-
- // -------------------------------------------------------------------
- void matVec(const double mat[3][3], const double vec[3], double res[3])
- {
- res[0] = mat[0][0] * vec[0] + mat[0][1] * vec[1] + mat[0][2] * vec[2];
- res[1] = mat[1][0] * vec[0] + mat[1][1] * vec[1] + mat[1][2] * vec[2];
- res[2] = mat[2][0] * vec[0] + mat[2][1] * vec[1] + mat[2][2] * vec[2];
- }
-
- // -------------------------------------------------------------------
- void matMat(const double mat1[3][3], const double mat2[3][3], double res[3][3])
- {
- res[0][0] = mat1[0][0] * mat2[0][0] + mat1[0][1] * mat2[1][0] + mat1[0][2] * mat2[2][0];
- res[0][1] = mat1[0][0] * mat2[0][1] + mat1[0][1] * mat2[1][1] + mat1[0][2] * mat2[2][1];
- res[0][2] = mat1[0][0] * mat2[0][2] + mat1[0][1] * mat2[1][2] + mat1[0][2] * mat2[2][2];
-
- res[1][0] = mat1[1][0] * mat2[0][0] + mat1[1][1] * mat2[1][0] + mat1[1][2] * mat2[2][0];
- res[1][1] = mat1[1][0] * mat2[0][1] + mat1[1][1] * mat2[1][1] + mat1[1][2] * mat2[2][1];
- res[1][2] = mat1[1][0] * mat2[0][2] + mat1[1][1] * mat2[1][2] + mat1[1][2] * mat2[2][2];
-
- res[2][0] = mat1[2][0] * mat2[0][0] + mat1[2][1] * mat2[1][0] + mat1[2][2] * mat2[2][0];
- res[2][1] = mat1[2][0] * mat2[0][1] + mat1[2][1] * mat2[1][1] + mat1[2][2] * mat2[2][1];
- res[2][2] = mat1[2][0] * mat2[0][2] + mat1[2][1] * mat2[1][2] + mat1[2][2] * mat2[2][2];
- }
-
- // -------------------------------------------------------------------
- double vecMatVec(const double mat[3][3], const double vec[3])
- {
- double tmp[3];
- matVec(mat,vec,tmp);
- return dotProd(vec,tmp);
- }
-
- // -------------------------------------------------------------------
- double inverseMat(const double mat[3][3], double inv[3][3])
- {
- double det = detMat(mat);
- if(det) {
- double idet = 1. / det;
- inv[0][0] = (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) * idet;
- inv[1][0] = -(mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0]) * idet;
- inv[2][0] = (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]) * idet;
- inv[0][1] = -(mat[0][1] * mat[2][2] - mat[0][2] * mat[2][1]) * idet;
- inv[1][1] = (mat[0][0] * mat[2][2] - mat[0][2] * mat[2][0]) * idet;
- inv[2][1] = -(mat[0][0] * mat[2][1] - mat[0][1] * mat[2][0]) * idet;
- inv[0][2] = (mat[0][1] * mat[1][2] - mat[0][2] * mat[1][1]) * idet;
- inv[1][2] = -(mat[0][0] * mat[1][2] - mat[0][2] * mat[1][0]) * idet;
- inv[2][2] = (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]) * idet;
- }
- else{
- printf("Error: Singular matrix\n");
- for(int i=0; i<3; i++) for(int j=0; j<3; j++) inv[i][j] = 0.;
- }
- return det;
- }
-
- // -------------------------------------------------------------------
- double invertMat(double mat[3][3])
- {
- double inv[3][3];
- double det = inverseMat(mat,inv);
- for (int i=0; i<3; i++) {
- for (int j=0; j<3; j++) {
- mat[i][j] = inv[i][j];
- }
- }
- return det;
- }
-
- // -------------------------------------------------------------------
- bool system(const double A[3][3], const double b[3], double res[3], double * det)
- {
- *det = detMat(A);
- if(*det == 0.0) {
- res[0] = res[1] = res[2] = 0.0;
- return false;
- }
-
- res[0] = b[0] * (A[1][1] * A[2][2] - A[1][2] * A[2][1]) -
- A[0][1] * (b[1] * A[2][2] - A[1][2] * b[2]) +
- A[0][2] * (b[1] * A[2][1] - A[1][1] * b[2]);
- res[1] = A[0][0] * (b[1] * A[2][2] - A[1][2] * b[2]) -
- b[0] * (A[1][0] * A[2][2] - A[1][2] * A[2][0]) +
- A[0][2] * (A[1][0] * b[2] - b[1] * A[2][0]);
- res[2] = A[0][0] * (A[1][1] * b[2] - b[1] * A[2][1]) -
- A[0][1] * (A[1][0] * b[2] - b[1] * A[2][0]) +
- b[0] * (A[1][0] * A[2][1] - A[1][1] * A[2][0]);
-
- double idet = 1. / (*det);
- for(int i=0; i<3; i++) res[i] *= idet;
-
- return true;
- }
-
- // -------------------------------------------------------------------
- void printMat(const double mat[3][3], const char * name)
- {
- printf("\nPrinting matrix %s\n",name);
- for (int i=0; i<3; i++) {
- for (int j=0; j<3; j++) {
- printf(" %g",mat[i][j]);
- }
- printf("\n");
- }
- printf("\n");
- }
-
- // -------------------------------------------------------------------
- void meanRow43(const double mat[4][3], double mean[3])
- {
- mean[0] = 0.25 * ( mat[0][0] + mat[1][0] + mat[2][0] + mat[3][0] );
- mean[1] = 0.25 * ( mat[0][1] + mat[1][1] + mat[2][1] + mat[3][1] );
- mean[2] = 0.25 * ( mat[0][2] + mat[1][2] + mat[2][2] + mat[3][2] );
- }
-
- // -------------------------------------------------------------------
- bool isNanMat (const double mat[3][3])
- {
- if ( isNanVec(mat[0]) || isNanVec(mat[1]) || isNanVec(mat[2]) ) return true;
- return false;
- }
-
- // -------------------------------------------------------------------
- // Miscellaneous
- // -------------------------------------------------------------------
-
- // -------------------------------------------------------------------
- void sort(double lst[3])
- {
- for (int i=0; i<3; i++) {
- int k = i;
- double mx = lst[i];
- for (int j=i+1; j<3; j++) if (lst[j] >= mx) { mx = lst[j]; k = j; }
- if (k != i) { lst[k] = lst[i]; lst[i] = mx; }
- }
- }
-
- // -------------------------------------------------------------------
- void cubicRoots(const double coef[4], double real[3], double imag[3]) // GCTODO: to be rewritten
- {
- double a = coef[3];
- double b = coef[2];
- double c = coef[1];
- double d = coef[0];
-
- if(!a || !d){
- printf("Error: Degenerate cubic: use a second degree solver!\n");
- return;
- }
-
- b /= a;
- c /= a;
- d /= a;
-
- double q = (3.0*c - (b*b))/9.0;
- double r = -(27.0*d) + b*(9.0*c - 2.0*(b*b));
- r /= 54.0;
-
- double discrim = q*q*q + r*r;
- imag[0] = 0.0; // The first root is always real.
- double term1 = (b/3.0);
-
- if (discrim > 0) { // one root is real, two are complex
- double s = r + sqrt(discrim);
- s = ((s < 0) ? -pow(-s, (1.0/3.0)) : pow(s, (1.0/3.0)));
- double t = r - sqrt(discrim);
- t = ((t < 0) ? -pow(-t, (1.0/3.0)) : pow(t, (1.0/3.0)));
- real[0] = -term1 + s + t;
- term1 += (s + t)/2.0;
- real[1] = real[2] = -term1;
- term1 = sqrt(3.0)*(-t + s)/2;
- imag[1] = term1;
- imag[2] = -term1;
- return;
- }
-
- // The remaining options are all real
- imag[1] = imag[2] = 0.0;
-
- double r13;
- if (discrim == 0){ // All roots real, at least two are equal.
- r13 = ((r < 0) ? -pow(-r,(1.0/3.0)) : pow(r,(1.0/3.0)));
- real[0] = -term1 + 2.0*r13;
- real[1] = real[2] = -(r13 + term1);
- return;
- }
-
- // Only option left is that all roots are real and unequal (to get
- // here, q < 0)
- q = -q;
- double dum1 = q*q*q;
- dum1 = acos(r/sqrt(dum1));
- r13 = 2.0*sqrt(q);
- real[0] = -term1 + r13*cos(dum1/3.0);
- real[1] = -term1 + r13*cos((dum1 + 2.0*M_PI)/3.0);
- real[2] = -term1 + r13*cos((dum1 + 4.0*M_PI)/3.0);
- }
-
-
- // -------------------------------------------------------------------
- // solve x^2 + b x + c = 0
- // x[2] is always set to be zero
- // long FindQuadraticRoots(const double b, const double c, double x[3]) // GCTODO: to be rewritten
- // {
- // // printf("Quadratic roots\n");
- // x[2]=0.0;
- // double delt=b*b-4.*c;
- // if( delt >=0 ) {
- // delt=sqrt(delt);
- // x[0]=(-b+delt)/2.0;
- // x[1]=(-b-delt)/2.0;
- // return 3;
- // }
-
- // printf("Imaginary roots, impossible, delt=%f\n",delt);
- // return 1;
- // }
-
- // -------------------------------------------------------------------
- // solve x^3 + a1 x^2 + a2 x + a3 = 0
- // long FindCubicRoots(const double coeff[4], double x[3]) // GCTODO: to be rewritten
- // {
- // double a1 = coeff[2] / coeff[3];
- // double a2 = coeff[1] / coeff[3];
- // double a3 = coeff[0] / coeff[3];
-
- // if( fabs(a3)<1.0e-8 )
- // return FindQuadraticRoots(a1,a2,x);
-
- // double Q = (a1 * a1 - 3 * a2) / 9.;
- // double R = (2. * a1 * a1 * a1 - 9. * a1 * a2 + 27. * a3) / 54.;
- // double Qcubed = Q * Q * Q;
- // double d = Qcubed - R * R;
-
- // // printf ("d = %22.15e Q = %12.5E R = %12.5E Qcubed %12.5E\n",d,Q,R,Qcubed);
-
- // /// three roots, 2 equal
- // if(Qcubed == 0.0 || fabs ( Qcubed - R * R ) < 1.e-8 * (fabs ( Qcubed) + fabs( R * R)) )
- // {
- // double theta;
- // if (Qcubed <= 0.0)theta = acos(1.0);
- // else if (R / sqrt(Qcubed) > 1.0)theta = acos(1.0);
- // else if (R / sqrt(Qcubed) < -1.0)theta = acos(-1.0);
- // else theta = acos(R / sqrt(Qcubed));
- // double sqrtQ = sqrt(Q);
- // // printf("sqrtQ = %12.5E teta=%12.5E a1=%12.5E\n",sqrt(Q),theta,a1);
- // x[0] = -2 * sqrtQ * cos( theta / 3) - a1 / 3;
- // x[1] = -2 * sqrtQ * cos((theta + 2 * M_PI) / 3) - a1 / 3;
- // x[2] = -2 * sqrtQ * cos((theta + 4 * M_PI) / 3) - a1 / 3;
- // return (3);
- // }
-
- // // Three real roots
- // if (d >= 0.0) {
- // double theta = acos(R / sqrt(Qcubed));
- // double sqrtQ = sqrt(Q);
- // x[0] = -2 * sqrtQ * cos( theta / 3) - a1 / 3;
- // x[1] = -2 * sqrtQ * cos((theta + 2 * M_PI) / 3) - a1 / 3;
- // x[2] = -2 * sqrtQ * cos((theta + 4 * M_PI) / 3) - a1 / 3;
- // return (3);
- // }
-
- // // One real root
- // else {
- // printf("IMPOSSIBLE !!!\n");
-
- // double e = pow(sqrt(-d) + fabs(R), 1. / 3.);
- // if (R > 0)
- // e = -e;
- // x[0] = (e + Q / e) - a1 / 3.;
- // return (1);
- // }
- // }
-
- // -------------------------------------------------------------------
- int indexOfMin(double v0, double v1, double v2)
- {
- double minV = v0;
- int index = 0;
- if ( v1 < minV ) { minV = v1; index = 1; }
- if ( v2 < minV ) { minV = v2; index = 2; }
- return index;
- }
-
- // -------------------------------------------------------------------
- int indexOfMax(double v0, double v1, double v2)
- {
- double maxV = v0;
- int index = 0;
- if ( v1 > maxV ) { maxV = v1; index = 1; }
- if ( v2 > maxV ) { maxV = v2; index = 2; }
- return index;
- }
-
- // -------------------------------------------------------------------
- //! Gets the projection of a point on a plane defined by 3 points
- void pointToPlane(const double plane[3][3],
- const double xyz[3],
- double proj[3])
- {
- double v01[3], v02[3];
- diffVec(plane[1],plane[0],v01);
- diffVec(plane[2],plane[0],v02);
- double normal[3];
- crossProd(v01,v02,normal);
- double areaSq = dotProd(normal,normal);
-
- double v0X[3];
- diffVec(xyz,plane[0],v0X);
- double ASqX = dotProd(v0X,normal);
-
- double ratio = ASqX / areaSq;
- for (int i=0; i<3; i++) proj[i] = xyz[i] - ratio * normal[i];
- }
-
- // -------------------------------------------------------------------
- double distanceSq(const double xyz0[3], const double xyz1[3])
- {
- return ( ( xyz1[0] - xyz0[0] ) * ( xyz1[0] - xyz0[0] ) +
- ( xyz1[1] - xyz0[1] ) * ( xyz1[1] - xyz0[1] ) +
- ( xyz1[2] - xyz0[2] ) * ( xyz1[2] - xyz0[2] ) );
- }
-
- // -------------------------------------------------------------------
-
-} // End of namespace MAd
diff --git a/Common/MathUtils.h b/Common/MathUtils.h
deleted file mode 100644
index 633f90e..0000000
--- a/Common/MathUtils.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// -*- 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 at madlib.be>
-//
-// Authors: Gaetan Compere, Jean-Francois Remacle
-// -------------------------------------------------------------------
-
-#ifndef _H_MATHUTILS
-#define _H_MATHUTILS
-
-namespace MAd {
-
- // -------------------------------------------------------------------
- // --- Vectors ---
-
- void diffVec (const double [3], const double [3], double [3]);
- double dotProd (const double [3], const double [3]);
- void crossProd (const double [3], const double [3], double [3]);
- void normalizeVec (const double [3], double[3]);
- void printVec (const double [3], const char * name="");
- bool isNanVec (const double [3]);
-
- // -------------------------------------------------------------------
- // --- Matrices ---
-
- void transpose (double [3][3]);
- void transpMat (const double [3][3], double [3][3]);
- double detMat (const double [3][3]);
- double traceMat (const double [3][3]);
- double traceMatMat (const double [3][3]);
- void vecMat (const double [3], const double [3][3], double [3]);
- void matVec (const double [3][3], const double [3], double [3]);
- double vecMatVec (const double [3][3], const double [3]);
- void matMat (const double [3][3], const double [3][3], double [3][3]);
- double inverseMat (const double [3][3], double [3][3]);
- double invertMat (double [3][3]);
- bool system (const double [3][3], const double [3], double [3], double *);
- void printMat (const double [3][3], const char * name="");
- void meanRow43 (const double [4][3], double [3]);
- bool isNanMat (const double [3][3]);
-
- // -------------------------------------------------------------------
-
- void sort(double [3]);
- void cubicRoots(const double [4], double [3], double [3]);
- int indexOfMin(double, double, double);
- int indexOfMax(double, double, double);
- void pointToPlane(const double [3][3], const double [3], double[3]);
- double distanceSq(const double[3], const double[3]);
-
- // -------------------------------------------------------------------
-
-}
-
-#endif
--
MAdLib, a mesh adaptation library.
More information about the Pkg-scicomp-commits
mailing list