OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
olb::BlockGeometry< T, D > Class Template Referencefinal

Representation of a block geometry. More...

#include <blockGeometry.h>

+ Inheritance diagram for olb::BlockGeometry< T, D >:
+ Collaboration diagram for olb::BlockGeometry< T, D >:

Public Member Functions

 BlockGeometry (Cuboid< T, D > &cuboid, int padding, int iCglob=-1)
 
Platform getPlatform () const
 
const BlockGeometryStatistics< T, D > & getStatistics () const
 Read only access to the associated block statistic.
 
BlockGeometryStatistics< T, D > & getStatistics ()
 Write access to the associated block statistic.
 
bool hasCommunicatable (std::type_index field) const
 
auto & getCommunicatable (std::type_index field)
 
int getIcGlob () const
 Read only access to the global iC number which is given !=-1 if the block geometries are part of a super geometry.
 
Vector< int, D > getExtent () const
 Returns the extend of the block in lattice units.
 
Vector< T, D > getOrigin () const
 Read only access to the origin position given in SI units (meter)
 
getDeltaR () const
 Read only access to the voxel size given in SI units (meter)
 
template<typename... L>
std::enable_if_t< sizeof...(L)==D, int > get (L... latticeR) const
 Read-only access to a material number.
 
int get (LatticeR< D > latticeR) const
 
int get (const int latticeR[D]) const
 
int get (std::size_t iCell) const
 
int getMaterial (LatticeR< D > latticeR) const
 returns the (iX,iY) entry in the 2D scalar field
 
int getMaterial (const int latticeR[D]) const
 
template<typename... L>
std::enable_if_t< sizeof...(L)==D, int > getMaterial (L... latticeR) const
 
void set (LatticeR< D > latticeR, int material)
 Write access to a material number.
 
void set (const int latticeR[D], int material)
 
void set (std::size_t iCell, int material)
 
Vector< T, D > getPhysR (LatticeR< D > latticeR)
 
void getPhysR (T physR[D], const int latticeR[D]) const
 Transforms lattice to physical coordinates (wrapped from cuboid geometry)
 
void getPhysR (T physR[D], LatticeR< D > latticeR) const
 
Cuboid< T, D > & getCuboid ()
 
const Cuboid< T, D > & getCuboid () const
 
template<typename... L>
std::enable_if_t< sizeof...(L)==D, void > get (T physR[D], L... latticeR) const
 
template<typename DESCRIPTOR = std::conditional_t<D==2,descriptors::D2Q9<>,descriptors::D3Q27<>>>
int clean (bool verbose=true, std::vector< int > bulkMaterials={1})
 Changes all cell materials which are not in bulkMaterials to 0 if there is no neighbour from bulkMaterials.
 
int outerClean (bool verbose=true, std::vector< int > bulkMaterials={1})
 Changes all cell materials from bulkMaterials to 0 if there is a neighbour with material 0.
 
int innerClean (bool verbose=true)
 Changes all cell materials which are not 0 or 1 to 1 if there is a non robust constiallation.
 
int innerClean (int fromM, bool verbose=true)
 Changes all cells with material fromM to 1 if there is a non robust constiallation.
 
void reset (IndicatorF< T, D > &domain)
 Resets all cell materials inside of a domain to 0.
 
bool find (int material, std::vector< unsigned > offset, std::vector< int > var)
 Returns the coordinates (iX,iY) of a voxel with a given material number (material) if there exists an neighbourhood of size (offsetX,offsetY) only with voxels of the given material number.
 
bool check (int material, std::vector< int > var, std::vector< unsigned > offset)
 Returns true if at position (iX,iY) and in a neighbourhood of size (offsetX,offsetY) only voxels with a given material number (material) are there.
 
bool checkForErrors (bool verbose=true) const
 Checks for errors (searches for all outer voxels (=0) with an inner voxel (=1) as a direct neighbour)
 
void rename (int fromM, int toM)
 Replaces all material numbers (fromM) to another (toM)
 
void rename (int fromM, int toM, IndicatorF< T, D > &condition)
 Replaces all material numbers (fromM) to another (toM) if an indicator functor condition is fulfilled.
 
void rename (int fromM, int toM, LatticeR< D > offset)
 Replaces all material numbers (fromM) to another (toM) if all materials in the neighbourhood (iX-offsetX,..,iX,..,ix+offsetX), .. are of the original material number (fromM)
 
void rename (int fromM, int toM, int testM, std::vector< int > testDirection)
 Replaces all material numbers (fromM) to another (toM) if all materials in the neighbourhood (iX+1,iX+2,..,ix+testDirection[0]), .. are of another material number (testM)
 
void rename (int fromM, int toM, int fluidM, IndicatorF< T, D > &condition, Vector< int, D > discreteNormal)
 Replaces all material numbers (fromM) to another (toM) if all materials in the neighbourhood (iX+discreteNormal[0],iX+2*discreteNormal[0]), .. are of another material number (testM) and if an indicator functor condition is fulfilled.
 
void rename (int fromM, int toM, int fluidM, IndicatorF< T, D > &condition)
 Replaces all material numbers (fromM) to another (toM) if all materials in the neighbourhood (iX+discreteNormal[0],iX+2*discreteNormal[0]), .. are of another material number (fluidM) and if an indicator functor condition is fulfilled, the discreteNormal is computed from all fromM which fulfill the indicator functor condition.
 
void copyMaterialLayer (IndicatorF3D< T > &condition, int discreteNormal[D], int numberOfLayers)
 Copy a layer of material numbers inside an indicator in a discrete normal direction.
 
void regionGrowing (int fromM, int toM, LatticeR< D > seed, std::vector< int > offset, std::map< std::vector< int >, int > *tmp=nullptr)
 Replaces all material numbers (fromM) to another (toM) using a seed point and max. directions indicated by offsetX,Y != 0.
 
void printLayer (std::vector< int > min, std::vector< int > max, bool linenumber=false)
 Prints a chosen part of the block geometry.
 
void printLayer (int direction, int layer, bool linenumber=false)
 Prints a chosen part of the block geometry.
 
void printNode (std::vector< int > loc)
 Prints a chosen node and its neighbourhood.
 
std::size_t getNblock () const override
 Number of data blocks for the serializable interface.
 
std::size_t getSerializableSize () const override
 Binary size for the serializer.
 
bool * getBlock (std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
 Return a pointer to the memory of the current block and its size for the serializable interface.
 
- Public Member Functions inherited from olb::BlockStructureD< D >
 BlockStructureD (Vector< int, D > size, int padding=0)
 
 BlockStructureD ()
 
int getNx () const
 Read only access to block width.
 
int getNy () const
 Read only access to block height.
 
int getNz () const
 Read only access to block height.
 
LatticeR< D > getExtent () const
 
int getPadding () const
 Read only access to padding.
 
std::size_t getNcells () const
 Get number of cells.
 
CellID getCellId (LatticeR< D > latticeR) const
 Get 1D cell ID.
 
template<typename... L>
std::enable_if_t< sizeof...(L)==D, CellIDgetCellId (L... latticeR) const
 
CellDistance getNeighborDistance (LatticeR< D > dir) const
 Get 1D neighbor distance.
 
bool isInside (LatticeR< D > latticeR) const
 Return whether location is valid.
 
bool isInsideCore (LatticeR< D > latticeR) const
 Return whether location is inside core.
 
bool isPadding (LatticeR< D > latticeR) const
 Return whether location is valid.
 
template<typename... L>
std::enable_if_t< sizeof...(L)==D, bool > isInside (L... latticeR) const
 
CellDistance getNeighborhoodRadius (LatticeR< D > latticeR) const
 Return maximum valid neighborhood sphere radius w.r.t. latticeR.
 
template<typename F >
void forSpatialLocations (F f) const
 
template<typename F >
void forSpatialLocationsParallel (F f) const
 
template<typename F >
void forSpatialLocations (LatticeR< D > min, LatticeR< D > max, F f) const
 
template<typename F >
void forCoreSpatialLocations (F f) const
 
template<typename F >
void forCellIndices (F f) const
 
- Public Member Functions inherited from olb::Serializable
virtual ~Serializable ()=default
 
template<bool includeLogOutputDir = true>
bool save (std::string fileName="", const bool enforceUint=false)
 Save Serializable into file fileName
 
template<bool includeLogOutputDir = true>
bool load (std::string fileName="", const bool enforceUint=false)
 Load Serializable from file fileName
 
bool save (std::uint8_t *buffer)
 Save Serializable into buffer of length getSerializableSize
 
bool load (const std::uint8_t *buffer)
 Load Serializable from buffer of length getSerializableSize
 
virtual void postLoad ()
 

Static Public Attributes

static constexpr Platform platform = Platform::CPU_SISD
 

Additional Inherited Members

- Protected Member Functions inherited from olb::Serializable
template<typename DataType >
void registerVar (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, const DataType &data, const size_t arrayLength=1) const
 Register primitive data types (int, double, ...) or arrays of those.
 
template<typename DataType >
void registerSerializableOfConstSize (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, DataType &data, const bool loadingMode=false)
 Register Serializable object of constant size.
 
template<typename DataType >
void registerSerializablesOfConstSize (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, DataType *data, const size_t arrayLength, const bool loadingMode=false)
 Register an array of Serializable objects of constant size.
 
- Protected Attributes inherited from olb::BlockStructureD< D >
LatticeR< D > _core
 
LatticeR< D > _size
 
LatticeR< D > _projection
 
int _padding
 

Detailed Description

template<typename T, unsigned D>
class olb::BlockGeometry< T, D >

Representation of a block geometry.

Representation of a statistic for a 3D geometry.

Representation of a statistic for a 2D geometry.

This class is derived from block geometry structure. It holds the actual data with the materials. It stores pointers to all dependent block geometry views. It presents a volume of voxels where different types are given my material numbers which is important e.g. to work with different boundaries (like for inflow/output regions).

A block geomety statistic computes different integral values, like total number of different materials, materials of any kind, min./max. physical position, of an underlying block geoemtry structure.

This class is not intended to be derived from.

Definition at line 55 of file blockGeometry.h.

Constructor & Destructor Documentation

◆ BlockGeometry()

template<typename T , unsigned D>
olb::BlockGeometry< T, D >::BlockGeometry ( Cuboid< T, D > & cuboid,
int padding,
int iCglob = -1 )

Definition at line 44 of file blockGeometry.hh.

45 : BlockStructureD<D>(cuboid.getExtent(), padding),
46 _data(this->getNcells()),
47 _communicatable(_data),
48 _cuboid(cuboid),
49 _iCglob(iCglob),
50 _statistics(this),
51 clout(std::cout, ("BlockGeometry" + std::to_string(D) + "D"))
52{
53 _statistics.update(false);
54}
std::size_t getNcells() const
Get number of cells.

Member Function Documentation

◆ check()

template<typename T , unsigned D>
bool olb::BlockGeometry< T, D >::check ( int material,
std::vector< int > var,
std::vector< unsigned > offset )

Returns true if at position (iX,iY) and in a neighbourhood of size (offsetX,offsetY) only voxels with a given material number (material) are there.

Definition at line 354 of file blockGeometry.hh.

356{
357 bool found = true;
358 for (int iOffsetX = -offset[0]; iOffsetX <= (int) offset[0]; ++iOffsetX) {
359 for (int iOffsetY = -offset[1]; iOffsetY <= (int) offset[1]; ++iOffsetY) {
360 if constexpr (D==3){
361 for (int iOffsetZ = -offset[2]; iOffsetZ <= (int) offset[2]; ++iOffsetZ) {
362 if (getMaterial({var[0] + iOffsetX, var[1] + iOffsetY, var[2] + iOffsetZ}) != material) {
363 found = false;
364 }
365 }
366 } else {
367 if (getMaterial({var[0] + iOffsetX, var[1] + iOffsetY}) != material) {
368 found = false;
369 }
370 }
371 }
372 }
373 return found;
374}
int getMaterial(LatticeR< D > latticeR) const
returns the (iX,iY) entry in the 2D scalar field

◆ checkForErrors()

template<typename T , unsigned D>
bool olb::BlockGeometry< T, D >::checkForErrors ( bool verbose = true) const

Checks for errors (searches for all outer voxels (=0) with an inner voxel (=1) as a direct neighbour)

Definition at line 377 of file blockGeometry.hh.

378{
379 bool error = false;
380 using DESCRIPTOR = std::conditional_t<D==2,descriptors::D2Q9<>,descriptors::D3Q27<>>;
381 bool errorFound = false;
382 this->forSpatialLocations([&](LatticeR<D> latticeR)
383 {
384 if (get(latticeR) == 0) {
385 errorFound = false;
386 for(int iPop = 1; iPop < DESCRIPTOR::q; iPop++){
387 if(getMaterial(latticeR + (descriptors::c<DESCRIPTOR>(iPop))) == 1){
388 errorFound = true;
389 }
390 }
391 if(errorFound){
392 error = true;
393 }
394 }
395 });
396
397 if (verbose) {
398 if (error) {
399 clout << "error!" << std::endl;
400 }
401 else {
402 clout << "the model is correct!" << std::endl;
403 }
404 }
405 return error;
406}
std::enable_if_t< sizeof...(L)==D, int > get(L... latticeR) const
Read-only access to a material number.
void forSpatialLocations(F f) const

◆ clean()

template<typename T , unsigned D>
template<typename DESCRIPTOR >
int olb::BlockGeometry< T, D >::clean ( bool verbose = true,
std::vector< int > bulkMaterials = {1} )

Changes all cell materials which are not in bulkMaterials to 0 if there is no neighbour from bulkMaterials.

Definition at line 174 of file blockGeometry.hh.

175{
176 //using DESCRIPTOR = std::conditional_t<D==2,descriptors::D2Q5<>,descriptors::D3Q27<>>;
177int counter=0;
178 bool toClean = true;
179 this->forCoreSpatialLocations([&](LatticeR<D> latticeR) {
180 // material not 0 and not in bulkMaterials
181 if (get(latticeR) != 0 && (! util::isContained(bulkMaterials, get(latticeR))) ) {
182 toClean = true;
183 for (int iPop = 1; iPop < DESCRIPTOR::q; iPop++){
184 if ( util::isContained(bulkMaterials, get(latticeR + (descriptors::c<DESCRIPTOR>(iPop)))) ){
185 toClean = false;
186 }
187 }
188 if (toClean){
189 set(latticeR, 0);
190 counter++;
191 }
192 }
193 });
194 if (verbose) {
195 clout << "cleaned "<< counter << " outer boundary voxel(s)" << std::endl;
196 }
197 return counter;
198}
void set(LatticeR< D > latticeR, int material)
Write access to a material number.
void forCoreSpatialLocations(F f) const
bool isContained(const C &c, U object)
Check, if object is contained in iteratable container c.

◆ copyMaterialLayer()

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::copyMaterialLayer ( IndicatorF3D< T > & condition,
int discreteNormal[D],
int numberOfLayers )

Copy a layer of material numbers inside an indicator in a discrete normal direction.

Definition at line 566 of file blockGeometry.hh.

567{
568 T physR[D];
569 this->forCoreSpatialLocations([&](LatticeR<D> latticeR) {
570 getPhysR(physR, latticeR);
571 bool inside[1];
572 condition(inside, physR);
573 if (inside[0]) {
574 for (int i = 0; i < numberOfLayers; i++) {
575 if (0 <= latticeR[0] + i * discreteNormal[0] && latticeR[0] + i * discreteNormal[0] < this->getNx() &&
576 0 <= latticeR[1] + i * discreteNormal[1] && latticeR[1] + i * discreteNormal[1] < this->getNy()){
577 if constexpr(D==3){
578 if(0 <= latticeR[2] + i * discreteNormal[2] && latticeR[2] + i * discreteNormal[2] < this->getNz()){
579 set({latticeR[0] + i * discreteNormal[0], latticeR[1] + i * discreteNormal[1], latticeR[2] + i * discreteNormal[2]}, get(latticeR));
580 }
581 } else {
582 set({latticeR[0] + i * discreteNormal[0], latticeR[1] + i * discreteNormal[1]}, get(latticeR));
583 }
584 }
585 }
586 }
587 });
588}
Vector< T, D > getPhysR(LatticeR< D > latticeR)
int getNy() const
Read only access to block height.
int getNx() const
Read only access to block width.
int getNz() const
Read only access to block height.

◆ find()

template<typename T , unsigned D>
bool olb::BlockGeometry< T, D >::find ( int material,
std::vector< unsigned > offset,
std::vector< int > var )

Returns the coordinates (iX,iY) of a voxel with a given material number (material) if there exists an neighbourhood of size (offsetX,offsetY) only with voxels of the given material number.

Definition at line 332 of file blockGeometry.hh.

334{
335 bool found = false;
336 for (var[0] = 0; var[0] < this->getNx(); var[0]++) {
337 for (var[1] = 0; var[1] < this->getNy(); var[1]++) {
338 if constexpr(D==3){
339 for (var[2] = 0; var[2] < this->getNz(); var[2]++) {
340 found = check(material, var, offset);
341 }
342 } else {
343 found = check(material, var, offset);
344 }
345 if (found) {
346 return found;
347 }
348 }
349 }
350 return found;
351}
bool check(int material, std::vector< int > var, std::vector< unsigned > offset)
Returns true if at position (iX,iY) and in a neighbourhood of size (offsetX,offsetY) only voxels with...

◆ get() [1/5]

template<typename T , unsigned D>
int olb::BlockGeometry< T, D >::get ( const int latticeR[D]) const

Definition at line 87 of file blockGeometry.hh.

88{
89 return _data[0][this->getCellId(latticeR)];
90}
CellID getCellId(LatticeR< D > latticeR) const
Get 1D cell ID.

◆ get() [2/5]

template<typename T , unsigned D>
template<typename... L>
std::enable_if_t< sizeof...(L)==D, int > olb::BlockGeometry< T, D >::get ( L... latticeR) const
inline

Read-only access to a material number.

Definition at line 107 of file blockGeometry.h.

107 {
108 return _data[0][this->getCellId(latticeR...)];
109 }

References olb::BlockStructureD< D >::getCellId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get() [3/5]

template<typename T , unsigned D>
int olb::BlockGeometry< T, D >::get ( LatticeR< D > latticeR) const

Definition at line 81 of file blockGeometry.hh.

82{
83 return _data[0][this->getCellId(latticeR)];
84}

◆ get() [4/5]

template<typename T , unsigned D>
int olb::BlockGeometry< T, D >::get ( std::size_t iCell) const

Definition at line 93 of file blockGeometry.hh.

94{
95 return _data[0][iCell];
96}

◆ get() [5/5]

template<typename T , unsigned D>
template<typename... L>
std::enable_if_t< sizeof...(L)==D, void > olb::BlockGeometry< T, D >::get ( T physR[D],
L... latticeR ) const
inline

Definition at line 146 of file blockGeometry.h.

146 {
147 return this->getPhysR(physR[D],LatticeR<D>{latticeR...});
148 }

References olb::BlockGeometry< T, D >::getPhysR().

+ Here is the call graph for this function:

◆ getBlock()

template<typename T , unsigned D>
bool * olb::BlockGeometry< T, D >::getBlock ( std::size_t iBlock,
std::size_t & sizeBlock,
bool loadingMode )
overridevirtual

Return a pointer to the memory of the current block and its size for the serializable interface.

Implements olb::Serializable.

Definition at line 742 of file blockGeometry.hh.

743{
744 std::size_t currentBlock = 0;
745 bool* dataPtr = nullptr;
746
747 this->registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, _data, loadingMode);
748
749 return dataPtr;
750}
void registerSerializableOfConstSize(const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, DataType &data, const bool loadingMode=false)
Register Serializable object of constant size.
Definition serializer.h:239

◆ getCommunicatable()

template<typename T , unsigned D>
auto & olb::BlockGeometry< T, D >::getCommunicatable ( std::type_index field)
inline

Definition at line 88 of file blockGeometry.h.

88 {
89 OLB_ASSERT(field == typeid(descriptors::MATERIAL),
90 "BlockGeometry only offers MATERIAL for communication");
91 return _communicatable;
92 }
#define OLB_ASSERT(COND, MESSAGE)
Definition olbDebug.h:45

References OLB_ASSERT.

◆ getCuboid() [1/2]

template<typename T , unsigned D>
Cuboid< T, D > & olb::BlockGeometry< T, D >::getCuboid ( )
inline

Definition at line 137 of file blockGeometry.h.

137 {
138 return _cuboid;
139 }

◆ getCuboid() [2/2]

template<typename T , unsigned D>
const Cuboid< T, D > & olb::BlockGeometry< T, D >::getCuboid ( ) const
inline

Definition at line 140 of file blockGeometry.h.

140 {
141 return _cuboid;
142 }

◆ getDeltaR()

template<typename T , unsigned D>
T olb::BlockGeometry< T, D >::getDeltaR ( ) const

Read only access to the voxel size given in SI units (meter)

Definition at line 75 of file blockGeometry.hh.

76{
77 return _cuboid.getDeltaR();
78}
+ Here is the caller graph for this function:

◆ getExtent()

template<typename T , unsigned D>
Vector< int, D > olb::BlockGeometry< T, D >::getExtent ( ) const

Returns the extend of the block in lattice units.

Definition at line 162 of file blockGeometry.hh.

163{
164 if constexpr (D == 3) {
165 return Vector<int,3>(this->getNx(), this->getNy(), this->getNz());
166 } else {
167 return Vector<int,2>(this->getNx(), this->getNy());
168 }
169 __builtin_unreachable();
170}
+ Here is the caller graph for this function:

◆ getIcGlob()

template<typename T , unsigned D>
int olb::BlockGeometry< T, D >::getIcGlob ( ) const

Read only access to the global iC number which is given !=-1 if the block geometries are part of a super geometry.

Definition at line 156 of file blockGeometry.hh.

157{
158 return _iCglob;
159}
+ Here is the caller graph for this function:

◆ getMaterial() [1/3]

template<typename T , unsigned D>
int olb::BlockGeometry< T, D >::getMaterial ( const int latticeR[D]) const

Definition at line 110 of file blockGeometry.hh.

111{
112 LatticeR<D> loc{latticeR};
113 if (this->isInside(loc)) {
114 return _data[0][this->getCellId(loc)];
115 }
116 else {
117 return 0;
118 }
119}
bool isInside(LatticeR< D > latticeR) const
Return whether location is valid.

◆ getMaterial() [2/3]

template<typename T , unsigned D>
template<typename... L>
std::enable_if_t< sizeof...(L)==D, int > olb::BlockGeometry< T, D >::getMaterial ( L... latticeR) const
inline

Definition at line 120 of file blockGeometry.h.

120 {
121 return this->getMaterial(LatticeR<D>{latticeR...});
122 }

References olb::BlockGeometry< T, D >::getMaterial().

+ Here is the call graph for this function:

◆ getMaterial() [3/3]

template<typename T , unsigned D>
int olb::BlockGeometry< T, D >::getMaterial ( LatticeR< D > latticeR) const

returns the (iX,iY) entry in the 2D scalar field

Definition at line 99 of file blockGeometry.hh.

100{
101 if (this->isInside(latticeR)) {
102 return _data[0][this->getCellId(latticeR)];
103 }
104 else {
105 return 0;
106 }
107}
+ Here is the caller graph for this function:

◆ getNblock()

template<typename T , unsigned D>
std::size_t olb::BlockGeometry< T, D >::getNblock ( ) const
overridevirtual

Number of data blocks for the serializable interface.

Implements olb::Serializable.

Definition at line 730 of file blockGeometry.hh.

731{
732 return _data.getNblock();
733}

References olb::BlockGeometry< T, D >::getNblock().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOrigin()

template<typename T , unsigned D>
Vector< T, D > olb::BlockGeometry< T, D >::getOrigin ( ) const

Read only access to the origin position given in SI units (meter)

Definition at line 69 of file blockGeometry.hh.

70{
71 return _cuboid.getOrigin();
72}
+ Here is the caller graph for this function:

◆ getPhysR() [1/3]

template<typename T , unsigned D>
Vector< T, D > olb::BlockGeometry< T, D >::getPhysR ( LatticeR< D > latticeR)
inline

Definition at line 129 of file blockGeometry.h.

129 {
130 T physR[D];
131 getPhysR(physR, latticeR);
132 return Vector<T,D>(physR);
133 }

References olb::BlockGeometry< T, D >::getPhysR().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPhysR() [2/3]

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::getPhysR ( T physR[D],
const int latticeR[D] ) const

Transforms lattice to physical coordinates (wrapped from cuboid geometry)

Definition at line 141 of file blockGeometry.hh.

142{
143 LatticeR<D> loc{latticeR};
144 getPhysR(physR, loc);
145 return;
146}

◆ getPhysR() [3/3]

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::getPhysR ( T physR[D],
LatticeR< D > latticeR ) const

Definition at line 149 of file blockGeometry.hh.

150{
151 _cuboid.getPhysR(physR, loc);
152 return;
153}

◆ getPlatform()

template<typename T , unsigned D>
Platform olb::BlockGeometry< T, D >::getPlatform ( ) const
inline

Definition at line 76 of file blockGeometry.h.

76 {
77 return platform;
78 }
static constexpr Platform platform

References olb::BlockGeometry< T, D >::platform.

◆ getSerializableSize()

template<typename T , unsigned D>
std::size_t olb::BlockGeometry< T, D >::getSerializableSize ( ) const
overridevirtual

Binary size for the serializer.

Implements olb::Serializable.

Definition at line 736 of file blockGeometry.hh.

737{
738 return _data.getSerializableSize();
739}

◆ getStatistics() [1/2]

template<typename T , unsigned D>
BlockGeometryStatistics< T, D > & olb::BlockGeometry< T, D >::getStatistics ( )

Write access to the associated block statistic.

Definition at line 63 of file blockGeometry.hh.

64{
65 return _statistics;
66}

◆ getStatistics() [2/2]

template<typename T , unsigned D>
const BlockGeometryStatistics< T, D > & olb::BlockGeometry< T, D >::getStatistics ( ) const

Read only access to the associated block statistic.

Definition at line 57 of file blockGeometry.hh.

58{
59 return _statistics;
60}
+ Here is the caller graph for this function:

◆ hasCommunicatable()

template<typename T , unsigned D>
bool olb::BlockGeometry< T, D >::hasCommunicatable ( std::type_index field) const
inline

Definition at line 85 of file blockGeometry.h.

85 {
86 return field == typeid(descriptors::MATERIAL);
87 }
std::enable_if_t< DESCRIPTOR::d==2, std::shared_ptr< SuperF2D< T > > > field(SuperLattice< T, DESCRIPTOR > &sLattice)
Returns external field functor.

◆ innerClean() [1/2]

template<typename T , unsigned D>
int olb::BlockGeometry< T, D >::innerClean ( bool verbose = true)

Changes all cell materials which are not 0 or 1 to 1 if there is a non robust constiallation.

Definition at line 227 of file blockGeometry.hh.

228{
229 int count2 = 0;
230 using DESCRIPTOR = std::conditional_t<D==2,descriptors::D2Q5<>,descriptors::D3Q7<>>;
231
232 this->forCoreSpatialLocations([&](LatticeR<D> latticeR) {
233 if (get(latticeR) != 1 && get(latticeR) != 0) {
234 if constexpr (D==3){
235 bool var[7] = {false};
236 for(int iPop = 1; iPop < DESCRIPTOR::q; iPop++){
237 if(getMaterial(latticeR + (descriptors::c<DESCRIPTOR>(iPop)))==1){
238 var[iPop] = true;
239 }
240 }
241 int comb[12][3]={{1,4,2},{1,4,3},{1,4,5},{1,4,6},{2,5,1},{2,5,3},{2,5,4},{2,5,6},{3,6,1},{3,6,2},{3,6,4},{3,6,5}};
242 for(int i = 0; i < 12; i++){
243 if (var[(comb[i][0])] == true
244 && var[(comb[i][1])] == true
245 && var[(comb[i][2])] == true){
246 set(latticeR, 1);
247 count2++;//count2 is the same value as before, count2 gets increased even if this cell has already been cleaned
248 }
249 }
250 } else {
251 int var = 0;
252 for(int iPop = 1; iPop < DESCRIPTOR::q; iPop++){
253 if(getMaterial(latticeR + (descriptors::c<DESCRIPTOR>(iPop)))==1){
254 var = var+1;
255 }
256 }
257 if(var >= 3){
258 set(latticeR, 1);
259 count2++;//count2 differs from original count2
260 }
261 }
262 }
263 });
264
265 if (verbose) {
266 clout << "cleaned "<< count2 << " inner boundary voxel(s)" << std::endl;
267 }
268 return count2;
269}

◆ innerClean() [2/2]

template<typename T , unsigned D>
int olb::BlockGeometry< T, D >::innerClean ( int fromM,
bool verbose = true )

Changes all cells with material fromM to 1 if there is a non robust constiallation.

Definition at line 272 of file blockGeometry.hh.

273{
274 int count2 = 0;
275 using DESCRIPTOR = std::conditional_t<D==2,descriptors::D2Q5<>,descriptors::D3Q7<>>;
276
277 this->forCoreSpatialLocations([&](LatticeR<D> latticeR) {
278 if (get(latticeR) != 1 && get(latticeR) != 0 && get(latticeR) == fromM) {
279 if constexpr (D==3){
280 bool var[7] = {false};
281 for(int iPop = 1; iPop < DESCRIPTOR::q; iPop++){
282 if(getMaterial(latticeR + (descriptors::c<DESCRIPTOR>(iPop)))==1){
283 var[iPop] = true;
284 }
285 }
286 int comb[12][3]={{1,4,2},{1,4,3},{1,4,5},{1,4,6},{2,5,1},{2,5,3},{2,5,4},{2,5,6},{3,6,1},{3,6,2},{3,6,4},{3,6,5}};
287 for(int i = 0; i < 12; i++){
288 if (var[(comb[i][0])] == true
289 && var[(comb[i][1])] == true
290 && var[(comb[i][2])] == true){
291 set(latticeR, 1);
292 count2++;//count2 is the same value as before, count2 gets increased even if this cell has already been cleaned
293 }
294 }
295 } else {
296 int var = 0;
297 for(int iPop = 1; iPop < DESCRIPTOR::q; iPop++){
298 if(getMaterial(latticeR + (descriptors::c<DESCRIPTOR>(iPop)))==1){
299 var = var+1;
300 }
301 }
302 if(var >= 3){
303 set(latticeR, 1);
304 count2++;//count2 differs from original count2
305 }
306 }
307 }
308 });
309
310 if (verbose){
311 clout << "cleaned "<< count2
312 << " inner boundary voxel(s) of Type " << fromM << std::endl;
313 }
314 return count2;
315}

◆ outerClean()

template<typename T , unsigned D>
int olb::BlockGeometry< T, D >::outerClean ( bool verbose = true,
std::vector< int > bulkMaterials = {1} )

Changes all cell materials from bulkMaterials to 0 if there is a neighbour with material 0.

Definition at line 201 of file blockGeometry.hh.

202{
203 int counter=0;
204 using DESCRIPTOR = std::conditional_t<D==2,descriptors::D2Q9<>,descriptors::D3Q27<>>;
205 bool toClean = false;
206 this->forCoreSpatialLocations([&](LatticeR<D> latticeR) {
207 if (util::isContained(bulkMaterials, get(latticeR))) {
208 toClean = false;
209 for(int iPop = 1; iPop < DESCRIPTOR::q; iPop++){
210 if(getMaterial(latticeR + (descriptors::c<DESCRIPTOR>(iPop))) == 0){
211 toClean = true;
212 }
213 }
214 if(toClean){
215 set(latticeR, 0);
216 counter++;
217 }
218 }
219 });
220 if (verbose) {
221 clout << "cleaned "<< counter << " outer fluid voxel(s)" << std::endl;
222 }
223 return counter;
224}

◆ printLayer() [1/2]

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::printLayer ( int direction,
int layer,
bool linenumber = false )

Prints a chosen part of the block geometry.

Definition at line 676 of file blockGeometry.hh.

677{
678 assert(direction >= 0 && direction <= 2);
679 if constexpr(D==3){
680 switch (direction) {
681 case 0:
682 printLayer({layer, 0, 0},{layer, this->getNy() - 1, this->getNz() - 1}, linenumber);
683 break;
684 case 1:
685 printLayer({0, layer, 0}, {this->getNx() - 1, layer, this->getNz() - 1}, linenumber);
686 break;
687 case 2:
688 printLayer({0, 0, layer}, {this->getNx() - 1, this->getNy() - 1, layer}, linenumber);
689 break;
690 }
691 } else {
692 switch (direction) {
693 case 0:
694 printLayer({layer, 0}, {layer, this->getNy() - 1}, linenumber);
695 break;
696 case 1:
697 printLayer({0, layer}, {this->getNx() - 1, layer}, linenumber);
698 break;
699 }
700 }
701}
void printLayer(std::vector< int > min, std::vector< int > max, bool linenumber=false)
Prints a chosen part of the block geometry.

◆ printLayer() [2/2]

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::printLayer ( std::vector< int > min,
std::vector< int > max,
bool linenumber = false )

Prints a chosen part of the block geometry.

Definition at line 650 of file blockGeometry.hh.

651{
652 for (int x = min[0]; x <= max[0]; x++) {
653 if (linenumber) {
654 clout << x << ": ";
655 }
656 for (int y = min[1]; y <= max[1]; y++) {
657 if constexpr (D==3){
658 for (int z = min[2]; z <= max[2]; z++) {
659 clout << getMaterial({x, y, z}) << " ";
660 }
661 if (max[1] - min[1] != 0 && max[2] - min[2] != 0) {
662 clout << std::endl;
663 }
664 } else {
665 clout << getMaterial({x, y}) << " ";
666 }
667 }
668 if (max[0] - min[0] != 0) {
669 clout << std::endl;
670 }
671 }
672 clout << std::endl;
673}
Pack< T > max(Pack< T > rhs, Pack< T > lhs)
Definition 256.h:416

◆ printNode()

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::printNode ( std::vector< int > loc)

Prints a chosen node and its neighbourhood.

Definition at line 704 of file blockGeometry.hh.

705{
706 for (int x = loc[0] - 1; x <= loc[0] + 1; x++) {
707 clout << "x=" << x << std::endl;
708 for (int y = loc[1] - 1; y <= loc[1] + 1; y++) {
709 if constexpr (D==3){
710 for (int z = loc[2] - 1; z <= loc[2] + 1; z++) {
711 clout << getMaterial({x, y, z}) << " ";
712 }
713 clout << std::endl;
714 } else {
715 clout << getMaterial({x, y}) << " ";
716 }
717 }
718 clout << std::endl;
719 }
720 clout << std::endl;
721}

◆ regionGrowing()

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::regionGrowing ( int fromM,
int toM,
LatticeR< D > seed,
std::vector< int > offset,
std::map< std::vector< int >, int > * tmp = nullptr )

Replaces all material numbers (fromM) to another (toM) using a seed point and max. directions indicated by offsetX,Y != 0.

Definition at line 591 of file blockGeometry.hh.

593{
594 std::map<std::vector<int>, int> tmp2;
595 bool firstCall = false;
596 if (tmp == nullptr) {
597 tmp = &tmp2;
598 firstCall = true;
599 }
600
601 if (getMaterial(seed) == fromM) {
602 std::vector<int> found;
603 found.push_back(seed[0]);
604 found.push_back(seed[1]);
605 if constexpr(D==3){
606 found.push_back(seed[2]);
607 if (tmp->count(found) == 0) {
608 (*tmp)[found] = 2;
609 if (offset[0] != 0) {
610 regionGrowing(fromM, toM, {seed[0] + 1, seed[1], seed[2]}, offset, tmp);
611 regionGrowing(fromM, toM, {seed[0] - 1, seed[1], seed[2]}, offset, tmp);
612 }
613 if (offset[1] != 0) {
614 regionGrowing(fromM, toM, {seed[0], seed[1] + 1, seed[2]}, offset, tmp);
615 regionGrowing(fromM, toM, {seed[0], seed[1] - 1, seed[2]}, offset, tmp);
616 }
617 if (offset[2] != 0) {
618 regionGrowing(fromM, toM, {seed[0], seed[1], seed[2] + 1}, offset, tmp);
619 regionGrowing(fromM, toM, {seed[0], seed[1], seed[2] - 1}, offset, tmp);
620 }
621 }
622 } else {
623 if (tmp->count(found) == 0) {
624 (*tmp)[found] = 2;
625 if (offset[0] != 0) {
626 regionGrowing(fromM, toM, {seed[0] + 1, seed[1]}, offset, tmp);
627 regionGrowing(fromM, toM, {seed[0] - 1, seed[1]}, offset, tmp);
628 }
629 if (offset[1] != 0) {
630 regionGrowing(fromM, toM, {seed[0], seed[1] + 1}, offset, tmp);
631 regionGrowing(fromM, toM, {seed[0], seed[1] - 1}, offset, tmp);
632 }
633 }
634 }
635 }
636 if (firstCall) {
637 std::map<std::vector<int>, int>::iterator iter;
638 for (iter = tmp->begin(); iter != tmp->end(); iter++) {
639 if constexpr(D==3){
640 set((iter->first)[0],(iter->first)[1],(iter->first)[2], toM);
641 } else {
642 set((iter->first)[0],(iter->first)[1], toM);
643 }
644 }
645 }
646 return;
647}
void regionGrowing(int fromM, int toM, LatticeR< D > seed, std::vector< int > offset, std::map< std::vector< int >, int > *tmp=nullptr)
Replaces all material numbers (fromM) to another (toM) using a seed point and max....

◆ rename() [1/6]

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::rename ( int fromM,
int toM )

Replaces all material numbers (fromM) to another (toM)

Definition at line 409 of file blockGeometry.hh.

410{
411 this->forCoreSpatialLocations([&](LatticeR<D> latticeR) {
412 if (get(latticeR) == fromM) {
413 set(latticeR, toM);
414 }
415 });
416}

◆ rename() [2/6]

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::rename ( int fromM,
int toM,
IndicatorF< T, D > & condition )

Replaces all material numbers (fromM) to another (toM) if an indicator functor condition is fulfilled.

Definition at line 419 of file blockGeometry.hh.

420{
421 T physR[D];
422 this->forSpatialLocations([&](LatticeR<D> latticeR) {
423 if (get(latticeR) == fromM) {
424 getPhysR(physR, latticeR);
425 bool inside[1];
426 condition(inside, physR);
427 if (inside[0]) {
428 set(latticeR, toM);
429 }
430 }
431 });
432}

◆ rename() [3/6]

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::rename ( int fromM,
int toM,
int fluidM,
IndicatorF< T, D > & condition )

Replaces all material numbers (fromM) to another (toM) if all materials in the neighbourhood (iX+discreteNormal[0],iX+2*discreteNormal[0]), .. are of another material number (fluidM) and if an indicator functor condition is fulfilled, the discreteNormal is computed from all fromM which fulfill the indicator functor condition.

Definition at line 534 of file blockGeometry.hh.

536{
537 rename(fromM, toM, condition);
538 std::vector<int> testDirection = getStatistics().computeDiscreteNormal(toM);
539 T physR[D];
540 // values that have been incorrectly changed from "fromM to "toM" get assigned back to "fromM"
541 this->forCoreSpatialLocations([&](LatticeR<D> latticeR) {
542 if (get(latticeR) == toM) {
543 getPhysR(physR, latticeR);
544 bool inside[1];
545 condition(inside, physR);
546 if (inside[0]) {
547 if constexpr(D==3){
548 if (getMaterial({latticeR[0]+testDirection[0],latticeR[1]+testDirection[1],latticeR[2]+testDirection[2]})!=fluidM ||
549 getMaterial({latticeR[0]+2*testDirection[0],latticeR[1]+2*testDirection[1],latticeR[2]+2*testDirection[2]})!=fluidM ||
550 getMaterial({latticeR[0]-testDirection[0],latticeR[1]-testDirection[1],latticeR[2]-testDirection[2]})!=0 ) {
551 set(latticeR, fromM);
552 }
553 } else {
554 if (getMaterial({latticeR[0]+testDirection[0],latticeR[1]+testDirection[1]})!=fluidM ||
555 getMaterial({latticeR[0]+2*testDirection[0],latticeR[1]+2*testDirection[1]})!=fluidM ||
556 getMaterial({latticeR[0]-testDirection[0],latticeR[1]-testDirection[1]})!=0 ) {
557 set(latticeR, fromM);
558 }
559 }
560 }
561 }
562 });
563}
void rename(int fromM, int toM)
Replaces all material numbers (fromM) to another (toM)
const BlockGeometryStatistics< T, D > & getStatistics() const
Read only access to the associated block statistic.

◆ rename() [4/6]

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::rename ( int fromM,
int toM,
int fluidM,
IndicatorF< T, D > & condition,
Vector< int, D > discreteNormal )

Replaces all material numbers (fromM) to another (toM) if all materials in the neighbourhood (iX+discreteNormal[0],iX+2*discreteNormal[0]), .. are of another material number (testM) and if an indicator functor condition is fulfilled.

Definition at line 503 of file blockGeometry.hh.

505{
506 rename(fromM, toM, condition);
507 Vector<int,D> testDirection(discreteNormal);
508 T physR[D];
509 this->forCoreSpatialLocations([&](LatticeR<D> latticeR) {
510 if (get(latticeR) == toM) {
511 getPhysR(physR, latticeR);
512 bool inside[1];
513 condition(inside, physR);
514 if (inside[0]) {
515 if constexpr (D==3){
516 if (getMaterial({latticeR[0]+testDirection[0],latticeR[1]+testDirection[1],latticeR[2]+testDirection[2]})!=fluidM ||
517 getMaterial({latticeR[0]+2*testDirection[0],latticeR[1]+2*testDirection[1],latticeR[2]+2*testDirection[2]})!=fluidM ||
518 getMaterial({latticeR[0]-testDirection[0],latticeR[1]-testDirection[1],latticeR[2]-testDirection[2]})!=0 ) {
519 set(latticeR, fromM);
520 }
521 } else {
522 if (getMaterial({latticeR[0]+testDirection[0],latticeR[1]+testDirection[1]}) != fluidM ||
523 getMaterial({latticeR[0]+2*testDirection[0],latticeR[1]+2*testDirection[1]}) != fluidM ||
524 getMaterial({latticeR[0]-testDirection[0],latticeR[1]-testDirection[1]}) != 0) {
525 set(latticeR, fromM);
526 }
527 }
528 }
529 }
530 });
531}

◆ rename() [5/6]

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::rename ( int fromM,
int toM,
int testM,
std::vector< int > testDirection )

Replaces all material numbers (fromM) to another (toM) if all materials in the neighbourhood (iX+1,iX+2,..,ix+testDirection[0]), .. are of another material number (testM)

Definition at line 468 of file blockGeometry.hh.

470{
471 this->forCoreSpatialLocations([&](LatticeR<D> latticeR) {
472 if (get(latticeR) == fromM) {
473 // flag that indicates the renaming of the current voxel, valid voxels are not renamed
474 bool isValid = true;
475 for (int iOffsetX = util::min(testDirection[0],0); iOffsetX <= util::max(testDirection[0],0); ++iOffsetX) {
476 for (int iOffsetY = util::min(testDirection[1],0); iOffsetY <= util::max(testDirection[1],0); ++iOffsetY) {
477 if constexpr (D == 3){
478 for (int iOffsetZ = util::min(testDirection[2],0); iOffsetZ <= util::max(testDirection[2],0); ++iOffsetZ) {
479 if (iOffsetX!=0 || iOffsetY!=0 || iOffsetZ!=0) {
480 if (getMaterial({latticeR[0] + iOffsetX, latticeR[1] + iOffsetY, latticeR[2] + iOffsetZ}) != testM) {
481 isValid = false;
482 }
483 }
484 }
485 } else {
486 if (iOffsetX!=0 || iOffsetY!=0) {
487 if (getMaterial({latticeR[0] + iOffsetX, latticeR[1] + iOffsetY}) != testM) {
488 isValid = false;
489 }
490 }
491 }
492 }
493 }
494 if (!isValid) {
495 set(latticeR, toM);
496 }
497 }
498 });
499}
bool isValid(Particle< T, PARTICLETYPE > particle)
cpu::simd::Pack< T > min(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:124
cpu::simd::Pack< T > max(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:130

References olb::util::max(), and olb::util::min().

+ Here is the call graph for this function:

◆ rename() [6/6]

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::rename ( int fromM,
int toM,
LatticeR< D > offset )

Replaces all material numbers (fromM) to another (toM) if all materials in the neighbourhood (iX-offsetX,..,iX,..,ix+offsetX), .. are of the original material number (fromM)

Definition at line 435 of file blockGeometry.hh.

436{
437 this->forCoreSpatialLocations([&](LatticeR<D> latticeR) {
438 if (get(latticeR) == fromM) {
439 bool found = true;
440 for (int iOffsetX = -offset[0]; iOffsetX <= (int) offset[0]; ++iOffsetX) {
441 for (int iOffsetY = -offset[1]; iOffsetY <= (int) offset[1]; ++iOffsetY) {
442 if constexpr (D == 3) {
443 for (int iOffsetZ = -offset[2]; iOffsetZ <= (int) offset[2]; ++iOffsetZ) {
444 if (getMaterial({latticeR[0] + iOffsetX, latticeR[1] + iOffsetY, latticeR[2] + iOffsetZ}) != fromM) {
445 if (getMaterial({latticeR[0] + iOffsetX, latticeR[1] + iOffsetY, latticeR[2] + iOffsetZ}) != 1245) {
446 found = false;
447 }
448 }
449 }
450 } else {
451 if (getMaterial({latticeR[0] + iOffsetX, latticeR[1] + iOffsetY}) != fromM) {
452 if (getMaterial({latticeR[0] + iOffsetX, latticeR[1] + iOffsetY}) != 1245) {
453 found = false;
454 }
455 }
456 }
457 }
458 }
459 if (found) {
460 set(latticeR, 1245); // TODO Replace this embarassing approach
461 }
462 }
463 });
464 rename(1245,toM);
465}

◆ reset()

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::reset ( IndicatorF< T, D > & domain)

Resets all cell materials inside of a domain to 0.

Definition at line 318 of file blockGeometry.hh.

319{
320 this->forCoreSpatialLocations([&](LatticeR<D> latticeR) {
321 T physR[D] { };
322 bool output{};
323 getPhysR(physR, latticeR);
324 domain(&output, physR);
325 if (output) {
326 set(latticeR, 0);
327 }
328 });
329}

◆ set() [1/3]

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::set ( const int latticeR[D],
int material )

Definition at line 128 of file blockGeometry.hh.

129{
130 set(this->getCellId(latticeR), material);
131}

◆ set() [2/3]

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::set ( LatticeR< D > latticeR,
int material )

Write access to a material number.

Definition at line 122 of file blockGeometry.hh.

123{
124 set(this->getCellId(latticeR), material);
125}

◆ set() [3/3]

template<typename T , unsigned D>
void olb::BlockGeometry< T, D >::set ( std::size_t iCell,
int material )

Definition at line 134 of file blockGeometry.hh.

135{
136 resetStatistics();
137 _data[0][iCell] = material;
138}

Member Data Documentation

◆ platform

template<typename T , unsigned D>
constexpr Platform olb::BlockGeometry< T, D >::platform = Platform::CPU_SISD
staticconstexpr

Definition at line 72 of file blockGeometry.h.


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