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