restructured project

This commit is contained in:
Lauchmelder 2021-12-12 22:44:31 +01:00
parent 62b90b7077
commit 5762d02b48
9 changed files with 26 additions and 20 deletions

View file

@ -1,16 +1,5 @@
# CMakeList.txt : CMake project for EulerFluid, include source and define set(BUILD_EULER_FLUID ON CACHE BOOL "Build Euler Fluid Project")
# project specific logic here.
#
cmake_minimum_required (VERSION 3.8)
# Add source to this project's executable. if(${BUILD_EULER_FLUID})
add_executable (EulerFluid "main.cpp" "Application.hpp" "Application.cpp" "VectorField.hpp" "VectorField.cpp" "FluidField.hpp" "FluidField.cpp") add_subdirectory(EulerFluid)
endif()
target_include_directories(EulerFluid PUBLIC ${SDL2_INCLUDE_DIRS})
target_link_libraries(EulerFluid PUBLIC ${SDL2_LIBRARIES})
if(MSVC)
target_compile_definitions(EulerFluid PUBLIC _CRT_SECURE_NO_WARNINGS)
endif()
# TODO: Add tests and install targets if needed.

View file

@ -88,7 +88,7 @@ void Application::Update()
before = std::chrono::steady_clock::now(); before = std::chrono::steady_clock::now();
field->VelocityStep(0.002, frametime); field->VelocityStep(0.002, frametime);
field->DensityStep(0.001, frametime); field->DensityStep(0.0005, frametime);
} }
void Application::Render() void Application::Render()

View file

@ -0,0 +1,16 @@
# CMakeList.txt : CMake project for EulerFluid, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.8)
# Add source to this project's executable.
add_executable (EulerFluid "main.cpp" "Application.hpp" "Application.cpp" "VectorField.hpp" "VectorField.cpp" "FluidField.hpp" "FluidField.cpp")
target_include_directories(EulerFluid PUBLIC ${SDL2_INCLUDE_DIRS})
target_link_libraries(EulerFluid PUBLIC ${SDL2_LIBRARIES})
if(MSVC)
target_compile_definitions(EulerFluid PUBLIC _CRT_SECURE_NO_WARNINGS)
endif()
# TODO: Add tests and install targets if needed.

View file

@ -215,7 +215,7 @@ void FluidField::VelocityStep(double visc, double dt)
AdvectVelocity(dt); AdvectVelocity(dt);
Project(); Project();
vel->RecalculateMagnitude(); // vel->RecalculateMagnitude();
} }
void FluidField::Project() void FluidField::Project()

View file

@ -62,14 +62,15 @@ void VectorField::RecalculateMagnitude()
{ {
double u = horizontal[y * this->width + x]; double u = horizontal[y * this->width + x];
double v = vertical[y * this->width + x]; double v = vertical[y * this->width + x];
double magnitude = u + v; double magnitude = u*u + v*v;
biggestMagnitude += (biggestMagnitude < magnitude) * (magnitude - biggestMagnitude); biggestMagnitude = std::max(biggestMagnitude, magnitude);
} }
} }
if (biggestMagnitude == 0.0) // should use an epsilon probably if (biggestMagnitude == 0.0) // should use an epsilon probably
biggestMagnitude = 1.0; biggestMagnitude = 1.0;
biggestMagnitude = sqrt(biggestMagnitude * 5.0); biggestMagnitude = sqrt(biggestMagnitude);
biggestMagnitude = 0.5f;
} }