Chaste Release::3.1
|
00001 /* 00002 00003 Copyright (C) Fujitsu Laboratories of Europe, 2009-2010 00004 00005 */ 00006 00007 /* 00008 00009 Copyright (c) 2005-2012, University of Oxford. 00010 All rights reserved. 00011 00012 University of Oxford means the Chancellor, Masters and Scholars of the 00013 University of Oxford, having an administrative office at Wellington 00014 Square, Oxford OX1 2JD, UK. 00015 00016 This file is part of Chaste. 00017 00018 Redistribution and use in source and binary forms, with or without 00019 modification, are permitted provided that the following conditions are met: 00020 * Redistributions of source code must retain the above copyright notice, 00021 this list of conditions and the following disclaimer. 00022 * Redistributions in binary form must reproduce the above copyright notice, 00023 this list of conditions and the following disclaimer in the documentation 00024 and/or other materials provided with the distribution. 00025 * Neither the name of the University of Oxford nor the names of its 00026 contributors may be used to endorse or promote products derived from this 00027 software without specific prior written permission. 00028 00029 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00030 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00031 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00032 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00033 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00034 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00035 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00036 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00037 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00038 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00039 00040 */ 00041 00042 00043 00044 #ifndef ADAPTIVETETRAHEDRALMESH_HPP_ 00045 #define ADAPTIVETETRAHEDRALMESH_HPP_ 00046 00047 #define CXXBLAS_H // This stops multiple definition of blas headers (one via Chaste, one via libadaptivity/include/cxxblas.h) 00048 // Might break things, no idea, will keep it here until problems appear.... 00049 00050 00051 #ifdef CHASTE_VTK 00052 #define _BACKWARD_BACKWARD_WARNING_H 1 //Cut out the strstream deprecated warning for now (gcc4.3) 00053 00054 #ifdef CHASTE_ADAPTIVITY 00055 #define HAVE_VTK // Tell libadaptivity that we are using VTK 00056 00057 #include "AbstractTetrahedralMesh.hpp" 00058 #include "DistributedTetrahedralMesh.hpp" 00059 00060 // Include libadaptivity header files. 00061 // Need to add $LIBADAPTIVITY_DIR/include/ to the include path. 00062 #include "vtk.h" 00063 #include "../metric_field/include/DiscreteGeometryConstraints.h" 00064 #include "../metric_field/include/ErrorMeasure.h" 00065 #include "../adapt3d/include/Adaptivity.h" 00066 00071 class AdaptiveTetrahedralMesh 00072 { 00073 friend class TestAdaptivityLibrary; 00074 friend class TestAdaptiveTetrahedralMesh; 00075 friend class TestAdaptiveTetrahedralMeshLargeMeshes; 00076 00077 private: 00079 vtkUnstructuredGrid *mpVtkUnstructuredGrid; 00080 00082 unsigned mNumNodes; 00083 00085 unsigned mNumElements; 00086 00088 unsigned mNumLocalNodes; 00089 00091 bool mAdaptSuccess; 00092 00094 DiscreteGeometryConstraints* mpDiscreteGeometryConstraints; 00096 ErrorMeasure* mpErrorMeasure; 00098 Adaptivity* mpAdapt; 00099 00101 std::vector<int> SENList; 00103 std::vector<int> sids; 00105 std::vector<double> max_len; 00106 00111 double mGoodEdgeRange; 00112 00114 double mBadEdgeCriterion; 00115 00117 bool mVerbose; 00118 00119 public: 00120 00124 AdaptiveTetrahedralMesh(); 00125 00129 ~AdaptiveTetrahedralMesh(); 00130 00136 void ConstructFromVtuFile(std::string fileName); 00137 00143 void ConstructFromMesh(AbstractTetrahedralMesh<3,3>* rMesh); 00144 00150 void ConstructFromDistributedMesh(DistributedTetrahedralMesh<3,3>* rMesh); 00151 00159 void AddPointData(std::string dataName, std::vector<double> dataPayload); 00160 00168 void AddPointData(std::string dataName, std::vector<unsigned> dataPayload); 00169 00175 void RemoveArray(std::string dataName); 00176 00183 void WriteMeshToFile(std::string directory, std::string fileName); 00184 00191 void WriteMeshToDistributedFile(std::string directory, std::string fileName); 00192 00196 vtkUnstructuredGrid* GetVtkUnstructuredGrid(); 00197 00205 void SetAdaptCriterion(double range, double criterion); 00206 00210 unsigned GetNumNodes(); 00211 00215 unsigned GetNumLocalNodes(); 00216 00220 unsigned GetNumLocalAndHaloNodes(); 00221 00225 unsigned GetNumElements(); 00226 00230 unsigned GetNumLocalElements(); 00231 00236 unsigned GetNumSurfaceElements(); 00237 00243 void CalculateSENListAndSids(double coplanarTolerance = 0.9999999); 00244 00250 double GetEdgeLengthDistribution(double range); 00251 00259 void AdaptMesh(); 00260 00265 void Reset(); 00266 00270 bool GetAdaptSuccess(); 00271 00277 void MakeVerbose(bool verbose=true); 00278 00279 00280 protected: 00286 void GetGeometryConstraints(); 00287 00294 void CalculateErrorMetric(); 00295 00304 void Adapt(); 00305 }; 00306 #endif /*CHASTE_ADAPTIVITY */ 00307 #endif /*CHASTE_VTK */ 00308 00309 #endif /*ADAPTIVETETRAHEDRALMESH_HPP_*/