38 #include "AxisymmetricConductivityTensors.hpp"
42 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
47 EXCEPTION(
"Axisymmetric anisotropic conductivity only makes sense in 3D");
51 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
55 if (constantConductivities[1] != constantConductivities[2])
57 EXCEPTION(
"Axisymmetric media defined: transversal and normal conductivities should have the same value");
60 this->mUseNonConstantConductivities =
false;
61 this->mConstantConductivities = constantConductivities;
64 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
69 if (!this->mUseNonConstantConductivities && !this->mUseFibreOrientation)
72 c_matrix<double, SPACE_DIM, SPACE_DIM> conductivity_matrix(zero_matrix<double>(SPACE_DIM,SPACE_DIM));
74 for (
unsigned dim=0; dim<SPACE_DIM; dim++)
76 assert(this->mConstantConductivities(dim) != DBL_MAX);
77 conductivity_matrix(dim,dim) = this->mConstantConductivities(dim);
79 this->mTensors.push_back(conductivity_matrix);
83 c_vector<double,SPACE_DIM> fibre_vector((zero_vector<double>(SPACE_DIM)));
86 if (this->mUseFibreOrientation)
90 if(this->mFileReader->GetNumLinesOfData() != this->mpMesh->GetNumElements())
92 EXCEPTION(
"The size of the fibre file does not match the number of elements in the mesh");
96 if (this->mUseNonConstantConductivities)
98 if(this->mpNonConstantConductivities->size() != this->mpMesh->GetNumLocalElements())
100 EXCEPTION(
"The size of the conductivities vector does not match the number of elements in the mesh");
106 this->mTensors.reserve(this->mpMesh->GetNumLocalElements());
108 c_matrix<double, SPACE_DIM, SPACE_DIM> conductivity_matrix(zero_matrix<double>(SPACE_DIM,SPACE_DIM));
110 unsigned local_element_index = 0;
113 it != this->mpMesh->GetElementIteratorEnd();
141 if (this->mUseNonConstantConductivities)
143 for (
unsigned dim=0; dim<SPACE_DIM; dim++)
145 conductivity_matrix(dim,dim) = (*this->mpNonConstantConductivities)[local_element_index][dim];
150 for (
unsigned dim=0; dim<SPACE_DIM; dim++)
152 assert(this->mConstantConductivities(dim) != DBL_MAX);
153 conductivity_matrix(dim,dim) = this->mConstantConductivities(dim);
157 if (this->mUseFibreOrientation)
159 unsigned current_fibre_global_index = it->GetIndex();
160 this->mFileReader->GetFibreVector(current_fibre_global_index, fibre_vector);
163 this->mTensors.push_back( conductivity_matrix(1,1) * identity_matrix<double>(SPACE_DIM) +
164 (conductivity_matrix(0,0) - conductivity_matrix(1,1)) * outer_prod(fibre_vector,fibre_vector));
166 local_element_index++;
169 assert(this->mTensors.size() == this->mpMesh->GetNumLocalElements());
170 assert(this->mTensors.size() == local_element_index);
172 if (this->mUseFibreOrientation)
175 this->mFileReader.reset();
179 this->mInitialised =
true;
#define EXCEPTION(message)
AxisymmetricConductivityTensors()
void SetConstantConductivities(c_vector< double, 3 > constantConductivities)
void Init(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)