Coder Social home page Coder Social logo

angelsolaorbaiceta / inkfem Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 0.0 1.53 MB

2D Finite Element Method structural analysis CLI application.

Home Page: https://www.inkstructure.com/

License: GNU General Public License v3.0

Go 99.04% Shell 0.53% Makefile 0.43%
structural-analysis fem finite-element-methods

inkfem's Introduction

inkFEM

2D structural analysis program using the Finite Element Method.

Usage

Structures are defined following the .inkfem input file format. To calculate a structure defined in a .inkfem file:

$ inkfem solve path/to/structure.inkfem

If the structural analysis process doesn't encounter any error, it'll produce a solution file inside the same directory as the input file with the same name but .inkfemsol extension. In the example above, this would be structure.inkfemsol.

To also write the sliced (preprocessed) structure to a file, you can provide the -p flag:

$ inkfem solve path/to/structure.inkfem -p

This will generate an additional file with the .inkfempre extension containing the information about how the structure has been sliced into finite elements.

Available Flags

Flag Type Description Required Default
verbose or -v bool use verbose output, including elapsed times no false
preprocess or -p bool save the preprocessed structure into a .inkfempre file no false
safe or -s bool perform some extra safety checks before proceeding with the resolution no false
error or -e float maximum displacement error allowed in the resolution no 1e-5
weight or -w bool include the own weight of the bars no false

Build & Test

To build the inkfem binary:

$ make build

This creates the inkfem binary at the project's top level. See the Usage section below to learn how to execute the binary program.

To run the tests:

$ make test

Docs

Code Structure

The code is split into four main packages:

  • structure: defines the structure model
  • preprocess: implements the preprocessing or slicing of the structure
  • process: implements the processing of a sliced/preprocessed structure
  • io: reading from .inkfem files and writing to .inkfempreand .inkfemsol files
  • plot: drawing SVG files from the .inkfem, .inkfempreand .inkfemsol files
  • cmd: the commands available to the CLI

inkfem's People

Contributors

angelsolaorbaiceta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

inkfem's Issues

Bars own weight as part of the structure definition. Remove `ReaderOptions`.

Summary

There is a reader options parameter used to read a structure file.
The only parameter in the ReaderOptions is ShouldIncludeOwnWeight:

package io

type ReaderOptions struct {
	ShouldIncludeOwnWeight bool
}

The user shouldn't remember whether a given structure was preprocessed including the weight of the bars as distributed loads.
Ideally, this should be part of the preprocessed structure definition: the .inkfempre file.

Proposed Solution

This proposal will change the .inkfempre file format to include this new flag: include_own_weight.
This parameter can be yes or no (if not present, no will be assumed).

    inkfem v1.1

    dof_count: 33
++  includes_own_weight: yes

    |nodes|
    1 -> 0.0 0.0 {dx dy rz}
    2 -> 100.0 0.0 {}

    ...

Between the header inkfem v1.1 and the definition of the structural elements (|nodes|, |bars|, ...) the section where the dof_count is defined will be used.
The general syntax for a flag in this section is:

tag_name: tag_value

Where tag_value is an arbitrary string which can have spaces, but tag_name can't have spaces and thus uses snake_case.
The colon separates the tag name from the value.

Analysis

The function:

func readStructureFromFile(filePath string, readerOptions io.ReaderOptions) *structure.Structure

shouldn't accept a ReaderOptions parameter, as the information of whether the structure should be preprocessed including its own weight should be a separate process of reading a structure file.

InkFEM execution failure

Describe the bug
The structure definition below makes the program crash:

inkfem v1.0
|nodes| 24
bd579763-0516-42ee-85b1-c10c8a1825f7 -> 0 0 { }
900efbe6-7d03-49da-bba7-cdab712382f2 -> 400 0 { }
70c19a27-9344-4821-800c-1bc3abdee97e -> 800 0 { }
945bdc90-80ba-420d-8d08-81c78b69a2a3 -> 1200 0 { }
56a1570c-bdf2-4e45-9677-2f5147025c9c -> 1600 0 { }
1fe553d3-ba03-47e9-a47b-4d0dec12afa1 -> 2000 0 { }
14927ec6-d22c-4eca-8215-9883b86206a7 -> 0 300 { }
94f9d1da-b228-4112-b7cd-dff860d79d4e -> 400 300 { }
b7690000-b638-4c75-8fa8-a5d5fe9dc8dd -> 800 300 { }
7c190cfb-5744-43a5-a7b7-c480d6ad3f9e -> 1200 300 { }
d17c62f1-94eb-4d6a-9b20-01dbeb368be0 -> 1600 300 { }
6433e520-b93f-43c2-8262-387e94a8173a -> 2000 300 { }
a6e6419d-ac2f-41e2-9501-dcaa47f21890 -> 0 600 { }
ad713a9f-9c39-484d-a3b7-e8d785bb9b89 -> 400 600 { }
98144faf-801d-404e-89d2-9f5f84f21990 -> 800 600 { }
a47de59d-ce6f-4be4-9021-520c53e96154 -> 1200 600 { }
752dc797-56a1-4b07-ba78-1ab59aa5107d -> 1600 600 { }
21e728c6-8bf7-452f-a03a-b5d49b7c7e3f -> 2000 600 { }
f46aeebb-264c-4026-b4e8-600d60fc0692 -> 0 900 { }
f6499d8b-327b-4bc0-ace0-45010d552544 -> 400 900 { }
9ca3a63d-7c9d-4359-b3c6-6b7d42e22c41 -> 800 900 { }
8bba6aaf-c93b-479e-874e-dbb604e5f0ac -> 1200 900 { }
e9e397a5-c7e6-4317-80f4-5497208ddbc8 -> 1600 900 { }
173f8229-212b-4266-ae6c-5ad1f545a839 -> 2000 900 { }
|materials| 1
'steel' -> 1 20000000 1 1 25000 40000
|sections| 1
'ipe 120' -> 14 318 28 53 9
|loads| 0
|bars| 33
3986398e-edff-43e2-803e-4856777d375b -> bd579763-0516-42ee-85b1-c10c8a1825f7{ dx dy rz } 14927ec6-d22c-4eca-8215-9883b86206a7{ dx dy rz } 'steel' 'ipe 120'
955bb894-2507-402d-93c9-16beee76c9ad -> 900efbe6-7d03-49da-bba7-cdab712382f2{ dx dy rz } 94f9d1da-b228-4112-b7cd-dff860d79d4e{ dx dy rz } 'steel' 'ipe 120'
542f3507-5a71-4b80-85a0-9540686019bd -> 70c19a27-9344-4821-800c-1bc3abdee97e{ dx dy rz } b7690000-b638-4c75-8fa8-a5d5fe9dc8dd{ dx dy rz } 'steel' 'ipe 120'
0c177920-8e8f-4b18-b8a2-e9ab542ceca6 -> 945bdc90-80ba-420d-8d08-81c78b69a2a3{ dx dy rz } 7c190cfb-5744-43a5-a7b7-c480d6ad3f9e{ dx dy rz } 'steel' 'ipe 120'
bd2cc4f2-fbf7-426a-9697-4f60ae50efdb -> 56a1570c-bdf2-4e45-9677-2f5147025c9c{ dx dy rz } d17c62f1-94eb-4d6a-9b20-01dbeb368be0{ dx dy rz } 'steel' 'ipe 120'
32f3613f-5c3a-4c61-9d4b-5adc064661f4 -> 1fe553d3-ba03-47e9-a47b-4d0dec12afa1{ dx dy rz } 6433e520-b93f-43c2-8262-387e94a8173a{ dx dy rz } 'steel' 'ipe 120'
fbc90825-8ac0-487d-8bc9-e4d3c6574e49 -> 14927ec6-d22c-4eca-8215-9883b86206a7{ dx dy rz } a6e6419d-ac2f-41e2-9501-dcaa47f21890{ dx dy rz } 'steel' 'ipe 120'
35bef438-818b-4b42-aeb0-4023fbd47565 -> 94f9d1da-b228-4112-b7cd-dff860d79d4e{ dx dy rz } ad713a9f-9c39-484d-a3b7-e8d785bb9b89{ dx dy rz } 'steel' 'ipe 120'
f2d3839f-d1f0-40f0-b285-be03430c72fd -> b7690000-b638-4c75-8fa8-a5d5fe9dc8dd{ dx dy rz } 98144faf-801d-404e-89d2-9f5f84f21990{ dx dy rz } 'steel' 'ipe 120'
37c80946-ece5-48ba-abf1-ec5e3c06ae20 -> 7c190cfb-5744-43a5-a7b7-c480d6ad3f9e{ dx dy rz } a47de59d-ce6f-4be4-9021-520c53e96154{ dx dy rz } 'steel' 'ipe 120'
d41cfaec-5780-476a-b8fc-3fd0c0058187 -> d17c62f1-94eb-4d6a-9b20-01dbeb368be0{ dx dy rz } 752dc797-56a1-4b07-ba78-1ab59aa5107d{ dx dy rz } 'steel' 'ipe 120'
90748a1c-67ad-4f57-8890-7eabe8a700cf -> 6433e520-b93f-43c2-8262-387e94a8173a{ dx dy rz } 21e728c6-8bf7-452f-a03a-b5d49b7c7e3f{ dx dy rz } 'steel' 'ipe 120'
948aad9a-cd24-4d6c-93d5-49ee95b2c481 -> a6e6419d-ac2f-41e2-9501-dcaa47f21890{ dx dy rz } f46aeebb-264c-4026-b4e8-600d60fc0692{ dx dy rz } 'steel' 'ipe 120'
6fe6e33e-263f-46a8-afe9-599642cc407a -> ad713a9f-9c39-484d-a3b7-e8d785bb9b89{ dx dy rz } f6499d8b-327b-4bc0-ace0-45010d552544{ dx dy rz } 'steel' 'ipe 120'
c8ef93b1-e447-4b1f-89df-7ce3d0cad5d5 -> 98144faf-801d-404e-89d2-9f5f84f21990{ dx dy rz } 9ca3a63d-7c9d-4359-b3c6-6b7d42e22c41{ dx dy rz } 'steel' 'ipe 120'
dc0289dd-564a-415a-a31f-f82094c77b70 -> a47de59d-ce6f-4be4-9021-520c53e96154{ dx dy rz } 8bba6aaf-c93b-479e-874e-dbb604e5f0ac{ dx dy rz } 'steel' 'ipe 120'
3e32543a-db01-4338-84d0-c3071ba8fad5 -> 752dc797-56a1-4b07-ba78-1ab59aa5107d{ dx dy rz } e9e397a5-c7e6-4317-80f4-5497208ddbc8{ dx dy rz } 'steel' 'ipe 120'
03b2f7f1-abbf-4ec6-97eb-d818423f89e5 -> 21e728c6-8bf7-452f-a03a-b5d49b7c7e3f{ dx dy rz } 173f8229-212b-4266-ae6c-5ad1f545a839{ dx dy rz } 'steel' 'ipe 120'
c6cdca28-7bf8-4d6e-84e3-d67a37b4dc03 -> 14927ec6-d22c-4eca-8215-9883b86206a7{ dx dy rz } 94f9d1da-b228-4112-b7cd-dff860d79d4e{ dx dy rz } 'steel' 'ipe 120'
53e18d65-816e-4997-a244-dace9a5ec952 -> 94f9d1da-b228-4112-b7cd-dff860d79d4e{ dx dy rz } b7690000-b638-4c75-8fa8-a5d5fe9dc8dd{ dx dy rz } 'steel' 'ipe 120'
3936ea88-a481-4b26-9060-f1fd47f74764 -> b7690000-b638-4c75-8fa8-a5d5fe9dc8dd{ dx dy rz } 7c190cfb-5744-43a5-a7b7-c480d6ad3f9e{ dx dy rz } 'steel' 'ipe 120'
df5a39e3-af87-4dc3-9cf5-98a1b32eea18 -> 7c190cfb-5744-43a5-a7b7-c480d6ad3f9e{ dx dy rz } d17c62f1-94eb-4d6a-9b20-01dbeb368be0{ dx dy rz } 'steel' 'ipe 120'
22cf1635-8a3a-4878-8cb0-8dca2d4025b2 -> d17c62f1-94eb-4d6a-9b20-01dbeb368be0{ dx dy rz } 6433e520-b93f-43c2-8262-387e94a8173a{ dx dy rz } 'steel' 'ipe 120'
f859b356-d0fe-4f4f-abc2-8bcbeff52cc4 -> a6e6419d-ac2f-41e2-9501-dcaa47f21890{ dx dy rz } ad713a9f-9c39-484d-a3b7-e8d785bb9b89{ dx dy rz } 'steel' 'ipe 120'
22bf25e2-4992-4117-8974-6b98d353e605 -> ad713a9f-9c39-484d-a3b7-e8d785bb9b89{ dx dy rz } 98144faf-801d-404e-89d2-9f5f84f21990{ dx dy rz } 'steel' 'ipe 120'
dc5fb190-c4f2-455e-a247-2dce43c60160 -> 98144faf-801d-404e-89d2-9f5f84f21990{ dx dy rz } a47de59d-ce6f-4be4-9021-520c53e96154{ dx dy rz } 'steel' 'ipe 120'
4756b3a5-0a78-458c-a791-40ccaa6be8d8 -> a47de59d-ce6f-4be4-9021-520c53e96154{ dx dy rz } 752dc797-56a1-4b07-ba78-1ab59aa5107d{ dx dy rz } 'steel' 'ipe 120'
8f3e89f8-0137-4ece-aff1-b3a61ddac3b2 -> 752dc797-56a1-4b07-ba78-1ab59aa5107d{ dx dy rz } 21e728c6-8bf7-452f-a03a-b5d49b7c7e3f{ dx dy rz } 'steel' 'ipe 120'
3e8651ac-74c7-47b0-b8f8-92135670ea7b -> f46aeebb-264c-4026-b4e8-600d60fc0692{ dx dy rz } f6499d8b-327b-4bc0-ace0-45010d552544{ dx dy rz } 'steel' 'ipe 120'
6fb99621-72d1-4f4d-a58d-bf1982998cd2 -> f6499d8b-327b-4bc0-ace0-45010d552544{ dx dy rz } 9ca3a63d-7c9d-4359-b3c6-6b7d42e22c41{ dx dy rz } 'steel' 'ipe 120'
db74815c-a91c-485e-b44c-bb33870e5023 -> 9ca3a63d-7c9d-4359-b3c6-6b7d42e22c41{ dx dy rz } 8bba6aaf-c93b-479e-874e-dbb604e5f0ac{ dx dy rz } 'steel' 'ipe 120'
c313f83f-4377-4da5-b5e1-f5b96e1bae50 -> 8bba6aaf-c93b-479e-874e-dbb604e5f0ac{ dx dy rz } e9e397a5-c7e6-4317-80f4-5497208ddbc8{ dx dy rz } 'steel' 'ipe 120'
8c34b3d7-6401-4f34-87c2-d5d56badda33 -> e9e397a5-c7e6-4317-80f4-5497208ddbc8{ dx dy rz } 173f8229-212b-4266-ae6c-5ad1f545a839{ dx dy rz } 'steel' 'ipe 120'

To Reproduce
Steps to reproduce the behavior:

  1. Execute the binary: inkfem -i path/to/file

Expected behavior
Either:

  • The structure is calculated and the solution file generated
  • The error in the file is reported with precision, so that I can fix the issue

Got Error
This is the error outputted by the program:

stderr: panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x114edc4]

goroutine 1 [running]:
github.com/angelsolaorbaiceta/inkfem/io.parseStructure(0xc0000c1d08, {0x44})
	/Users/angelsolaorbaiceta/go/src/github.com/angelsolaorbaiceta/inkfem/io/reader.go:131 +0x6c4
github.com/angelsolaorbaiceta/inkfem/io.StructureFromFile({0x7ffeefbfd298, 0x35}, {0xf})
	/Users/angelsolaorbaiceta/go/src/github.com/angelsolaorbaiceta/inkfem/io/reader.go:39 +0x145
main.readStructureFromFile({0x7ffeefbfd298, 0x44}, {0x40})
	/Users/angelsolaorbaiceta/go/src/github.com/angelsolaorbaiceta/inkfem/inkfem.go:60 +0x6a
main.main()
	/Users/angelsolaorbaiceta/go/src/github.com/angelsolaorbaiceta/inkfem/inkfem.go:37 +0x16e

Look for updates in the `-v` of the root command

Using GitHub's API, check for the latest label and if it's greater than the current build numbers, display the information:

New version available: vM.n (current one is vM.m)
Find it at: https://inkstructure.com/download

Calculate reactions

Calculate the reaction forces in those nodes that are externally constrained.

The solution file (*.inkfemsol) should contain a new section for the reaction torsors in global coordinates:

|reactions| <count>
<node_id> -> <fx> <fy> <fz>

Read solution file

Reader for the .inkfemsol file format to plot the results with the plot command.

Definition writer

Implement a writer for .inkfem files.
This writer can be used to save definition files resulting from the generate command.

`pre` command

The pre command can be used to preprocess a structure model.

Then, the solve command should accept both .inkfem definition files or .inkfempre preprocessed files.
In the second case, it shouldn't repeat the preprocessing step.

Add own weight loads

Elements can add a linear distributed load for their own weight.
CLI should add a new flag to allow this.

Torsor

Create a Torsor struct representing the torsor of the fx, fy and mz components.

(io) Loads format

The loads format in the input .inkfem files is hard to read.
For example, the following distributed load:

fy ld 1 0.0 -200.0 1.0 0.0

could be better written as:

fy ld 1 -> (0.0 -200.0) (1.0 0.0)

Preprocess reader should read DOF numbers

The preprocess Read() function doesn't use the DOF numbers in the file, but reassigns them when the file is read.

func Read(reader io.Reader) *preprocess.Structure {
        // ... //

	return preprocess.MakeStructure(
		metadata,
		structure.MakeNodesById(nodes),
		bars,
		includesOwnWeight,
	).SetDofsCount(numberOfDof) // TODO: should read the DOFs from the file, not reassign them
}

Read preprocessed file

Reader for the .inkfempre format.
These .inkfempre files must have all the information required for them to be read independently without the need of the original structure definition that produced them.

`generate` command

Create a new command: generate.
This command should generate .infem files with different configurations:

  • reticular structures (square grid)
  • trusses: Howe, Pratt, Warren...

Read version from VERSION file

When the binary is executed with the -v flag: inkfem -v, read the version from the VERSION file and output it to the standard output without doing anything else.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.