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 "OrthotropicConductivityTensors.hpp"
00030 #include "Exception.hpp"
00031
00032 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00033 void OrthotropicConductivityTensors<ELEMENT_DIM, SPACE_DIM>::Init(AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM> *pMesh) throw (Exception)
00034 {
00035 this->mpMesh = pMesh;
00036
00037 if (!this->mUseNonConstantConductivities && !this->mUseFibreOrientation)
00038 {
00039
00040 c_matrix<double, SPACE_DIM, SPACE_DIM> conductivity_matrix(zero_matrix<double>(SPACE_DIM,SPACE_DIM));
00041
00042 for (unsigned dim=0; dim<SPACE_DIM; dim++)
00043 {
00044 assert(this->mConstantConductivities(dim) != DBL_MAX);
00045 conductivity_matrix(dim,dim) = this->mConstantConductivities(dim);
00046 }
00047
00048 this->mTensors.push_back(conductivity_matrix);
00049 }
00050 else
00051 {
00052 c_matrix<double,SPACE_DIM,SPACE_DIM> orientation_matrix((identity_matrix<double>(SPACE_DIM)));
00053
00054 if (this->mUseFibreOrientation)
00055 {
00056
00057 this->mFileReader.reset(new FibreReader<SPACE_DIM>(this->mFibreOrientationFile, ORTHO));
00058 if(this->mFileReader->GetNumLinesOfData() != this->mpMesh->GetNumElements())
00059 {
00060 EXCEPTION("The size of the fibre file does not match the number of elements in the mesh");
00061 }
00062 }
00063
00064 if (this->mUseNonConstantConductivities)
00065 {
00066 if(this->mpNonConstantConductivities->size() != this->mpMesh->GetNumLocalElements())
00067 {
00068 EXCEPTION("The size of the conductivities vector does not match the number of elements in the mesh");
00069 }
00070 }
00071
00072
00073
00074 this->mTensors.reserve(this->mpMesh->GetNumLocalElements());
00075
00076 c_matrix<double, SPACE_DIM, SPACE_DIM> conductivity_matrix(zero_matrix<double>(SPACE_DIM,SPACE_DIM));
00077
00078 unsigned local_element_index = 0;
00079 for (typename AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>::ElementIterator it = this->mpMesh->GetElementIteratorBegin();
00080 it != this->mpMesh->GetElementIteratorEnd();
00081 ++it)
00082 {
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 if (this->mUseNonConstantConductivities)
00102 {
00103 for (unsigned dim=0; dim<SPACE_DIM; dim++)
00104 {
00105 conductivity_matrix(dim,dim) = (*this->mpNonConstantConductivities)[local_element_index][dim];
00106 }
00107 }
00108 else
00109 {
00110 for (unsigned dim=0; dim<SPACE_DIM; dim++)
00111 {
00112 assert(this->mConstantConductivities(dim) != DBL_MAX);
00113 conductivity_matrix(dim,dim) = this->mConstantConductivities(dim);
00114 }
00115 }
00116
00117 if (this->mUseFibreOrientation)
00118 {
00119 this->mFileReader->GetNextFibreSheetAndNormalMatrix(orientation_matrix);
00120 }
00121
00122 c_matrix<double,SPACE_DIM,SPACE_DIM> temp;
00123 noalias(temp) = prod(orientation_matrix, conductivity_matrix);
00124 this->mTensors.push_back( prod(temp, trans(orientation_matrix) ) );
00125
00126 local_element_index++;
00127 }
00128 assert(this->mTensors.size() == this->mpMesh->GetNumLocalElements());
00129 assert(this->mTensors.size() == local_element_index);
00130
00131 if (this->mUseFibreOrientation)
00132 {
00133
00134 this->mFileReader.reset();
00135 }
00136 }
00137
00138 this->mInitialised = true;
00139 }
00140
00141
00143
00145
00146 template class OrthotropicConductivityTensors<1,1>;
00147 template class OrthotropicConductivityTensors<1,2>;
00148 template class OrthotropicConductivityTensors<1,3>;
00149 template class OrthotropicConductivityTensors<2,2>;
00150 template class OrthotropicConductivityTensors<2,3>;
00151 template class OrthotropicConductivityTensors<3,3>;