Compare commits
No commits in common. "5fee39cdd8a551c8fcac9a634791462500650365" and "892f5395bc1c50775494bfcca570e09bcd7523c9" have entirely different histories.
5fee39cdd8
...
892f5395bc
|
@ -1,231 +0,0 @@
|
||||||
# PhasicFlow Coding Style Guidelines
|
|
||||||
This document outlines the coding style guidelines for the PhasicFlow codebase.
|
|
||||||
Adhering to these guidelines ensures consistency, readability, and maintainability of the project.
|
|
||||||
## 1. FormattingIndentation:
|
|
||||||
* Use 4 spaces for every logical level and block.
|
|
||||||
* Line Spacing: Leave two empty lines between sections (e.g., between functions in a .cpp file, between class members).
|
|
||||||
|
|
||||||
## 2. Naming ConventionsGeneral Naming:
|
|
||||||
* All names should start with lowercase letters, except for special names (e.g., Ergun, Hertz).
|
|
||||||
* Macro names start with Upper case or all the letters are in UPPER case.
|
|
||||||
* Compound Names: For compound names, the first word starts with a lowercase letter, and subsequent words start with an uppercase letter (e.g., boundaryBase, motionModel).
|
|
||||||
|
|
||||||
## 3. File Structure
|
|
||||||
* Header Files: Use the .hpp extension for header files.
|
|
||||||
* Source Files: Use the .cpp extension for source files.
|
|
||||||
* Header and Source File Headers: All header and source files must include a standardized header that describes the project's intention and licensing information.
|
|
||||||
* File Naming: Header and source file names should correspond to the class they contain. Aim for one class per file.
|
|
||||||
* Inline Functions: Place inline functions in a separate classNameI.hpp file to avoid cluttering the main header file.
|
|
||||||
|
|
||||||
## 4. Class DesignClass Member Order:
|
|
||||||
* Private members and methods
|
|
||||||
* Private static members and methods
|
|
||||||
* Public methods
|
|
||||||
* Public static methods
|
|
||||||
* Enumerations and Nested Classes: Declare enumerations and nested classes before all class members and methods.
|
|
||||||
* Special Functions: Each class must explicitly define all special functions:Constructor, Copy constructor and assignment operator, Move constructor and assignment operator
|
|
||||||
* Destructor: Each class must have an explicit destructor declaration:`~className() = default`; or `~className();`
|
|
||||||
* Interface classes or classes with virtual methods must have a virtual destructor.
|
|
||||||
* Virtual Method Overrides: When implementing a `virtual` method from a base class in a derived class, use the `override` keyword. The same applies to derived class destructors.
|
|
||||||
## 5. NamespacesOfficial Namespace:
|
|
||||||
The official namespace for the codebase is pFlow. All entities should be defined within this namespace.
|
|
||||||
|
|
||||||
### Example File Structure
|
|
||||||
```
|
|
||||||
src/
|
|
||||||
├── componentName1/
|
|
||||||
│ ├── componentName1.hpp
|
|
||||||
│ ├── componentName1.cpp
|
|
||||||
│ ├── componentName1I.hpp
|
|
||||||
│ └── ...
|
|
||||||
└── componentName2/
|
|
||||||
├── componentName2.hpp
|
|
||||||
├── componentName2.cpp
|
|
||||||
└── ...
|
|
||||||
```
|
|
||||||
### Example Class Structure
|
|
||||||
```C++
|
|
||||||
namespace pFlow
|
|
||||||
{
|
|
||||||
|
|
||||||
class MyClass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum class MyEnum
|
|
||||||
{
|
|
||||||
Value1,
|
|
||||||
Value2
|
|
||||||
};
|
|
||||||
|
|
||||||
class NestedClass
|
|
||||||
{
|
|
||||||
// ...
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
int privateMember_;
|
|
||||||
|
|
||||||
void privateMethod();
|
|
||||||
|
|
||||||
|
|
||||||
static int privateStaticMember_;
|
|
||||||
|
|
||||||
static void privateStaticMethod();
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
MyClass();
|
|
||||||
|
|
||||||
MyClass(const MyClass& other);
|
|
||||||
|
|
||||||
MyClass(MyClass&& other);
|
|
||||||
|
|
||||||
MyClass& operator=(const MyClass& other);
|
|
||||||
|
|
||||||
MyClass& operator=(MyClass&& other);
|
|
||||||
|
|
||||||
~MyClass();
|
|
||||||
|
|
||||||
|
|
||||||
void publicMethod();
|
|
||||||
|
|
||||||
static void publicStaticMethod();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// assuming base class has virtual methods
|
|
||||||
class DerivedClass
|
|
||||||
:
|
|
||||||
public BaseClass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
~DerivedClass() override;
|
|
||||||
|
|
||||||
void virtualMethod() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace pFlow
|
|
||||||
```
|
|
||||||
|
|
||||||
## 6. Doxygen Documentation
|
|
||||||
|
|
||||||
### 6.1. Ruls
|
|
||||||
provide the documentations in the header files only. In rare cases where you are generating documentations for executables, the doxygen documentation can be supplied in the .cpp file.
|
|
||||||
|
|
||||||
* **General Doxygen Style:**
|
|
||||||
|
|
||||||
* Use `///` for short documentations for methods and members.
|
|
||||||
|
|
||||||
* Use `/** */` for classes and main methods which play a significant role in the class or code.
|
|
||||||
|
|
||||||
* Place Doxygen comments *before* the declaration of the entity being documented (e.g., class, function, variable).
|
|
||||||
|
|
||||||
* Use `@param` to document function parameters, `@return` for return values, `@brief` for a short description, and `@details` for a more in-depth explanation.
|
|
||||||
|
|
||||||
* Use Markdown syntax within Doxygen comments for formatting.
|
|
||||||
|
|
||||||
* **File Headers:** Each file should contain a Doxygen comment at the top, including:
|
|
||||||
|
|
||||||
* `@file` : The name of the file.
|
|
||||||
|
|
||||||
* `@brief`: A brief description of the file's purpose.
|
|
||||||
|
|
||||||
* `@author`: The author(s) of the file.
|
|
||||||
|
|
||||||
* `@date` : The date of creation or last modification.
|
|
||||||
|
|
||||||
* **Class Documentation:**
|
|
||||||
|
|
||||||
* Use `/** */` for class documentation.
|
|
||||||
|
|
||||||
* Provide a `@brief` description of the class.
|
|
||||||
|
|
||||||
* Use `@tparam` to document template parameters.
|
|
||||||
|
|
||||||
* Document the purpose of the class, its invariants, and how it should be used.
|
|
||||||
|
|
||||||
* **Function/Method Documentation:**
|
|
||||||
|
|
||||||
* Use `///` for short documentations.
|
|
||||||
|
|
||||||
* Use `/** */` for main methods which play a significant role.
|
|
||||||
|
|
||||||
* Provide a `@brief` description of the function.
|
|
||||||
|
|
||||||
* Use `@param` to describe each parameter, including its purpose and whether it is an input, output, or input/output parameter.
|
|
||||||
|
|
||||||
* Use `@return` to describe the return value, including its meaning and possible values.
|
|
||||||
|
|
||||||
* Use `@pre` to document any preconditions that must be met before calling the function.
|
|
||||||
|
|
||||||
* Use `@post` to document any postconditions that will be true after the function returns.
|
|
||||||
|
|
||||||
* Use `@throws` to document any exceptions that the function may throw.
|
|
||||||
|
|
||||||
* Use `@details` for a more detailed explanation of the function's behavior, algorithms, or any other relevant information.
|
|
||||||
|
|
||||||
* **Variable Documentation:**
|
|
||||||
|
|
||||||
* Use `///<` for single-line documentation of variables.
|
|
||||||
|
|
||||||
### 6.2. Doxygen Documentation Examples
|
|
||||||
|
|
||||||
* **Class example**
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
/**
|
|
||||||
* @brief Represents a particle in the simulation.
|
|
||||||
* @details This class stores the position, velocity, and other physical
|
|
||||||
* properties of a particle.
|
|
||||||
*/
|
|
||||||
class Particle
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
Point position_; ///< The current position of the particle.
|
|
||||||
|
|
||||||
Vector velocity_; ///< The current velocity of the particle.
|
|
||||||
|
|
||||||
double mass_; ///< The mass of the particle.
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Constructs a particle with default values.
|
|
||||||
Particle();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Updates the position of the particle based on its velocity
|
|
||||||
* and the given time step.
|
|
||||||
* @param deltaTime The time elapsed since the last update, in seconds.
|
|
||||||
*/
|
|
||||||
void updatePosition(const timeInfo& ti );
|
|
||||||
|
|
||||||
/// Gets the current position of the particle.
|
|
||||||
Point getPosition() const;
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
* **Function Example**
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
/**
|
|
||||||
* @brief Calculates the distance between two points.
|
|
||||||
* @param p1 The first point.
|
|
||||||
* @param p2 The second point.
|
|
||||||
* @return The distance between the two points.
|
|
||||||
*/
|
|
||||||
double calculateDistance(const Point& p1, const Point& p2)
|
|
||||||
{
|
|
||||||
// Implementation
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the velocity of the particle.
|
|
||||||
Vector getVelocity() const
|
|
||||||
{
|
|
||||||
return velocity_;
|
|
||||||
}
|
|
||||||
```
|
|
|
@ -21,6 +21,7 @@ Licence:
|
||||||
template<typename MotionModel>
|
template<typename MotionModel>
|
||||||
bool pFlow::geometryMotion<MotionModel>::findMotionIndex()
|
bool pFlow::geometryMotion<MotionModel>::findMotionIndex()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(motionComponentName().size() != numSurfaces() )
|
if(motionComponentName().size() != numSurfaces() )
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
|
|
|
@ -28,4 +28,4 @@ template class pFlow::geometryMotion<pFlow::stationaryWall>;
|
||||||
|
|
||||||
template class pFlow::geometryMotion<pFlow::conveyorBeltMotion>;
|
template class pFlow::geometryMotion<pFlow::conveyorBeltMotion>;
|
||||||
|
|
||||||
template class pFlow::geometryMotion<pFlow::multiRotatingAxisMotion>;
|
//template class pFlow::geometryMotion<pFlow::multiRotatingAxisMotion>;
|
||||||
|
|
|
@ -25,7 +25,7 @@ Licence:
|
||||||
#include "stationaryWall.hpp"
|
#include "stationaryWall.hpp"
|
||||||
#include "rotatingAxisMotion.hpp"
|
#include "rotatingAxisMotion.hpp"
|
||||||
#include "conveyorBeltMotion.hpp"
|
#include "conveyorBeltMotion.hpp"
|
||||||
#include "multiRotatingAxisMotion.hpp"
|
//#include "multiRotatingAxisMotion.hpp"
|
||||||
#include "vibratingMotion.hpp"
|
#include "vibratingMotion.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,10 @@ using stationaryGeometry = geometryMotion<stationaryWall>;
|
||||||
|
|
||||||
using conveyorBeltMotionGeometry = geometryMotion<conveyorBeltMotion>;
|
using conveyorBeltMotionGeometry = geometryMotion<conveyorBeltMotion>;
|
||||||
|
|
||||||
using multiRotationAxisMotionGeometry = geometryMotion<multiRotatingAxisMotion>;
|
//typedef geometryMotion<multiRotatingAxisMotion> multiRotationAxisMotionGeometry;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,7 +193,7 @@ public:
|
||||||
|
|
||||||
if( capacity+1 > flags_.size() )
|
if( capacity+1 > flags_.size() )
|
||||||
{
|
{
|
||||||
reallocInit(flags_, capacity+1);
|
reallocNoInit(flags_, capacity+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill the flags
|
// fill the flags
|
||||||
|
@ -219,7 +219,7 @@ public:
|
||||||
{
|
{
|
||||||
// get more space to prevent reallocations in next iterations
|
// get more space to prevent reallocations in next iterations
|
||||||
uint32 len = size_*1.1+1;
|
uint32 len = size_*1.1+1;
|
||||||
reallocInit(sortedPairs_, len);
|
reallocNoInit(sortedPairs_, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
Kokkos::parallel_for(
|
Kokkos::parallel_for(
|
||||||
|
@ -231,7 +231,6 @@ public:
|
||||||
// - sort paris based on the first and second
|
// - sort paris based on the first and second
|
||||||
sort(sortedPairs_, 0, size_ );
|
sort(sortedPairs_, 0, size_ );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,5 +58,5 @@ createInteraction(pFlow::cfModels::limitedNonLinearModNormalRolling, pFlow::conv
|
||||||
createInteraction(pFlow::cfModels::nonLimitedNonLinearModNormalRolling,pFlow::conveyorBeltMotionGeometry);
|
createInteraction(pFlow::cfModels::nonLimitedNonLinearModNormalRolling,pFlow::conveyorBeltMotionGeometry);
|
||||||
|
|
||||||
// multiRotationAxisMotionGeometry
|
// multiRotationAxisMotionGeometry
|
||||||
createInteraction(pFlow::cfModels::limitedNonLinearModNormalRolling, pFlow::multiRotationAxisMotionGeometry);
|
//createInteraction(pFlow::cfModels::limitedNonLinearModNormalRolling, pFlow::multiRotationAxisMotionGeometry);
|
||||||
createInteraction(pFlow::cfModels::nonLimitedNonLinearModNormalRolling,pFlow::multiRotationAxisMotionGeometry);
|
//createInteraction(pFlow::cfModels::nonLimitedNonLinearModNormalRolling,pFlow::multiRotationAxisMotionGeometry);
|
||||||
|
|
|
@ -14,8 +14,8 @@ entities/stationary/stationary.cpp
|
||||||
conveyorBeltMotion/conveyorBeltMotion.cpp
|
conveyorBeltMotion/conveyorBeltMotion.cpp
|
||||||
entities/conveyorBelt/conveyorBelt.cpp
|
entities/conveyorBelt/conveyorBelt.cpp
|
||||||
|
|
||||||
entities/multiRotatingAxis/multiRotatingAxis.cpp
|
#entities/multiRotatingAxis/multiRotatingAxis.cpp
|
||||||
multiRotatingAxisMotion/multiRotatingAxisMotion.cpp
|
#multiRotatingAxisMotion/multiRotatingAxisMotion.cpp
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ bool pFlow::MotionModel<Model, Component>::impl_nameToIndex(const word& name, ui
|
||||||
indx = static_cast<uint32>(i);
|
indx = static_cast<uint32>(i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Model, typename Component>
|
template<typename Model, typename Component>
|
||||||
|
|
|
@ -22,32 +22,31 @@ Licence:
|
||||||
#include "multiRotatingAxisMotion.hpp"
|
#include "multiRotatingAxisMotion.hpp"
|
||||||
#include "dictionary.hpp"
|
#include "dictionary.hpp"
|
||||||
|
|
||||||
/// Construct from dictionary
|
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
pFlow::multiRotatingAxis::multiRotatingAxis(const dictionary& dict)
|
pFlow::multiRotatingAxis::multiRotatingAxis
|
||||||
:
|
(
|
||||||
rotatingAxis(dict)
|
multiRotatingAxisMotion* axisMotion
|
||||||
{}
|
)
|
||||||
|
{
|
||||||
|
//axisList_ = axisMotion->getAxisListPtr();
|
||||||
|
}
|
||||||
|
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
pFlow::multiRotatingAxis::multiRotatingAxis
|
pFlow::multiRotatingAxis::multiRotatingAxis
|
||||||
(
|
(
|
||||||
multiRotatingAxis* axisListPtr,
|
multiRotatingAxisMotion* axisMotion,
|
||||||
const wordList& componentsNames,
|
|
||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
:
|
|
||||||
rotatingAxis(dict),
|
|
||||||
axisList_(axisListPtr)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!read(dict, componentsNames))
|
if(!read(axisMotion, dict))
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
" error in reading rotatingAxis from dictionary "<< dict.globalName()<<endl;
|
" error in reading rotatingAxis from dictionary "<< dict.globalName()<<endl;
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//axisList_ = axisMotion->getAxisListPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,29 +54,22 @@ pFlow::multiRotatingAxis::multiRotatingAxis
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
bool pFlow::multiRotatingAxis::read
|
bool pFlow::multiRotatingAxis::read
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
multiRotatingAxisMotion* axisMotion,
|
||||||
const wordList& componentNames
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(!rotatingAxis::read(dict))return false;
|
||||||
|
|
||||||
word rotAxis = dict.getValOrSet<word>("rotationAxis", "none");
|
word rotAxis = dict.getValOrSet<word>("rotationAxis", "none");
|
||||||
|
|
||||||
if(rotAxis == "none")
|
if(rotAxis == "none")
|
||||||
{
|
{
|
||||||
parentAxisIndex_ = static_cast<uint32>(-1);
|
parentAxisIndex_ = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( auto i = componentNames.findi(rotAxis); i != -1 )
|
parentAxisIndex_ = axisMotion-> nameToIndex(rotAxis);
|
||||||
{
|
|
||||||
parentAxisIndex_ = i;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fatalErrorInFunction<<"crotationAxis "<< rotAxis<<" in dictionary "<<
|
|
||||||
dict.globalName()<<" is not found in list of axis names "<< componentNames<<endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -86,8 +78,8 @@ bool pFlow::multiRotatingAxis::read
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
bool pFlow::multiRotatingAxis::write
|
bool pFlow::multiRotatingAxis::write
|
||||||
(
|
(
|
||||||
dictionary& dict,
|
const multiRotatingAxisMotion* axisMotion,
|
||||||
const wordList& componentNames
|
dictionary& dict
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if( !rotatingAxis::write(dict) ) return false;
|
if( !rotatingAxis::write(dict) ) return false;
|
||||||
|
@ -98,8 +90,10 @@ bool pFlow::multiRotatingAxis::write
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dict.add("rotationAxis", componentNames[parentAxisIndex_]);
|
auto rotAxis = axisMotion->indexToName(parentAxisIndex_);
|
||||||
|
dict.add("rotationAxis", rotAxis);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ Licence:
|
||||||
|
|
||||||
#include "rotatingAxis.hpp"
|
#include "rotatingAxis.hpp"
|
||||||
#include "KokkosTypes.hpp"
|
#include "KokkosTypes.hpp"
|
||||||
#include "List.hpp"
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
@ -79,31 +79,26 @@ class multiRotatingAxis
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/// This is device pointer to all axes
|
/// This is device pointer to all axes
|
||||||
multiRotatingAxis* axisList_ = nullptr;
|
multiRotatingAxis* axisList_;
|
||||||
|
|
||||||
/// Index of parent axis
|
/// Index of parent axis
|
||||||
uint32 parentAxisIndex_ = static_cast<uint32>(-1);
|
int32 parentAxisIndex_ = -1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TypeInfoNV("multiRotatingAxis");
|
|
||||||
|
|
||||||
// - Constructors
|
// - Constructors
|
||||||
|
|
||||||
/// Empty Constructor
|
/// Empty Constructor
|
||||||
FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
multiRotatingAxis() = default;
|
multiRotatingAxis(){}
|
||||||
|
|
||||||
/// Construct from dictionary
|
/// Empty with list of axes
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
explicit multiRotatingAxis(const dictionary& dict);
|
multiRotatingAxis(multiRotatingAxisMotion* axisMotion);
|
||||||
|
|
||||||
/// Construct from dictionary and list of axes
|
/// Construct from dictionary and list of axes
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
multiRotatingAxis(
|
multiRotatingAxis(multiRotatingAxisMotion* axisMotion, const dictionary& dict);
|
||||||
multiRotatingAxis* axisListPtr,
|
|
||||||
const wordList& componentsNames,
|
|
||||||
const dictionary& dict);
|
|
||||||
|
|
||||||
/// Copy constructor
|
/// Copy constructor
|
||||||
FUNCTION_HD
|
FUNCTION_HD
|
||||||
|
@ -128,11 +123,11 @@ public:
|
||||||
while(parIndex != -1)
|
while(parIndex != -1)
|
||||||
{
|
{
|
||||||
auto& ax = axisList_[parIndex];
|
auto& ax = axisList_[parIndex];
|
||||||
parentVel += ax.linVelocityPoint(p);
|
parentVel += ax.linTangentialVelocityPoint(p);
|
||||||
parIndex = ax.parentAxisIndex();
|
parIndex = ax.parentAxisIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
return parentVel + rotatingAxis::linVelocityPoint(p);
|
return parentVel + rotatingAxis::linTangentialVelocityPoint(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translate point p for dt seconds based on the axis information
|
/// Translate point p for dt seconds based on the axis information
|
||||||
|
@ -148,7 +143,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
auto parIndex = parentAxisIndex_;
|
auto parIndex = parentAxisIndex_;
|
||||||
while(parIndex != static_cast<uint32>(-1))
|
while(parIndex != -1)
|
||||||
{
|
{
|
||||||
auto& ax = axisList_[parIndex];
|
auto& ax = axisList_[parIndex];
|
||||||
newP = pFlow::rotate(newP, ax, dt);
|
newP = pFlow::rotate(newP, ax, dt);
|
||||||
|
@ -162,12 +157,12 @@ public:
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
bool hasParent()const
|
bool hasParent()const
|
||||||
{
|
{
|
||||||
return parentAxisIndex_ != static_cast<uint32>(-1);
|
return parentAxisIndex_ > -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the index of parent axis
|
/// Return the index of parent axis
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
uint32 parentAxisIndex()const
|
int32 parentAxisIndex()const
|
||||||
{
|
{
|
||||||
return parentAxisIndex_;
|
return parentAxisIndex_;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +182,6 @@ public:
|
||||||
* It is assumed that the axis with deepest level (with more parrents) is
|
* It is assumed that the axis with deepest level (with more parrents) is
|
||||||
* moved first and then the axis with lower levels.
|
* moved first and then the axis with lower levels.
|
||||||
*/
|
*/
|
||||||
INLINE_FUNCTION_HD
|
|
||||||
void move(real dt)
|
void move(real dt)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -207,12 +201,11 @@ public:
|
||||||
|
|
||||||
/// Read from dictionary
|
/// Read from dictionary
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
bool read(const dictionary& dict, const wordList& componentNames);
|
bool read(multiRotatingAxisMotion* axisMotion, const dictionary& dict);
|
||||||
|
|
||||||
/// Write to dictionary
|
/// Write to dictionary
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
bool write(dictionary& dict, const wordList& componentNames) const;
|
bool write(const multiRotatingAxisMotion* axisMotion, dictionary& dict) const;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,63 +19,40 @@ Licence:
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "multiRotatingAxisMotion.hpp"
|
#include "multiRotatingAxisMotion.hpp"
|
||||||
|
#include "dictionary.hpp"
|
||||||
|
#include "vocabs.hpp"
|
||||||
|
|
||||||
void pFlow::multiRotatingAxisMotion::impl_setTime
|
|
||||||
|
bool pFlow::multiRotatingAxisMotion::readDictionary
|
||||||
(
|
(
|
||||||
uint32 iter,
|
const dictionary& dict
|
||||||
real t,
|
)
|
||||||
real dt
|
|
||||||
)const
|
|
||||||
{
|
{
|
||||||
auto motion = motionComponents_.deviceViewAll();
|
|
||||||
Kokkos::parallel_for(
|
|
||||||
"multiRotatingAxisMotion::impl_setTime",
|
|
||||||
deviceRPolicyStatic(0, numComponents_),
|
|
||||||
LAMBDA_D(uint32 i){
|
|
||||||
motion[i].setTime(t);
|
|
||||||
});
|
|
||||||
Kokkos::fence();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pFlow::multiRotatingAxisMotion::impl_move(uint32 iter, real t , real dt ) const
|
auto motionModel = dict.getVal<word>("motionModel");
|
||||||
{
|
|
||||||
auto motion = motionComponents_.deviceViewAll();
|
|
||||||
Kokkos::parallel_for(
|
|
||||||
"multiRotatingAxisMotion::impl_move",
|
|
||||||
deviceRPolicyStatic(0, numComponents_),
|
|
||||||
LAMBDA_D(uint32 i){
|
|
||||||
motion[i].move(dt);
|
|
||||||
});
|
|
||||||
Kokkos::fence();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pFlow::multiRotatingAxisMotion::impl_readDictionary(const dictionary &dict)
|
if(motionModel != "multiRotatingAxisMotion")
|
||||||
{
|
|
||||||
auto modelName = dict.getVal<word>("motionModel");
|
|
||||||
|
|
||||||
if(modelName != getTypeName<ModelComponent>())
|
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
" motionModel should be "<< Yellow_Text(getTypeName<ModelComponent>())<<
|
" motionModel should be multiRotatingAxisMotion, but found "
|
||||||
", but found "<< Yellow_Text(modelName)<<endl;
|
<< motionModel <<endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& motionInfo = dict.subDict(modelName+"Info");
|
auto& motionInfo = dict.subDict("multiRotatingAxisMotionInfo");
|
||||||
auto compNames = motionInfo.dictionaryKeywords();
|
auto axisNames = motionInfo.dictionaryKeywords();
|
||||||
|
wordList rotationAxis;
|
||||||
wordList rotationAxisNames;
|
|
||||||
|
|
||||||
|
// first check if
|
||||||
|
|
||||||
// in the first round read all dictionaries
|
|
||||||
for(auto& compName: compNames)
|
for(auto& aName: axisNames)
|
||||||
{
|
{
|
||||||
auto& axDict = motionInfo.subDict(compName);
|
auto& axDict = motionInfo.subDict(aName);
|
||||||
|
|
||||||
if(auto axPtr = makeUnique<rotatingAxis>(axDict); axPtr)
|
if(auto axPtr = makeUnique<rotatingAxis>(axDict); axPtr)
|
||||||
{
|
{
|
||||||
rotationAxisNames.push_back(
|
rotationAxis.push_back(
|
||||||
axDict.getValOrSet<word>("rotationAxis", "none"));
|
axDict.getValOrSet<word>("rotationAxis", "none"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -86,26 +63,26 @@ bool pFlow::multiRotatingAxisMotion::impl_readDictionary(const dictionary &dict)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !compNames.search("none") )
|
if( !axisNames.search("none") )
|
||||||
{
|
{
|
||||||
compNames.push_back("none");
|
axisNames.push_back("none");
|
||||||
rotationAxisNames.push_back("none");
|
rotationAxis.push_back("none");
|
||||||
}
|
}
|
||||||
|
|
||||||
using intPair = std::pair<int32, int32>;
|
using intPair = std::pair<int32, int32>;
|
||||||
|
|
||||||
std::vector<intPair> numRotAxis;
|
std::vector<intPair> numRotAxis;
|
||||||
|
|
||||||
for(size_t i=0; i< compNames.size(); i++)
|
for(size_t i=0; i< axisNames.size(); i++)
|
||||||
{
|
{
|
||||||
word rotAxis = rotationAxisNames[i];
|
word rotAxis = rotationAxis[i];
|
||||||
int32 n=0;
|
int32 n=0;
|
||||||
while(rotAxis != "none")
|
while(rotAxis != "none")
|
||||||
{
|
{
|
||||||
n++;
|
n++;
|
||||||
if(int32 iAxis = compNames.findi(rotAxis) ; iAxis != -1)
|
if(int32 iAxis = axisNames.findi(rotAxis) ; iAxis != -1)
|
||||||
{
|
{
|
||||||
rotAxis = rotationAxisNames[iAxis];
|
rotAxis = rotationAxis[iAxis];
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
|
@ -121,73 +98,60 @@ bool pFlow::multiRotatingAxisMotion::impl_readDictionary(const dictionary &dict)
|
||||||
auto compareFunc = [](const intPair& a, const intPair& b)
|
auto compareFunc = [](const intPair& a, const intPair& b)
|
||||||
{ return a.first > b.first; };
|
{ return a.first > b.first; };
|
||||||
|
|
||||||
std::sort(numRotAxis.begin(), numRotAxis.end(), compareFunc);
|
algorithms::STD::sort(numRotAxis.data(), numRotAxis.size(), compareFunc);
|
||||||
Vector<int> sortedIndex;
|
|
||||||
componentNames_.clear();
|
|
||||||
|
|
||||||
output<<compNames<<endl;
|
sortedIndex_.clear();
|
||||||
|
axisName_.clear();
|
||||||
|
|
||||||
|
|
||||||
for(auto ax:numRotAxis)
|
for(auto ax:numRotAxis)
|
||||||
{
|
{
|
||||||
componentNames_.push_back(compNames[ax.second]);
|
axisName_.push_back(axisNames[ax.second]);
|
||||||
sortedIndex.push_back(ax.second);
|
sortedIndex_.push_back(ax.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
numComponents_ = componentNames_.size();
|
numAxis_ = axisName_.size();
|
||||||
motionComponents_.reserve(numComponents_);
|
axis_.clear();
|
||||||
sortedIndex_.assign(sortedIndex);
|
axis_.reserve(numAxis_);
|
||||||
|
|
||||||
Vector<ModelComponent> components("Read::modelComponent",
|
|
||||||
compNames.size()+1,
|
// create the actual axis vector
|
||||||
0,
|
for(auto& aName: axisName_)
|
||||||
RESERVE());
|
|
||||||
|
|
||||||
|
|
||||||
for(auto& compName: componentNames_)
|
|
||||||
{
|
{
|
||||||
|
if(aName != "none")
|
||||||
if(compName != "none")
|
|
||||||
{
|
{
|
||||||
auto& compDict = motionInfo.subDict(compName);
|
auto& axDict = motionInfo.subDict(aName);
|
||||||
components.emplace_back(
|
axis_.push_back(
|
||||||
motionComponents_.data(),
|
multiRotatingAxis(this, axDict));
|
||||||
componentNames_,
|
|
||||||
compDict);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
components.emplace_back(impl_noneComponent());
|
axis_.push_back(
|
||||||
|
multiRotatingAxis(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
motionComponents_.assign(components);
|
return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pFlow::multiRotatingAxisMotion::writeDictionary
|
||||||
bool pFlow::multiRotatingAxisMotion::impl_writeDictionary
|
|
||||||
(
|
(
|
||||||
dictionary& dict
|
dictionary& dict
|
||||||
)const
|
)const
|
||||||
{
|
{
|
||||||
word modelName = "multiRotatingAxis";
|
dict.add("motionModel", "multiRotatingAxisMotion");
|
||||||
|
|
||||||
dict.add("motionModel", modelName );
|
auto& motionInfo = dict.subDictOrCreate("multiRotatingAxisMotionInfo");
|
||||||
|
|
||||||
auto modelDictName = modelName+"Info";
|
ForAll(i, axis_)
|
||||||
|
|
||||||
auto& motionInfo = dict.subDictOrCreate(modelDictName);
|
|
||||||
auto hostComponents = motionComponents_.hostView();
|
|
||||||
|
|
||||||
ForAll(i, motionComponents_)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
auto& axDict = motionInfo.subDictOrCreate(componentNames_[i]);
|
auto& axDict = motionInfo.subDictOrCreate(axisName_[i]);
|
||||||
if( !hostComponents[i].write(axDict, componentNames_))
|
if( !axis_.hostVectorAll()[i].write(this,axDict))
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
" error in writing axis "<< componentNames_[i] << " to dicrionary "
|
" error in writing axis "<< axisName_[i] << " to dicrionary "
|
||||||
<< motionInfo.globalName()<<endl;
|
<< motionInfo.globalName()<<endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -196,52 +160,79 @@ bool pFlow::multiRotatingAxisMotion::impl_writeDictionary
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::multiRotatingAxisMotion::multiRotatingAxisMotion(
|
pFlow::multiRotatingAxisMotion::multiRotatingAxisMotion()
|
||||||
const objectFile &objf,
|
{}
|
||||||
repository *owner)
|
|
||||||
: fileDictionary(objf, owner)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(! getModel().impl_readDictionary(*this) )
|
pFlow::multiRotatingAxisMotion::multiRotatingAxisMotion
|
||||||
|
(
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(! readDictionary(dict) )
|
||||||
{
|
{
|
||||||
fatalErrorInFunction;
|
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::multiRotatingAxisMotion::multiRotatingAxisMotion
|
FUNCTION_H
|
||||||
(
|
bool pFlow::multiRotatingAxisMotion::move(real t, real dt)
|
||||||
const objectFile &objf,
|
|
||||||
const dictionary &dict,
|
|
||||||
repository *owner
|
|
||||||
)
|
|
||||||
:
|
|
||||||
fileDictionary(objf, dict, owner)
|
|
||||||
{
|
{
|
||||||
if(!getModel().impl_readDictionary(*this) )
|
|
||||||
{
|
// every thing is done on host
|
||||||
fatalErrorInFunction;
|
for(int32 i=0; i<numAxis_; i++)
|
||||||
fatalExit;
|
{
|
||||||
|
auto& ax = axis_[sortedIndex_[i]];
|
||||||
|
ax.setTime(t);
|
||||||
|
ax.setAxisList(getAxisListPtrHost());
|
||||||
|
ax.move(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// transfer to device
|
||||||
|
axis_.modifyOnHost();
|
||||||
|
axis_.syncViews();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pFlow::multiRotatingAxisMotion::read
|
||||||
|
(
|
||||||
|
iIstream& is
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// create an empty file dictionary
|
||||||
|
dictionary motionInfo(motionModelFile__, true);
|
||||||
|
|
||||||
|
// read dictionary from stream
|
||||||
|
if( !motionInfo.read(is) )
|
||||||
|
{
|
||||||
|
ioErrorInFile(is.name(), is.lineNumber()) <<
|
||||||
|
" error in reading dictionray " << motionModelFile__ <<" from file. \n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !readDictionary(motionInfo) ) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::multiRotatingAxisMotion::write
|
bool pFlow::multiRotatingAxisMotion::write
|
||||||
(
|
(
|
||||||
iOstream &os,
|
iOstream& os
|
||||||
const IOPattern &iop
|
)const
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
// a global dictionary
|
// create an empty file dictionary
|
||||||
dictionary newDict(fileDictionary::dictionary::name(), true);
|
dictionary motionInfo(motionModelFile__, true);
|
||||||
if( iop.thisProcWriteData() )
|
|
||||||
|
if( !writeDictionary(motionInfo))
|
||||||
{
|
{
|
||||||
if( !getModel().impl_writeDictionary(newDict) ||
|
return false;
|
||||||
!newDict.write(os))
|
|
||||||
{
|
|
||||||
fatalErrorInFunction<<
|
|
||||||
" error in writing to dictionary "<< newDict.globalName()<<endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
if( !motionInfo.write(os) )
|
||||||
|
{
|
||||||
|
ioErrorInFile( os.name(), os.lineNumber() )<<
|
||||||
|
" error in writing dictionray to file. \n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
|
@ -22,16 +22,18 @@ Licence:
|
||||||
#define __multiRotatingAxisMotion_hpp__
|
#define __multiRotatingAxisMotion_hpp__
|
||||||
|
|
||||||
|
|
||||||
#include "MotionModel.hpp"
|
#include "types.hpp"
|
||||||
|
#include "typeInfo.hpp"
|
||||||
|
#include "VectorDual.hpp"
|
||||||
|
#include "List.hpp"
|
||||||
#include "multiRotatingAxis.hpp"
|
#include "multiRotatingAxis.hpp"
|
||||||
#include "fileDictionary.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
// forward
|
// forward
|
||||||
// class dictionary;
|
class dictionary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotating axis motion model for walls
|
* Rotating axis motion model for walls
|
||||||
|
@ -61,55 +63,200 @@ multiRotatingAxisMotionInfo
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class multiRotatingAxisMotion
|
class multiRotatingAxisMotion
|
||||||
:
|
|
||||||
public fileDictionary,
|
|
||||||
public MotionModel<multiRotatingAxisMotion, multiRotatingAxis>
|
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/** Motion model class to be passed to computational units/kernels for
|
||||||
|
* transfing points and returning velocities at various positions
|
||||||
|
*/
|
||||||
|
class Model
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
deviceViewType1D<multiRotatingAxis> axis_;
|
||||||
|
int32 numAxis_=0;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
INLINE_FUNCTION_HD
|
||||||
|
Model(deviceViewType1D<multiRotatingAxis> axis, int32 numAxis):
|
||||||
|
axis_(axis),
|
||||||
|
numAxis_(numAxis)
|
||||||
|
{}
|
||||||
|
|
||||||
|
INLINE_FUNCTION_HD
|
||||||
|
Model(const Model&) = default;
|
||||||
|
|
||||||
|
|
||||||
|
INLINE_FUNCTION_HD
|
||||||
|
Model& operator=(const Model&) = default;
|
||||||
|
|
||||||
|
|
||||||
|
INLINE_FUNCTION_HD
|
||||||
|
realx3 pointVelocity(int32 n, const realx3& p)const
|
||||||
|
{
|
||||||
|
return axis_[n].pointTangentialVel(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
INLINE_FUNCTION_HD
|
||||||
|
realx3 operator()(int32 n, const realx3& p)const
|
||||||
|
{
|
||||||
|
return pointVelocity(n,p);
|
||||||
|
}
|
||||||
|
|
||||||
|
INLINE_FUNCTION_HD
|
||||||
|
realx3 transferPoint(int32 n, const realx3 p, real dt)const
|
||||||
|
{
|
||||||
|
return axis_[n].transferPoint(p, dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
INLINE_FUNCTION_HD int32 numComponents()const
|
||||||
|
{
|
||||||
|
return numAxis_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
VectorSingle<int32> sortedIndex_;
|
using axisVector_HD = VectorDual<multiRotatingAxis>;
|
||||||
|
|
||||||
friend MotionModel<multiRotatingAxisMotion, multiRotatingAxis>;
|
/// Vector of multiRotaingAxis axes
|
||||||
|
axisVector_HD axis_;
|
||||||
|
|
||||||
|
/// Sorted index based on number of parrents each axis ha
|
||||||
|
VectorDual<int32> sortedIndex_;
|
||||||
|
|
||||||
/// is the geometry attached to this component moving
|
/// List of axes names
|
||||||
bool impl_isMoving()const
|
wordList axisName_;
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/// Number of axes
|
||||||
|
label numAxis_= 0;
|
||||||
|
|
||||||
|
/// Read from a dictionary
|
||||||
|
bool readDictionary(const dictionary& dict);
|
||||||
|
|
||||||
/// Read from dictionary
|
/// Write to a dictionary
|
||||||
bool impl_readDictionary(const dictionary& dict);
|
bool writeDictionary(dictionary& dict)const;
|
||||||
|
|
||||||
bool impl_writeDictionary(dictionary& dict)const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TypeInfo("multiRotatingAxisMotion");
|
/// Type info
|
||||||
|
TypeInfoNV("multiRotatingAxisMotion");
|
||||||
|
|
||||||
multiRotatingAxisMotion(const objectFile& objf, repository* owner);
|
// - Constructor
|
||||||
|
|
||||||
multiRotatingAxisMotion(
|
/// Empty constructor
|
||||||
const objectFile& objf,
|
FUNCTION_H
|
||||||
const dictionary& dict,
|
multiRotatingAxisMotion();
|
||||||
repository* owner);
|
|
||||||
|
|
||||||
using fileDictionary::write;
|
/// Construct with dictionary
|
||||||
|
FUNCTION_H
|
||||||
|
multiRotatingAxisMotion(const dictionary& dict);
|
||||||
|
|
||||||
bool write(iOstream& os, const IOPattern& iop)const override;
|
/// Copy constructor
|
||||||
|
FUNCTION_H
|
||||||
|
multiRotatingAxisMotion(const multiRotatingAxisMotion&) = default;
|
||||||
|
|
||||||
static
|
/// No Move
|
||||||
multiRotatingAxis noneComponent()
|
multiRotatingAxisMotion(multiRotatingAxisMotion&&) = delete;
|
||||||
{
|
|
||||||
return multiRotatingAxis();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: make this method protected
|
/// Copy assignment
|
||||||
void impl_setTime(uint32 iter, real t, real dt)const;
|
FUNCTION_H
|
||||||
|
multiRotatingAxisMotion& operator=(const multiRotatingAxisMotion&) = default;
|
||||||
|
|
||||||
/// move the component itself
|
/// No move assignment
|
||||||
bool impl_move(uint32 iter, real t, real dt)const;
|
multiRotatingAxisMotion& operator=(multiRotatingAxisMotion&&) = delete;
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
FUNCTION_H
|
||||||
|
~multiRotatingAxisMotion() = default;
|
||||||
|
|
||||||
|
// - Methods
|
||||||
|
|
||||||
|
/// Retrun motion model at time t
|
||||||
|
Model getModel(real t)
|
||||||
|
{
|
||||||
|
for(int32 i= 0; i<numAxis_; i++ )
|
||||||
|
{
|
||||||
|
axis_[i].setTime(t);
|
||||||
|
axis_[i].setAxisList(getAxisListPtrDevice());
|
||||||
|
}
|
||||||
|
axis_.modifyOnHost();
|
||||||
|
axis_.syncViews();
|
||||||
|
|
||||||
|
return Model(axis_.deviceVector(), numAxis_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Pointer to axis list on host side
|
||||||
|
INLINE_FUNCTION_H
|
||||||
|
multiRotatingAxis* getAxisListPtrHost()
|
||||||
|
{
|
||||||
|
return axis_.hostVectorAll().data();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Pointer to axis list on device
|
||||||
|
INLINE_FUNCTION_H
|
||||||
|
multiRotatingAxis* getAxisListPtrDevice()
|
||||||
|
{
|
||||||
|
return axis_.deviceVectorAll().data();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Name of motion component to index
|
||||||
|
INLINE_FUNCTION_H
|
||||||
|
int32 nameToIndex(const word& name)const
|
||||||
|
{
|
||||||
|
if( auto i = axisName_.findi(name); i == -1)
|
||||||
|
{
|
||||||
|
fatalErrorInFunction<<
|
||||||
|
"axis name " << name << " does not exist. \n";
|
||||||
|
fatalExit;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Index of motion component to component name
|
||||||
|
INLINE_FUNCTION_H
|
||||||
|
word indexToName(label i)const
|
||||||
|
{
|
||||||
|
if(i < numAxis_ )
|
||||||
|
return axisName_[i];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fatalErrorInFunction<<
|
||||||
|
"out of range access to the list of axes " << i <<endl<<
|
||||||
|
" size of axes_ is "<<numAxis_<<endl;
|
||||||
|
fatalExit;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Is moving
|
||||||
|
INLINE_FUNCTION_HD
|
||||||
|
bool isMoving()const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Move points
|
||||||
|
FUNCTION_H
|
||||||
|
bool move(real t, real dt);
|
||||||
|
|
||||||
|
// - IO operation
|
||||||
|
|
||||||
|
/// Read from input stream is
|
||||||
|
FUNCTION_H
|
||||||
|
bool read(iIstream& is);
|
||||||
|
|
||||||
|
/// Write to output stream os
|
||||||
|
FUNCTION_H
|
||||||
|
bool write(iOstream& os)const;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
|
@ -56,7 +56,7 @@ template<typename Type, typename... Properties>
|
||||||
INLINE_FUNCTION_H void
|
INLINE_FUNCTION_H void
|
||||||
reallocInit(ViewType1D<Type, Properties...>& view, uint32 len)
|
reallocInit(ViewType1D<Type, Properties...>& view, uint32 len)
|
||||||
{
|
{
|
||||||
Kokkos::realloc(view, len);
|
Kokkos::realloc(Kokkos::WithoutInitializing, view, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Type, typename... Properties>
|
template<typename Type, typename... Properties>
|
||||||
|
|
|
@ -28,8 +28,6 @@ Licence:
|
||||||
#include "cudaAlgorithms.hpp"
|
#include "cudaAlgorithms.hpp"
|
||||||
#include "kokkosAlgorithms.hpp"
|
#include "kokkosAlgorithms.hpp"
|
||||||
#include "stdAlgorithms.hpp"
|
#include "stdAlgorithms.hpp"
|
||||||
#include "Kokkos_Sort.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
@ -297,9 +295,7 @@ sort(ViewType1D<T, properties...>& view, uint32 start, uint32 end)
|
||||||
|
|
||||||
if constexpr (isHostAccessible<ExecutionSpace>())
|
if constexpr (isHostAccessible<ExecutionSpace>())
|
||||||
{
|
{
|
||||||
//auto sView = Kokkos::subview(view, Kokkos::make_pair<uint32,uint32>(start,end));
|
pFlow::algorithms::STD::sort<T, true>(view.data() + start, numElems);
|
||||||
//Kokkos::sort(sView);
|
|
||||||
pFlow::algorithms::STD::sort<T, false>(view.data() + start, numElems);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +316,7 @@ sort(
|
||||||
ViewType1D<T, properties...>& view,
|
ViewType1D<T, properties...>& view,
|
||||||
uint32 start,
|
uint32 start,
|
||||||
uint32 end,
|
uint32 end,
|
||||||
const CompareFunc& compare
|
CompareFunc compare
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
using ExecutionSpace =
|
using ExecutionSpace =
|
||||||
|
@ -330,12 +326,9 @@ sort(
|
||||||
|
|
||||||
if constexpr (isHostAccessible<ExecutionSpace>())
|
if constexpr (isHostAccessible<ExecutionSpace>())
|
||||||
{
|
{
|
||||||
// sort without parallelization
|
pFlow::algorithms::STD::sort<T, CompareFunc, true>(
|
||||||
pFlow::algorithms::STD::sort<T, CompareFunc,false>(
|
|
||||||
view.data() + start, numElems, compare
|
view.data() + start, numElems, compare
|
||||||
);
|
);
|
||||||
//auto sView = Kokkos::subview(view, Kokkos::make_pair<uint32,uint32>(start,end));
|
|
||||||
//Kokkos::sort(sView, compare);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +345,6 @@ sort(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<
|
template<
|
||||||
typename Type,
|
typename Type,
|
||||||
typename... properties,
|
typename... properties,
|
||||||
|
|
|
@ -148,7 +148,7 @@ void sort(Type* first, int32 numElems)
|
||||||
if constexpr(useParallel)
|
if constexpr(useParallel)
|
||||||
{
|
{
|
||||||
std::sort(
|
std::sort(
|
||||||
std::execution::par_unseq,
|
std::execution::par,
|
||||||
first,
|
first,
|
||||||
first+numElems,
|
first+numElems,
|
||||||
less<Type>());
|
less<Type>());
|
||||||
|
|
Loading…
Reference in New Issue