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
42using namespace std;
43
44
45/*
46 * Returns the new dimensions in case of weak scaling
47 * eg.
48 * dim -> (32, 32, 32), numberOfProcesses-> 4
49 * newdim -> (64, 64, 32)
50 *
51 */
52void weakScaling(int Nx, int Ny, int Nz, int numberOfProcesses, vector<int> & newNxNyNz);
53
54inline bool file_exists (const std::string& name) {
55 /* Checks if a file exists */
56// http://stackoverflow.com/questions/12774207/fastest-way-to-check-if-a-file-exist-using-standard-c-c11-c
57 struct stat buffer;
58 return (stat (name.c_str(), &buffer) == 0);
59}
60
61int renameFileToDotOld(std::string fName);
62
63
64
65/*
66@(#)File: $RCSfile: mkpath.c,v $
67@(#)Version: $Revision: 1.13 $
68@(#)Last changed: $Date: 2012/07/15 00:40:37 $
69@(#)Purpose: Create all directories in path
70@(#)Author: J Leffler
71@(#)Copyright: (C) JLSS 1990-91,1997-98,2001,2005,2008,2012
72*/
73// http://stackoverflow.com/questions/675039/how-can-i-create-directory-tree-in-c-linux
74
75int do_mkdir(const char *path, mode_t mode);
76
83// mkpath(argv[i], 0777);
84int mkpath(const char *path, mode_t mode);
85
86std::string zeroPadNumber(int num,int w = 12);
87
88void printHeader();
89
90}
91#include "multiBlock/multiBlockLattice3D.h"
92#include "multiBlock/multiDataField3D.h"
93#include "constant_defaults.h"
94namespace hemo {
95void boundaryFromFlagMatrix(plb::MultiBlockLattice3D<T,DESCRIPTOR> * fluid, plb::MultiScalarField3D<int> * flagMatrix, bool);
96inline std::ostream& operator<<(std::ostream& stream, const plb::Box3D& box) {
97 return stream << "Box3D: " << box.x0 << " "<<box.x1<<" "<<box.y0<<" "<<box.y1<< " "<<box.z0<<" "<<box.z1<<endl;
98}
99inline std::ostream& operator<<(std::ostream& stream, const plb::Dot3D& dot) {
100 return stream << "Dot3D: " << dot.x << " "<<dot.y<<" "<<dot.z<<endl;
101}
102}
103#endif // FCN_GENERIC_FUNCTIONS_HH
Definition config.cpp:34
struct stat Stat
Definition genericFunctions.h:39
std::string zeroPadNumber(int num, int w)
Definition genericFunctions.cpp:112
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:138
void printHeader()
Definition genericFunctions.cpp:121
void weakScaling(int Nx, int Ny, int Nz, int numberOfProcesses, vector< int > &newNxNyNz)
Definition genericFunctions.cpp:36
Logfile & operator<<(Logfile &lf, Val const &rhs)
Definition logfile.h:43
int mkpath(const char *path, mode_t mode)
Definition genericFunctions.cpp:86
_Tp dot(const Array< _Tp, _Nm > &one, const Array< _Tp, _Nm > &two)
Definition array.h:220
int renameFileToDotOld(std::string fName)
Definition genericFunctions.cpp:46
bool file_exists(const std::string &name)
Definition genericFunctions.h:54