inp

package
v0.0.0-...-54c0f88 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2015 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

package inp implements the input data read from a (.sim) JSON file

Index

Constants

View Source
const Ztol = 1e-7

constants

Variables

View Source
var LogFile *os.File

LogFile holds a handle to errors logger file

Functions

func FlushLog

func FlushLog()

FlusLog saves log (flushes to disk)

func InitLogFile

func InitLogFile(dirout, fnamekey string) (err error)

InitLogFile initialises logger

func LogErr

func LogErr(err error, msg string) (stop bool)

LogErr logs error and returs stop flag

func LogErrCond

func LogErrCond(condition bool, msg string, prm ...interface{}) (stop bool)

LogErr logs error using condition (==true) to stop and returs stop flag

func MatfileNew2Old

func MatfileNew2Old(dirout string, fnold, fnnew string, convertsymbols bool)

MatfileNew2Old converts a new mat file to the old mat file format

convertsymbols -- convert back symbols with Greek characters to UTF-8

func MatfileOld2New

func MatfileOld2New(dirout string, fnnew, fnold string, convertsymbols bool)

MatfileOld2New converts an old mat file to new mat file format

convertsymbols -- convert symbols with Greek characters to ANSI

Types

type Cell

type Cell struct {

	// input data
	Id     int    // id
	Tag    int    // tag
	Geo    int    // geometry type (gemlab code)
	Type   string // geometry type (string)
	Part   int    // partition id
	Verts  []int  // vertices
	FTags  []int  // edge (2D) or face (3D) tags
	STags  []int  // seam tags (for 3D only; it is actually a 3D edge tag)
	JlinId int    // joint line id
	JsldId int    // joint solid id

	// neighbours
	Neighs []int // neighbours; e.g. [3, 7, -1, 11] => side:cid => 0:3, 1:7, 2:-1(no cell), 3:11

	// derived
	Shp *shp.Shape // shape structure

	// specific problems data
	IsJoint   bool         // cell represents joint element
	SeepVerts map[int]bool // local vertices ids of vertices on seepage faces
}

Cell holds cell data

func (*Cell) String

func (o *Cell) String() string

String returns a JSON representation of *Cell

type CellFaceId

type CellFaceId struct {
	C   *Cell // cell
	Fid int   // face id
}

CellFaceId structure

type CellSeamId

type CellSeamId struct {
	C   *Cell // cell
	Sid int   // seam id
}

CellSeamId structure

type Data

type Data struct {

	// global information
	Desc    string `json:"desc"`    // description of simulation
	Matfile string `json:"matfile"` // materials file path
	DirOut  string `json:"dirout"`  // directory for output; e.g. /tmp/gofem
	Encoder string `json:"encoder"` // encoder name; e.g. "gob" "json" "xml"

	// problem definition and options
	Steady  bool    `json:"steady"`  // steady simulation
	Pstress bool    `json:"pstress"` // plane-stress
	Axisym  bool    `json:"axisym"`  // axisymmetric
	NoLBB   bool    `json:"nolbb"`   // do not satisfy Ladyženskaja-Babuška-Brezzi condition; i.e. do not use [qua8,qua4] for u-p formulation
	LogBcs  bool    `json:"logbcs"`  // log boundary conditions setting up
	Debug   bool    `json:"debug"`   // activate debugging
	Stat    bool    `json:"stat"`    // activate statistics
	Wlevel  float64 `json:"wlevel"`  // water level; 0 means use max elevation
	Surch   float64 `json:"surch"`   // surcharge load at surface == qn0

	// options
	React bool `json:"react"` // indicates whether or not reaction forces must be computed
	ShowR bool `json:"showr"` // show residual
	NoDiv bool `json:"nodiv"` // disregard divergence control in both fb or Lδu
	CteTg bool `json:"ctetg"` // use constant tangent (modified Newton) during iterations

	// derived
	FnameDir string // directory where .sim filename is locatd
	FnameKey string // simulation filename key; e.g. mysim01.sim => mysim01
}

Data holds global data for simulations

func (*Data) PostProcess

func (o *Data) PostProcess(dir, fn string, erasefiles bool)

PostProcess performs a post-processing of the just read json file

func (*Data) SetDefault

func (o *Data) SetDefault()

SetDefault sets defaults values

type EleCond

type EleCond struct {
	Tag   int      `json:"tag"`   // tag of cell/element
	Keys  []string `json:"keys"`  // key indicating type of condition. ex: "g" (gravity), "qn" for beams, etc.
	Funcs []string `json:"funcs"` // name of function. ex: grav, none
	Extra string   `json:"extra"` // extra information. ex: '!λl:10'
}

EleCond holds element condition

type ElemData

type ElemData struct {
	Tag   int    `json:"tag"`   // tag of element
	Mat   string `json:"mat"`   // material name
	Type  string `json:"type"`  // type of element. ex: u, p, up, rod, beam, rjoint
	Nip   int    `json:"nip"`   // number of integration points; 0 => use default
	Nipf  int    `json:"nipf"`  // number of integration points on face; 0 => use default
	Extra string `json:"extra"` // extra flags (in keycode format). ex: "!thick:0.2 !nip:4"
	Inact bool   `json:"inact"` // whether element starts inactive or not
}

ElemData holds element data

type FaceBc

type FaceBc struct {
	Tag   int      `json:"tag"`   // tag of face
	Keys  []string `json:"keys"`  // key indicating type of bcs. ex: qn, pw, ux, uy, uz, wwx, wwy, wwz
	Funcs []string `json:"funcs"` // name of function. ex: zero, load, myfunction1, etc.
	Extra string   `json:"extra"` // extra information. ex: '!λl:10'
}

FaceBc holds face boundary condition

type FuncData

type FuncData struct {
	Name string   `json:"name"` // name of function. ex: zero, load, myfunction1, etc.
	Type string   `json:"type"` // type of function. ex: cte, rmp
	Prms fun.Prms `json:"prms"` // parameters
}

FuncData holds function definition

func (FuncData) String

func (o FuncData) String() string

String prints one function

type FuncsData

type FuncsData []*FuncData

Funcs holds functions

func (FuncsData) Get

func (o FuncsData) Get(name string) fun.Func

Get returns function by name

Note: returns nil if not found

func (FuncsData) PlotAll

func (o FuncsData) PlotAll(pd *PlotFdata, dirout, fnkey string)

PlotAll plot all functions

func (FuncsData) String

func (o FuncsData) String() string

String prints functions

type GeoStData

type GeoStData struct {
	Nu     []float64 `json:"nu"`     // [nlayers] Poisson's coefficient to compute effective horizontal state for each layer
	K0     []float64 `json:"K0"`     // [nlayers] Earth pressure coefficient at rest to compute effective horizontal stresses
	UseK0  []bool    `json:"useK0"`  // [nlayers] use K0 to compute effective horizontal stresses instead of "nu"
	Layers [][]int   `json:"layers"` // [nlayers][ntagsInLayer]; e.g. [[-1,-2], [-3,-4]] => 2 layers
}

GeoStData holds data for setting initial geostatic state (hydrostatic as well)

type ImportRes

type ImportRes struct {
	Dir    string `json:"dir"`    // output directory with previous simulation files
	Fnk    string `json:"fnk"`    // previous simulation file name key (without .sim)
	ResetU bool   `json:"resetu"` // reset/zero u (displacements)
}

ImportRes holds definitions for importing results from a previous simulation

type IniStressData

type IniStressData struct {
	Hom bool    `json:"hom"` // homogeneous stress distribution
	Iso bool    `json:"iso"` // isotropic state
	Psa bool    `json:"psa"` // plane-strain state
	S0  float64 `json:"s0"`  // Iso => stress value to use in homogeneous and isotropic distribution
	Sh  float64 `json:"sh"`  // Psa => horizontal stress
	Sv  float64 `json""sv"`  // Psa => vertical stress
	Nu  float64 `json:"nu"`  // Psa => Poisson's coefficient for plane-strain state
}

IniStressData holds data for setting initial stresses

type InitialData

type InitialData struct {
	Fcn  string `json:"fcn"`  // function F(t, x) is given; from functions database
	File string `json:"file"` // file with values at each node is given; filename with path is provided
}

InitialData holds data for setting initial solution values such as Y, dYdt and d2Ydt2

type LinSolData

type LinSolData struct {
	Name      string `json:"name"`      // "mumps" or "umfpack"
	Symmetric bool   `json:"symmetric"` // use symmetric solver
	Verbose   bool   `json:"verbose"`   // verbose?
	Timing    bool   `json:"timing"`    // show timing statistics
	Ordering  string `json:"ordering"`  // ordering scheme
	Scaling   string `json:"scaling"`   // scaling scheme
}

LinSolData holds data for linear solvers

func (*LinSolData) PostProcess

func (o *LinSolData) PostProcess()

PostProcess performs a post-processing of the just read json file

func (*LinSolData) SetDefault

func (o *LinSolData) SetDefault()

SetDefault sets defaults values

type MatDb

type MatDb struct {
	Functions FuncsData `json:"functions"` // all functions
	Materials MatsData  `json:"materials"` // all materials
}

MatDb implements a database of materials

func ReadMat

func ReadMat(dir, fn string) *MatDb

ReadMat reads all materials data from a .mat JSON file

Note: returns nil on errors

func (MatDb) Get

func (o MatDb) Get(name string) *Material

Get returns a material

Note: returns nil if not found

func (MatDb) GroupGet

func (o MatDb) GroupGet(matname, key string) *Material

GroupGet parses group data

Note: returns nil on failure

func (MatDb) GroupGet3

func (o MatDb) GroupGet3(matname, key1, key2, key3 string) (m1, m2, m3 *Material, err error)

GroupGet3 parses group data

func (MatDb) String

func (o MatDb) String() string

String outputs all materials

type Material

type Material struct {
	Name  string   `json:"name"`  // name of material
	Desc  string   `json:"desc"`  // description of material
	Model string   `json:"model"` // name of model ex: 'dp', 'vm', 'elast', etc.
	Extra string   `json:"extra"` // extra information about this material
	Prms  fun.Prms `json:"prms"`  // prms holds all model parameters for this material
}

Material holds material data

func (*Material) String

func (o *Material) String() string

String prints one function

type MatsData

type MatsData []*Material

Mats holds materials

func (MatsData) String

func (o MatsData) String() string

String prints materials

type Mesh

type Mesh struct {

	// from JSON
	Verts []*Vert // vertices
	Cells []*Cell // cells

	// derived
	FnamePath  string  // complete filename path
	Ndim       int     // space dimension
	Xmin, Xmax float64 // min and max x-coordinate
	Ymin, Ymax float64 // min and max x-coordinate
	Zmin, Zmax float64 // min and max x-coordinate

	// derived: maps
	VertTag2verts map[int][]*Vert      // vertex tag => set of vertices
	CellTag2cells map[int][]*Cell      // cell tag => set of cells
	FaceTag2cells map[int][]CellFaceId // face tag => set of cells
	FaceTag2verts map[int][]int        // face tag => vertices on tagged face
	SeamTag2cells map[int][]CellSeamId // seam tag => set of cells
	Ctype2cells   map[string][]*Cell   // cell type => set of cells
	Part2cells    map[int][]*Cell      // partition number => set of cells
}

Mesh holds a mesh for FE analyses

func ReadMsh

func ReadMsh(dir, fn string) *Mesh

ReadMsh reads a mesh for FE analyses

Note: returns nil on errors

func (Mesh) String

func (o Mesh) String() string

String returns a JSON representation of *Mesh

type NodeBc

type NodeBc struct {
	Tag   int      `json:"tag"`   // tag of node
	Keys  []string `json:"keys"`  // key indicating type of bcs. ex: pw, ux, uy, uz, wwx, wwy, wwz
	Funcs []string `json:"funcs"` // name of function. ex: zero, load, myfunction1, etc.
	Extra string   `json:"extra"` // extra information. ex: '!λl:10'
}

NodeBc holds node boundary condition

type PlotFdata

type PlotFdata struct {
	Ti      float64  `json:"ti"`      // initial time
	Tf      float64  `json:"tf"`      // final time
	Np      int      `json:"np"`      // number of points
	Skip    []string `json:"skip"`    // skip functions
	WithG   bool     `json:"withg"`   // with dF/dt
	WithH   bool     `json:"withh"`   // with d²F/dt²
	Eps     bool     `json:"eps"`     // save eps instead of png
	WithTxt bool     `json:"withtxt"` // show text corresponding to initial and final points
}

PlotFdata holds information to plot functions

type Region

type Region struct {

	// input data
	Desc      string      `json:"desc"`      // description of region. ex: ground, indenter, etc.
	Mshfile   string      `json:"mshfile"`   // file path of file with mesh data
	ElemsData []*ElemData `json:"elemsdata"` // list of elements data

	// derived
	Msh *Mesh // the mesh
	// contains filtered or unexported fields
}

Region holds region data

func (*Region) Etag2data

func (d *Region) Etag2data(etag int) *ElemData

Etag2data returns the ElemData corresponding to element tag

Note: returns nil if not found

type SeamBc

type SeamBc struct {
	Tag   int      `json:"tag"`   // tag of seam
	Keys  []string `json:"keys"`  // key indicating type of bcs. ex: qn, pw, ux, uy, uz, wwx, wwy, wwz
	Funcs []string `json:"funcs"` // name of function. ex: zero, load, myfunction1, etc.
	Extra string   `json:"extra"` // extra information. ex: '!λl:10'
}

SeamBc holds seam (3D edge) boundary condition

type Simulation

type Simulation struct {

	// input
	Data      Data       `json:"data"`      // stores global simulation data
	Functions FuncsData  `json:"functions"` // stores all boundary condition functions
	PlotF     *PlotFdata `json:"plotf"`     // plot functions
	Regions   []*Region  `json:"regions"`   // stores all regions
	LinSol    LinSolData `json:"linsol"`    // linear solver data
	Solver    SolverData `json:"solver"`    // FEM solver data
	Stages    []*Stage   `json:"stages"`    // stores all stages

	// derived
	Mdb        *MatDb   // materials database
	Ndim       int      // space dimension
	MaxElev    float64  // maximum elevation
	Gfcn       fun.Func // first stage: gravity constant function
	WaterRho0  float64  // first stage: intrinsic density of water corresponding to pressure pl=0
	WaterBulk  float64  // first stage: bulk modulus of water
	WaterLevel float64  // first stage: water level == max(Wlevel, MaxElev)
}

Simulation holds all simulation data

func ReadSim

func ReadSim(dir, fn, logPrefix string, erasefiles bool) *Simulation

ReadSim reads all simulation data from a .sim JSON file

Notes:  1) this function initialises log file
        2) returns nil on errors

func (*Simulation) GetInfo

func (o *Simulation) GetInfo(w goio.Writer) (err error)

GetInfo returns formatted information

type SolverData

type SolverData struct {

	// constants
	Eps float64 // smallest number satisfying 1.0 + ϵ > 1.0

	// nonlinear solver
	NmaxIt  int     `json:"nmaxit"`  // number of max iterations
	Atol    float64 `json:"atol"`    // absolute tolerance
	Rtol    float64 `json:"rtol"`    // relative tolerance
	FbTol   float64 `json:"fbtol"`   // tolerance for convergence on fb
	FbMin   float64 `json:"fbmin"`   // minimum value of fb
	DvgCtrl bool    `json:"dvgctrl"` // use divergence control
	NdvgMax int     `json:"ndvgmax"` // max number of continued divergence

	// Richardson's extrapolation
	RE       bool    // Richardson extrapolation is active
	REnogus  bool    // Richardson extrapolation: no Gustafsson's step control
	REnssmax int     // Richardson extrapolation: max number of substeps
	REatol   float64 // Richardson extrapolation: absolute tolerance
	RErtol   float64 // Richardson extrapolation: relative tolerance
	REmfac   float64 // Richardson extrapolation: multiplier factor
	REmmin   float64 // Richardson extrapolation: min multiplier
	REmmax   float64 // Richardson extrapolation: max multiplier

	// transient analyses
	DtMin      float64 `json:"dtmin"`      // minium value of Dt for transient (θ and Newmark / Dyn coefficients)
	Theta      float64 `json:"theta"`      // θ-method
	ThGalerkin bool    `json:"thgalerkin"` // use θ = 2/3
	ThLiniger  bool    `json:"thliniger"`  // use θ = 0.878

	// dynamics
	Theta1 float64 `json:"theta1"` // Newmark's method parameter
	Theta2 float64 `json:"theta2"` // Newmark's method parameter
	HHT    bool    `json:"hht"`    // use Hilber-Hughes-Taylor method
	HHTalp float64 `json:"hhtalp"` // HHT α parameter

	// combination of coefficients
	ThCombo1 bool `json:"thcombo1"` // use θ=2/3, θ1=5/6 and θ2=8/9 to avoid oscillations

	// derived
	Itol float64 // iterations tolerance
}

SolverData holds FEM solver data

func (*SolverData) PostProcess

func (o *SolverData) PostProcess()

PostProcess performs a post-processing of the just read json file

func (*SolverData) SetDefault

func (o *SolverData) SetDefault()

SetDefault set defaults values

type Stage

type Stage struct {

	// main
	Desc       string `json:"desc"`       // description of simulation stage. ex: activation of top layer
	Activate   []int  `json:"activate"`   // array of tags of elements to be activated
	Deactivate []int  `json:"deactivate"` // array of tags of elements to be deactivated
	Save       bool   `json:"save"`       // save stage data to binary file
	Load       string `json:"load"`       // load stage data (filename) from binary file
	Skip       bool   `json:"skip"`       // do not run stage

	// specific problems data
	HydroSt   bool           `json:"hydrost"`   // hydrostatic initial condition
	SeepFaces []int          `json:"seepfaces"` // face tags corresponding to seepage faces
	IniStress *IniStressData `json:"inistress"` // initial stress data
	GeoSt     *GeoStData     `json:"geost"`     // initial geostatic state data (hydrostatic as well)
	Import    *ImportRes     `json:"import"`    // import results from another previous simulation
	Initial   *InitialData   `json:"initial"`   // set initial solution values such as Y, dYdt and d2Ydt2

	// conditions
	EleConds []*EleCond `json:"eleconds"` // element conditions. ex: gravity or beam distributed loads
	FaceBcs  []*FaceBc  `json:"facebcs"`  // face boundary conditions
	SeamBcs  []*SeamBc  `json:"seambcs"`  // seam (3D) boundary conditions
	NodeBcs  []*NodeBc  `json:"nodebcs"`  // node boundary conditions

	// timecontrol
	Control TimeControl `json:"control"` // time control
}

Stage holds stage data

func (Stage) GetFaceBc

func (o Stage) GetFaceBc(facetag int) *FaceBc

GetFaceBc returns face boundary condition structure by giving a face tag

Note: returns nil if not found

type TimeControl

type TimeControl struct {
	Tf     float64 `json:"tf"`     // final time
	Dt     float64 `json:"dt"`     // time step size (if constant)
	DtOut  float64 `json:"dtout"`  // time step size for output
	DtFcn  string  `json:"dtfcn"`  // time step size (function name)
	DtoFcn string  `json:"dtofcn"` // time step size for output (function name)

	// derived
	DtFunc  fun.Func // time step function
	DtoFunc fun.Func // output time step function
}

TimeControl holds data for defining the simulation time stepping

type Vert

type Vert struct {
	Id  int       // id
	Tag int       // tag
	C   []float64 // coordinates (size==2 or 3)
}

Vert holds vertex data

func (*Vert) String

func (o *Vert) String() string

String returns a JSON representation of *Vert

Jump to

Keyboard shortcuts

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