SimpleDg0ParabolicAssemblerImplementation.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
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 #ifndef _SIMPLEDG0PARABOLICASSEMBLERIMPLEMENTATION_HPP_
00029 #define _SIMPLEDG0PARABOLICASSEMBLERIMPLEMENTATION_HPP_
00030 
00031 #include "SimpleDg0ParabolicAssembler.hpp"
00032 
00033 
00035 // Implementation
00037 
00038 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, bool NON_HEART, class CONCRETE>
00039 SimpleDg0ParabolicAssembler<ELEMENT_DIM, SPACE_DIM, NON_HEART, CONCRETE>::SimpleDg0ParabolicAssembler(
00040             AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* pMesh,
00041             AbstractLinearParabolicPde<ELEMENT_DIM,SPACE_DIM>* pPde,
00042             BoundaryConditionsContainer<ELEMENT_DIM,SPACE_DIM,1>* pBoundaryConditions,
00043             unsigned numQuadPoints)
00044     : AbstractAssembler<ELEMENT_DIM,SPACE_DIM,1>(),
00045       BaseClassType(numQuadPoints),
00046       AbstractDynamicAssemblerMixin<ELEMENT_DIM,SPACE_DIM,1>()
00047 {
00048     // note - we don't check any of these are NULL here (that is done in Solve() instead),
00049     // to allow the user or a subclass to set any of these later
00050     mpParabolicPde = pPde;
00051     this->SetMesh(pMesh);
00052     this->SetBoundaryConditionsContainer(pBoundaryConditions);
00053 
00054     // the solver could solve problems where the matrix is non-constant, but currently 
00055     // AbstractLinearParabolicPde can't be used to define such problems, so we will assume 
00056     // the matrix is constant. 
00057     this->SetMatrixIsConstant();    
00058 }
00059 
00060 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, bool NON_HEART, class CONCRETE>
00061 void SimpleDg0ParabolicAssembler<ELEMENT_DIM, SPACE_DIM, NON_HEART, CONCRETE>::PrepareForSolve()
00062 {
00063     BaseClassType::PrepareForSolve();
00064     assert(mpParabolicPde != NULL);
00065 }
00066 
00067 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, bool NON_HEART, class CONCRETE>
00068 Vec SimpleDg0ParabolicAssembler<ELEMENT_DIM, SPACE_DIM, NON_HEART, CONCRETE>::Solve(
00069             Vec currentSolutionOrGuess,
00070             double currentTime)
00071 {
00072     return AbstractDynamicAssemblerMixin<ELEMENT_DIM,SPACE_DIM,1>::Solve(currentSolutionOrGuess, currentTime);
00073 }
00074 
00075 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, bool NON_HEART, class CONCRETE>
00076 c_matrix<double,1*(ELEMENT_DIM+1),1*(ELEMENT_DIM+1)>
00077     SimpleDg0ParabolicAssembler<ELEMENT_DIM, SPACE_DIM, NON_HEART, CONCRETE>::ComputeMatrixTerm(
00078             c_vector<double, ELEMENT_DIM+1>& rPhi,
00079             c_matrix<double, SPACE_DIM, ELEMENT_DIM+1>& rGradPhi,
00080             ChastePoint<SPACE_DIM>& rX,
00081             c_vector<double,1>& rU,
00082             c_matrix<double,1,SPACE_DIM>& rGradU /* not used */,
00083             Element<ELEMENT_DIM,SPACE_DIM>* pElement)
00084 {
00085     c_matrix<double, SPACE_DIM, SPACE_DIM> pde_diffusion_term = mpParabolicPde->ComputeDiffusionTerm(rX, pElement);
00086 
00087     return    prod( trans(rGradPhi), c_matrix<double, SPACE_DIM, ELEMENT_DIM+1>(prod(pde_diffusion_term, rGradPhi)) )
00088               + this->mDtInverse * mpParabolicPde->ComputeDuDtCoefficientFunction(rX) * outer_prod(rPhi, rPhi);
00089 }
00090 
00091 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, bool NON_HEART, class CONCRETE>
00092 c_vector<double,1*(ELEMENT_DIM+1)>
00093     SimpleDg0ParabolicAssembler<ELEMENT_DIM, SPACE_DIM, NON_HEART, CONCRETE>::ComputeVectorTerm(
00094             c_vector<double, ELEMENT_DIM+1>& rPhi,
00095             c_matrix<double, SPACE_DIM, ELEMENT_DIM+1>& rGradPhi,
00096             ChastePoint<SPACE_DIM>& rX,
00097             c_vector<double,1>& rU,
00098             c_matrix<double, 1, SPACE_DIM>& rGradU /* not used */,
00099             Element<ELEMENT_DIM,SPACE_DIM>* pElement)
00100 
00101 {
00102     return (mpParabolicPde->ComputeNonlinearSourceTerm(rX, rU(0)) + mpParabolicPde->ComputeLinearSourceTerm(rX)
00103             + this->mDtInverse * mpParabolicPde->ComputeDuDtCoefficientFunction(rX) * rU(0)) * rPhi;
00104 }
00105 
00106 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, bool NON_HEART, class CONCRETE>
00107 c_vector<double, ELEMENT_DIM>
00108     SimpleDg0ParabolicAssembler<ELEMENT_DIM, SPACE_DIM, NON_HEART, CONCRETE>::ComputeVectorSurfaceTerm(
00109             const BoundaryElement<ELEMENT_DIM-1,SPACE_DIM>& rSurfaceElement,
00110             c_vector<double, ELEMENT_DIM>& rPhi,
00111             ChastePoint<SPACE_DIM>& rX)
00112 {
00113     // D_times_gradu_dot_n = [D grad(u)].n, D=diffusion matrix
00114     double D_times_gradu_dot_n = this->mpBoundaryConditions->GetNeumannBCValue(&rSurfaceElement, rX);
00115     return rPhi * D_times_gradu_dot_n;
00116 }
00117 
00118 
00119 #endif //_SIMPLEDG0PARABOLICASSEMBLERIMPLEMENTATION_HPP_

Generated on Tue Aug 4 16:10:24 2009 for Chaste by  doxygen 1.5.5