00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "AbstractTetrahedralMesh.hpp"
00030
00032
00034
00035
00036 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00037 void AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::SetElementOwnerships(unsigned lo, unsigned hi)
00038 {
00039 assert(hi >= lo);
00040 for (unsigned element_index=0; element_index<mElements.size(); element_index++)
00041 {
00042 Element<ELEMENT_DIM, SPACE_DIM> *p_element = mElements[element_index];
00043 p_element->SetOwnership(false);
00044 for (unsigned local_node_index=0; local_node_index< p_element->GetNumNodes(); local_node_index++)
00045 {
00046 unsigned global_node_index = p_element->GetNodeGlobalIndex(local_node_index);
00047 if (lo<=global_node_index && global_node_index<hi)
00048 {
00049 p_element->SetOwnership(true);
00050 break;
00051 }
00052 }
00053 }
00054 }
00055
00056 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00057 AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::AbstractTetrahedralMesh()
00058 {
00059 }
00060
00061 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00062 AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::~AbstractTetrahedralMesh()
00063 {
00064
00065 for (unsigned i=0; i<mElements.size(); i++)
00066 {
00067 delete mElements[i];
00068 }
00069
00070 for (unsigned i=0; i<mBoundaryElements.size(); i++)
00071 {
00072 delete mBoundaryElements[i];
00073 }
00074 }
00075
00076 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00077 unsigned AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::GetNumElements() const
00078 {
00079 return mElements.size();
00080 }
00081
00082 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00083 unsigned AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::GetNumAllElements() const
00084 {
00085 return mElements.size();
00086 }
00087
00088 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00089 unsigned AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::GetNumAllBoundaryElements() const
00090 {
00091 return mBoundaryElements.size();
00092 }
00093
00094 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00095 unsigned AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::GetNumBoundaryElements() const
00096 {
00097 return mBoundaryElements.size();
00098 }
00099
00100
00101 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00102 Element<ELEMENT_DIM, SPACE_DIM>* AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::GetElement(unsigned index) const
00103 {
00104 unsigned local_index = SolveElementMapping(index);
00105 return mElements[local_index];
00106 }
00107
00108 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00109 BoundaryElement<ELEMENT_DIM-1, SPACE_DIM>* AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::GetBoundaryElement(unsigned index) const
00110 {
00111 unsigned local_index = SolveBoundaryElementMapping(index);
00112 return mBoundaryElements[local_index];
00113 }
00114
00115 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00116 typename AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::BoundaryElementIterator AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::GetBoundaryElementIteratorBegin() const
00117 {
00118 return mBoundaryElements.begin();
00119 }
00120
00121 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00122 typename AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::BoundaryElementIterator AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::GetBoundaryElementIteratorEnd() const
00123 {
00124 return mBoundaryElements.end();
00125 }
00126
00127 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00128 void AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::GetInverseJacobianForElement(
00129 unsigned elementIndex,
00130 c_matrix<double, SPACE_DIM, ELEMENT_DIM>& rJacobian,
00131 double& rJacobianDeterminant,
00132 c_matrix<double, ELEMENT_DIM, SPACE_DIM>& rInverseJacobian) const
00133 {
00134 mElements[SolveElementMapping(elementIndex)]->CalculateInverseJacobian(rJacobian, rJacobianDeterminant, rInverseJacobian);
00135 }
00136
00137 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00138 void AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>::GetWeightedDirectionForBoundaryElement(
00139 unsigned elementIndex,
00140 c_vector<double, SPACE_DIM>& rWeightedDirection,
00141 double& rJacobianDeterminant) const
00142 {
00143 mBoundaryElements[SolveBoundaryElementMapping(elementIndex)]->CalculateWeightedDirection(rWeightedDirection, rJacobianDeterminant );
00144 }
00145
00147
00149
00150 template class AbstractTetrahedralMesh<1,1>;
00151 template class AbstractTetrahedralMesh<1,2>;
00152 template class AbstractTetrahedralMesh<1,3>;
00153 template class AbstractTetrahedralMesh<2,2>;
00154 template class AbstractTetrahedralMesh<2,3>;
00155 template class AbstractTetrahedralMesh<3,3>;