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 #ifndef MONODOMAINASSEMBLER_CPP_
00030 #define MONODOMAINASSEMBLER_CPP_
00031
00032 #include "MonodomainAssembler.hpp"
00033
00034 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00035 c_matrix<double,1*(ELEMENT_DIM+1),1*(ELEMENT_DIM+1)> MonodomainAssembler<ELEMENT_DIM,SPACE_DIM>::ComputeMatrixTerm(
00036 c_vector<double, ELEMENT_DIM+1> &rPhi,
00037 c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> &rGradPhi,
00038 ChastePoint<SPACE_DIM> &rX,
00039 c_vector<double,1> &rU,
00040 c_matrix<double, 1, SPACE_DIM> &rGradU ,
00041 Element<ELEMENT_DIM,SPACE_DIM>* pElement)
00042 {
00043
00044 double Am = mpConfig->GetSurfaceAreaToVolumeRatio();
00045 double Cm = mpConfig->GetCapacitance();
00046
00047 const c_matrix<double, SPACE_DIM, SPACE_DIM>& sigma_i = mpMonodomainTissue->rGetIntracellularConductivityTensor(pElement->GetIndex());
00048
00049 c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> temp = prod(sigma_i, rGradPhi);
00050 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> grad_phi_sigma_i_grad_phi =
00051 prod(trans(rGradPhi), temp);
00052
00053 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> basis_outer_prod =
00054 outer_prod(rPhi, rPhi);
00055
00056 return (Am*Cm/this->mDt)*basis_outer_prod + grad_phi_sigma_i_grad_phi;
00057 }
00058
00059
00060
00061 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00062 c_vector<double,1*(ELEMENT_DIM+1)> MonodomainAssembler<ELEMENT_DIM,SPACE_DIM>::ComputeVectorTerm(
00063 c_vector<double, ELEMENT_DIM+1> &rPhi,
00064 c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> &rGradPhi ,
00065 ChastePoint<SPACE_DIM> &rX ,
00066 c_vector<double,1> &rU,
00067 c_matrix<double, 1, SPACE_DIM> &rGradU ,
00068 Element<ELEMENT_DIM,SPACE_DIM>* pElement )
00069 {
00070 double Am = mpConfig->GetSurfaceAreaToVolumeRatio();
00071 double Cm = mpConfig->GetCapacitance();
00072
00073 return rPhi * (Am*Cm*rU(0)/mDt - Am*mIionic - mIIntracellularStimulus);
00074 }
00075
00076
00077
00078 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00079 c_vector<double, ELEMENT_DIM> MonodomainAssembler<ELEMENT_DIM,SPACE_DIM>::ComputeVectorSurfaceTerm(
00080 const BoundaryElement<ELEMENT_DIM-1,SPACE_DIM>& rSurfaceElement,
00081 c_vector<double, ELEMENT_DIM>& rPhi,
00082 ChastePoint<SPACE_DIM>& rX)
00083 {
00084
00085 double D_times_gradu_dot_n = this->mpBoundaryConditions->GetNeumannBCValue(&rSurfaceElement, rX);
00086 return rPhi * D_times_gradu_dot_n;
00087 }
00088
00089
00090 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00091 void MonodomainAssembler<ELEMENT_DIM,SPACE_DIM>::IncrementInterpolatedQuantities(double phiI, const Node<SPACE_DIM>* pNode)
00092 {
00093 unsigned node_global_index = pNode->GetIndex();
00094 mIionic += phiI * mpMonodomainTissue->rGetIionicCacheReplicated()[ node_global_index ];
00095 mIIntracellularStimulus += phiI * mpMonodomainTissue->rGetIntracellularStimulusCacheReplicated()[ node_global_index ];
00096 }
00097
00098 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00099 MonodomainAssembler<ELEMENT_DIM,SPACE_DIM>::MonodomainAssembler(
00100 AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* pMesh,
00101 MonodomainTissue<ELEMENT_DIM,SPACE_DIM>* pTissue,
00102 double dt,
00103 unsigned numQuadPoints)
00104 : AbstractFeObjectAssembler<ELEMENT_DIM,SPACE_DIM,1,true,true,CARDIAC>(pMesh,numQuadPoints),
00105 mpMonodomainTissue(pTissue),
00106 mDt(dt)
00107 {
00108 assert(pTissue);
00109 assert(dt>0);
00110 mpConfig = HeartConfig::Instance();
00111 }
00112
00113
00114
00116
00118
00119
00120 template class MonodomainAssembler<1,1>;
00121 template class MonodomainAssembler<1,2>;
00122 template class MonodomainAssembler<1,3>;
00123 template class MonodomainAssembler<2,2>;
00124 template class MonodomainAssembler<3,3>;
00125
00126 #endif