Skip to content

Commit 882d4f5

Browse files
committed
Reverted back to version of app without memeory leaks - implemented back all else but the part that cuased the leaks
1 parent e060f2a commit 882d4f5

File tree

7 files changed

+45
-24
lines changed

7 files changed

+45
-24
lines changed

simulation/TODO.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
1-
## To discuss in thesis
2-
- Check that the uses of "was done" and "will be done" is consistent and makes sense
3-
- Make sure that it is properly distinguished between the time step of switching files (a day), and a simulation time step (dt)
4-
- Make sure that it is clear that fluid simulation and particle simulation is the same thing as we are simulating the fluid as particles (probs. in the intro)
5-
- Update research question
6-
71

82
## Android side
93
- Delete unused project files / folders
10-
- Properly handle the screen layout (see boxVisualization branch)
114

125
## Native side
136
- Delete unused functions
14-
- Take out functions from native-lib into a class called application and make the native-lib only be responsible for JNI communication
157

168
## Stuff to research
179
- Try cuberiles after all
1810
- Direct volume rendering / volume ray casting
19-
- The outline box approach
2011

2112
## General project
2213
- Make sure to use same case (e.g. camelCase)
23-
- Try better rendering methods when exatra time, e.g. thesis draft is being review ->volume rendering / volume ray casting, find new ones
24-
- Mention the different (attempted) different ways of rendering stuff - so far: LIC
14+
2515

2616
## Next meeting points
2717
- Make repo public?

simulation/app/src/main/cpp/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ target_link_libraries(${CMAKE_PROJECT_NAME}
8282
# For including libraries (outside NDK) later on
8383
# include_directories(include/)
8484

85-
# TODO: Maybe add this to make sure the C++ standard is enforced
86-
#set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
87-
# CXX_STANDARD 17
88-
# CXX_STANDARD_REQUIRED ON)
89-
9085
# Compiler flags
9186
# target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall -Wextra -O2)
9287

simulation/app/src/main/cpp/include/ThreadPool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Created: https://github.com/progschj/ThreadPool
3-
// Modified by: Martin K. Mwila
3+
// Modified by: Martin Opat
44
//
55
#ifndef THREAD_POOL_H
66
#define THREAD_POOL_H

simulation/app/src/main/cpp/include/consts.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,5 @@ enum class Mode {
3030
};
3131
extern Mode mode;
3232

33-
//// Application state - user (i.e. programmer) defined
34-
//struct appState;
35-
//extern appState *globalAppState;
3633

3734
#endif //LAGRANGIAN_FLUID_SIMULATION_CONSTS_H

simulation/app/src/main/cpp/include/timer.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,56 @@
2020
template<typename ClockType>
2121
class Timer {
2222
public:
23+
/**
24+
* @brief Constructor for the Timer class.
25+
*/
2326
Timer();
2427

28+
/**
29+
* @brief Starts the timer.
30+
*/
2531
void start();
32+
33+
/**
34+
* @brief Stops the timer.
35+
*/
2636
void stop();
37+
38+
/**
39+
* @brief Gets the elapsed time in seconds.
40+
*
41+
* @return The elapsed time in seconds.
42+
*/
2743
float getElapsedTimeInSeconds();
44+
45+
/**
46+
* @brief Gets the elapsed time in milliseconds.
47+
*
48+
* @return The elapsed time in milliseconds.
49+
*/
2850
std::chrono::milliseconds getElapsedTime();
2951

52+
/**
53+
* @brief Logs the frames per second to console.
54+
*/
3055
void logFPS();
56+
57+
/**
58+
* @brief Logs the elapsed time to console.
59+
*/
3160
void logElapsedTime();
3261

62+
/**
63+
* @brief Checks if the timer is started.
64+
*
65+
* @return True if the timer is started, false otherwise.
66+
*/
3367
bool isStarted();
3468

69+
/**
70+
* @brief Measures the time elapsed since the last measurement.
71+
* @note This method logs the elapsed time to console every `displayFrequency` milliseconds.
72+
*/
3573
void measure();
3674

3775
private:

simulation/app/src/main/cpp/src/native-lib.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ void init(std::string packageName) {
122122
/////////////////////////////////////////////////////////////
123123

124124

125+
// Choose one of the following particle initialization methods
125126
globalAppState->particlesHandler = new ParticlesHandler(*globalAppState->physics, NUM_PARTICLES); // Initialization from file
126127
// globalAppState->particlesHandler = new ParticlesHandler(ParticlesHandler::InitType::line , *(globalAppState->physics), NUM_PARTICLES); // Diagonal line code-wise initialization
127128
// globalAppState->particlesHandler = new ParticlesHandler(ParticlesHandler::InitType::uniform ,*(globalAppState->physics), NUM_PARTICLES); // Random uniform code-wise initialization
@@ -144,7 +145,7 @@ extern "C" {
144145
(globalAppState->mainview)->drawUI();
145146
}
146147

147-
JNIEXPORT void JNICALL Java_com_rug_lagrangianfluidsimulation_MainActivity_setupGraphics(JNIEnv* env, jobject obj, jobject assetManager, jstring path) { // TODO: Rename
148+
JNIEXPORT void JNICALL Java_com_rug_lagrangianfluidsimulation_MainActivity_setupNative(JNIEnv* env, jobject obj, jobject assetManager, jstring path) { // TODO: Rename
148149
globalAppState->mainview = new Mainview(AAssetManager_fromJava(env, assetManager));
149150
(globalAppState->mainview)->setupGraphics();
150151

@@ -182,7 +183,7 @@ extern "C" {
182183
}
183184

184185
JNIEXPORT void JNICALL
185-
Java_com_rug_lagrangianfluidsimulation_MainActivity_createBuffers(JNIEnv *env, jobject thiz) { // TODO: Is there a reason for this to be exported ?
186+
Java_com_rug_lagrangianfluidsimulation_MainActivity_createBuffers(JNIEnv *env, jobject thiz) {
186187
(globalAppState->mainview)->createVectorFieldBuffer((globalAppState->vectorFieldHandler)->getOldVertices());
187188
(globalAppState->mainview)->createParticlesBuffer((globalAppState->particlesHandler)->getParticlesPositions());
188189
(globalAppState->mainview)->createComputeBuffer((globalAppState->vectorFieldHandler)->getOldVertices(), (globalAppState->vectorFieldHandler)->getNewVertices(), (globalAppState->vectorFieldHandler)->getFutureVertices());

simulation/app/src/main/java/com/rug/lagrangianfluidsimulation/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class MainActivity extends Activity {
3939

4040

4141
private native void drawFrame();
42-
public native void setupGraphics(AssetManager assetManager, String workPath);
42+
public native void setupNative(AssetManager assetManager, String workPath);
4343
public native void createBuffers();
4444
public native void nativeSendTouchEvent(int pointerCount, float[] x, float[] y, int action);
4545
public native void onDestroyNative();
@@ -77,7 +77,7 @@ public void onSurfaceCreated(GL10 gl, EGLConfig config) {
7777
AssetManager assetManager = getAssets();
7878

7979
String workPath = getFilesDir().getAbsolutePath();
80-
setupGraphics(assetManager, workPath);
80+
setupNative(assetManager, workPath);
8181
}
8282

8383
@Override

0 commit comments

Comments
 (0)