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);
241 bool applyToMatrix =
true,
242 bool applyToRhsVector =
true);
294 unsigned indexOfUnknown = 0);
306 unsigned indexOfUnknown = 0);
336 template <
class Archive>
356 template <
class Archive>
362 friend class boost::serialization::access;
370 template<
class Archive>
371 void save(Archive & archive,
const unsigned int version)
const;
390 template<
class Archive>
391 void load(Archive & archive,
const unsigned int version)
395 BOOST_SERIALIZATION_SPLIT_MEMBER()
398 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
399 template<
class Archive>
401 Archive & archive,
const unsigned int version)
const
403 typedef typename std::map<unsigned, const AbstractBoundaryCondition<SPACE_DIM> *> archive_map_type;
406 for (
unsigned index_of_unknown=0; index_of_unknown<PROBLEM_DIM; index_of_unknown++)
408 archive_map_type bc_map;
410 while (it != this->mpDirichletMap[index_of_unknown]->end() )
412 unsigned node_index = it->first->GetIndex();
414 bc_map[node_index] = p_cond;
422 for (
unsigned index_of_unknown=0; index_of_unknown<PROBLEM_DIM; index_of_unknown++)
424 archive_map_type bc_map;
426 it != mpNeumannMap[index_of_unknown]->end();
429 unsigned elem_index = it->first->GetIndex();
431 bc_map[elem_index] = p_cond;
437 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
438 template<
class Archive>
442 mLoadedFromArchive =
true;
444 typedef typename std::map<unsigned, AbstractBoundaryCondition<SPACE_DIM>*> archive_map_type;
447 std::set<const AbstractBoundaryCondition<SPACE_DIM>*> maybe_unused_bcs;
448 std::set<const AbstractBoundaryCondition<SPACE_DIM>*> used_bcs;
451 for (
unsigned index_of_unknown=0; index_of_unknown<PROBLEM_DIM; index_of_unknown++)
453 archive_map_type bc_map;
455 for (
typename archive_map_type::iterator it = bc_map.begin();
459 unsigned node_index = it->first;
460 this->mHasDirichletBCs=
true;
469 maybe_unused_bcs.insert(it->second);
472 AddDirichletBoundaryCondition(p_node, it->second, index_of_unknown,
false);
473 used_bcs.insert(it->second);
476 this->mCheckedAndCommunicatedIfDirichletBcs=
true;
479 for (
unsigned index_of_unknown=0; index_of_unknown<PROBLEM_DIM; index_of_unknown++)
481 archive_map_type bc_map;
483 for (
typename archive_map_type::iterator it = bc_map.begin();
487 unsigned boundary_element_index = it->first;
496 maybe_unused_bcs.insert(it->second);
499 AddNeumannBoundaryCondition(p_boundary_element, it->second, index_of_unknown);
500 used_bcs.insert(it->second);
506 it != maybe_unused_bcs.end();
509 typename std::set<const AbstractBoundaryCondition<SPACE_DIM>*>::iterator used = used_bcs.find(*it);
510 if (used == used_bcs.end())
517 #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