io

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

README

Input File Format

The structure input file defines the structure to be analyzed. The calculation engine is unit-agnostic, so the units used as input are also the output units. Units need, nevertheless, to be congruent.

The input file should be a plain-text file with the .inkfem extension. Inside the file, the first line should include the header:

inkfem vM.m

where M and m are the major and minor versions of the binary used to compute the structure. The current version is 1.1:

inkfem v1.1

Then go the definition sections:

  • nodes: the structure nodes, referred by id
  • sections: the element's sections, referred by name
  • materials: the element's materials, referred by name
  • loads: the loads applied to the nodes and elements
  • bars: the structure bars (linear resistant elements), referred by id

The sections can appear in any order.

The Nodes

The nodes are defined under the header:

|nodes|

Each node is defined following the format:

<id> -> <xCoord> <yCoord> {[dx dy rz]}

where:

  • id: the node's unique id
  • xCoord: the node's position x-coordinate
  • yCoord: the node's position y-coordinate
  • {dx dy rz}: set of externally constrained degrees of freedom
Examples

Node with id 23, at position (120, 450) and no external constraints:

23 -> 120.0 450.0 { }

Node with id 48, at position (300, 50) and the displacement in the x and y directions externally constrained:

48 -> 300.0 50.0 { dx dy }

The Materials

The materials are defined under the header:

|materials|

Each material is defined following the format:

<name> -> <density> <young> <shear> <poisson> <yield> <ultimate>

where:

  • name: the material's unique name
  • density: the material's density
  • young: the material's Young or elasticity modulus
  • shear: the material's shear modulus
  • poisson: the material's poisson ratio
  • yield: the material's yield strength
  • ultimate: the material's ultimate strength
Examples

Standard steel 275:

'steel_275' -> 0.00000785 21000000.0 8100000.0 0.3 27500.0 43000.0

The Sections

The sections are defined under the header:

|sections|

Each section is defined following the format:

<name> -> <area> <iStrong> <iWeak> <sStrong> <sWeak>

where:

  • name: the section's unique name
  • area: the section's cross section area
  • iStrong: the strong axis' moment of inertia
  • iWeak: the weak axis' moment of inertia
  • sStrong: the strong axis' section modulus
  • sWeak: the weak axis' section modulus
Examples

Standard European IPE-100 section:

'ipe_100' -> 10.3 171.0 15.92 34.2 5.79

The Loads

The loads are defined under the header:

|loads|

There are two types of loads:

  • Distributed
  • Concentrated

Both types are applied to bars. To define a concentrated load on a node, choose a bar which contains the node, and add the concentrated load to that bar at position t = 0 (start node) or t = 1 (end node).

Distributed loads are defined following the format:

<term> <reference><type> <barId> <tStart> <valueStart> <tEnd> <valueEnd>

where:

  • term: is either:
    • fx: force in the x-axis direction
    • fy: force in the y-axis direction
    • mz: moment about the z-axis
  • reference: the reference frame in which the load is defined. Can be:
    • l: reference frame local to the bar
    • g: global reference frame
  • type: must be d to signify this is a distributed load
  • barId: The id of the bar where the load is applied
  • tStart: the load start position in the bar's directrix (0 <= t <= 1)
  • valueStart: the value for the load at tStart
  • tEnd: the load end position in the bar's directrix (tStart <= t <= 1)
  • valueEnd: the value for the load at tEnd

Distributed loads are always linear: they have a start and end value, and those values are linearly interpolated. The current implementation doesn't allow any other kind of distributed load interpolation.

Examples (Distributed)

A distributed force in the bar's local y-axis direction, applied to a bar with id 4, starting at t = 0 with value -50 and ending at t = 1 with value -75.

fy ld 4 0.0 -50.0 1.0 -75.0

A distributed moment about the global z-axis, applied to a bar with id 12, starting at t = 0.25 with value 100 and ending at t = 0.75 with value 200.

mz gd 12 0.25 100 0.75 200

Concentrated loads are defined following the format:

<term> <reference><type> <elementId> <t> <value>

where:

  • term: is either:
    • fx: force in the x-axis direction
    • fy: force in the y-axis direction
    • mz: moment about the z-axis
  • reference: the reference frame in which the load is defined. Can be:
    • l: reference frame local to the bar
    • g: global reference frame
  • type: must be c to signify this is a concentrated load
  • elementId: The if of the bar where the load is applied
  • t: the load position in the bar's directrix (0 <= t <= 1)
  • value: the load's value
Examples (Concentrated)

A concentrated force in the element with id 11 local y-axis direction, at position t = 0 (applied in the start node), with value -70.

fy lc 11 0.0 -70.0

The Bars

The bars are defined under the header:

|bars|

Each bar is defined following the format:

Input File Example

Here's a complete input file example:

inkfem v1.1

|nodes|
1 -> 0 0 {dx dy}
2 -> 200 300 {}
3 -> 400 0 {}
4 -> 600 300 {}
5 -> 800 0 {dx dy}

|materials|
'mat_A' -> 1.0 1.0 1.0 1.0 1.0 1.0

|sections|
'sec_A' -> 1.0 1.0 1.0 1.0 1.0

|loads|
fy ld 4 0.0 -50.0 1.0 -75.0

|bars|
1 -> 1{dx dy rz} 2{dx dy rz} 'mat_A' 'sec_A'
2 -> 1{dx dy rz} 3{dx dy rz} 'mat_A' 'sec_A'
3 -> 2{dx dy rz} 3{dx dy rz} 'mat_A' 'sec_A'
4 -> 2{dx dy rz} 4{dx dy rz} 'mat_A' 'sec_A'
5 -> 3{dx dy rz} 4{dx dy rz} 'mat_A' 'sec_A'
6 -> 3{dx dy rz} 5{dx dy rz} 'mat_A' 'sec_A'
7 -> 4{dx dy rz} 5{dx dy rz} 'mat_A' 'sec_A'

Preprocess File Format

The preprocessed structure is saved into a .inkfempre file if the -p flag is passed to inkfem. The file's template is defined in preprocess.template.txt.

Solution File Format

The solution structure is saved into a .inkfemsol file. The file's template is defined in solution.template.txt.

Documentation

Index

Constants

View Source
const (
	OptionalSpaceExpr       = `\s*`
	SpaceExpr               = `\s+`
	NameGrpName             = "name"
	NameGrpExpr             = `'(?P<` + NameGrpName + `>` + validNameExpr + `)'`
	IdGrpName               = "id"
	IdGrpExpr               = `(?P<` + IdGrpName + `>` + validIDExpr + `)`
	ArrowExpr               = `\s*->\s*`
	LoadTermExpr            = `(?P<term>[fm]{1}[xyz]{1})\s+`
	LoadElementID           = `(?P<element>` + validIDExpr + `)\s+`
	DistributedLoadRefExpr  = `(?P<ref>[lg]{1})d\s+`
	ConcentratedLoadRefExpr = `(?P<ref>[lg]{1})c\s+`
	DofGrpName              = "dof"
	DofGrpExpr              = `(?P<` + DofGrpName + `>\[\d+ \d+ \d+\])`
)
View Source
const DefinitionFileExt = ".inkfem"

DefinitionFileExt is the extension of the structure definition files.

View Source
const PreFileExt = ".inkfempre"

PreFileExt is the extension of the preprocessed structure files.

View Source
const SolFileExt = ".inkfemsol"

SolFileExt is the extension of the solved structure files.

Variables

View Source
var (
	NodesHeader     = "nodes"
	MaterialsHeader = "materials"
	SectionsHeader  = "sections"
	LoadsHeader     = "loads"
	BarsHeader      = "bars"
)

Functions

func ConstraintGroupExpr

func ConstraintGroupExpr(groupName string) string

func CreateFile

func CreateFile(filePath string) *os.File

CreateFile returns a new open file to be writen to. Panics if the file can't be created. Don't forget to close the file.

func EnsureParseDOF

func EnsureParseDOF(dofString string, context string) (int, int, int)

EnsureParseDOF attempts to parse three degrees of freedom given the format: [%d %d %d]. Panics if the operation fails. The "context" is used as part of the panic message and it refers to the name of the number being parsed.

func EnsureParseFloat

func EnsureParseFloat(stringValue string, context string) float64

EnsureParseFloat attempts to parse a floating point number from the given string and panics if the operation fails. The "context" is used as part of the panic message and it refers to the name of the number being parsed.

func EnsureParseInt

func EnsureParseInt(stringValue string, context string) int

EnsureParseInt attempts to parse a floating point number from the given string and panics if the operation fails. The "context" is used as part of the panic message and it refers to the name of the number being parsed.

func EnsureParseTorsor

func EnsureParseTorsor(torsorString string, context string) *math.Torsor

EnsureParseTorsor attempts to parse a torsor given it's string form: {%f %f %f}. Panics if the operation fails. The "context" is used as part of the panic message and it refers to the name of the number being parsed.

func ExtractNamedGroups

func ExtractNamedGroups(re *regexp.Regexp, str string) map[string]string

ExtractNamedGroups returns a map of matches by group id. Panics if the given string doesn't match the regular expression.

func FloatGroupExpr

func FloatGroupExpr(groupName string) string

func IdGroupExpr

func IdGroupExpr(groupName string) string

func IsDefinitionFile

func IsDefinitionFile(path string) bool

IsDefinitionFile returns true if the file extension in the path is .inkfem.

func IsPreprocessedFile

func IsPreprocessedFile(path string) bool

IsPreprocessedFile returns true if the file extension in the path is .inkfempre.

func IsSectionHeaderLine

func IsSectionHeaderLine(line string) bool

func MakeTestDefinitionReader

func MakeTestDefinitionReader() io.Reader

func MakeTestDefinitionReaderInverseOrder

func MakeTestDefinitionReaderInverseOrder() io.Reader

func MakeTestOriginalStructure

func MakeTestOriginalStructure() *structure.Structure

func MakeTestPreprocessedReader

func MakeTestPreprocessedReader() io.Reader

func MakeTestPreprocessedStructure

func MakeTestPreprocessedStructure() *preprocess.Structure

func MakeTestSolution

func MakeTestSolution() *process.Solution

func NameGroupExpr

func NameGroupExpr(groupName string) string

func OpenFile

func OpenFile(filePath string) *os.File

OpenFile returns an existing file to be writen to. Panics if the file can't be opened. Don't forget to close the file.

func ParseMetadata

func ParseMetadata(linesReader *LinesReader) structure.StrMetadata

ParseMetadata reads the structure metadata from the structure files first line: "inkfem vM.m". Panics if the first line doesn't follow the expected format.

func ParseSectionHeader

func ParseSectionHeader(line string) string

func ParseVersionNumbers

func ParseVersionNumbers(versionString string) (majorVersion, minorVersion int)

ParseVersionNumbers expectes the passed in string to follow the format "inkfem vM.m" where "M" and "m" are the major and minor versions of the application. It returns these two version numbers or panics if the line couldn't be matched.

func ShouldIgnoreLine

func ShouldIgnoreLine(line string) bool

ShouldIgnoreLine decides whether a given line can be ignored. A line can be ignored if, after removing the surrounding white space, it's empty or starts with "#", the comment opener.

func TorsorGroupExpr

func TorsorGroupExpr(groupName string) string

Types

type LinesReader

type LinesReader struct {
	// contains filtered or unexported fields
}

A LinesReader reads lines from a buffered scanner one by one, ignoring blank and commented lines. All returned lines are trimmed to remove the blank space around them.

func MakeLinesReader

func MakeLinesReader(reader io.Reader) *LinesReader

MakeLinesReader creates a lines using the passed in reader.

func (*LinesReader) GetNextLine

func (lr *LinesReader) GetNextLine() string

GetNextLine returns the next line read by the ReadNext method.

func (*LinesReader) GetNextLineNumber

func (lr *LinesReader) GetNextLineNumber() int

GetNextLineNumber returns the next line number read by the ReadNext method.

func (*LinesReader) GetNextLines

func (lr *LinesReader) GetNextLines(count int) []string

GetNextLines gets the next "count" lines from the reader, ignoring comments and blank lines. Panics if there're not enough lines left in the reader.

func (*LinesReader) ReadNext

func (lr *LinesReader) ReadNext() bool

ReadNext checks if there are more lines available and reads the next one. If HasMoreLines returns "true", GetNextLine and GetNextLineNumber can be called to get the next line and its original line number.

type ReaderOptions

type ReaderOptions struct {
	ShouldIncludeOwnWeight bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL