MonodomainAssembler.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
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 /* not used */,
00041                 Element<ELEMENT_DIM,SPACE_DIM>* pElement)
00042 {
00043     // get bidomain parameters
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 /* not used */,
00065         ChastePoint<SPACE_DIM> &rX /* not used */,
00066         c_vector<double,1> &rU,
00067         c_matrix<double, 1, SPACE_DIM> &rGradU /* not used */,
00068         Element<ELEMENT_DIM,SPACE_DIM>* pElement /* not used */)
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     // D_times_gradu_dot_n = [D grad(u)].n, D=diffusion matrix
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 // explicit instantiation
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 /*MONODOMAINASSEMBLER_CPP_*/

Generated on Mon Nov 1 12:35:17 2010 for Chaste by  doxygen 1.5.5