Skip to content

Commit

Permalink
Merge pull request #112 from eric2003/hexin
Browse files Browse the repository at this point in the history
Hexin
  • Loading branch information
eric2003 authored Jul 19, 2024
2 parents 54602f2 + ff442e0 commit e445140
Show file tree
Hide file tree
Showing 11 changed files with 1,051 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modern-cfd/README.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake ../ -D CMAKE_TOOLCHAIN_FILE="c:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"
cmake .. -D CMAKE_PREFIX_PATH:PATH=C:/local/Qt/6.3.2/msvc2019_64/
cmake .. -D CMAKE_PREFIX_PATH:PATH=C:/local/Qt/Qt6.4.0/6.4.0/msvc2019_64/
cmake .. -D CMAKE_PREFIX_PATH:PATH=C:/local/Qt/6.7.2/msvc2019_64/
c:\local\Qt\6.7.2\
c:\local\Qt\Qt6.4.0\
cmake --build .
C:\local\Qt\6.3.2\msvc2019_64\bin\windeployqt.exe .\Debug\testprj.exe
Expand Down
76 changes: 76 additions & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
cmake_minimum_required(VERSION 3.29)

project(ModernCFD VERSION 0.1.0)

set ( PRJ_COMPILE_FEATURES )
set ( PRJ_COMPILE_DEFINITIONS )
set ( PRJ_LIBRARIES )
set ( PRJ_INCLUDE_DIRS )

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

find_package(Qt6 REQUIRED COMPONENTS Widgets)

list ( APPEND PRJ_LIBRARIES Qt6::Widgets )
list ( APPEND PRJ_COMPILE_FEATURES cxx_std_23 )

if ( MSVC )
set_property( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME} )
endif()

set( PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
CfdThread.h CfdThread.cpp
Terminal.h Terminal.cpp
terminal.ui
)

set( PRJ_SOURCES )
foreach(source ${PROJECT_SOURCES})
list( APPEND PRJ_SOURCES "codes/${source}" )
endforeach()

foreach(source ${PRJ_SOURCES})
#message( STATUS "source=${source}" )
endforeach()

add_executable( ${PROJECT_NAME}
)

target_sources( ${PROJECT_NAME}
PRIVATE
${PRJ_SOURCES}
)

target_include_directories ( ${PROJECT_NAME}
PRIVATE
${PRJ_INCLUDE_DIRS}
)

target_link_libraries( ${PROJECT_NAME}
PRIVATE
${PRJ_LIBRARIES}
)

target_compile_features ( ${PROJECT_NAME}
PRIVATE
${PRJ_COMPILE_FEATURES}
)

target_compile_definitions ( ${PROJECT_NAME}
PRIVATE
${PRJ_COMPILE_DEFINITIONS}
)

include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
43 changes: 43 additions & 0 deletions tools/codes/CfdThread.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "CfdThread.h"
#include <QTime>
#include <thread>
#include <iostream>

CfdThread::CfdThread()
{
this->paused = false;
this->stop = false;
}

void CfdThread::beginCFD()
{
this->paused = false;

}

void CfdThread::pauseCFD()
{
this->paused = true;
}

void CfdThread::stopCFD()
{
this->stop = true;
}

void CfdThread::run()
{
download( "CfdThread::run()" );
}

void CfdThread::download(const std::string &file)
{
for ( int i = 0; i < 10; ++ i )
{
if ( this->stop ) break;
std::cout << "Downloading " << file
<< " (" << i * 10 << "%)..." << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
std::cout << "Download complete: " << file << std::endl;
}
24 changes: 24 additions & 0 deletions tools/codes/CfdThread.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <QObject>
#include <QThread>

class CfdThread : public QThread
{
Q_OBJECT
public:
CfdThread();
public:
void beginCFD();
void pauseCFD();
void stopCFD();
private:
void download( const std::string & file );
signals:
void newValue(int seq, int diceValue);
protected:
void run() override;
private:
bool stop = false;
bool paused = false;
};
Loading

0 comments on commit e445140

Please sign in to comment.