AbstractConductivityTensors.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 "AbstractConductivityTensors.hpp"
00037 #include "Exception.hpp"
00038 #include <sstream>
00039
00040 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00041 AbstractConductivityTensors<ELEMENT_DIM,SPACE_DIM>::AbstractConductivityTensors()
00042 : mpMesh(NULL),
00043 mUseNonConstantConductivities(false),
00044 mUseFibreOrientation(false),
00045 mInitialised(false)
00046 {
00047 double init_data[]={DBL_MAX, DBL_MAX, DBL_MAX};
00048
00049 for (unsigned dim=0; dim<SPACE_DIM; dim++)
00050 {
00051 mConstantConductivities[dim] = init_data[dim];
00052 }
00053 }
00054
00055 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00056 AbstractConductivityTensors<ELEMENT_DIM,SPACE_DIM>::~AbstractConductivityTensors()
00057 {
00058 }
00059
00060 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00061 void AbstractConductivityTensors<ELEMENT_DIM,SPACE_DIM>::SetFibreOrientationFile(const FileFinder &rFibreOrientationFile)
00062 {
00063 mUseFibreOrientation = true;
00064 mFibreOrientationFile = rFibreOrientationFile;
00065 }
00066
00067 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00068 void AbstractConductivityTensors<ELEMENT_DIM,SPACE_DIM>::SetConstantConductivities(c_vector<double, 1> constantConductivities)
00069 {
00070 if (SPACE_DIM != 1)
00071 {
00072 EXCEPTION("Wrong number of conductivities provided");
00073 }
00074
00075 mUseNonConstantConductivities = false;
00076 mConstantConductivities = constantConductivities;
00077 }
00078
00079 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00080 void AbstractConductivityTensors<ELEMENT_DIM,SPACE_DIM>::SetConstantConductivities(c_vector<double, 2> constantConductivities)
00081 {
00082 if (SPACE_DIM != 2)
00083 {
00084 EXCEPTION("Wrong number of conductivities provided");
00085 }
00086
00087 mUseNonConstantConductivities = false;
00088 mConstantConductivities = constantConductivities;
00089 }
00090
00091 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00092 void AbstractConductivityTensors<ELEMENT_DIM,SPACE_DIM>::SetConstantConductivities(c_vector<double, 3> constantConductivities)
00093 {
00094 if (SPACE_DIM != 3)
00095 {
00096 EXCEPTION("Wrong number of conductivities provided");
00097 }
00098
00099 mUseNonConstantConductivities = false;
00100 mConstantConductivities = constantConductivities;
00101 }
00102
00103 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00104 void AbstractConductivityTensors<ELEMENT_DIM,SPACE_DIM>::SetNonConstantConductivities(std::vector<c_vector<double, SPACE_DIM> >* pNonConstantConductivities)
00105 {
00106 mUseNonConstantConductivities = true;
00107 mpNonConstantConductivities = pNonConstantConductivities;
00108 }
00109
00110 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00111 c_matrix<double,SPACE_DIM,SPACE_DIM>& AbstractConductivityTensors<ELEMENT_DIM,SPACE_DIM>::operator[](const unsigned global_index)
00112 {
00113 assert(mInitialised);
00114 if (global_index >= this->mpMesh->GetNumElements() )
00115 {
00116 EXCEPTION("Conductivity tensor requested for element with global_index=" << global_index << ", but there are only " << this->mpMesh->GetNumElements() << " elements in the mesh.");
00117 }
00118
00119 if (!mUseNonConstantConductivities && !mUseFibreOrientation)
00120 {
00121 return mTensors[0];
00122 }
00123 else
00124 {
00125 unsigned local_index = mpMesh->SolveElementMapping(global_index);
00126 return mTensors[local_index];
00127 }
00128 }
00129
00131
00133
00134 template class AbstractConductivityTensors<1,1>;
00135 template class AbstractConductivityTensors<1,2>;
00136 template class AbstractConductivityTensors<1,3>;
00137 template class AbstractConductivityTensors<2,2>;
00138 template class AbstractConductivityTensors<2,3>;
00139 template class AbstractConductivityTensors<3,3>;