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 template<unsigned SPACE_DIM>
00035 void AxisymmetricConductivityTensors<SPACE_DIM>::ReadOrientationVectorFromFile (c_vector<double,SPACE_DIM>& rOrientVector)
00036 {
00037 std::vector<double> tokens;
00038
00039 unsigned num_elems = this->GetTokensAtNextLine(tokens);
00040
00041 if (num_elems != 3u)
00042 {
00043 this->CloseFibreOrientationFile();
00044 EXCEPTION("Axisymmetric media defined. Fibre orientation file should contain 3 values per element");
00045 }
00046
00047 for (unsigned i=0; i<SPACE_DIM; i++)
00048 {
00049 rOrientVector[i] = tokens[i];
00050 }
00051 }
00052
00053 template<unsigned SPACE_DIM>
00054 AxisymmetricConductivityTensors<SPACE_DIM>::AxisymmetricConductivityTensors()
00055 {
00056 if (SPACE_DIM != 3)
00057 {
00058 EXCEPTION("Axisymmetric anisotropic conductivity only makes sense in 3D");
00059 }
00060 }
00061
00062 template<unsigned SPACE_DIM>
00063 void AxisymmetricConductivityTensors<SPACE_DIM>::SetConstantConductivities(c_vector<double, 3> constantConductivities)
00064 {
00065
00066 if (constantConductivities[1] != constantConductivities[2])
00067 {
00068 EXCEPTION("Axisymmetric media defined: transversal and normal conductivities should have the same value");
00069 }
00070
00071 this->mUseNonConstantConductivities = false;
00072 this->mConstantConductivities = constantConductivities;
00073 }
00074
00075 template<unsigned SPACE_DIM>
00076 void AxisymmetricConductivityTensors<SPACE_DIM>::Init() throw (Exception)
00077 {
00078 if (!this->mUseNonConstantConductivities && !this->mUseFibreOrientation)
00079 {
00080
00081 c_matrix<double, SPACE_DIM, SPACE_DIM> conductivity_matrix(zero_matrix<double>(SPACE_DIM,SPACE_DIM));
00082
00083 for (unsigned dim=0; dim<SPACE_DIM; dim++)
00084 {
00085 assert(this->mConstantConductivities(dim) != DBL_MAX);
00086 conductivity_matrix(dim,dim) = this->mConstantConductivities(dim);
00087 }
00088 this->mTensors.push_back(conductivity_matrix);
00089 }
00090 else
00091 {
00092 c_vector<double,SPACE_DIM> fibre_vector((zero_vector<double>(SPACE_DIM)));
00093 fibre_vector[0]=1.0;
00094
00095 if (this->mUseFibreOrientation)
00096 {
00097 this->OpenFibreOrientationFile();
00098 this->mNumElements = this->GetNumElementsFromFile();
00099 }
00100 else
00101 {
00102 this->mNumElements = this->mpNonConstantConductivities->size();
00103 }
00104
00105
00106
00107 this->mTensors.reserve(this->mNumElements);
00108
00109 c_matrix<double, SPACE_DIM, SPACE_DIM> conductivity_matrix(zero_matrix<double>(SPACE_DIM,SPACE_DIM));
00110
00111 for (unsigned element_index=0; element_index<this->mNumElements; element_index++)
00112 {
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 if (this->mUseNonConstantConductivities)
00139 {
00140 for (unsigned dim=0; dim<SPACE_DIM; dim++)
00141 {
00142 conductivity_matrix(dim,dim) = (*this->mpNonConstantConductivities)[element_index][dim];
00143 }
00144 }
00145 else
00146 {
00147 for (unsigned dim=0; dim<SPACE_DIM; dim++)
00148 {
00149 assert(this->mConstantConductivities(dim) != DBL_MAX);
00150 conductivity_matrix(dim,dim) = this->mConstantConductivities(dim);
00151 }
00152 }
00153
00154
00155 if (this->mUseFibreOrientation)
00156 {
00157 ReadOrientationVectorFromFile(fibre_vector);
00158 }
00159
00160 this->mTensors.push_back( conductivity_matrix(1,1) * identity_matrix<double>(SPACE_DIM) +
00161 (conductivity_matrix(0,0) - conductivity_matrix(1,1)) * outer_prod(fibre_vector,fibre_vector));
00162 }
00163
00164 if (this->mUseFibreOrientation)
00165 {
00166 this->CloseFibreOrientationFile();
00167 }
00168 }
00169
00170 this->mInitialised = true;
00171 }
00172
00173
00174
00176
00178
00179
00180
00181 template class AxisymmetricConductivityTensors<1>;
00182 template class AxisymmetricConductivityTensors<2>;
00183 template class AxisymmetricConductivityTensors<3>;