25# ifndef __BITPIT_LEVELSET_OBJECT_HPP__
26# define __BITPIT_LEVELSET_OBJECT_HPP__
32# include <unordered_map>
33# include <unordered_set>
35# include "bitpit_IO.hpp"
37# include "bitpit_communications.hpp"
39# include "bitpit_containers.hpp"
40# include "levelSetCommon.hpp"
41# include "levelSetCache.hpp"
42# include "levelSetKernel.hpp"
43# include "levelSetCartesianKernel.hpp"
44# include "levelSetOctreeKernel.hpp"
45# include "levelSetUnstructuredKernel.hpp"
59template<
typename SourceLevelSetObject,
typename BaseLevelSetObject>
76 virtual bool empty()
const = 0;
80 void update(
const std::vector<adaption::Info> &adaptionData);
91 virtual bool isInNarrowBand(
const std::array<double,3> &point)
const;
96 virtual double evalCellValue(
long id,
bool signedLevelSet)
const;
97 virtual std::array<double,3>
evalCellGradient(
long id,
bool signedLevelSet)
const;
100 virtual short evalSign(
const std::array<double,3> &point)
const;
101 virtual double evalValue(
const std::array<double,3> &point,
bool signedLevelSet)
const;
102 virtual std::array<double,3>
evalGradient(
const std::array<double,3> &point,
bool signedLevelSet)
const;
105 void enableVTKOutput(
const LevelSetFieldset &fieldset,
bool enable=
true);
106 void enableVTKOutput(
const LevelSetFieldset &fieldset,
const std::string &objectName,
bool enable=
true);
118 BITPIT_DEPRECATED_FOR(
short getSign(
long cellId)
const,
short evalCellSign(
long id)
const);
119 BITPIT_DEPRECATED_FOR(
double getValue(
long cellId)
const,
double evalCellValue(
long id,
bool signedLevelSet)
const);
120 BITPIT_DEPRECATED_FOR(std::array<double BITPIT_COMMA 3> getGradient(
long cellId)
const, std::array<double BITPIT_COMMA 3>
evalCellGradient(
long id,
bool signedLevelSet)
const);
128 template<
typename data_t>
136 bool m_defaultSignedLevelSet;
138 LevelSetFieldMap<std::string> m_enabledOutputFields;
179 virtual void dump(std::ostream &);
180 virtual void restore(std::istream &);
184 virtual short _evalCellSign(
long id)
const = 0;
185 virtual double _evalCellValue(
long id,
bool signedLevelSet)
const = 0;
186 virtual std::array<double,3> _evalCellGradient(
long id,
bool signedLevelSet)
const = 0;
188 virtual short _evalSign(
const std::array<double,3> &point)
const;
189 virtual double _evalValue(
const std::array<double,3> &point,
bool signedLevelSet)
const = 0;
190 virtual std::array<double,3> _evalGradient(
const std::array<double,3> &point,
bool signedLevelSet)
const = 0;
194# if BITPIT_ENABLE_MPI
204 void pruneCellCache(std::size_t cacheId,
const std::vector<long> &cellIds);
217 template<
typename value_t,
typename evaluator_t,
typename fallback_t>
219 template<
typename value_t,
typename evaluator_t,
typename fallback_t>
226 template<
typename value_t>
229 template<
typename value_t>
234 template<
typename value_t>
240 template<
typename value_t>
243 template<
typename value_t>
254 template<
typename value_t,
typename evaluator_t,
typename fallback_t>
256 const evaluator_t evluator,
const fallback_t fallback)
const;
263 std::size_t m_nReferences;
267 mutable std::unique_ptr<CellCacheCollection> m_cellCacheCollection;
269 std::vector<LevelSetCacheMode> m_cellFieldCacheModes;
270 std::vector<std::size_t> m_cellFieldCacheIds;
274 std::size_t incrementReferenceCount();
275 std::size_t decrementReferenceCount();
282#include "levelSetObject.tpp"
The DataCommunicator class provides the infrastructure needed to exchange data among processes.
The class ElementCacheCollection allows to store a collection of caches for the elements of a mesh.
static const std::size_t NULL_CACHE_ID
The class LevelSetCache is the base class for defining caches.
Mesh specific implementation to calculate the levelset function.
Interface class for all objects with respect to whom the levelset function may be computed.
double getLS(long cellId) const
std::vector< long > evalCellCacheStaleIds(const std::vector< adaption::Info > &adaptionData) const
void clearCellCache(std::size_t cacheId, bool release)
void flushData(std::fstream &, const std::string &, VTKFormat) override
LevelSetInfo getLevelSetInfo(long cellId) const
virtual void destroyFieldCellCache(LevelSetField field)
CellCacheCollection::ValueCache< value_t > * getCellCache(std::size_t cacheId) const
static const LevelSetIntersectionMode CELL_LOCATION_INTERSECTION_MODE
void destroyCellCache(std::size_t cacheId)
LevelSetBulkEvaluationMode getCellBulkEvaluationMode() const
void pruneCellCache(std::size_t cacheId, const std::vector< long > &cellIds)
void updateCellNarrowBandData(const std::vector< adaption::Info > &adaptionData)
void completeCellCachesExchange(const std::unordered_map< int, std::vector< long > > &sendCellIds, const std::vector< std::size_t > &cacheIds, DataCommunicator *)
void startCellCachesExchange(const std::unordered_map< int, std::vector< long > > &recvCellIds, const std::vector< std::size_t > &cacheIds, DataCommunicator *) const
void setSizeNarrowBand(double)
void destroyCellBulkData()
std::vector< long > evalCellCacheFillIds(LevelSetZone zone, LevelSetCacheMode cacheMode) const
void fillFieldCellCache(LevelSetField field, const std::vector< long > &cellIds)
void setDefaultLevelSetSigndness(bool signedLevelSet)
short evalValueSign(double value) const
virtual double evalValue(const std::array< double, 3 > &point, bool signedLevelSet) const
LevelSetKernel * m_kernel
virtual std::array< double, 3 > evalCellProjectionPoint(long id) const
void removeVTKOutputData(LevelSetField field, const std::string &objectName)
std::size_t createCellCache(LevelSetFillIn expectedFillIn, std::size_t cacheId=CellCacheCollection::NULL_CACHE_ID)
void completeCellCacheExchange(const std::unordered_map< int, std::vector< long > > &sendCellIds, std::size_t cacheIds, DataCommunicator *)
void enableFieldCellCache(LevelSetField field, LevelSetCacheMode cacheMode)
std::array< double BITPIT_COMMA 3 > computeVertexProjectionPoint(long vertexId) const
virtual const LevelSetKernel * getKernel() const
std::size_t getFieldCellCacheId(LevelSetField field) const
CellCacheCollection::ValueCache< value_t > * getFieldCellCache(LevelSetField field) const
virtual std::size_t createCellLocationCache(std::size_t cacheId=CellCacheCollection::NULL_CACHE_ID)
void updateCellBulkData(const std::vector< adaption::Info > &adaptionData)
void setCellBulkEvaluationMode(LevelSetBulkEvaluationMode evaluationMode)
virtual void addVTKOutputData(LevelSetField field, const std::string &objectName)
void destroyCellLocationCache()
static const bool CELL_CACHE_IS_SIGNED
double m_narrowBandSize
Size of narrow band.
virtual std::string getVTKOutputFieldName(LevelSetField field) const
LevelSetIntersectionStatus intersectSurface(long, LevelSetIntersectionMode=LevelSetIntersectionMode::FAST_FUZZY) const
virtual bool isPrimary() const
virtual ~LevelSetObject()
virtual std::size_t createCellPropagatedSignCache(std::size_t cacheId=CellCacheCollection::NULL_CACHE_ID)
virtual void fillCellPropagatedSignCache()
virtual short evalSign(const std::array< double, 3 > &point) const
virtual std::array< double, 3 > evalProjectionPoint(const std::array< double, 3 > &point) const
LevelSetCacheMode getFieldCellCacheMode(LevelSetField field) const
virtual short _evalSign(const std::array< double, 3 > &point) const
std::vector< long > evalCellNarrowBandCacheFillIds(LevelSetZone zone) const
virtual LevelSetIntersectionStatus _intersectSurface(long, double distance, LevelSetIntersectionMode=LevelSetIntersectionMode::FAST_FUZZY) const
virtual std::array< double, 3 > evalCellGradient(long id, bool signedLevelSet) const
void disableFieldCellCache(LevelSetField field)
void destroyCellPropagatedSignCache()
virtual double evalCellValue(long id, bool signedLevelSet) const
virtual std::array< double, 3 > evalGradient(const std::array< double, 3 > &point, bool signedLevelSet) const
virtual LevelSetFieldset getSupportedFields() const
virtual void dump(std::ostream &)
bool hasVTKOutputData(LevelSetField field, const std::string &objectName) const
virtual void fillCellLocationCache()
virtual short evalCellSign(long id) const
LevelSetCellLocation getCellLocation(long id) const
LevelSetZone getCellZone(long id) const
void evaluateCellNarrowBandData()
void adaptCellCaches(const std::vector< adaption::Info > &adaptionData)
virtual bool isCellInNarrowBand(long id) const
std::vector< long > evalCellOnDemandCacheFillIds(LevelSetZone zone) const
value_t evalCellFieldCached(LevelSetField field, long id, const evaluator_t &evaluator, const fallback_t &fallback) const
void setNarrowBandSize(double size)
std::size_t m_cellLocationCacheId
Id of the cache that will keep track if cell zones.
double getNarrowBandSize() const
void destroyCellNarrowBandData()
double getSizeNarrowBand() const
std::array< double BITPIT_COMMA 3 > computeProjectionPoint(long cellId) const
virtual LevelSetCellLocation fillCellGeometricNarrowBandLocationCache(long id)
void enableVTKOutput(const LevelSetFieldset &fieldset, bool enable=true)
std::size_t m_cellPropagatedSignCacheId
Id of the cache that will keep track if cell propagated sign.
void fillFieldCellCaches(LevelSetZone zone, const std::vector< LevelSetField > &fields)
virtual void flushVTKOutputData(std::fstream &stream, VTKFormat format, LevelSetField field) const
value_t evalCellField(LevelSetField field, long id, const evaluator_t &evaluator, const fallback_t &fallback) const
virtual void setKernel(LevelSetKernel *)
void evaluateCellBulkData()
virtual void restore(std::istream &)
std::size_t getReferenceCount() const
std::vector< long > evalCellFullCacheFillIds(LevelSetZone zone) const
virtual std::size_t createFieldCellCache(LevelSetField field, std::size_t cacheId=CellCacheCollection::NULL_CACHE_ID)
std::string getVTKOutputDataName(LevelSetField field, const std::string &objectName) const
virtual bool isInNarrowBand(const std::array< double, 3 > &point) const
void update(const std::vector< adaption::Info > &adaptionData)
void startCellCacheExchange(const std::unordered_map< int, std::vector< long > > &recvCellIds, std::size_t cacheIds, DataCommunicator *) const
Interface class for all objects, which depend on other LevelSetObjects.
The class LevelSetCache is the base class for defining caches that store values.
The base class to be used to derive VTK streamers form.
#define BITPIT_DEPRECATED(func)
LevelSetIntersectionStatus
LevelSetBulkEvaluationMode
A public container which includes all information provided by LevelSet.