Skip to content

Commit ad1c801

Browse files
authored
Minor fixes on Particle/SphSystemData (#108)
This revision includes: * Minor comment fixes on Particle/SphSystemData2 and 3 * Adding setKernelRadius function to SphSystemData2 and 3 * Adding more Python bindings to ParticleSystemData2 and 3
1 parent 8caf231 commit ad1c801

16 files changed

Lines changed: 677 additions & 181 deletions

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ script:
3030
- cmake ..
3131
- make
3232
- bin/unit_tests
33+
- pip install --user -r ../requirements.txt
3334
- pip install --user ..
3435
- python ../src/tests/python_tests/main.py

INSTALL.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,15 @@ Then, build `INSTALL` project under `jet.sln`. This will install the header file
124124
To install the Python SDK, `pyjet`, run the following command from the project root directory (where `setup.py` lives):
125125

126126
```
127-
pip install .
127+
pip install -U .
128+
```
129+
130+
> You can also use `virtualenv` to isolate the SDK installation. Check out [the virtualenv documentation](https://virtualenv.pypa.io/en/stable/) for more details.
131+
132+
To run the test/example scripts, install other Python dependencies as follows:
133+
134+
```
135+
pip install -r requirements.txt
128136
```
129137

130138
Once installed, try running the unit test to see if the module is installed correctly:

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ build:
3939

4040
after_build:
4141
- c:\jet\build\bin\Release\unit_tests.exe
42+
- pip install --user -r c:\jet\requirements.txt
4243
- pip install --user c:\jet
4344
- python c:\jet\src\tests\python_tests\main.py

include/jet/particle_system_data2.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ class ParticleSystemData2 : public Serializable {
168168
//! responsibility to call ParticleSystemData2::buildNeighborSearcher and
169169
//! ParticleSystemData2::buildNeighborLists to refresh those data.
170170
//!
171-
//! \param[in] newPosition The new position.
172-
//! \param[in] newVelocity The new velocity.
173-
//! \param[in] newForce The new force.
171+
//! \param[in] newPositions The new positions.
172+
//! \param[in] newVelocities The new velocities.
173+
//! \param[in] newForces The new forces.
174174
//!
175175
void addParticles(
176176
const ConstArrayAccessor1<Vector2D>& newPositions,

include/jet/particle_system_data3.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ class ParticleSystemData3 : public Serializable {
168168
//! responsibility to call ParticleSystemData3::buildNeighborSearcher and
169169
//! ParticleSystemData3::buildNeighborLists to refresh those data.
170170
//!
171-
//! \param[in] newPosition The new position.
172-
//! \param[in] newVelocity The new velocity.
173-
//! \param[in] newForce The new force.
171+
//! \param[in] newPositions The new positions.
172+
//! \param[in] newVelocities The new velocities.
173+
//! \param[in] newForces The new forces.
174174
//!
175175
void addParticles(
176176
const ConstArrayAccessor1<Vector3D>& newPositions,

include/jet/sph_system_data2.h

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class SphSystemData2 : public ParticleSystemData2 {
9595
//! \brief Sets the relative kernel radius.
9696
//!
9797
//! Sets the relative kernel radius compared to the target particle
98-
//! spacing (i.e. kernal radius / target spacing).
98+
//! spacing (i.e. kernel radius / target spacing).
9999
//! Once this function is called, hash grid and density should
100100
//! be updated using updateHashGrid() and updateDensities).
101101
//!
@@ -105,10 +105,20 @@ class SphSystemData2 : public ParticleSystemData2 {
105105
//! \brief Returns the relative kernel radius.
106106
//!
107107
//! Returns the relative kernel radius compared to the target particle
108-
//! spacing (i.e. kernal radius / target spacing).
108+
//! spacing (i.e. kernel radius / target spacing).
109109
//!
110110
double relativeKernelRadius() const;
111111

112+
//!
113+
//! \brief Sets the absolute kernel radius.
114+
//!
115+
//! Sets the absolute kernel radius compared to the target particle
116+
//! spacing (i.e. relative kernel radius * target spacing).
117+
//! Once this function is called, hash grid and density should
118+
//! be updated using updateHashGrid() and updateDensities).
119+
//!
120+
void setKernelRadius(double kernelRadius);
121+
112122
//! Returns the kernel radius in meters unit.
113123
double kernelRadius() const;
114124

@@ -126,9 +136,8 @@ class SphSystemData2 : public ParticleSystemData2 {
126136
//! \warning You must update the neighbor searcher
127137
//! (SphSystemData2::buildNeighborSearcher) before calling this function.
128138
//!
129-
double interpolate(
130-
const Vector2D& origin,
131-
const ConstArrayAccessor1<double>& values) const;
139+
double interpolate(const Vector2D& origin,
140+
const ConstArrayAccessor1<double>& values) const;
132141

133142
//!
134143
//! \brief Returns interpolated vector value at given origin point.
@@ -141,39 +150,35 @@ class SphSystemData2 : public ParticleSystemData2 {
141150
//! \warning You must update the neighbor searcher
142151
//! (SphSystemData2::buildNeighborSearcher) before calling this function.
143152
//!
144-
Vector2D interpolate(
145-
const Vector2D& origin,
146-
const ConstArrayAccessor1<Vector2D>& values) const;
153+
Vector2D interpolate(const Vector2D& origin,
154+
const ConstArrayAccessor1<Vector2D>& values) const;
147155

148156
//!
149157
//! Returns the gradient of the given values at i-th particle.
150158
//!
151159
//! \warning You must update the neighbor lists
152160
//! (SphSystemData2::buildNeighborLists) before calling this function.
153161
//!
154-
Vector2D gradientAt(
155-
size_t i,
156-
const ConstArrayAccessor1<double>& values) const;
162+
Vector2D gradientAt(size_t i,
163+
const ConstArrayAccessor1<double>& values) const;
157164

158165
//!
159166
//! Returns the laplacian of the given values at i-th particle.
160167
//!
161168
//! \warning You must update the neighbor lists
162169
//! (SphSystemData2::buildNeighborLists) before calling this function.
163170
//!
164-
double laplacianAt(
165-
size_t i,
166-
const ConstArrayAccessor1<double>& values) const;
171+
double laplacianAt(size_t i,
172+
const ConstArrayAccessor1<double>& values) const;
167173

168174
//!
169175
//! Returns the laplacian of the given values at i-th particle.
170176
//!
171177
//! \warning You must update the neighbor lists
172178
//! (SphSystemData2::buildNeighborLists) before calling this function.
173179
//!
174-
Vector2D laplacianAt(
175-
size_t i,
176-
const ConstArrayAccessor1<Vector2D>& values) const;
180+
Vector2D laplacianAt(size_t i,
181+
const ConstArrayAccessor1<Vector2D>& values) const;
177182

178183
//! Builds neighbor searcher with kernel radius.
179184
void buildNeighborSearcher();

include/jet/sph_system_data3.h

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,27 @@ class SphSystemData3 : public ParticleSystemData3 {
8787
//! \brief Sets the relative kernel radius.
8888
//!
8989
//! Sets the relative kernel radius compared to the target particle
90-
//! spacing (i.e. kernal radius / target spacing).
90+
//! spacing (i.e. kernel radius / target spacing).
9191
//! Once this function is called, hash grid and density should
9292
//! be updated using updateHashGrid() and updateDensities).
9393
//!
9494
void setRelativeKernelRadius(double relativeRadius);
9595

96+
//!
97+
//! \brief Sets the absolute kernel radius.
98+
//!
99+
//! Sets the absolute kernel radius compared to the target particle
100+
//! spacing (i.e. relative kernel radius * target spacing).
101+
//! Once this function is called, hash grid and density should
102+
//! be updated using updateHashGrid() and updateDensities).
103+
//!
104+
void setKernelRadius(double kernelRadius);
105+
96106
//!
97107
//! \brief Returns the relative kernel radius.
98108
//!
99109
//! Returns the relative kernel radius compared to the target particle
100-
//! spacing (i.e. kernal radius / target spacing).
110+
//! spacing (i.e. kernel radius / target spacing).
101111
//!
102112
double relativeKernelRadius() const;
103113

@@ -115,9 +125,8 @@ class SphSystemData3 : public ParticleSystemData3 {
115125
//! particle layout. For example, density or pressure arrays can be
116126
//! used.
117127
//!
118-
double interpolate(
119-
const Vector3D& origin,
120-
const ConstArrayAccessor1<double>& values) const;
128+
double interpolate(const Vector3D& origin,
129+
const ConstArrayAccessor1<double>& values) const;
121130

122131
//!
123132
//! \brief Returns interpolated vector value at given origin point.
@@ -127,24 +136,20 @@ class SphSystemData3 : public ParticleSystemData3 {
127136
//! particle layout. For example, velocity or acceleration arrays can be
128137
//! used.
129138
//!
130-
Vector3D interpolate(
131-
const Vector3D& origin,
132-
const ConstArrayAccessor1<Vector3D>& values) const;
139+
Vector3D interpolate(const Vector3D& origin,
140+
const ConstArrayAccessor1<Vector3D>& values) const;
133141

134142
//! Returns the gradient of the given values at i-th particle.
135-
Vector3D gradientAt(
136-
size_t i,
137-
const ConstArrayAccessor1<double>& values) const;
143+
Vector3D gradientAt(size_t i,
144+
const ConstArrayAccessor1<double>& values) const;
138145

139146
//! Returns the laplacian of the given values at i-th particle.
140-
double laplacianAt(
141-
size_t i,
142-
const ConstArrayAccessor1<double>& values) const;
147+
double laplacianAt(size_t i,
148+
const ConstArrayAccessor1<double>& values) const;
143149

144150
//! Returns the laplacian of the given values at i-th particle.
145-
Vector3D laplacianAt(
146-
size_t i,
147-
const ConstArrayAccessor1<Vector3D>& values) const;
151+
Vector3D laplacianAt(size_t i,
152+
const ConstArrayAccessor1<Vector3D>& values) const;
148153

149154
//! Builds neighbor searcher with kernel radius.
150155
void buildNeighborSearcher();

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
numpy
2+
matplotlib

0 commit comments

Comments
 (0)