Types folder updated
This commit is contained in:
parent
1696340ada
commit
503ee6be5e
|
@ -72,11 +72,11 @@ include_directories(src/setHelpers src/demComponent "${PROJECT_BINARY_DIR}")
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
add_subdirectory(solvers)
|
#add_subdirectory(solvers)
|
||||||
|
|
||||||
add_subdirectory(utilities)
|
#add_subdirectory(utilities)
|
||||||
|
|
||||||
add_subdirectory(DEMSystems)
|
#add_subdirectory(DEMSystems)
|
||||||
#add_subdirectory(testIO)
|
#add_subdirectory(testIO)
|
||||||
|
|
||||||
install(FILES "${PROJECT_BINARY_DIR}/phasicFlowConfig.H"
|
install(FILES "${PROJECT_BINARY_DIR}/phasicFlowConfig.H"
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
|
|
||||||
add_subdirectory(phasicFlow)
|
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)
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -4,84 +4,11 @@ types/basicTypes/bTypesFunctions.cpp
|
||||||
types/basicTypes/Logical.cpp
|
types/basicTypes/Logical.cpp
|
||||||
types/types.cpp
|
types/types.cpp
|
||||||
|
|
||||||
globals/error.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)
|
set(link_libs Kokkos::kokkos tbb)
|
||||||
|
|
||||||
pFlow_add_library_install(phasicFlow SourceFiles link_libs)
|
pFlow_add_library_install(phasicFlow SourceFiles link_libs)
|
||||||
|
|
||||||
target_include_directories(phasicFlow PUBLIC ./Kokkos ./algorithms ./globals)
|
target_include_directories(phasicFlow PUBLIC ./globals)
|
||||||
|
|
||||||
|
|
|
@ -227,9 +227,8 @@ iIstream& operator >>(iIstream& is, List<T>& lst);
|
||||||
|
|
||||||
using int64List = List<int64>;
|
using int64List = List<int64>;
|
||||||
using int32List = List<int32>;
|
using int32List = List<int32>;
|
||||||
using int16List = List<int16>;
|
|
||||||
using int8List = List<int8>;
|
using int8List = List<int8>;
|
||||||
using labelList = List<label>;
|
using uint64List = List<uint64>;
|
||||||
using uint32List = List<uint32>;
|
using uint32List = List<uint32>;
|
||||||
|
|
||||||
using realList = List<real>;
|
using realList = List<real>;
|
||||||
|
|
|
@ -21,10 +21,17 @@ Licence:
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifdef pFlow_Build_MPI
|
||||||
|
#include <mpi.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Kokkos_Core.hpp>
|
||||||
|
|
||||||
#include "error.hpp"
|
#include "error.hpp"
|
||||||
#include "streams.hpp"
|
#include "streams.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static pFlow::Ostream& errorStream = pFlow::errReport;
|
static pFlow::Ostream& errorStream = pFlow::errReport;
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,4 +100,22 @@ pFlow::iOstream& reportAndExit()
|
||||||
return errorStream;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ Licence:
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __error_hpp__
|
#ifndef __error_hpp__
|
||||||
#define __error_hpp__
|
#define __error_hpp__
|
||||||
|
|
||||||
|
@ -26,36 +25,17 @@ Licence:
|
||||||
#include "builtinTypes.hpp"
|
#include "builtinTypes.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
//- Forward decleartions
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
class iOstream;
|
class iOstream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// reports a fatal error and exit the applicaiton
|
//- Decleartions
|
||||||
#define fatalError \
|
|
||||||
fatalErrorMessage(__FILE__, __LINE__)
|
|
||||||
|
|
||||||
#define fatalErrorIn( functionName ) \
|
/// Take actions to fatal exit phasicFlow
|
||||||
fatalErrorInMessage((functionName), __FILE__, __LINE__ )
|
int fatalExitPhasicFlow();
|
||||||
|
|
||||||
#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()
|
|
||||||
|
|
||||||
pFlow::iOstream& fatalErrorMessage(const char* fileName, int linNumber );
|
pFlow::iOstream& fatalErrorMessage(const char* fileName, int linNumber );
|
||||||
pFlow::iOstream& fatalErrorInMessage(const char* fnName, 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& warningMessage(const char* fnName, const char* fileName, int linNumber );
|
||||||
pFlow::iOstream& reportAndExit();
|
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
|
#endif
|
||||||
|
|
|
@ -25,10 +25,7 @@ Licence:
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
const inline double vectorGrowthFactor__ = 1.2;
|
||||||
const inline double vectorGrowthFactor__ = 1.1;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ Licence:
|
||||||
|
|
||||||
#define ForAll(i, container) for(auto i=0; i < container.size(); ++i)
|
#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;
|
static inline const bool useStdParallel__ = true;
|
||||||
#else
|
#else
|
||||||
static inline const bool useStdParallel__ = false;
|
static inline const bool useStdParallel__ = false;
|
||||||
|
|
|
@ -46,128 +46,125 @@ class Istream
|
||||||
std::istream& is_;
|
std::istream& is_;
|
||||||
|
|
||||||
|
|
||||||
//- Get the next valid character
|
/// Get the next valid character
|
||||||
char nextValid();
|
char nextValid();
|
||||||
|
|
||||||
//- Read a word token
|
/// Read a word token
|
||||||
void readWordToken(token& t);
|
void readWordToken(token& t);
|
||||||
|
|
||||||
|
|
||||||
//- Read a variable name starting with '$'.
|
/// Read a variable name starting with '$'.
|
||||||
// Handles "$var" and "${var}" forms, permits '/' scoping character.
|
// Handles "$var" and "${var}" forms, permits '/' scoping character.
|
||||||
Istream& readVariable(word& str);
|
Istream& readVariable(word& str);
|
||||||
|
|
||||||
//- No copy assignment
|
/// No copy assignment
|
||||||
void operator=(const Istream&) = delete;
|
void operator=(const Istream&) = delete;
|
||||||
|
|
||||||
|
|
||||||
public:
|
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);
|
Istream( std::istream& is, const word& streamName, writeFormat wf = ASCII);
|
||||||
|
|
||||||
//- Destructor
|
/// Destructor
|
||||||
virtual ~Istream() = default;
|
virtual ~Istream() = default;
|
||||||
|
|
||||||
|
|
||||||
//// - Methods
|
//// - Methods
|
||||||
|
|
||||||
//- Return the name of the stream
|
/// Return the name of the stream
|
||||||
virtual const word& name() const
|
virtual const word& name() const
|
||||||
{
|
{
|
||||||
return name_;
|
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()
|
virtual word& name()
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return flags of output stream
|
/// Return flags of output stream
|
||||||
virtual ios_base::fmtflags flags() const;
|
virtual ios_base::fmtflags flags() const;
|
||||||
|
|
||||||
|
|
||||||
//// Read Functions
|
//// Read Functions
|
||||||
|
|
||||||
//- Raw, low-level get character function.
|
/// Raw, low-level get character function.
|
||||||
Istream& get(char& c);
|
Istream& get(char& c);
|
||||||
|
|
||||||
//- Raw, low-level peek function.
|
/// Raw, low-level peek function.
|
||||||
// Does not remove the character from the stream.
|
// Does not remove the character from the stream.
|
||||||
// Returns the next character in the stream or EOF if the
|
// Returns the next character in the stream or EOF if the
|
||||||
// end of file is read.
|
// end of file is read.
|
||||||
int peek();
|
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');
|
Istream& getLine(word& str, char delim = '\n');
|
||||||
|
|
||||||
//- Low-level discard until delimiter
|
/// Low-level discard until delimiter
|
||||||
// return the number of characters extracted
|
// return the number of characters extracted
|
||||||
std::streamsize getLine(std::nullptr_t, char delim = '\n');
|
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);
|
Istream& putback(const char c);
|
||||||
|
|
||||||
//- Return next token from stream
|
/// Return next token from stream
|
||||||
virtual iIstream& read(token& t) override;
|
virtual iIstream& read(token& t) override;
|
||||||
|
|
||||||
//- Read a character
|
/// Read a character
|
||||||
virtual iIstream& read(char& c) override;
|
virtual iIstream& read(char& c) override;
|
||||||
|
|
||||||
//- Read a word
|
/// Read a word
|
||||||
virtual iIstream& read(word& str) override;
|
virtual iIstream& read(word& str) override;
|
||||||
|
|
||||||
//- Read a string
|
/// Read a string
|
||||||
virtual iIstream& readString(word& str) override;
|
virtual iIstream& readString(word& str) override;
|
||||||
|
|
||||||
//- Read a int64
|
/// Read a int64
|
||||||
virtual iIstream& read(int64&) override;
|
virtual iIstream& read(int64&) override;
|
||||||
|
|
||||||
//- Read a int32
|
/// Read a int32
|
||||||
virtual iIstream& read(int32&) override;
|
virtual iIstream& read(int32&) override;
|
||||||
|
|
||||||
//- Read a int16
|
/// Read a int8
|
||||||
virtual iIstream& read(int16&) override;
|
|
||||||
|
|
||||||
//- Read a int8
|
|
||||||
virtual iIstream& read(int8&) override;
|
virtual iIstream& read(int8&) override;
|
||||||
|
|
||||||
//- Read a label
|
/// Read a uint64
|
||||||
virtual iIstream& read(label&) override;
|
virtual iIstream& read(uint64&) override;
|
||||||
|
|
||||||
//- Read a uint32
|
/// Read a uint32
|
||||||
virtual iIstream& read(uint32&) override;
|
virtual iIstream& read(uint32&) override;
|
||||||
|
|
||||||
//- Read a uint16
|
/// Read a uint8
|
||||||
virtual iIstream& read(uint16&) override;
|
virtual iIstream& read(uint8&) override;
|
||||||
|
|
||||||
//- Read a float
|
/// Read a float
|
||||||
virtual iIstream& read(float& val) override;
|
virtual iIstream& read(float& val) override;
|
||||||
|
|
||||||
//- Read a double
|
/// Read a double
|
||||||
virtual iIstream& read(double& val) override;
|
virtual iIstream& read(double& val) override;
|
||||||
|
|
||||||
iIstream& read(char* buffer, std::streamsize count) 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();
|
virtual void rewind();
|
||||||
|
|
||||||
|
|
||||||
//- Set stream flags
|
/// Set stream flags
|
||||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags 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()
|
virtual std::istream& stdStream()
|
||||||
{
|
{
|
||||||
return is_;
|
return is_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Const access to underlying std::istream
|
/// Const access to underlying std::istream
|
||||||
virtual const std::istream& stdStream() const
|
virtual const std::istream& stdStream() const
|
||||||
{
|
{
|
||||||
return is_;
|
return is_;
|
||||||
|
|
|
@ -48,112 +48,115 @@ public:
|
||||||
|
|
||||||
Ostream ( std::ostream& os, const word& streamName, writeFormat wf = ASCII);
|
Ostream ( std::ostream& os, const word& streamName, writeFormat wf = ASCII);
|
||||||
|
|
||||||
//- no copy construct
|
/// no copy construct
|
||||||
Ostream(const Ostream&) = delete;
|
Ostream(const Ostream&) = delete;
|
||||||
|
|
||||||
//- No copy assignment
|
/// No copy assignment
|
||||||
void operator=(const Ostream&) = delete;
|
void operator=(const Ostream&) = delete;
|
||||||
|
|
||||||
|
|
||||||
//// - Methods
|
//// - Methods
|
||||||
|
|
||||||
//- Return the name of the stream
|
/// Return the name of the stream
|
||||||
virtual const word& name() const
|
virtual const word& name() const
|
||||||
{
|
{
|
||||||
return name_;
|
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()
|
virtual word& name()
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return flags of output stream
|
/// Return flags of output stream
|
||||||
virtual ios_base::fmtflags flags() const;
|
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
|
// return false if the token type was not handled by this method
|
||||||
bool write(const token& tok)override;
|
bool write(const token& tok)override;
|
||||||
|
|
||||||
//- Write character
|
/// Write character
|
||||||
iOstream& write(const char c)override;
|
iOstream& write(const char c)override;
|
||||||
|
|
||||||
//- Write character string
|
/// Write character string
|
||||||
iOstream& write(const char* str)override;
|
iOstream& write(const char* str)override;
|
||||||
|
|
||||||
//- Write word
|
/// Write word
|
||||||
iOstream& write(const word& str)override;
|
iOstream& write(const word& str)override;
|
||||||
|
|
||||||
//- Write std::string surrounded by quotes.
|
/// Write std::string surrounded by quotes.
|
||||||
// Optional write without quotes.
|
// Optional write without quotes.
|
||||||
iOstream& writeQuoted ( const word& str, const bool quoted=true ) override;
|
iOstream& writeQuoted ( const word& str, const bool quoted=true ) override;
|
||||||
|
|
||||||
//- Write int64
|
/// Write int64
|
||||||
iOstream& write(const int64 val) override;
|
iOstream& write(const int64 val) override;
|
||||||
|
|
||||||
//- Write int32
|
/// Write int32
|
||||||
iOstream& write(const int32 val) override;
|
iOstream& write(const int32 val) override;
|
||||||
|
|
||||||
//- Write label
|
/// Write int32
|
||||||
iOstream& write(const label val) override;
|
iOstream& write(const int8 val) override;
|
||||||
|
|
||||||
//- Write uint32
|
/// Write uint64
|
||||||
|
iOstream& write(const uint64 val) override;
|
||||||
|
|
||||||
|
/// Write uint32
|
||||||
iOstream& write(const uint32 val) override;
|
iOstream& write(const uint32 val) override;
|
||||||
|
|
||||||
//- Write uint16
|
/// Write uint8
|
||||||
iOstream& write(const uint16 val) override;
|
iOstream& write(const uint8 val) override;
|
||||||
|
|
||||||
//- Write float
|
/// Write float
|
||||||
iOstream& write(const float val) override;
|
iOstream& write(const float val) override;
|
||||||
|
|
||||||
//- Write double
|
/// Write double
|
||||||
iOstream& write(const double val) override;
|
iOstream& write(const double val) override;
|
||||||
|
|
||||||
/// Write a block of binray data
|
/// Write a block of binray data
|
||||||
iOstream& write(const char* binaryData, std::streamsize count) override;
|
iOstream& write(const char* binaryData, std::streamsize count) override;
|
||||||
|
|
||||||
//- Add indentation characters
|
/// Add indentation characters
|
||||||
void indent() override;
|
void indent() override;
|
||||||
|
|
||||||
//- Set stream flags
|
/// Set stream flags
|
||||||
ios_base::fmtflags flags(const ios_base::fmtflags f) override;
|
ios_base::fmtflags flags(const ios_base::fmtflags f) override;
|
||||||
|
|
||||||
//- Flush stream
|
/// Flush stream
|
||||||
void flush() override;
|
void flush() override;
|
||||||
|
|
||||||
//- Add newline and flush stream
|
/// Add newline and flush stream
|
||||||
void endl() override;
|
void endl() override;
|
||||||
|
|
||||||
//- Get the current padding character
|
/// Get the current padding character
|
||||||
char fill() const override;
|
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
|
// \return previous padding character
|
||||||
char fill(const char fillch) override;
|
char fill(const char fillch) override;
|
||||||
|
|
||||||
//- Get width of output field
|
/// Get width of output field
|
||||||
int width() const override;
|
int width() const override;
|
||||||
|
|
||||||
//- Set width of output field
|
/// Set width of output field
|
||||||
// \return previous width
|
// \return previous width
|
||||||
int width(const int w) override;
|
int width(const int w) override;
|
||||||
|
|
||||||
//- Get precision of output field
|
/// Get precision of output field
|
||||||
int precision() const override;
|
int precision() const override;
|
||||||
|
|
||||||
//- Set precision of output field
|
/// Set precision of output field
|
||||||
// return old precision
|
// return old precision
|
||||||
int precision(const int p) override;
|
int precision(const int p) override;
|
||||||
|
|
||||||
//- Access to underlying std::ostream
|
/// Access to underlying std::ostream
|
||||||
virtual std::ostream& stdStream()
|
virtual std::ostream& stdStream()
|
||||||
{
|
{
|
||||||
return os_;
|
return os_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Const access to underlying std::ostream
|
/// Const access to underlying std::ostream
|
||||||
virtual const std::ostream& stdStream() const
|
virtual const std::ostream& stdStream() const
|
||||||
{
|
{
|
||||||
return os_;
|
return os_;
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
|
|
||||||
//// - Constructors
|
//// - Constructors
|
||||||
|
|
||||||
//- construct with a name
|
/// construct with a name
|
||||||
iTstream(const word& streamName);
|
iTstream(const word& streamName);
|
||||||
|
|
||||||
// - construct with name and copy
|
// - construct with name and copy
|
||||||
|
@ -72,55 +72,52 @@ public:
|
||||||
// move assignment from tokenList
|
// move assignment from tokenList
|
||||||
void operator=(tokenList&& tList);
|
void operator=(tokenList&& tList);
|
||||||
|
|
||||||
//- Destructor
|
/// Destructor
|
||||||
virtual ~iTstream() = default;
|
virtual ~iTstream() = default;
|
||||||
|
|
||||||
|
|
||||||
//// Member Functions
|
//// Member Functions
|
||||||
|
|
||||||
//- Return the name of the stream
|
/// Return the name of the stream
|
||||||
virtual const word& name() const;
|
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();
|
virtual word& name();
|
||||||
|
|
||||||
//- Return next token from stream
|
/// Return next token from stream
|
||||||
virtual iIstream& read(token& t)override;
|
virtual iIstream& read(token& t)override;
|
||||||
|
|
||||||
//- Read a character
|
/// Read a character
|
||||||
virtual iIstream& read(char& c)override;
|
virtual iIstream& read(char& c)override;
|
||||||
|
|
||||||
//- Read a word
|
/// Read a word
|
||||||
virtual iIstream& read(word& str)override;
|
virtual iIstream& read(word& str)override;
|
||||||
|
|
||||||
//- Read a string
|
/// Read a string
|
||||||
virtual iIstream& readString(word& str)override;
|
virtual iIstream& readString(word& str)override;
|
||||||
|
|
||||||
//- Read a int64
|
/// Read a int64
|
||||||
virtual iIstream& read(int64&) override;
|
virtual iIstream& read(int64&) override;
|
||||||
|
|
||||||
//- Read a int32
|
/// Read a int32
|
||||||
virtual iIstream& read(int32&) override;
|
virtual iIstream& read(int32&) override;
|
||||||
|
|
||||||
//- Read a int16
|
/// Read a int8
|
||||||
virtual iIstream& read(int16&) override;
|
|
||||||
|
|
||||||
//- Read a int8
|
|
||||||
virtual iIstream& read(int8&) override;
|
virtual iIstream& read(int8&) override;
|
||||||
|
|
||||||
//- Read a label
|
/// Read a uint64
|
||||||
virtual iIstream& read(label&) override;
|
virtual iIstream& read(uint64&) override;
|
||||||
|
|
||||||
//- Read a uint32
|
/// Read a uint32
|
||||||
virtual iIstream& read(uint32&) override;
|
virtual iIstream& read(uint32&) override;
|
||||||
|
|
||||||
//- Read a uint16
|
/// Read a uint8
|
||||||
virtual iIstream& read(uint16&) override;
|
virtual iIstream& read(uint8&) override;
|
||||||
|
|
||||||
//- Read a floatScalar
|
/// Read a floatScalar
|
||||||
virtual iIstream& read(float&) override;
|
virtual iIstream& read(float&) override;
|
||||||
|
|
||||||
//- Read a doubleScalar
|
/// Read a doubleScalar
|
||||||
virtual iIstream& read(double&) override;
|
virtual iIstream& read(double&) override;
|
||||||
|
|
||||||
iIstream& read(char* buffer, std::streamsize count) 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
|
// - append token to the end of token and rewind the stream
|
||||||
void appendToken(const token& t);
|
void appendToken(const token& t);
|
||||||
|
|
||||||
//- Return flags of output stream
|
/// Return flags of output stream
|
||||||
ios_base::fmtflags flags() const
|
ios_base::fmtflags flags() const
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
return ios_base::fmtflags(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set flags of stream
|
/// Set flags of stream
|
||||||
ios_base::fmtflags flags(const ios_base::fmtflags)
|
ios_base::fmtflags flags(const ios_base::fmtflags)
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
return ios_base::fmtflags(0);
|
||||||
|
|
|
@ -61,45 +61,47 @@ public:
|
||||||
|
|
||||||
//// - Write
|
//// - 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
|
// return false if the token type was not handled by this method
|
||||||
virtual bool write(const token& tok);
|
virtual bool write(const token& tok);
|
||||||
|
|
||||||
//- Write single character. Whitespace is suppressed.
|
/// Write single character. Whitespace is suppressed.
|
||||||
virtual iOstream& write(const char c);
|
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.
|
// Sends as a single char, or as word.
|
||||||
virtual iOstream& write(const char* str);
|
virtual iOstream& write(const char* str);
|
||||||
|
|
||||||
//- Write word
|
/// Write word
|
||||||
virtual iOstream& write(const word& str);
|
virtual iOstream& write(const word& str);
|
||||||
|
|
||||||
|
|
||||||
//- Write std::string surrounded by quotes.
|
/// Write std::string surrounded by quotes.
|
||||||
// Optional write without quotes.
|
// Optional write without quotes.
|
||||||
virtual iOstream& writeQuoted(const std::string& str, const bool quoted=true );
|
virtual iOstream& writeQuoted(const std::string& str, const bool quoted=true );
|
||||||
|
|
||||||
//- Write int64
|
/// Write int64
|
||||||
virtual iOstream& write(const int64 val) override;
|
virtual iOstream& write(const int64 val) override;
|
||||||
|
|
||||||
//- Write int32
|
/// Write int32
|
||||||
virtual iOstream& write(const int32 val) override;
|
virtual iOstream& write(const int32 val) override;
|
||||||
|
|
||||||
|
/// Write int8
|
||||||
|
virtual iOstream& write(const int8 val) override;
|
||||||
|
|
||||||
//- Write label
|
/// Write uint64
|
||||||
virtual iOstream& write(const label val) override;
|
virtual iOstream& write(const uint64 val) override;
|
||||||
|
|
||||||
//- Write uint32
|
/// Write uint32
|
||||||
virtual iOstream& write(const uint32 val) override;
|
virtual iOstream& write(const uint32 val) override;
|
||||||
|
|
||||||
//- Write uint16
|
/// Write uint8
|
||||||
virtual iOstream& write(const uint16 val) override;
|
virtual iOstream& write(const uint8 val) override;
|
||||||
|
|
||||||
//- Write float
|
/// Write float
|
||||||
virtual iOstream& write(const float val) override;
|
virtual iOstream& write(const float val) override;
|
||||||
|
|
||||||
//- Write double
|
/// Write double
|
||||||
virtual iOstream& write(const double val) override;
|
virtual iOstream& write(const double val) override;
|
||||||
|
|
||||||
/// Write a block of binray data
|
/// Write a block of binray data
|
||||||
|
@ -107,80 +109,80 @@ public:
|
||||||
const char* binaryData,
|
const char* binaryData,
|
||||||
std::streamsize count) override;
|
std::streamsize count) override;
|
||||||
|
|
||||||
// - append token to the stream
|
/// append token to the stream
|
||||||
virtual void append(const token& tok);
|
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);
|
virtual void append(const tokenList& tLisk);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//// - Stream state functions
|
//// - Stream state functions
|
||||||
|
|
||||||
//- Reset the output buffer and rewind the stream
|
/// Reset the output buffer and rewind the stream
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
//- Rewind the output stream
|
/// Rewind the output stream
|
||||||
virtual void rewind();
|
virtual void rewind();
|
||||||
|
|
||||||
//- Add indentation characters
|
/// Add indentation characters
|
||||||
virtual void indent()
|
virtual void indent()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Flush stream
|
/// Flush stream
|
||||||
virtual void flush()
|
virtual void flush()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Add newline and flush stream
|
/// Add newline and flush stream
|
||||||
virtual void endl()
|
virtual void endl()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Get the current padding character
|
/// Get the current padding character
|
||||||
// \return previous padding character
|
// \return previous padding character
|
||||||
virtual char fill() const
|
virtual char fill() const
|
||||||
{
|
{
|
||||||
return 0;
|
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)
|
virtual char fill(const char)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Get width of output field
|
/// Get width of output field
|
||||||
virtual int width() const
|
virtual int width() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set width of output field
|
/// Set width of output field
|
||||||
// \return previous width
|
// \return previous width
|
||||||
virtual int width(const int)
|
virtual int width(const int)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Get precision of output field
|
/// Get precision of output field
|
||||||
virtual int precision() const
|
virtual int precision() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set precision of output field
|
/// Set precision of output field
|
||||||
// \return old precision
|
// \return old precision
|
||||||
virtual int precision(const int)
|
virtual int precision(const int)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return flags of output stream
|
/// Return flags of output stream
|
||||||
virtual ios_base::fmtflags flags() const
|
virtual ios_base::fmtflags flags() const
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
return ios_base::fmtflags(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set flags of stream
|
/// Set flags of stream
|
||||||
ios_base::fmtflags flags(const ios_base::fmtflags)
|
ios_base::fmtflags flags(const ios_base::fmtflags)
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
return ios_base::fmtflags(0);
|
||||||
|
|
|
@ -29,7 +29,10 @@ Licence:
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface input stream class
|
||||||
|
*
|
||||||
|
*/
|
||||||
class iIstream // interface class for input streams
|
class iIstream // interface class for input streams
|
||||||
:
|
:
|
||||||
public IOstream
|
public IOstream
|
||||||
|
@ -37,17 +40,17 @@ class iIstream // interface class for input streams
|
||||||
|
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
//- Has a token been put back on the stream?
|
/// Has a token been put back on the stream?
|
||||||
bool putBack_;
|
bool putBack_;
|
||||||
|
|
||||||
//- The last token put back on the stream
|
/// The last token put back on the stream
|
||||||
token putBackToken_;
|
token putBackToken_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//// - Constructors
|
///// Constructors
|
||||||
|
|
||||||
// - default
|
/// default
|
||||||
iIstream():
|
iIstream():
|
||||||
IOstream(),
|
IOstream(),
|
||||||
putBack_(false)
|
putBack_(false)
|
||||||
|
@ -58,85 +61,82 @@ public:
|
||||||
putBack_(false)
|
putBack_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// - Copy construct
|
/// Copy construct
|
||||||
iIstream(const iIstream&) = default;
|
iIstream(const iIstream&) = default;
|
||||||
|
|
||||||
// - Destructor
|
/// Destructor
|
||||||
virtual ~iIstream() = default;
|
virtual ~iIstream() = default;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//// member methods
|
//// member methods
|
||||||
|
|
||||||
//- Put back token
|
/// Put back token
|
||||||
// Only a single put back is permitted
|
/// Only a single put back is permitted
|
||||||
void putBack(const token& tok);
|
void putBack(const token& tok);
|
||||||
|
|
||||||
//- Get the put back token if there is one and return true.
|
/// Get the put back token if there is one and return true.
|
||||||
// Return false if no put back token is available.
|
/// Return false if no put back token is available.
|
||||||
bool getBack(token& tok);
|
bool getBack(token& tok);
|
||||||
|
|
||||||
//- Peek at the put back token without removing it.
|
/// Peek at the put back token without removing it.
|
||||||
// Returns false if no put back token is available and set the
|
/// Returns false if no put back token is available and set the
|
||||||
// token to undefined.
|
/// token to undefined.
|
||||||
bool peekBack(token& tok);
|
bool peekBack(token& tok);
|
||||||
|
|
||||||
//- reset the put back token;
|
/// reset the put back token;
|
||||||
void resetPutBack()
|
void resetPutBack()
|
||||||
{
|
{
|
||||||
putBackToken_.reset();
|
putBackToken_.reset();
|
||||||
putBack_ = false;
|
putBack_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return next token from stream
|
/// Return next token from stream
|
||||||
virtual iIstream& read(token&) = 0;
|
virtual iIstream& read(token&) = 0;
|
||||||
|
|
||||||
//- Read a character
|
/// Read a character
|
||||||
virtual iIstream& read(char&) = 0;
|
virtual iIstream& read(char&) = 0;
|
||||||
|
|
||||||
//- Read a string (including enclosing double-quotes)
|
/// Read a string (including enclosing double-quotes)
|
||||||
virtual iIstream& read(word&) = 0;
|
virtual iIstream& read(word&) = 0;
|
||||||
|
|
||||||
//- Read a string
|
/// Read a string
|
||||||
virtual iIstream& readString(word&) = 0;
|
virtual iIstream& readString(word&) = 0;
|
||||||
|
|
||||||
//- Read a int64
|
/// Read a int64
|
||||||
virtual iIstream& read(int64&) = 0;
|
virtual iIstream& read(int64&) = 0;
|
||||||
|
|
||||||
//- Read a int32
|
/// Read a int32
|
||||||
virtual iIstream& read(int32&) = 0;
|
virtual iIstream& read(int32&) = 0;
|
||||||
|
|
||||||
//- Read a int16
|
/// Read a int8
|
||||||
virtual iIstream& read(int16&) = 0;
|
|
||||||
|
|
||||||
//- Read a int8
|
|
||||||
virtual iIstream& read(int8&) = 0;
|
virtual iIstream& read(int8&) = 0;
|
||||||
|
|
||||||
//- Read a label
|
/// Read a uint64
|
||||||
virtual iIstream& read(label&) = 0;
|
virtual iIstream& read(uint64&) = 0;
|
||||||
|
|
||||||
//- Read a uin32
|
/// Read a uin32
|
||||||
virtual iIstream& read(uint32&) = 0;
|
virtual iIstream& read(uint32&) = 0;
|
||||||
|
|
||||||
//- Read a uin16
|
/// Read a uint8
|
||||||
virtual iIstream& read(uint16&) = 0;
|
virtual iIstream& read(uint8&) = 0;
|
||||||
|
|
||||||
//- Read a floatScalar
|
/// Read a floatScalar
|
||||||
virtual iIstream& read(float&) = 0;
|
virtual iIstream& read(float&) = 0;
|
||||||
|
|
||||||
//- Read a doubleScalar
|
/// Read a doubleScalar
|
||||||
virtual iIstream& read(double&) = 0;
|
virtual iIstream& read(double&) = 0;
|
||||||
|
|
||||||
virtual iIstream& read(char* buffer, std::streamsize count) =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;
|
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 );
|
virtual bool findToken( const word & w );
|
||||||
|
|
||||||
/// search for all tokesn after the current file position
|
/// search for all tokesn after the current file position
|
||||||
|
@ -144,69 +144,69 @@ public:
|
||||||
virtual bool findTokenResume(const word& w);
|
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 );
|
virtual bool findTokenSilent( const word & w, int32 limitLine = 100 );
|
||||||
|
|
||||||
/// search for all tokesn after the current file position
|
/// search for all tokesn after the current file position
|
||||||
/// and find the first word token tbat matchs w
|
/// and find the first word token tbat matchs w
|
||||||
virtual bool findTokenResumeSilent( const word & w, int32 limitLine = 100 );
|
virtual bool findTokenResumeSilent( const word & w, int32 limitLine = 100 );
|
||||||
|
|
||||||
// - search for all tokens and find the first word token and also next word token
|
/// search for all tokens and find the first word token and also next word token
|
||||||
// chekck if it is eneded with end statement ;
|
/// chekck if it is eneded with end statement ;
|
||||||
virtual bool findTokenAndNext( const word& w, word& nextW, bool checkEndStatement = true);
|
virtual bool findTokenAndNext( const word& w, word& nextW, bool checkEndStatement = true);
|
||||||
|
|
||||||
|
|
||||||
virtual bool findTokenAndNextSilent( const word& w, word& nextW, int32 limitLine = 100);
|
virtual bool findTokenAndNextSilent( const word& w, word& nextW, int32 limitLine = 100);
|
||||||
|
|
||||||
// - find a pair of keyword and data terminated by ;
|
/// find a pair of keyword and data terminated by ;
|
||||||
// keyword data;
|
/// keyword data;
|
||||||
// return false if keyword does not exist or reading fails.
|
/// return false if keyword does not exist or reading fails.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool findKeywordAndVal(const word& keyword, T& val, bool checkEndStatement = true);
|
bool findKeywordAndVal(const word& keyword, T& val, bool checkEndStatement = true);
|
||||||
|
|
||||||
// - lookup for keyword and data;
|
/// lookup for keyword and data;
|
||||||
// fatalExit if fails
|
/// fatalExit if fails
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T lookupData(const word& keyword);
|
T lookupData(const word& keyword);
|
||||||
|
|
||||||
// - lookup for keyword and data;
|
/// lookup for keyword and data;
|
||||||
// set to setVal if lookup fails.
|
/// set to setVal if lookup fails.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T lookupDataOrSet(const word& keyword, const T& setVal);
|
T lookupDataOrSet(const word& keyword, const T& setVal);
|
||||||
|
|
||||||
// - read the data next to keword
|
/// read the data next to keword
|
||||||
// keyword data;
|
/// keyword data;
|
||||||
// check the keyword is correct or not
|
/// check the keyword is correct or not
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool nextData(const word& keyword, T& data);
|
bool nextData(const word& keyword, T& data);
|
||||||
|
|
||||||
//// Read List punctuation tokens
|
//// Read List punctuation tokens
|
||||||
|
|
||||||
//- Begin read of data chunk, starts with '('.
|
/// Begin read of data chunk, starts with '('.
|
||||||
// return true or FatalIOError
|
/// return true or FatalIOError
|
||||||
bool readBegin(const char* funcName);
|
bool readBegin(const char* funcName);
|
||||||
|
|
||||||
//- End read of data chunk, ends with ')'
|
/// End read of data chunk, ends with ')'
|
||||||
// return true or FatalIOError
|
/// return true or FatalIOError
|
||||||
bool readEnd(const char* funcName);
|
bool readEnd(const char* funcName);
|
||||||
|
|
||||||
//- Begin read of data chunk, starts with '('.
|
/// Begin read of data chunk, starts with '('.
|
||||||
// return true or FatalIOError
|
/// return true or FatalIOError
|
||||||
bool readBeginSquare(const char* funcName);
|
bool readBeginSquare(const char* funcName);
|
||||||
|
|
||||||
//- Begin read of data chunk, starts with '('.
|
/// Begin read of data chunk, starts with '('.
|
||||||
// return true or FatalIOError
|
/// return true or FatalIOError
|
||||||
bool readEndSquare(const char* funcName);
|
bool readEndSquare(const char* funcName);
|
||||||
|
|
||||||
//- Begin read of list data, starts with '(' or '{'
|
/// Begin read of list data, starts with '(' or '{'
|
||||||
// return starting delimiter or FatalIOError
|
/// return starting delimiter or FatalIOError
|
||||||
char readBeginList(const char* funcName);
|
char readBeginList(const char* funcName);
|
||||||
|
|
||||||
//- End read of list data, ends with ')' or '}'
|
/// End read of list data, ends with ')' or '}'
|
||||||
// return closing delimiter or FatalIOError
|
/// return closing delimiter or FatalIOError
|
||||||
char readEndList(const char* funcName);
|
char readEndList(const char* funcName);
|
||||||
|
|
||||||
// End statement character ;
|
/// End statement character ;
|
||||||
char readEndStatement(const char* funcName);
|
char readEndStatement(const char* funcName);
|
||||||
|
|
||||||
|
|
||||||
|
@ -217,13 +217,13 @@ public:
|
||||||
|
|
||||||
typedef iIstream& (*iIstreamManip)(iIstream&);
|
typedef iIstream& (*iIstreamManip)(iIstream&);
|
||||||
|
|
||||||
//- operator>> handling for manipulators without arguments
|
/// operator>> handling for manipulators without arguments
|
||||||
inline iIstream& operator>>(iIstream& is, iIstreamManip f)
|
inline iIstream& operator>>(iIstream& is, iIstreamManip f)
|
||||||
{
|
{
|
||||||
return f(is);
|
return f(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- operator>> handling for manipulators without arguments
|
/// operator>> handling for manipulators without arguments
|
||||||
inline iIstream& operator>>(iIstream& is, IOstreamManip f)
|
inline iIstream& operator>>(iIstream& is, IOstreamManip f)
|
||||||
{
|
{
|
||||||
f(is);
|
f(is);
|
||||||
|
@ -233,22 +233,19 @@ inline iIstream& operator>>(iIstream& is, IOstreamManip f)
|
||||||
|
|
||||||
// read operation for basic types it gets from the
|
// read operation for basic types it gets from the
|
||||||
// token stream
|
// token stream
|
||||||
|
|
||||||
inline iIstream& operator>>( iIstream& is, word & w);
|
inline iIstream& operator>>( iIstream& is, word & w);
|
||||||
|
|
||||||
inline iIstream& operator>>( iIstream& is, int64& val);
|
inline iIstream& operator>>( iIstream& is, int64& val);
|
||||||
|
|
||||||
inline iIstream& operator>>( iIstream& is, int32& 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, int8& val);
|
||||||
|
|
||||||
|
inline iIstream& operator>>( iIstream& is, uint64& val);
|
||||||
|
|
||||||
inline iIstream& operator>>( iIstream& is, uint32& val);
|
inline iIstream& operator>>( iIstream& is, uint32& val);
|
||||||
|
|
||||||
inline iIstream& operator>>( iIstream& is, uint16& val);
|
inline iIstream& operator>>( iIstream& is, uint8& val);
|
||||||
|
|
||||||
inline iIstream& operator>>( iIstream& is, label& val);
|
|
||||||
|
|
||||||
inline iIstream& operator>>( iIstream& is, float& val);
|
inline iIstream& operator>>( iIstream& is, float& val);
|
||||||
|
|
||||||
|
|
|
@ -200,13 +200,6 @@ inline pFlow::iIstream& pFlow::operator>>( iIstream& is, int32& val)
|
||||||
return is;
|
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)
|
inline pFlow::iIstream& pFlow::operator>>( iIstream& is, int8& val)
|
||||||
{
|
{
|
||||||
|
@ -216,11 +209,11 @@ inline pFlow::iIstream& pFlow::operator>>( iIstream& is, int8& val)
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline pFlow::iIstream& pFlow::operator>>( iIstream& is, label& val)
|
inline pFlow::iIstream& pFlow::operator>>( iIstream& is, uint64& val)
|
||||||
{
|
{
|
||||||
int64 lval(0);
|
int64 lval(0);
|
||||||
is>>lval;
|
is>>lval;
|
||||||
val = static_cast<label>(lval);
|
val = static_cast<uint64>(lval);
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,11 +225,11 @@ inline pFlow::iIstream& pFlow::operator>>( iIstream& is, uint32& val)
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline pFlow::iIstream& pFlow::operator>>( iIstream& is, uint16& val)
|
inline pFlow::iIstream& pFlow::operator>>( iIstream& is, uint8& val)
|
||||||
{
|
{
|
||||||
int64 lval(0);
|
int64 lval(0);
|
||||||
is>>lval;
|
is>>lval;
|
||||||
val = static_cast<uint16>(lval);
|
val = static_cast<uint8>(lval);
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,14 +118,17 @@ public:
|
||||||
/// Write int32
|
/// Write int32
|
||||||
virtual iOstream& write(const int32 val) = 0;
|
virtual iOstream& write(const int32 val) = 0;
|
||||||
|
|
||||||
/// Write label
|
/// Write int8
|
||||||
virtual iOstream& write(const label val) = 0;
|
virtual iOstream& write(const int8 val) = 0;
|
||||||
|
|
||||||
|
/// Write uint64
|
||||||
|
virtual iOstream& write(const uint64 val) = 0;
|
||||||
|
|
||||||
/// Write uint32
|
/// Write uint32
|
||||||
virtual iOstream& write(const uint32 val) = 0;
|
virtual iOstream& write(const uint32 val) = 0;
|
||||||
|
|
||||||
/// Write uint16
|
/// Write uint8
|
||||||
virtual iOstream& write(const uint16 val) = 0;
|
virtual iOstream& write(const uint8 val) = 0;
|
||||||
|
|
||||||
/// Write float
|
/// Write float
|
||||||
virtual iOstream& write(const float val) = 0;
|
virtual iOstream& write(const float val) = 0;
|
||||||
|
@ -377,17 +380,13 @@ inline iOstream& operator<<( iOstream& os, const int32& val)
|
||||||
return os.write(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)
|
inline iOstream& operator<<( iOstream& os, const int8& val)
|
||||||
{
|
{
|
||||||
return os.write(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);
|
return os.write(val);
|
||||||
}
|
}
|
||||||
|
@ -397,7 +396,7 @@ inline iOstream& operator<<( iOstream& os, const uint32& val)
|
||||||
return os.write(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);
|
return os.write(val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,28 +17,30 @@ Licence:
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
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__
|
#ifndef __token_hpp__
|
||||||
#define __token_hpp__
|
#define __token_hpp__
|
||||||
|
|
||||||
|
|
||||||
#include "bTypes.hpp"
|
#include "bTypes.hpp"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward Declarations
|
//- Forward Declarations
|
||||||
class token;
|
class token;
|
||||||
class iIstream;
|
class iIstream;
|
||||||
class iOstream;
|
class iOstream;
|
||||||
|
|
||||||
iOstream& operator<<(iOstream& os, const token& tok);
|
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
|
class token
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -212,8 +214,8 @@ public:
|
||||||
//- Construct punctuation character token
|
//- Construct punctuation character token
|
||||||
inline explicit token(punctuationToken p, int32 lineNumber=0);
|
inline explicit token(punctuationToken p, int32 lineNumber=0);
|
||||||
|
|
||||||
//- Construct label token
|
//- Construct uint64 token
|
||||||
inline explicit token(const label val, int32 lineNumber=0);
|
inline explicit token(const uint64 val, int32 lineNumber=0);
|
||||||
|
|
||||||
//- Construct uint32 token
|
//- Construct uint32 token
|
||||||
inline explicit token(const uint32 val, int32 lineNumber=0);
|
inline explicit token(const uint32 val, int32 lineNumber=0);
|
||||||
|
|
|
@ -144,7 +144,7 @@ inline pFlow::token::token(punctuationToken p, int32 lineNumber)
|
||||||
data_.punctuationVal = p;
|
data_.punctuationVal = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline pFlow::token::token(const label val, int32 lineNumber)
|
inline pFlow::token::token(const uint64 val, int32 lineNumber)
|
||||||
:
|
:
|
||||||
data_(),
|
data_(),
|
||||||
type_(tokenType::INT64),
|
type_(tokenType::INT64),
|
||||||
|
|
|
@ -137,18 +137,18 @@ namespace pFlow
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<int32>(){ return "int32"; }
|
inline word basicTypeName<int32>(){ return "int32"; }
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<int16>(){ return "int16"; }
|
|
||||||
|
|
||||||
template<>
|
|
||||||
inline word basicTypeName<int8>(){ return "int8"; }
|
inline word basicTypeName<int8>(){ return "int8"; }
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<label>(){ return "label"; }
|
inline word basicTypeName<uint64>(){ return "uint64"; }
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<uint32>(){ return "uint32"; }
|
inline word basicTypeName<uint32>(){ return "uint32"; }
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline word basicTypeName<uint8>(){ return "uint8"; }
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<real>(){ return "real"; }
|
inline word basicTypeName<real>(){ return "real"; }
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ Licence:
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef __Logical_hpp__
|
#ifndef __Logical_hpp__
|
||||||
#define __Logical_hpp__
|
#define __Logical_hpp__
|
||||||
|
|
||||||
|
@ -25,22 +24,32 @@ Licence:
|
||||||
#include "bTypesFunctions.hpp"
|
#include "bTypesFunctions.hpp"
|
||||||
#include "typeInfo.hpp"
|
#include "typeInfo.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//- Forward
|
||||||
class iIstream;
|
class iIstream;
|
||||||
class iOstream;
|
class iOstream;
|
||||||
|
|
||||||
// allias for bool
|
/**
|
||||||
|
* Holds a bool value and converts strings to bool
|
||||||
|
*
|
||||||
|
*/
|
||||||
class Logical
|
class Logical
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/// bool value
|
||||||
bool s_ = false;
|
bool s_ = false;
|
||||||
|
|
||||||
|
/// Set numbe of of Yes or No
|
||||||
int yesNoSet_ = 0;
|
int yesNoSet_ = 0;
|
||||||
|
|
||||||
|
/// Set of Yes or Nos
|
||||||
inline static const word YesNo__[4][2] = {{"Yes", "No"},{"on","off"},{"true","false"}, {"Ok","No"}};
|
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)
|
inline explicit Logical(bool s, int yns)
|
||||||
:
|
:
|
||||||
s_(s),
|
s_(s),
|
||||||
|
@ -49,58 +58,75 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/// Type info
|
||||||
TypeInfoNV("Logical");
|
TypeInfoNV("Logical");
|
||||||
|
|
||||||
|
//// Constructors
|
||||||
|
|
||||||
inline Logical(){}
|
/// Default constructor
|
||||||
|
inline Logical(){}
|
||||||
|
|
||||||
|
/// Construct from bool
|
||||||
|
inline explicit Logical(bool s)
|
||||||
|
:
|
||||||
|
s_(s)
|
||||||
|
{}
|
||||||
|
|
||||||
inline explicit Logical(bool s)
|
/// Construct from word
|
||||||
:
|
Logical(const word& l);
|
||||||
s_(s),
|
|
||||||
yesNoSet_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Logical(const word& l);
|
/// Construct from char string
|
||||||
|
Logical(const char* ch);
|
||||||
|
|
||||||
Logical(const char* ch);
|
/// Copy
|
||||||
|
Logical(const Logical&) = default;
|
||||||
|
|
||||||
Logical(const Logical&) = default;
|
/// Move
|
||||||
|
Logical(Logical&&) = default;
|
||||||
|
|
||||||
Logical(Logical&&) = default;
|
/// Copy assignment
|
||||||
|
Logical& operator=(const Logical&) = default;
|
||||||
|
|
||||||
Logical& operator=(const Logical&) = default;
|
/// Move assignment
|
||||||
|
Logical& operator=(Logical&&) = default;
|
||||||
|
|
||||||
Logical& operator=(Logical&&) = default;
|
/// Assignment with bool
|
||||||
|
inline Logical& operator=(const bool& b)
|
||||||
|
{
|
||||||
|
s_ = b;
|
||||||
|
yesNoSet_ = 0;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
inline Logical& operator=(const bool& b)
|
//// Methods
|
||||||
{
|
|
||||||
s_ = b;
|
|
||||||
yesNoSet_ = 0;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool operator()() const
|
/// () operator, return bool value
|
||||||
{
|
inline bool operator()() const
|
||||||
return s_;
|
{
|
||||||
}
|
return s_;
|
||||||
|
}
|
||||||
|
|
||||||
inline explicit operator bool() const
|
/// Return bool value
|
||||||
{
|
inline explicit operator bool() const
|
||||||
return s_;
|
{
|
||||||
}
|
return s_;
|
||||||
|
}
|
||||||
|
|
||||||
inline Logical operator!()const
|
/// Not operator
|
||||||
{
|
inline Logical operator!()const
|
||||||
return Logical(!s_, yesNoSet_);
|
{
|
||||||
}
|
return Logical(!s_, yesNoSet_);
|
||||||
|
}
|
||||||
|
|
||||||
//// IO operations
|
//// IO operations
|
||||||
bool read(iIstream& is);
|
|
||||||
|
|
||||||
bool write(iOstream& os)const;
|
bool read(iIstream& is);
|
||||||
|
|
||||||
bool static evaluteWord(const word& l, bool& b, int& yesNoSet );
|
bool write(iOstream& os)const;
|
||||||
|
|
||||||
|
//// Static members
|
||||||
|
|
||||||
|
bool static evaluteWord(const word& l, bool& b, int& yesNoSet );
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -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)
|
pFlow::word pFlow::real2Fixed(const real & v, int32 numPrecision)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
@ -104,29 +127,6 @@ pFlow::word pFlow::real2FixedStripZeros(const real & v, int32 numPrecision)
|
||||||
return removeDecimalZeros(strVal);
|
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)
|
pFlow::word pFlow::angleBracketsNames(const word& w1, const word& w2)
|
||||||
{
|
{
|
||||||
|
@ -222,25 +222,6 @@ bool pFlow::validWordWithQuote(const word& w)
|
||||||
return true;
|
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)
|
bool pFlow::readUint32( const word& w, uint32 & val)
|
||||||
{
|
{
|
||||||
try{
|
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)
|
bool pFlow::readInt8( const char* buf, int8 & val)
|
||||||
{
|
{
|
||||||
word w(buf);
|
word w(buf);
|
||||||
return readInt8(w, val);
|
return readInt8(w, val);
|
||||||
}
|
}
|
||||||
#include <iostream>
|
|
||||||
|
//#include <iostream>
|
||||||
bool pFlow::readReal( const word& w, real & val)
|
bool pFlow::readReal( const word& w, real & val)
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
|
@ -364,7 +316,6 @@ bool pFlow::readReal( const char* buf, real & val )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,10 @@ Licence:
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
/*! \file bTypeFunctions.hpp
|
||||||
|
|
||||||
|
\brief Helper functions for built-in types.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef __bTypesFunctions_hpp__
|
#ifndef __bTypesFunctions_hpp__
|
||||||
#define __bTypesFunctions_hpp__
|
#define __bTypesFunctions_hpp__
|
||||||
|
@ -27,127 +31,132 @@ Licence:
|
||||||
#include "math.hpp"
|
#include "math.hpp"
|
||||||
|
|
||||||
|
|
||||||
// helper functions and constants for basic types
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/// Zero real variable
|
||||||
inline const real zero = 0.0;
|
inline const real zero = 0.0;
|
||||||
|
|
||||||
|
/// one real variable
|
||||||
inline const real one = 1.0;
|
inline const real one = 1.0;
|
||||||
|
|
||||||
|
/// zero int32 variable
|
||||||
inline const int32 zero32 = 0;
|
inline const int32 zero32 = 0;
|
||||||
|
|
||||||
|
/// one int32 variable
|
||||||
inline const int32 one32 = 1;
|
inline const int32 one32 = 1;
|
||||||
|
|
||||||
|
/// null/empty word
|
||||||
inline const word nullWord;
|
inline const word nullWord;
|
||||||
|
|
||||||
|
/// white space
|
||||||
inline const word whiteSpace(" \t\n\v\f\r");
|
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);
|
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);
|
int32 countChar(const char* s, const char c);
|
||||||
|
|
||||||
|
/// convert a word to all caps
|
||||||
word toUpper(const word & inStr);
|
word toUpper(const word & inStr);
|
||||||
|
|
||||||
|
/// Check if str equals "Yes", "Y", "True", "Ok", "ON", or "T"
|
||||||
bool isYes(const word & str);
|
bool isYes(const word & str);
|
||||||
|
|
||||||
|
/// Check if str equals "No", "N", "False", or "Off"
|
||||||
bool isNo(const word & str);
|
bool isNo(const word & str);
|
||||||
|
|
||||||
|
/// Convert floating point variable to string with fixed number of precisions
|
||||||
word real2Fixed(const real & v, int32 numPrecision = 6);
|
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 real2Word(const real & v, int32 numPrecision = 6);
|
||||||
|
|
||||||
word removeDecimalZeros(const word& str);
|
/// Convert int32 to word
|
||||||
|
|
||||||
word real2FixedStripZeros(const real & v, int32 numPrecision = 6);
|
|
||||||
|
|
||||||
word int322Word(const int32 & v);
|
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);
|
word angleBracketsNames(const word& w1, const word& w2);
|
||||||
|
|
||||||
|
/// Output base<w1,w2>
|
||||||
word angleBracketsNames2(const word& base, const word& w1, const word& 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);
|
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 = '.');
|
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 = '.');
|
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 = '.');
|
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);
|
bool validWord(char c);
|
||||||
|
|
||||||
|
/// Is c a valid character including quote?
|
||||||
bool validWordWithQuote(char c);
|
bool validWordWithQuote(char c);
|
||||||
|
|
||||||
|
/// Is a valid word?
|
||||||
bool validWord(const word& w);
|
bool validWord(const word& w);
|
||||||
|
|
||||||
|
/// Is a valid word with qoute?
|
||||||
bool validWordWithQuote(const word& c);
|
bool validWordWithQuote(const word& c);
|
||||||
|
|
||||||
|
/// Convert word to uint32
|
||||||
bool readLabel( const word& w, label & val);
|
|
||||||
|
|
||||||
|
|
||||||
bool readLabel( const char* buf, label & val);
|
|
||||||
|
|
||||||
|
|
||||||
bool readUint32( const word& w, uint32 & val);
|
bool readUint32( const word& w, uint32 & val);
|
||||||
|
|
||||||
|
/// Convert char string to uint32
|
||||||
bool readUint32( const char* buf, uint32 & val);
|
bool readUint32( const char* buf, uint32 & val);
|
||||||
|
|
||||||
|
/// Convert word to int64
|
||||||
bool readInt64( const word& w, int64 & val);
|
bool readInt64( const word& w, int64 & val);
|
||||||
|
|
||||||
|
/// Convert char string to int64
|
||||||
bool readInt64( const char* buf, int64 & val);
|
bool readInt64( const char* buf, int64 & val);
|
||||||
|
|
||||||
|
/// Convert word to int32
|
||||||
bool readInt32( const word& w, int32 & val);
|
bool readInt32( const word& w, int32 & val);
|
||||||
|
|
||||||
|
/// Convert char string to int32
|
||||||
bool readInt32( const char* buf, int32 & val);
|
bool readInt32( const char* buf, int32 & val);
|
||||||
|
|
||||||
|
|
||||||
bool readInt16( const word& w, int16 & val);
|
/// Convert word to int8
|
||||||
|
|
||||||
|
|
||||||
bool readInt16( const char* buf, int16 & val);
|
|
||||||
|
|
||||||
|
|
||||||
bool readInt8( const word& w, int8 & val);
|
bool readInt8( const word& w, int8 & val);
|
||||||
|
|
||||||
|
/// Convert char string to int8
|
||||||
bool readInt8( const char* buf, int8 & val);
|
bool readInt8( const char* buf, int8 & val);
|
||||||
|
|
||||||
|
/// Convert word to real
|
||||||
bool readReal( const word& w, real & val);
|
bool readReal( const word& w, real & val);
|
||||||
|
|
||||||
|
/// Convert char string to real
|
||||||
bool readReal( const char* buf, real & val );
|
bool readReal( const char* buf, real & val );
|
||||||
|
|
||||||
|
/// Convert word to bool
|
||||||
bool readBoolian_Str( const word& w, bool & val);
|
bool readBoolian_Str( const word& w, bool & val);
|
||||||
|
|
||||||
|
/// Convert char string to bool
|
||||||
bool readBoolian_Str( const char* buf, bool & val);
|
bool readBoolian_Str( const char* buf, bool & val);
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool readValue(const word& w, real& val)
|
bool readValue(const word& w, real& val)
|
||||||
{
|
{
|
||||||
return readReal(w,val);
|
return readReal(w,val);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
bool readValue(const word& w, label& val)
|
|
||||||
{
|
|
||||||
return readLabel(w,val);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool readValue(const word& w, uint32& val)
|
bool readValue(const word& w, uint32& val)
|
||||||
{
|
{
|
||||||
|
@ -166,11 +175,6 @@ bool readValue(const word& w, int32& val)
|
||||||
return readInt32(w,val);
|
return readInt32(w,val);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
bool readValue(const word& w, int16& val)
|
|
||||||
{
|
|
||||||
return readInt16(w,val);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool readValue(const word& w, int8& val)
|
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;
|
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;
|
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;
|
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;
|
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;
|
return s1 == s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD bool equal(const uint32& s1, const uint32& s2)
|
/// Are two words equal (host only)?
|
||||||
{
|
INLINE_FUNCTION
|
||||||
return s1 == s2;
|
bool equal(const word& s1, const word& 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)
|
|
||||||
{
|
{
|
||||||
return s1==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;
|
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;
|
return phi / Pi * 180.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,22 +48,22 @@ inline const bool usingDouble__ = false;
|
||||||
|
|
||||||
using int8 = signed char;
|
using int8 = signed char;
|
||||||
|
|
||||||
using int16 = short int;
|
|
||||||
|
|
||||||
using int32 = int;
|
using int32 = int;
|
||||||
|
|
||||||
using int64 = long long int;
|
using int64 = long long int;
|
||||||
|
|
||||||
using uint16 = unsigned short int ;
|
using uint8 = unsigned char ;
|
||||||
|
|
||||||
using uint32 = unsigned int;
|
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;
|
using word = std::string;
|
||||||
|
|
||||||
inline
|
inline
|
||||||
auto floatingPointDescription()
|
word floatingPointDescription()
|
||||||
{
|
{
|
||||||
return word("In this build, ") + word(floatingPointType__) +
|
return word("In this build, ") + word(floatingPointType__) +
|
||||||
word(" is used for floating point operations.");
|
word(" is used for floating point operations.");
|
||||||
|
|
|
@ -88,12 +88,12 @@ INLINE_FUNCTION_HD int32 mod(int32 x, int32 y)
|
||||||
return x%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;
|
return x%y;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD int32 mod(uint32 x, uint32 y)
|
INLINE_FUNCTION_HD auto mod(uint32 x, uint32 y)
|
||||||
{
|
{
|
||||||
return x%y;
|
return x%y;
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ INLINE_FUNCTION_HD int64 min(int64 x, int64 y)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD label min(label x, label y)
|
INLINE_FUNCTION_HD uint64 min(uint64 x, uint64 y)
|
||||||
{
|
{
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
return ::min(x, y);
|
return ::min(x, y);
|
||||||
|
@ -338,14 +338,7 @@ INLINE_FUNCTION_HD uint32 min(uint32 x, uint32 y)
|
||||||
#endif
|
#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)
|
INLINE_FUNCTION_HD real max(real x, real y)
|
||||||
{
|
{
|
||||||
|
@ -374,7 +367,7 @@ INLINE_FUNCTION_HD int32 max(int32 x, int32 y)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD label max(label x, label y)
|
INLINE_FUNCTION_HD uint64 max(uint64 x, uint64 y)
|
||||||
{
|
{
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
return ::max(x, y);
|
return ::max(x, y);
|
||||||
|
@ -393,15 +386,6 @@ INLINE_FUNCTION_HD uint32 max(uint32 x, uint32 y)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD uint32 max(uint16 x, uint16 y)
|
|
||||||
{
|
|
||||||
#ifdef __CUDACC__
|
|
||||||
return ::max(x, y);
|
|
||||||
#else
|
|
||||||
return std::max(x, y);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ Licence:
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef __triple_hpp__
|
#ifndef __triple_hpp__
|
||||||
#define __triple_hpp__
|
#define __triple_hpp__
|
||||||
|
|
||||||
|
@ -33,193 +32,201 @@ Licence:
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/// - Forward
|
||||||
template<typename T> class triple;
|
template<typename T> class triple;
|
||||||
|
|
||||||
|
|
||||||
#include "tripleFwd.hpp"
|
#include "tripleFwd.hpp"
|
||||||
|
|
||||||
|
/**
|
||||||
// for 3D vectors
|
* A set of 3 variables that can be used for vector variables.
|
||||||
// it should be used only for numeric types, real, unit
|
* The template parameter should be numeric type only.
|
||||||
|
*
|
||||||
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct triple
|
struct triple
|
||||||
{
|
{
|
||||||
// data members
|
/// data members
|
||||||
T x_;
|
T x_;
|
||||||
T y_;
|
T y_;
|
||||||
T z_;
|
T z_;
|
||||||
|
|
||||||
// initilizes to zero
|
//// Constructors
|
||||||
INLINE_FUNCTION_HD triple():
|
|
||||||
x_(0),
|
|
||||||
y_(0),
|
|
||||||
z_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// Constructors
|
/// Initilize to zero
|
||||||
INLINE_FUNCTION_HD triple(const T &x, const T &y, const T &z):
|
INLINE_FUNCTION_HD
|
||||||
x_(x),
|
triple():
|
||||||
y_(y),
|
x_(0),
|
||||||
z_(z)
|
y_(0),
|
||||||
{}
|
z_(0)
|
||||||
|
{}
|
||||||
INLINE_FUNCTION_HD triple(const T &v):
|
|
||||||
triple(v, v, v)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// type conversion trough assignment
|
|
||||||
template <typename T2>
|
|
||||||
INLINE_FUNCTION_HD triple<T> & operator = (const triple<T2> & rhs)
|
|
||||||
{
|
|
||||||
this->x_ = static_cast<T>(rhs.x_);
|
|
||||||
this->y_ = static_cast<T>(rhs.y_);
|
|
||||||
this->z_ = static_cast<T>(rhs.z_);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// type casting through copy constructor
|
|
||||||
template<typename T2>
|
|
||||||
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
|
|
||||||
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
|
|
||||||
INLINE_FUNCTION_HD
|
|
||||||
triple(triple<T>&& src) = default;
|
|
||||||
|
|
||||||
// copy assignment
|
|
||||||
INLINE_FUNCTION_HD
|
|
||||||
triple<T>& operator=(const triple<T>& src) = default;
|
|
||||||
|
|
||||||
// move assignment
|
|
||||||
INLINE_FUNCTION_HD
|
|
||||||
triple<T>& operator=(triple<T>&& src) = default;
|
|
||||||
|
|
||||||
// clone
|
|
||||||
INLINE_FUNCTION
|
|
||||||
uniquePtr<triple<T>> clone() const
|
|
||||||
{
|
|
||||||
return makeUnique<triple<T>>(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
INLINE_FUNCTION
|
|
||||||
triple<T>* clonePtr()const
|
|
||||||
{
|
|
||||||
return new triple<T>(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//// member methods
|
|
||||||
|
|
||||||
// access
|
|
||||||
INLINE_FUNCTION_HD T & x(){ return x_; }
|
|
||||||
INLINE_FUNCTION_HD const T & x()const { return x_; }
|
|
||||||
|
|
||||||
INLINE_FUNCTION_HD T & y(){ return y_; }
|
|
||||||
INLINE_FUNCTION_HD const T & y()const { return y_; }
|
|
||||||
|
|
||||||
INLINE_FUNCTION_HD T & z(){ return z_; }
|
|
||||||
INLINE_FUNCTION_HD const T & z()const { return z_; }
|
|
||||||
|
|
||||||
// methods
|
|
||||||
friend FUNCTION_HD T dot <T> (const triple<T> & oprnd1, const triple<T> & oprnd2);
|
|
||||||
|
|
||||||
friend FUNCTION_HD triple<T> cross <T>(const triple<T> & v1, const triple<T> & v2);
|
|
||||||
|
|
||||||
INLINE_FUNCTION_HD T length() const;
|
|
||||||
|
|
||||||
INLINE_FUNCTION_HD void normalize();
|
|
||||||
|
|
||||||
|
|
||||||
|
/// Construct from x, y, z
|
||||||
|
INLINE_FUNCTION_HD
|
||||||
|
triple(const T &x, const T &y, const T &z):
|
||||||
|
x_(x),
|
||||||
|
y_(y),
|
||||||
|
z_(z)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/// Construct from v
|
||||||
|
INLINE_FUNCTION_HD
|
||||||
|
triple(const T &v):
|
||||||
|
triple(v, v, v)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/// Type conversion trough assignment
|
||||||
|
template <typename T2>
|
||||||
|
INLINE_FUNCTION_HD triple<T> & operator = (const triple<T2> & rhs)
|
||||||
|
{
|
||||||
|
this->x_ = static_cast<T>(rhs.x_);
|
||||||
|
this->y_ = static_cast<T>(rhs.y_);
|
||||||
|
this->z_ = static_cast<T>(rhs.z_);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Type casting through copy constructor
|
||||||
|
template<typename T2>
|
||||||
|
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
|
||||||
|
INLINE_FUNCTION_HD
|
||||||
|
triple(const triple<T>& src) = default;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// Move construct
|
||||||
|
INLINE_FUNCTION_HD
|
||||||
|
triple(triple<T>&& src) = default;
|
||||||
|
|
||||||
|
/// copy assignment
|
||||||
|
INLINE_FUNCTION_HD
|
||||||
|
triple<T>& operator=(const triple<T>& src) = default;
|
||||||
|
|
||||||
|
/// move assignment
|
||||||
|
INLINE_FUNCTION_HD
|
||||||
|
triple<T>& operator=(triple<T>&& src) = default;
|
||||||
|
|
||||||
|
/// clone
|
||||||
|
INLINE_FUNCTION
|
||||||
|
uniquePtr<triple<T>> clone() const
|
||||||
|
{
|
||||||
|
return makeUnique<triple<T>>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
INLINE_FUNCTION
|
||||||
|
triple<T>* clonePtr()const
|
||||||
|
{
|
||||||
|
return new triple<T>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
////// member methods
|
||||||
|
|
||||||
|
/// 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
|
||||||
|
|
||||||
|
/// 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
|
//// 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 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 triple<T> & oprnd1, const T & oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD triple<T> operator+ <T> (const T & oprnd1, const triple<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 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 triple<T> & oprnd1, const T & oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD triple<T> operator - <T> (const T & oprnd1, const triple<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 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 triple<T> & oprnd1, const T & oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD triple<T> operator * <T> (const T & oprnd1, const triple<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 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 triple<T> & oprnd1, const T & oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD triple<T> operator / <T> (const T & oprnd1, const triple<T> & oprnd2);
|
friend FUNCTION_HD triple<T> operator / <T> (const T & oprnd1, const triple<T> & oprnd2);
|
||||||
|
|
||||||
|
|
||||||
INLINE_FUNCTION_HD void operator+= (const triple & oprnd2);
|
INLINE_FUNCTION_HD void operator+= (const triple & oprnd2);
|
||||||
|
|
||||||
INLINE_FUNCTION_HD void operator-= (const triple & oprnd2);
|
INLINE_FUNCTION_HD void operator-= (const triple & oprnd2);
|
||||||
|
|
||||||
INLINE_FUNCTION_HD void operator*= (const triple & oprnd2);
|
INLINE_FUNCTION_HD void operator*= (const triple & oprnd2);
|
||||||
|
|
||||||
INLINE_FUNCTION_HD void operator/= (const triple & oprnd2);
|
INLINE_FUNCTION_HD void operator/= (const triple & oprnd2);
|
||||||
|
|
||||||
|
|
||||||
// unary negate operator
|
/// unary negate operator
|
||||||
INLINE_FUNCTION_HD triple operator- ()const;
|
INLINE_FUNCTION_HD triple operator- ()const;
|
||||||
|
|
||||||
// unary plus operator
|
/// unary plus operator
|
||||||
INLINE_FUNCTION_HD triple operator+ ()const;
|
INLINE_FUNCTION_HD triple operator+ ()const;
|
||||||
|
|
||||||
|
|
||||||
friend FUNCTION_HD bool operator == <T> (const triple<T> &opr1, const triple<T> &opr2);
|
friend FUNCTION_HD bool operator == <T> (const triple<T> &opr1, const triple<T> &opr2);
|
||||||
|
|
||||||
friend FUNCTION_HD bool operator < <T> (const triple<T> &opr1, const triple<T> &opr2);
|
friend FUNCTION_HD bool operator < <T> (const triple<T> &opr1, const triple<T> &opr2);
|
||||||
|
|
||||||
friend FUNCTION_HD bool operator > <T> (const triple<T> &opr1, const triple<T> &opr2);
|
friend FUNCTION_HD bool operator > <T> (const triple<T> &opr1, const triple<T> &opr2);
|
||||||
|
|
||||||
friend FUNCTION_HD bool operator >= <T> (const triple<T> &opr1, const triple<T> &opr2);
|
friend FUNCTION_HD bool operator >= <T> (const triple<T> &opr1, const triple<T> &opr2);
|
||||||
|
|
||||||
friend FUNCTION_HD bool operator <= <T> (const triple<T> &opr1, const triple<T> &opr2);
|
friend FUNCTION_HD bool operator <= <T> (const triple<T> &opr1, const triple<T> &opr2);
|
||||||
|
|
||||||
// << operator
|
//// IO operators
|
||||||
friend iOstream& operator<< <T> (iOstream& str, const triple<T> & ov);
|
|
||||||
|
|
||||||
// >> operator
|
/// << operator
|
||||||
friend iIstream& operator >> <T> (iIstream & str, triple<T> & iv);
|
friend iOstream& operator<< <T> (iOstream& str, const triple<T> & ov);
|
||||||
|
|
||||||
// same as >> operator, but faster, good for mass read
|
/// >> operator
|
||||||
friend void readIstream <T>( iIstream& str, triple<T> &iv);
|
friend iIstream& operator >> <T> (iIstream & str, triple<T> & iv);
|
||||||
|
|
||||||
|
/// 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 );
|
bool INLINE_FUNCTION_HD equal( const triple<T>& opr1, const triple<T>& opr2 );
|
||||||
|
|
||||||
|
|
||||||
} // end of pFlow
|
} /// end of pFlow
|
||||||
|
|
||||||
#include "tripleI.hpp"
|
#include "tripleI.hpp"
|
||||||
#include "tripleMath.hpp"
|
#include "tripleMath.hpp"
|
||||||
|
|
|
@ -25,15 +25,11 @@ namespace pFlow
|
||||||
|
|
||||||
const realx3 zero3(0.0);
|
const realx3 zero3(0.0);
|
||||||
const realx3 one3(1.0);
|
const realx3 one3(1.0);
|
||||||
const uint32x3 zeroU3(0);
|
|
||||||
const uint32x3 oneU3(1);
|
|
||||||
|
|
||||||
const realx3x3 zero33(zero3);
|
const realx3x3 zero33(zero3);
|
||||||
const realx3x3 one33(one3);
|
const realx3x3 one33(one3);
|
||||||
const uint32x3x3 zeroU33(zeroU3);
|
|
||||||
const uint32x3x3 oneU33(oneU3);
|
|
||||||
|
|
||||||
const real4 zero4(zero);
|
const realx4 zero4(zero);
|
||||||
|
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
|
@ -37,31 +37,23 @@ namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
using int8x3 = triple<int8>;
|
using int8x3 = triple<int8>;
|
||||||
using int16x3 = triple<int16>;
|
|
||||||
using int32x3 = triple<int32>;
|
using int32x3 = triple<int32>;
|
||||||
using int64x3 = triple<int64>;
|
using int64x3 = triple<int64>;
|
||||||
using uint16x3 = triple<uint16>;
|
using uint8x3 = triple<uint8>;
|
||||||
using uint32x3 = triple<uint32>;
|
using uint32x3 = triple<uint32>;
|
||||||
using int32x3 = triple<int32>;
|
using uint64x3 = triple<uint64>;
|
||||||
using int64x3 = triple<int64>;
|
|
||||||
using labelx3 = triple<label>;
|
|
||||||
using realx3 = triple<real>;
|
using realx3 = triple<real>;
|
||||||
|
|
||||||
using uint16x3x3= triple<uint16x3>;
|
|
||||||
using uint32x3x3= triple<uint32x3>;
|
|
||||||
using int32x3x3 = triple<int32x3>;
|
using int32x3x3 = triple<int32x3>;
|
||||||
using labelx3x3 = triple<labelx3>;
|
using uint32x3x3= triple<uint32x3>;
|
||||||
using realx3x3 = triple<realx3>;
|
using realx3x3 = triple<realx3>;
|
||||||
|
|
||||||
using real4 = quadruple<real>;
|
using realx4 = quadruple<real>;
|
||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<int8x3>(){ return "int8x3"; }
|
inline word basicTypeName<int8x3>(){ return "int8x3"; }
|
||||||
|
|
||||||
template<>
|
|
||||||
inline word basicTypeName<int16x3>(){ return "int16x3"; }
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<int32x3>(){ return "int32x3"; }
|
inline word basicTypeName<int32x3>(){ return "int32x3"; }
|
||||||
|
|
||||||
|
@ -69,19 +61,19 @@ template<>
|
||||||
inline word basicTypeName<int64x3>(){ return "int64x3"; }
|
inline word basicTypeName<int64x3>(){ return "int64x3"; }
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<uint16x3>(){ return "uint16x3"; }
|
inline word basicTypeName<uint8x3>(){ return "uint8x3"; }
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<uint32x3>(){ return "uint32x3"; }
|
inline word basicTypeName<uint32x3>(){ return "uint32x3"; }
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<labelx3>(){ return "labelx3"; }
|
inline word basicTypeName<uint64x3>(){ return "unit64x3"; }
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<realx3>(){ return "realx3"; }
|
inline word basicTypeName<realx3>(){ return "realx3"; }
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<uint16x3x3>(){ return "uint16x3x3"; }
|
inline word basicTypeName<int32x3x3>(){ return "int32x3x3"; }
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<uint32x3x3>(){ return "uint32x3x3"; }
|
inline word basicTypeName<uint32x3x3>(){ return "uint32x3x3"; }
|
||||||
|
@ -91,20 +83,17 @@ inline word basicTypeName<realx3x3>(){ return "realx3x3"; }
|
||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<real4>(){ return "real4"; }
|
inline word basicTypeName<realx4>(){ return "realx4"; }
|
||||||
|
|
||||||
|
|
||||||
extern const realx3 zero3;
|
extern const realx3 zero3;
|
||||||
extern const realx3 one3;
|
extern const realx3 one3;
|
||||||
extern const uint32x3 zeroU3;
|
|
||||||
extern const uint32x3 oneU3;
|
|
||||||
|
|
||||||
extern const realx3x3 zero33;
|
extern const realx3x3 zero33;
|
||||||
extern const realx3x3 one33;
|
extern const realx3x3 one33;
|
||||||
extern const uint32x3x3 zeroU33;
|
|
||||||
extern const uint32x3x3 oneU33;
|
|
||||||
|
|
||||||
|
|
||||||
|
extern const realx4 zero4;
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue