Chaste Commit::baa90ac2819b962188b7562f2326be23c47859a7
TetrahedralMesh.hpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright notice,
15 this list of conditions and the following disclaimer.
16 * Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19 * Neither the name of the University of Oxford nor the names of its
20 contributors may be used to endorse or promote products derived from this
21 software without specific prior written permission.
22
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35
36#ifndef _TETRAHEDRALMESH_HPP_
37#define _TETRAHEDRALMESH_HPP_
38
40#include <boost/serialization/base_object.hpp>
41
44
45#include <vector>
46#include <string>
47#include <set>
48
49#include "AbstractTetrahedralMesh.hpp"
50#include "AbstractMeshReader.hpp"
51#include "ChastePoint.hpp"
52
53
54struct triangulateio;
57// DECLARATION
59
63template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
64class TetrahedralMesh : public AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM>
65{
66 friend class TestTetrahedralMesh; // to give access to private methods (not variables)
67 friend class TestCryptSimulation2d; // to give access to private methods (not variables)
68private:
77 template<class Archive>
78 void serialize(Archive & archive, const unsigned int version)
79 {
80 archive & boost::serialization::base_object<AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM> >(*this);
81 }
82
83protected:
84
91 unsigned SolveNodeMapping(unsigned index) const;
92
99 unsigned SolveElementMapping(unsigned index) const;
100
107 unsigned SolveBoundaryElementMapping(unsigned index) const;
108
110 std::vector< c_vector<double, SPACE_DIM> > mElementWeightedDirections;
111
113 std::vector< c_matrix<double, SPACE_DIM, ELEMENT_DIM> > mElementJacobians;
114
116 std::vector< c_matrix<double, ELEMENT_DIM, SPACE_DIM> > mElementInverseJacobians;
117
119 std::vector<double> mElementJacobianDeterminants;
120
122 std::vector< c_vector<double, SPACE_DIM> > mBoundaryElementWeightedDirections;
123
126
143 template <class MESHER_IO>
144 void ExportToMesher(NodeMap& map, MESHER_IO& mesherInput, int *elementList=nullptr);
145
163 template <class MESHER_IO>
164 void ImportFromMesher(MESHER_IO& mesherOutput, unsigned numberOfElements, int *elementList, unsigned numberOfFaces, int *faceList, int *edgeMarkerList);
165
166
171 void InitialiseTriangulateIo(triangulateio& mesherIo);
172
177 void FreeTriangulateIo(triangulateio& mesherIo);
178
179public:
180
185
192
198 void ReadNodesPerProcessorFile(const std::string& rNodesPerProcessorFile);
199
212 bool CheckIsConforming();
213
218 double GetVolume();
219
223 double GetSurfaceArea();
224
228 void RefreshMesh();
229
234 void PermuteNodes();
235
241 void PermuteNodes(const std::vector<unsigned>& perm);
242
252 unsigned GetContainingElementIndexWithInitialGuess(const ChastePoint<SPACE_DIM>& rTestPoint, unsigned startingElementGuess, bool strict=false);
253
262 unsigned GetNearestElementIndex(const ChastePoint<SPACE_DIM>& rTestPoint);
263
269 std::vector<unsigned> GetContainingElementIndices(const ChastePoint<SPACE_DIM>& rTestPoint);
270
274 virtual void Clear();
275
283 double GetAngleBetweenNodes(unsigned indexA, unsigned indexB);
284
286 virtual void RefreshJacobianCachedData();
287
295 virtual void GetJacobianForElement(unsigned elementIndex, c_matrix<double, SPACE_DIM, SPACE_DIM>& rJacobian, double& rJacobianDeterminant) const;
296
305 virtual void GetInverseJacobianForElement(unsigned elementIndex, c_matrix<double, SPACE_DIM, ELEMENT_DIM>& rJacobian, double& rJacobianDeterminant, c_matrix<double, ELEMENT_DIM, SPACE_DIM>& rInverseJacobian) const;
306
314 virtual void GetWeightedDirectionForElement(unsigned elementIndex, c_vector<double, SPACE_DIM>& rWeightedDirection, double& rJacobianDeterminant) const;
315
323 virtual void GetWeightedDirectionForBoundaryElement(unsigned elementIndex, c_vector<double, SPACE_DIM>& rWeightedDirection, double& rJacobianDeterminant) const;
324
332 {
333 public:
342
349
355
362 EdgeIterator(TetrahedralMesh& rMesh, unsigned elemIndex);
363
364 private:
369 std::set< std::pair<unsigned, unsigned> > mEdgesVisited;
370
373 unsigned mElemIndex;
376 };
377
382
388};
389
392
393#endif //_TETRAHEDRALMESH_HPP_
gcov doesn't like this file...
#define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)
Definition Node.hpp:59
std::set< std::pair< unsigned, unsigned > > mEdgesVisited
bool operator!=(const typename TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::EdgeIterator &rOther)
std::vector< c_matrix< double, ELEMENT_DIM, SPACE_DIM > > mElementInverseJacobians
virtual void RefreshJacobianCachedData()
void ImportFromMesher(MESHER_IO &mesherOutput, unsigned numberOfElements, int *elementList, unsigned numberOfFaces, int *faceList, int *edgeMarkerList)
void ExportToMesher(NodeMap &map, MESHER_IO &mesherInput, int *elementList=nullptr)
void serialize(Archive &archive, const unsigned int version)
std::vector< double > mBoundaryElementJacobianDeterminants
virtual void GetJacobianForElement(unsigned elementIndex, c_matrix< double, SPACE_DIM, SPACE_DIM > &rJacobian, double &rJacobianDeterminant) const
unsigned SolveNodeMapping(unsigned index) const
std::vector< c_vector< double, SPACE_DIM > > mBoundaryElementWeightedDirections
std::vector< c_matrix< double, SPACE_DIM, ELEMENT_DIM > > mElementJacobians
double GetAngleBetweenNodes(unsigned indexA, unsigned indexB)
std::vector< c_vector< double, SPACE_DIM > > mElementWeightedDirections
void ConstructFromMeshReader(AbstractMeshReader< ELEMENT_DIM, SPACE_DIM > &rMeshReader)
std::vector< unsigned > GetContainingElementIndices(const ChastePoint< SPACE_DIM > &rTestPoint)
void ReadNodesPerProcessorFile(const std::string &rNodesPerProcessorFile)
unsigned SolveElementMapping(unsigned index) const
unsigned GetNearestElementIndex(const ChastePoint< SPACE_DIM > &rTestPoint)
EdgeIterator EdgesEnd()
unsigned SolveBoundaryElementMapping(unsigned index) const
EdgeIterator EdgesBegin()
virtual void GetWeightedDirectionForBoundaryElement(unsigned elementIndex, c_vector< double, SPACE_DIM > &rWeightedDirection, double &rJacobianDeterminant) const
unsigned GetContainingElementIndexWithInitialGuess(const ChastePoint< SPACE_DIM > &rTestPoint, unsigned startingElementGuess, bool strict=false)
virtual void GetInverseJacobianForElement(unsigned elementIndex, c_matrix< double, SPACE_DIM, ELEMENT_DIM > &rJacobian, double &rJacobianDeterminant, c_matrix< double, ELEMENT_DIM, SPACE_DIM > &rInverseJacobian) const
friend class boost::serialization::access
void FreeTriangulateIo(triangulateio &mesherIo)
void InitialiseTriangulateIo(triangulateio &mesherIo)
virtual void GetWeightedDirectionForElement(unsigned elementIndex, c_vector< double, SPACE_DIM > &rWeightedDirection, double &rJacobianDeterminant) const
std::vector< double > mElementJacobianDeterminants
virtual void Clear()