From 7fcf5f816b90628f5d56a979f395222e3d93972f Mon Sep 17 00:00:00 2001 From: Robin van Grinsven Date: Wed, 9 Jul 2025 14:29:03 +0200 Subject: [PATCH] basis for project to upload to server. --- .ipynb_checkpoints/Untitled-checkpoint.ipynb | 6 ++ .ipynb_checkpoints/main-checkpoint.jl | 0 MakeFile | 45 ++++++++++++ Untitled.ipynb | 72 +++++++++++++++++++ datastructure.yaml | 42 +++++++++++ include/layers.hpp | 17 +++++ include/neighbours.hpp | 20 ++++++ include/plant_types.hpp | 19 +++++ include/plants.hpp | 14 ++++ include/weather.hpp | 20 ++++++ main.cpp | 26 +++++++ main.jl | 0 sim.db | Bin 0 -> 32768 bytes tables.db | 34 +++++++++ tests/tests.cpp | 1 + 15 files changed, 316 insertions(+) create mode 100644 .ipynb_checkpoints/Untitled-checkpoint.ipynb create mode 100644 .ipynb_checkpoints/main-checkpoint.jl create mode 100644 MakeFile create mode 100644 Untitled.ipynb create mode 100644 datastructure.yaml create mode 100644 include/layers.hpp create mode 100644 include/neighbours.hpp create mode 100644 include/plant_types.hpp create mode 100644 include/plants.hpp create mode 100644 include/weather.hpp create mode 100644 main.cpp create mode 100644 main.jl create mode 100644 sim.db create mode 100644 tables.db create mode 100644 tests/tests.cpp diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 0000000..363fcab --- /dev/null +++ b/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/.ipynb_checkpoints/main-checkpoint.jl b/.ipynb_checkpoints/main-checkpoint.jl new file mode 100644 index 0000000..e69de29 diff --git a/MakeFile b/MakeFile new file mode 100644 index 0000000..8a81dd8 --- /dev/null +++ b/MakeFile @@ -0,0 +1,45 @@ +TARGET_EXEC := sim + +BUILD_DIR := ./build +SRC_DIR := ./src +SHADER_DIR := ./shaders + +# Find all the C and C++ files we want to compile +SRCS := $(shell find $(SRC_DIR) -name '*.cpp') +GLSLS := $(shell find $(SHADER_DIR) -name '*.glsl') + +# Prepends BUILD_DIR and appends .o to every src file +OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) +SPIRVS := $(GLSLS:%.glsl=$(BUILD_DIR)/%.sphv) + +# String substitution (suffix version without %). +DEPS := $(OBJS:.o=.d) + +# Every folder in ./src will need to be passed to GCC so that it can find header files +INC_DIRS := $(shell find $(SRC_DIRS) -type d) +# Add a prefix to INC_DIRS. So moduleA would become -ImoduleA. GCC understands this -I flag +INC_FLAGS := $(addprefix -I,$(INC_DIRS)) + + +# The -MMD and -MP flags together generate Makefiles for us! +CPPFLAGS := $(INC_FLAGS) -MMD -MP + + + +# The final build step. +$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS) + $(CXX) $(OBJS) -o $@ $(LDFLAGS) + +# Build step for C++ source +$(BUILD_DIR)/%.cpp.o: %.cpp $(SPIRVS) .simdb + mkdir -p $(dir $@) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $i@ + +#build the shaders +$(SPIRVS): $(GLSL) + mkdir -p $(dir $@) + glslc $(shaders).glsl $(shaders).spv + + +run: $(BUILD_DIR)/$(TARGET_EXEC) + ./$(BUILD_DIR)/$(TARGET_EXEC) diff --git a/Untitled.ipynb b/Untitled.ipynb new file mode 100644 index 0000000..eaab18b --- /dev/null +++ b/Untitled.ipynb @@ -0,0 +1,72 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 4, + "id": "f6e13c4a-8200-4c09-b402-025fae57236f", + "metadata": {}, + "outputs": [ + { + "ename": "LoadError", + "evalue": "ArgumentError: Package FixedSizeArrays not found in current path.\n- Run `import Pkg; Pkg.add(\"FixedSizeArrays\")` to install the FixedSizeArrays package.", + "output_type": "error", + "traceback": [ + "ArgumentError: Package FixedSizeArrays not found in current path.\n- Run `import Pkg; Pkg.add(\"FixedSizeArrays\")` to install the FixedSizeArrays package.", + "" + ] + } + ], + "source": [ + "using FixedSizeArrays" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "251cbbae-41f5-4ef9-b16b-4fd63a07a126", + "metadata": {}, + "outputs": [ + { + "ename": "LoadError", + "evalue": "UndefVarError: `FixedSizeArray` not defined in `Main`\nSuggestion: check for spelling errors or missing imports.", + "output_type": "error", + "traceback": [ + "UndefVarError: `FixedSizeArray` not defined in `Main`\nSuggestion: check for spelling errors or missing imports.", + "", + "Stacktrace:", + " [1] top-level scope", + " @ In[3]:1" + ] + } + ], + "source": [ + "struct Ground \n", + " nurtrient::FixedSizeArray{Float32}(undef, (1000, 1000, 50))\n", + "end " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "83f4cd41-3b52-43ff-a536-3381d5fe1faa", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.11.3", + "language": "julia", + "name": "julia-1.11" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.11.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/datastructure.yaml b/datastructure.yaml new file mode 100644 index 0000000..85a5b98 --- /dev/null +++ b/datastructure.yaml @@ -0,0 +1,42 @@ +weather: + rain mm + rain nutrients + rain ph value + temperature + wind + oxigen + CO2 + humidity + ice + snow + +locations: + - + plant: + growth: float + type: string + moister: % #hoeveelheid vocht de plant heeft(hoe dicht bij het is bij uitdrogen) + Nutrienten: + onkruid: % + + + distance to neighbours: + - + neighbourID: + distance: float #locations are static so only need to know the distance between the squares + layers: + - + Compaction + H2O/water + organic life + dead organic mattter + Kalk + Roots + stones + +plantType: + - + type: + Moister release ratio + nurtrient absobertion capacity + GrowthShadowRatio diff --git a/include/layers.hpp b/include/layers.hpp new file mode 100644 index 0000000..b47d051 --- /dev/null +++ b/include/layers.hpp @@ -0,0 +1,17 @@ +#ifndef LAYERS_H_ +#define LAYERS_H_ + +struct Layer_s{ + unsigned int size; + unsigned int* location_index; + float* compaction; + float* H2O; + float* Organic_life; + float* Organic_dead; + float* Lime; + float* Roots; + float* Stone_volume; +} + + +#endif // LAYERS_H_ diff --git a/include/neighbours.hpp b/include/neighbours.hpp new file mode 100644 index 0000000..7484e8a --- /dev/null +++ b/include/neighbours.hpp @@ -0,0 +1,20 @@ +#ifndef NEIGHBOURS_H_ +#define NEIGHBOURS_H_ + +template +class Neighbours_s { + +private: + unsigned int size; + unsigned int[edge_ammount] location_index_A; + unsigned int[edge_ammount] location_index_B; + float[edge_ammount] distance; +}; + +struct neighbourloop{ + int[locations-1] till_next; + int[allNeighbours] distance; + int[allNeighbours] neighbour; +}; + +#endif // NEIGHBOURS_H_ diff --git a/include/plant_types.hpp b/include/plant_types.hpp new file mode 100644 index 0000000..119c044 --- /dev/null +++ b/include/plant_types.hpp @@ -0,0 +1,19 @@ +#ifndef PLANT_TYPES_H_ +#define PLANT_TYPES_H_ + +#include + +static class Plant_type_s{ +public: + void LoadIn(sqlite3 *db); +private: + unsigned int size; + char** name; + float* Moister_release_ratio; + float* Nutrient_absorbtion_cap; + float* Growth_Shadow_ratio; +}plant_types; + + + +#endif // PLANT_TYPES_H_ diff --git a/include/plants.hpp b/include/plants.hpp new file mode 100644 index 0000000..a204eb5 --- /dev/null +++ b/include/plants.hpp @@ -0,0 +1,14 @@ +#ifndef PLANTS_H_ +#define PLANTS_H_ + +struct Plant_s{ + unsigned int* location_index; + unsigned int* plant_type_index; + float* Growth; + float* Moister; + float* Nutrient; + float* Weeds; +}; + + +#endif // PLANTS_H_ diff --git a/include/weather.hpp b/include/weather.hpp new file mode 100644 index 0000000..275e41c --- /dev/null +++ b/include/weather.hpp @@ -0,0 +1,20 @@ +#ifndef WEATHER_H_ +#define WEATHER_H_ + +#include +class Weather{ +private: + float* rain; + float* rain_nutrient; + float* rain_ph; + float* temperature; + float* wind; + float* O2; + float* CO2; + float* H2O; + float* CH4; + float* N2; + float* airpressure; +}; + +#endif // WEATHER_H_ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..d00b30a --- /dev/null +++ b/main.cpp @@ -0,0 +1,26 @@ +// opencl +#include +// raylib +#include +// sqllite +#include + +#include "include/layers.hpp" + +int main(){ + // import data + sqlite3 *db; + + + + // setup opencl pipeline + + + + // setup raylib env + + + //while loop + // raylib thread (60fps) + // opencl sim (every 15 seconds) swap data every 15 seconds +} diff --git a/main.jl b/main.jl new file mode 100644 index 0000000..e69de29 diff --git a/sim.db b/sim.db new file mode 100644 index 0000000000000000000000000000000000000000..7dfcde828bdc0159eb4a466d4c7e8bef59b3896a GIT binary patch literal 32768 zcmeI#?{Aw%7zc1@Gn05q)xDUkDyn*kw87?UZAVFHb@3s zAWPkMZPWJk{TGmAc^z;wT@-9ZG+hDXFY@DWu#eOdmV+B$vH7k zPYkQuA!gs^$GzUe`r1}9ov~B=Q&^RaSY)m@BOqha;MJ zVIUi<(>I5<)#lTf&Dt3plY!MeXpON1j>$paGP;N6weyH& z92k~ic8npJH*b2byu-}S<~G$Hb244*Z_zsKu&#f2qG^rIP4(*OB1Bndi-xP!P-QLB zaCvUUsD#lzwfkL@cW`2uHuo^8&xmcj;89&fb{0R2jTw!ZmD08Bz?SRBjNUDpSvxnRMFUHiFG3jejrX27%dLw=_I ze*c!%cw+gf;_f&c^{009U<00Izz00bZa0SJf!c>fnQ za0~$mKmY;|fB*y_009U<00IzLP653CFK1k_DhNOT0uX=z1Rwwb2tWV=5P*Ov@GtrC B=i>kX literal 0 HcmV?d00001 diff --git a/tables.db b/tables.db new file mode 100644 index 0000000..fa40b8e --- /dev/null +++ b/tables.db @@ -0,0 +1,34 @@ +-- weather definition + +CREATE TABLE weather ( + rain_mm NUMERIC NOT NULL, + "day" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + rain_nutrient NUMERIC NOT NULL, + rain_ph NUMERIC DEFAULT (random() % 1 + 7) NOT NULL, + temperature NUMERIC NOT NULL, + WindSpeed NUMERIC NOT NULL, + O2 NUMERIC DEFAULT (0.21) NOT NULL, + CO2 NUMERIC DEFAULT (0.001) NOT NULL, + Humidity NUMERIC DEFAULT (random() % 100) NOT NULL, + CH4 NUMERIC NOT NULL, + N2 NUMERIC DEFAULT (.78) NOT NULL, + AirPressure NUMERIC NOT NULL, + CONSTRAINT weather_pk PRIMARY KEY ("day") +); +-- Locations definition + +CREATE TABLE Locations ( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + loc_x NUMERIC NOT NULL, + loc_y NUMERIC NOT NULL, + loc_z NUMERIC NOT NULL +); +-- Distance definition + +CREATE TABLE Distance ( + distance NUMERIC NOT NULL, + vecA INTEGER NOT NULL, + vecB INTEGER NOT NULL, + CONSTRAINT Distance_Locations_FK FOREIGN KEY (vecA) REFERENCES Locations(id), + CONSTRAINT Distance_Locations_FK_1 FOREIGN KEY (vecB) REFERENCES Locations(id) +); diff --git a/tests/tests.cpp b/tests/tests.cpp new file mode 100644 index 0000000..7e0b44b --- /dev/null +++ b/tests/tests.cpp @@ -0,0 +1 @@ +#include "tests.h"