28#ifndef SUPER_GEOMETRY_HH
29#define SUPER_GEOMETRY_HH
56template<
typename T,
unsigned D>
62 _communicationNeeded(false),
64 _clout(std::cout, (
"SuperGeometry" + std::to_string(D) +
"D")),
66 _writeIncrementalVtkEnabled{true}
74 _communicator->template requestField<descriptors::MATERIAL>();
75 _communicator->requestOverlap(this->
_overlap);
76 _communicator->exchangeRequests();
78 _statistics.getStatisticsStatus() =
true;
79 _communicationNeeded =
true;
85template<
typename T,
unsigned D>
88 if (_writeIncrementalVtkEnabled) {
90 if (_iConstructionT == 0) {
91 writer.createMasterFile();
94 writer.addFunctor(geometryF);
95 writer.write(_iConstructionT++);
99template<
typename T,
unsigned D>
102 if ( this->getLoadBalancer().rank(latticeR[0]) ==
singleton::mpi().getRank() ) {
103 return _block[this->getLoadBalancer().loc(latticeR[0])]->get(latticeR.
data()+1);
105 throw std::domain_error(
"read only access to data which is not available locally");
109template<
typename T,
unsigned D>
114 material = _block[this->getLoadBalancer().loc(latticeR[0])]->get(latticeR.
data()+1);
116#ifdef PARALLEL_MODE_MPI
122template<
typename T,
unsigned D>
125 return this->_cuboidDecomposition.getPhysR(latticeR);
128template<
typename T,
unsigned D>
131 auto physR = this->_cuboidDecomposition.getPhysR(latticeR);
132 std::copy(physR.data(), physR.data() + D, output);
135template<
typename T,
unsigned D>
138 _statistics.getStatisticsStatus() =
true;
139 return *_block[locIC];
142template<
typename T,
unsigned D>
145 return *_block[locIC];
148template<
typename T,
unsigned D>
149template <
typename BLOCK>
152 _statistics.getStatisticsStatus() =
true;
153 return *_block[locIC];
156template<
typename T,
unsigned D>
157template <
typename BLOCK>
160 return *_block[locIC];
163template<
typename T,
unsigned D>
166 if (this->_communicationNeeded) {
168 getStatisticsStatus()=
true;
173template<
typename T,
unsigned D>
179template<
typename T,
unsigned D>
182 return _statistics.getStatisticsStatus();
185template<
typename T,
unsigned D>
188 return _statistics.getStatisticsStatus();
191template<
typename T,
unsigned D>
194 if (this->_communicationNeeded) {
196 getStatisticsStatus()=
true;
198 _statistics.update(verbose);
199 for (
unsigned iC=0; iC<_block.size(); iC++) {
200 _block[iC]->getStatistics().update(verbose);
204template<
typename T,
unsigned D>
205template<
typename DESCRIPTOR>
210 for (
unsigned iC=0; iC<_block.size(); iC++) {
211 counter+=_block[iC]->template clean <DESCRIPTOR>(
false, bulkMaterials);
213#ifdef PARALLEL_MODE_MPI
218 _clout <<
"cleaned "<< counter <<
" outer boundary voxel(s)" << std::endl;
220 _statistics.getStatisticsStatus() =
true;
221 this->_communicationNeeded =
true;
222 writeIncrementalVTK();
226template<
typename T,
unsigned D>
231 for (
unsigned iC=0; iC<_block.size(); iC++) {
232 counter+=_block[iC]->outerClean(
false, bulkMaterials);
234#ifdef PARALLEL_MODE_MPI
239 _clout <<
"cleaned "<< counter <<
" outer fluid voxel(s)" << std::endl;
241 _statistics.getStatisticsStatus() =
true;
242 this->_communicationNeeded =
true;
243 writeIncrementalVTK();
247template<
typename T,
unsigned D>
252 for (
unsigned iC=0; iC<_block.size(); iC++) {
253 counter+=_block[iC]->innerClean(
false);
255#ifdef PARALLEL_MODE_MPI
261 _clout <<
"cleaned "<< counter <<
" inner boundary voxel(s)" << std::endl;
263 _statistics.getStatisticsStatus() =
true;
264 this->_communicationNeeded =
true;
265 writeIncrementalVTK();
269template<
typename T,
unsigned D>
274 for (
unsigned iC=0; iC<_block.size(); iC++) {
275 counter+=_block[iC]->innerClean(bcType,
false);
277#ifdef PARALLEL_MODE_MPI
282 _clout <<
"cleaned "<< counter <<
" inner boundary voxel(s) of Type " << bcType << std::endl;
284 _statistics.getStatisticsStatus() =
true;
285 this->_communicationNeeded =
true;
286 writeIncrementalVTK();
290template<
typename T,
unsigned D>
293 updateStatistics(verbose);
295 for (
unsigned iC=0; iC<_block.size(); iC++) {
296 if (_block[iC]->checkForErrors(
false)) {
302 this->_clout <<
"error!" << std::endl;
305 this->_clout <<
"the model is correct!" << std::endl;
311template<
typename T,
unsigned D>
315 for (
unsigned iC = 0; iC < _block.size(); ++iC) {
316 _block[iC]->reset(domain);
318 _statistics.getStatisticsStatus() =
true;
319 this->_communicationNeeded =
true;
320 writeIncrementalVTK();
323template<
typename T,
unsigned D>
327 for (
unsigned iC=0; iC<_block.size(); iC++) {
328 _block[iC]->rename(fromM,toM);
330 _statistics.getStatisticsStatus() =
true;
331 this->_communicationNeeded =
true;
332 writeIncrementalVTK();
335template<
typename T,
unsigned D>
339 for (
unsigned iC=0; iC<_block.size(); iC++) {
340 _block[iC]->rename(fromM,toM,*condition);
342 _statistics.getStatisticsStatus() =
true;
343 writeIncrementalVTK();
346template<
typename T,
unsigned D>
350 if ( offset <= overlap ){
351 _communicator->communicate();
352 for (
unsigned iC=0; iC<_block.size(); iC++) {
353 _block[iC]->rename(fromM,toM,offset);
355 _statistics.getStatisticsStatus() =
true;
356 this->_communicationNeeded =
true;
357 writeIncrementalVTK();
359 _clout <<
"error rename only implemented for offset<=overlap" << std::endl;
363template<
typename T,
unsigned D>
366 if ( testDirection[0]*testDirection[0]<=(this->_overlap)*(this->_overlap)
367 && testDirection[1]*testDirection[1]<=(this->_overlap)*(this->_overlap) ){
369 if(testDirection[2]*testDirection[2]<=(this->_overlap)*(this->_overlap)){
370 _communicator->communicate();
371 for (
unsigned iC=0; iC<_block.size(); iC++) {
372 _block[iC]->rename(fromM,toM,testM,testDirection);
374 _statistics.getStatisticsStatus() =
true;
375 this->_communicationNeeded =
true;
378 _communicator->communicate();
379 for (
unsigned iC=0; iC<_block.size(); iC++) {
380 _block[iC]->rename(fromM,toM,testM,testDirection);
382 _statistics.getStatisticsStatus() =
true;
383 this->_communicationNeeded =
true;
385 writeIncrementalVTK();
387 _clout <<
"error rename only implemented for |testDirection[i]|<=overlap" << std::endl;
391template<
typename T,
unsigned D>
395 if (this->_overlap>1) {
397 rename(fromBcMat, toBcMat, condition);
398 Vector<int,D> testDirection = this->getStatistics().computeDiscreteNormal(toBcMat);
400 for (
unsigned iC=0; iC < _block.size(); iC++) {
401 _block[iC]->rename(fromBcMat,toBcMat,fluidMat,condition,testDirection);
403 _statistics.getStatisticsStatus() =
true;
404 this->_communicationNeeded =
true;
405 writeIncrementalVTK();
408 _clout <<
"error rename only implemented for overlap>=2" << std::endl;
412template<
typename T,
unsigned D>
416 if (this->_overlap>1) {
417 _communicator->communicate();
418 rename(fromBcMat, toBcMat, *condition);
419 Vector<int,D> testDirection = this->getStatistics().computeDiscreteNormal(toBcMat);
420 _communicator->communicate();
421 for (
unsigned iC=0; iC<_block.size(); iC++) {
422 _block[iC]->rename(fromBcMat,toBcMat,fluidMat,*condition,testDirection);
424 _statistics.getStatisticsStatus() =
true;
425 this->_communicationNeeded =
true;
426 writeIncrementalVTK();
429 _clout <<
"error rename only implemented for overlap>=2" << std::endl;
434template<
typename T,
unsigned D>
437 this->_cuboidDecomposition.print();
438 getStatistics().print();
442template<
typename T,
unsigned D>
445 if (offset >= this->_overlap) {
446 _clout <<
"Warning! the offset is larger than overlap, set offset to _overlap = " << this->_overlap << std::endl;
447 offset=this->_overlap;
451 if ( this->_cuboidDecomposition.getLatticeR(latticeR, physR) ) {
452 int iCglob = latticeR[0];
454 std::vector<int> loc(D, 0);
455 if constexpr (D==3) {
456 loc[0] = latticeR[1];
457 loc[1] = latticeR[2];
458 loc[2] = latticeR[3];
459 _clout <<
"physR(center)" <<
"=" <<
"{" << latticeR[1] <<
"," << latticeR[2] <<
"," << latticeR[3] <<
"}" << std::endl;
462 loc[0] = latticeR[1];
463 loc[1] = latticeR[2];
464 _clout <<
"physR(center)" <<
"=" <<
"{" << latticeR[1] <<
"," << latticeR[2] <<
"}" << std::endl;
467 _block[this->getLoadBalancer().loc(iCglob)]->printNode(loc,offset);
471 _clout <<
"this point isn't inside the geometry" << std::endl;
475template<
typename T,
unsigned D>
477 std::vector<int>&& materials)
480 "Indicator to be constructed is SuperIndicatorF implementation");
482 return std::unique_ptr<SuperIndicatorF<T,D>>(
487template<
typename T,
unsigned D>
490 return this->getMaterialIndicator(std::vector<int> { material });
493template<
typename T,
unsigned D>
496 return std::accumulate(_block.begin(), _block.end(),
size_t(0), [](std::size_t sum,
auto& b) -> std::size_t {
497 return sum + b->getNblock();
502template<
typename T,
unsigned D>
505 return std::accumulate(_block.begin(), _block.end(),
size_t(0), [](std::size_t sum,
auto& b) -> std::size_t {
506 return sum + b->getSerializableSize();
510template<
typename T,
unsigned D>
513 std::size_t currentBlock = 0;
514 bool* dataPtr =
nullptr;
516 for (std::size_t iC=0; iC < _block.size(); ++iC) {
517 registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, getBlock(iC), loadingMode);
Representation of a block geometry.
Decomposition of a physical volume into a set of disjoint cuboids.
const Cuboid< T, D > & get(int iC) const
Read access to a single cuboid.
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.
int get(LatticeR< D+1 > latticeR) const
Read only access to the material numbers, error handling: returns 0 if data is not available.
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.
SuperGeometry(CuboidDecomposition< T, D > &cuboidDecomposition, LoadBalancer< T > &loadBalancer, int overlap=3)
Vector< T, D > getPhysR(LatticeR< D+1 > latticeR) const
Transforms a lattice to physical position (SI units)
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.
int getAndCommunicate(LatticeR< D+1 > latticeR) const
Read only access to the material numbers with global communication to all ranks.
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.
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)
constexpr const T * data() const any_platform
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.
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, SuperIndicatorMaterial2D< T >, SuperIndicatorMaterial3D< T > > SuperIndicatorMaterial
std::conditional_t< D==2, IndicatorF2D< T >, IndicatorF3D< T > > IndicatorF
std::conditional_t< DIM==2, SuperVTMwriter2D< T, OUT_T, W >, SuperVTMwriter3D< T, OUT_T, W > > SuperVTMwriter
std::conditional_t< D==2, SuperGeometryF2D< T >, SuperGeometryF3D< T > > SuperGeometryF
Representation of a parallel 2D geometry – header file.
A method to write vtk data for cuboid geometries (only for uniform grids) – header file.
A method to write vtk data for cuboid geometries (only for uniform grids) – header file.