diff --git a/src/gpu/GridGenerator/grid/Grid.h b/src/gpu/GridGenerator/grid/Grid.h index ef21f1e22da743ae18700ab5eddf52d2cb5c6920..2c4a8b63ee64060da7a02a3cfb3df2e0c9951be9 100644 --- a/src/gpu/GridGenerator/grid/Grid.h +++ b/src/gpu/GridGenerator/grid/Grid.h @@ -182,6 +182,10 @@ public: virtual void addFluidNodeIndicesMacroVars(std::vector<uint> _fluidNodeIndicesMacroVars) = 0; virtual void addFluidNodeIndicesApplyBodyForce(std::vector<uint> _fluidNodeIndicesApplyBodyForce) = 0; virtual void addFluidNodeIndicesAllFeatures(std::vector<uint> _fluidNodeIndicesAllFeatures) = 0; + virtual void sortFluidNodeIndicesMacroVars() = 0; + virtual void sortFluidNodeIndicesApplyBodyForce() = 0; + virtual void sortFluidNodeIndicesAllFeatures() = 0; + }; #endif diff --git a/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h b/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h index 448737e90aa204ba5cf8a9eae11697476364b25c..c1aad5a33730a786bf21bf1f38b51dbe035cca70 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h +++ b/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h @@ -140,6 +140,9 @@ public: virtual void addFluidNodeIndicesMacroVars(std::vector<uint> fluidNodeIndicesMacroVars, uint level) = 0; virtual void addFluidNodeIndicesApplyBodyForce(std::vector<uint> fluidNodeIndicesApplyBodyForce, uint level) = 0; virtual void addFluidNodeIndicesAllFeatures(std::vector<uint> fluidNodeIndicesAllFeatures, uint level) = 0; + virtual void sortFluidNodeIndicesMacroVars(uint level) = 0; + virtual void sortFluidNodeIndicesApplyBodyForce(uint level) = 0; + virtual void sortFluidNodeIndicesAllFeatures(uint level) = 0; }; diff --git a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp index e29ef28c2b78f85acc0910dddbc445ad40fb0d3b..9c5f439b55ba1fa07ceccf67856ef957b5cd66da 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp +++ b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp @@ -690,4 +690,19 @@ void LevelGridBuilder::addFluidNodeIndicesApplyBodyForce(std::vector<uint> fluid void LevelGridBuilder::addFluidNodeIndicesAllFeatures(std::vector<uint> fluidNodeIndicesAllFeatures, uint level) { grids[level]->addFluidNodeIndicesAllFeatures(fluidNodeIndicesAllFeatures); +} + +void LevelGridBuilder::sortFluidNodeIndicesMacroVars(uint level) +{ + +} + +void LevelGridBuilder::sortFluidNodeIndicesApplyBodyForce(uint level) +{ + +} + +void LevelGridBuilder::sortFluidNodeIndicesAllFeatures(uint level) +{ + } \ No newline at end of file diff --git a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h index 8efb3de4c2f056d3aee516ee7d3acfe494e8a104..21482952459edee22af38360bcdf6cfc07f68e40 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h +++ b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h @@ -198,6 +198,9 @@ public: void addFluidNodeIndicesMacroVars(std::vector<uint> fluidNodeIndicesMacroVars, uint level) override; void addFluidNodeIndicesApplyBodyForce(std::vector<uint> fluidNodeIndicesApplyBodyForce, uint level) override; void addFluidNodeIndicesAllFeatures(std::vector<uint> fluidNodeIndicesAllFeatures, uint level) override; + void sortFluidNodeIndicesMacroVars(uint level) override; + void sortFluidNodeIndicesApplyBodyForce(uint level) override; + void sortFluidNodeIndicesAllFeatures(uint level) override; }; #endif diff --git a/src/gpu/GridGenerator/grid/GridImp.cpp b/src/gpu/GridGenerator/grid/GridImp.cpp index b79ace78c5d7f9eed09ff3b40fdab5a4bc015003..e886cac20f5863d71d6faadd69edcde733184363 100644 --- a/src/gpu/GridGenerator/grid/GridImp.cpp +++ b/src/gpu/GridGenerator/grid/GridImp.cpp @@ -2114,6 +2114,71 @@ void GridImp::addFluidNodeIndicesAllFeatures(std::vector<uint> _fluidNodeIndices this->fluidNodeIndicesAllFeatures.insert(fluidNodeIndicesAllFeatures.end(), fluidNodeIndicesAllFeatures.begin(), _fluidNodeIndicesAllFeatures.end()); } +void GridImp::sortFluidNodeIndicesMacroVars() +{ + if(this->fluidNodeIndicesMacroVars.size()>0) + { + sort(this->fluidNodeIndicesMacroVars.begin(), this->fluidNodeIndicesMacroVars.end()); + // Remove duplicates + this->fluidNodeIndicesMacroVars.erase( unique( this->fluidNodeIndicesMacroVars.begin(), this->fluidNodeIndicesMacroVars.end() ), this->fluidNodeIndicesMacroVars.end() ); + + // Remove indices of fluidNodeIndicesAllFeatures from fluidNodeIndicesMacroVars + if(this->fluidNodeIndicesAllFeatures.size()>0) + { + this->fluidNodeIndicesMacroVars.erase( std::remove_if( this->fluidNodeIndicesMacroVars.begin(), this->fluidNodeIndicesMacroVars.end(), + [&](auto x){return binary_search(fluidNodeIndicesAllFeatures.begin(),fluidNodeIndicesAllFeatures.end(),x);} ), + this->fluidNodeIndicesMacroVars.end() + ); + } + + // Remove indices of fluidNodeIndicesMacroVars from fluidNodeIndices + this->fluidNodeIndices.erase( std::remove_if( this->fluidNodeIndices.begin(), this->fluidNodeIndices.end(), + [&](auto x){return binary_search(fluidNodeIndicesMacroVars.begin(),fluidNodeIndicesMacroVars.end(),x);} ), + this->fluidNodeIndices.end() + ); + } +} + +void GridImp::sortFluidNodeIndicesApplyBodyForce() +{ + if(this->fluidNodeIndicesApplyBodyForce.size()>0) + { + sort(this->fluidNodeIndicesApplyBodyForce.begin(), this->fluidNodeIndicesApplyBodyForce.end()); + // Remove duplicates + this->fluidNodeIndicesApplyBodyForce.erase( unique( this->fluidNodeIndicesApplyBodyForce.begin(), this->fluidNodeIndicesApplyBodyForce.end() ), this->fluidNodeIndicesApplyBodyForce.end() ); + + // Remove indices of fluidNodeIndicesAllFeatures from fluidNodeIndicesMacroVars + if(this->fluidNodeIndicesAllFeatures.size()>0) + { + this->fluidNodeIndicesApplyBodyForce.erase( std::remove_if( this->fluidNodeIndicesApplyBodyForce.begin(), this->fluidNodeIndicesApplyBodyForce.end(), + [&](auto x){return binary_search(fluidNodeIndicesAllFeatures.begin(),fluidNodeIndicesAllFeatures.end(),x);} ), + this->fluidNodeIndicesApplyBodyForce.end() + ); + } + + // Remove indices of fluidNodeIndicesMacroVars from fluidNodeIndices + this->fluidNodeIndices.erase( std::remove_if( this->fluidNodeIndices.begin(), this->fluidNodeIndices.end(), + [&](auto x){return binary_search(fluidNodeIndicesApplyBodyForce.begin(),fluidNodeIndicesApplyBodyForce.end(),x);} ), + this->fluidNodeIndices.end() + ); + } +} + +void GridImp::sortFluidNodeIndicesAllFeatures() +{ + if(this->fluidNodeIndicesAllFeatures.size()>0) + { + sort(this->fluidNodeIndicesAllFeatures.begin(), this->fluidNodeIndicesAllFeatures.end()); + // Remove duplicates + this->fluidNodeIndicesAllFeatures.erase( unique( this->fluidNodeIndicesAllFeatures.begin(), this->fluidNodeIndicesAllFeatures.end() ), this->fluidNodeIndicesAllFeatures.end() ); + // Remove indices of fluidNodeIndicesMacroVars from fluidNodeIndices + this->fluidNodeIndices.erase( std::remove_if( this->fluidNodeIndices.begin(), this->fluidNodeIndices.end(), + [&](auto x){return binary_search(fluidNodeIndicesAllFeatures.begin(),fluidNodeIndicesAllFeatures.end(),x);} ), + this->fluidNodeIndices.end() + ); + } +} + void GridImp::print() const { printf("min: (%2.4f, %2.4f, %2.4f), max: (%2.4f, %2.4f, %2.4f), size: %d, delta: %2.4f\n", startX, startY, startZ, diff --git a/src/gpu/GridGenerator/grid/GridImp.h b/src/gpu/GridGenerator/grid/GridImp.h index 51510a90ee34a8bc6ba78d2230d8c70e52605bee..d368f68e419ed340a51a3d853a55078102a1b450 100644 --- a/src/gpu/GridGenerator/grid/GridImp.h +++ b/src/gpu/GridGenerator/grid/GridImp.h @@ -369,6 +369,9 @@ public: void addFluidNodeIndicesMacroVars(std::vector<uint> _fluidNodeIndicesMacroVars) override; void addFluidNodeIndicesApplyBodyForce(std::vector<uint> _fluidNodeIndicesApplyBodyForce) override; void addFluidNodeIndicesAllFeatures(std::vector<uint> _fluidNodeIndicesAllFeatures) override; + void sortFluidNodeIndicesMacroVars() override; + void sortFluidNodeIndicesApplyBodyForce() override; + void sortFluidNodeIndicesAllFeatures() override; public: struct CommunicationIndices { diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.h index c6c703cd3ff6e257e47debfc4bffa3e28ccdd5cd..0ba30d12108dc3998fcbd69f3a5d3f8d46748b66 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.h @@ -32,6 +32,7 @@ public: virtual void allocArrays_fluidNodeIndicesBorder() = 0; virtual void tagFluidNodeIndices(std::vector<uint> taggedFluidNodeIndices, CollisionTemplate tag, uint level) = 0; + virtual void sortFluidNodeTags() = 0; virtual void setDimensions() = 0; virtual void setBoundingBox() = 0; diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.cpp index 92c9688d997a54598e3688b36393e259516e9fda..e423cf871da51ae785c6c3ea3a20931a4f4503b4 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.cpp @@ -233,6 +233,11 @@ void GridReader::tagFluidNodeIndices(std::vector<uint> taggedFluidNodeIndices, C // TODO } +void GridReader::sortFluidNodeTags(){ + std::cout << "GridReader::sortFluidNodeTags not implemented" << std::endl; + // TODO +} + void GridReader::setPressureValues(int channelSide) const { for (unsigned int level = 0; level <= BC_Values[channelSide]->getLevel(); level++) diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h index 128e90222796f92397f0659e0923452c0ee6b149..70ddb1f47fd0e5e00cb89a1b936c24072c0d4976 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h @@ -43,6 +43,7 @@ public: void allocArrays_fluidNodeIndicesBorder() override; void tagFluidNodeIndices(std::vector<uint> taggedFluidNodeIndices, CollisionTemplate tag, uint level) override; + void sortFluidNodeTags() override; void initalValuesDomainDecompostion(int level); diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp index 1975f9a6cfad96462e888d9f91b14dd1f8a9a88f..c9aaa1d1b505e79860a0242fe7522c52e079d5ee 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp @@ -135,6 +135,13 @@ void GridGenerator::tagFluidNodeIndices(std::vector<uint> taggedFluidNodeIndices } +void GridGenerator::sortFluidNodeTags() { + for (uint level = 0; level < builder->getNumberOfGridLevels(); level++) + { + + } +} + void GridGenerator::allocArrays_BoundaryValues() { std::cout << "------read BoundaryValues------" << std::endl; diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h index 7b72564f371d00df08d4bd45ec7e2820f7b92102..fed5ac7f41ea62686f8d39d45c0f868eb8a540d2 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h @@ -75,6 +75,7 @@ public: void allocArrays_fluidNodeIndicesBorder() override; void tagFluidNodeIndices(std::vector<uint> taggedFluidNodeIndices, CollisionTemplate tag, uint level) override; + void sortFluidNodeTags() override; virtual void setDimensions() override; virtual void setBoundingBox() override;