Chaste  Release::3.4
ExtendedBidomainAssembler.cpp
1 /*
2 
3 Copyright (c) 2005-2016, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 #include "ExtendedBidomainAssembler.hpp"
37 
38 #include "Exception.hpp"
39 #include "DistributedVector.hpp"
40 #include "PdeSimulationTime.hpp"
41 #include "ConstBoundaryCondition.hpp"
42 
43 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
44 c_matrix<double,3*(ELEMENT_DIM+1),3*(ELEMENT_DIM+1)>
46  c_vector<double, ELEMENT_DIM+1> &rPhi,
47  c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> &rGradPhi,
49  c_vector<double,3> &rU,
50  c_matrix<double, 3, SPACE_DIM> &rGradU /* not used */,
52 {
53  // get bidomain parameters
54  double Am1 = mpExtendedBidomainTissue->GetAmFirstCell();
55  double Am2 = mpExtendedBidomainTissue->GetAmSecondCell();
56  double Cm1 = mpExtendedBidomainTissue->GetCmFirstCell();
57  double Cm2 = mpExtendedBidomainTissue->GetCmSecondCell();
58 
59  const c_matrix<double, SPACE_DIM, SPACE_DIM>& sigma_i_first_cell = mpExtendedBidomainTissue->rGetIntracellularConductivityTensor(pElement->GetIndex());
60  const c_matrix<double, SPACE_DIM, SPACE_DIM>& sigma_i_second_cell = mpExtendedBidomainTissue->rGetIntracellularConductivityTensorSecondCell(pElement->GetIndex());
61  const c_matrix<double, SPACE_DIM, SPACE_DIM>& sigma_e = mpExtendedBidomainTissue->rGetExtracellularConductivityTensor(pElement->GetIndex());
62 
63  double delta_t = PdeSimulationTime::GetPdeTimeStep();
64 
65  c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> temp_1 = prod(sigma_i_first_cell, rGradPhi);
66  c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> grad_phi_sigma_i_first_cell_grad_phi =
67  prod(trans(rGradPhi), temp_1);
68 
69  c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> temp_2 = prod(sigma_i_second_cell, rGradPhi);
70  c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> grad_phi_sigma_i_second_cell_grad_phi =
71  prod(trans(rGradPhi), temp_2);
72 
73  c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> basis_outer_prod =
74  outer_prod(rPhi, rPhi);
75 
76  c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> temp_ext = prod(sigma_e, rGradPhi);
77  c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> grad_phi_sigma_e_grad_phi =
78  prod(trans(rGradPhi), temp_ext);
79 
80 
81  c_matrix<double,3*(ELEMENT_DIM+1),3*(ELEMENT_DIM+1)> ret;
82 
83  // first equation, first unknown
84  matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
85  slice100(ret, slice (0, 3, ELEMENT_DIM+1), slice (0, 3, ELEMENT_DIM+1));
86  slice100 = (Am1*Cm1/delta_t)*basis_outer_prod + grad_phi_sigma_i_first_cell_grad_phi;
87 
88  // first equation, second unknown
89  matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
90  slice200(ret, slice (0, 3, ELEMENT_DIM+1), slice (1, 3, ELEMENT_DIM+1));
91  slice200 = zero_matrix<double>(ELEMENT_DIM+1, ELEMENT_DIM+1);
92 
93  // first equation, third unknown
94  matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
95  slice300(ret, slice (0, 3, ELEMENT_DIM+1), slice (2, 3, ELEMENT_DIM+1));
96  slice300 = grad_phi_sigma_i_first_cell_grad_phi;
97 
98  // second equation, first unknown
99  matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
100  slice010(ret, slice (1, 3, ELEMENT_DIM+1), slice (0, 3, ELEMENT_DIM+1));
101  slice010 = zero_matrix<double>(ELEMENT_DIM+1, ELEMENT_DIM+1);
102 
103  // second equation, second unknown
104  matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
105  slice020(ret, slice (1, 3, ELEMENT_DIM+1), slice (1, 3, ELEMENT_DIM+1));
106  slice020 = (Am2*Cm2/delta_t)*basis_outer_prod + grad_phi_sigma_i_second_cell_grad_phi;
107 
108  // second equation, third unknown
109  matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
110  slice030(ret, slice (1, 3, ELEMENT_DIM+1), slice (2, 3, ELEMENT_DIM+1));
111  slice030 = grad_phi_sigma_i_second_cell_grad_phi;
112 
113  // third equation, first unknown
114  matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
115  slice001(ret, slice (2, 3, ELEMENT_DIM+1), slice (0, 3, ELEMENT_DIM+1));
116  slice001 = grad_phi_sigma_i_first_cell_grad_phi;
117 
118  // third equation, second unknown
119  matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
120  slice002(ret, slice (2, 3, ELEMENT_DIM+1), slice (1, 3, ELEMENT_DIM+1));
121  slice002 = grad_phi_sigma_i_second_cell_grad_phi;
122 
123  // third equation, third unknown
124  matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
125  slice003(ret, slice (2, 3, ELEMENT_DIM+1), slice (2, 3, ELEMENT_DIM+1));
126  slice003 = grad_phi_sigma_e_grad_phi + grad_phi_sigma_i_first_cell_grad_phi + grad_phi_sigma_i_second_cell_grad_phi;
127 
128  return ret;
129 }
130 
131 
132 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
136  : AbstractCardiacFeVolumeIntegralAssembler<ELEMENT_DIM,SPACE_DIM,3,true,true,NORMAL>(pMesh,pTissue),
137  mpExtendedBidomainTissue(pTissue)
138 {
139  assert(pTissue != NULL);
140 }
141 
142 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
144 {
145 }
146 
148 // Explicit instantiation
150 
151 template class ExtendedBidomainAssembler<1,1>;
152 template class ExtendedBidomainAssembler<2,2>;
153 template class ExtendedBidomainAssembler<3,3>;
virtual c_matrix< double, 3 *(ELEMENT_DIM+1), 3 *(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, 3 > &rU, c_matrix< double, 3, SPACE_DIM > &rGradU, Element< ELEMENT_DIM, SPACE_DIM > *pElement)
static double GetPdeTimeStep()
unsigned GetIndex() const
ExtendedBidomainAssembler(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh, ExtendedBidomainTissue< SPACE_DIM > *pTissue)