Loading...
Searching...
No Matches
levelSet.hpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25# ifndef __BITPIT_LEVELSET_HPP__
26# define __BITPIT_LEVELSET_HPP__
27
28// Standard Template Library
29# include <array>
30# include <vector>
31# include <unordered_map>
32# include <unordered_set>
33# include <memory>
34
35# include "levelSetCommon.hpp"
36
37# include "bitpit_IO.hpp"
38
39namespace bitpit{
40
41namespace adaption{
42 struct Info;
43}
44class VolumeKernel;
45class SurfaceKernel;
46class SurfUnstructured;
47
48class LevelSetKernel;
49class LevelSetObject;
50
52
53private:
54 std::unique_ptr<LevelSetKernel> m_kernel ;
56 LevelSetFillIn m_expectedFillIn;
58 bool m_signedDistance;
60 bool m_forceSignPropagation;
61 bool m_signPropagationEnabled;
63 double m_narrowBandSize;
66 IndexGenerator<long> m_objectIdentifierGenerator;
67 std::unordered_map<int,std::unique_ptr<LevelSetObject>> m_objects ;
68 std::vector<int> m_orderedObjectsIds ;
70 int registerObject( std::unique_ptr<LevelSetObject> && ) ;
71 bool unregisterObject(int id, bool force);
72
73 void registerObjectId(int) ;
74 void unregisterObjectId(int) ;
75
76 void incrementObjectsReferenceCount(int parentId) ;
77 void decrementObjectsReferenceCount(int parentId) ;
78
79public:
81
82 LevelSet(LevelSet&& other) = default;
83
84 void clear();
85 void update(const std::vector<adaption::Info> &adaptionData) ;
86
87 double getNarrowBandSize() const;
88 void setNarrowBandSize(double size = 0);
89
90 void setMesh( VolumeKernel* mesh ) ;
91
92 template<typename LevelSetSourceObject = LevelSetObject>
94
95 template<typename LevelSetSourceObject = LevelSetObject>
97 template<typename LevelSetSourceObject = LevelSetObject>
98 int addObject( LevelSetBooleanOperation, const std::vector<int> &, int id=levelSetDefaults::OBJECT ) ;
99
100 int addObject( std::unique_ptr<SurfaceKernel> &&, double, int id = levelSetDefaults::OBJECT ) ;
101 int addObject( SurfaceKernel *, double, int id = levelSetDefaults::OBJECT ) ;
103 int addObject( std::unique_ptr<SurfUnstructured> &&, double, int id = levelSetDefaults::OBJECT ) ;
104 int addObject( SurfUnstructured *, double, int id = levelSetDefaults::OBJECT ) ;
106 int addObject( const std::unordered_set<long> &, int id=levelSetDefaults::OBJECT ) ;
107 int addObject( const std::vector<long> &, long, bool, int id=levelSetDefaults::OBJECT ) ;
108 int addObject( std::unique_ptr<LevelSetObject> && ) ;
109
110 void removeObjects();
111 bool removeObject(int);
112
113 bool isObjectRemovable(int);
114
115 LevelSetObject & getObject( int ) const ;
116 LevelSetObject * getObjectPtr( int ) const ;
117 std::vector<LevelSetObject *> getObjectPtrs( ) const ;
118
119 template<typename T>
120 T & getObject( int ) const ;
121 template<typename T>
122 T * getObjectPtr( int ) const ;
123 template<typename T>
124 std::vector<T *> getObjectPtrs( ) const ;
125
126 int getObjectCount( ) const ;
127 std::vector<int> getObjectIds( ) const ;
128
129 void dump( std::ostream &) const;
130 void restore( std::istream &);
131
132 BITPIT_DEPRECATED_FOR(void setSizeNarrowBand(double size), void setNarrowBandSize(double size));
133 BITPIT_DEPRECATED_FOR(double getSizeNarrowBand() const, double getNarrowBandSize() const);
134
135 BITPIT_DEPRECATED(void setSign(bool));
137
138 BITPIT_DEPRECATED_FOR(void compute(), void evaluate());
139 BITPIT_DEPRECATED_FOR(void compute(int id), void evaluate(int id));
140 BITPIT_DEPRECATED_FOR(void compute(const std::vector<int> &ids), void evaluate(const std::vector<int> &ids));
141
142 BITPIT_DEPRECATED_FOR(void update(const std::vector<adaption::Info> &adaptionData, int id), void update(const std::vector<adaption::Info> &adaptionData));
143 BITPIT_DEPRECATED_FOR(void update(const std::vector<adaption::Info> &adaptionData, const std::vector<int> &ids), void update(const std::vector<adaption::Info> &adaptionData));
144
145# if BITPIT_ENABLE_MPI
146 BITPIT_DEPRECATED(void partition( const std::vector<adaption::Info> & ));
147# endif
148};
149
150}
151
152// Template implementation
153#include "levelSet.tpp"
154
155#endif
The IndexGenerator class allows to generate unique ids.
Interface class for all objects with respect to whom the levelset function may be computed.
Level Set driver class.
Definition levelSet.hpp:51
LevelSetObject & getObject(int) const
Definition levelSet.cpp:569
int addObjectComplement(int, int id=levelSetDefaults::OBJECT)
Definition levelSet.tpp:38
void setNarrowBandSize(double size=0)
Definition levelSet.cpp:164
void setPropagateSign(bool)
Definition levelSet.cpp:673
int getObjectCount() const
Definition levelSet.cpp:594
void restore(std::istream &)
Definition levelSet.cpp:636
void setSign(bool)
Definition levelSet.cpp:656
LevelSetObject * getObjectPtr(int) const
Definition levelSet.cpp:578
void setMesh(VolumeKernel *mesh)
Definition levelSet.cpp:183
std::vector< LevelSetObject * > getObjectPtrs() const
Definition levelSet.cpp:586
std::vector< int > getObjectIds() const
Definition levelSet.cpp:602
void update(const std::vector< adaption::Info > &adaptionData)
Definition levelSet.cpp:113
void dump(std::ostream &) const
Definition levelSet.cpp:616
double getNarrowBandSize() const
Definition levelSet.cpp:145
LevelSet(LevelSetFillIn expectedFillIn=LevelSetFillIn::SPARSE)
Definition levelSet.cpp:83
bool removeObject(int)
Definition levelSet.cpp:416
void partition(const std::vector< adaption::Info > &)
Definition levelSet.cpp:817
int addObject(LevelSetBooleanOperation, int, int, int id=levelSetDefaults::OBJECT)
Definition levelSet.tpp:60
bool isObjectRemovable(int)
Definition levelSet.cpp:451
The SurfUnstructured class defines an unstructured surface triangulation.
The SurfaceKernel class provides an interface for defining surface patches.
The VolumeKernel class provides an interface for defining volume patches.
#define BITPIT_DEPRECATED(func)
Definition compiler.hpp:87
--- layout: doxygen_footer ---