00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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_