AdaptiveTetrahedralMesh.hpp

00001 /*
00002 
00003 Copyright (C) Fujitsu Laboratories of Europe, 2009-2010
00004 
00005 */
00006 
00007 /*
00008 
00009 Copyright (C) University of Oxford, 2005-2011
00010 
00011 University of Oxford means the Chancellor, Masters and Scholars of the
00012 University of Oxford, having an administrative office at Wellington
00013 Square, Oxford OX1 2JD, UK.
00014 
00015 This file is part of Chaste.
00016 
00017 Chaste is free software: you can redistribute it and/or modify it
00018 under the terms of the GNU Lesser General Public License as published
00019 by the Free Software Foundation, either version 2.1 of the License, or
00020 (at your option) any later version.
00021 
00022 Chaste is distributed in the hope that it will be useful, but WITHOUT
00023 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00024 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00025 License for more details. The offer of Chaste under the terms of the
00026 License is subject to the License being interpreted in accordance with
00027 English Law and subject to any action against the University of Oxford
00028 being under the jurisdiction of the English Courts.
00029 
00030 You should have received a copy of the GNU Lesser General Public License
00031 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00032 
00033 */
00034 
00035 
00036 
00037 #ifndef ADAPTIVETETRAHEDRALMESH_HPP_
00038 #define ADAPTIVETETRAHEDRALMESH_HPP_
00039 
00040 #define CXXBLAS_H    // This stops multiple definition of blas headers (one via Chaste, one via libadaptivity/include/cxxblas.h)
00041                     // Might break things, no idea, will keep it here until problems appear....
00042 
00043 
00044 #ifdef CHASTE_VTK
00045 #define _BACKWARD_BACKWARD_WARNING_H 1 //Cut out the strstream deprecated warning for now (gcc4.3)
00046 
00047 #ifdef CHASTE_ADAPTIVITY
00048 #define HAVE_VTK // Tell libadaptivity that we are using VTK
00049 
00050 #include "AbstractTetrahedralMesh.hpp"
00051 #include "DistributedTetrahedralMesh.hpp"
00052 
00053 // Include libadaptivity header files.
00054 // Need to add $LIBADAPTIVITY_DIR/include/ to the include path.
00055 #include "vtk.h"
00056 #include "../metric_field/include/DiscreteGeometryConstraints.h"
00057 #include "../metric_field/include/ErrorMeasure.h"
00058 #include "../adapt3d/include/Adaptivity.h"
00059 
00064 class AdaptiveTetrahedralMesh
00065 {
00066     friend class TestAdaptivityLibrary;
00067     friend class TestAdaptiveTetrahedralMesh;
00068     friend class TestAdaptiveTetrahedralMeshLargeMeshes;
00069 
00070 private:
00072     vtkUnstructuredGrid *mpVtkUnstructuredGrid;
00073 
00075     unsigned mNumNodes;
00076 
00078     unsigned mNumElements;
00079 
00081     unsigned mNumLocalNodes;
00082 
00084     bool mAdaptSuccess;
00085 
00087     DiscreteGeometryConstraints* mpDiscreteGeometryConstraints;
00089     ErrorMeasure* mpErrorMeasure;
00091     Adaptivity* mpAdapt;
00092 
00094     std::vector<int> SENList;
00096     std::vector<int> sids;
00098     std::vector<double> max_len;
00099 
00104     double mGoodEdgeRange;
00105 
00107     double mBadEdgeCriterion;
00108 
00110     bool mVerbose;
00111 
00112 public:
00113 
00117     AdaptiveTetrahedralMesh();
00118 
00122     ~AdaptiveTetrahedralMesh();
00123 
00129     void ConstructFromVtuFile(std::string fileName);
00130 
00136     void ConstructFromMesh(AbstractTetrahedralMesh<3,3>* rMesh);
00137 
00143     void ConstructFromDistributedMesh(DistributedTetrahedralMesh<3,3>* rMesh);
00144 
00152     void AddPointData(std::string dataName, std::vector<double> dataPayload);
00153 
00161     void AddPointData(std::string dataName, std::vector<unsigned> dataPayload);
00162 
00168     void RemoveArray(std::string dataName);
00169 
00176     void WriteMeshToFile(std::string directory, std::string fileName);
00177 
00184     void WriteMeshToDistributedFile(std::string directory, std::string fileName);
00185 
00189     vtkUnstructuredGrid* GetVtkUnstructuredGrid();
00190 
00198     void SetAdaptCriterion(double range, double criterion);
00199 
00203     unsigned GetNumNodes();
00204 
00208     unsigned GetNumLocalNodes();
00209 
00213     unsigned GetNumLocalAndHaloNodes();
00214 
00218     unsigned GetNumElements();
00219 
00223     unsigned GetNumLocalElements();
00224 
00229     unsigned GetNumSurfaceElements();
00230 
00236     void CalculateSENListAndSids(double coplanarTolerance = 0.9999999);
00237 
00243     double GetEdgeLengthDistribution(double range);
00244 
00252     void AdaptMesh();
00253 
00258     void Reset();
00259 
00263     bool GetAdaptSuccess();
00264 
00270     void MakeVerbose(bool verbose=true);
00271 
00272 
00273 protected:
00279     void GetGeometryConstraints();
00280 
00287     void CalculateErrorMetric();
00288 
00297     void Adapt();
00298 };
00299 #endif /*CHASTE_ADAPTIVITY */
00300 #endif /*CHASTE_VTK */
00301 
00302 #endif /*ADAPTIVETETRAHEDRALMESH_HPP_*/

Generated on Tue May 31 14:31:41 2011 for Chaste by  doxygen 1.5.5