OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
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 204 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 215 of file serialization.h.

217 : _indicator(std::move(indicator))
218 {
219 const auto cGeometry = superGeometry.getCuboidGeometry();
220 L latticeR;
221 for (unsigned iC = 0; iC < cGeometry.getNc(); ++iC) {
222 latticeR[0] = iC;
223 const int nX = cGeometry.get(iC).getNx();
224 const int nY = cGeometry.get(iC).getNy();
225 for (int iX=0; iX<nX; iX++) {
226 latticeR[1] = iX;
227 for (int iY=0; iY<nY; iY++) {
228 latticeR[2] = iY;
229 if constexpr (dim == 2) {
230 if (_indicator(latticeR.data())) {
231 _coords.push_back(latticeR);
232 }
233 } else {
234 const int nZ = cGeometry.get(iC).getNz();
235 for (int iZ=0; iZ<nZ; iZ++) {
236 latticeR[3] = iZ;
237
238 if (_indicator(latticeR.data())) {
239 _coords.push_back(latticeR);
240 }
241 }
242 }
243 }
244 }
245 }
246 }
CuboidGeometry< T, D > & getCuboidGeometry()
Read and write access to cuboid geometry.

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

+ 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 248 of file serialization.h.

250 : SparseGeometrySerializer(superGeometry,
251 new SuperIndicatorFfromIndicatorF<S,dim>(std::move(indicator), superGeometry))
252 { }
SparseGeometrySerializer(SuperGeometry< S, dim > &superGeometry, FunctorPtr< SuperIndicatorF< S, dim > > &&indicator)

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 278 of file serialization.h.

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

◆ getNoCells()

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

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

Definition at line 291 of file serialization.h.

291 {
292 return _coords.size();
293 }

◆ 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 255 of file serialization.h.

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

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