diff --git a/source/Applications/DLR-F16-Solid/f16.cpp b/source/Applications/DLR-F16-Solid/f16.cpp index 7b31c4024c9d5770c2f884af5ccf7fe4c7a1803e..1670b12df6b36e6257e5281d4d3b2e81bc39b7c8 100644 --- a/source/Applications/DLR-F16-Solid/f16.cpp +++ b/source/Applications/DLR-F16-Solid/f16.cpp @@ -497,7 +497,8 @@ void run(string configname) GbCuboid3DPtr spongeLayerX1max(new GbCuboid3D(g_maxX1-8.0*blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); if (myid==0) GbSystem3D::writeGeoObject(spongeLayerX1max.get(), pathOut+"/geo/spongeLayerX1max", WbWriterVtkXmlASCII::getInstance()); - SpongeLayerBlockVisitor slVisitorX1max(spongeLayerX1max, 1.0); + SpongeLayerBlockVisitor slVisitorX1max; + slVisitorX1max.setBoundingBox(spongeLayerX1max); SPtr<LBMKernel> spKernel = SPtr<LBMKernel>(new CompressibleCumulantLBMKernel()); dynamicPointerCast<CompressibleCumulantLBMKernel>(spKernel)->setRelaxationParameter(CompressibleCumulantLBMKernel::NORMAL); spKernel->setBCProcessor(bcProc); @@ -533,10 +534,18 @@ void run(string configname) grid->accept(bcVisitor); - //GbCuboid3DPtr spongeLayerX1max(new GbCuboid3D(g_maxX1-5.0*blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); - //if (myid==0) GbSystem3D::writeGeoObject(spongeLayerX1max.get(), pathOut+"/geo/spongeLayerX1max", WbWriterVtkXmlASCII::getInstance()); - //SpongeLayerBlockVisitor slVisitorX1max(spongeLayerX1max, 1.0); - //grid->accept(slVisitorX1max); + ////sponge layer + //////////////////////////////////////////////////////////////////////////// + + GbCuboid3DPtr spongeLayerX1max(new GbCuboid3D(g_maxX1-8.0*blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(spongeLayerX1max.get(), pathOut+"/geo/spongeLayerX1max", WbWriterVtkXmlASCII::getInstance()); + SpongeLayerBlockVisitor slVisitorX1max; + slVisitorX1max.setBoundingBox(spongeLayerX1max); + SPtr<LBMKernel> spKernel = SPtr<LBMKernel>(new CompressibleCumulantLBMKernel()); + dynamicPointerCast<CompressibleCumulantLBMKernel>(spKernel)->setRelaxationParameter(CompressibleCumulantLBMKernel::NORMAL); + spKernel->setBCProcessor(bcProc); + slVisitorX1max.setKernel(spKernel); + grid->accept(slVisitorX1max); } SPtr<UbScheduler> nupsSch(new UbScheduler(nupsStep[0], nupsStep[1], nupsStep[2])); diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index fe601585cdbecbc125a227a11c589047fa3d200d..3269acb5265effd0a8d4b5dedc41c68c27d28c19 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -15,6 +15,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) #set(CMAKE_C_COMPILER cc) #set(CMAKE_CXX_COMPILER CC) +#SuperMUC +#set(CMAKE_C_COMPILER mpicc) +#set(CMAKE_CXX_COMPILER mpiCC) + PROJECT(VirtualFluids) set(SOURCE_ROOT "../source") diff --git a/source/VirtualFluidsCore/CoProcessors/WriteObjectsCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/WriteObjectsCoProcessor.cpp index a0840094e06533737f91acd0bf9f3f13a7476b1d..2be2868d554cb57889d3d44986844c7925fd2681 100644 --- a/source/VirtualFluidsCore/CoProcessors/WriteObjectsCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/WriteObjectsCoProcessor.cpp @@ -9,6 +9,7 @@ #include "Communicator.h" #include "UbScheduler.h" #include "Grid3D.h" +#include "UbSystem.h" WriteObjectsCoProcessor::WriteObjectsCoProcessor() { @@ -44,7 +45,7 @@ void WriteObjectsCoProcessor::process(double step) } int stepInt = (int)step; - std::string outFilename = WbWriterVtkXmlBinary::getInstance()->writeTriangles(path + std::to_string(stepInt), nodes, triangles); + std::string outFilename = WbWriterVtkXmlBinary::getInstance()->writeTriangles(path + UbSystem::toString(stepInt), nodes, triangles); } diff --git a/source/VirtualFluidsCore/Grid/BasicCalculator.cpp b/source/VirtualFluidsCore/Grid/BasicCalculator.cpp index e854ff93216528b396d66dbb378b8a4fdc616c30..53fb06011ca297d23fca66ef6eeca2ab623c1fc7 100644 --- a/source/VirtualFluidsCore/Grid/BasicCalculator.cpp +++ b/source/VirtualFluidsCore/Grid/BasicCalculator.cpp @@ -135,6 +135,8 @@ void BasicCalculator::calculate() { UBLOG(logERROR, e.what()); UBLOG(logERROR, " step = "<<calcStep); + //throw; + exit(EXIT_FAILURE); } } ////////////////////////////////////////////////////////////////////////// @@ -167,9 +169,9 @@ void BasicCalculator::calculateBlocks(int startLevel, int maxInitLevel, int calc } catch (std::exception& e) { - //error = boost::current_exception(); UBLOG(logERROR, e.what()); UBLOG(logERROR, blockTemp->toString()<<" step = "<<calcStep); + //throw; exit(EXIT_FAILURE); } } diff --git a/source/VirtualFluidsCore/Utilities/ConfigurationFile.hpp b/source/VirtualFluidsCore/Utilities/ConfigurationFile.hpp index 32492e04c006b8b155c1d0aa9691f339aab4d6b7..9960caca6e1aba82fb313b759cff3ba24ace340d 100644 --- a/source/VirtualFluidsCore/Utilities/ConfigurationFile.hpp +++ b/source/VirtualFluidsCore/Utilities/ConfigurationFile.hpp @@ -67,7 +67,7 @@ private: template<class T> T fromString(const std::string& str) const; - std::vector<std::string> split(const std::string &s, char delim) const; + void split(std::vector<std::string>& lst, const std::string& input, const std::string& separators, bool remove_empty = true) const; }; @@ -167,26 +167,34 @@ std::vector<T> ConfigurationFile::getVector(const std::string& key) const { std::string str = getString(key); std::vector<T> v; - std::vector<std::string> strings = split(str, ' '); - for(std::string s : strings) + std::vector<std::string> strings; + split(strings, str, "\t\n\r;, "); + for (std::vector<std::string>::iterator it = strings.begin(); it != strings.end(); ++it) { - if (s != "") + if (*it != "") { - v.push_back(fromString<T>(s)); + v.push_back(fromString<T>(*it)); } } return v; } ////////////////////////////////////////////////////////////////////////// -std::vector<std::string> ConfigurationFile::split(const std::string &s, char delim) const +void ConfigurationFile::split(std::vector<std::string>& lst, const std::string& input, const std::string& separators, bool remove_empty) const { - std::vector<std::string> result; - std::stringstream ss(s); - std::string item; - while (getline(ss, item, delim)) { - result.push_back(item); + std::ostringstream word; + for (size_t n = 0; n < input.size(); ++n) + { + if (std::string::npos == separators.find(input[n])) + word << input[n]; + else + { + if (!word.str().empty() || !remove_empty) + lst.push_back(word.str()); + word.str(""); + } } - return result; + if (!word.str().empty() || !remove_empty) + lst.push_back(word.str()); } ////////////////////////////////////////////////////////////////////////// template<class T> diff --git a/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.cpp index cd2cd0e2bd6a099d4dd853af002605964579f3ff..c9cd16c09ab86d56c5c2b4fbf52fe4e07285fcb7 100644 --- a/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.cpp +++ b/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.cpp @@ -5,6 +5,7 @@ #include "Grid3D.h" #include "Block3D.h" #include "ILBMKernel.h" +#include "UbException.h" #include "CompressibleCumulant4thOrderViscosityLBMKernel.h" @@ -12,12 +13,9 @@ using namespace std; -SpongeLayerBlockVisitor::SpongeLayerBlockVisitor(GbCuboid3DPtr boundingBox, LBMReal collFactor) : - Block3DVisitor(0, Grid3DSystem::MAXLEVEL), - boundingBox(boundingBox), - collFactor(collFactor) +SpongeLayerBlockVisitor::SpongeLayerBlockVisitor() : Block3DVisitor(0, Grid3DSystem::MAXLEVEL) { - + } ////////////////////////////////////////////////////////////////////////// SpongeLayerBlockVisitor::~SpongeLayerBlockVisitor() @@ -27,7 +25,15 @@ SpongeLayerBlockVisitor::~SpongeLayerBlockVisitor() ////////////////////////////////////////////////////////////////////////// void SpongeLayerBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) { - if (block->getRank() == grid->getRank()) + if (!boundingBox) + { + UB_THROW(UbException(UB_EXARGS, "The bounding box isn't set!")); + } + if (!kernel) + { + UB_THROW(UbException(UB_EXARGS, "The kernel isn't set!")); + } + if (kernel && (block->getRank() == grid->getRank())) { UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); UbTupleDouble3 blockLengths = grid->getBlockLengths(block); @@ -41,7 +47,7 @@ void SpongeLayerBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) if (boundingBox->isCellInsideGbObject3D(minX1, minX2, minX3, maxX1, maxX2, maxX3)) { - LBMReal collFactor = LBMSystem::calcCollisionFactor(viscosity, block->getLevel()); + LBMReal collFactor = block->getKernel()->getCollisionFactor(); kernel->setCollisionFactor(collFactor); kernel->setIndex(block->getX1(), block->getX2(), block->getX3()); kernel->setDeltaT(LBMSystem::getDeltaT(block->getLevel())); @@ -62,9 +68,7 @@ void SpongeLayerBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) UB_THROW(UbException(UB_EXARGS, "It is not possible to change a BCProcessor in kernel! Old BCProcessor is not exist!")); } newKernel->setBCProcessor(bcProc); - block->setKernel(newKernel); - //SPtr<ILBMKernel> kernel = block->getKernel(); double oldCollFactor = newKernel->getCollisionFactor(); int ibX1 = block->getX1(); @@ -73,9 +77,9 @@ void SpongeLayerBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) UbTupleInt3 ixMax = grid->getBlockIndexes(boundingBox->getX1Maximum(),boundingBox->getX2Maximum(),boundingBox->getX3Maximum()); int ibMax = val<1>(ixMax)-val<1>(ixMin)+1; - double index = ibX1-val<1>(ixMin)+1; + double index = (double)(ibX1-val<1>(ixMin)+1); - double newCollFactor = oldCollFactor - (oldCollFactor-1.0)/ibMax*index; + double newCollFactor = oldCollFactor - (oldCollFactor-1.0)/(double)(ibMax)*index; newKernel->setCollisionFactor(newCollFactor); block->setKernel(newKernel); @@ -83,13 +87,14 @@ void SpongeLayerBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) } } ////////////////////////////////////////////////////////////////////////// -void SpongeLayerBlockVisitor::setKernel(SPtr<LBMKernel> k) +void SpongeLayerBlockVisitor::setBoundingBox(SPtr<GbCuboid3D> bb) { - kernel = k; + boundingBox = bb; } ////////////////////////////////////////////////////////////////////////// -void SpongeLayerBlockVisitor::setViscosity(LBMReal v) +void SpongeLayerBlockVisitor::setKernel(SPtr<LBMKernel> k) { - viscosity = v; + kernel = k; } + diff --git a/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.h b/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.h index c53a6a53ef78adb6cfeb7149d7c6a73d821eece4..9e4adc570b5aa50df71098420947f54efb4553c5 100644 --- a/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.h +++ b/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.h @@ -10,22 +10,21 @@ class GbCuboid3D; class LBMKernel; //! \brief Set sponge layer for all blocks inside boundingBox -//! \details This visitor is useful if you need to set or reset sponge layer in kernels (e.g. after restart because sponge layer is not serializable). +//! \details This visitor sets viscosity gradient inside bounding box. //! \author K. Kutscher class SpongeLayerBlockVisitor : public Block3DVisitor { public: - SpongeLayerBlockVisitor(SPtr<GbCuboid3D> boundingBox, LBMReal collFactor); + SpongeLayerBlockVisitor(); virtual ~SpongeLayerBlockVisitor(); void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; + void setBoundingBox(SPtr<GbCuboid3D> boundingBox); void setKernel(SPtr<LBMKernel> k); - void setViscosity(LBMReal v); private: SPtr<GbCuboid3D> boundingBox; - LBMReal collFactor; SPtr<LBMKernel> kernel; LBMReal viscosity; };