36 #ifndef _BOUNDARYCONDITIONSCONTAINER_HPP_
37 #define _BOUNDARYCONDITIONSCONTAINER_HPP_
41 #include <boost/serialization/split_member.hpp>
42 #include <boost/serialization/map.hpp>
44 #include "AbstractBoundaryConditionsContainer.hpp"
45 #include "AbstractBoundaryCondition.hpp"
46 #include "AbstractTetrahedralMesh.hpp"
47 #include "BoundaryElement.hpp"
49 #include "LinearSystem.hpp"
50 #include "PetscException.hpp"
51 #include "ChastePoint.hpp"
52 #include "ConstBoundaryCondition.hpp"
53 #include "DistributedVectorFactory.hpp"
66 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
132 unsigned indexOfUnknown = 0,
133 bool checkIfBoundaryNode =
true);
155 unsigned indexOfUnknown = 0);
177 unsigned indexOfUnknown = 0);
189 unsigned indexOfUnknown = 0);
199 unsigned indexOfUnknown = 0);
216 bool applyToMatrix =
true,
217 bool applyToRhsVector =
true);
239 bool applyToMatrix =
true,
240 bool applyToRhsVector =
true);
292 unsigned indexOfUnknown = 0);
304 unsigned indexOfUnknown = 0);
334 template <
class Archive>
354 template <
class Archive>
360 friend class boost::serialization::access;
368 template<
class Archive>
369 void save(Archive & archive,
const unsigned int version)
const;
388 template<
class Archive>
389 void load(Archive & archive,
const unsigned int version)
393 BOOST_SERIALIZATION_SPLIT_MEMBER()
396 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
397 template<
class Archive>
399 Archive & archive,
const unsigned int version)
const
401 typedef typename std::map<unsigned, const AbstractBoundaryCondition<SPACE_DIM> *> archive_map_type;
404 for (
unsigned index_of_unknown=0; index_of_unknown<PROBLEM_DIM; index_of_unknown++)
406 archive_map_type bc_map;
408 while (it != this->mpDirichletMap[index_of_unknown]->end() )
410 unsigned node_index = it->first->GetIndex();
412 bc_map[node_index] = p_cond;
420 for (
unsigned index_of_unknown=0; index_of_unknown<PROBLEM_DIM; index_of_unknown++)
422 archive_map_type bc_map;
424 it != mpNeumannMap[index_of_unknown]->end();
427 unsigned elem_index = it->first->GetIndex();
429 bc_map[elem_index] = p_cond;
435 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
436 template<
class Archive>
440 mLoadedFromArchive =
true;
442 typedef typename std::map<unsigned, AbstractBoundaryCondition<SPACE_DIM>*> archive_map_type;
445 std::set<const AbstractBoundaryCondition<SPACE_DIM>*> maybe_unused_bcs;
446 std::set<const AbstractBoundaryCondition<SPACE_DIM>*> used_bcs;
449 for (
unsigned index_of_unknown=0; index_of_unknown<PROBLEM_DIM; index_of_unknown++)
451 archive_map_type bc_map;
453 for (
typename archive_map_type::iterator it = bc_map.begin();
457 unsigned node_index = it->first;
458 this->mHasDirichletBCs=
true;
467 maybe_unused_bcs.insert(it->second);
470 AddDirichletBoundaryCondition(p_node, it->second, index_of_unknown,
false);
471 used_bcs.insert(it->second);
474 this->mCheckedAndCommunicatedIfDirichletBcs=
true;
477 for (
unsigned index_of_unknown=0; index_of_unknown<PROBLEM_DIM; index_of_unknown++)
479 archive_map_type bc_map;
481 for (
typename archive_map_type::iterator it = bc_map.begin();
485 unsigned boundary_element_index = it->first;
494 maybe_unused_bcs.insert(it->second);
497 AddNeumannBoundaryCondition(p_boundary_element, it->second, index_of_unknown);
498 used_bcs.insert(it->second);
504 it != maybe_unused_bcs.end();
507 typename std::set<const AbstractBoundaryCondition<SPACE_DIM>*>::iterator used = used_bcs.find(*it);
508 if (used == used_bcs.end())
515 #endif //_BOUNDARYCONDITIONSCONTAINER_HPP_
void load(Archive &archive, const unsigned int version)
void AddPeriodicBoundaryCondition(const Node< SPACE_DIM > *pNode1, const Node< SPACE_DIM > *pNode2)
void ApplyDirichletToNonlinearResidual(const Vec currentSolution, Vec residual, DistributedVectorFactory &rFactory)
NeumannMapIterator mLastNeumannCondition[PROBLEM_DIM]
void DefineZeroDirichletOnMeshBoundary(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh, unsigned indexOfUnknown=0)
void AddNeumannBoundaryCondition(const BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > *pBoundaryElement, const AbstractBoundaryCondition< SPACE_DIM > *pBoundaryCondition, unsigned indexOfUnknown=0)
void LoadFromArchive(Archive &archive, AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
std::map< const BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > *, const AbstractBoundaryCondition< SPACE_DIM > * >::const_iterator NeumannMapIterator
void ApplyDirichletToLinearProblem(LinearSystem &rLinearSystem, bool applyToMatrix=true, bool applyToRhsVector=true)
double GetNeumannBCValue(const BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > *pSurfaceElement, const ChastePoint< SPACE_DIM > &rX, unsigned indexOfUnknown=0)
void ApplyPeriodicBcsToLinearProblem(LinearSystem &rLinearSystem, bool applyToMatrix=true, bool applyToRhsVector=true)
void AddDirichletBoundaryCondition(const Node< SPACE_DIM > *pBoundaryNode, const AbstractBoundaryCondition< SPACE_DIM > *pBoundaryCondition, unsigned indexOfUnknown=0, bool checkIfBoundaryNode=true)
std::map< const Node< SPACE_DIM > *, const Node< SPACE_DIM > * > * mpPeriodicBcMap[PROBLEM_DIM]
~BoundaryConditionsContainer()
void MergeFromArchive(Archive &archive, AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
bool Validate(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
ConstBoundaryCondition< SPACE_DIM > * mpZeroBoundaryCondition
BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > * GetBoundaryElement(unsigned index) const
bool AnyNonZeroNeumannConditions()
BoundaryConditionsContainer(bool deleteConditions=true)
void save(Archive &archive, const unsigned int version) const
std::map< const BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > *, const AbstractBoundaryCondition< SPACE_DIM > * > * mpNeumannMap[PROBLEM_DIM]
void DefineConstantDirichletOnMeshBoundary(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh, double value, unsigned indexOfUnknown=0)
void ApplyDirichletToNonlinearJacobian(Mat jacobian)
std::map< const Node< SPACE_DIM > *, const AbstractBoundaryCondition< SPACE_DIM > *, LessThanNode< SPACE_DIM > >::const_iterator DirichletIteratorType
AbstractBoundaryConditionsContainer< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM > BaseClassType
void DefineZeroNeumannOnMeshBoundary(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh, unsigned indexOfUnknown=0)
NeumannMapIterator EndNeumann()
NeumannMapIterator BeginNeumann()
bool HasNeumannBoundaryCondition(const BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > *pSurfaceElement, unsigned indexOfUnknown=0)
bool mAnyNonZeroNeumannConditionsForUnknown[PROBLEM_DIM]
Node< SPACE_DIM > * GetNodeFromPrePermutationIndex(unsigned index) const