Types folder updated

This commit is contained in:
Hamidreza Norouzi 2023-09-28 07:44:39 +03:30
parent 1696340ada
commit 503ee6be5e
27 changed files with 718 additions and 722 deletions

View File

@ -72,11 +72,11 @@ include_directories(src/setHelpers src/demComponent "${PROJECT_BINARY_DIR}")
add_subdirectory(src)
add_subdirectory(solvers)
#add_subdirectory(solvers)
add_subdirectory(utilities)
#add_subdirectory(utilities)
add_subdirectory(DEMSystems)
#add_subdirectory(DEMSystems)
#add_subdirectory(testIO)
install(FILES "${PROJECT_BINARY_DIR}/phasicFlowConfig.H"

View File

@ -1,15 +1,15 @@
add_subdirectory(phasicFlow)
add_subdirectory(Integration)
#add_subdirectory(Integration)
add_subdirectory(Property)
#add_subdirectory(Property)
add_subdirectory(Particles)
#add_subdirectory(Particles)
add_subdirectory(Interaction)
#add_subdirectory(Interaction)
add_subdirectory(MotionModel)
#add_subdirectory(MotionModel)
add_subdirectory(Geometry)
#add_subdirectory(Geometry)

View File

@ -0,0 +1,87 @@
list(APPEND SourceFiles
types/basicTypes/bTypesFunctions.cpp
types/basicTypes/Logical.cpp
types/types.cpp
globals/error.cpp
streams/token/tokenIO.cpp
streams/token/token.cpp
streams/iStream/IOstream.cpp
streams/iStream/iIstream.cpp
streams/iStream/iOstream.cpp
streams/Stream/Istream.cpp
streams/Stream/Ostream.cpp
streams/Fstream/iFstream.cpp
streams/Fstream/oFstream.cpp
streams/Fstream/fileStream.cpp
streams/TStream/iTstream.cpp
streams/TStream/oTstream.cpp
streams/streams.cpp
dictionary/dictionary.cpp
dictionary/entry/iEntry.cpp
dictionary/entry/dataEntry.cpp
dictionary/twoPartEntry/twoPartEntry.cpp
fileSystem/fileSystem.cpp
commandLine/commandLine.cpp
random/randomReal/randomReal.cpp
random/randomReal/randomReals.cpp
Timer/Timer.cpp
Timer/Timers.cpp
repository/Time/Time.cpp
repository/Time/timeControl.cpp
repository/systemControl/systemControl.cpp
repository/systemControl/dynamicLinkLibs.cpp
repository/repository/repository.cpp
repository/IOobject/objectFile.cpp
repository/IOobject/IOobject.cpp
repository/IOobject/IOfileHeader.cpp
structuredData/box/box.cpp
structuredData/cells/cells.cpp
structuredData/cylinder/cylinder.cpp
structuredData/sphere/sphere.cpp
structuredData/iBox/iBoxs.cpp
structuredData/line/line.cpp
structuredData/zAxis/zAxis.cpp
structuredData/pointStructure/pointStructure.cpp
structuredData/pointStructure/mortonIndexing.cpp
structuredData/pointStructure/selectors/pStructSelector/pStructSelector.cpp
structuredData/pointStructure/selectors/selectBox/selectBox.cpp
structuredData/pointStructure/selectors/selectRange/selectRange.cpp
structuredData/pointStructure/selectors/selectRandom/selectRandom.cpp
structuredData/trisurfaceStructure/triSurface.cpp
structuredData/trisurfaceStructure/multiTriSurface.cpp
structuredData/trisurfaceStructure/stlFile.cpp
structuredData/peakableRegion/sphereRegion/sphereRegion.cpp
structuredData/peakableRegion/cylinderRegion/cylinderRegion.cpp
structuredData/peakableRegion/boxRegion/boxRegion.cpp
structuredData/peakableRegion/peakableRegion/peakableRegion.cpp
structuredData/peakableRegion/peakableRegions.cpp
containers/Vector/Vectors.cpp
containers/Field/Fields.cpp
containers/symArrayHD/symArrays.cpp
containers/triSurfaceField/triSurfaceFields.cpp
containers/bitsetHD/bitsetHDs.cpp
containers/indexContainer/indexContainer.cpp
setFieldList/setFieldList.cpp
setFieldList/setFieldEntry.cpp
eventSubscriber/eventSubscriber.cpp
eventSubscriber/eventObserver.cpp)
set(link_libs Kokkos::kokkos tbb)
pFlow_add_library_install(phasicFlow SourceFiles link_libs)
target_include_directories(phasicFlow PUBLIC ./Kokkos ./algorithms ./globals)

View File

@ -4,84 +4,11 @@ types/basicTypes/bTypesFunctions.cpp
types/basicTypes/Logical.cpp
types/types.cpp
globals/error.cpp
streams/token/tokenIO.cpp
streams/token/token.cpp
streams/iStream/IOstream.cpp
streams/iStream/iIstream.cpp
streams/iStream/iOstream.cpp
streams/Stream/Istream.cpp
streams/Stream/Ostream.cpp
streams/Fstream/iFstream.cpp
streams/Fstream/oFstream.cpp
streams/Fstream/fileStream.cpp
streams/TStream/iTstream.cpp
streams/TStream/oTstream.cpp
streams/streams.cpp
dictionary/dictionary.cpp
dictionary/entry/iEntry.cpp
dictionary/entry/dataEntry.cpp
dictionary/twoPartEntry/twoPartEntry.cpp
fileSystem/fileSystem.cpp
commandLine/commandLine.cpp
random/randomReal/randomReal.cpp
random/randomReal/randomReals.cpp
Timer/Timer.cpp
Timer/Timers.cpp
repository/Time/Time.cpp
repository/Time/timeControl.cpp
repository/systemControl/systemControl.cpp
repository/systemControl/dynamicLinkLibs.cpp
repository/repository/repository.cpp
repository/IOobject/objectFile.cpp
repository/IOobject/IOobject.cpp
repository/IOobject/IOfileHeader.cpp
structuredData/box/box.cpp
structuredData/cells/cells.cpp
structuredData/cylinder/cylinder.cpp
structuredData/sphere/sphere.cpp
structuredData/iBox/iBoxs.cpp
structuredData/line/line.cpp
structuredData/zAxis/zAxis.cpp
structuredData/pointStructure/pointStructure.cpp
structuredData/pointStructure/mortonIndexing.cpp
structuredData/pointStructure/selectors/pStructSelector/pStructSelector.cpp
structuredData/pointStructure/selectors/selectBox/selectBox.cpp
structuredData/pointStructure/selectors/selectRange/selectRange.cpp
structuredData/pointStructure/selectors/selectRandom/selectRandom.cpp
structuredData/trisurfaceStructure/triSurface.cpp
structuredData/trisurfaceStructure/multiTriSurface.cpp
structuredData/trisurfaceStructure/stlFile.cpp
structuredData/peakableRegion/sphereRegion/sphereRegion.cpp
structuredData/peakableRegion/cylinderRegion/cylinderRegion.cpp
structuredData/peakableRegion/boxRegion/boxRegion.cpp
structuredData/peakableRegion/peakableRegion/peakableRegion.cpp
structuredData/peakableRegion/peakableRegions.cpp
containers/Vector/Vectors.cpp
containers/Field/Fields.cpp
containers/symArrayHD/symArrays.cpp
containers/triSurfaceField/triSurfaceFields.cpp
containers/bitsetHD/bitsetHDs.cpp
containers/indexContainer/indexContainer.cpp
setFieldList/setFieldList.cpp
setFieldList/setFieldEntry.cpp
eventSubscriber/eventSubscriber.cpp
eventSubscriber/eventObserver.cpp)
globals/error.cpp)
set(link_libs Kokkos::kokkos tbb)
pFlow_add_library_install(phasicFlow SourceFiles link_libs)
target_include_directories(phasicFlow PUBLIC ./Kokkos ./algorithms ./globals)
target_include_directories(phasicFlow PUBLIC ./globals)

View File

@ -227,9 +227,8 @@ iIstream& operator >>(iIstream& is, List<T>& lst);
using int64List = List<int64>;
using int32List = List<int32>;
using int16List = List<int16>;
using int8List = List<int8>;
using labelList = List<label>;
using uint64List = List<uint64>;
using uint32List = List<uint32>;
using realList = List<real>;

View File

@ -21,10 +21,17 @@ Licence:
#include <iostream>
#include <stdlib.h>
#ifdef pFlow_Build_MPI
#include <mpi.h>
#endif
#include <Kokkos_Core.hpp>
#include "error.hpp"
#include "streams.hpp"
static pFlow::Ostream& errorStream = pFlow::errReport;
@ -93,4 +100,22 @@ pFlow::iOstream& reportAndExit()
return errorStream;
}
int exitPhasicFlow()
{
// Kokkos should be finalized first
Kokkos::finalize();
#ifdef pFlow_Build_MPI
int flag=0;
MPI_Initialized(&flag)
if(flag == 1)
{
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
MPI_Finalize();
}
exit(EXIT_FAILURE);
#else
exit(EXIT_FAILURE);
#endif
return EXIT_FAILURE;
}

View File

@ -18,7 +18,6 @@ Licence:
-----------------------------------------------------------------------------*/
#ifndef __error_hpp__
#define __error_hpp__
@ -26,36 +25,17 @@ Licence:
#include "builtinTypes.hpp"
//- Forward decleartions
namespace pFlow
{
class iOstream;
}
// reports a fatal error and exit the applicaiton
#define fatalError \
fatalErrorMessage(__FILE__, __LINE__)
//- Decleartions
#define fatalErrorIn( functionName ) \
fatalErrorInMessage((functionName), __FILE__, __LINE__ )
#define fatalErrorInFunction fatalErrorIn(FUNCTION_NAME)
#define Not_Implemented(functionName) \
notImplementedErrorMessage ((functionName), __FILE__, __LINE__ )
#define notImplementedFunction Not_Implemented(FUNCTION_NAME);
#define ioErrorInFile( fileName, lineNumber) \
ioErrorMessage( fileName, lineNumber, FUNCTION_NAME, __FILE__, __LINE__ )
#define warningIn( functionName ) \
warningMessage((functionName), __FILE__, __LINE__ )
#define warningInFunction warningIn(FUNCTION_NAME)
#define fatalExit \
reportAndExit()
/// Take actions to fatal exit phasicFlow
int fatalExitPhasicFlow();
pFlow::iOstream& fatalErrorMessage(const char* fileName, int linNumber );
pFlow::iOstream& fatalErrorInMessage(const char* fnName, const char* fileName, int linNumber );
@ -65,4 +45,38 @@ pFlow::iOstream& ioErrorMessage(const char* fileName, int fileLineNumber, const
pFlow::iOstream& warningMessage(const char* fnName, const char* fileName, int linNumber );
pFlow::iOstream& reportAndExit();
/// Report a fatal error and exit the applicaiton
#define fatalError \
fatalErrorMessage(__FILE__, __LINE__)
/// Report a fatal error and supplied function name and exit the application
#define fatalErrorIn( functionName ) \
fatalErrorInMessage((functionName), __FILE__, __LINE__ )
/// Report a fatal error and function name and exit the application
#define fatalErrorInFunction fatalErrorIn(FUNCTION_NAME)
/// Report that a function is yet not implemented with supplied function name.
#define Not_Implemented(functionName) \
notImplementedErrorMessage ((functionName), __FILE__, __LINE__ )
/// Report that a function is yet not implemented.
#define notImplementedFunction Not_Implemented(FUNCTION_NAME);
/// Report an error in file operation with supplied fileName and lineNumber.
#define ioErrorInFile( fileName, lineNumber) \
ioErrorMessage( fileName, lineNumber, FUNCTION_NAME, __FILE__, __LINE__ )
/// Report a warning with supplied function name
#define warningIn( functionName ) \
warningMessage((functionName), __FILE__, __LINE__ )
/// Report a warning
#define warningInFunction warningIn(FUNCTION_NAME)
/// Fatal exit
#define fatalExit \
reportAndExit()
#endif

View File

@ -25,10 +25,7 @@ Licence:
namespace pFlow
{
const inline double vectorGrowthFactor__ = 1.1;
const inline double vectorGrowthFactor__ = 1.2;
}

View File

@ -70,7 +70,7 @@ Licence:
#define ForAll(i, container) for(auto i=0; i < container.size(); ++i)
#ifdef USE_STD_PARALLEL_ALG
#ifdef pFlow_STD_Parallel_Alg
static inline const bool useStdParallel__ = true;
#else
static inline const bool useStdParallel__ = false;

View File

@ -46,128 +46,125 @@ class Istream
std::istream& is_;
//- Get the next valid character
/// Get the next valid character
char nextValid();
//- Read a word token
/// Read a word token
void readWordToken(token& t);
//- Read a variable name starting with '$'.
/// Read a variable name starting with '$'.
// Handles "$var" and "${var}" forms, permits '/' scoping character.
Istream& readVariable(word& str);
//- No copy assignment
/// No copy assignment
void operator=(const Istream&) = delete;
public:
//- Construct wrapper around std::istream, set stream status
/// Construct wrapper around std::istream, set stream status
Istream( std::istream& is, const word& streamName, writeFormat wf = ASCII);
//- Destructor
/// Destructor
virtual ~Istream() = default;
//// - Methods
//- Return the name of the stream
/// Return the name of the stream
virtual const word& name() const
{
return name_;
}
//- Return non-const access to the name of the stream
/// Return non-const access to the name of the stream
virtual word& name()
{
return name_;
}
//- Return flags of output stream
/// Return flags of output stream
virtual ios_base::fmtflags flags() const;
//// Read Functions
//- Raw, low-level get character function.
/// Raw, low-level get character function.
Istream& get(char& c);
//- Raw, low-level peek function.
/// Raw, low-level peek function.
// Does not remove the character from the stream.
// Returns the next character in the stream or EOF if the
// end of file is read.
int peek();
//- Raw, low-level getline (until delimiter) into a string.
/// Raw, low-level getline (until delimiter) into a string.
Istream& getLine(word& str, char delim = '\n');
//- Low-level discard until delimiter
/// Low-level discard until delimiter
// return the number of characters extracted
std::streamsize getLine(std::nullptr_t, char delim = '\n');
//- Raw, low-level putback character function.
/// Raw, low-level putback character function.
Istream& putback(const char c);
//- Return next token from stream
/// Return next token from stream
virtual iIstream& read(token& t) override;
//- Read a character
/// Read a character
virtual iIstream& read(char& c) override;
//- Read a word
/// Read a word
virtual iIstream& read(word& str) override;
//- Read a string
/// Read a string
virtual iIstream& readString(word& str) override;
//- Read a int64
/// Read a int64
virtual iIstream& read(int64&) override;
//- Read a int32
/// Read a int32
virtual iIstream& read(int32&) override;
//- Read a int16
virtual iIstream& read(int16&) override;
//- Read a int8
/// Read a int8
virtual iIstream& read(int8&) override;
//- Read a label
virtual iIstream& read(label&) override;
/// Read a uint64
virtual iIstream& read(uint64&) override;
//- Read a uint32
/// Read a uint32
virtual iIstream& read(uint32&) override;
//- Read a uint16
virtual iIstream& read(uint16&) override;
/// Read a uint8
virtual iIstream& read(uint8&) override;
//- Read a float
/// Read a float
virtual iIstream& read(float& val) override;
//- Read a double
/// Read a double
virtual iIstream& read(double& val) override;
iIstream& read(char* buffer, std::streamsize count) override;
//- Rewind the stream so that it may be read again
/// Rewind the stream so that it may be read again
virtual void rewind();
//- Set stream flags
/// Set stream flags
virtual ios_base::fmtflags flags(const ios_base::fmtflags flags);
//- Access to underlying std::istream
/// Access to underlying std::istream
virtual std::istream& stdStream()
{
return is_;
}
//- Const access to underlying std::istream
/// Const access to underlying std::istream
virtual const std::istream& stdStream() const
{
return is_;

View File

@ -48,112 +48,115 @@ public:
Ostream ( std::ostream& os, const word& streamName, writeFormat wf = ASCII);
//- no copy construct
/// no copy construct
Ostream(const Ostream&) = delete;
//- No copy assignment
/// No copy assignment
void operator=(const Ostream&) = delete;
//// - Methods
//- Return the name of the stream
/// Return the name of the stream
virtual const word& name() const
{
return name_;
}
//- Return non-const access to the name of the stream
/// Return non-const access to the name of the stream
virtual word& name()
{
return name_;
}
//- Return flags of output stream
/// Return flags of output stream
virtual ios_base::fmtflags flags() const;
//- Write token to stream or otherwise handle it.
/// Write token to stream or otherwise handle it.
// return false if the token type was not handled by this method
bool write(const token& tok)override;
//- Write character
/// Write character
iOstream& write(const char c)override;
//- Write character string
/// Write character string
iOstream& write(const char* str)override;
//- Write word
/// Write word
iOstream& write(const word& str)override;
//- Write std::string surrounded by quotes.
/// Write std::string surrounded by quotes.
// Optional write without quotes.
iOstream& writeQuoted ( const word& str, const bool quoted=true ) override;
//- Write int64
/// Write int64
iOstream& write(const int64 val) override;
//- Write int32
/// Write int32
iOstream& write(const int32 val) override;
//- Write label
iOstream& write(const label val) override;
/// Write int32
iOstream& write(const int8 val) override;
//- Write uint32
/// Write uint64
iOstream& write(const uint64 val) override;
/// Write uint32
iOstream& write(const uint32 val) override;
//- Write uint16
iOstream& write(const uint16 val) override;
/// Write uint8
iOstream& write(const uint8 val) override;
//- Write float
/// Write float
iOstream& write(const float val) override;
//- Write double
/// Write double
iOstream& write(const double val) override;
/// Write a block of binray data
iOstream& write(const char* binaryData, std::streamsize count) override;
//- Add indentation characters
/// Add indentation characters
void indent() override;
//- Set stream flags
/// Set stream flags
ios_base::fmtflags flags(const ios_base::fmtflags f) override;
//- Flush stream
/// Flush stream
void flush() override;
//- Add newline and flush stream
/// Add newline and flush stream
void endl() override;
//- Get the current padding character
/// Get the current padding character
char fill() const override;
//- Set padding character for formatted field up to field width
/// Set padding character for formatted field up to field width
// \return previous padding character
char fill(const char fillch) override;
//- Get width of output field
/// Get width of output field
int width() const override;
//- Set width of output field
/// Set width of output field
// \return previous width
int width(const int w) override;
//- Get precision of output field
/// Get precision of output field
int precision() const override;
//- Set precision of output field
/// Set precision of output field
// return old precision
int precision(const int p) override;
//- Access to underlying std::ostream
/// Access to underlying std::ostream
virtual std::ostream& stdStream()
{
return os_;
}
//- Const access to underlying std::ostream
/// Const access to underlying std::ostream
virtual const std::ostream& stdStream() const
{
return os_;

View File

@ -46,7 +46,7 @@ public:
//// - Constructors
//- construct with a name
/// construct with a name
iTstream(const word& streamName);
// - construct with name and copy
@ -72,55 +72,52 @@ public:
// move assignment from tokenList
void operator=(tokenList&& tList);
//- Destructor
/// Destructor
virtual ~iTstream() = default;
//// Member Functions
//- Return the name of the stream
/// Return the name of the stream
virtual const word& name() const;
//- Return non-const access to the name of the stream
/// Return non-const access to the name of the stream
virtual word& name();
//- Return next token from stream
/// Return next token from stream
virtual iIstream& read(token& t)override;
//- Read a character
/// Read a character
virtual iIstream& read(char& c)override;
//- Read a word
/// Read a word
virtual iIstream& read(word& str)override;
//- Read a string
/// Read a string
virtual iIstream& readString(word& str)override;
//- Read a int64
/// Read a int64
virtual iIstream& read(int64&) override;
//- Read a int32
/// Read a int32
virtual iIstream& read(int32&) override;
//- Read a int16
virtual iIstream& read(int16&) override;
//- Read a int8
/// Read a int8
virtual iIstream& read(int8&) override;
//- Read a label
virtual iIstream& read(label&) override;
/// Read a uint64
virtual iIstream& read(uint64&) override;
//- Read a uint32
/// Read a uint32
virtual iIstream& read(uint32&) override;
//- Read a uint16
virtual iIstream& read(uint16&) override;
/// Read a uint8
virtual iIstream& read(uint8&) override;
//- Read a floatScalar
/// Read a floatScalar
virtual iIstream& read(float&) override;
//- Read a doubleScalar
/// Read a doubleScalar
virtual iIstream& read(double&) override;
iIstream& read(char* buffer, std::streamsize count) override;
@ -147,13 +144,13 @@ public:
// - append token to the end of token and rewind the stream
void appendToken(const token& t);
//- Return flags of output stream
/// Return flags of output stream
ios_base::fmtflags flags() const
{
return ios_base::fmtflags(0);
}
//- Set flags of stream
/// Set flags of stream
ios_base::fmtflags flags(const ios_base::fmtflags)
{
return ios_base::fmtflags(0);

View File

@ -61,45 +61,47 @@ public:
//// - Write
//- Write token to stream or otherwise handle it.
/// Write token to stream or otherwise handle it.
// return false if the token type was not handled by this method
virtual bool write(const token& tok);
//- Write single character. Whitespace is suppressed.
/// Write single character. Whitespace is suppressed.
virtual iOstream& write(const char c);
//- Write the word-characters of a character string.
/// Write the word-characters of a character string.
// Sends as a single char, or as word.
virtual iOstream& write(const char* str);
//- Write word
/// Write word
virtual iOstream& write(const word& str);
//- Write std::string surrounded by quotes.
/// Write std::string surrounded by quotes.
// Optional write without quotes.
virtual iOstream& writeQuoted(const std::string& str, const bool quoted=true );
//- Write int64
/// Write int64
virtual iOstream& write(const int64 val) override;
//- Write int32
/// Write int32
virtual iOstream& write(const int32 val) override;
/// Write int8
virtual iOstream& write(const int8 val) override;
//- Write label
virtual iOstream& write(const label val) override;
/// Write uint64
virtual iOstream& write(const uint64 val) override;
//- Write uint32
/// Write uint32
virtual iOstream& write(const uint32 val) override;
//- Write uint16
virtual iOstream& write(const uint16 val) override;
/// Write uint8
virtual iOstream& write(const uint8 val) override;
//- Write float
/// Write float
virtual iOstream& write(const float val) override;
//- Write double
/// Write double
virtual iOstream& write(const double val) override;
/// Write a block of binray data
@ -107,80 +109,80 @@ public:
const char* binaryData,
std::streamsize count) override;
// - append token to the stream
/// append token to the stream
virtual void append(const token& tok);
// - append a list of tokens to the stream
/// append a list of tokens to the stream
virtual void append(const tokenList& tLisk);
//// - Stream state functions
//- Reset the output buffer and rewind the stream
/// Reset the output buffer and rewind the stream
void reset();
//- Rewind the output stream
/// Rewind the output stream
virtual void rewind();
//- Add indentation characters
/// Add indentation characters
virtual void indent()
{}
//- Flush stream
/// Flush stream
virtual void flush()
{}
//- Add newline and flush stream
/// Add newline and flush stream
virtual void endl()
{}
//- Get the current padding character
/// Get the current padding character
// \return previous padding character
virtual char fill() const
{
return 0;
}
//- Set padding character for formatted field up to field width
/// Set padding character for formatted field up to field width
virtual char fill(const char)
{
return 0;
}
//- Get width of output field
/// Get width of output field
virtual int width() const
{
return 0;
}
//- Set width of output field
/// Set width of output field
// \return previous width
virtual int width(const int)
{
return 0;
}
//- Get precision of output field
/// Get precision of output field
virtual int precision() const
{
return 0;
}
//- Set precision of output field
/// Set precision of output field
// \return old precision
virtual int precision(const int)
{
return 0;
}
//- Return flags of output stream
/// Return flags of output stream
virtual ios_base::fmtflags flags() const
{
return ios_base::fmtflags(0);
}
//- Set flags of stream
/// Set flags of stream
ios_base::fmtflags flags(const ios_base::fmtflags)
{
return ios_base::fmtflags(0);

View File

@ -29,7 +29,10 @@ Licence:
namespace pFlow
{
/**
* Interface input stream class
*
*/
class iIstream // interface class for input streams
:
public IOstream
@ -37,17 +40,17 @@ class iIstream // interface class for input streams
// Private Data
//- Has a token been put back on the stream?
/// Has a token been put back on the stream?
bool putBack_;
//- The last token put back on the stream
/// The last token put back on the stream
token putBackToken_;
public:
//// - Constructors
///// Constructors
// - default
/// default
iIstream():
IOstream(),
putBack_(false)
@ -58,85 +61,82 @@ public:
putBack_(false)
{}
// - Copy construct
/// Copy construct
iIstream(const iIstream&) = default;
// - Destructor
/// Destructor
virtual ~iIstream() = default;
//// member methods
//- Put back token
// Only a single put back is permitted
/// Put back token
/// Only a single put back is permitted
void putBack(const token& tok);
//- Get the put back token if there is one and return true.
// Return false if no put back token is available.
/// Get the put back token if there is one and return true.
/// Return false if no put back token is available.
bool getBack(token& tok);
//- Peek at the put back token without removing it.
// Returns false if no put back token is available and set the
// token to undefined.
/// Peek at the put back token without removing it.
/// Returns false if no put back token is available and set the
/// token to undefined.
bool peekBack(token& tok);
//- reset the put back token;
/// reset the put back token;
void resetPutBack()
{
putBackToken_.reset();
putBack_ = false;
}
//- Return next token from stream
/// Return next token from stream
virtual iIstream& read(token&) = 0;
//- Read a character
/// Read a character
virtual iIstream& read(char&) = 0;
//- Read a string (including enclosing double-quotes)
/// Read a string (including enclosing double-quotes)
virtual iIstream& read(word&) = 0;
//- Read a string
/// Read a string
virtual iIstream& readString(word&) = 0;
//- Read a int64
/// Read a int64
virtual iIstream& read(int64&) = 0;
//- Read a int32
/// Read a int32
virtual iIstream& read(int32&) = 0;
//- Read a int16
virtual iIstream& read(int16&) = 0;
//- Read a int8
/// Read a int8
virtual iIstream& read(int8&) = 0;
//- Read a label
virtual iIstream& read(label&) = 0;
/// Read a uint64
virtual iIstream& read(uint64&) = 0;
//- Read a uin32
/// Read a uin32
virtual iIstream& read(uint32&) = 0;
//- Read a uin16
virtual iIstream& read(uint16&) = 0;
/// Read a uint8
virtual iIstream& read(uint8&) = 0;
//- Read a floatScalar
/// Read a floatScalar
virtual iIstream& read(float&) = 0;
//- Read a doubleScalar
/// Read a doubleScalar
virtual iIstream& read(double&) = 0;
virtual iIstream& read(char* buffer, std::streamsize count) =0;
//- Rewind the stream so that it may be read again
/// Rewind the stream so that it may be read again
virtual void rewind() = 0;
//// - find and lookups
///// find and lookups
// - search for all tokesn and find the first word token tbat matchs w
/// search for all tokesn and find the first word token tbat matchs w
virtual bool findToken( const word & w );
/// search for all tokesn after the current file position
@ -144,69 +144,69 @@ public:
virtual bool findTokenResume(const word& w);
// - search for all tokesn and find the first word token that matchs
/// search for all tokesn and find the first word token that matchs
virtual bool findTokenSilent( const word & w, int32 limitLine = 100 );
/// search for all tokesn after the current file position
/// and find the first word token tbat matchs w
virtual bool findTokenResumeSilent( const word & w, int32 limitLine = 100 );
// - search for all tokens and find the first word token and also next word token
// chekck if it is eneded with end statement ;
/// search for all tokens and find the first word token and also next word token
/// chekck if it is eneded with end statement ;
virtual bool findTokenAndNext( const word& w, word& nextW, bool checkEndStatement = true);
virtual bool findTokenAndNextSilent( const word& w, word& nextW, int32 limitLine = 100);
// - find a pair of keyword and data terminated by ;
// keyword data;
// return false if keyword does not exist or reading fails.
/// find a pair of keyword and data terminated by ;
/// keyword data;
/// return false if keyword does not exist or reading fails.
template<typename T>
bool findKeywordAndVal(const word& keyword, T& val, bool checkEndStatement = true);
// - lookup for keyword and data;
// fatalExit if fails
/// lookup for keyword and data;
/// fatalExit if fails
template<typename T>
T lookupData(const word& keyword);
// - lookup for keyword and data;
// set to setVal if lookup fails.
/// lookup for keyword and data;
/// set to setVal if lookup fails.
template<typename T>
T lookupDataOrSet(const word& keyword, const T& setVal);
// - read the data next to keword
// keyword data;
// check the keyword is correct or not
/// read the data next to keword
/// keyword data;
/// check the keyword is correct or not
template<typename T>
bool nextData(const word& keyword, T& data);
//// Read List punctuation tokens
//- Begin read of data chunk, starts with '('.
// return true or FatalIOError
/// Begin read of data chunk, starts with '('.
/// return true or FatalIOError
bool readBegin(const char* funcName);
//- End read of data chunk, ends with ')'
// return true or FatalIOError
/// End read of data chunk, ends with ')'
/// return true or FatalIOError
bool readEnd(const char* funcName);
//- Begin read of data chunk, starts with '('.
// return true or FatalIOError
/// Begin read of data chunk, starts with '('.
/// return true or FatalIOError
bool readBeginSquare(const char* funcName);
//- Begin read of data chunk, starts with '('.
// return true or FatalIOError
/// Begin read of data chunk, starts with '('.
/// return true or FatalIOError
bool readEndSquare(const char* funcName);
//- Begin read of list data, starts with '(' or '{'
// return starting delimiter or FatalIOError
/// Begin read of list data, starts with '(' or '{'
/// return starting delimiter or FatalIOError
char readBeginList(const char* funcName);
//- End read of list data, ends with ')' or '}'
// return closing delimiter or FatalIOError
/// End read of list data, ends with ')' or '}'
/// return closing delimiter or FatalIOError
char readEndList(const char* funcName);
// End statement character ;
/// End statement character ;
char readEndStatement(const char* funcName);
@ -217,13 +217,13 @@ public:
typedef iIstream& (*iIstreamManip)(iIstream&);
//- operator>> handling for manipulators without arguments
/// operator>> handling for manipulators without arguments
inline iIstream& operator>>(iIstream& is, iIstreamManip f)
{
return f(is);
}
//- operator>> handling for manipulators without arguments
/// operator>> handling for manipulators without arguments
inline iIstream& operator>>(iIstream& is, IOstreamManip f)
{
f(is);
@ -233,22 +233,19 @@ inline iIstream& operator>>(iIstream& is, IOstreamManip f)
// read operation for basic types it gets from the
// token stream
inline iIstream& operator>>( iIstream& is, word & w);
inline iIstream& operator>>( iIstream& is, int64& val);
inline iIstream& operator>>( iIstream& is, int32& val);
inline iIstream& operator>>( iIstream& is, int16& val);
inline iIstream& operator>>( iIstream& is, int8& val);
inline iIstream& operator>>( iIstream& is, uint64& val);
inline iIstream& operator>>( iIstream& is, uint32& val);
inline iIstream& operator>>( iIstream& is, uint16& val);
inline iIstream& operator>>( iIstream& is, label& val);
inline iIstream& operator>>( iIstream& is, uint8& val);
inline iIstream& operator>>( iIstream& is, float& val);

View File

@ -200,13 +200,6 @@ inline pFlow::iIstream& pFlow::operator>>( iIstream& is, int32& val)
return is;
}
inline pFlow::iIstream& pFlow::operator>>( iIstream& is, int16& val)
{
int64 lval(0);
is>>lval;
val = static_cast<int16>(lval);
return is;
}
inline pFlow::iIstream& pFlow::operator>>( iIstream& is, int8& val)
{
@ -216,11 +209,11 @@ inline pFlow::iIstream& pFlow::operator>>( iIstream& is, int8& val)
return is;
}
inline pFlow::iIstream& pFlow::operator>>( iIstream& is, label& val)
inline pFlow::iIstream& pFlow::operator>>( iIstream& is, uint64& val)
{
int64 lval(0);
is>>lval;
val = static_cast<label>(lval);
val = static_cast<uint64>(lval);
return is;
}
@ -232,11 +225,11 @@ inline pFlow::iIstream& pFlow::operator>>( iIstream& is, uint32& val)
return is;
}
inline pFlow::iIstream& pFlow::operator>>( iIstream& is, uint16& val)
inline pFlow::iIstream& pFlow::operator>>( iIstream& is, uint8& val)
{
int64 lval(0);
is>>lval;
val = static_cast<uint16>(lval);
val = static_cast<uint8>(lval);
return is;
}

View File

@ -118,14 +118,17 @@ public:
/// Write int32
virtual iOstream& write(const int32 val) = 0;
/// Write label
virtual iOstream& write(const label val) = 0;
/// Write int8
virtual iOstream& write(const int8 val) = 0;
/// Write uint64
virtual iOstream& write(const uint64 val) = 0;
/// Write uint32
virtual iOstream& write(const uint32 val) = 0;
/// Write uint16
virtual iOstream& write(const uint16 val) = 0;
/// Write uint8
virtual iOstream& write(const uint8 val) = 0;
/// Write float
virtual iOstream& write(const float val) = 0;
@ -377,17 +380,13 @@ inline iOstream& operator<<( iOstream& os, const int32& val)
return os.write(val);
}
inline iOstream& operator<<( iOstream& os, const int16& val)
{
return os.write(val);
}
inline iOstream& operator<<( iOstream& os, const int8& val)
{
return os.write(val);
}
inline iOstream& operator<<( iOstream& os, const label& val)
inline iOstream& operator<<( iOstream& os, const uint64& val)
{
return os.write(val);
}
@ -397,7 +396,7 @@ inline iOstream& operator<<( iOstream& os, const uint32& val)
return os.write(val);
}
inline iOstream& operator<<( iOstream& os, const uint16& val)
inline iOstream& operator<<( iOstream& os, const uint8& val)
{
return os.write(val);
}

View File

@ -17,28 +17,30 @@ Licence:
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
// based on OpenFOAM stream, with some modifications/simplifications
// to be tailored to our needs
#ifndef __token_hpp__
#define __token_hpp__
#include "bTypes.hpp"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace pFlow
{
// Forward Declarations
//- Forward Declarations
class token;
class iIstream;
class iOstream;
iOstream& operator<<(iOstream& os, const token& tok);
/**
* Token class
* based on OpenFOAM stream, with some modifications/simplifications
* to be tailored to our needs
*/
class token
{
public:
@ -212,8 +214,8 @@ public:
//- Construct punctuation character token
inline explicit token(punctuationToken p, int32 lineNumber=0);
//- Construct label token
inline explicit token(const label val, int32 lineNumber=0);
//- Construct uint64 token
inline explicit token(const uint64 val, int32 lineNumber=0);
//- Construct uint32 token
inline explicit token(const uint32 val, int32 lineNumber=0);

View File

@ -144,7 +144,7 @@ inline pFlow::token::token(punctuationToken p, int32 lineNumber)
data_.punctuationVal = p;
}
inline pFlow::token::token(const label val, int32 lineNumber)
inline pFlow::token::token(const uint64 val, int32 lineNumber)
:
data_(),
type_(tokenType::INT64),

View File

@ -137,18 +137,18 @@ namespace pFlow
template<>
inline word basicTypeName<int32>(){ return "int32"; }
template<>
inline word basicTypeName<int16>(){ return "int16"; }
template<>
inline word basicTypeName<int8>(){ return "int8"; }
template<>
inline word basicTypeName<label>(){ return "label"; }
inline word basicTypeName<uint64>(){ return "uint64"; }
template<>
inline word basicTypeName<uint32>(){ return "uint32"; }
template<>
inline word basicTypeName<uint8>(){ return "uint8"; }
template<>
inline word basicTypeName<real>(){ return "real"; }

View File

@ -17,7 +17,6 @@ Licence:
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#ifndef __Logical_hpp__
#define __Logical_hpp__
@ -25,22 +24,32 @@ Licence:
#include "bTypesFunctions.hpp"
#include "typeInfo.hpp"
namespace pFlow
{
//- Forward
class iIstream;
class iOstream;
// allias for bool
/**
* Holds a bool value and converts strings to bool
*
*/
class Logical
{
protected:
/// bool value
bool s_ = false;
/// Set numbe of of Yes or No
int yesNoSet_ = 0;
/// Set of Yes or Nos
inline static const word YesNo__[4][2] = {{"Yes", "No"},{"on","off"},{"true","false"}, {"Ok","No"}};
/// Construct from bool and set number
inline explicit Logical(bool s, int yns)
:
s_(s),
@ -49,30 +58,39 @@ protected:
public:
/// Type info
TypeInfoNV("Logical");
//// Constructors
/// Default constructor
inline Logical(){}
/// Construct from bool
inline explicit Logical(bool s)
:
s_(s),
yesNoSet_(0)
s_(s)
{}
/// Construct from word
Logical(const word& l);
/// Construct from char string
Logical(const char* ch);
/// Copy
Logical(const Logical&) = default;
/// Move
Logical(Logical&&) = default;
/// Copy assignment
Logical& operator=(const Logical&) = default;
/// Move assignment
Logical& operator=(Logical&&) = default;
/// Assignment with bool
inline Logical& operator=(const bool& b)
{
s_ = b;
@ -80,26 +98,34 @@ public:
return *this;
}
//// Methods
/// () operator, return bool value
inline bool operator()() const
{
return s_;
}
/// Return bool value
inline explicit operator bool() const
{
return s_;
}
/// Not operator
inline Logical operator!()const
{
return Logical(!s_, yesNoSet_);
}
//// IO operations
bool read(iIstream& is);
bool write(iOstream& os)const;
//// Static members
bool static evaluteWord(const word& l, bool& b, int& yesNoSet );

View File

@ -41,6 +41,29 @@ pFlow::int32 pFlow::countChar( const char* s, const char c)
);
}
pFlow::word pFlow::toUpper(const word & inStr)
{
word oStr(inStr);
transform(inStr.begin(), inStr.end(), oStr.begin(), ::toupper);
return oStr;
}
bool pFlow::isYes(const word & str)
{
word s = toUpper(str);
if( s == "YES" || s=="Y" || s == "OK" || s == "TRUE" || s == "ON" || s=="T") return true;
return false;
}
bool pFlow::isNo(const word & str)
{
word s = toUpper(str);
if( s == "NO" || s == "N" || "FALSE" || s == "OFF" || s == "F") return true;
return false;
}
pFlow::word pFlow::real2Fixed(const real & v, int32 numPrecision)
{
std::stringstream ss;
@ -104,29 +127,6 @@ pFlow::word pFlow::real2FixedStripZeros(const real & v, int32 numPrecision)
return removeDecimalZeros(strVal);
}
pFlow::word pFlow::toUpper(const word & inStr)
{
word oStr(inStr);
transform(inStr.begin(), inStr.end(), oStr.begin(), ::toupper);
return oStr;
}
bool pFlow::isYes(const word & str)
{
word s = toUpper(str);
if( s == "YES" || s == "OK" || s == "TRUE" || s == "ON" || s=="T") return true;
return false;
}
bool pFlow::isNo(const word & str)
{
word s = toUpper(str);
if( s == "NO" || s == "N" || "FALSE" || s == "OFF" || s == "F") return true;
return false;
}
pFlow::word pFlow::angleBracketsNames(const word& w1, const word& w2)
{
@ -222,25 +222,6 @@ bool pFlow::validWordWithQuote(const word& w)
return true;
}
bool pFlow::readLabel( const word& w, label & val)
{
try{
val = std::stoull(w);
}
catch (...)
{
return false;
}
return true;
}
bool pFlow::readLabel( const char* buf, label & val)
{
word w(buf);
return readLabel(w, val);
}
bool pFlow::readUint32( const word& w, uint32 & val)
{
try{
@ -296,42 +277,13 @@ bool pFlow::readInt32( const char* buf, int32 & val)
}
bool pFlow::readInt16( const word& w, int16 & val)
{
try{
val = static_cast<int16>(std::stoi(w));
}
catch (...)
{
return false;
}
return true;
}
bool pFlow::readInt16( const char* buf, int16 & val)
{
word w(buf);
return readInt16(w, val);
}
bool pFlow::readInt8( const word& w, int8 & val)
{
try{
val = static_cast<int8>(std::stoi(w));
}
catch (...)
{
return false;
}
return true;
}
bool pFlow::readInt8( const char* buf, int8 & val)
{
word w(buf);
return readInt8(w, val);
}
#include <iostream>
//#include <iostream>
bool pFlow::readReal( const word& w, real & val)
{
try{
@ -364,7 +316,6 @@ bool pFlow::readReal( const char* buf, real & val )
return false;
}
return true;
}

View File

@ -17,6 +17,10 @@ Licence:
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
/*! \file bTypeFunctions.hpp
\brief Helper functions for built-in types.
*/
#ifndef __bTypesFunctions_hpp__
#define __bTypesFunctions_hpp__
@ -27,127 +31,132 @@ Licence:
#include "math.hpp"
// helper functions and constants for basic types
namespace pFlow
{
/// Zero real variable
inline const real zero = 0.0;
/// one real variable
inline const real one = 1.0;
/// zero int32 variable
inline const int32 zero32 = 0;
/// one int32 variable
inline const int32 one32 = 1;
/// null/empty word
inline const word nullWord;
/// white space
inline const word whiteSpace(" \t\n\v\f\r");
/// Count numer of chars c in a word
int32 countChar (const word& s, const char c);
/// Count numer of chars c in a char string
int32 countChar(const char* s, const char c);
/// convert a word to all caps
word toUpper(const word & inStr);
/// Check if str equals "Yes", "Y", "True", "Ok", "ON", or "T"
bool isYes(const word & str);
/// Check if str equals "No", "N", "False", or "Off"
bool isNo(const word & str);
/// Convert floating point variable to string with fixed number of precisions
word real2Fixed(const real & v, int32 numPrecision = 6);
/// Convert floating point variable to string with general format
word real2Word(const real & v, int32 numPrecision = 6);
word removeDecimalZeros(const word& str);
word real2FixedStripZeros(const real & v, int32 numPrecision = 6);
/// Convert int32 to word
word int322Word(const int32 & v);
/// Remove zeros from decimal part of a string number
word removeDecimalZeros(const word& str);
/// Convert to fixed point variable and remove zeros
word real2FixedStripZeros(const real & v, int32 numPrecision = 6);
/// Output <w1,w2>
word angleBracketsNames(const word& w1, const word& w2);
/// Output base<w1,w2>
word angleBracketsNames2(const word& base, const word& w1, const word& w2);
/// Output base<w1,sw2,w3>
word angleBracketsNames3(const word& base, const word& w1, const word& w2, const word& w3);
/// Group words and output bw.tw
word groupNames(const word& bw, const word& tw, char sep = '.');
/// Find the base in a group separated by "." and return it.
word baseName(const word& w, char sep = '.');
/// Find tail name in a group separated by "." and return it.
word tailName(const word& w, char sep = '.');
// is the character valid for a word name
/// Is the character valid for a word name?
bool validWord(char c);
/// Is c a valid character including quote?
bool validWordWithQuote(char c);
/// Is a valid word?
bool validWord(const word& w);
/// Is a valid word with qoute?
bool validWordWithQuote(const word& c);
bool readLabel( const word& w, label & val);
bool readLabel( const char* buf, label & val);
/// Convert word to uint32
bool readUint32( const word& w, uint32 & val);
/// Convert char string to uint32
bool readUint32( const char* buf, uint32 & val);
/// Convert word to int64
bool readInt64( const word& w, int64 & val);
/// Convert char string to int64
bool readInt64( const char* buf, int64 & val);
/// Convert word to int32
bool readInt32( const word& w, int32 & val);
/// Convert char string to int32
bool readInt32( const char* buf, int32 & val);
bool readInt16( const word& w, int16 & val);
bool readInt16( const char* buf, int16 & val);
/// Convert word to int8
bool readInt8( const word& w, int8 & val);
/// Convert char string to int8
bool readInt8( const char* buf, int8 & val);
/// Convert word to real
bool readReal( const word& w, real & val);
/// Convert char string to real
bool readReal( const char* buf, real & val );
/// Convert word to bool
bool readBoolian_Str( const word& w, bool & val);
/// Convert char string to bool
bool readBoolian_Str( const char* buf, bool & val);
inline
bool readValue(const word& w, real& val)
{
return readReal(w,val);
}
inline
bool readValue(const word& w, label& val)
{
return readLabel(w,val);
}
inline
bool readValue(const word& w, uint32& val)
{
@ -166,11 +175,6 @@ bool readValue(const word& w, int32& val)
return readInt32(w,val);
}
inline
bool readValue(const word& w, int16& val)
{
return readInt16(w,val);
}
inline
bool readValue(const word& w, int8& val)
@ -185,53 +189,53 @@ bool readValue(const word& w, bool& val)
}
INLINE_FUNCTION_HD bool equal(const real& s1, const real& s2)
INLINE_FUNCTION_HD
bool equal(const real& s1, const real& s2)
{
return abs(s1 - s2) <= smallValue;
}
INLINE_FUNCTION_HD bool equal(const int64& s1, const int64& s2)
INLINE_FUNCTION_HD
bool equal(const int64& s1, const int64& s2)
{
return s1 == s2;
}
INLINE_FUNCTION_HD bool equal(const int32& s1, const int32& s2)
INLINE_FUNCTION_HD
bool equal(const int32& s1, const int32& s2)
{
return s1 == s2;
}
INLINE_FUNCTION_HD bool equal(const int16& s1, const int16& s2)
INLINE_FUNCTION_HD
bool equal(const int8& s1, const int8& s2)
{
return s1 == s2;
}
INLINE_FUNCTION_HD bool equal(const int8& s1, const int8& s2)
INLINE_FUNCTION_HD
bool equal(const uint32& s1, const uint32& s2)
{
return s1 == s2;
}
INLINE_FUNCTION_HD bool equal(const uint32& s1, const uint32& s2)
{
return s1 == s2;
}
INLINE_FUNCTION_HD bool equal(const label& s1, const label& s2)
{
return s1 == s2;
}
// host only
INLINE_FUNCTION bool equal(const word& s1, const word& s2)
/// Are two words equal (host only)?
INLINE_FUNCTION
bool equal(const word& s1, const word& s2)
{
return s1==s2;
}
INLINE_FUNCTION_HD real degree2Radian(const real &theta)
/// Convert degree to radians
INLINE_FUNCTION_HD
real degree2Radian(const real &theta)
{
return theta / 180.0 * Pi;
}
INLINE_FUNCTION_HD real radian2Degree(const real &phi)
/// Convert radians to degree
INLINE_FUNCTION_HD
real radian2Degree(const real &phi)
{
return phi / Pi * 180.0;
}

View File

@ -48,22 +48,22 @@ inline const bool usingDouble__ = false;
using int8 = signed char;
using int16 = short int;
using int32 = int;
using int64 = long long int;
using uint16 = unsigned short int ;
using uint8 = unsigned char ;
using uint32 = unsigned int;
using label = std::size_t;
using uint64 = unsigned long long int;
using size_t = std::size_t;
using word = std::string;
inline
auto floatingPointDescription()
word floatingPointDescription()
{
return word("In this build, ") + word(floatingPointType__) +
word(" is used for floating point operations.");

View File

@ -88,12 +88,12 @@ INLINE_FUNCTION_HD int32 mod(int32 x, int32 y)
return x%y;
}
INLINE_FUNCTION_HD int64 mod(label x, label y)
INLINE_FUNCTION_HD int64 mod(uint64 x, uint64 y)
{
return x%y;
}
INLINE_FUNCTION_HD int32 mod(uint32 x, uint32 y)
INLINE_FUNCTION_HD auto mod(uint32 x, uint32 y)
{
return x%y;
}
@ -319,7 +319,7 @@ INLINE_FUNCTION_HD int64 min(int64 x, int64 y)
#endif
}
INLINE_FUNCTION_HD label min(label x, label y)
INLINE_FUNCTION_HD uint64 min(uint64 x, uint64 y)
{
#ifdef __CUDACC__
return ::min(x, y);
@ -338,14 +338,7 @@ INLINE_FUNCTION_HD uint32 min(uint32 x, uint32 y)
#endif
}
INLINE_FUNCTION_HD uint32 min(uint16 x, uint16 y)
{
#ifdef __CUDACC__
return ::min(x, y);
#else
return std::min(x, y);
#endif
}
INLINE_FUNCTION_HD real max(real x, real y)
{
@ -374,7 +367,7 @@ INLINE_FUNCTION_HD int32 max(int32 x, int32 y)
#endif
}
INLINE_FUNCTION_HD label max(label x, label y)
INLINE_FUNCTION_HD uint64 max(uint64 x, uint64 y)
{
#ifdef __CUDACC__
return ::max(x, y);
@ -393,15 +386,6 @@ INLINE_FUNCTION_HD uint32 max(uint32 x, uint32 y)
#endif
}
INLINE_FUNCTION_HD uint32 max(uint16 x, uint16 y)
{
#ifdef __CUDACC__
return ::max(x, y);
#else
return std::max(x, y);
#endif
}
} // pFlow

View File

@ -17,7 +17,6 @@ Licence:
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#ifndef __triple_hpp__
#define __triple_hpp__
@ -33,42 +32,51 @@ Licence:
namespace pFlow
{
/// - Forward
template<typename T> class triple;
#include "tripleFwd.hpp"
// for 3D vectors
// it should be used only for numeric types, real, unit
/**
* A set of 3 variables that can be used for vector variables.
* The template parameter should be numeric type only.
*
*/
template <typename T>
struct triple
{
// data members
/// data members
T x_;
T y_;
T z_;
// initilizes to zero
INLINE_FUNCTION_HD triple():
//// Constructors
/// Initilize to zero
INLINE_FUNCTION_HD
triple():
x_(0),
y_(0),
z_(0)
{}
// Constructors
INLINE_FUNCTION_HD triple(const T &x, const T &y, const T &z):
/// Construct from x, y, z
INLINE_FUNCTION_HD
triple(const T &x, const T &y, const T &z):
x_(x),
y_(y),
z_(z)
{}
INLINE_FUNCTION_HD triple(const T &v):
/// Construct from v
INLINE_FUNCTION_HD
triple(const T &v):
triple(v, v, v)
{}
// type conversion trough assignment
/// Type conversion trough assignment
template <typename T2>
INLINE_FUNCTION_HD triple<T> & operator = (const triple<T2> & rhs)
{
@ -78,48 +86,34 @@ struct triple
return *this;
}
// type casting through copy constructor
/// Type casting through copy constructor
template<typename T2>
INLINE_FUNCTION_HD triple(const triple<T2> &src):
INLINE_FUNCTION_HD triple(const triple<T2> &src)
:
x_(static_cast<T>(src.x_)),
y_(static_cast<T>(src.y_)),
z_(static_cast<T>(src.z_))
{
}
{}
// copy construct
/// Copy construct
INLINE_FUNCTION_HD
triple(const triple<T>& src) = default;
// volatile copy construct
/*INLINE_FUNCTION_HD
triple(volatile triple<T>& src):
x_(src.x_),
y_(src.y_),
z_(src.z_)
{}*/
/*INLINE_FUNCTION_HD
triple& operator=(volatile triple<T>& src)
{
x_ = src.x_;
y_ = src.y_;
z_ = src.z_;
}*/
// move construct
/// Move construct
INLINE_FUNCTION_HD
triple(triple<T>&& src) = default;
// copy assignment
/// copy assignment
INLINE_FUNCTION_HD
triple<T>& operator=(const triple<T>& src) = default;
// move assignment
/// move assignment
INLINE_FUNCTION_HD
triple<T>& operator=(triple<T>&& src) = default;
// clone
/// clone
INLINE_FUNCTION
uniquePtr<triple<T>> clone() const
{
@ -132,53 +126,64 @@ struct triple
return new triple<T>(*this);
}
//// member methods
////// member methods
// access
/// access component
INLINE_FUNCTION_HD T & x(){ return x_; }
/// access component
INLINE_FUNCTION_HD const T & x()const { return x_; }
/// access component
INLINE_FUNCTION_HD T & y(){ return y_; }
/// access component
INLINE_FUNCTION_HD const T & y()const { return y_; }
/// access component
INLINE_FUNCTION_HD T & z(){ return z_; }
/// access component
INLINE_FUNCTION_HD const T & z()const { return z_; }
// methods
//// methods
/// Dot product of two vectors
friend FUNCTION_HD T dot <T> (const triple<T> & oprnd1, const triple<T> & oprnd2);
/// Cross product of two vectors
friend FUNCTION_HD triple<T> cross <T>(const triple<T> & v1, const triple<T> & v2);
/// Length of the vector
INLINE_FUNCTION_HD T length() const;
/// Normalize the vector
INLINE_FUNCTION_HD void normalize();
//// operators
// + operator
/// + operator
friend FUNCTION_HD triple<T> operator+ <T> (const triple<T> & oprnd1, const triple<T> & oprnd2);
friend FUNCTION_HD triple<T> operator+ <T> (const triple<T> & oprnd1, const T & oprnd2);
friend FUNCTION_HD triple<T> operator+ <T> (const T & oprnd1, const triple<T> & oprnd2);
// - operator
/// - operator
friend FUNCTION_HD triple<T> operator - <T> (const triple<T> & oprnd1, const triple<T> & oprnd2);
friend FUNCTION_HD triple<T> operator - <T> (const triple<T> & oprnd1, const T & oprnd2);
friend FUNCTION_HD triple<T> operator - <T> (const T & oprnd1, const triple<T> & oprnd2);
// * operators
/// * operators
friend FUNCTION_HD triple<T> operator * <T> (const triple<T> & oprnd1, const triple<T> & oprnd2);
friend FUNCTION_HD triple<T> operator * <T> (const triple<T> & oprnd1, const T & oprnd2);
friend FUNCTION_HD triple<T> operator * <T> (const T & oprnd1, const triple<T> & oprnd2);
// / operators
/// / operators
friend FUNCTION_HD triple<T> operator / <T> (const triple<T> & oprnd1, const triple<T> & oprnd2);
friend FUNCTION_HD triple<T> operator / <T> (const triple<T> & oprnd1, const T & oprnd2);
@ -195,10 +200,10 @@ struct triple
INLINE_FUNCTION_HD void operator/= (const triple & oprnd2);
// unary negate operator
/// unary negate operator
INLINE_FUNCTION_HD triple operator- ()const;
// unary plus operator
/// unary plus operator
INLINE_FUNCTION_HD triple operator+ ()const;
@ -212,13 +217,15 @@ struct triple
friend FUNCTION_HD bool operator <= <T> (const triple<T> &opr1, const triple<T> &opr2);
// << operator
//// IO operators
/// << operator
friend iOstream& operator<< <T> (iOstream& str, const triple<T> & ov);
// >> operator
/// >> operator
friend iIstream& operator >> <T> (iIstream & str, triple<T> & iv);
// same as >> operator, but faster, good for mass read
/// same as >> operator, but faster, good for mass read
friend void readIstream <T>( iIstream& str, triple<T> &iv);
};
@ -227,7 +234,7 @@ template<typename T>
bool INLINE_FUNCTION_HD equal( const triple<T>& opr1, const triple<T>& opr2 );
} // end of pFlow
} /// end of pFlow
#include "tripleI.hpp"
#include "tripleMath.hpp"

View File

@ -25,15 +25,11 @@ namespace pFlow
const realx3 zero3(0.0);
const realx3 one3(1.0);
const uint32x3 zeroU3(0);
const uint32x3 oneU3(1);
const realx3x3 zero33(zero3);
const realx3x3 one33(one3);
const uint32x3x3 zeroU33(zeroU3);
const uint32x3x3 oneU33(oneU3);
const real4 zero4(zero);
const realx4 zero4(zero);
} // pFlow

View File

@ -37,31 +37,23 @@ namespace pFlow
{
using int8x3 = triple<int8>;
using int16x3 = triple<int16>;
using int32x3 = triple<int32>;
using int64x3 = triple<int64>;
using uint16x3 = triple<uint16>;
using uint8x3 = triple<uint8>;
using uint32x3 = triple<uint32>;
using int32x3 = triple<int32>;
using int64x3 = triple<int64>;
using labelx3 = triple<label>;
using uint64x3 = triple<uint64>;
using realx3 = triple<real>;
using uint16x3x3= triple<uint16x3>;
using uint32x3x3= triple<uint32x3>;
using int32x3x3 = triple<int32x3>;
using labelx3x3 = triple<labelx3>;
using uint32x3x3= triple<uint32x3>;
using realx3x3 = triple<realx3>;
using real4 = quadruple<real>;
using realx4 = quadruple<real>;
template<>
inline word basicTypeName<int8x3>(){ return "int8x3"; }
template<>
inline word basicTypeName<int16x3>(){ return "int16x3"; }
template<>
inline word basicTypeName<int32x3>(){ return "int32x3"; }
@ -69,19 +61,19 @@ template<>
inline word basicTypeName<int64x3>(){ return "int64x3"; }
template<>
inline word basicTypeName<uint16x3>(){ return "uint16x3"; }
inline word basicTypeName<uint8x3>(){ return "uint8x3"; }
template<>
inline word basicTypeName<uint32x3>(){ return "uint32x3"; }
template<>
inline word basicTypeName<labelx3>(){ return "labelx3"; }
inline word basicTypeName<uint64x3>(){ return "unit64x3"; }
template<>
inline word basicTypeName<realx3>(){ return "realx3"; }
template<>
inline word basicTypeName<uint16x3x3>(){ return "uint16x3x3"; }
inline word basicTypeName<int32x3x3>(){ return "int32x3x3"; }
template<>
inline word basicTypeName<uint32x3x3>(){ return "uint32x3x3"; }
@ -91,20 +83,17 @@ inline word basicTypeName<realx3x3>(){ return "realx3x3"; }
template<>
inline word basicTypeName<real4>(){ return "real4"; }
inline word basicTypeName<realx4>(){ return "realx4"; }
extern const realx3 zero3;
extern const realx3 one3;
extern const uint32x3 zeroU3;
extern const uint32x3 oneU3;
extern const realx3x3 zero33;
extern const realx3x3 one33;
extern const uint32x3x3 zeroU33;
extern const uint32x3x3 oneU33;
extern const realx4 zero4;
} // pFlow