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 "AbstractTetrahedralMesh.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 #include "DistributedVectorFactory.hpp"
00043 
00044 
00056 template<unsigned ELEM_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM>
00057 class BoundaryConditionsContainer : public AbstractBoundaryConditionsContainer<ELEM_DIM,SPACE_DIM,PROBLEM_DIM>
00058 {
00059 public:
00060 
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]; 
00073     NeumannMapIterator mLastNeumannCondition[PROBLEM_DIM];
00074 
00078     bool mAnyNonZeroNeumannConditionsForUnknown[PROBLEM_DIM];
00079 
00081     ConstBoundaryCondition<SPACE_DIM> *mpZeroBoundaryCondition;
00082 
00083 public:
00084 
00089     BoundaryConditionsContainer();
00090 
00095     ~BoundaryConditionsContainer();
00096 
00109     void AddDirichletBoundaryCondition(const Node<SPACE_DIM>* pBoundaryNode,
00110                                        const AbstractBoundaryCondition<SPACE_DIM>* pBoundaryCondition,
00111                                        unsigned indexOfUnknown = 0,
00112                                        bool checkIfBoundaryNode = true);
00113 
00132     void AddNeumannBoundaryCondition(const BoundaryElement<ELEM_DIM-1, SPACE_DIM>* pBoundaryElement,
00133                                      const AbstractBoundaryCondition<SPACE_DIM>* pBoundaryCondition,
00134                                      unsigned indexOfUnknown = 0);
00135 
00143     void DefineZeroDirichletOnMeshBoundary(AbstractTetrahedralMesh<ELEM_DIM,SPACE_DIM>* pMesh,
00144                                            unsigned indexOfUnknown = 0);
00145 
00154     void DefineConstantDirichletOnMeshBoundary(AbstractTetrahedralMesh<ELEM_DIM,SPACE_DIM>* pMesh,
00155                                                double value,
00156                                                unsigned indexOfUnknown = 0);
00157 
00165     void DefineZeroNeumannOnMeshBoundary(AbstractTetrahedralMesh<ELEM_DIM,SPACE_DIM>* pMesh,
00166                                          unsigned indexOfUnknown = 0);
00167 
00181     void ApplyDirichletToLinearProblem(LinearSystem& rLinearSystem,
00182                                        bool applyToMatrix = true);
00183 
00196     void ApplyDirichletToNonlinearResidual(const Vec currentSolution, Vec residual,
00197                                            DistributedVectorFactory& rFactory);
00198 
00209     void ApplyDirichletToNonlinearJacobian(Mat jacobian);
00210 
00224     bool Validate(AbstractTetrahedralMesh<ELEM_DIM,SPACE_DIM>* pMesh);
00225 
00235     double GetNeumannBCValue(const BoundaryElement<ELEM_DIM-1,SPACE_DIM>* pSurfaceElement,
00236                              const ChastePoint<SPACE_DIM>& rX,
00237                              unsigned indexOfUnknown = 0);
00238 
00249     bool HasNeumannBoundaryCondition(const BoundaryElement<ELEM_DIM-1,SPACE_DIM>* pSurfaceElement,
00250                                      unsigned indexOfUnknown = 0);
00251 
00255     bool AnyNonZeroNeumannConditions();
00256 
00260     NeumannMapIterator BeginNeumann();
00261 
00265     NeumannMapIterator EndNeumann();
00266 };
00267 
00268 
00269 #endif //_BOUNDARYCONDITIONSCONTAINER_HPP_

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