OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::opti::SparseGeometrySerializer< S, dim > Class Template Reference

This class serializes the cells which are marked by indicator. More...

#include <serialization.h>

+ Inheritance diagram for olb::opti::SparseGeometrySerializer< S, dim >:
+ Collaboration diagram for olb::opti::SparseGeometrySerializer< S, dim >:

Public Member Functions

 SparseGeometrySerializer (SuperGeometry< S, dim > &superGeometry, FunctorPtr< SuperIndicatorF< S, dim > > &&indicator)
 
 SparseGeometrySerializer (SuperGeometry< S, dim > &superGeometry, FunctorPtr< IndicatorF< S, dim > > &&indicator)
 
std::size_t getSerializedCellIndex (const int latticeR[]) const override
 Compute serialized cell index from lattice coordinates.
 
LatticeR< dim+1 > getLatticeR (std::size_t index) const override
 Get lattice coordinates from serialized cell index.
 
unsigned getNoCells () const override
 
- Public Member Functions inherited from olb::opti::GeometrySerializer< S, dim >
std::size_t getSerializedCellIndex (LatticeR< dim+1 > latticeR) const
 Compute serialized cell index from lattice coordinates.
 
std::size_t getSerializedComponentIndex (const int latticeR[], unsigned iD, unsigned fieldDim) const
 Get index of field component from lattice coordinates and component index.
 
std::size_t getSerializedComponentIndex (LatticeR< dim+1 > latticeR, unsigned iD, unsigned fieldDim) const
 Get index of field component from lattice coordinates and component index.
 
std::size_t getSerializedComponentIndex (LatticeAndFieldR coords, unsigned fieldDim) const
 Get index of field component from lattice coordinates and component index.
 
LatticeAndFieldR getLatticeAndFieldR (std::size_t index, unsigned fieldDim) const
 Get lattice coordinates and field component from serialized field index.
 

Detailed Description

template<typename S, unsigned dim>
class olb::opti::SparseGeometrySerializer< S, dim >

This class serializes the cells which are marked by indicator.

It produces a smaller control vector, but access is more expensive compared to SimpleGeometrySerializer.

Template Parameters
SFloating point type
dimGeometrical dimension

Definition at line 209 of file serialization.h.

Constructor & Destructor Documentation

◆ SparseGeometrySerializer() [1/2]

template<typename S , unsigned dim>
olb::opti::SparseGeometrySerializer< S, dim >::SparseGeometrySerializer ( SuperGeometry< S, dim > & superGeometry,
FunctorPtr< SuperIndicatorF< S, dim > > && indicator )
inline

Definition at line 220 of file serialization.h.

222 : _indicator(std::move(indicator))
223 {
224 const auto cGeometry = superGeometry.getCuboidDecomposition();
225 L latticeR;
226 for (unsigned iC = 0; iC < cGeometry.size(); ++iC) {
227 latticeR[0] = iC;
228 const int nX = cGeometry.get(iC).getNx();
229 const int nY = cGeometry.get(iC).getNy();
230 for (int iX=0; iX<nX; iX++) {
231 latticeR[1] = iX;
232 for (int iY=0; iY<nY; iY++) {
233 latticeR[2] = iY;
234 if constexpr (dim == 2) {
235 if (_indicator(latticeR.data())) {
236 _coords.push_back(latticeR);
237 }
238 } else {
239 const int nZ = cGeometry.get(iC).getNz();
240 for (int iZ=0; iZ<nZ; iZ++) {
241 latticeR[3] = iZ;
242
243 if (_indicator(latticeR.data())) {
244 _coords.push_back(latticeR);
245 }
246 }
247 }
248 }
249 }
250 }
251 }

References olb::Vector< T, Size >::data(), and olb::SuperStructure< T, D >::getCuboidDecomposition().

+ Here is the call graph for this function:

◆ SparseGeometrySerializer() [2/2]

template<typename S , unsigned dim>
olb::opti::SparseGeometrySerializer< S, dim >::SparseGeometrySerializer ( SuperGeometry< S, dim > & superGeometry,
FunctorPtr< IndicatorF< S, dim > > && indicator )
inline

Definition at line 253 of file serialization.h.

255 : SparseGeometrySerializer(superGeometry,
256 new SuperIndicatorFfromIndicatorF<S,dim>(std::move(indicator), superGeometry))
257 { }
SparseGeometrySerializer(SuperGeometry< S, dim > &superGeometry, FunctorPtr< SuperIndicatorF< S, dim > > &&indicator)
std::conditional_t< D==2, SuperIndicatorFfromIndicatorF2D< T >, SuperIndicatorFfromIndicatorF3D< T > > SuperIndicatorFfromIndicatorF
Definition aliases.h:277

Member Function Documentation

◆ getLatticeR()

template<typename S , unsigned dim>
LatticeR< dim+1 > olb::opti::SparseGeometrySerializer< S, dim >::getLatticeR ( std::size_t index) const
inlineoverridevirtual

Get lattice coordinates from serialized cell index.

Implements olb::opti::GeometrySerializer< S, dim >.

Definition at line 283 of file serialization.h.

283 {
284#ifdef OLB_DEBUG
285 // check if index lies in accessible range
286 if (index >= _coords.size()) {
287 OstreamManager clout (std::cout, "SparseGeometrySerializer");
288 clout << "Warning: the passed index is higher than the number of cells "
289 << "which are marked by indicator." << std::endl;
290 std::exit(1);
291 }
292#endif
293 return _coords[index];
294 }

◆ getNoCells()

template<typename S , unsigned dim>
unsigned olb::opti::SparseGeometrySerializer< S, dim >::getNoCells ( ) const
inlineoverridevirtual

Implements olb::opti::GeometrySerializer< S, dim >.

Definition at line 296 of file serialization.h.

296 {
297 return _coords.size();
298 }

◆ getSerializedCellIndex()

template<typename S , unsigned dim>
std::size_t olb::opti::SparseGeometrySerializer< S, dim >::getSerializedCellIndex ( const int latticeR[]) const
inlineoverridevirtual

Compute serialized cell index from lattice coordinates.

Implements olb::opti::GeometrySerializer< S, dim >.

Definition at line 260 of file serialization.h.

260 {
261#ifdef OLB_DEBUG
262 // check if cell lies in indicated domain
263 bool isInside;
264 _indicator(&isInside, latticeR);
265 if (! isInside) {
266 OstreamManager clout (std::cout, "SparseGeometrySerializer");
267 clout << "Warning: the passed cell does not lie in the indicated domain "
268 << "and can therefore not be accessed." << std::endl;
269 std::exit(1);
270 }
271#endif
272 const L point (latticeR);
273 const auto upper = std::upper_bound(
274 _coords.begin(), _coords.end(), point, [](const L& a, const L& b){
275 return lex_smaller(a, b);
276 });
277 return std::distance(_coords.begin(), upper - 1);
278 }

The documentation for this class was generated from the following file: