hemocell
Loading...
Searching...
No Matches
genericFunctions.h
Go to the documentation of this file.
1/*
2This file is part of the HemoCell library
3
4HemoCell is developed and maintained by the Computational Science Lab
5in the University of Amsterdam. Any questions or remarks regarding this library
6can be sent to: info@hemocell.eu
7
8When using the HemoCell library in scientific work please cite the
9corresponding paper: https://doi.org/10.3389/fphys.2017.00563
10
11The HemoCell library is free software: you can redistribute it and/or
12modify it under the terms of the GNU Affero General Public License as
13published by the Free Software Foundation, either version 3 of the
14License, or (at your option) any later version.
15
16The library is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU Affero General Public License for more details.
20
21You should have received a copy of the GNU Affero General Public License
22along with this program. If not, see <http://www.gnu.org/licenses/>.
23*/
24#ifndef FCN_GENERIC_FUNCTIONS_H
25#define FCN_GENERIC_FUNCTIONS_H
26
27#include <sys/stat.h>
28#include <vector>
29#include <string>
30
31#include <errno.h>
32#include <math.h>
33#ifdef HAVE_UNISTD_H
34#include <unistd.h>
35#endif /* HAVE_UNISTD_H */
36
37namespace hemo {
38
39typedef struct stat Stat;
40
41
42/*
43 * Returns the new dimensions in case of weak scaling
44 * eg.
45 * dim -> (32, 32, 32), numberOfProcesses-> 4
46 * newdim -> (64, 64, 32)
47 *
48 */
49void weakScaling(int Nx, int Ny, int Nz, int numberOfProcesses, std::vector<int> & newNxNyNz);
50
51inline bool file_exists(const std::string & name) {
52 /* Checks if a file exists */
53 // http://stackoverflow.com/questions/12774207/fastest-way-to-check-if-a-file-exist-using-standard-c-c11-c
54 struct stat buffer;
55 return (stat(name.c_str(), &buffer) == 0);
56}
57
58int renameFileToDotOld(std::string fName);
59
60
61/*
62@(#)File: $RCSfile: mkpath.c,v $
63@(#)Version: $Revision: 1.13 $
64@(#)Last changed: $Date: 2012/07/15 00:40:37 $
65@(#)Purpose: Create all directories in path
66@(#)Author: J Leffler
67@(#)Copyright: (C) JLSS 1990-91,1997-98,2001,2005,2008,2012
68*/
69// http://stackoverflow.com/questions/675039/how-can-i-create-directory-tree-in-c-linux
70
71int do_mkdir(const char * path, mode_t mode);
72
79// mkpath(argv[i], 0777);
80int mkpath(const char * path, mode_t mode);
81
82std::string zeroPadNumber(int num, int w = 12);
83
84void printHeader();
85
86}
87#include "multiBlock/multiBlockLattice3D.h"
88#include "multiBlock/multiDataField3D.h"
89#include "constant_defaults.h"
90namespace hemo {
91void boundaryFromFlagMatrix(plb::MultiBlockLattice3D<T, DESCRIPTOR> * fluid, plb::MultiScalarField3D<int> * flagMatrix,
92 bool);
93inline std::ostream & operator<<(std::ostream & stream, const plb::Box3D & box) {
94 return stream << "Box3D: " << box.x0 << " " << box.x1 << " " << box.y0 << " " << box.y1 << " " << box.z0 << " "
95 << box.z1 << std::endl;
96}
97inline std::ostream & operator<<(std::ostream & stream, const plb::Dot3D & dot) {
98 return stream << "Dot3D: " << dot.x << " " << dot.y << " " << dot.z << std::endl;
99}
100}
101#endif // FCN_GENERIC_FUNCTIONS_HH
Definition config.cpp:37
struct stat Stat
Definition genericFunctions.h:39
std::string zeroPadNumber(int num, int w)
Definition genericFunctions.cpp:103
int do_mkdir(const char *path, mode_t mode)
Definition genericFunctions.cpp:59
void boundaryFromFlagMatrix(plb::MultiBlockLattice3D< T, DESCRIPTOR > *fluid, plb::MultiScalarField3D< int > *flagMatrix, bool partOfpreInlet)
Definition genericFunctions.cpp:127
void printHeader()
Definition genericFunctions.cpp:110
void weakScaling(int Nx, int Ny, int Nz, int numberOfProcesses, vector< int > &newNxNyNz)
Definition genericFunctions.cpp:39
Logfile & operator<<(Logfile &lf, Val const &rhs)
Definition logfile.h:73
int mkpath(const char *path, mode_t mode)
Definition genericFunctions.cpp:81
_Tp dot(const Array< _Tp, _Nm > &one, const Array< _Tp, _Nm > &two)
Definition array.h:183
int renameFileToDotOld(std::string fName)
Definition genericFunctions.cpp:49
bool file_exists(const std::string &name)
Definition genericFunctions.h:51