BoundaryConditionsContainer.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 _BOUNDARYCONDITIONSCONTAINER_HPP_
00029 #define _BOUNDARYCONDITIONSCONTAINER_HPP_
00030 
00031 #include <map>
00032 
00033 #include "AbstractBoundaryConditionsContainer.hpp"
00034 #include "AbstractBoundaryCondition.hpp"
00035 #include "AbstractMesh.hpp"
00036 #include "BoundaryElement.hpp"
00037 #include "Node.hpp"
00038 #include "LinearSystem.hpp"
00039 #include "PetscException.hpp"
00040 #include "ChastePoint.hpp"
00041 #include "ConstBoundaryCondition.hpp"
00042 
00043 
00057 template<unsigned ELEM_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM>
00058 class BoundaryConditionsContainer : public AbstractBoundaryConditionsContainer<ELEM_DIM,SPACE_DIM,PROBLEM_DIM>
00059 {
00060 public:
00062     typedef typename std::map< const BoundaryElement<ELEM_DIM-1, SPACE_DIM> *,  const AbstractBoundaryCondition<SPACE_DIM>* >::const_iterator
00063         NeumannMapIterator;
00064 
00065 private:
00066 
00067     std::map< const BoundaryElement<ELEM_DIM-1, SPACE_DIM> *,  const AbstractBoundaryCondition<SPACE_DIM>* >
00068         *mpNeumannMap[PROBLEM_DIM]; 
00070     NeumannMapIterator mLastNeumannCondition[PROBLEM_DIM];
00071 
00072     bool mAnyNonZeroNeumannConditionsForUnknown[PROBLEM_DIM];
00073     
00075     ConstBoundaryCondition<SPACE_DIM>* mpZeroBoundaryCondition;
00076 
00077 public:
00078 
00083     BoundaryConditionsContainer();
00084 
00089     ~BoundaryConditionsContainer();
00090 
00101     void AddDirichletBoundaryCondition( const Node<SPACE_DIM> *  pBoundaryNode,
00102                                         const AbstractBoundaryCondition<SPACE_DIM> * pBoundaryCondition,
00103                                         unsigned indexOfUnknown=0,
00104                                         bool checkIfBoundaryNode = true);
00105 
00106 
00124     void AddNeumannBoundaryCondition( const BoundaryElement<ELEM_DIM-1, SPACE_DIM> * pBoundaryElement,
00125                                       const AbstractBoundaryCondition<SPACE_DIM> * pBoundaryCondition,
00126                                       unsigned indexOfUnknown = 0);
00127 
00128 
00135     void DefineZeroDirichletOnMeshBoundary(AbstractMesh<ELEM_DIM,SPACE_DIM>* pMesh,
00136                                            unsigned indexOfUnknown = 0);
00137 
00145     void DefineConstantDirichletOnMeshBoundary(AbstractMesh<ELEM_DIM,SPACE_DIM>* pMesh,
00146                                                double value,
00147                                                unsigned indexOfUnknown = 0);
00148 
00149 
00156     void DefineZeroNeumannOnMeshBoundary(AbstractMesh<ELEM_DIM,SPACE_DIM>* pMesh,
00157                                          unsigned indexOfUnknown = 0);
00158 
00159 
00160 
00174     void ApplyDirichletToLinearProblem(LinearSystem& rLinearSystem,
00175                                        bool applyToMatrix = true );
00176 
00186     void ApplyDirichletToNonlinearResidual(const Vec currentSolution, Vec residual);
00187 
00197     void ApplyDirichletToNonlinearJacobian(Mat jacobian);
00198 
00199 
00213     bool Validate(AbstractMesh<ELEM_DIM,SPACE_DIM> *pMesh);
00214 
00215 
00221     double GetNeumannBCValue(const BoundaryElement<ELEM_DIM-1,SPACE_DIM>* pSurfaceElement,
00222                              const ChastePoint<SPACE_DIM>& x,
00223                              unsigned indexOfUnknown = 0);
00224 
00232     bool HasNeumannBoundaryCondition(const BoundaryElement<ELEM_DIM-1,SPACE_DIM>* pSurfaceElement,
00233                                      unsigned indexOfUnknown = 0);
00234 
00235 
00236     bool AnyNonZeroNeumannConditions();
00237 
00238     NeumannMapIterator BeginNeumann();
00239 
00240     NeumannMapIterator EndNeumann();
00241 };
00242 
00243 
00244 #endif //_BOUNDARYCONDITIONSCONTAINER_HPP_

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