AbstractFeAssemblerCommon.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
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 
00029 #ifndef ABSTRACTFEASSEMBLERCOMMON_HPP_
00030 #define ABSTRACTFEASSEMBLERCOMMON_HPP_
00031 
00032 #include "AbstractFeAssemblerInterface.hpp"
00033 #include "ReplicatableVector.hpp"
00034 #include "DistributedVector.hpp"
00035 #include "HeartEventHandler.hpp"
00036 #include "LinearBasisFunction.hpp"
00037 #include "PetscTools.hpp"
00038 #include "AbstractTetrahedralMesh.hpp"
00039 
00049 typedef enum InterpolationLevel_
00050 {
00051     CARDIAC = 0,
00052     NORMAL,
00053     NONLINEAR
00054 } InterpolationLevel;
00055 
00056 
00057 
00067 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM, bool CAN_ASSEMBLE_VECTOR, bool CAN_ASSEMBLE_MATRIX, InterpolationLevel INTERPOLATION_LEVEL>
00068 class AbstractFeAssemblerCommon : public AbstractFeAssemblerInterface<CAN_ASSEMBLE_VECTOR,CAN_ASSEMBLE_MATRIX>
00069 {
00070 protected:
00075     ReplicatableVector mCurrentSolutionOrGuessReplicated;
00076 
00083     virtual double GetCurrentSolutionOrGuessValue(unsigned nodeIndex, unsigned indexOfUnknown)
00084     {
00085         return mCurrentSolutionOrGuessReplicated[ PROBLEM_DIM*nodeIndex + indexOfUnknown];
00086     }
00087 
00093     virtual void ResetInterpolatedQuantities()
00094     {}
00095 
00104     virtual void IncrementInterpolatedQuantities(double phiI, const Node<SPACE_DIM>* pNode)
00105     {}
00106 public:
00107 
00111     AbstractFeAssemblerCommon();
00112 
00119     void SetCurrentSolution(Vec currentSolution);
00120 
00124     virtual ~AbstractFeAssemblerCommon()
00125     {
00126     }
00127 };
00128 
00129 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM, bool CAN_ASSEMBLE_VECTOR, bool CAN_ASSEMBLE_MATRIX, InterpolationLevel INTERPOLATION_LEVEL>
00130 AbstractFeAssemblerCommon<ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CAN_ASSEMBLE_VECTOR, CAN_ASSEMBLE_MATRIX, INTERPOLATION_LEVEL>::AbstractFeAssemblerCommon()
00131     : AbstractFeAssemblerInterface<CAN_ASSEMBLE_VECTOR,CAN_ASSEMBLE_MATRIX>()
00132 {
00133 }
00134 
00135 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM, bool CAN_ASSEMBLE_VECTOR, bool CAN_ASSEMBLE_MATRIX, InterpolationLevel INTERPOLATION_LEVEL>
00136 void AbstractFeAssemblerCommon<ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CAN_ASSEMBLE_VECTOR, CAN_ASSEMBLE_MATRIX, INTERPOLATION_LEVEL>::SetCurrentSolution(Vec currentSolution)
00137 {
00138     assert(currentSolution != NULL);
00139 
00140     // Replicate the current solution and store so can be used in AssembleOnElement
00141     HeartEventHandler::BeginEvent(HeartEventHandler::COMMUNICATION);
00142     mCurrentSolutionOrGuessReplicated.ReplicatePetscVector(currentSolution);
00143     HeartEventHandler::EndEvent(HeartEventHandler::COMMUNICATION);
00144 
00145     // The AssembleOnElement type methods will determine if a current solution or
00146     // current guess exists by looking at the size of the replicated vector, so
00147     // check the size is zero if there isn't a current solution.
00148     assert(mCurrentSolutionOrGuessReplicated.GetSize() > 0);
00149 }
00150 
00151 
00152 #endif /* ABSTRACTFEASSEMBLERCOMMON_HPP_ */
Generated on Thu Dec 22 13:00:17 2011 for Chaste by  doxygen 1.6.3