28#ifndef SUPER_GEOMETRY_HH
29#define SUPER_GEOMETRY_HH
52template<
typename T,
unsigned D>
58 _communicationNeeded(false),
60 clout(std::cout, (
"SuperGeometry" + std::to_string(D) +
"D"))
68 _communicator->template requestField<descriptors::MATERIAL>();
69 _communicator->requestOverlap(this->
_overlap);
70 _communicator->exchangeRequests();
72 _statistics.getStatisticsStatus() =
true;
73 _communicationNeeded =
true;
77template<
typename T,
unsigned D>
80 if ( this->getLoadBalancer().rank(iCglob) ==
singleton::mpi().getRank() ) {
81 return _block[this->getLoadBalancer().loc(iCglob)]->get(
84 throw std::domain_error(
"read only access to data which is not available locally");
88template<
typename T,
unsigned D>
91 if constexpr (D == 3){
92 return get(latticeR[0], {latticeR[1], latticeR[2], latticeR[3]});
94 return get(latticeR[0], {latticeR[1], latticeR[2]});
98template<
typename T,
unsigned D>
101 if constexpr (D == 3){
102 return get(latticeR[0], {latticeR[1], latticeR[2], latticeR[3]});
104 return get(latticeR[0], {latticeR[1], latticeR[2]});
108template<
typename T,
unsigned D>
113 material = _block[this->getLoadBalancer().loc(iCglob)]->get(latticeR);
115#ifdef PARALLEL_MODE_MPI
121template<
typename T,
unsigned D>
124 if constexpr (D == 3){
125 return getAndCommunicate(latticeR[0], {latticeR[1], latticeR[2], latticeR[3]});
127 return getAndCommunicate(latticeR[0], {latticeR[1], latticeR[2]});
131template<
typename T,
unsigned D>
135 getPhysR(physRv, iCglob, latticeR);
136 std::vector<T> physR(physRv,physRv + D);
140template<
typename T,
unsigned D>
144 this->_cuboidGeometry.getPhysR(physRv, latticeR);
145 std::vector<T> physR(physRv,physRv + D);
149template<
typename T,
unsigned D>
152 this->_cuboidGeometry.getPhysR(output, latticeR);
155template<
typename T,
unsigned D>
158 this->_cuboidGeometry.getPhysR(output, iCglob, latticeR);
161template<
typename T,
unsigned D>
164 _statistics.getStatisticsStatus() =
true;
165 return *_block[locIC];
168template<
typename T,
unsigned D>
171 return *_block[locIC];
174template<
typename T,
unsigned D>
175template <
typename BLOCK>
178 _statistics.getStatisticsStatus() =
true;
179 return *_block[locIC];
182template<
typename T,
unsigned D>
183template <
typename BLOCK>
186 return *_block[locIC];
189template<
typename T,
unsigned D>
192 if (this->_communicationNeeded) {
194 getStatisticsStatus()=
true;
199template<
typename T,
unsigned D>
205template<
typename T,
unsigned D>
208 return _statistics.getStatisticsStatus();
211template<
typename T,
unsigned D>
214 return _statistics.getStatisticsStatus();
217template<
typename T,
unsigned D>
220 if (this->_communicationNeeded) {
222 getStatisticsStatus()=
true;
224 _statistics.update(verbose);
225 for (
unsigned iC=0; iC<_block.size(); iC++) {
226 _block[iC]->getStatistics().update(verbose);
230template<
typename T,
unsigned D>
231template<
typename DESCRIPTOR>
236 for (
unsigned iC=0; iC<_block.size(); iC++) {
237 counter+=_block[iC]->template clean <DESCRIPTOR>(
false, bulkMaterials);
239#ifdef PARALLEL_MODE_MPI
244 clout <<
"cleaned "<< counter <<
" outer boundary voxel(s)" << std::endl;
246 _statistics.getStatisticsStatus() =
true;
247 this->_communicationNeeded =
true;
251template<
typename T,
unsigned D>
256 for (
unsigned iC=0; iC<_block.size(); iC++) {
257 counter+=_block[iC]->outerClean(
false, bulkMaterials);
259#ifdef PARALLEL_MODE_MPI
264 clout <<
"cleaned "<< counter <<
" outer fluid voxel(s)" << std::endl;
266 _statistics.getStatisticsStatus() =
true;
267 this->_communicationNeeded =
true;
271template<
typename T,
unsigned D>
276 for (
unsigned iC=0; iC<_block.size(); iC++) {
277 counter+=_block[iC]->innerClean(
false);
279#ifdef PARALLEL_MODE_MPI
285 clout <<
"cleaned "<< counter <<
" inner boundary voxel(s)" << std::endl;
287 _statistics.getStatisticsStatus() =
true;
288 this->_communicationNeeded =
true;
292template<
typename T,
unsigned D>
297 for (
unsigned iC=0; iC<_block.size(); iC++) {
298 counter+=_block[iC]->innerClean(bcType,
false);
300#ifdef PARALLEL_MODE_MPI
305 clout <<
"cleaned "<< counter <<
" inner boundary voxel(s) of Type " << bcType << std::endl;
307 _statistics.getStatisticsStatus() =
true;
308 this->_communicationNeeded =
true;
312template<
typename T,
unsigned D>
315 updateStatistics(verbose);
317 for (
unsigned iC=0; iC<_block.size(); iC++) {
318 if (_block[iC]->checkForErrors(
false)) {
324 this->clout <<
"error!" << std::endl;
327 this->clout <<
"the model is correct!" << std::endl;
333template<
typename T,
unsigned D>
337 for (
unsigned iC = 0; iC < _block.size(); ++iC) {
338 _block[iC]->reset(domain);
340 _statistics.getStatisticsStatus() =
true;
341 this->_communicationNeeded =
true;
344template<
typename T,
unsigned D>
348 for (
unsigned iC=0; iC<_block.size(); iC++) {
349 _block[iC]->rename(fromM,toM);
351 _statistics.getStatisticsStatus() =
true;
352 this->_communicationNeeded =
true;
355template<
typename T,
unsigned D>
359 for (
unsigned iC=0; iC<_block.size(); iC++) {
360 _block[iC]->rename(fromM,toM,*condition);
362 _statistics.getStatisticsStatus() =
true;
365template<
typename T,
unsigned D>
369 if ( offset <= overlap ){
370 _communicator->communicate();
371 for (
unsigned iC=0; iC<_block.size(); iC++) {
372 _block[iC]->rename(fromM,toM,offset);
374 _statistics.getStatisticsStatus() =
true;
375 this->_communicationNeeded =
true;
377 clout <<
"error rename only implemented for offset<=overlap" << std::endl;
381template<
typename T,
unsigned D>
384 if ( testDirection[0]*testDirection[0]<=(this->_overlap)*(this->_overlap)
385 && testDirection[1]*testDirection[1]<=(this->_overlap)*(this->_overlap) ){
387 if(testDirection[2]*testDirection[2]<=(this->_overlap)*(this->_overlap)){
388 _communicator->communicate();
389 for (
unsigned iC=0; iC<_block.size(); iC++) {
390 _block[iC]->rename(fromM,toM,testM,testDirection);
392 _statistics.getStatisticsStatus() =
true;
393 this->_communicationNeeded =
true;
396 _communicator->communicate();
397 for (
unsigned iC=0; iC<_block.size(); iC++) {
398 _block[iC]->rename(fromM,toM,testM,testDirection);
400 _statistics.getStatisticsStatus() =
true;
401 this->_communicationNeeded =
true;
404 clout <<
"error rename only implemented for |testDirection[i]|<=overlap" << std::endl;
408template<
typename T,
unsigned D>
412 if (this->_overlap>1) {
414 rename(fromBcMat, toBcMat, condition);
415 Vector<int,D> testDirection = this->getStatistics().computeDiscreteNormal(toBcMat);
417 for (
unsigned iC=0; iC < _block.size(); iC++) {
418 _block[iC]->rename(fromBcMat,toBcMat,fluidMat,condition,testDirection);
420 _statistics.getStatisticsStatus() =
true;
421 this->_communicationNeeded =
true;
424 clout <<
"error rename only implemented for overlap>=2" << std::endl;
428template<
typename T,
unsigned D>
432 if (this->_overlap>1) {
433 _communicator->communicate();
434 rename(fromBcMat, toBcMat, *condition);
435 Vector<int,D> testDirection = this->getStatistics().computeDiscreteNormal(toBcMat);
436 _communicator->communicate();
437 for (
unsigned iC=0; iC<_block.size(); iC++) {
438 _block[iC]->rename(fromBcMat,toBcMat,fluidMat,*condition,testDirection);
440 _statistics.getStatisticsStatus() =
true;
441 this->_communicationNeeded =
true;
444 clout <<
"error rename only implemented for overlap>=2" << std::endl;
449template<
typename T,
unsigned D>
452 this->_cuboidGeometry.print();
453 getStatistics().print();
456template<
typename T,
unsigned D>
458 std::vector<int>&& materials)
461 "Indicator to be constructed is SuperIndicatorF implementation");
463 return std::unique_ptr<SuperIndicatorF<T,D>>(
468template<
typename T,
unsigned D>
471 return this->getMaterialIndicator(std::vector<int> { material });
474template<
typename T,
unsigned D>
477 return std::accumulate(_block.begin(), _block.end(),
size_t(0), [](std::size_t sum,
auto& b) -> std::size_t {
478 return sum + b->getNblock();
483template<
typename T,
unsigned D>
486 return std::accumulate(_block.begin(), _block.end(),
size_t(0), [](std::size_t sum,
auto& b) -> std::size_t {
487 return sum + b->getSerializableSize();
491template<
typename T,
unsigned D>
494 std::size_t currentBlock = 0;
495 bool* dataPtr =
nullptr;
497 for (std::size_t iC=0; iC < _block.size(); ++iC) {
498 registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, getBlock(iC), loadingMode);
Representation of a block geometry.
Smart pointer for managing the various ways of passing functors around.
Base class for all LoadBalancer.
Generic communicator for overlaps between blocks of SUPER.
Representation of a statistic for a parallel 2D geometry.
SuperGeometry(CuboidGeometry< T, D > &cuboidGeometry, LoadBalancer< T > &loadBalancer, int overlap=3)
std::size_t getSerializableSize() const override
Binary size for the serializer.
int clean(bool verbose=true, std::vector< int > bulkMaterials={1})
Executes an outer cleaning: Sets all material numbers which are not bulk-materials to 0 if there is n...
bool & getStatisticsStatus()
Read and write access to the statistic status flag, update needed = true.
int get(const int latticeR[D+1]) const
int getAndCommunicate(int iCglob, LatticeR< D > latticeR) const
Read only access to the material numbers with global communication to all ranks.
int get(int iCglob, LatticeR< D > latticeR) const
Read only access to the material numbers, error handling: returns 0 if data is not available.
void print()
Prints some information about the super geometry.
void updateStatistics(bool verbose=true)
Updates the super geometry at the boundaries if needed and afterwards the statisics if needed.
void reset(IndicatorF< T, D > &domain)
reset all cell materials inside of a domain to 0
bool checkForErrors(bool verbose=true)
check for errors (searches for all outer voxels (=0) with an inner voxel (=1) as a direct neighbour)
int innerClean(bool verbose=true)
inner cleaning for all boundary types
SuperGeometryStatistics< T, D > & getStatistics()
Returns the statistics object.
void rename(int fromM, int toM)
replace one material with another
std::unique_ptr< SuperIndicatorF< T, D > > getMaterialIndicator(std::vector< int > &&materials)
Returns a material indicator using the given vector of materials.
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
BlockGeometry< T, D > & getBlockGeometry(int locIC)
Read and write access to a single block geometry.
BLOCK & getBlock(int locIC)
Read and write access to a single extended block geometry.
int outerClean(bool verbose=true, std::vector< int > bulkMaterials={1})
Removes not needed fluid cells from the outer domain.
std::vector< T > getPhysR(int iCglob, LatticeR< D > latticeR) const
Transforms a lattice to physical position (SI unites)
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
int _overlap
Size of ghost cell layer (must be greater than 1 and greater_overlapBC, default =1)
void bCast(T *sendBuf, int sendCount, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Broadcast data from one processor to multiple processors.
void reduceAndBcast(T &reductVal, MPI_Op op, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Reduction operation, followed by a broadcast.
void barrier(MPI_Comm comm=MPI_COMM_WORLD)
Synchronizes the processes.
The description of a single 2D cuboid – header file.
The description of a vector of 2D cuboid – header file.
The description of a vector of 3D cuboid – header file.
This file contains indicator functions.
This file contains indicator functions.
Top level namespace for all of OpenLB.
std::conditional_t< DIM==2, SuperGeometryStatistics2D< T >, SuperGeometryStatistics3D< T > > SuperGeometryStatistics
std::conditional_t< D==2, CuboidGeometry2D< T >, CuboidGeometry3D< T > > CuboidGeometry
std::conditional_t< D==2, SuperIndicatorMaterial2D< T >, SuperIndicatorMaterial3D< T > > SuperIndicatorMaterial
std::conditional_t< D==2, IndicatorF2D< T >, IndicatorF3D< T > > IndicatorF
Representation of a parallel 2D geometry – header file.