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             AbstractMesh<ELEMENT_DIM,SPACE_DIM>* pMesh,
00041             AbstractLinearParabolicPde<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     this->SetMatrixIsConstant();
00055 }
00056 
00057 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, bool NON_HEART, class CONCRETE>
00058 void SimpleDg0ParabolicAssembler<ELEMENT_DIM, SPACE_DIM, NON_HEART, CONCRETE>::PrepareForSolve()
00059 {
00060     BaseClassType::PrepareForSolve();
00061     assert(mpParabolicPde != NULL);
00062 }
00063 
00064 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, bool NON_HEART, class CONCRETE>
00065 Vec SimpleDg0ParabolicAssembler<ELEMENT_DIM, SPACE_DIM, NON_HEART, CONCRETE>::Solve(
00066             Vec currentSolutionOrGuess,
00067             double currentTime)
00068 {
00069     return AbstractDynamicAssemblerMixin<ELEMENT_DIM,SPACE_DIM,1>::Solve(currentSolutionOrGuess, currentTime);
00070 }
00071 
00072 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, bool NON_HEART, class CONCRETE>
00073 c_matrix<double,1*(ELEMENT_DIM+1),1*(ELEMENT_DIM+1)>
00074     SimpleDg0ParabolicAssembler<ELEMENT_DIM, SPACE_DIM, NON_HEART, CONCRETE>::ComputeMatrixTerm(
00075             c_vector<double, ELEMENT_DIM+1> &rPhi,
00076             c_matrix<double, ELEMENT_DIM, ELEMENT_DIM+1> &rGradPhi,
00077             ChastePoint<SPACE_DIM> &rX,
00078             c_vector<double,1> &u,
00079             c_matrix<double,1,SPACE_DIM> &rGradU /* not used */,
00080             Element<ELEMENT_DIM,SPACE_DIM>* pElement)
00081 {
00082     c_matrix<double, ELEMENT_DIM, ELEMENT_DIM> pde_diffusion_term = mpParabolicPde->ComputeDiffusionTerm(rX, pElement);
00083 
00084     return    prod( trans(rGradPhi), c_matrix<double, ELEMENT_DIM, ELEMENT_DIM+1>(prod(pde_diffusion_term, rGradPhi)) )
00085               + this->mDtInverse * mpParabolicPde->ComputeDuDtCoefficientFunction(rX) * outer_prod(rPhi, rPhi);
00086 }
00087 
00088 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, bool NON_HEART, class CONCRETE>
00089 c_vector<double,1*(ELEMENT_DIM+1)>
00090     SimpleDg0ParabolicAssembler<ELEMENT_DIM, SPACE_DIM, NON_HEART, CONCRETE>::ComputeVectorTerm(
00091             c_vector<double, ELEMENT_DIM+1> &rPhi,
00092             c_matrix<double, ELEMENT_DIM, ELEMENT_DIM+1> &rGradPhi,
00093             ChastePoint<SPACE_DIM> &rX,
00094             c_vector<double,1> &u,
00095             c_matrix<double, 1, SPACE_DIM> &rGradU /* not used */,
00096             Element<ELEMENT_DIM,SPACE_DIM>* pElement)
00097 
00098 {
00099     return (mpParabolicPde->ComputeNonlinearSourceTerm(rX, u(0)) + mpParabolicPde->ComputeLinearSourceTerm(rX)
00100             + this->mDtInverse * mpParabolicPde->ComputeDuDtCoefficientFunction(rX) * u(0)) * rPhi;
00101 }
00102 
00103 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, bool NON_HEART, class CONCRETE>
00104 c_vector<double, ELEMENT_DIM>
00105     SimpleDg0ParabolicAssembler<ELEMENT_DIM, SPACE_DIM, NON_HEART, CONCRETE>::ComputeVectorSurfaceTerm(
00106             const BoundaryElement<ELEMENT_DIM-1,SPACE_DIM> &rSurfaceElement,
00107             c_vector<double, ELEMENT_DIM> &rPhi,
00108             ChastePoint<SPACE_DIM> &rX )
00109 {
00110     // D_times_gradu_dot_n = [D grad(u)].n, D=diffusion matrix
00111     double D_times_gradu_dot_n = this->mpBoundaryConditions->GetNeumannBCValue(&rSurfaceElement, rX);
00112     return rPhi * D_times_gradu_dot_n;
00113 }
00114 
00115 
00116 #endif //_SIMPLEDG0PARABOLICASSEMBLERIMPLEMENTATION_HPP_

Generated on Wed Mar 18 12:51:56 2009 for Chaste by  doxygen 1.5.5