Chaste Commit::f841a6fa79bd6f7a205054452b95ddf6d10aae23
ExtendedBidomainAssembler.cpp
1/*
2
3Copyright (c) 2005-2026, 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 = prod(trans(rGradPhi), temp_1);
67
68 c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> temp_2 = prod(sigma_i_second_cell, rGradPhi);
69 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> grad_phi_sigma_i_second_cell_grad_phi = prod(trans(rGradPhi), temp_2);
70
71 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> basis_outer_prod = outer_prod(rPhi, rPhi);
72
73 c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> temp_ext = prod(sigma_e, rGradPhi);
74 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> grad_phi_sigma_e_grad_phi = prod(trans(rGradPhi), temp_ext);
75
76
77 c_matrix<double,3*(ELEMENT_DIM+1),3*(ELEMENT_DIM+1)> ret;
78
79 // first equation, first unknown
80 matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
81 slice100(ret, slice (0, 3, ELEMENT_DIM+1), slice (0, 3, ELEMENT_DIM+1));
82 slice100 = (Am1*Cm1/delta_t)*basis_outer_prod + grad_phi_sigma_i_first_cell_grad_phi;
83
84 // first equation, second unknown
85 matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
86 slice200(ret, slice (0, 3, ELEMENT_DIM+1), slice (1, 3, ELEMENT_DIM+1));
87 slice200 = zero_matrix<double>(ELEMENT_DIM+1, ELEMENT_DIM+1);
88
89 // first equation, third unknown
90 matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
91 slice300(ret, slice (0, 3, ELEMENT_DIM+1), slice (2, 3, ELEMENT_DIM+1));
92 slice300 = grad_phi_sigma_i_first_cell_grad_phi;
94 // second equation, first unknown
95 matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
96 slice010(ret, slice (1, 3, ELEMENT_DIM+1), slice (0, 3, ELEMENT_DIM+1));
97 slice010 = zero_matrix<double>(ELEMENT_DIM+1, ELEMENT_DIM+1);
98
99 // second equation, second unknown
100 matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
101 slice020(ret, slice (1, 3, ELEMENT_DIM+1), slice (1, 3, ELEMENT_DIM+1));
102 slice020 = (Am2*Cm2/delta_t)*basis_outer_prod + grad_phi_sigma_i_second_cell_grad_phi;
103
104 // second equation, third unknown
105 matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
106 slice030(ret, slice (1, 3, ELEMENT_DIM+1), slice (2, 3, ELEMENT_DIM+1));
107 slice030 = grad_phi_sigma_i_second_cell_grad_phi;
108
109 // third equation, first unknown
110 matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
111 slice001(ret, slice (2, 3, ELEMENT_DIM+1), slice (0, 3, ELEMENT_DIM+1));
112 slice001 = grad_phi_sigma_i_first_cell_grad_phi;
113
114 // third equation, second unknown
115 matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
116 slice002(ret, slice (2, 3, ELEMENT_DIM+1), slice (1, 3, ELEMENT_DIM+1));
117 slice002 = grad_phi_sigma_i_second_cell_grad_phi;
118
119 // third equation, third unknown
120 matrix_slice<c_matrix<double, 3*ELEMENT_DIM+3, 3*ELEMENT_DIM+3> >
121 slice003(ret, slice (2, 3, ELEMENT_DIM+1), slice (2, 3, ELEMENT_DIM+1));
122 slice003 = grad_phi_sigma_e_grad_phi + grad_phi_sigma_i_first_cell_grad_phi + grad_phi_sigma_i_second_cell_grad_phi;
123
124 return ret;
125}
126
127template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
131 : AbstractCardiacFeVolumeIntegralAssembler<ELEMENT_DIM,SPACE_DIM,3,true,true,NORMAL>(pMesh,pTissue),
132 mpExtendedBidomainTissue(pTissue)
133{
134 assert(pTissue != NULL);
135}
136
137template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
141
142// Explicit instantiation
143template class ExtendedBidomainAssembler<1,1>;
144template class ExtendedBidomainAssembler<2,2>;
145template 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()