-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from frostsim/release/1.0.0
master <- release/1.0.0
- Loading branch information
Showing
16 changed files
with
1,631 additions
and
208 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.19.0) | ||
|
||
# Set the project name | ||
SET( PROJECT_NAME DXViewer ) | ||
SET( PROJECT_NAME EulerianFluids ) | ||
PROJECT(${PROJECT_NAME}) | ||
|
||
# Define character set as Unicode | ||
add_definitions(-DUNICODE -D_UNICODE) | ||
|
||
# Collect shader files | ||
FILE( GLOB VS_SHD ${CMAKE_SOURCE_DIR}/shader/vertexShader.hlsl ) | ||
FILE( GLOB PS_SHD ${CMAKE_SOURCE_DIR}/shader/fragShader.hlsl ) | ||
# Set configuration types | ||
Set(CMAKE_CONFIGURATION_TYPES Debug Release) | ||
|
||
# Set the shader type of files | ||
set_property(SOURCE ${VS_SHD} PROPERTY VS_SHADER_TYPE Vertex) | ||
set_property(SOURCE ${PS_SHD} PROPERTY VS_SHADER_TYPE Pixel) | ||
# Set the include/lib directory | ||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ext/DXViewer/DXViewer-2.0.0/include) | ||
LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/ext/DXViewer/DXViewer-2.0.0/lib) | ||
|
||
# Set the header directory | ||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ext/DXViewer/DXViewer-1.0.0/include) | ||
# Copy DLLs | ||
FILE(GLOB DLL ${CMAKE_SOURCE_DIR}/ext/DXViewer/DXViewer-2.0.0/bin/*.dll) | ||
FILE(COPY ${DLL} DESTINATION ${CMAKE_BINARY_DIR}) | ||
|
||
# Copy CSOs | ||
FILE(GLOB CSO ${CMAKE_SOURCE_DIR}/ext/DXViewer/DXViewer-2.0.0/*.cso) | ||
FILE(COPY ${CSO} DESTINATION ${CMAKE_BINARY_DIR}) | ||
|
||
# Collect source files | ||
FILE( GLOB SRC ${CMAKE_SOURCE_DIR}/ext/DXViewer/src/*.cpp | ||
${CMAKE_SOURCE_DIR}/src/*.cpp) | ||
FILE( GLOB HDR ${CMAKE_SOURCE_DIR}/ext/DXViewer/DXViewer-1.0.0/include/*.h | ||
${CMAKE_SOURCE_DIR}/src/*.h) | ||
FILE( GLOB SHD ${VS_SHD} ${PS_SHD} ) | ||
|
||
# Link Source files | ||
ADD_EXECUTABLE( ${PROJECT_NAME} WIN32 ${SRC} ${HDR} ${SHD} ) | ||
FILE( GLOB SRC ${CMAKE_SOURCE_DIR}/src/*.cpp ) | ||
FILE( GLOB HDR ${CMAKE_SOURCE_DIR}/src/*.h ) | ||
|
||
# Link Source files ('WIN32' keyword is used for win32 project) | ||
ADD_EXECUTABLE( ${PROJECT_NAME} WIN32 ${SRC} ${HDR} ) | ||
|
||
# Set 'Additional Dependencies' | ||
SET(LIB $<$<CONFIG:DEBUG>:DXViewer.lib> $<$<CONFIG:RELEASE>:DXViewerRel.lib>) | ||
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${LIB}) |
Submodule DXViewer
updated
from 4c417f to 3be46d
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#include "EulerGasSim.h" | ||
|
||
using namespace DirectX; | ||
using namespace std; | ||
|
||
EulerGasSim::EulerGasSim(float timeStep) | ||
:GridFluidSim::GridFluidSim(timeStep) | ||
{ | ||
} | ||
|
||
EulerGasSim::~EulerGasSim() | ||
{ | ||
|
||
} | ||
|
||
|
||
void EulerGasSim::update() | ||
{ | ||
_force(); | ||
|
||
_project(); | ||
_advect(); | ||
_project(); | ||
|
||
_updateParticlePos(_timeStep); | ||
_paintGrid(); | ||
} | ||
|
||
|
||
void EulerGasSim::_force() | ||
{ | ||
_gridVelocity[_INDEX(5, 5)] = { 1.0f, 1.0f }; | ||
} | ||
|
||
void EulerGasSim::_advect() | ||
{ | ||
int N = _gridCount - 2; | ||
float t0step = _timeStep * N; | ||
|
||
float yMax = _gridPosition[_INDEX(0, N + 1)].y - 0.5f; | ||
float yMin = _gridPosition[_INDEX(0, 0)].y + 0.5f; | ||
float xMax = _gridPosition[_INDEX(N + 1, 0)].x - 0.5f; | ||
float xMin = _gridPosition[_INDEX(0, 0)].x + 0.5f; | ||
|
||
vector<XMFLOAT2> oldVelocity = _gridVelocity; | ||
|
||
for (int i = 1; i <= N; i++) | ||
{ | ||
for (int j = 1; j <= N; j++) | ||
{ | ||
XMFLOAT2 backPos = | ||
XMFLOAT2( | ||
_gridPosition[_INDEX(i, j)].x - t0step * oldVelocity[_INDEX(i, j)].x, | ||
_gridPosition[_INDEX(i, j)].y - t0step * oldVelocity[_INDEX(i, j)].y | ||
); | ||
if (backPos.x > xMax) backPos.x = xMax; | ||
else if (backPos.x < xMin) backPos.x = xMin; | ||
|
||
if (backPos.y > yMax) backPos.y = yMax; | ||
else if (backPos.y < yMin) backPos.y = yMin; | ||
|
||
|
||
_gridVelocity[_INDEX(i, j)] = _velocityInterpolation(backPos, oldVelocity); | ||
} | ||
} | ||
_setBoundary(_gridVelocity); | ||
} | ||
|
||
void EulerGasSim::_project() | ||
{ | ||
int N = _gridCount - 2; | ||
for (int i = 1; i <= N; i++) | ||
{ | ||
for (int j = 1; j <= N; j++) | ||
{ | ||
_gridDivergence[_INDEX(i, j)] = | ||
0.5f * (_gridVelocity[_INDEX(i + 1, j)].x - _gridVelocity[_INDEX(i - 1, j)].x | ||
+ _gridVelocity[_INDEX(i, j + 1)].y - _gridVelocity[_INDEX(i, j - 1)].y) / N; | ||
_gridPressure[_INDEX(i, j)] = 0.0f; | ||
} | ||
} | ||
|
||
_setBoundary(_gridDivergence); | ||
_setBoundary(_gridPressure); | ||
|
||
for (int iter = 0; iter < 20; iter++) | ||
{ | ||
for (int i = 1; i <= N; i++) | ||
{ | ||
for (int j = 1; j <= N; j++) | ||
{ | ||
_gridPressure[_INDEX(i, j)] = | ||
( | ||
_gridDivergence[_INDEX(i, j)] - | ||
(_gridPressure[_INDEX(i + 1, j)] + _gridPressure[_INDEX(i - 1, j)] + | ||
_gridPressure[_INDEX(i, j + 1)] + _gridPressure[_INDEX(i, j - 1)]) | ||
) / -4.0f; | ||
} | ||
|
||
} | ||
_setBoundary(_gridPressure); | ||
} | ||
|
||
for (int i = 1; i <= N; i++) | ||
{ | ||
for (int j = 1; j <= N; j++) | ||
{ | ||
_gridVelocity[_INDEX(i, j)].x -= (_gridPressure[_INDEX(i + 1, j)] - _gridPressure[_INDEX(i - 1, j)]) * 0.5f * N; | ||
_gridVelocity[_INDEX(i, j)].y -= (_gridPressure[_INDEX(i, j + 1)] - _gridPressure[_INDEX(i, j - 1)]) * 0.5f * N; | ||
} | ||
} | ||
_setBoundary(_gridVelocity); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
#include "GridFluidSim.h" | ||
|
||
class EulerGasSim : public GridFluidSim | ||
{ | ||
public: | ||
EulerGasSim(float timeStep); | ||
~EulerGasSim() override; | ||
|
||
void update() override; | ||
|
||
private: | ||
|
||
void _force(); | ||
void _advect(); | ||
void _project(); | ||
}; | ||
|
Oops, something went wrong.