some cleanup

This commit is contained in:
HRN 2025-01-31 01:06:16 +03:30
parent f98a696fc8
commit af2572331d
10 changed files with 112 additions and 223 deletions

View File

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

View File

@ -26,11 +26,15 @@ Licence:
namespace pFlow {
///
/// @class span
/// @brief Represents a view into a contiguous sequence of elements.
///
/// `span` provides a lightweight way to work with arrays and other contiguous
/// sequences without the overhead of copying. This will word on both GPU and CPU
template<typename T>
class span
{
public:
using iterator = T*;
@ -47,39 +51,40 @@ public:
using constPointer = const T*;
protected:
private:
T* data_ = nullptr;
mutable T* data_ = nullptr;
uint32 size_ = 0;
index size_ = 0;
public:
TypeInfoTemplateNV11("span", T);
/// Constructor
/// Constructor with no arguments
INLINE_FUNCTION_HD
span() = default;
/// Constructor that takes a pointer to the beginning of the data and the size of the span
INLINE_FUNCTION_HD
span(T* data, uint32 size)
: data_(data), size_(size)
{}
/// copy
/// copy constructor
INLINE_FUNCTION_HD
span(const span&) = default;
/// assignment
/// copy assignment operator
INLINE_FUNCTION_HD
span& operator=(const span&) = default;
/// move
/// move constructor
INLINE_FUNCTION_HD
span(span&&) = default;
/// assignment
/// move assignment operator
INLINE_FUNCTION_HD
span& operator=(span&) = default;
@ -90,6 +95,7 @@ public:
return size_ == 0;
}
/// Returns a pointer to the beginning of the data
INLINE_FUNCTION_HD
T* data() const
{
@ -98,7 +104,7 @@ public:
/// Returns the number of elements in the span
INLINE_FUNCTION_HD
uint32 size() const
index size() const
{
return size_;
}
@ -110,7 +116,7 @@ public:
return data_;
}
/// Returns an iterator to the beginning of the span
/// Returns an iterator to the beginning of the span (const version)
INLINE_FUNCTION_HD
constIterator cbegin() const
{
@ -124,54 +130,34 @@ public:
return data_ + size_;
}
/// Returns an iterator to one past the end of the span
/// Returns an iterator to one past the end of the span (const version)
INLINE_FUNCTION_HD
constIterator cend() const
{
return data_ + size_;
}
/// Returns a reference to the element at the specified index
INLINE_FUNCTION_HD
T& operator[](uint32 i)
T& operator[](index i)
{
return data_[i];
}
/// Returns a const reference to the element at the specified index
INLINE_FUNCTION_HD
const T& operator[](uint32 i)const
{
return data_[i];
}
INLINE_FUNCTION_HD
T& operator[](int32 i)
{
return data_[i];
}
INLINE_FUNCTION_HD
const T& operator[](int32 i)const
T& operator[](index i)const
{
return data_[i];
}
};
/*template<typename T, typename... properties, template<class, class...> class Container>
size_t makeSpan(Container<T, properties...>& container)
{
return span<T>(container.data(), container.size());
}
template<typename T, typename... properties, template<class, class...> class Container>
size_t makeSpan(const Container<T, properties...>& container)
{
return span<T>(
const_cast<T*>(container.data()),
container.size());
}*/
/// Creates a span of char from a span of any type.
///
/// This helper function reinterprets the underlying memory of the given span
/// as a span of char.
template<typename T>
inline
span<char> charSpan(span<T> s)
@ -182,6 +168,10 @@ span<char> charSpan(span<T> s)
s.size()*el);
}
/// Creates a span of const char from a span of const any type.
///
/// This helper function reinterprets the underlying memory of the given span
/// as a span of const char.
template<typename T>
inline
span<const char> charSpan(span<const T> s)
@ -192,24 +182,6 @@ span<const char> charSpan(span<const T> s)
s.size()*el);
}
/*template<typename T, template<class> class Container>
span<T> makeSpan(Container<T>& container)
{
return span<T>(container.data(), container.size());
}
template<typename T, template<class> class Container>
span<T> makeSpan(const Container<T>& container)
{
return span<T>(
const_cast<T*>(container.data()),
container.size());
}*/
} // pFlow

View File

@ -32,41 +32,35 @@ Licence:
static pFlow::Ostream& errorStream = pFlow::pOutput;
pFlow::iOstream&
fatalErrorMessage(const char* fileName, int linNumber)
pFlow::fatalErrorMessage(const char* fileName, int lineNumber)
{
errorStream << "\n>>> Fatal error in phasicFlow\n"
<< "Error occured in source file " << Red_Text(fileName)
<< " at line " << Red_Text(linNumber) << '\n';
errorStream << "\nError occured in file ("<<lineNumber<<"):" <<Red_Text(fileName)<<'\n';
return errorStream;
}
pFlow::iOstream&
fatalErrorInMessage(const char* fnName, const char* fileName, int linNumber)
pFlow::fatalErrorInMessage(const char* fnName, const char* fileName, int lineNumber)
{
errorStream << "\n>>> Fatal error in phasicFlow\n"
<< " Error is issued in function " << Red_Text(fnName)
<< ", located in file " << Red_Text(fileName) << " at line "
<< Red_Text(linNumber) << '\n';
errorStream << "\nError occured in file ("<<lineNumber<<"):" <<Red_Text(fileName)<<'\n'<<
"Function: "<<Red_Text(fnName)<<'\n';
return errorStream;
}
pFlow::iOstream&
notImplementedErrorMessage(
pFlow::notImplementedErrorMessage(
const char* fnName,
const char* fileName,
int lineNumber
)
{
errorStream << "\n>>> Fatal error in phasicFlow\n";
errorStream << " Function " << Red_Text(fnName)
errorStream << "\n Function " << Yellow_Text(fnName)
<< " has not been implemented yet!\n"
<< " File " << Yellow_Text(fileName) << " at line "
<< Yellow_Text(lineNumber) << '\n';
<< " Look into file ("<<lineNumber<<"):" <<fileName<<'\n';
return errorStream;
}
pFlow::iOstream&
ioErrorMessage(
pFlow::ioErrorMessage(
const char* fileName,
int fileLineNumber,
const char* fnName,
@ -84,7 +78,7 @@ ioErrorMessage(
}
pFlow::iOstream&
ioErrorMessage(
pFlow::ioErrorMessage(
const pFlow::word& fileName,
int fileLineNumber,
const char* fnName,
@ -98,7 +92,7 @@ ioErrorMessage(
}
pFlow::iOstream&
warningMessage(const char* fnName, const char* fileName, int linNumber)
pFlow::warningMessage(const char* fnName, const char* fileName, int linNumber)
{
errorStream << "\n>>> Warning in phasicFlow\n"
<< " Warning is issued in function " << Yellow_Text(fnName)
@ -108,7 +102,7 @@ warningMessage(const char* fnName, const char* fileName, int linNumber)
}
pFlow::iOstream&
reportAndExit(int errorCode)
pFlow::reportAndExit(int errorCode)
{
errorStream << "\n>>> phasicFlow is exiting . . ." << pFlow::endl;
fatalExitPhasicFlow(errorCode);
@ -116,7 +110,7 @@ reportAndExit(int errorCode)
}
int
fatalExitPhasicFlow(int errorCode)
pFlow::fatalExitPhasicFlow(int errorCode)
{
// Kokkos should be finalized first
Kokkos::finalize();

View File

@ -27,7 +27,7 @@ Licence:
namespace pFlow
{
class iOstream;
}
//- Decleartions
@ -66,35 +66,37 @@ warningMessage(const char* fnName, const char* fileName, int linNumber);
pFlow::iOstream&
reportAndExit(int errorCode = EXIT_FAILURE);
}
/// Report a fatal error and exit the applicaiton
#define fatalError fatalErrorMessage(__FILE__, __LINE__)
#define fatalError pFlow::fatalErrorMessage(__FILE__, __LINE__)
/// Report a fatal error and supplied function name and exit the application
#define fatalErrorIn(functionName) \
fatalErrorInMessage((functionName), __FILE__, __LINE__)
pFlow::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__)
pFlow::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__)
pFlow::ioErrorMessage(fileName, lineNumber, FUNCTION_NAME, __FILE__, __LINE__)
/// Report a warning with supplied function name
#define warningIn(functionName) \
warningMessage((functionName), __FILE__, __LINE__)
pFlow::warningMessage((functionName), __FILE__, __LINE__)
/// Report a warning
#define warningInFunction warningIn(FUNCTION_NAME)
/// Fatal exit
#define fatalExit reportAndExit()
#define fatalExit pFlow::reportAndExit()
#endif

View File

@ -60,7 +60,7 @@ private:
fileSystem localPath_ = "";
/// Number of bytes used for writing/reading real variable (used for binray)
int numBytesForReal_ = numBytesForReal__;
int numBytesForReal_ = sizeof(real);
/// Does the objectFile read & write the header?
bool readWriteHeader_ = true;

View File

@ -277,7 +277,7 @@ equal(const uint32& s1, const uint32& s2)
}
/// Are two words equal (host only)?
INLINE_FUNCTION
inline
bool
equal(const word& s1, const word& s2)
{

View File

@ -29,17 +29,19 @@ namespace pFlow
{
#ifdef pFlow_Build_Double
#define useDouble 1
#define UseDouble 1
inline const char* floatingPointType__ = "double";
inline const bool usingDouble__ = true;
#else
#define useDouble 0
#define UseDouble 0
inline const char* floatingPointType__ = "float";
inline const bool usingDouble__ = false;
#endif
// scalars
#if useDouble
#if UseDouble
using real = double;
#else
using real = float;
@ -57,21 +59,27 @@ using uint32 = unsigned int;
using uint64 = unsigned long long int;
using id_t = uint32;
using size_t = std::size_t;
using word = std::string;
using timeValue = double;
inline const int numBytesForReal__ = sizeof(real);
#ifdef pFlow_Build_Index64
#define Index64 1
using index = std::size_t;
inline const char* IndexType__ = "std::size_t";
#else
#define Index64 0
using index = uint32;
inline const char* IndexType__ = "uint32";
#endif
inline word
floatingPointDescription()
{
return word("In this build, ") + word(floatingPointType__) +
word(" is used for floating point operations.");
word(" is used for floating point operations and ") +
IndexType__ + "for indexing.";
}
} // end of pFlow

View File

@ -114,13 +114,13 @@ struct triple
triple<T>& operator=(triple<T>&& src) = default;
/// clone
INLINE_FUNCTION
inline
uniquePtr<triple<T>> clone() const
{
return makeUnique<triple<T>>(*this);
}
INLINE_FUNCTION
inline
triple<T>* clonePtr() const
{
return new triple<T>(*this);

View File

@ -103,13 +103,13 @@ INLINE_FUNCTION_HD bool
operator>=(const triple<T>& opr1, const triple<T>& opr2);
template<typename T>
INLINE_FUNCTION iOstream&
inline iOstream&
operator<<(iOstream& str, const triple<T>& ov);
template<typename T>
INLINE_FUNCTION iIstream&
inline iIstream&
operator>>(iIstream& str, triple<T>& iv);
template<typename T>
INLINE_FUNCTION void
inline void
readIstream(iIstream& str, triple<T>& iv);

View File

@ -287,7 +287,7 @@ pFlow::operator>=(const triple<T>& opr1, const triple<T>& opr2)
}
template<typename T>
INLINE_FUNCTION pFlow::iOstream&
inline pFlow::iOstream&
pFlow::operator<<(iOstream& str, const triple<T>& ov)
{
str << token::BEGIN_LIST << ov.x_ << token::SPACE << ov.y_ << token::SPACE
@ -299,7 +299,7 @@ INLINE_FUNCTION pFlow::iOstream&
}
template<typename T>
INLINE_FUNCTION pFlow::iIstream&
inline pFlow::iIstream&
pFlow::operator>>(iIstream& str, triple<T>& iv)
{
str.readBegin("triple<T>");
@ -316,7 +316,7 @@ INLINE_FUNCTION pFlow::iIstream&
}
template<typename T>
INLINE_FUNCTION void
inline void
pFlow::readIstream(iIstream& str, triple<T>& iv)
{
str.readBegin("triple<T>");