Loading...
Searching...
No Matches
levelSetProxyObject.tpp
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_PROXY_OBJECT_TPP__
26# define __BITPIT_LEVELSET_PROXY_OBJECT_TPP__
27
28namespace bitpit {
29
39template<typename SourceLevelSetObject, typename BaseLevelSetObject>
42
52template<typename SourceLevelSetObject, typename BaseLevelSetObject>
54 return false;
55}
56
67template<typename SourceLevelSetObject, typename BaseLevelSetObject>
70 // Mesh information
71 const VolumeKernel &mesh = *(this->getKernel()->getMesh()) ;
75 // Get cell zone cache
76 typedef typename BaseLevelSetObject::CellCacheCollection::template ValueCache<char> BaseZoneCache;
77 BaseZoneCache *locationCache = this->template getCellCache<char>(this->m_cellLocationCacheId);
79 // Get zone information from reference object
80 for (VolumeKernel::CellConstIterator cellItr = cellBegin; cellItr != cellEnd; ++cellItr) {
81 long cellId = cellItr.getId();
82 LevelSetCellLocation cellLocation = getCellReferenceObject(cellId)->getCellLocation(cellId);
83 locationCache->insertEntry(cellId, static_cast<char>(cellLocation));
84 }
85}
86
99template<typename SourceLevelSetObject, typename BaseLevelSetObject>
101{
102 // Get cell location cache
103 typedef typename BaseLevelSetObject::CellCacheCollection::template ValueCache<char> BaseZoneCache;
104 BaseZoneCache *locationCache = this->template getCellCache<char>(this->m_cellLocationCacheId);
105
106 // Get location information from reference object
107 for (const adaption::Info &adaptionInfo : adaptionData) {
108 if (adaptionInfo.entity != adaption::Entity::ENTITY_CELL) {
109 continue;
110 }
111
112 // Skip received cells when the cache is non-volatile
113 //
114 // If the cache is non-volatile, data on exchanged cells has been communicated during
115 // cache adaption.
116 if (adaptionInfo.type == adaption::Type::TYPE_PARTITION_RECV && !locationCache->isVolatile()) {
117 continue;
118 }
119
120 // Add current cells to the process list
121 for (long cellId : adaptionInfo.current) {
122 LevelSetCellLocation cellLocation = getCellReferenceObject(cellId)->getCellLocation(cellId);
123 locationCache->insertEntry(cellId, static_cast<char>(cellLocation));
124 }
125 }
126}
127
143template<typename SourceLevelSetObject, typename BaseLevelSetObject>
145{
146 return getCellReferenceObject(id)->isCellInNarrowBand(id);
147}
148
157template<typename SourceLevelSetObject, typename BaseLevelSetObject>
159{
160 return getReferenceObject(point)->isInNarrowBand(point);
161}
162
170template<typename SourceLevelSetObject, typename BaseLevelSetObject>
172
173 const SourceLevelSetObject *referenceObject = getCellReferenceObject(id);
174 if (!referenceObject) {
175 return nullptr;
176 }
177
178 if (referenceObject->isPrimary()) {
179 return referenceObject;
180 }
181
182 if( const LevelSetProxyObject *referenceProxyObject = dynamic_cast<const LevelSetProxyObject*>(referenceObject) ){
183 return referenceProxyObject->getCellReferencePrimaryObject(id);
184 }
185
186 return nullptr;
187
188}
189
197template<typename SourceLevelSetObject, typename BaseLevelSetObject>
198const SourceLevelSetObject * LevelSetProxyObject<SourceLevelSetObject, BaseLevelSetObject>::getReferencePrimaryObject(const std::array<double, 3> &point) const{
199
200 const SourceLevelSetObject *referenceObject = getReferenceObject(point);
201 if (!referenceObject) {
202 return nullptr;
203 }
204
205 if (referenceObject->isPrimary()) {
206 return referenceObject;
207 }
208
209 if( const LevelSetProxyObject *referenceProxyObject = dynamic_cast<const LevelSetProxyObject*>(referenceObject) ){
210 return referenceProxyObject->getReferencePrimaryObject(point);
211 }
212
213 return nullptr;
214
215}
216
224template<typename SourceLevelSetObject, typename BaseLevelSetObject>
226
227 const SourceLevelSetObject *referenceObject = getCellReferenceObject(id);
228 if (!referenceObject) {
230 }
231
232 return referenceObject->getId();
233
234}
235
243template<typename SourceLevelSetObject, typename BaseLevelSetObject>
245
246 const SourceLevelSetObject *referenceObject = getCellReferenceObject(id);
247 if (!referenceObject) {
249 }
250
251 if (referenceObject->isPrimary()) {
252 return referenceObject->getId();
253 }
254
255 const LevelSetProxyBaseObject *referenceProxyObject = dynamic_cast<const LevelSetProxyBaseObject *>(referenceObject);
256 if (!referenceProxyObject) {
258 }
259
260 return referenceProxyObject->getCellReferencePrimaryObjectId(id);
261}
262
270template<typename SourceLevelSetObject, typename BaseLevelSetObject>
272
273 const SourceLevelSetObject *referenceObject = getReferenceObject(point);
274 if (!referenceObject) {
276 }
277
278 return referenceObject->getId();
279
280}
281
289template<typename SourceLevelSetObject, typename BaseLevelSetObject>
291
292 const SourceLevelSetObject *referenceObject = getReferenceObject(point);
293 if (!referenceObject) {
295 }
296
297 if (referenceObject->isPrimary()) {
298 return referenceObject->getId();
299 }
300
301
302 const LevelSetProxyBaseObject *referenceProxyObject = dynamic_cast<const LevelSetProxyBaseObject *>(referenceObject);
303 if (!referenceProxyObject) {
305 }
306
307 return referenceProxyObject->getReferencePrimaryObjectId(point);
308}
309
315template<typename SourceLevelSetObject, typename BaseLevelSetObject>
317
318 std::vector<const SourceLevelSetObject *> objects;
319 for( const SourceLevelSetObject *sourceObject : getSourceObjects()){
320 if( const LevelSetProxyObject *proxySourceObject = dynamic_cast<const LevelSetProxyObject*>(sourceObject) ){
321 std::vector<const SourceLevelSetObject *> sourcePrimarySourceObjects = proxySourceObject->getPrimarySourceObjects();
322 objects.insert(objects.end(), sourcePrimarySourceObjects.begin(), sourcePrimarySourceObjects.end());
323 } else {
324 objects.push_back(sourceObject);
325 }
326 }
327
328 return objects;
329
330}
331
337template<typename SourceLevelSetObject, typename BaseLevelSetObject>
339
340 std::vector<const SourceLevelSetObject*> sourceObjects = getSourceObjects();
341 std::size_t nSourceObjects = sourceObjects.size();
342
343 std::vector<int> sourceIds(nSourceObjects);
344 for (std::size_t i = 0; i < nSourceObjects; ++i) {
345 const SourceLevelSetObject *sourceObject = sourceObjects[i];
346 sourceIds[i] = sourceObject->getId();
347 }
348
349 return sourceIds;
350
351}
352
358template<typename SourceLevelSetObject, typename BaseLevelSetObject>
360
361 std::vector<const SourceLevelSetObject*> primaryObjects = getPrimarySourceObjects();
362 std::size_t nPrimaryObjects = primaryObjects.size();
363
364 std::vector<int> primaryIds(nPrimaryObjects);
365 for (std::size_t i = 0; i < nPrimaryObjects; ++i) {
366 const SourceLevelSetObject *primaryObject = primaryObjects[i];
367 primaryIds[i] = primaryObject->getId();
368 }
369
370 return primaryIds;
371
372}
373
381template<typename SourceLevelSetObject, typename BaseLevelSetObject>
383
384 return getReferencePrimaryObjectId(id);
385
386}
387
388}
389
390#endif
Interface class for all objects, which depend on other LevelSetObjects.
virtual const SourceLevelSetObject * getCellReferencePrimaryObject(long id) const
int getReferencePrimaryObjectId(const std::array< double, 3 > &point) const override
int getCellReferenceObjectId(long id) const override
std::vector< int > getPrimarySourceObjectIds() const override
bool isCellInNarrowBand(long id) const override
virtual std::vector< const SourceLevelSetObject * > getPrimarySourceObjects() const
int getCellReferencePrimaryObjectId(long id) const override
bool isInNarrowBand(const std::array< double, 3 > &point) const override
int getReferenceObjectId(const std::array< double, 3 > &point) const override
std::vector< int > getSourceObjectIds() const override
virtual const SourceLevelSetObject * getReferencePrimaryObject(const std::array< double, 3 > &point) const
CellConstIterator cellConstBegin() const
CellConstIterator cellConstEnd() const
Iterator for the class PiercedStorage.
The VolumeKernel class provides an interface for defining volume patches.
The Info struct defines the information associated to an adaption.
Definition adaption.hpp:63
--- layout: doxygen_footer ---