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 <vector>
00030 #include "UblasIncludes.hpp"
00031 #include "AxisymmetricConductivityTensors.hpp"
00032 #include "Exception.hpp"
00033
00034
00035 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00036 AxisymmetricConductivityTensors<ELEMENT_DIM, SPACE_DIM>::AxisymmetricConductivityTensors()
00037 {
00038 if (SPACE_DIM != 3)
00039 {
00040 EXCEPTION("Axisymmetric anisotropic conductivity only makes sense in 3D");
00041 }
00042 }
00043
00044 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00045 void AxisymmetricConductivityTensors<ELEMENT_DIM, SPACE_DIM>::SetConstantConductivities(c_vector<double, 3> constantConductivities)
00046 {
00047
00048 if (constantConductivities[1] != constantConductivities[2])
00049 {
00050 EXCEPTION("Axisymmetric media defined: transversal and normal conductivities should have the same value");
00051 }
00052
00053 this->mUseNonConstantConductivities = false;
00054 this->mConstantConductivities = constantConductivities;
00055 }
00056
00057 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00058 void AxisymmetricConductivityTensors<ELEMENT_DIM, SPACE_DIM>::Init(AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM> *pMesh) throw (Exception)
00059 {
00060 this->mpMesh = pMesh;
00061
00062 if (!this->mUseNonConstantConductivities && !this->mUseFibreOrientation)
00063 {
00064
00065 c_matrix<double, SPACE_DIM, SPACE_DIM> conductivity_matrix(zero_matrix<double>(SPACE_DIM,SPACE_DIM));
00066
00067 for (unsigned dim=0; dim<SPACE_DIM; dim++)
00068 {
00069 assert(this->mConstantConductivities(dim) != DBL_MAX);
00070 conductivity_matrix(dim,dim) = this->mConstantConductivities(dim);
00071 }
00072 this->mTensors.push_back(conductivity_matrix);
00073 }
00074 else
00075 {
00076 c_vector<double,SPACE_DIM> fibre_vector((zero_vector<double>(SPACE_DIM)));
00077 fibre_vector[0]=1.0;
00078
00079 if (this->mUseFibreOrientation)
00080 {
00081
00082 this->mFileReader.reset(new FibreReader<SPACE_DIM>(this->mFibreOrientationFile, AXISYM));
00083 if(this->mFileReader->GetNumLinesOfData() != this->mpMesh->GetNumElements())
00084 {
00085 EXCEPTION("The size of the fibre file does not match the number of elements in the mesh");
00086 }
00087 }
00088
00089 if (this->mUseNonConstantConductivities)
00090 {
00091 if(this->mpNonConstantConductivities->size() != this->mpMesh->GetNumLocalElements())
00092 {
00093 EXCEPTION("The size of the conductivities vector does not match the number of elements in the mesh");
00094 }
00095 }
00096
00097
00098
00099 this->mTensors.reserve(this->mpMesh->GetNumLocalElements());
00100
00101 c_matrix<double, SPACE_DIM, SPACE_DIM> conductivity_matrix(zero_matrix<double>(SPACE_DIM,SPACE_DIM));
00102
00103 unsigned local_element_index = 0;
00104
00105 for (typename AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>::ElementIterator it = this->mpMesh->GetElementIteratorBegin();
00106 it != this->mpMesh->GetElementIteratorEnd();
00107 ++it)
00108 {
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 if (this->mUseNonConstantConductivities)
00135 {
00136 for (unsigned dim=0; dim<SPACE_DIM; dim++)
00137 {
00138 conductivity_matrix(dim,dim) = (*this->mpNonConstantConductivities)[local_element_index][dim];
00139 }
00140 }
00141 else
00142 {
00143 for (unsigned dim=0; dim<SPACE_DIM; dim++)
00144 {
00145 assert(this->mConstantConductivities(dim) != DBL_MAX);
00146 conductivity_matrix(dim,dim) = this->mConstantConductivities(dim);
00147 }
00148 }
00149
00150
00151 if (this->mUseFibreOrientation)
00152 {
00153 this->mFileReader->GetNextFibreVector(fibre_vector);
00154 }
00155
00156 this->mTensors.push_back( conductivity_matrix(1,1) * identity_matrix<double>(SPACE_DIM) +
00157 (conductivity_matrix(0,0) - conductivity_matrix(1,1)) * outer_prod(fibre_vector,fibre_vector));
00158
00159 local_element_index++;
00160 }
00161
00162 assert(this->mTensors.size() == this->mpMesh->GetNumLocalElements());
00163 assert(this->mTensors.size() == local_element_index);
00164
00165 if (this->mUseFibreOrientation)
00166 {
00167
00168 this->mFileReader.reset();
00169 }
00170 }
00171
00172 this->mInitialised = true;
00173 }
00174
00175
00176
00178
00180
00181
00182
00183 template class AxisymmetricConductivityTensors<1,1>;
00184 template class AxisymmetricConductivityTensors<1,2>;
00185 template class AxisymmetricConductivityTensors<1,3>;
00186 template class AxisymmetricConductivityTensors<2,2>;
00187 template class AxisymmetricConductivityTensors<2,3>;
00188 template class AxisymmetricConductivityTensors<3,3>;