Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Apr 26, 2024
2 parents 5184183 + 374bfc5 commit 498ab79
Show file tree
Hide file tree
Showing 44 changed files with 555 additions and 173 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Further information and artwork:
An Nvidia graphics card with compute capability 6.0 or higher is needed. Please check [https://en.wikipedia.org/wiki/CUDA#GPUs_supported](https://en.wikipedia.org/wiki/CUDA#GPUs_supported).

# 💽 Installer
Installer for Windows: [alien-installer.msi](https://alien-project.org/media/files/alien-installer.msi) (Updated: 2024-03-16)
Installer for Windows: [alien-installer.msi](https://alien-project.org/media/files/alien-installer.msi) (Updated: 2024-04-22)

In the case that the program crashes for an unknown reason, please refer to the troubleshooting section in [alien-project.org/downloads.html](https://alien-project.org/downloads.html).

Expand Down Expand Up @@ -137,9 +137,10 @@ A short architectural overview of the source code can be found in the [documenta

ALIEN has been initiated, mainly developed and maintained by [Christian Heinemann](mailto:heinemann.christian@gmail.com). Thanks to all the others who contributed to this repository:
- [tlemo](https://github.com/tlemo)
- [TheBarret](https://github.com/TheBarret)
- [mpersano](https://github.com/mpersano)
- [dguerizec](https://github.com/dguerizec)
- [Will Allen](https://github.com/willjallen)
- [TheBarret](https://github.com/TheBarret)

The following external libraries are used:
- [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit)
Expand Down
11 changes: 11 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Release notes

## [4.9.1] - 2024-04-26
### Added
- gui/browser: label new simulations
- gui/browser: allow to replace simulations and genomes

### Changed
- gui/browser: ignore upper and lower case in the browser filter

### Fixed
- gui/browser: preserve subfolder names when renaming folders

## [4.9.0] - 2024-04-22
### Added
- engine, gui/simulation parameters: conditional and unconditional energy inflow from external energy source
Expand Down
2 changes: 1 addition & 1 deletion external/vcpkg
Submodule vcpkg updated 10499 files
2 changes: 2 additions & 0 deletions scripts/Server/helpers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
const MAX_MINUTES_FOR_INACTIVITY = 60;
const PUBLIC_WORKSPACE_TYPE = 0;
const ALIEN_PROJECT_WORKSPACE_TYPE = 1;
const PRIVATE_WORKSPACE_TYPE = 2;

function connectToDB()
Expand Down
21 changes: 15 additions & 6 deletions scripts/Server/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,23 @@ function sendDiscordMessage($payload) {
// functions for Discord messages
function createAddResourceMessage($type, $simName, $userName, $simDesc, $width, $height, $particles) {
if ($type == 0) {
return createAddSimulationMessage($simName, $userName, $simDesc, $width, $height, $particles);
return createMessageForSimulation("New simulation added to the database", $simName, $userName, $simDesc, $width, $height, $particles);
}
else {
return createAddGenomeMessage($simName, $userName, $simDesc, $width, $height, $particles);
return createMessageForGenome("New genome added to the database", $simName, $userName, $simDesc, $width, $height, $particles);
}
}

function createAddSimulationMessage($simName, $userName, $simDesc, $width, $height, $particles) {
function createUpdateResourceMessage($type, $simName, $userName, $simDesc, $width, $height, $particles) {
if ($type == 0) {
return createMessageForSimulation("Simulation updated in the database", $simName, $userName, $simDesc, $width, $height, $particles);
}
else {
return createMessageForGenome("Genome updated in the database", $simName, $userName, $simDesc, $width, $height, $particles);
}
}

function createMessageForSimulation($message, $simName, $userName, $simDesc, $width, $height, $particles) {
$particlesString = $particles < 1000 ? "{$particles}" : strval((int)($particles/1000)) . " K";
return json_encode([
"username" => "alien-project",
Expand All @@ -33,7 +42,7 @@ function createAddSimulationMessage($simName, $userName, $simDesc, $width, $heig
"embeds" => [
[
"author" => [
"name" => "New simulation added to the database",
"name" => $message,
"icon_url" => "https://alien-project.org/alien-server/galaxy.png"
],
"title" => $simName,
Expand All @@ -60,15 +69,15 @@ function createAddSimulationMessage($simName, $userName, $simDesc, $width, $heig
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}

function createAddGenomeMessage($simName, $userName, $simDesc, $width, $height, $particles) {
function createMessageForGenome($message, $simName, $userName, $simDesc, $width, $height, $particles) {
return json_encode([
"username" => "alien-project",
"avatar_url" => "https://alien-project.org/alien-server/logo.png",
"content" => "",
"embeds" => [
[
"author" => [
"name" => "New genome added to the database",
"name" => $message,
"icon_url" => "https://alien-project.org/alien-server/genome.png"
],
"title" => $simName,
Expand Down
69 changes: 69 additions & 0 deletions scripts/Server/replacesimulation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
require './helpers.php';
require './hooks.php';

function closeAndExit($db) {
echo json_encode(["result"=>false]);
$db->close();
exit;
}


$db = connectToDB();
$db->begin_transaction();

$userName = $_POST["userName"];
$pw = $_POST["password"];

if (!checkPw($db, $userName, $pw)) {
closeAndExit($db);
}

$obj = $db->query("SELECT u.ID as id FROM user u WHERE u.NAME='".addslashes($userName)."'")->fetch_object();
if (!$obj) {
closeAndExit($db);
}

$success = false;
$particles = (int)$_POST['particles'];
$version = $_POST['version'];
$width = (int)$_POST['width'];
$height = (int)$_POST['height'];
$content = $_POST['content'];
$settings = $_POST['settings'];
$simId = $_POST['simId'];
$size = strlen($content);
$statistics = array_key_exists('statistics', $_POST) ? $_POST['statistics'] : "";

$obj = $db->query("SELECT sim.NAME as name, sim.TYPE as type, sim.FROM_RELEASE as workspace FROM simulation sim WHERE sim.ID='".addslashes($simId)."'")->fetch_object();
if (!$obj) {
closeAndExit($db);
}

if ($userName != 'alien-project' && $obj->workspace == ALIEN_PROJECT_WORKSPACE_TYPE) {
closeAndExit($db);
}

$stmt = $db->prepare("UPDATE simulation SET PARTICLES=?, VERSION=?, CONTENT=?, WIDTH=?, HEIGHT=?, SETTINGS=?, SIZE=?, STATISTICS=?, CONTENT2=?, CONTENT3=?, CONTENT4=?, CONTENT5=?, CONTENT6=? WHERE ID=?");
if (!$stmt) {
closeAndExit($db);
}

$emptyString = '';
$stmt->bind_param("issiisissssssi", $particles, $version, $content, $width, $height, $settings, $size, $statistics, $emptyString, $emptyString, $emptyString, $emptyString, $emptyString, $simId);

if (!$stmt->execute()) {
closeAndExit($db);
}

// create Discord message
if ($obj->workspace != PRIVATE_WORKSPACE_TYPE) {
$discordPayload = createUpdateResourceMessage($obj->type, $obj->name, $userName, $simDesc, $width, $height, $particles);
sendDiscordMessage($discordPayload);
}

echo json_encode(["result"=>true]);

$db->commit();
$db->close();
?>
4 changes: 2 additions & 2 deletions source/Base/Cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ template<typename Key, typename Value, int MaxEntries>
class Cache
{
public:
void insert(Key const& key, Value const& value);
void insertOrAssign(Key const& key, Value const& value);

std::optional<Value> find(Key const& key);

Expand All @@ -21,7 +21,7 @@ class Cache
/* Implementation */
/************************************************************************/
template <typename Key, typename Value, int MaxEntries>
void Cache<Key, Value, MaxEntries>::insert(Key const& key, Value const& value)
void Cache<Key, Value, MaxEntries>::insertOrAssign(Key const& key, Value const& value)
{
if (_cacheMap.size() >= MaxEntries) {
_cacheMap.erase(_usedKeys.front());
Expand Down
29 changes: 21 additions & 8 deletions source/Base/GlobalSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void GlobalSettings::setDebugMode(bool value) const
_impl->_debugMode = value;
}

bool GlobalSettings::getBoolState(std::string const& key, bool defaultValue)
bool GlobalSettings::getBool(std::string const& key, bool defaultValue)
{
bool result;
#ifdef _WIN32
Expand All @@ -164,7 +164,7 @@ bool GlobalSettings::getBoolState(std::string const& key, bool defaultValue)
return result;
}

void GlobalSettings::setBoolState(std::string const& key, bool value)
void GlobalSettings::setBool(std::string const& key, bool value)
{
#ifdef _WIN32
setBoolToWinReg(key, value);
Expand All @@ -173,7 +173,7 @@ void GlobalSettings::setBoolState(std::string const& key, bool value)
#endif
}

int GlobalSettings::getIntState(std::string const& key, int defaultValue)
int GlobalSettings::getInt(std::string const& key, int defaultValue)
{
int result;
#ifdef _WIN32
Expand All @@ -184,7 +184,7 @@ int GlobalSettings::getIntState(std::string const& key, int defaultValue)
return result;
}

void GlobalSettings::setIntState(std::string const& key, int value)
void GlobalSettings::setInt(std::string const& key, int value)
{
#ifdef _WIN32
setIntToWinReg(key, value);
Expand All @@ -193,7 +193,7 @@ void GlobalSettings::setIntState(std::string const& key, int value)
#endif
}

float GlobalSettings::getFloatState(std::string const& key, float defaultValue)
float GlobalSettings::getFloat(std::string const& key, float defaultValue)
{
float result;
#ifdef _WIN32
Expand All @@ -204,7 +204,7 @@ float GlobalSettings::getFloatState(std::string const& key, float defaultValue)
return result;
}

void GlobalSettings::setFloatState(std::string const& key, float value)
void GlobalSettings::setFloat(std::string const& key, float value)
{
#ifdef _WIN32
setFloatToWinReg(key, value);
Expand All @@ -213,7 +213,7 @@ void GlobalSettings::setFloatState(std::string const& key, float value)
#endif
}

std::string GlobalSettings::getStringState(std::string const& key, std::string const& defaultValue)
std::string GlobalSettings::getString(std::string const& key, std::string const& defaultValue)
{
std::string result;
#ifdef _WIN32
Expand All @@ -224,7 +224,7 @@ std::string GlobalSettings::getStringState(std::string const& key, std::string c
return result;
}

void GlobalSettings::setStringState(std::string const& key, std::string value)
void GlobalSettings::setString(std::string const& key, std::string value)
{
#ifdef _WIN32
setStringToWinReg(key, value);
Expand All @@ -233,6 +233,19 @@ void GlobalSettings::setStringState(std::string const& key, std::string value)
#endif
}

std::vector<std::string> GlobalSettings::getStringVector(std::string const& key, std::vector<std::string> const& defaultValue)
{
auto joinedString = getString(key, boost::join(defaultValue, "\\"));
std::vector<std::string> result;
boost::split(result, joinedString, boost::is_any_of("\\"));
return result;
}

void GlobalSettings::setStringVector(std::string const& key, std::vector<std::string> value)
{
setString(key, boost::join(value, "\\"));
}

GlobalSettings::GlobalSettings()
{
_impl = std::make_shared<GlobalSettingsImpl>();
Expand Down
20 changes: 12 additions & 8 deletions source/Base/GlobalSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <memory>
#include <string>
#include <vector>

struct GlobalSettingsImpl;

Expand All @@ -16,17 +17,20 @@ class GlobalSettings
GlobalSettings(GlobalSettings const&) = delete;
void operator=(GlobalSettings const&) = delete;

bool getBoolState(std::string const& key, bool defaultValue);
void setBoolState(std::string const& key, bool value);
bool getBool(std::string const& key, bool defaultValue);
void setBool(std::string const& key, bool value);

int getIntState(std::string const& key, int defaultValue);
void setIntState(std::string const& key, int value);
int getInt(std::string const& key, int defaultValue);
void setInt(std::string const& key, int value);

float getFloatState(std::string const& key, float defaultValue);
void setFloatState(std::string const& key, float value);
float getFloat(std::string const& key, float defaultValue);
void setFloat(std::string const& key, float value);

std::string getStringState(std::string const& key, std::string const& defaultValue);
void setStringState(std::string const& key, std::string value);
std::string getString(std::string const& key, std::string const& defaultValue);
void setString(std::string const& key, std::string value);

std::vector<std::string> getStringVector(std::string const& key, std::vector<std::string> const& defaultValue);
void setStringVector(std::string const& key, std::vector<std::string> value);

private:
GlobalSettings();
Expand Down
4 changes: 2 additions & 2 deletions source/Base/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Const
{
std::string const ProgramVersion = "4.9.0";
std::string const DiscordLink = "https://discord.gg/7bjyZdXXQ2";
std::string const ProgramVersion = "4.9.1";
std::string const DiscordURL = "https://discord.gg/7bjyZdXXQ2";

std::string const BasePath = "resources/";

Expand Down
2 changes: 2 additions & 0 deletions source/Cli/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ int main(int argc, char** argv)
simController->newSimulation(simData.auxiliaryData.timestep, simData.auxiliaryData.generalSettings, simData.auxiliaryData.simulationParameters);
simController->setClusteredSimulationData(simData.mainData);
simController->setStatisticsHistory(simData.statistics);
simController->setRealTime(simData.auxiliaryData.realTime);
std::cout << "Device: " << simController->getGpuName() << std::endl;
std::cout << "Start simulation" << std::endl;

Expand All @@ -68,6 +69,7 @@ int main(int argc, char** argv)
simData.mainData = simController->getClusteredSimulationData();
simData.auxiliaryData.simulationParameters = simController->getSimulationParameters();
simData.statistics = simController->getStatisticsHistory().getCopiedData();
simData.auxiliaryData.realTime = simController->getRealTime();
if (outputFilename.empty()) {
std::cout << "No output file given." << std::endl;
return 1;
Expand Down
1 change: 0 additions & 1 deletion source/Gui/AlienImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,6 @@ bool AlienImGui::BasicSlider(Parameter const& parameters, T* value, bool* enable
}

//slider

T sliderValue;
T minValue = value[0], maxValue = value[0];
int sliderValueColor = 0;
Expand Down
4 changes: 2 additions & 2 deletions source/Gui/AlienWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ _AlienWindow::_AlienWindow(std::string const& title, std::string const& settings
: _title(title)
, _settingsNode(settingsNode)
{
_on = GlobalSettings::getInstance().getBoolState(settingsNode + ".active", defaultOn);
_on = GlobalSettings::getInstance().getBool(settingsNode + ".active", defaultOn);
}

_AlienWindow::~_AlienWindow()
{
GlobalSettings::getInstance().setBoolState(_settingsNode + ".active", _on);
GlobalSettings::getInstance().setBool(_settingsNode + ".active", _on);
}

void _AlienWindow::process()
Expand Down
4 changes: 2 additions & 2 deletions source/Gui/AutosaveController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ _AutosaveController::_AutosaveController(SimulationController const& simControll
: _simController(simController)
{
_startTimePoint = std::chrono::steady_clock::now();
_on = GlobalSettings::getInstance().getBoolState("controllers.auto save.active", true);
_on = GlobalSettings::getInstance().getBool("controllers.auto save.active", true);
}

_AutosaveController::~_AutosaveController()
{
GlobalSettings::getInstance().setBoolState("controllers.auto save.active", _on);
GlobalSettings::getInstance().setBool("controllers.auto save.active", _on);
}

void _AutosaveController::shutdown()
Expand Down
Loading

0 comments on commit 498ab79

Please sign in to comment.