Loading...
Searching...
No Matches
levelSetObject.cpp
78const LevelSetIntersectionMode LevelSetObject::CELL_LOCATION_INTERSECTION_MODE = LevelSetIntersectionMode::FAST_GUARANTEE_FALSE;
93 m_cellFieldCacheIds(static_cast<std::size_t>(LevelSetField::COUNT), CellCacheCollection::NULL_CACHE_ID)
415 for (std::size_t fieldIndex = 0; fieldIndex < static_cast<std::size_t>(LevelSetField::COUNT); ++fieldIndex) {
422 } else if (fieldCacheMode == LevelSetCacheMode::FULL && getCellBulkEvaluationMode() == LevelSetBulkEvaluationMode::EXACT) {
501 CellCacheCollection::ValueCache<char> *locationCache = getCellCache<char>(m_cellLocationCacheId);
567 for (VolumeKernel::CellConstIterator cellItr = internalCellsBegin; cellItr != internalCellsEnd; ++cellItr) {
574 CellCacheCollection::ValueCache<char> *locationCache = getCellCache<char>(m_cellLocationCacheId);
615 locationCache->insertEntry(neighId, static_cast<char>(LevelSetCellLocation::NARROW_BAND_NEIGHBOUR));
626 CellCacheCollection::ValueCache<char>::Entry locationCacheEntry = locationCache->findEntry(cellId);
637 startCellCacheExchange(mesh.getGhostCellExchangeSources(), m_cellLocationCacheId, dataCommunicator.get());
638 completeCellCacheExchange(mesh.getGhostCellExchangeTargets(), m_cellLocationCacheId, dataCommunicator.get());
661 CellCacheCollection::ValueCache<char> *locationCache = getCellCache<char>(m_cellLocationCacheId);
733 startCellCacheExchange(mesh.getGhostCellExchangeSources(), m_cellLocationCacheId, dataCommunicator.get());
734 completeCellCacheExchange(mesh.getGhostCellExchangeTargets(), m_cellLocationCacheId, dataCommunicator.get());
787 locationCache->insertEntry(neighId, static_cast<char>(LevelSetCellLocation::NARROW_BAND_NEIGHBOUR));
806 startCellCacheExchange(mesh.getGhostCellExchangeSources(), m_cellLocationCacheId, dataCommunicator.get());
807 completeCellCacheExchange(mesh.getGhostCellExchangeTargets(), m_cellLocationCacheId, dataCommunicator.get());
837 if (_isCellIntersected(id, cellUnsignedValue, CELL_LOCATION_INTERSECTION_MODE) == LevelSetIntersectionStatus::TRUE) {
844 CellCacheCollection::ValueCache<char> *locationCache = getCellCache<char>(m_cellLocationCacheId);
1042 ghostCommunicator = std::unique_ptr<DataCommunicator>(new DataCommunicator(mesh.getCommunicator()));
1070 for (VolumeKernel::CellConstIterator cellItr = internalCellsBegin; cellItr != internalCellsEnd; ++cellItr) {
1077 CellCacheCollection::ValueCache<char> *propagatedSignCache = getCellCache<char>(m_cellPropagatedSignCacheId);
1107 CellCacheCollection::ValueCache<char>::Entry seedSignEntry = propagatedSignCache->findEntry(seedId);
1130 CellCacheCollection::ValueCache<char>::Entry cellSignEntry = propagatedSignCache->findEntry(cellId);
1209 CellCacheCollection::ValueCache<char>::Entry cellSignEntry = propagatedSignCache->findEntry(cellId);
1262 MPI_Allreduce(MPI_IN_PLACE, &ghostSignMismatch, 1, MPI_C_BOOL, MPI_LOR, mesh.getCommunicator());
1341LevelSetIntersectionStatus LevelSetObject::intersectSurface(long id, LevelSetIntersectionMode mode) const
1379LevelSetIntersectionStatus LevelSetObject::isCellIntersected(long id, LevelSetIntersectionMode mode) const
1481LevelSetIntersectionStatus LevelSetObject::_isCellIntersected(long id, double distance, LevelSetIntersectionMode mode) const
1489 if(utils::DoubleFloatingLessEqual()(distance, tangentSphere, distanceTolerance, distanceTolerance)){
1501 if(utils::DoubleFloatingGreater()(distance, boundingSphere, distanceTolerance, distanceTolerance)){
1513 if(utils::DoubleFloatingGreater()(distance, boundingSphere, distanceTolerance, distanceTolerance)){
1518 if(utils::DoubleFloatingLessEqual()(distance, tangentSphere, distanceTolerance, distanceTolerance)){
1530 if(utils::DoubleFloatingGreater()(distance, boundingSphere, distanceTolerance, distanceTolerance)){
1535 if(utils::DoubleFloatingLessEqual()(distance, tangentSphere, distanceTolerance, distanceTolerance)){
1604 CellCacheCollection::ValueCache<char> *propagatedSignCache = getCellCache<char>(m_cellPropagatedSignCacheId);
1606 CellCacheCollection::ValueCache<char>::Entry propagatedSignCacheEntry = propagatedSignCache->findEntry(id);
1619 CellCacheCollection::ValueCache<char> *propagatedSignCache = getCellCache<char>(m_cellPropagatedSignCacheId);
1695 std::array<double, 3> gradient = evalCellFieldCached<std::array<double, 3>>(field, id, evaluator, fallback);
1715 return m_kernel->computeCellCentroid(id) - evalCellValue(id, true) * evalCellGradient(id, true);
1733double LevelSetObject::evalValue(const std::array<double,3> &point, bool signedLevelSet) const {
1743std::array<double,3> LevelSetObject::evalGradient(const std::array<double,3> &point, bool signedLevelSet) const {
1762std::array<double,3> LevelSetObject::evalProjectionPoint(const std::array<double,3> &point) const{
1854 for (std::size_t fieldIndex = 0; fieldIndex < static_cast<std::size_t>(LevelSetField::COUNT); ++fieldIndex) {
1910 throw std::runtime_error("Unable to restore levelset object " + std::to_string(getId()) + "!");
1954void LevelSetObject::enableVTKOutput( const LevelSetFieldset &fieldset, const std::string &objectName, bool enable) {
1983void LevelSetObject::enableVTKOutput( LevelSetField field, const std::string &objectName, bool enable) {
2028void LevelSetObject::enableVTKOutput( LevelSetWriteField writeField, const std::string &objectName, bool enable) {
2062bool LevelSetObject::hasVTKOutputData( LevelSetField field, const std::string &objectName) const {
2126std::string LevelSetObject::getVTKOutputDataName( LevelSetField field, const std::string &objectName) const {
2173void LevelSetObject::flushData( std::fstream &stream, const std::string &name, VTKFormat format){
2197void LevelSetObject::flushVTKOutputData(std::fstream &stream, VTKFormat format, LevelSetField field) const {
2219 auto evaluator = [this] (long id) -> std::array<double, 3> { return evalCellGradient(id, true); };
2220 auto fallback = [] (long id) -> const std::array<double, 3> & { BITPIT_UNUSED(id); return levelSetDefaults::GRADIENT; };
2241void LevelSetObject::startCellCacheExchange( const std::unordered_map<int, std::vector<long>> &sendCellIds,
2254void LevelSetObject::startCellCachesExchange( const std::unordered_map<int, std::vector<long>> &sendCellIds,
2292void LevelSetObject::completeCellCacheExchange( const std::unordered_map<int, std::vector<long>> &recvCellIds,
2295 completeCellCachesExchange(recvCellIds, std::vector<std::size_t>(1, cacheId), dataCommunicator);
2305void LevelSetObject::completeCellCachesExchange( const std::unordered_map<int, std::vector<long>> &recvCellIds,
2433 MPI_Allreduce(MPI_IN_PLACE, &allCachesEmpty, 1, MPI_C_BOOL, MPI_LAND, m_kernel->getCommunicator()) ;
2450 for (std::size_t fieldIndex = 0; fieldIndex < static_cast<std::size_t>(LevelSetField::COUNT); ++fieldIndex) {
2491 MPI_Allreduce(MPI_IN_PLACE, &exchangeCacheData, 1, MPI_C_BOOL, MPI_LOR, m_kernel->getCommunicator()) ;
2579std::vector<long> LevelSetObject::evalCellCacheFillIds(LevelSetZone zone, LevelSetCacheMode cacheMode) const
2608std::vector<long> LevelSetObject::evalCellCacheFillIds(LevelSetZone zone, LevelSetCacheMode cacheMode,
2654std::vector<long> LevelSetObject::evalCellOnDemandCacheFillIds(LevelSetZone zone, const std::vector<adaption::Info> &adaptionData) const
2732std::vector<long> LevelSetObject::evalCellNarrowBandCacheFillIds(LevelSetZone zone, const std::vector<adaption::Info> &adaptionData) const
2834std::vector<long> LevelSetObject::evalCellFullCacheFillIds(LevelSetZone zone, const std::vector<adaption::Info> &adaptionData) const
2880std::vector<long> LevelSetObject::evalCellCacheStaleIds(const std::vector<adaption::Info> &adaptionData) const
2895 cellPruneIds.insert(cellPruneIds.end(), adaptionInfo.previous.begin(), adaptionInfo.previous.end());
2910typename LevelSetObject::CellCacheCollection::Cache * LevelSetObject::getFieldCellCache(LevelSetField field) const
2985void LevelSetObject::fillFieldCellCaches(LevelSetZone zone, const std::vector<LevelSetField> &fields)
3027void LevelSetObject::fillFieldCellCaches(LevelSetZone zone, const std::vector<LevelSetField> &fields,
3074 for (std::size_t cacheModeIndex = 0; cacheModeIndex < static_cast<std::size_t>(LevelSetCacheMode::COUNT); ++cacheModeIndex) {
3092 std::vector<long> cellVolatileCacheFillIds = evalCellCacheFillIds(zone, cacheMode, adaptionData);
3097 MPI_Allreduce(MPI_IN_PLACE, &emptyCellVolatileCacheFillIds, 1, MPI_C_BOOL, MPI_LAND, m_kernel->getCommunicator()) ;
3164 MPI_Allreduce(MPI_IN_PLACE, &emptyCellIds, 1, MPI_C_BOOL, MPI_LAND, m_kernel->getCommunicator()) ;
3229 completeCellCacheExchange(mesh.getGhostCellExchangeTargets(), cacheId, dataCommunicator.get());
3277typename LevelSetObject::CellCacheCollection::Cache * LevelSetObject::getCellCache(std::size_t cacheId) const
3322std::array<double,3> LevelSetObject::computeProjectionPoint(const std::array<double,3> &point) const{
3366 return LevelSetInfo(evalCellValue(cellId, m_defaultSignedLevelSet), evalCellGradient(cellId, m_defaultSignedLevelSet));
The DataCommunicator class provides the infrastructure needed to exchange data among processes.
Definition communications.hpp:42
void clearAllSends(bool synchronous=false)
Definition communications.cpp:522
SendBuffer & getSendBuffer(int rank)
Definition communications.cpp:696
int waitAnyRecv(const std::vector< int > &blackList=std::vector< int >())
Definition communications.cpp:894
void setSend(int rank, long length=0)
Definition communications.cpp:562
RecvBuffer & getRecvBuffer(int rank)
Definition communications.cpp:709
Mesh specific implementation to calculate the levelset function.
Definition levelSetKernel.hpp:47
std::vector< long > evalCellCacheStaleIds(const std::vector< adaption::Info > &adaptionData) const
Definition levelSetObject.cpp:2880
void clearCellCache(std::size_t cacheId, bool release)
Definition levelSetObject.cpp:2535
void flushData(std::fstream &, const std::string &, VTKFormat) override
Definition levelSetObject.cpp:2173
LevelSetInfo getLevelSetInfo(long cellId) const
Definition levelSetObject.cpp:3364
virtual void destroyFieldCellCache(LevelSetField field)
Definition levelSetObject.cpp:2968
CellCacheCollection::ValueCache< value_t > * getCellCache(std::size_t cacheId) const
Definition levelSetObject.tpp:61
static const LevelSetIntersectionMode CELL_LOCATION_INTERSECTION_MODE
Definition levelSetObject.hpp:135
void destroyCellCache(std::size_t cacheId)
Definition levelSetObject.cpp:3291
LevelSetBulkEvaluationMode getCellBulkEvaluationMode() const
Definition levelSetObject.cpp:945
void pruneCellCache(std::size_t cacheId, const std::vector< long > &cellIds)
Definition levelSetObject.cpp:2553
void updateCellNarrowBandData(const std::vector< adaption::Info > &adaptionData)
Definition levelSetObject.cpp:458
void completeCellCachesExchange(const std::unordered_map< int, std::vector< long > > &sendCellIds, const std::vector< std::size_t > &cacheIds, DataCommunicator *)
Definition levelSetObject.cpp:2305
void startCellCachesExchange(const std::unordered_map< int, std::vector< long > > &recvCellIds, const std::vector< std::size_t > &cacheIds, DataCommunicator *) const
Definition levelSetObject.cpp:2254
void setSizeNarrowBand(double)
Definition levelSetObject.cpp:3395
void destroyCellBulkData()
Definition levelSetObject.cpp:1021
std::vector< long > evalCellCacheFillIds(LevelSetZone zone, LevelSetCacheMode cacheMode) const
Definition levelSetObject.cpp:2579
void fillFieldCellCache(LevelSetField field, const std::vector< long > &cellIds)
Definition levelSetObject.cpp:3145
void setDefaultLevelSetSigndness(bool signedLevelSet)
Definition levelSetObject.cpp:234
short evalValueSign(double value) const
Definition levelSetObject.cpp:1771
virtual double evalValue(const std::array< double, 3 > &point, bool signedLevelSet) const
Definition levelSetObject.cpp:1733
virtual std::array< double, 3 > evalCellProjectionPoint(long id) const
Definition levelSetObject.cpp:1714
void removeVTKOutputData(LevelSetField field, const std::string &objectName)
Definition levelSetObject.cpp:2077
std::size_t createCellCache(LevelSetFillIn expectedFillIn, std::size_t cacheId=CellCacheCollection::NULL_CACHE_ID)
Definition levelSetObject.tpp:112
void completeCellCacheExchange(const std::unordered_map< int, std::vector< long > > &sendCellIds, std::size_t cacheIds, DataCommunicator *)
Definition levelSetObject.cpp:2292
void enableFieldCellCache(LevelSetField field, LevelSetCacheMode cacheMode)
Definition levelSetObject.cpp:2353
std::array< double BITPIT_COMMA 3 > computeVertexProjectionPoint(long vertexId) const
Definition levelSetObject.cpp:3312
virtual const LevelSetKernel * getKernel() const
Definition levelSetObject.cpp:271
std::size_t getFieldCellCacheId(LevelSetField field) const
Definition levelSetObject.cpp:2929
CellCacheCollection::ValueCache< value_t > * getFieldCellCache(LevelSetField field) const
Definition levelSetObject.tpp:40
virtual std::size_t createCellLocationCache(std::size_t cacheId=CellCacheCollection::NULL_CACHE_ID)
Definition levelSetObject.cpp:865
void updateCellBulkData(const std::vector< adaption::Info > &adaptionData)
Definition levelSetObject.cpp:1009
LevelSetIntersectionStatus isCellIntersected(long id, LevelSetIntersectionMode=LevelSetIntersectionMode::FAST_FUZZY) const
Definition levelSetObject.cpp:1379
void setCellBulkEvaluationMode(LevelSetBulkEvaluationMode evaluationMode)
Definition levelSetObject.cpp:955
virtual void addVTKOutputData(LevelSetField field, const std::string &objectName)
Definition levelSetObject.cpp:2092
void destroyCellLocationCache()
Definition levelSetObject.cpp:875
static const bool CELL_CACHE_IS_SIGNED
Definition levelSetObject.hpp:134
virtual std::string getVTKOutputFieldName(LevelSetField field) const
Definition levelSetObject.cpp:2142
virtual std::size_t createCellPropagatedSignCache(std::size_t cacheId=CellCacheCollection::NULL_CACHE_ID)
Definition levelSetObject.cpp:1292
virtual void fillCellPropagatedSignCache()
Definition levelSetObject.cpp:1031
virtual short evalSign(const std::array< double, 3 > &point) const
Definition levelSetObject.cpp:1723
virtual std::array< double, 3 > evalProjectionPoint(const std::array< double, 3 > &point) const
Definition levelSetObject.cpp:1762
LevelSetCacheMode getFieldCellCacheMode(LevelSetField field) const
Definition levelSetObject.cpp:2335
virtual short _evalSign(const std::array< double, 3 > &point) const
Definition levelSetObject.cpp:1753
std::vector< long > evalCellNarrowBandCacheFillIds(LevelSetZone zone) const
Definition levelSetObject.cpp:2670
virtual std::array< double, 3 > evalCellGradient(long id, bool signedLevelSet) const
Definition levelSetObject.cpp:1678
void disableFieldCellCache(LevelSetField field)
Definition levelSetObject.cpp:2391
void destroyCellPropagatedSignCache()
Definition levelSetObject.cpp:1302
virtual double evalCellValue(long id, bool signedLevelSet) const
Definition levelSetObject.cpp:1644
virtual std::array< double, 3 > evalGradient(const std::array< double, 3 > &point, bool signedLevelSet) const
Definition levelSetObject.cpp:1743
virtual LevelSetIntersectionStatus _isInterfaceIntersected(long id, bool positivePart, std::array< std::array< double, 3 >, 2 > *intersection, std::vector< std::array< double, 3 > > *polygon) const
Definition levelSetObject.cpp:1573
virtual LevelSetFieldset getSupportedFields() const
Definition levelSetObject.cpp:175
bool hasVTKOutputData(LevelSetField field, const std::string &objectName) const
Definition levelSetObject.cpp:2062
virtual void fillCellLocationCache()
Definition levelSetObject.cpp:550
virtual short evalCellSign(long id) const
Definition levelSetObject.cpp:1598
LevelSetCellLocation getCellLocation(long id) const
Definition levelSetObject.cpp:483
LevelSetZone getCellZone(long id) const
Definition levelSetObject.cpp:517
void evaluateCellNarrowBandData()
Definition levelSetObject.cpp:444
LevelSetIntersectionStatus intersectSurface(long id, LevelSetIntersectionMode=LevelSetIntersectionMode::FAST_FUZZY) const
Definition levelSetObject.cpp:1341
void adaptCellCaches(const std::vector< adaption::Info > &adaptionData)
Definition levelSetObject.cpp:2414
virtual bool isCellInNarrowBand(long id) const
Definition levelSetObject.cpp:896
std::vector< long > evalCellOnDemandCacheFillIds(LevelSetZone zone) const
Definition levelSetObject.cpp:2636
value_t evalCellFieldCached(LevelSetField field, long id, const evaluator_t &evaluator, const fallback_t &fallback) const
Definition levelSetObject.tpp:236
void setNarrowBandSize(double size)
Definition levelSetObject.cpp:400
LevelSetIntersectionStatus isInterfaceIntersected(long id, bool invert, std::array< std::array< double, 3 >, 2 > *intersection, std::vector< std::array< double, 3 > > *polygon) const
Definition levelSetObject.cpp:1424
std::size_t m_cellLocationCacheId
Id of the cache that will keep track if cell zones.
Definition levelSetObject.hpp:145
double getNarrowBandSize() const
Definition levelSetObject.cpp:384
void destroyCellNarrowBandData()
Definition levelSetObject.cpp:469
double getSizeNarrowBand() const
Definition levelSetObject.cpp:3386
std::array< double BITPIT_COMMA 3 > computeProjectionPoint(long cellId) const
Definition levelSetObject.cpp:3302
virtual LevelSetCellLocation fillCellGeometricNarrowBandLocationCache(long id)
Definition levelSetObject.cpp:826
void enableVTKOutput(const LevelSetFieldset &fieldset, bool enable=true)
Definition levelSetObject.cpp:1938
std::size_t m_cellPropagatedSignCacheId
Id of the cache that will keep track if cell propagated sign.
Definition levelSetObject.hpp:146
void fillFieldCellCaches(LevelSetZone zone, const std::vector< LevelSetField > &fields)
Definition levelSetObject.cpp:2985
virtual void flushVTKOutputData(std::fstream &stream, VTKFormat format, LevelSetField field) const
Definition levelSetObject.cpp:2197
virtual void setKernel(LevelSetKernel *)
Definition levelSetObject.cpp:242
virtual LevelSetIntersectionStatus _isCellIntersected(long, double distance, LevelSetIntersectionMode=LevelSetIntersectionMode::FAST_FUZZY) const
Definition levelSetObject.cpp:1481
void evaluateCellBulkData()
Definition levelSetObject.cpp:998
virtual void restore(std::istream &)
Definition levelSetObject.cpp:1843
std::size_t getReferenceCount() const
Definition levelSetObject.cpp:221
std::vector< long > evalCellFullCacheFillIds(LevelSetZone zone) const
Definition levelSetObject.cpp:2776
virtual std::size_t createFieldCellCache(LevelSetField field, std::size_t cacheId=CellCacheCollection::NULL_CACHE_ID)
Definition levelSetObject.cpp:2944
std::string getVTKOutputDataName(LevelSetField field, const std::string &objectName) const
Definition levelSetObject.cpp:2126
virtual bool isInNarrowBand(const std::array< double, 3 > &point) const
Definition levelSetObject.cpp:919
void update(const std::vector< adaption::Info > &adaptionData)
Definition levelSetObject.cpp:337
void startCellCacheExchange(const std::unordered_map< int, std::vector< long > > &recvCellIds, std::size_t cacheIds, DataCommunicator *) const
Definition levelSetObject.cpp:2241
CellConstIterator internalCellConstEnd() const
Definition patch_kernel.cpp:2746
const std::unordered_map< int, std::vector< long > > & getGhostCellExchangeSources() const
Definition patch_kernel_parallel.cpp:4070
CellConstIterator internalCellConstBegin() const
Definition patch_kernel.cpp:2725
const std::unordered_map< int, std::vector< long > > & getGhostCellExchangeTargets() const
Definition patch_kernel_parallel.cpp:3986
const MPI_Comm & getCommunicator() const
Definition patch_kernel_parallel.cpp:128
void processCellFaceNeighbours(long seedId, int nLayers, Function function) const
Definition patch_kernel.tpp:497
bool isPartitioned() const
Definition patch_kernel_parallel.cpp:1686
CellConstIterator getCellConstIterator(long id) const
Definition patch_kernel.cpp:2695
Buffer to be used for receive communications.
Definition communications_buffers.hpp:107
Buffer to be used for send communications.
Definition communications_buffers.hpp:91
The VolumeKernel class provides an interface for defining volume patches.
Definition volume_kernel.hpp:33
void write(std::ostream &stream, const std::vector< bool > &container)
Definition binaryUtils.cpp:41
void read(std::istream &stream, std::vector< bool > &container)
Definition binaryUtils.cpp:72
bool keywordInString(const std::string &line, const std::string &key)
Definition stringUtils.tpp:175
@ FAST_GUARANTEE_TRUE
Definition levelSetCommon.hpp:120
@ FAST_GUARANTEE_FALSE
Definition levelSetCommon.hpp:121
@ NARROW_BAND_UNDEFINED
Definition levelSetCommon.hpp:87
@ NARROW_BAND_NEIGHBOUR
Definition levelSetCommon.hpp:85
@ NARROW_BAND_INTERSECTED
Narrow band zone, the cell intersects the surface.
Definition levelSetCommon.hpp:84
@ NARROW_BAND_DISTANCE
Definition levelSetCommon.hpp:82
@ SIGN_PROPAGATION
Sign is propagated from the narrow band, no other data will be evaluated.
Definition levelSetCommon.hpp:157
const std::array< double, 3 > GRADIENT
Definition levelSetCommon.hpp:48
A public container which includes all information provided by LevelSet.
Definition levelSetCommon.hpp:59
The Info struct defines the infomation associated to an adaption.
Definition adaption.hpp:63
