25#ifndef __BITPIT_PATCH_KERNEL_HPP__
26#define __BITPIT_PATCH_KERNEL_HPP__
32#if BITPIT_ENABLE_MPI==1
38#include <unordered_map>
40#include "bitpit_IO.hpp"
41#if BITPIT_ENABLE_MPI==1
42# include "bitpit_communications.hpp"
44#include "bitpit_containers.hpp"
46#include "adaption.hpp"
49#include "interface.hpp"
58#if BITPIT_ENABLE_MPI==1
59friend class PatchGlobalInfo;
81 WRITE_TARGET_CELLS_ALL
83 , WRITE_TARGET_CELLS_INTERNAL
97 : m_tolerance(tolerance)
103 bool operator()(std::array<double, 3> point_1, std::array<double, 3> point_2)
const
109 bool coincident =
true;
110 for (
int k = 0; k < 3; ++k) {
129 for (
int k = 0; k < 3; ++k) {
130 if (point_1[k] == point_2[k]) {
134 return (point_1[k] < point_2[k]);
140 const double m_tolerance;
157 bool operator()(
long id_1,
long id_2)
const
166 return PointPositionLess::operator()(coords_1, coords_2);
184 bool operator()(
long id_1,
long id_2)
const
186 return !VertexPositionLess::operator()(id_1, id_2);
204 bool operator()(
long id_1,
long id_2)
const
210 std::array<double, 3> centroid_1;
211 std::array<double, 3> centroid_2;
216 centroid_1 = m_patch.PatchKernel::evalCellCentroid(id_1);
217 centroid_2 = m_patch.PatchKernel::evalCellCentroid(id_2);
220 return PointPositionLess::operator()(centroid_1, centroid_2);
239 bool operator()(
long id_1,
long id_2)
const
241 return !CellPositionLess::operator()(id_1, id_2);
262 bool operator()(
long id_1,
long id_2)
const
273 long vertexId_2 = Vertex::NULL_ID;
275 if (vertexId_1 != candidateVertexId_2) {
276 vertexId_2 = candidateVertexId_2;
281 if (vertexId_2 == Vertex::NULL_ID) {
286 const std::array<double, 3> &vertexCoords_1 = m_patch.
getVertex(vertexId_1).
getCoords();
287 const std::array<double, 3> &vertexCoords_2 = m_patch.
getVertex(vertexId_2).
getCoords();
289 return PointPositionLess::operator()(vertexCoords_1, vertexCoords_2);
310 bool operator()(
long id_1,
long id_2)
const
312 return !CellFuzzyPositionLess::operator()(id_1, id_2);
320 ADJACENCIES_NONE = -1,
321 ADJACENCIES_AUTOMATIC
328 INTERFACES_NONE = -1,
336 ADAPTION_DISABLED = -1,
359 PARTITIONING_DISABLED = -1,
368 PARTITIONING_PREPARED,
377 template<
typename patch_t>
378 static std::unique_ptr<patch_t> clone(
const patch_t *original);
380 virtual std::unique_ptr<PatchKernel> clone()
const = 0;
384 virtual void reset();
393 std::vector<adaption::Info>
update(
bool trackAdaption =
true,
bool squeezeStorage =
false);
400 std::vector<adaption::Info> adaption(
bool trackAdaption =
true,
bool squeezeStorage =
false);
401 std::vector<adaption::Info>
adaptionPrepare(
bool trackAdaption =
true);
402 std::vector<adaption::Info>
adaptionAlter(
bool trackAdaption =
true,
bool squeezeStorage =
false);
413 bool isDirty(
bool global =
false)
const;
421 virtual int getVolumeCodimension()
const = 0;
422 virtual int getSurfaceCodimension()
const = 0;
423 virtual int getLineCodimension()
const = 0;
424 virtual int getPointCodimension()
const = 0;
426 bool empty(
bool global =
true)
const;
433#if BITPIT_ENABLE_MPI==1
442#if BITPIT_ENABLE_MPI==1
447 void getVertexCoords(std::size_t nVertices,
const long *ids, std::unique_ptr<std::array<double, 3>[]> *coordinates)
const;
448 void getVertexCoords(std::size_t nVertices,
const long *ids, std::array<double, 3> *coordinates)
const;
449 VertexIterator
addVertex(
const Vertex &source,
long id = Vertex::NULL_ID);
451 VertexIterator
addVertex(
const std::array<double, 3> &coords,
long id = Vertex::NULL_ID);
465#if BITPIT_ENABLE_MPI==1
475#if BITPIT_ENABLE_MPI==1
486#if BITPIT_ENABLE_MPI==1
497#if BITPIT_ENABLE_MPI==1
503 CellIterator
addCell(
const Cell &source,
long id = Element::NULL_ID);
504 CellIterator
addCell(
Cell &&source,
long id = Element::NULL_ID);
506 CellIterator
addCell(
ElementType type,
const std::vector<long> &connectivity,
long id = Element::NULL_ID);
507 CellIterator
addCell(
ElementType type, std::unique_ptr<
long[]> &&connectStorage,
long id = Element::NULL_ID);
508#if BITPIT_ENABLE_MPI==1
509 CellIterator
addCell(
const Cell &source,
int owner,
long id = Element::NULL_ID);
510 CellIterator
addCell(
const Cell &source,
int owner,
int haloLayer,
long id = Element::NULL_ID);
511 CellIterator
addCell(
Cell &&source,
int owner,
long id = Element::NULL_ID);
512 CellIterator
addCell(
Cell &&source,
int owner,
int haloLayer,
long id = Element::NULL_ID);
514 CellIterator
addCell(
ElementType type,
int owner,
int haloLayer,
long id = Element::NULL_ID);
515 CellIterator
addCell(
ElementType type,
const std::vector<long> &connectivity,
int owner,
long id = Element::NULL_ID);
516 CellIterator
addCell(
ElementType type,
const std::vector<long> &connectivity,
int owner,
int haloLayer,
long id = Element::NULL_ID);
517 CellIterator
addCell(
ElementType type, std::unique_ptr<
long[]> &&connectStorage,
int owner,
long id = Element::NULL_ID);
518 CellIterator
addCell(
ElementType type, std::unique_ptr<
long[]> &&connectStorage,
int owner,
int haloLayer,
long id = Element::NULL_ID);
521 template<
typename IdStorage>
523#if BITPIT_ENABLE_MPI==1
527 virtual double evalCellSize(
long id)
const = 0;
536 virtual void evalCellBoundingBox(
long id, std::array<double,3> *minPoint, std::array<double,3> *maxPoint)
const;
542 std::vector<long>
findCellNeighs(
long id,
int codimension,
bool complete =
true)
const;
543 void findCellNeighs(
long id,
int codimension,
bool complete, std::vector<long> *neighs)
const;
558 bool findFaceNeighCell(
long cellId,
long neighId,
int *cellFace,
int *cellAdjacencyId)
const;
573#if BITPIT_ENABLE_MPI==1
587#if BITPIT_ENABLE_MPI==1
606 InterfaceIterator
addInterface(
ElementType type,
const std::vector<long> &connectivity,
long id = Element::NULL_ID);
607 InterfaceIterator
addInterface(
ElementType type, std::unique_ptr<
long[]> &&connectStorage,
long id = Element::NULL_ID);
609 template<
typename IdStorage>
618 virtual void evalInterfaceBoundingBox(
long id, std::array<double,3> *minPoint, std::array<double,3> *maxPoint)
const;
645 long locatePoint(
double x,
double y,
double z)
const;
646 virtual long locatePoint(
const std::array<double, 3> &point)
const = 0;
662 void getBoundingBox(std::array<double, 3> &minPoint, std::array<double, 3> &maxPoint)
const;
663 void getBoundingBox(
bool global, std::array<double, 3> &minPoint, std::array<double, 3> &maxPoint)
const;
667 virtual void translate(
const std::array<double, 3> &translation);
668 void translate(
double sx,
double sy,
double sz);
669 virtual void rotate(
const std::array<double, 3> &n0,
const std::array<double, 3> &n1,
double angle);
670 void rotate(
double n0x,
double n0y,
double n0z,
double n1x,
double n1y,
double n1z,
double angle);
671 void scale(
const std::array<double, 3> &scaling);
672 virtual void scale(
const std::array<double, 3> &scaling,
const std::array<double, 3> &origin);
673 void scale(
double scaling);
674 void scale(
double scaling,
const std::array<double, 3> &origin);
675 void scale(
double sx,
double sy,
double sz);
676 void scale(
double sx,
double sy,
double sz,
const std::array<double, 3> &origin);
678 void setTol(
double tolerance);
684 void displayVertices(std::ostream &out,
unsigned int padding = 0)
const;
685 void displayCells(std::ostream &out,
unsigned int padding = 0)
const;
698 void flushData(std::fstream &stream,
const std::string &name,
VTKFormat format)
override;
701 bool dump(std::ostream &stream);
702 bool dump(std::ostream &stream)
const;
703 void restore(std::istream &stream,
bool reregister =
false);
710#if BITPIT_ENABLE_MPI==1
716 int getOwner(
bool allowDirty =
false)
const;
752 BITPIT_DEPRECATED(std::vector<adaption::Info>
partition(MPI_Comm communicator,
const std::unordered_map<long, int> &cellRanks,
bool trackPartitioning,
bool squeezeStorage =
false, std::size_t haloSize = 1));
753 std::vector<adaption::Info>
partition(
const std::unordered_map<long, int> &cellRanks,
bool trackPartitioning,
bool squeezeStorage =
false);
754 BITPIT_DEPRECATED(std::vector<adaption::Info>
partition(MPI_Comm communicator,
const std::unordered_map<long, double> &cellWeights,
bool trackPartitioning,
bool squeezeStorage =
false, std::size_t haloSize = 1));
755 std::vector<adaption::Info>
partition(
const std::unordered_map<long, double> &cellWeights,
bool trackPartitioning,
bool squeezeStorage =
false);
756 BITPIT_DEPRECATED(std::vector<adaption::Info>
partition(MPI_Comm communicator,
bool trackPartitioning,
bool squeezeStorage =
false, std::size_t haloSize = 1));
757 std::vector<adaption::Info>
partition(
bool trackPartitioning,
bool squeezeStorage =
false);
758 BITPIT_DEPRECATED(std::vector<adaption::Info>
partitioningPrepare(MPI_Comm communicator,
const std::unordered_map<long, int> &cellRanks,
bool trackPartitioning, std::size_t haloSize = 1));
759 std::vector<adaption::Info>
partitioningPrepare(
const std::unordered_map<long, int> &cellRanks,
bool trackPartitioning);
760 BITPIT_DEPRECATED(std::vector<adaption::Info>
partitioningPrepare(MPI_Comm communicator,
const std::unordered_map<long, double> &cellWeights,
bool trackPartitioning, std::size_t haloSize = 1));
761 std::vector<adaption::Info>
partitioningPrepare(
const std::unordered_map<long, double> &cellWeights,
bool trackPartitioning);
764 std::vector<adaption::Info>
partitioningAlter(
bool trackPartitioning =
true,
bool squeezeStorage =
false);
768 template<
typename Function>
770 template<
typename Selector,
typename Function>
772 template<
typename Function,
typename SeedContainer>
774 template<
typename Selector,
typename Function,
typename SeedContainer>
775 void processCellsNeighbours(
const SeedContainer &seedIds,
int nLayers, Selector isSelected, Function function)
const;
776 template<
typename Function>
778 template<
typename Selector,
typename Function>
780 template<
typename Function,
typename SeedContainer>
782 template<
typename Selector,
typename Function,
typename SeedContainer>
792 typedef uint16_t AlterationFlags;
793 typedef std::unordered_map<long, AlterationFlags> AlterationFlagsStorage;
795#if BITPIT_ENABLE_MPI==1
799 const static AlterationFlags FLAG_NONE = 0x0;
800 const static AlterationFlags FLAG_DELETED = (1u << 0);
801 const static AlterationFlags FLAG_ADJACENCIES_DIRTY = (1u << 1);
802 const static AlterationFlags FLAG_INTERFACES_DIRTY = (1u << 2);
803 const static AlterationFlags FLAG_DANGLING = (1u << 3);
809 AlterationFlagsStorage m_alteredCells;
810 AlterationFlagsStorage m_alteredInterfaces;
812#if BITPIT_ENABLE_MPI==1
828 void setBoundingBox(
const std::array<double, 3> &minPoint,
const std::array<double, 3> &maxPoint);
830#if BITPIT_ENABLE_MPI==1
835#if BITPIT_ENABLE_MPI==1
843#if BITPIT_ENABLE_MPI==1
850 template<
typename IdStorage>
852#if BITPIT_ENABLE_MPI==1
860 void dumpCells(std::ostream &stream)
const;
867#if BITPIT_ENABLE_MPI==1
872#if BITPIT_ENABLE_MPI==1
906 bool testAlterationFlags(AlterationFlags availableFlags, AlterationFlags requestedFlags)
const;
911 virtual std::vector<adaption::Info>
_adaptionAlter(
bool trackAdaption);
919 virtual void _setTol(
double tolerance);
922 virtual int _getDumpVersion()
const = 0;
923 virtual void _dump(std::ostream &stream)
const = 0;
924 virtual void _restore(std::istream &stream) = 0;
928 virtual void _findCellNeighs(
long id,
const std::vector<long> *blackList, std::vector<long> *neighs)
const;
929 virtual void _findCellFaceNeighs(
long id,
int face,
const std::vector<long> *blackList, std::vector<long> *neighs)
const;
930 virtual void _findCellEdgeNeighs(
long id,
int edge,
const std::vector<long> *blackList, std::vector<long> *neighs)
const;
931 virtual void _findCellVertexNeighs(
long id,
int vertex,
const std::vector<long> *blackList, std::vector<long> *neighs)
const;
942#if BITPIT_ENABLE_MPI==1
946 void setPartitioned(
bool partitioned);
949 virtual std::vector<adaption::Info>
_partitioningPrepare(
const std::unordered_map<long, double> &cellWeights,
double defaultWeight,
bool trackPartitioning);
950 virtual std::vector<adaption::Info>
_partitioningPrepare(
const std::unordered_map<long, int> &cellRanks,
bool trackPartitioning);
957 template<
typename item_t,
typename id_t =
long>
960 template<
typename item_t,
typename id_t =
long>
964 virtual bool isSameFace(
const Cell &cell_A,
int face_A,
const Cell &cell_B,
int face_B)
const;
967 struct GhostVertexInfo {
971 struct GhostCellInfo {
976 std::unique_ptr<IndexGenerator<long>> m_vertexIdGenerator;
977 std::unique_ptr<IndexGenerator<long>> m_interfaceIdGenerator;
978 std::unique_ptr<IndexGenerator<long>> m_cellIdGenerator;
980 long m_nInternalVertices;
981#if BITPIT_ENABLE_MPI==1
982 long m_nGhostVertices;
985 long m_lastInternalVertexId;
986#if BITPIT_ENABLE_MPI==1
987 long m_firstGhostVertexId;
990 long m_nInternalCells;
991#if BITPIT_ENABLE_MPI==1
995 long m_lastInternalCellId;
996#if BITPIT_ENABLE_MPI==1
997 long m_firstGhostCellId;
1000 VTKUnstructuredGrid m_vtk ;
1001 WriteTarget m_vtkWriteTarget;
1002 PiercedStorage<long, long> m_vtkVertexMap;
1006 std::array<double, 3> m_boxMinPoint;
1007 std::array<double, 3> m_boxMaxPoint;
1008 std::array<int, 3> m_boxMinCounter;
1009 std::array<int, 3> m_boxMaxCounter;
1021 bool m_toleranceCustom;
1026#if BITPIT_ENABLE_MPI==1
1027 MPI_Comm m_communicator;
1033 std::size_t m_haloSize;
1035 int m_partitioningCellsTag;
1036 int m_partitioningVerticesTag;
1037 bool m_partitioningSerialization;
1038 std::unordered_map<long, int> m_partitioningOutgoings;
1039 std::vector<std::pair<int, int>> m_partitioningGlobalExchanges;
1041 bool m_partitioningInfoDirty;
1043 std::unordered_map<long, GhostVertexInfo> m_ghostVertexInfo;
1044 std::unordered_map<int, std::vector<long>> m_ghostVertexExchangeTargets;
1045 std::unordered_map<int, std::vector<long>> m_ghostVertexExchangeSources;
1047 std::unordered_map<long, GhostCellInfo> m_ghostCellInfo;
1048 std::unordered_map<int, std::vector<long>> m_ghostCellExchangeTargets;
1049 std::unordered_map<int, std::vector<long>> m_ghostCellExchangeSources;
1051 void setGhostVertexInfo(
long id,
int owner);
1052 void unsetGhostVertexInfo(
long id);
1053 void clearGhostVerticesInfo();
1055 void setGhostCellInfo(
long id,
int owner,
int haloLayer);
1056 void unsetGhostCellInfo(
long id);
1057 void clearGhostCellsInfo();
1059 void computeCellHaloLayer(
int id);
1061 void _partitioningAlter_deleteGhosts();
1063 std::unordered_map<long, int> _partitioningAlter_evalGhostCellOwnershipChanges();
1064 void _partitioningAlter_applyGhostCellOwnershipChanges(
int sendRank, std::unordered_map<long, int> *ghostCellOwnershipChanges);
1066 std::vector<adaption::Info> _partitioningAlter_sendCells(
const std::unordered_set<int> &recvRanks,
bool trackPartitioning, std::unordered_map<long, int> *ghostCellOwnershipChanges);
1067 std::vector<adaption::Info> _partitioningAlter_receiveCells(
const std::unordered_set<int> &sendRanks,
bool trackPartitioning, std::unordered_map<long, int> *ghostCellOwnershipChanges);
1069 void setPartitioningInfoDirty(
bool dirty);
1071 void updatePartitioningInfo(
bool forcedUpdated =
false);
1073 void updateGhostCellExchangeInfo();
1075 void updateGhostVertexOwners();
1076 void updateGhostVertexExchangeInfo();
1079 int evalOwner()
const;
1081 std::unordered_map<long, int> evaluateExchangeVertexOwners()
const;
1083 template<
typename ExcludeList>
1084 bool confirmCellHaloLayer(
const Cell &cell,
int haloLayer,
const ExcludeList &excludeList = ExcludeList())
const;
1087#if BITPIT_ENABLE_MPI==1
1088 void initialize(MPI_Comm communicator, std::size_t haloSize);
1089 void initializeHaloSize(std::size_t haloSize);
1090 void initializeCommunicator(MPI_Comm communicator);
1092 void freeCommunicator();
1095 void initializeSerialCommunicator();
1098 void finalizeAlterations(
bool squeezeStorage =
false);
1100 InterfaceIterator buildCellInterface(Cell *cell_1,
int face_1, Cell *cell_2,
int face_2,
long interfaceId = Element::NULL_ID);
1102 void _setId(
int id);
1104 bool testElementAlterationFlags(
long id, AlterationFlags flags,
const AlterationFlagsStorage &flagsStorage)
const;
1105 AlterationFlags getElementAlterationFlags(
long id,
const AlterationFlagsStorage &flagsStorage)
const;
1106 void resetElementAlterationFlags(
long id, AlterationFlags flags, AlterationFlagsStorage *flagsStorage)
const;
1107 void setElementAlterationFlags(
long id, AlterationFlags flags, AlterationFlagsStorage *flagsStorage)
const;
1108 void unsetElementAlterationFlags(AlterationFlags flags, AlterationFlagsStorage *flagsStorage)
const;
1109 void unsetElementAlterationFlags(
long id, AlterationFlags flags, AlterationFlagsStorage *flagsStorage)
const;
1111 void mergeAdaptionInfo(std::vector<adaption::Info> &&source, std::vector<adaption::Info> &destination);
1113 void setRestoredCellAlterationFlags(
long id);
1114 void setAddedCellAlterationFlags(
long id);
1115 void setDeletedCellAlterationFlags(
long id);
1117 void setRestoredInterfaceAlterationFlags(
long id);
1118 void setAddedInterfaceAlterationFlags(
long id);
1119 void setDeletedInterfaceAlterationFlags(
long id);
1121 void dumpVertexAutoIndexing(std::ostream &stream)
const;
1122 void restoreVertexAutoIndexing(std::istream &stream);
1123 void createVertexIndexGenerator(
bool populate);
1124 void importVertexIndexGenerator(
const PatchKernel &source);
1126 void dumpCellAutoIndexing(std::ostream &stream)
const;
1127 void restoreCellAutoIndexing(std::istream &stream);
1128 void createCellIndexGenerator(
bool populate);
1129 void importCellIndexGenerator(
const PatchKernel &source);
1131 void dumpInterfaceAutoIndexing(std::ostream &stream)
const;
1132 void restoreInterfaceAutoIndexing(std::istream &stream);
1133 void createInterfaceIndexGenerator(
bool populate);
1134 void importInterfaceIndexGenerator(
const PatchKernel &source);
1136 VertexIterator _addInternalVertex(
const std::array<double, 3> &coords,
long id);
1138 void _restoreInternalVertex(
const VertexIterator &iterator,
const std::array<double, 3> &coords);
1139#if BITPIT_ENABLE_MPI==1
1140 void _restoreGhostVertex(
const VertexIterator &iterator,
const std::array<double, 3> &coords,
int owner);
1143 void _deleteInternalVertex(
long id);
1144#if BITPIT_ENABLE_MPI==1
1145 void _deleteGhostVertex(
long id);
1148 CellIterator _addInternalCell(
ElementType type, std::unique_ptr<
long[]> &&connectStorage,
long id);
1149#if BITPIT_ENABLE_MPI==1
1150 CellIterator _addGhostCell(
ElementType type, std::unique_ptr<
long[]> &&connectStorage,
int owner,
int haloLayer,
long id);
1153 void _restoreInternalCell(
const CellIterator &iterator,
ElementType type, std::unique_ptr<
long[]> &&connectStorage);
1154#if BITPIT_ENABLE_MPI==1
1155 void _restoreGhostCell(
const CellIterator &iterator,
ElementType type, std::unique_ptr<
long[]> &&connectStorage,
int owner,
int haloLayer);
1158 void _deleteInternalCell(
long id);
1159#if BITPIT_ENABLE_MPI==1
1160 void _deleteGhostCell(
long id);
1163 InterfaceIterator _addInterface(
ElementType type, std::unique_ptr<
long[]> &&connectStorage,
long id);
1165 void _restoreInterface(
const InterfaceIterator &iterator,
ElementType type, std::unique_ptr<
long[]> &&connectStorage);
1167 void _deleteInterface(
long id);
1169 void replaceVTKStreamer(
const VTKBaseStreamer *original, VTKBaseStreamer *updated);
1176#include "patch_kernel.tpp"
1177#include "patch_kernel_parallel.tpp"
The Cell class defines the cells.
The Element class provides an interface for defining elements.
static ConstProxyVector< long > getVertexIds(ElementType type, const long *connectivity)
long getVertexId(int vertex) const
The Interface class defines the interfaces among cells.
The PatchInfo class provides an interface for defining patch info.
The PatchKernel class provides an interface for defining patches.
void initializeAdjacencies(AdjacenciesBuildStrategy strategy=ADJACENCIES_AUTOMATIC)
VertexIterator vertexEnd()
void unsetCellAlterationFlags(AlterationFlags flags)
CellConstIterator cellConstBegin() const
void processCellNeighbours(long seedId, int nLayers, Function function) const
Vertex & getLastInternalVertex()
CellIterator getCellIterator(long id)
void mappedItemRenumbering(PiercedVector< item_t, id_t > &container, const std::unordered_map< id_t, id_t > &renumberMap)
void dumpInterfaces(std::ostream &stream) const
CellIterator internalCellBegin()
InterfacesBuildStrategy getInterfacesBuildStrategy() const
CellConstIterator internalConstBegin() const
virtual bool _enableCellBalancing(long id, bool enabled)
CellConstIterator internalCellConstEnd() const
CellIterator internalBegin()
AdjacenciesBuildStrategy getAdjacenciesBuildStrategy() const
virtual bool _markCellForRefinement(long id)
std::vector< long > getInternalCellsByPID(int pid)
void displayVertices(std::ostream &out, unsigned int padding=0) const
int getVertexOwner(long id) const
InterfaceIterator restoreInterface(ElementType type, std::unique_ptr< long[]> &&connectStorage, long id)
const std::unordered_map< int, std::vector< long > > & getGhostCellExchangeSources() const
std::unordered_map< id_t, id_t > consecutiveItemRenumbering(PiercedVector< item_t, id_t > &container, long offset)
virtual void _findCellEdgeNeighs(long id, int edge, const std::vector< long > *blackList, std::vector< long > *neighs) const
void markCellForRefinement(long id)
VertexIterator ghostVertexEnd()
std::vector< long > findVertexOneRing(long vertexId) const
virtual std::array< double, 3 > evalInterfaceCentroid(long id) const
void setCellAutoIndexing(bool enabled)
virtual std::vector< long > _findGhostCellExchangeSources(int rank)
virtual long getInterfaceCount() const
std::vector< adaption::Info > update(bool trackAdaption=true, bool squeezeStorage=false)
long getGhostVertexCount() const
InterfaceIterator interfaceBegin()
PiercedVector< Cell > & getCells()
std::vector< long > findOrphanInterfaces() const
@ ADAPTION_AUTOMATIC
No adaption can be performed.
bool testAlterationFlags(AlterationFlags availableFlags, AlterationFlags requestedFlags) const
VertexConstIterator vertexConstEnd() const
void dumpVertices(std::ostream &stream) const
virtual void _writeFinalize()
InterfaceIterator interfaceEnd()
void destroyAdjacencies()
void pruneStaleAdjacencies()
Interface & getInterface(long id)
PatchKernel(PatchKernel &&other)
void updateFirstGhostCellId()
virtual void _resetInterfaces(bool release)
VertexIterator restoreVertex(const std::array< double, 3 > &coords, int owner, long id)
AdaptionMode getAdaptionMode() const
CellIterator restoreCell(ElementType type, std::unique_ptr< long[]> &&connectStorage, int owner, int haloLayer, long id)
void setExpert(bool expert)
long countBorderInterfaces() const
InterfaceIterator addInterface(const Interface &source, long id=Element::NULL_ID)
void dumpCells(std::ostream &stream) const
void setBoundingBoxDirty(bool dirty)
CellConstIterator internalCellConstBegin() const
bool isVertexAutoIndexingEnabled() const
virtual void _writePrepare()
VertexIterator vertexBegin()
InterfaceConstIterator interfaceConstEnd() const
InterfaceConstIterator interfaceConstBegin() const
std::vector< long > collapseCoincidentVertices()
void consecutiveRenumberInterfaces(long offset=0)
bool isCellAutoIndexingEnabled() const
VertexConstIterator vertexConstBegin() const
virtual std::vector< adaption::Info > _partitioningPrepare(const std::unordered_map< long, double > &cellWeights, double defaultWeight, bool trackPartitioning)
WriteTarget getVTKWriteTarget() const
virtual long getVertexCount() const
const std::unordered_map< int, std::vector< long > > & getGhostCellExchangeTargets() const
bool deleteCoincidentVertices()
long countOrphanInterfaces() const
virtual void evalCellBoundingBox(long id, std::array< double, 3 > *minPoint, std::array< double, 3 > *maxPoint) const
bool isRankNeighbour(int rank)
void restoreCells(std::istream &stream)
CellIterator ghostCellEnd()
virtual void _findCellFaceNeighs(long id, int face, const std::vector< long > *blackList, std::vector< long > *neighs) const
void addPointToBoundingBox(const std::array< double, 3 > &point)
std::vector< long > findDuplicateCells() const
virtual ElementType getInterfaceType(long id) const
VertexIterator addVertex(const Vertex &source, long id=Vertex::NULL_ID)
bool empty(bool global=true) const
std::vector< long > findCellNeighs(long id) const
bool deleteVertex(long id)
void getBoundingBox(std::array< double, 3 > &minPoint, std::array< double, 3 > &maxPoint) const
PartitioningMode getPartitioningMode() const
std::vector< adaption::Info > adaptionPrepare(bool trackAdaption=true)
adaption::Marker getCellAdaptionMarker(long id)
void processCellsNeighbours(const SeedContainer &seedIds, int nLayers, Function function) const
VTKUnstructuredGrid & getVTK()
std::unordered_map< long, std::vector< long > > binGroupVertices(const PiercedVector< Vertex > &vertices, int nBins)
void setBoundingBoxFrozen(bool frozen)
VertexIterator internalVertex2GhostVertex(long id, int owner)
virtual bool isSameFace(const Cell &cell_A, int face_A, const Cell &cell_B, int face_B) const
virtual std::vector< adaption::Info > _partitioningAlter(bool trackPartitioning)
const CellConstRange getVTKCellWriteRange() const
virtual bool _resetCellAdaptionMarker(long id)
void consecutiveRenumberCells(long offset=0)
virtual void simulateCellUpdate(const long id, adaption::Marker marker, std::vector< Cell > *virtualCells, PiercedVector< Vertex, long > *virtualVertices) const
CellIterator ghostCellBegin()
void setVertexAutoIndexing(bool enabled)
VertexIterator getVertexIterator(long id)
VertexConstIterator getVertexConstIterator(long id) const
PiercedVector< Vertex > & getVertices()
virtual bool _markCellForCoarsening(long id)
std::vector< long > findCellFaceNeighs(long id) const
virtual void _setTol(double tolerance)
bool deleteVertices(const IdStorage &ids)
long locatePoint(double x, double y, double z) const
Cell & getLastInternalCell()
InterfaceConstIterator getInterfaceConstIterator(long id) const
void flushData(std::fstream &stream, const std::string &name, VTKFormat format) override
virtual adaption::Marker _getCellAdaptionMarker(long id)
CellIterator ghostBegin()
int getVertexRank(long id) const
std::vector< adaption::Info > partition(MPI_Comm communicator, const std::unordered_map< long, int > &cellRanks, bool trackPartitioning, bool squeezeStorage=false, std::size_t haloSize=1)
CellIterator addCell(const Cell &source, long id=Element::NULL_ID)
void evalElementBoundingBox(const Element &element, std::array< double, 3 > *minPoint, std::array< double, 3 > *maxPoint) const
PartitioningStatus getPartitioningStatus(bool global=false) const
int getCellRank(long id) const
void resetCellAlterationFlags(long id, AlterationFlags flags=FLAG_NONE)
virtual void _partitioningCleanup()
void updateInterfaces(bool forcedUpdated=false)
void displayTopologyStats(std::ostream &out, unsigned int padding=0) const
virtual void rotate(const std::array< double, 3 > &n0, const std::array< double, 3 > &n1, double angle)
ConstProxyVector< std::array< double BITPIT_COMMA 3 > > getElementVertexCoordinates(const Element &element) const
long countBorderCells() const
void setTol(double tolerance)
CellConstIterator cellConstEnd() const
AlterationFlags getCellAlterationFlags(long id) const
void scale(const std::array< double, 3 > &scaling)
virtual void setDimension(int dimension)
void markCellForCoarsening(long id)
const std::unordered_map< int BITPIT_COMMA std::vector< long > > & getGhostExchangeTargets() const
void restoreVertices(std::istream &stream)
virtual void translate(const std::array< double, 3 > &translation)
VertexConstIterator internalVertexConstEnd() const
bool arePartitioningInfoDirty(bool global=true) const
CellIterator internalCell2GhostCell(long id, int owner, int haloLayer)
@ PARTITIONING_ENABLED
No partitioning can be performed.
void setInterfaceAutoIndexing(bool enabled)
CellIterator ghostCell2InternalCell(long id)
void setAdaptionStatus(AdaptionStatus status)
bool isInterfaceAutoIndexingEnabled() const
PatchKernel & operator=(PatchKernel &&other)
void setAdjacenciesBuildStrategy(AdjacenciesBuildStrategy status)
void updateLastInternalVertexId()
VertexConstIterator ghostVertexConstEnd() const
VertexIterator internalVertexEnd()
bool reserveInterfaces(size_t nInterfaces)
int getOwner(bool allowDirty=false) const
long countDuplicateCells() const
bool areInterfacesDirty(bool global=false) const
void partitioningCleanup()
bool deleteOrphanInterfaces()
double evalPartitioningUnbalance() const
CellConstIterator ghostCellConstEnd() const
static const double DEFAULT_PARTITIONING_WEIGTH
void setInterfacesBuildStrategy(InterfacesBuildStrategy status)
VertexIterator ghostVertexBegin()
const MPI_Comm & getCommunicator() const
void updateBoundingBox(bool forcedUpdated=false)
void processCellFaceNeighbours(long seedId, int nLayers, Function function) const
std::size_t getHaloSize() const
void restore(std::istream &stream, bool reregister=false)
virtual void resetVertices()
virtual int findAdjoinNeighFace(const Cell &cell, int cellFace, const Cell &neigh) const
virtual void resetInterfaces()
CellConstIterator ghostConstEnd() const
long countFreeVertices() const
void updateFirstGhostVertexId()
void setHaloSize(std::size_t haloSize)
long countFreeCells() const
virtual void _updateAdjacencies()
Vertex & getFirstGhostVertex()
void initializeInterfaces(InterfacesBuildStrategy strategy=INTERFACES_AUTOMATIC)
CellIterator internalEnd()
void enableCellBalancing(long id, bool enabled)
virtual void _resetAdjacencies(bool release)
void setVTKWriteTarget(WriteTarget targetCells)
bool isPartitioned() const
void displayCells(std::ostream &out, unsigned int padding=0) const
int getDumpVersion() const
bool testInterfaceAlterationFlags(long id, AlterationFlags flags) const
Vertex & getVertex(long id)
virtual std::size_t _getMaxHaloSize()
std::vector< adaption::Info > partitioningPrepare(MPI_Comm communicator, const std::unordered_map< long, int > &cellRanks, bool trackPartitioning, std::size_t haloSize=1)
std::set< int > getInternalCellPIDs()
long countOrphanVertices() const
void restoreInterfaces(std::istream &stream)
virtual long getCellCount() const
VertexIterator ghostVertex2InternalVertex(long id)
void unsetInterfaceAlterationFlags(AlterationFlags flags)
VertexConstIterator ghostVertexConstBegin() const
const std::unordered_map< int, std::vector< long > > & getGhostVertexExchangeTargets() const
virtual void _adaptionCleanup()
bool isBoundingBoxFrozen() const
void removePointFromBoundingBox(const std::array< double, 3 > &point)
void resetCellAdaptionMarker(long id)
std::vector< long > findCellVertexNeighs(long id, bool complete=true) const
void setAdaptionMode(AdaptionMode mode)
bool isDistributed(bool allowDirty=false) const
std::vector< adaption::Info > partitioningAlter(bool trackPartitioning=true, bool squeezeStorage=false)
bool deleteOrphanVertices()
int getCellHaloLayer(long id) const
const std::unordered_map< int, std::vector< long > > & getGhostVertexExchangeSources() const
bool deleteInterface(long id)
virtual void _findCellNeighs(long id, const std::vector< long > *blackList, std::vector< long > *neighs) const
const std::array< double, 3 > & getVertexCoords(long id) const
virtual long _getCellNativeIndex(long id) const
long countOrphanCells() const
bool dump(std::ostream &stream)
void write(VTKWriteMode mode=VTKWriteMode::DEFAULT)
virtual void _updateInterfaces()
virtual void evalInterfaceBoundingBox(long id, std::array< double, 3 > *minPoint, std::array< double, 3 > *maxPoint) const
void updateAdjacencies(bool forcedUpdated=false)
ConstProxyVector< std::array< double BITPIT_COMMA 3 > > getInterfaceVertexCoordinates(long id) const
bool areAdjacenciesDirty(bool global=false) const
virtual void settleAdaptionMarkers()
VertexConstIterator internalVertexConstBegin() const
void setPartitioningMode(PartitioningMode mode)
const std::unordered_map< int BITPIT_COMMA std::vector< long > > & getGhostExchangeSources() const
long countBorderVertices() const
InterfaceIterator getInterfaceIterator(long id)
AdaptionStatus getAdaptionStatus(bool global=false) const
long getInternalCount() const
bool isDirty(bool global=false) const
std::vector< long > findCellEdgeNeighs(long id, bool complete=true) const
VertexIterator internalVertexBegin()
long countFreeInterfaces() const
bool isTolCustomized() const
CellConstIterator internalConstEnd() const
void consecutiveRenumberVertices(long offset=0)
void extractEnvelope(PatchKernel &envelope) const
long getInternalCellCount() const
std::vector< long > findOrphanCells() const
void displayInterfaces(std::ostream &out, unsigned int padding=0) const
bool isInterfaceOrphan(long id) const
int getProcessorCount() const
virtual std::vector< adaption::Info > _adaptionPrepare(bool trackAdaption)
PiercedVector< Interface > & getInterfaces()
virtual ElementType getCellType(long id) const
void setInterfaceAlterationFlags(AlterationFlags flags)
bool testCellAlterationFlags(long id, AlterationFlags flags) const
void setPartitioningStatus(PartitioningStatus status)
CellConstIterator ghostCellConstBegin() const
long getInternalVertexCount() const
long countBorderFaces() const
bool findFaceNeighCell(long cellId, long neighId, int *cellFace, int *cellAdjacencyId) const
void consecutiveRenumber(long offsetVertices, long offsetCells, long offsetInterfaces)
CellConstIterator ghostConstBegin() const
virtual std::vector< adaption::Info > _adaptionAlter(bool trackAdaption)
std::array< double, 3 > evalElementCentroid(const Element &element) const
virtual std::array< double, 3 > evalCellCentroid(long id) const
bool deleteCells(const IdStorage &ids)
std::vector< long > findOrphanVertices()
bool reserveCells(size_t nCells)
AlterationFlags getInterfaceAlterationFlags(long id) const
bool isBoundingBoxDirty(bool global=false) const
void resetInterfaceAlterationFlags(long id, AlterationFlags flags=FLAG_NONE)
std::vector< int > getNeighbourRanks()
void updateLastInternalCellId()
bool isPartitioningSupported() const
void setCellAlterationFlags(AlterationFlags flags)
long getGhostCellCount() const
long getGhostCount() const
bool reserveVertices(size_t nVertices)
void setBoundingBox(const std::array< double, 3 > &minPoint, const std::array< double, 3 > &maxPoint)
void processCellsFaceNeighbours(const SeedContainer &seedIds, int nLayers, Function function) const
long countFreeFaces() const
virtual void _setHaloSize(std::size_t haloSize)
std::vector< long > findCellVertexOneRing(long id, int vertex) const
CellIterator internalCellEnd()
bool isAdaptionSupported() const
CellConstIterator getCellConstIterator(long id) const
ConstProxyVector< std::array< double BITPIT_COMMA 3 > > getCellVertexCoordinates(long id) const
virtual void resetCells()
bool isCommunicatorSet() const
int getCellOwner(long id) const
virtual void setCommunicator(MPI_Comm communicator)
void pruneStaleInterfaces()
std::vector< adaption::Info > adaptionAlter(bool trackAdaption=true, bool squeezeStorage=false)
virtual void _findCellVertexNeighs(long id, int vertex, const std::vector< long > *blackList, std::vector< long > *neighs) const
Cell & getFirstGhostCell()
bool isThreeDimensional() const
bool deleteInterfaces(const IdStorage &ids)
The PatchManager oversee the handling of the patches.
Numbering information about the patch.
Iterator for the class PiercedStorage.
The PiercedStorageRange allow to iterate using range-based loops over a PiercedStorage.
Metafunction for generating a pierced vector.
PiercedVectorStorage< value_t, id_t >::const_range const_range
PiercedVectorStorage< value_t, id_t >::const_iterator const_iterator
PiercedVectorStorage< value_t, id_t >::iterator iterator
Metafunction for generating a list of elements that can be either stored in an external vectror or,...
The base class to be used to derive VTK streamers form.
VTK input output for Unstructured Meshes.
The Vertex class defines the vertexs.
std::array< double, 3 > & getCoords()
#define BITPIT_DEPRECATED(func)