out

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: 12 Imported by: 0

Documentation

Overview

package out implements FE simulation output handling for analyses and plotting

Index

Constants

View Source
const DIST_TOL = 1e-6 // tolerance to compare distances or proximity between points

Variables

View Source
var (
	TolC = 1e-8 // tolerance to compare x-y-z coordinates
	TolT = 1e-3 // tolerance to compare times
	Ndiv = 20   // bins n-division
)

constants

View Source
var (

	// data set by Start
	Sum       *fem.Summary     // summary
	Dom       *fem.Domain      // FE domain
	Ipoints   []*fem.OutIpData // all integration points. ipid == index in Ipoints
	Cid2ips   [][]int          // [ncells][nip] maps cell id to index in Ipoints
	Ipkey2ips map[string][]int // maps ip keys to indices in Ipoints
	Ipkeys    map[string]bool  // all ip keys
	NodBins   gm.Bins          // bins for nodes
	IpsBins   gm.Bins          // bins for integration points
	IpsMin    []float64        // [ndim] {x,y,z}_min among all ips
	IpsMax    []float64        // [ndim] {x,y,z}_max among all ips

	// defined entities and results loaded by LoadResults
	Planes   map[string]*PlaneData // for points defined on planes. maps aliases to data
	Results  ResultsMap            // maps labels => points
	TimeInds []int                 // selected output indices
	Times    []float64             // selected output times

	// extrapolated values
	Extrap []string             // keys to be extrapolated; e.g. []string{"nwlx", "nwly"}
	ExVals []map[string]float64 // [nverts][nkeys] extrapolated values

	// subplots
	Splots []*SplotDat // all subplots
	Csplot *SplotDat   // current subplot
)

Global variables

Functions

func ComputeExtrapolatedValues

func ComputeExtrapolatedValues(extrapKeys []string)

func Define

func Define(alias string, loc Locator)

Define defines aliases

alias -- an alias to a group of points, an individual point, or to a set of points.
         Example: "A", "left-column" or "a b c". If the number of points found is different
         than the number of aliases, a group is created.
Note:
  To use spaces in aliases, prefix the alias with an exclamation mark; e.g "!right column"

func Draw

func Draw(dirout, fname string, show bool, extra ExtraPlt)

Draw draws or save figure with plot

dirout -- directory to save figure
fname  -- file name; e.g. myplot.eps or myplot.png. Use "" to skip saving
show   -- shows figure
extra  -- is called just after Subplot command and before any plotting
Note: subplots will be split if using 'eps' files

func End

func End()

End must be called at the end to flush log file

func GetCoords

func GetCoords(alias string) []float64

GetCoords returns the coordinates of a single point

func GetDist

func GetDist(key, alias string) (dist []float64)

GetDist returns the distance from a reference point on the given line with selected points if they contain a given key

key -- use any to get coordinates of points with any key such as "ux", "pl", etc.

func GetIds

func GetIds(alias string) (vids, ipids []int)

GetIds return the ids corresponding to alias

func GetRes

func GetRes(key, alias string, idxI int) []float64

GetRes gets results as a time or space series corresponding to a given alias for a single point or set of points.

idxI -- index in TimeInds slice corresponding to selected output time; use -1 for the last item.
        If alias defines a single point, the whole time series is returned and idxI is ignored.

func GetTexLabel

func GetTexLabel(key, unit string) string

func GetXYZ

func GetXYZ(key, alias string) (x, y, z []float64)

GetXYZ returns the x-y-z coordinates of selected points that have a specified key

key -- use any to get coordinates of points with any key such as "ux", "pl", etc.

func IntegOnPlane

func IntegOnPlane(key, alias string) (res []float64)

IntegOnPlane integrates the results of nodes located on a plane perpedicular to either {x,y,z} The mesh on the plane must be structured and with rectangle elements in order to build an {u,v} coordinates system Input:

key   -- node variable; e.g. "uz", "ex_sz"
alias -- alias of plane; e.g. "surf"

Output:

res -- the result of the integration res = ∫_u ∫_v f(u,v) du dv for all output times

func Integrate

func Integrate(key, alias, along string, idxI int) float64

Integrate integrates key along direction "x", "y", or "z"

idxI -- index in TimeInds slice corresponding to selected output time; use -1 for the last item.
        If alias defines a single point, the whole time series is returned and idxI is ignored.

func LoadResults

func LoadResults(times []float64)

LoadResults loads all results after points are defined

times -- specified selected output times
         use nil to indicate that all times are required

func ParseKey

func ParseKey(key string) (string, int)

ParseKey parses key like "duxdt" returning "ux" and time derivative number

Output: {key, number-of-time-derivatives}
Examples:  "ux"      => "ux", 0
           "duxdt"   => "ux", 1
           "d2uxdt2" => "ux", 2

func Plot

func Plot(xHandle, yHandle interface{}, alias string, fm plt.Fmt, idxI int)

Plot plots data

xHandle -- can be a string, e.g. "t" or a slice, e.g. pc = []float64{0, 1, 2}
yHandle -- can be a string, e.g. "pl" or a slice, e.g. sl = []float64{0, 1, 2}
alias   -- alias such as "centre"
fm      -- formatting codes; e.g. plt.Fmt{C:"blue", L:"label"}
idxI    -- index of time; use -1 for all times

func Splot

func Splot(splotTitle string)

Splot activates a new subplot window

func SplotConfig

func SplotConfig(xunit, yunit string, xscale, yscale float64)

SplotConfig configures units and scales of axes

func Start

func Start(simfnpath string, stageIdx, regionIdx int)

Start starts handling of results given a simulation input file

Types

type Along

type Along [][]float64

Along implements locator along line => LineLocator

Example: with 2 points in 3D: {{0,0,0}, {1,1,1}}

func (Along) Locate

func (o Along) Locate() (res Points)

Locate finds points

type AlongX

type AlongX []float64

AlongX implements LineLocator with []float64{y_cte} or []float64{y_cte, z_cte}

func (AlongX) Locate

func (o AlongX) Locate() (res Points)

Locate finds points

type AlongY

type AlongY []float64

AlongY implements LineLocator with []float64{x_cte} or []float64{x_cte, z_cte}

func (AlongY) Locate

func (o AlongY) Locate() (res Points)

Locate finds points

type AlongZ

type AlongZ []float64

AlongZ implements LineLocator with []float64{x_cte, y_cte}

func (AlongZ) Locate

func (o AlongZ) Locate() (res Points)

Locate finds points

type At

type At []float64

At implements locator at point => PointLocator

func (At) Locate

func (o At) Locate() Points

Locate finds points

type AtIp

type AtIp []float64

AtIp implements locator at integration point => PointLocator

Note: this is useful when there are vertices overlapping ips

func (AtIp) Locate

func (o AtIp) Locate() Points

Locate finds integration points

type ExtraPlt

type ExtraPlt func(i, j, nplots int)

ExtraPlt defines a callback function for extra plt commands

Note: i and j are indices as in Subplot

type Locator

type Locator interface {
	Locate() Points
}

PointLocator defines interface for locating space positions

type N

type N []int

N implements node locator Ids or tags of vertices can be stored in Verts

func AllNodes

func AllNodes() N

AllNodes returns all nodes

func (N) Locate

func (o N) Locate() (res Points)

Locate finds nodes

type OnZplane

type OnZplane []float64

OnZplane implements locator for nodes/ips on plane perpendicular to z-axis

Note: slice must contain at least one value; e.g. []float64{z_cte}
      a second value is used as tolerance; e.g. []float64{z_cte, z_tolerance}

func (OnZplane) Locate

func (o OnZplane) Locate() (res Points)

Locate finds points on z-plane. TODO: use bins to optimise search

type P

type P [][]int

P implements [element][integrationPoint] locator Pairs of ids or tags of cells and integration points indices can be stored in Cells

Note: 1) negative element ids means element tags
      2) negative integration poitns ids means all integration points of element

func AllIps

func AllIps() P

AllIps returns all cell/ip indices

func (P) Locate

func (o P) Locate() (res Points)

Locate finds points

type PlaneData

type PlaneData struct {
	Plane int          // Plane indicator: {0,1,2} == {x-pane, y-plane, z-plane}. plane perpendicular to {x,y,z}
	Ids   map[int]bool // Ids in Dom.Msh.Verts or Ipoints of notes/ips on plane
	Dx    []float64    // Increments between cells in global coordinates
	Iu    []int        // Index of global coordinates corresponding to {u,v} plane
	Du    []float64    // Increments between cells in {u,v} coordinates
	Umin  []float64    // min {u,v} coordinates
	Umax  []float64    // max {u,v} coordinates
	Nu    []int        // number of divisions along {u,v}
	Ubins gm.Bins      // bins to search points in {u,v} grid
	F     [][]float64  // [nu][nv] values of a function evaluated at the uv coords; i.e. f(u,v)
	// contains filtered or unexported fields
}

PlaneData holds data for handling planes described by {u,v}-coordinates

func NodesOnPlane

func NodesOnPlane(ftag int) *PlaneData

NodesOnPlane finds vertices located on {x,y,z} plane and returns an iterator that can be used to extract results on the plane. An {u,v}-coordinates system is built on the plane.

Input:
  ftag -- cells' face tag; e.g. -31
Output:
  dat -- plane data holding vertices on plane and other information; see above
Note:
  1) this function works with 3D cells only
  2) faces on cells must be either "qua4" or "qua8" types
  3) middle nodes in "qua8" are disregarded in order to buidl an {u,v} grid
  4) the resulting mesh on plane must be equally spaced; i.e. Δx and Δy are constant;
     but not necessarily equal to each other

func (*PlaneData) ConnectResults

func (o *PlaneData) ConnectResults(alias string)

ConnectResults connects Ids to Points in Results structure

func (PlaneData) Locate

func (o PlaneData) Locate() (res Points)

Locate finds points on plane => implement the Locator interface

type PltEntity

type PltEntity struct {
	Alias string    // alias
	X     []float64 // x-values
	Y     []float64 // y-values
	Xlbl  string    // horizontal axis label (raw; e.g. "t")
	Ylbl  string    // vertical axis label (raw; e.g. "pl")
	Style plt.Fmt   // style
}

PltEntity stores all data for a plot entity (X vs Y)

type Point

type Point struct {
	Vid  int                  // vertex id; -1 => not node
	IpId int                  // ip id; -1 => not ip
	X    []float64            // coordinates
	Dist float64              // distance from reference point (if along line)
	Vals map[string][]float64 // combines keys to results along time; e.g. "ux" : {0,0.0001,0,0002,...}
}

Point holds information about one specific node xor one integration point

func (Point) String

func (o Point) String() string

type Points

type Points []*Point

Points is a set of Point

func (Points) Len

func (o Points) Len() int

Len the length of Points

func (Points) Less

func (o Points) Less(i, j int) bool

Less compares Points considering Dist

func (Points) String

func (o Points) String() string

func (Points) Swap

func (o Points) Swap(i, j int)

Swap swaps two Points

type ResultsMap

type ResultsMap map[string]Points

ResultsMap maps aliases to points

func (ResultsMap) String

func (o ResultsMap) String() string

type SplotDat

type SplotDat struct {
	Title   string       // title of subplot
	Topts   string       // title options
	Xscale  float64      // x-axis scale
	Yscale  float64      // y-axis scale
	Xlbl    string       // x-axis label (formatted; e.g. "$t$")
	Ylbl    string       // y-axis label (formatted; e.g. "$p_{\ell}$")
	GllArgs string       // extra arguments for Gll such as leg_out
	Data    []*PltEntity // data and styles to be plotted
}

SplotDat stores all data for one subplot

type Styles

type Styles []plt.Fmt

Styles

func GetDefaultStyles

func GetDefaultStyles(qts Points) Styles

Jump to

Keyboard shortcuts

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