diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..7b272a2 --- /dev/null +++ b/build.bat @@ -0,0 +1,14 @@ +@echo off + +if "%~1"=="run" ( + set buildcmd=run +) else ( + set buildcmd=build +) + +pushd build +del /F /Q * +odin %buildcmd% ../src/ -keep-executable -out:femodin.exe + +popd + diff --git a/odinfmt.json b/odinfmt.json new file mode 100644 index 0000000..b8afd63 --- /dev/null +++ b/odinfmt.json @@ -0,0 +1,6 @@ +{ + "character_width": 90, + "tabs": false, + "tabs_width": 2, + "spaces": 2 +} diff --git a/ols.json b/ols.json new file mode 100644 index 0000000..2e6bc5d --- /dev/null +++ b/ols.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/ols.schema.json", + "enable_semantic_tokens": false, + "enable_document_symbols": true, + "enable_hover": true, + "enable_snippets": true, + "profile": "default", + "profiles": [ + { "name": "windows_profile", "os": "windows", "checker_path": ["src"], "defines": { "ODIN_DEBUG": "false" }} + ] +} diff --git a/run.bat b/run.bat new file mode 100644 index 0000000..d60ad6d --- /dev/null +++ b/run.bat @@ -0,0 +1,10 @@ +@echo off + +pushd build +del /F /Q * +@echo on +odin run -verbose ../src/ -out:femodin.exe +@echo off + +popd + diff --git a/src/main.odin b/src/main.odin new file mode 100644 index 0000000..2a0f8b3 --- /dev/null +++ b/src/main.odin @@ -0,0 +1,57 @@ +package main + +import "core:fmt" + +// -------------------------------------------------------------------------------------// +// We use the built in array for general vectors +VecF32 :: []f32 + +vec_make_f32 :: proc(n: i32, allocator := context.allocator) -> VecF32 { + return make([]f32, n, allocator) +} + +// But we need our custom format for matrices. +// We will use col-major storage. +MatF32 :: struct { + data: []f32, + rows: i32, + cols: i32, +} + +mat_make_f32 :: proc(nrows: i32, ncols: i32, allocator := context.allocator) -> MatF32 { + out: MatF32 + out.data = make([]f32, nrows * ncols, allocator) + out.rows = nrows + out.cols = ncols + return out +} + +mat_get_f32 :: proc(m: MatF32, i: i32, j: i32) -> f32 { + return m.data[j * m.rows + i] +} + +mat_set_f32 :: proc(m: ^MatF32, i: i32, j: i32, val: f32) { + m.data[j * m.rows + i] = val +} + +// -------------------------------------------------------------------------------------// + + +main :: proc() { + + fmt.println("Program start. Running some simple FEM problem in 1D.") + + x_start: f32 = 0.0 + x_end: f32 = 1.0 + num_elements: i32 = 100 + num_nodes := num_elements + 1 + dx := (x_end - x_start) / cast(f32)num_elements + + x_axis := vec_make_f32(num_nodes) + for i in 0 ..< num_nodes { + x_axis[i] = cast(f32)i * (dx) + } + + +} +