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 "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_