Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Showing
with 1504 additions and 48 deletions
This diff is collapsed.
waLBerla_link_files_to_builddir( *.dat )
waLBerla_add_executable( NAME 01_cnt_film
FILES 01_cnt_film.cpp
Config.cpp
FilmSpecimen.cpp
InitializeCNTs.cpp
SQLProperties.cpp
Statistics.cpp
DEPENDS walberla::blockforest walberla::core walberla::mesa_pd walberla::sqlite walberla::vtk )
//======================================================================================================================
//
// 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
//! \author Igor Ostanin <i.ostanin@skoltech.ru>
//! \author Grigorii Drozdov <drozd013@umn.edu>
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#include "Config.h"
#include "TerminalColors.h"
#include "core/mpi/Gatherv.h"
#include "core/mpi/MPIIO.h"
#include "core/mpi/RecvBuffer.h"
#include "core/mpi/SendBuffer.h"
namespace walberla {
namespace mesa_pd {
void saveConfig(const shared_ptr<data::ParticleStorage>& ps,
const std::string& filename,
const IO_MODE io_mode)
{
mpi::SendBuffer sb;
for (const auto& p : *ps)
{
using namespace walberla::mesa_pd::data::particle_flags;
if (isSet(p.getFlags(), GHOST)) continue; //skip ghosts
sb << static_cast<int64_t> (p.getSegmentID());
sb << static_cast<int64_t> (p.getClusterID());
// sb << static_cast<int64_t> (p.getGroupID());
sb << static_cast<double> (p.getPosition()[0]);
sb << static_cast<double> (p.getPosition()[1]);
sb << static_cast<double> (p.getPosition()[2]);
Vec3 orient = p.getRotation().getMatrix() * Vec3(1,0,0);
// Now orient has the shape (sin(th)cos(ph), sin(th)sin(ph), cos(th))
sb << static_cast<double> (std::acos(orient[2]));
sb << static_cast<double> (std::atan2(orient[1], orient[0]));
sb << static_cast<double> (p.getLinearVelocity()[0]);
sb << static_cast<double> (p.getLinearVelocity()[1]);
sb << static_cast<double> (p.getLinearVelocity()[2]);
sb << static_cast<double> (p.getAngularVelocity()[0]);
sb << static_cast<double> (p.getAngularVelocity()[1]);
sb << static_cast<double> (p.getAngularVelocity()[2]);
}
switch (io_mode)
{
case IO_MODE::REDUCE_TO_ROOT:
{
WALBERLA_LOG_INFO_ON_ROOT(CYAN << "Saving configuration (reduce to root): " << filename << RESET);
walberla::mpi::RecvBuffer rb;
walberla::mpi::gathervBuffer(sb, rb);
WALBERLA_ROOT_SECTION()
{
uint_t dataSize = sizeof(mpi::RecvBuffer::ElementType) * rb.size();
std::ofstream binfile;
binfile.open(filename + ".sav",
std::ios::out | std::ios::binary);
binfile.write(reinterpret_cast< const char * >(rb.ptr()), numeric_cast<std::streamsize>(dataSize));
binfile.close();
}
break;
}
case IO_MODE::USE_MPI_IO:
{
WALBERLA_LOG_INFO_ON_ROOT(CYAN << "Saving configuration (MPIIO): " << filename << RESET);
walberla::mpi::writeMPIIO(filename + ".mpiio", sb);
break;
}
case IO_MODE::ONE_FILE_PER_RANK:
{
WALBERLA_LOG_INFO_ON_ROOT(CYAN << "Saving configuration (one file per process): " << filename << RESET);
uint_t dataSize = sizeof(mpi::SendBuffer::ElementType) * sb.size();
std::ofstream binfile;
binfile.open(filename + "_" + std::to_string(mpi::MPIManager::instance()->rank()) + ".sav",
std::ios::out | std::ios::binary);
binfile.write(reinterpret_cast< const char * >(sb.ptr()), numeric_cast<std::streamsize>(dataSize));
binfile.close();
}
break;
default:
WALBERLA_ABORT("Unknown IO_MODE");
}
}
} //namespace mesa_pd
} //namespace walberla
......@@ -13,27 +13,25 @@
// 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 ShapeTypes.cpp
//! \file
//! \author Igor Ostanin <i.ostanin@skoltech.ru>
//! \author Grigorii Drozdov <drozd013@umn.edu>
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#include <mesa_pd/data/shape/Box.h>
#include <mesa_pd/data/shape/CylindricalBoundary.h>
#include <mesa_pd/data/shape/HalfSpace.h>
#include <mesa_pd/data/shape/Ellipsoid.h>
#include <mesa_pd/data/shape/Sphere.h>
#pragma once
#include "mesa_pd/data/ParticleStorage.h"
namespace walberla {
namespace mesa_pd {
namespace data {
const int Box::SHAPE_TYPE ;
const int CylindricalBoundary::SHAPE_TYPE;
const int HalfSpace::SHAPE_TYPE ;
const int Ellipsoid::SHAPE_TYPE ;
const int Sphere::SHAPE_TYPE ;
enum class IO_MODE {REDUCE_TO_ROOT, USE_MPI_IO, ONE_FILE_PER_RANK};
void saveConfig(const shared_ptr<data::ParticleStorage>& ps,
const std::string& filename,
const IO_MODE io_mode);
} //namespace data
} //namespace mesa_pd
} //namespace walberla
} //namespace walberla
\ No newline at end of file
This diff is collapsed.
//======================================================================================================================
//
// 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
//! \author Igor Ostanin <i.ostanin@skoltech.ru>
//! \author Grigorii Drozdov <drozd013@umn.edu>
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
//======================================================================================================================
//
// THIS FILE IS GENERATED - PLEASE CHANGE THE TEMPLATE !!!
//
//======================================================================================================================
#pragma once
#include "core/config/Config.h"
#include <string>
namespace walberla {
namespace mesa_pd {
struct FilmSpecimen
{
real_t sizeX = 0; //Specimen length (x direction)
real_t sizeY = 0; //Specimen length (y direction)
real_t sizeZ = 0; //Specimen length (z direction)
bool oopp = false; //Specimen out-of-plane periodicity (0 - film, 1 - cnt material)
uint_t numBlocksX = 1; //Number of blocks in x direction
uint_t numBlocksY = 1; //Number of blocks in y direction
uint_t numBlocksZ = 1; //Number of blocks in z direction
real_t min_OOP = 0; //Out-of-plane angle minimum
real_t max_OOP = 0; //Out-of-plane angle maximum
int numCNTs = 0; //Number of CNTs
int numSegs = 0; //Number of segments in a CNT
real_t spacing = 0; //Segment half-spacing
real_t localDamping = 0; //Local damping coefficient
real_t viscousDamping = 0; //Viscous damping coefficient
uint_t seed = 0; //random generator seed
int vdW = 0; //type of vdW interaction model
int simulationSteps = 0; //Relaxation duration
int saveVTKEveryNthStep = 0; //timesteps between saving VTK outputs
int saveEnergyEveryNthStep = 0; //timesteps between saving energies
int saveConfEveryNthStep = 0; //timesteps between saving confs
std::string vtkFolder = "."; //Folder for VTK files
std::string energyFolder = "."; //Folder for energy files
std::string confFolder = "."; //Folder for conf files
bool useMPIIO = false; //Write a single file instead of one file per process
std::string sqlFile = "cnt.sqlite"; //database file
std::string initialConfigurationFile = ""; //restart from checkpoint
};
void loadFromConfig(FilmSpecimen& params,
const Config::BlockHandle& cfg);
} //namespace mesa_pd
} //namespace walberla
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
from FilmSpecimenGenerator import Config
cfg = Config()
cfg.add_parameter("sizeX", "real_t", "0", "Specimen length (x direction)")
cfg.add_parameter("sizeY", "real_t", "0", "Specimen length (y direction)")
cfg.add_parameter("sizeZ", "real_t", "0", "Specimen length (z direction)")
cfg.add_parameter("oopp", "bool", "false", "Specimen out-of-plane periodicity (0 - film, 1 - cnt material)")
cfg.add_parameter("numBlocksX", "uint_t", "1", "Number of blocks in x direction")
cfg.add_parameter("numBlocksY", "uint_t", "1", "Number of blocks in y direction")
cfg.add_parameter("numBlocksZ", "uint_t", "1", "Number of blocks in z direction")
cfg.add_parameter("min_OOP", "real_t", "0", "Out-of-plane angle minimum")
cfg.add_parameter("max_OOP", "real_t", "0", "Out-of-plane angle maximum")
cfg.add_parameter("numCNTs", "int", "0", "Number of CNTs")
cfg.add_parameter("numSegs", "int", "0", "Number of segments in a CNT")
cfg.add_parameter("spacing", "real_t", "0", "Segment half-spacing")
cfg.add_parameter("localDamping", "real_t", "0", "Local damping coefficient")
cfg.add_parameter("viscousDamping", "real_t", "0", "Viscous damping coefficient")
cfg.add_parameter("seed", "uint_t", "0", "random generator seed")
cfg.add_parameter("vdW", "int", "0", "type of vdW interaction model")
cfg.add_parameter("simulationSteps", "int", "0", "Relaxation duration")
cfg.add_parameter("saveVTKEveryNthStep", "int", "0", "timesteps between saving VTK outputs")
cfg.add_parameter("saveEnergyEveryNthStep", "int", "0", "timesteps between saving energies")
cfg.add_parameter("saveConfEveryNthStep", "int", "0", "timesteps between saving confs")
cfg.add_parameter("vtkFolder", "std::string", '"."', "Folder for VTK files")
cfg.add_parameter("energyFolder", "std::string", '"."', "Folder for energy files")
cfg.add_parameter("confFolder", "std::string", '"."', "Folder for conf files")
cfg.add_parameter("useMPIIO", "bool", "false", "Write a single file instead of one file per process")
cfg.add_parameter("sqlFile", "std::string", '"cnt.sqlite"', "database file")
cfg.add_parameter("initialConfigurationFile", "std::string", '""', "restart from checkpoint")
cfg.generate()
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.