23#ifndef AUXILIARMETHODS_H_INCLUDED
24#define AUXILIARMETHODS_H_INCLUDED
33#include "aquagpusph/ext/boost/numeric/conversion/cast.hpp"
48hasPrefix(
const std::string& str,
const std::string& prefix);
53startswith(
const std::string& str,
const std::string& prefix)
65hasSuffix(
const std::string& str,
const std::string& suffix);
70endswith(
const std::string& str,
const std::string& prefix)
83 const std::string& search,
84 const std::string& replace);
94replaceAllCopy(std::string str, std::string search, std::string replace);
102ltrim(std::string& s);
110rtrim(std::string& s);
159xxd2string(
unsigned char* arr,
unsigned int len);
200std::vector<std::string>
201split(std::string str,
char chr);
209inline std::vector<std::string>
212 return split(s,
' ');
224std::vector<std::string>
250 unsigned int digits = 5);
293template<
typename T=
unsigned int>
297 T rest = x % divisor;
309template<
typename Tout=
int,
typename Tin>
311round(Tin n) {
return (Tout)(n + ((n >= 0) ? 0.5 : -0.5)); }
362isFile(
const std::string file_name);
402 return x < a ? a : (x > b ? b : x);
412template<
class Tdst,
class Torg>
419 r = boost::numeric_cast<Torg>(v);
421 catch(boost::numeric::bad_numeric_cast& e) {
422 throw std::out_of_range(
"narrow_cast<>() failed");
423 throw std::out_of_range(e.what());
463int rank(MPI_Comm comm);
470int size(MPI_Comm comm);
487void send(
const void *buf,
int count, MPI_Datatype datatype,
int dest,
int tag,
500MPI_Request
isend(
const void *buf,
int count, MPI_Datatype datatype,
int dest,
501 int tag, MPI_Comm comm);
513MPI_Status
recv(
void *buf,
int count, MPI_Datatype datatype,
int source,
514 int tag, MPI_Comm comm);
526MPI_Request
irecv(
void *buf,
int count, MPI_Datatype datatype,
527 int source,
int tag, MPI_Comm comm);
534MPI_Status
wait(MPI_Request *request);
#define T
Definition Sort.hcl.in:83
__kernel void count(__global const int *imove, __global unsigned int *ibuffer, usize N)
Identify the buffer particles.
Definition SetBuffer.cl:37
void finalize()
Wrapper for MPI_Finalize()
Definition AuxiliarMethods.cpp:409
MPI_Request isend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
Wrapper for MPI_Isend()
Definition AuxiliarMethods.cpp:461
MPI_Status recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm)
Wrapper for MPI_Recv()
Definition AuxiliarMethods.cpp:474
MPI_Status wait(MPI_Request *request)
Wrapper for MPI_Wait()
Definition AuxiliarMethods.cpp:500
int size(MPI_Comm comm)
Wrapper for MPI_Comm_size()
Definition AuxiliarMethods.cpp:429
void barrier(MPI_Comm comm)
Wrapper for MPI_Barrier()
Definition AuxiliarMethods.cpp:440
void send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
Wrapper for MPI_Send()
Definition AuxiliarMethods.cpp:450
int rank(MPI_Comm comm)
Wrapper for MPI_Comm_rank()
Definition AuxiliarMethods.cpp:418
std::string error_str(int errorcode)
Wrapper for MPI_Error_string()
Definition AuxiliarMethods.cpp:377
MPI_Request irecv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm)
Wrapper for MPI_Irecv()
Definition AuxiliarMethods.cpp:487
void init(int *argc, char ***argv)
Wrapper for MPI_Init()
Definition AuxiliarMethods.cpp:388
Main AQUAgpusph namespace.
Definition ArgumentsManager.cpp:50
bool startswith(const std::string &str, const std::string &prefix)
Alias for hasPrefix()
Definition AuxiliarMethods.hpp:53
void toLower(std::string &str)
Convert a string to lower case.
Definition AuxiliarMethods.cpp:148
const std::string getFolderFromFilePath(const std::string file_path)
Gets the folder path which contains the file <strong class=.
Definition AuxiliarMethods.cpp:303
Tdst narrow_cast(Torg v)
Cast a value, checking that it is not overflowing.
Definition AuxiliarMethods.hpp:414
std::string setStrConstantsCopy(std::string str)
Set several constants into a string.
Definition AuxiliarMethods.cpp:175
std::string toLowerCopy(std::string str)
Convert a string to lower case.
Definition AuxiliarMethods.cpp:154
std::string newFilePath(const std::string &basename, unsigned int &i, unsigned int digits)
Look for a file path which is not already taken.
Definition AuxiliarMethods.cpp:215
const std::string getFileNameFromFilePath(const std::string file_path)
Gets the file name of the path <strong class=.
Definition AuxiliarMethods.cpp:310
bool endswith(const std::string &str, const std::string &prefix)
Alias for hasSuffix()
Definition AuxiliarMethods.hpp:70
std::string xxd2string(unsigned char *arr, unsigned int len)
Transform a xxd exported file into a C++ string.
Definition AuxiliarMethods.cpp:132
std::string ltrimCopy(std::string s)
Remove all the blank spaces (including line breaks, tabulators...) string suffix.
Definition AuxiliarMethods.cpp:111
size_t getGlobalWorkSize(size_t n, size_t local_work_size)
Compute the global work size needed to compute <strong class= threads.
Definition AuxiliarMethods.cpp:358
T roundUp(T x, T divisor)
Rounded up value which is divisible by <strong class=.
Definition AuxiliarMethods.hpp:295
std::string trimCopy(std::string s)
Remove all the blank spaces (including line breaks, tabulators...) string prefix and suffix.
Definition AuxiliarMethods.cpp:125
void ltrim(std::string &s)
Remove all the blank spaces (including line breaks, tabulators...) string prefix.
Definition AuxiliarMethods.cpp:87
unsigned int isPowerOf2(unsigned int n)
Definition AuxiliarMethods.cpp:272
void trim(std::string &s)
Remove all the blank spaces (including line breaks, tabulators...) string prefix and suffix.
Definition AuxiliarMethods.cpp:104
unsigned int numberOfDigits(unsigned int number)
Get the number of digits of an integer decimal text representation.
Definition AuxiliarMethods.cpp:364
float clamp(float x, float a, float b)
Clamps a value between the bounds.
Definition AuxiliarMethods.hpp:400
std::string rtrimCopy(std::string s)
Remove all the blank spaces (including line breaks, tabulators...) string suffix.
Definition AuxiliarMethods.cpp:118
std::vector< std::string > split(std::string str, char chr)
Split a string by a character.
Definition AuxiliarMethods.cpp:182
void rtrim(std::string &s)
Remove all the blank spaces (including line breaks, tabulators...) string suffix.
Definition AuxiliarMethods.cpp:95
std::vector< std::string > split_formulae(std::string str)
Split a list of split_formulae.
Definition AuxiliarMethods.cpp:194
const std::string getExtensionFromFilePath(const std::string file_path)
Gets the file extension.
Definition AuxiliarMethods.cpp:317
size_t getLocalWorkSize(cl_command_queue queue)
Compute the maximum local work size allowed by a device.
Definition AuxiliarMethods.cpp:339
void setStrConstants(std::string &str)
Set several constants into a string.
Definition AuxiliarMethods.cpp:161
const std::string getRootPath()
Get the root path.
Definition AuxiliarMethods.cpp:293
std::string replaceAllCopy(std::string str, std::string search, std::string replace)
Replace all substring occurrences by another substring.
Definition AuxiliarMethods.cpp:80
Tout round(Tin n)
Round an float value to an integer one.
Definition AuxiliarMethods.hpp:311
bool isFile(const std::string file_name)
Check if the file <strong class= exist on the system.
Definition AuxiliarMethods.cpp:324
void replaceAll(std::string &str, const std::string &search, const std::string &replace)
Replace all substring occurrences by another substring.
Definition AuxiliarMethods.cpp:68
bool hasPrefix(const std::string &str, const std::string &prefix)
Check if a string starts with an specific prefix.
Definition AuxiliarMethods.cpp:54
bool isRelativePath(const std::string path)
Check if the path <strong class= is a relative or an absolute one.
Definition AuxiliarMethods.cpp:331
unsigned int nextPowerOf2(unsigned int n)
Definition AuxiliarMethods.cpp:259
bool hasSuffix(const std::string &str, const std::string &suffix)
Check if a string ends with an specific suffix.
Definition AuxiliarMethods.cpp:61
const std::string getExePath()
Get the executable path.
Definition AuxiliarMethods.cpp:278
Set of definitions and macros related with the implementation.
#define DECLDIR
Prefix to export C functions on the compiled library.
Definition sphPrerequisites.hpp:65