36 #ifndef ABSTRACTTETRAHEDRALMESH_HPP_
37 #define ABSTRACTTETRAHEDRALMESH_HPP_
42 #include <boost/serialization/vector.hpp>
43 #include <boost/serialization/base_object.hpp>
44 #include <boost/serialization/split_member.hpp>
49 #include <boost/foreach.hpp>
51 #include "AbstractMesh.hpp"
52 #include "BoundaryElement.hpp"
53 #include "Element.hpp"
54 #include "GenericMeshReader.hpp"
55 #include "AbstractMeshReader.hpp"
56 #include "TrianglesMeshReader.hpp"
57 #include "TrianglesMeshWriter.hpp"
58 #include "ArchiveLocationInfo.hpp"
59 #include "FileFinder.hpp"
63 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
70 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
74 friend class CentroidWriter;
104 friend class boost::serialization::access;
117 template<
class Archive>
118 void save(Archive & archive,
const unsigned int version)
const
120 archive & boost::serialization::base_object<AbstractMesh<ELEMENT_DIM,SPACE_DIM> >(*this);
131 archive & permutation_available;
133 if (permutation_available)
136 archive & rPermutation;
145 unsigned order_of_element = (mMeshIsLinear?1:2);
146 unsigned& order_of_boundary_element = order_of_element;
150 std::auto_ptr<AbstractMeshReader<ELEMENT_DIM, SPACE_DIM> > p_original_mesh_reader
151 = GenericMeshReader<ELEMENT_DIM, SPACE_DIM>(original_file, order_of_element, order_of_boundary_element);
153 if (p_original_mesh_reader->IsFileFormatBinary())
161 std::vector<FileFinder> mesh_files = mesh_folder.
FindMatches(mesh_leaf_name +
".*");
163 BOOST_FOREACH(
const FileFinder& r_mesh_file, mesh_files)
189 template<
class Archive>
190 void load(Archive & archive,
const unsigned int version)
192 archive & boost::serialization::base_object<AbstractMesh<ELEMENT_DIM,SPACE_DIM> >(*this);
195 bool permutation_available=
false;
196 std::vector<unsigned> permutation;
200 archive & permutation_available;
202 if (permutation_available)
204 archive & permutation;
227 p_our_factory = NULL;
235 if (permutation_available)
272 BOOST_SERIALIZATION_SPLIT_MEMBER()
301 class ElementIterator;
414 void ConstructFromMesh(AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>& rOtherMesh);
437 double& rJacobianDeterminant,
438 c_matrix<
double, ELEMENT_DIM, SPACE_DIM>& rInverseJacobian) const;
449 c_vector<
double, SPACE_DIM>& rWeightedDirection,
450 double& rJacobianDeterminant) const;
507 virtual
void ConstructCuboid(
unsigned width,
unsigned height,
unsigned depth);
593 std::vector<std::vector<
unsigned> >& rNodesToReceivePerProcess);
621 std::set<
unsigned> testElements=std::set<
unsigned>(),
622 bool onlyTryWithTestElements = false);
630 std::set<
unsigned> testElements);
642 class ElementIterator
669 inline ElementIterator& operator++();
683 bool skipDeletedElements=
true);
690 typename std::vector<Element<ELEMENT_DIM, SPACE_DIM> *>::iterator
mElementIter;
699 inline bool IsAtEnd();
705 inline bool IsAllowedElement();
713 namespace serialization {
720 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
734 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
736 bool skipDeletedElements)
741 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
747 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
754 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
758 return *mElementIter;
761 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
767 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
774 while (!IsAtEnd() && !IsAllowedElement());
779 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
783 bool skipDeletedElements)
785 mElementIter(elementIter),
786 mSkipDeletedElements(skipDeletedElements)
803 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
806 return mElementIter == mrMesh.mElements.end();
809 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
812 return !(mSkipDeletedElements && (*this)->IsDeleted());
ElementIterator GetElementIteratorBegin(bool skipDeletedElements=true)
virtual unsigned GetNumBoundaryElements() const
#define TEMPLATED_CLASS_IS_ABSTRACT_2_UNSIGNED(T)
std::vector< Element< ELEMENT_DIM, SPACE_DIM > * > mElements
bool operator!=(const typename AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ElementIterator &rOther)
virtual unsigned GetNumLocalBoundaryElements() const
#define ABORT_IF_THROWS(block)
bool mSkipDeletedElements
BoundaryElementIterator GetBoundaryElementIteratorBegin() const
static std::string GetMeshFilename()
virtual unsigned GetMaximumNodeIndex()
virtual bool CalculateDesignatedOwnershipOfBoundaryElement(unsigned faceIndex)
const std::vector< unsigned > & rGetNodePermutation() const
ElementIterator GetElementIteratorEnd()
void ConstructRegularSlabMesh(double spaceStep, double width, double height=0, double depth=0)
void load(Archive &archive, const unsigned int version)
virtual unsigned GetNumElements() const
virtual unsigned GetNumCableElements() const
unsigned CalculateMaximumNodeConnectivityPerProcess() const
Element< ELEMENT_DIM, SPACE_DIM > * GetElement(unsigned index) const
FileFinder CopyTo(const FileFinder &rDest) const
std::vector< Element< ELEMENT_DIM, SPACE_DIM > * >::iterator mElementIter
Element< ELEMENT_DIM, SPACE_DIM > & operator*()
std::string GetMeshFileBaseName() const
void CheckOutwardNormals()
virtual void GetHaloNodeIndices(std::vector< unsigned > &rHaloIndices) const
DistributedVectorFactory * GetOriginalFactory()
virtual void GetInverseJacobianForElement(unsigned elementIndex, c_matrix< double, SPACE_DIM, ELEMENT_DIM > &rJacobian, double &rJacobianDeterminant, c_matrix< double, ELEMENT_DIM, SPACE_DIM > &rInverseJacobian) const
virtual unsigned GetNumLocalElements() const
virtual unsigned SolveElementMapping(unsigned index) const =0
Element< ELEMENT_DIM, SPACE_DIM > * operator->()
bool mMeshChangesDuringSimulation
DistributedVectorFactory * mpDistributedVectorFactory
virtual void GetWeightedDirectionForBoundaryElement(unsigned elementIndex, c_vector< double, SPACE_DIM > &rWeightedDirection, double &rJacobianDeterminant) const
ElementIterator(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, typename std::vector< Element< ELEMENT_DIM, SPACE_DIM > * >::iterator elementIter, bool skipDeletedElements=true)
std::vector< BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > * > mBoundaryElements
void SetNodePermutation(std::vector< unsigned > &rPermutationVector)
std::string GetExtension() const
#define CHASTE_VERSION_CONTENT(N)
virtual unsigned GetNumVertices() const
void SetFromFactory(DistributedVectorFactory *pFactory)
AbstractTetrahedralMesh & mrMesh
unsigned GetContainingElementIndex(const ChastePoint< SPACE_DIM > &rTestPoint, bool strict=false, std::set< unsigned > testElements=std::set< unsigned >(), bool onlyTryWithTestElements=false)
virtual void ConstructRectangularMesh(unsigned width, unsigned height, bool stagger=true)
std::vector< FileFinder > FindMatches(const std::string &rPattern) const
bool IsMeshOnDisk() const
BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > * GetBoundaryElement(unsigned index) const
virtual void ConstructCuboid(unsigned width, unsigned height, unsigned depth)
void SetElementOwnerships()
unsigned GetNumAllElements() const
virtual void ConstructFromMeshReader(AbstractMeshReader< ELEMENT_DIM, SPACE_DIM > &rMeshReader)=0
FileFinder GetParent() const
void CalculateNodeExchange(std::vector< std::vector< unsigned > > &rNodesToSendPerProcess, std::vector< std::vector< unsigned > > &rNodesToReceivePerProcess)
Forward declaration which is going to be used for friendship.
unsigned GetNumAllBoundaryElements() const
std::string GetLeafNameNoExtension() const
void save(Archive &archive, const unsigned int version) const
virtual unsigned SolveBoundaryElementMapping(unsigned index) const =0
unsigned GetNearestElementIndexFromTestElements(const ChastePoint< SPACE_DIM > &rTestPoint, std::set< unsigned > testElements)
virtual bool CalculateDesignatedOwnershipOfElement(unsigned elementIndex)
void SetWriteFilesAsBinary()
virtual void SetDistributedVectorFactory(DistributedVectorFactory *pFactory)
virtual void ConstructLinearMesh(unsigned width)
std::vector< BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > * >::const_iterator BoundaryElementIterator
static std::string GetArchiveDirectory()
virtual void WriteFilesUsingMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, bool keepOriginalElementIndexing=true)
ElementIterator & operator++()
unsigned GetNumProcs() const
static std::string GetArchiveRelativePath()
virtual c_vector< double, 2 > CalculateMinMaxEdgeLengths()
void ConstructFromMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rOtherMesh)
void ConstructRegularSlabMeshWithDimensionSplit(unsigned dimension, double spaceStep, double width, double height=0, double depth=0)
void WriteFilesUsingMeshReaderAndMesh(AbstractMeshReader< ELEMENT_DIM, SPACE_DIM > &rMeshReader, AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh)
BoundaryElementIterator GetBoundaryElementIteratorEnd() const