starting with some basic types
This commit is contained in:
parent
e16a939473
commit
470033c01e
14
build.bat
Normal file
14
build.bat
Normal file
@ -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
|
||||||
|
|
||||||
6
odinfmt.json
Normal file
6
odinfmt.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"character_width": 90,
|
||||||
|
"tabs": false,
|
||||||
|
"tabs_width": 2,
|
||||||
|
"spaces": 2
|
||||||
|
}
|
||||||
11
ols.json
Normal file
11
ols.json
Normal file
@ -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" }}
|
||||||
|
]
|
||||||
|
}
|
||||||
10
run.bat
Normal file
10
run.bat
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
pushd build
|
||||||
|
del /F /Q *
|
||||||
|
@echo on
|
||||||
|
odin run -verbose ../src/ -out:femodin.exe
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
popd
|
||||||
|
|
||||||
57
src/main.odin
Normal file
57
src/main.odin
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user