Commit 67700050 authored by Houman Mirzaalian Dastjerdi's avatar Houman Mirzaalian Dastjerdi
Browse files

Merged linked_list_lbm

parents a89019c6 e5a2a091
This diff is collapsed.
......@@ -5,6 +5,7 @@ add_subdirectory( CouetteFlow )
add_subdirectory( ForcesOnSphereNearPlaneInShearFlow )
add_subdirectory( NonUniformGrid )
add_subdirectory( MotionSingleHeavySphere )
add_subdirectory( PeriodicGranularGas )
add_subdirectory( PoiseuilleChannel )
add_subdirectory( SchaeferTurek )
add_subdirectory( UniformGrid )
\ No newline at end of file
add_subdirectory( UniformGrid )
......@@ -32,7 +32,6 @@
#include "lbm/list/CellCounters.h"
#include "lbm/list/List.h"
#include "lbm/list/ListCommunication.h"
//#include "lbm/list/ListSIMDKernel.h"
#include "lbm/list/ListKernel.h"
#include "lbm/list/ListPressureBoundary.h"
#include "lbm/list/ListVTK.h"
......
......@@ -241,7 +241,7 @@ class BorderRefinementSelection
public:
BorderRefinementSelection( const Setup & setup, const uint_t level, const real_t bufferDistance ) :
setup_( setup ), level_( level ), bufferDistance_( bufferDistance ) {}
setup_( setup ), level_( level ), bufferDistance_( bufferDistance ) { WALBERLA_UNUSED(setup_); }
void operator()( SetupBlockForest & forest )
{
......
waLBerla_link_files_to_builddir( *.cfg )
waLBerla_link_files_to_builddir( *.py )
waLBerla_add_executable ( NAME PeriodicGranularGas
FILES PeriodicGranularGas.cpp
DEPENDS blockforest core pe )
PeriodicGranularGas
{
simulationCorner < 0, 0, 0 >;
simulationDomain < 30, 30, 30 >;
blocks < 2, 2, 2 >;
isPeriodic < 1, 1, 1 >;
radius 0.5;
spacing 1.0;
vMax 0.0;
dt 0.1;
simulationSteps 1000;
visSpacing 100;
HCSITSmaxIterations 10;
HCSITSRelaxationParameter 0.7;
HCSITSErrorReductionParameter 0.8;
HCSITSRelaxationModelStr ApproximateInelasticCoulombContactByDecoupling;
globalLinearAcceleration < 0, 0, 0 >;
}
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file PeriodicGranularGas.cpp
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#include <pe/basic.h>
#include <pe/vtk/SphereVtkOutput.h>
#include <core/Abort.h>
#include <core/Environment.h>
#include <core/grid_generator/SCIterator.h>
#include <core/logging/Logging.h>
#include <core/waLBerlaBuildInfo.h>
#include <vtk/VTKOutput.h>
#include <functional>
#include <memory>
using namespace walberla;
using namespace walberla::pe;
using namespace walberla::timing;
typedef boost::tuple<Sphere> BodyTuple ;
int main( int argc, char ** argv )
{
Environment env(argc, argv);
logging::Logging::instance()->setStreamLogLevel(logging::Logging::INFO);
logging::Logging::instance()->setFileLogLevel(logging::Logging::INFO);
WALBERLA_LOG_INFO_ON_ROOT( "config file: " << argv[1] )
WALBERLA_LOG_INFO_ON_ROOT( "waLBerla Revision: " << WALBERLA_GIT_SHA1 );
math::seedRandomGenerator( static_cast<unsigned int>(1337 * mpi::MPIManager::instance()->worldRank()) );
WALBERLA_LOG_INFO_ON_ROOT("*** READING COMMANDLINE ARGUMENTS ***");
bool bDEM = false;
bool bHCSITS = false;
bool bNN = false;
bool bSO = false;
bool bInelasticFrictionlessContact = false;
bool bApproximateInelasticCoulombContactByDecoupling = false;
bool bInelasticCoulombContactByDecoupling = false;
bool bInelasticGeneralizedMaximumDissipationContact = false;
for( int i = 1; i < argc; ++i )
{
if( std::strcmp( argv[i], "--DEM" ) == 0 ) bDEM = true;
if( std::strcmp( argv[i], "--HCSITS" ) == 0 ) bHCSITS = true;
if( std::strcmp( argv[i], "--syncNextNeighbor" ) == 0 ) bNN = true;
if( std::strcmp( argv[i], "--syncShadowOwners" ) == 0 ) bSO = true;
if( std::strcmp( argv[i], "--InelasticFrictionlessContact" ) == 0 ) bInelasticFrictionlessContact = true;
if( std::strcmp( argv[i], "--ApproximateInelasticCoulombContactByDecoupling" ) == 0 ) bApproximateInelasticCoulombContactByDecoupling = true;
if( std::strcmp( argv[i], "--InelasticCoulombContactByDecoupling" ) == 0 ) bInelasticCoulombContactByDecoupling = true;
if( std::strcmp( argv[i], "--InelasticGeneralizedMaximumDissipationContact" ) == 0 ) bInelasticGeneralizedMaximumDissipationContact = true;
}
WALBERLA_LOG_INFO_ON_ROOT("*** READING CONFIG FILE ***");
auto cfg = env.config();
if (cfg == NULL) WALBERLA_ABORT("No config specified!");
const Config::BlockHandle mainConf = cfg->getBlock( "PeriodicGranularGas" );
int simulationSteps = mainConf.getParameter<int>("simulationSteps", 10 );
WALBERLA_LOG_INFO_ON_ROOT("simulationSteps: " << simulationSteps);
real_t dt = mainConf.getParameter<real_t>("dt", real_c(0.01) );
WALBERLA_LOG_INFO_ON_ROOT("dt: " << dt);
const int visSpacing = mainConf.getParameter<int>("visSpacing", 1000 );
WALBERLA_LOG_INFO_ON_ROOT("visSpacing: " << visSpacing);
const std::string path = mainConf.getParameter<std::string>("path", "vtk_out" );
WALBERLA_LOG_INFO_ON_ROOT("path: " << path);
WALBERLA_LOG_INFO_ON_ROOT("*** GLOBALBODYSTORAGE ***");
shared_ptr<BodyStorage> globalBodyStorage = make_shared<BodyStorage>();
WALBERLA_LOG_INFO_ON_ROOT("*** BLOCKFOREST ***");
// create forest
shared_ptr< BlockForest > forest = createBlockForestFromConfig( mainConf );
if (!forest)
{
WALBERLA_LOG_INFO_ON_ROOT( "No BlockForest created ... exiting!");
return EXIT_SUCCESS;
}
WALBERLA_LOG_INFO_ON_ROOT("simulationDomain: " << forest->getDomain());
WALBERLA_LOG_INFO_ON_ROOT("blocks: " << Vector3<uint_t>(forest->getXSize(), forest->getYSize(), forest->getZSize()) );
WALBERLA_LOG_INFO_ON_ROOT("*** BODYTUPLE ***");
// initialize body type ids
SetBodyTypeIDs<BodyTuple>::execute();
WALBERLA_LOG_INFO_ON_ROOT("*** STORAGEDATAHANDLING ***");
// add block data
auto storageID = forest->addBlockData(createStorageDataHandling<BodyTuple>(), "Storage");
auto ccdID = forest->addBlockData(ccd::createHashGridsDataHandling( globalBodyStorage, storageID ), "CCD");
auto fcdID = forest->addBlockData(fcd::createGenericFCDDataHandling<BodyTuple, fcd::AnalyticCollideFunctor>(), "FCD");
WALBERLA_LOG_INFO_ON_ROOT("*** INTEGRATOR ***");
std::unique_ptr<cr::ICR> cr;
if (bDEM)
{
cr = std::make_unique<cr::DEM>(globalBodyStorage, forest, storageID, ccdID, fcdID);
WALBERLA_LOG_INFO_ON_ROOT("Using DEM!");
} else if (bHCSITS)
{
cr = std::make_unique<cr::HCSITS>(globalBodyStorage, forest, storageID, ccdID, fcdID);
configure(mainConf, *static_cast<cr::HCSITS*>(cr.get()));
WALBERLA_LOG_INFO_ON_ROOT("Using HCSITS!");
cr::HCSITS* hcsits = static_cast<cr::HCSITS*>(cr.get());
if (bInelasticFrictionlessContact)
{
hcsits->setRelaxationModel(cr::HCSITS::InelasticFrictionlessContact);
WALBERLA_LOG_INFO_ON_ROOT("Using InelasticFrictionlessContact!");
} else if (bApproximateInelasticCoulombContactByDecoupling)
{
hcsits->setRelaxationModel(cr::HCSITS::ApproximateInelasticCoulombContactByDecoupling);
WALBERLA_LOG_INFO_ON_ROOT("Using ApproximateInelasticCoulombContactByDecoupling!");
} else if (bInelasticCoulombContactByDecoupling)
{
hcsits->setRelaxationModel(cr::HCSITS::InelasticCoulombContactByDecoupling);
WALBERLA_LOG_INFO_ON_ROOT("Using InelasticCoulombContactByDecoupling!");
} else if (bInelasticGeneralizedMaximumDissipationContact)
{
hcsits->setRelaxationModel(cr::HCSITS::InelasticGeneralizedMaximumDissipationContact);
WALBERLA_LOG_INFO_ON_ROOT("Using InelasticGeneralizedMaximumDissipationContact!");
} else
{
WALBERLA_ABORT("Friction model could not be determined!");
}
} else
{
WALBERLA_ABORT("Model could not be determined!");
}
WALBERLA_LOG_INFO_ON_ROOT("*** SYNCCALL ***");
std::function<void(void)> syncCallWithoutTT;
if (bNN)
{
syncCallWithoutTT = std::bind( pe::syncNextNeighbors<BodyTuple>, boost::ref(*forest), storageID, static_cast<WcTimingTree*>(NULL), real_c(0.0), false );
WALBERLA_LOG_INFO_ON_ROOT("Using NextNeighbor sync!");
} else if (bSO)
{
syncCallWithoutTT = std::bind( pe::syncShadowOwners<BodyTuple>, boost::ref(*forest), storageID, static_cast<WcTimingTree*>(NULL), real_c(0.0), false );
WALBERLA_LOG_INFO_ON_ROOT("Using ShadowOwner sync!");
} else
{
WALBERLA_ABORT("Synchronization method could not be determined!");
}
WALBERLA_LOG_INFO_ON_ROOT("*** VTK ***");
auto vtkDomainOutput = vtk::createVTKOutput_DomainDecomposition( forest, "domain_decomposition", 1, "vtk_out", "simulation_step" );
auto vtkSphereHelper = make_shared<SphereVtkOutput>(storageID, *forest) ;
auto vtkSphereOutput = vtk::createVTKOutput_PointData(vtkSphereHelper, "Bodies", 1, "vtk_out", "simulation_step", false, false);
WALBERLA_LOG_INFO_ON_ROOT("*** SETUP - START ***");
const real_t static_cof ( real_c(0.1) / 2 ); // Coefficient of static friction. Note: pe doubles the input coefficient of friction for material-material contacts.
const real_t dynamic_cof ( static_cof ); // Coefficient of dynamic friction. Similar to static friction for low speed friction.
MaterialID material = createMaterial( "granular", real_t( 1.0 ), 0, static_cof, dynamic_cof, real_t( 0.5 ), 1, 1, 0, 0 );
auto simulationDomain = forest->getDomain();
auto generationDomain = simulationDomain; // simulationDomain.getExtended(-real_c(0.5) * spacing);
const real_t spacing(1.0);
const real_t radius(0.5);
uint_t numParticles = uint_c(0);
for (auto& currentBlock : *forest)
{
for (auto it = grid_generator::SCIterator(currentBlock.getAABB().getIntersection(generationDomain), Vector3<real_t>(spacing, spacing, spacing) * real_c(0.5), spacing); it != grid_generator::SCIterator(); ++it)
{
SphereID sp = pe::createSphere( *globalBodyStorage, *forest, storageID, 0, *it, radius, material);
if (sp != NULL) ++numParticles;
}
}
mpi::reduceInplace(numParticles, mpi::SUM);
WALBERLA_LOG_INFO_ON_ROOT("#particles created: " << numParticles);
WALBERLA_LOG_INFO_ON_ROOT("*** SETUP - END ***");
// synchronize particles
syncCallWithoutTT();
syncCallWithoutTT();
WALBERLA_LOG_INFO_ON_ROOT("*** SIMULATION - START ***");
WALBERLA_MPI_BARRIER();
WcTimer timer;
for (int i=0; i < simulationSteps; ++i)
{
if( i % 200 == 0 )
{
WALBERLA_LOG_DEVEL_ON_ROOT( "Timestep " << i << " / " << simulationSteps );
}
cr->timestep( real_c(dt) );
syncCallWithoutTT();
// if( i % visSpacing == 0 )
// {
// vtkDomainOutput->write( );
// vtkSphereOutput->write( );
// }
}
WALBERLA_MPI_BARRIER();
timer.end();
WALBERLA_LOG_INFO_ON_ROOT("runtime: " << timer.average());
WALBERLA_LOG_INFO_ON_ROOT("*** SIMULATION - END ***");
WALBERLA_LOG_INFO_ON_ROOT("*** CHECKING RESULT - START ***");
for (auto& currentBlock : *forest)
{
Storage * storage = currentBlock.getData< Storage >( storageID );
BodyStorage& localStorage = (*storage)[0];
auto bodyIt = localStorage.begin();
for (auto it = grid_generator::SCIterator(currentBlock.getAABB().getIntersection(generationDomain), Vector3<real_t>(spacing, spacing, spacing) * real_c(0.5), spacing);
it != grid_generator::SCIterator();
++it, ++bodyIt)
{
WALBERLA_CHECK_UNEQUAL(bodyIt, localStorage.end());
WALBERLA_CHECK_FLOAT_EQUAL(bodyIt->getPosition(), *it);
}
}
WALBERLA_LOG_INFO_ON_ROOT("*** CHECKING RESULT - END ***");
return EXIT_SUCCESS;
}
import os
import time
import math
import random
import re
from influxdb import InfluxDBClient
from git import Repo
def main():
try:
write_user_pw = os.environ["INFLUXDB_WRITE_USER"]
except KeyError:
import sys
print('Password for the InfluxDB write_user was not set.\n',
'See https://docs.gitlab.com/ee/ci/variables/#secret-variables', file=sys.stderr)
exc_info = sys.exc_info()
raise exc_info[0].with_traceback(exc_info[1], exc_info[2])
client = InfluxDBClient('i10grafana.informatik.uni-erlangen.de', 8086,
'pe', write_user_pw, 'pe')
#repo = Repo(search_parent_directories=True)
#commit = repo.head.commit
with open("PeriodicGranularGas_DEM_NN.txt") as f:
s = f.read()
m = re.search('runtime: (\d*.\d*)', s)
json_body = [
{
'measurement': 'pe_benchmark',
'tags': {
'host' : os.uname()[1],
'image' : os.environ["DOCKER_IMAGE_NAME"],
'model' : 'DEM',
'friction': 'Coulomb',
'sync' : 'next neighbor'
},
'time': int(time.time()),
'fields': {'runtime': float(m.group(1))}
}
]
print(float(m.group(1)))
client.write_points(json_body, time_precision='s')
#*************************************************
with open("PeriodicGranularGas_DEM_SO.txt") as f:
s = f.read()
m = re.search('runtime: (\d*.\d*)', s)
json_body = [
{
'measurement': 'pe_benchmark',
'tags': {
'host' : os.uname()[1],
'image' : os.environ["DOCKER_IMAGE_NAME"],
'model' : 'DEM',
'friction': 'Coulomb',
'sync' : 'shadow owner'
},
'time': int(time.time()),
'fields': {'runtime': float(m.group(1))}
}
]
print(float(m.group(1)))
client.write_points(json_body, time_precision='s')
#*************************************************
with open("PeriodicGranularGas_HCSITS_NN_IFC.txt") as f:
s = f.read()
m = re.search('runtime: (\d*.\d*)', s)
json_body = [
{
'measurement': 'pe_benchmark',
'tags': {
'host' : os.uname()[1],
'image' : os.environ["DOCKER_IMAGE_NAME"],
'model' : 'HCSITS',
'friction': 'InelasticFrictionlessContact',
'sync' : 'next neighbor'
},
'time': int(time.time()),
'fields': {'runtime': float(m.group(1))}
}
]
print(float(m.group(1)))
client.write_points(json_body, time_precision='s')
#*************************************************
with open("PeriodicGranularGas_HCSITS_NN_AICCBD.txt") as f:
s = f.read()
m = re.search('runtime: (\d*.\d*)', s)
json_body = [
{
'measurement': 'pe_benchmark',
'tags': {
'host' : os.uname()[1],
'image' : os.environ["DOCKER_IMAGE_NAME"],
'model' : 'HCSITS',
'friction': 'ApproximateInelasticCoulombContactByDecoupling',
'sync' : 'next neighbor'
},
'time': int(time.time()),
'fields': {'runtime': float(m.group(1))}
}
]
print(float(m.group(1)))
client.write_points(json_body, time_precision='s')
#*************************************************
with open("PeriodicGranularGas_HCSITS_NN_ICCBD.txt") as f:
s = f.read()
m = re.search('runtime: (\d*.\d*)', s)
json_body = [
{
'measurement': 'pe_benchmark',
'tags': {
'host' : os.uname()[1],
'image' : os.environ["DOCKER_IMAGE_NAME"],
'model' : 'HCSITS',
'friction': 'InelasticCoulombContactByDecoupling',
'sync' : 'next neighbor'
},
'time': int(time.time()),
'fields': {'runtime': float(m.group(1))}
}
]
print(float(m.group(1)))
client.write_points(json_body, time_precision='s')
#*************************************************
with open("PeriodicGranularGas_HCSITS_NN_IGMDC.txt") as f:
s = f.read()
m = re.search('runtime: (\d*.\d*)', s)
json_body = [
{
'measurement': 'pe_benchmark',
'tags': {
'host' : os.uname()[1],
'image' : os.environ["DOCKER_IMAGE_NAME"],
'model' : 'HCSITS',
'friction': 'InelasticGeneralizedMaximumDissipationContact',
'sync' : 'next neighbor'
},
'time': int(time.time()),
'fields': {'runtime': float(m.group(1))}
}
]
print(float(m.group(1)))
client.write_points(json_body, time_precision='s')
#*************************************************
with open("PeriodicGranularGas_HCSITS_SO_IFC.txt") as f:
s = f.read()
m = re.search('runtime: (\d*.\d*)', s)
json_body = [
{
'measurement': 'pe_benchmark',
'tags': {
'host' : os.uname()[1],
'image' : os.environ["DOCKER_IMAGE_NAME"],
'model' : 'HCSITS',
'friction': 'InelasticFrictionlessContact',
'sync' : 'shadow owner'
},
'time': int(time.time()),
'fields': {'runtime': float(m.group(1))}
}
]
print(float(m.group(1)))
client.write_points(json_body, time_precision='s')
if __name__ == "__main__":
main()
......@@ -31,7 +31,6 @@
#include "core/uid/SUID.h"
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
#include <algorithm>
#include <functional>
......
......@@ -23,8 +23,6 @@
#include "CellSet.h"
#include "CellVector.h"
#include <boost/foreach.hpp>
namespace walberla {
namespace cell {
......@@ -51,7 +49,7 @@ bool CellInterval::overlaps( const CellVector& cellVector ) const
if( empty() )
return false;
BOOST_FOREACH( const Cell & cell, cellVector )
for( const Cell & cell : cellVector )
{
if( this->contains( cell ) )
return true;
......
......@@ -21,7 +21,6 @@
#include "ConfigToBoostPropertyTree.h"
#include <boost/foreach.hpp>
#include <boost/property_tree/ptree.hpp>
......@@ -39,7 +38,7 @@ boost::property_tree::iptree configBlockHandleToBoostPropertyTree( const Config:
Config::Blocks blocks;
blockHandle.getBlocks(blocks);
BOOST_FOREACH( const Config::BlockHandle & handle, blocks )
for( const Config::BlockHandle & handle : blocks )
propTree.add_child( handle.getKey(), configBlockHandleToBoostPropertyTree( handle ) );
return propTree;
......
......@@ -27,6 +27,7 @@
# include "CheckFunctions.h"
# include <functional>
# include <string>
# include "core/Macros.h"
#endif
......
......@@ -34,119 +34,19 @@ namespace domain_decomposition {
/// \cond internal
namespace internal
{
template<class T>
T * newFunc( const IBlock* const ) {
return new T();
template<class T, typename... Args>
T * newFunc( const IBlock* const, Args&... args ) {
return new T(args...);
}
template<class T, class P1>
T * newFunc( const IBlock* const , const P1 & p1 ) {
return new T(p1);
}
template<class T, class P1, class P2>
T * newFunc( const IBlock* const , const P1 & p1, const P2 & p2 ) {
return new T(p1, p2);
}
template<class T, class P1, class P2, class P3>
T * newFunc( const IBlock* const , const P1 & p1, const P2 & p2, const P3 & p3 ) {
return new T(p1, p2, p3);
}
template<class T, class P1, class P2, class P3, class P4>
T * newFunc( const IBlock* const , const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4 ) {
return new T(p1, p2, p3, p4);