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