Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
ExtendedBidomainAssembler.cpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, 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
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF 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
43template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
44c_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
131template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
135 : AbstractCardiacFeVolumeIntegralAssembler<ELEMENT_DIM,SPACE_DIM,3,true,true,NORMAL>(pMesh,pTissue),
136 mpExtendedBidomainTissue(pTissue)
137{
138 assert(pTissue != NULL);
139}
140
141template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
145
146// Explicit instantiation
147template class ExtendedBidomainAssembler<1,1>;
148template class ExtendedBidomainAssembler<2,2>;
149template class ExtendedBidomainAssembler<3,3>;
unsigned GetIndex() const
ExtendedBidomainAssembler(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh, ExtendedBidomainTissue< SPACE_DIM > *pTissue)
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()