Chaste  Release::2017.1
BidomainAssembler.cpp
1 
2 /*
3 
4 Copyright (c) 2005-2017, University of Oxford.
5 All rights reserved.
6 
7 University of Oxford means the Chancellor, Masters and Scholars of the
8 University of Oxford, having an administrative office at Wellington
9 Square, Oxford OX1 2JD, UK.
10 
11 This file is part of Chaste.
12 
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright notice,
16  this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright notice,
18  this list of conditions and the following disclaimer in the documentation
19  and/or other materials provided with the distribution.
20  * Neither the name of the University of Oxford nor the names of its
21  contributors may be used to endorse or promote products derived from this
22  software without specific prior written permission.
23 
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
30 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 
35 */
36 
37 #include "BidomainAssembler.hpp"
38 #include "PdeSimulationTime.hpp"
39 #include "UblasIncludes.hpp"
40 
41 
42 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
43 c_matrix<double,2*(ELEMENT_DIM+1),2*(ELEMENT_DIM+1)>
45  c_vector<double, ELEMENT_DIM+1> &rPhi,
46  c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> &rGradPhi,
48  c_vector<double,2> &rU,
49  c_matrix<double, 2, SPACE_DIM> &rGradU /* not used */,
51 {
52  // get bidomain parameters
53  double Am = this->mpConfig->GetSurfaceAreaToVolumeRatio();
54  double Cm = this->mpConfig->GetCapacitance();
55 
56  const c_matrix<double, SPACE_DIM, SPACE_DIM>& sigma_i = this->mpCardiacTissue->rGetIntracellularConductivityTensor(pElement->GetIndex());
57  const c_matrix<double, SPACE_DIM, SPACE_DIM>& sigma_e = this->mpCardiacTissue->rGetExtracellularConductivityTensor(pElement->GetIndex());
58 
59 
60  c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> temp = prod(sigma_i, rGradPhi);
61  c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> grad_phi_sigma_i_grad_phi =
62  prod(trans(rGradPhi), temp);
63 
64  c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> basis_outer_prod =
65  outer_prod(rPhi, rPhi);
66 
67  c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> temp2 = prod(sigma_e, rGradPhi);
68  c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> grad_phi_sigma_e_grad_phi =
69  prod(trans(rGradPhi), temp2);
70 
71 
72  c_matrix<double,2*(ELEMENT_DIM+1),2*(ELEMENT_DIM+1)> ret;
73 
74  // even rows, even columns
75  matrix_slice<c_matrix<double, 2*ELEMENT_DIM+2, 2*ELEMENT_DIM+2> >
76  slice00(ret, slice (0, 2, ELEMENT_DIM+1), slice (0, 2, ELEMENT_DIM+1));
77  slice00 = (Am*Cm*PdeSimulationTime::GetPdeTimeStepInverse())*basis_outer_prod + grad_phi_sigma_i_grad_phi;
78 
79  // odd rows, even columns
80  matrix_slice<c_matrix<double, 2*ELEMENT_DIM+2, 2*ELEMENT_DIM+2> >
81  slice10(ret, slice (1, 2, ELEMENT_DIM+1), slice (0, 2, ELEMENT_DIM+1));
82  slice10 = grad_phi_sigma_i_grad_phi;
83 
84  // even rows, odd columns
85  matrix_slice<c_matrix<double, 2*ELEMENT_DIM+2, 2*ELEMENT_DIM+2> >
86  slice01(ret, slice (0, 2, ELEMENT_DIM+1), slice (1, 2, ELEMENT_DIM+1));
87  slice01 = grad_phi_sigma_i_grad_phi;
88 
89  // odd rows, odd columns
90  matrix_slice<c_matrix<double, 2*ELEMENT_DIM+2, 2*ELEMENT_DIM+2> >
91  slice11(ret, slice (1, 2, ELEMENT_DIM+1), slice (1, 2, ELEMENT_DIM+1));
92  slice11 = grad_phi_sigma_i_grad_phi + grad_phi_sigma_e_grad_phi;
93 
94  return ret;
95 }
96 
97 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
100  BidomainTissue<SPACE_DIM>* pTissue)
101  : AbstractCardiacFeVolumeIntegralAssembler<ELEMENT_DIM,SPACE_DIM,2,false,true,CARDIAC>(pMesh,pTissue)
102 {
103  assert(pTissue != NULL);
104 }
105 
106 // Explicit instantiation
107 template class BidomainAssembler<1,1>;
108 template class BidomainAssembler<2,2>;
109 template class BidomainAssembler<3,3>;
virtual c_matrix< double, 2 *(ELEMENT_DIM+1), 2 *(ELEMENT_DIM+1)> ComputeMatrixTerm(c_vector< double, ELEMENT_DIM+1 > &rPhi, c_matrix< double, SPACE_DIM, ELEMENT_DIM+1 > &rGradPhi, ChastePoint< SPACE_DIM > &rX, c_vector< double, 2 > &rU, c_matrix< double, 2, SPACE_DIM > &rGradU, Element< ELEMENT_DIM, SPACE_DIM > *pElement)
BidomainAssembler(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh, BidomainTissue< SPACE_DIM > *pTissue)
static double GetPdeTimeStepInverse()
unsigned GetIndex() const