本文整理匯總了Golang中github.com/cpmech/gofem/ana.CteStressPstrain.CheckStress方法的典型用法代碼示例。如果您正苦於以下問題:Golang CteStressPstrain.CheckStress方法的具體用法?Golang CteStressPstrain.CheckStress怎麽用?Golang CteStressPstrain.CheckStress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cpmech/gofem/ana.CteStressPstrain
的用法示例。
在下文中一共展示了CteStressPstrain.CheckStress方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Test_nurbs02
func Test_nurbs02(tst *testing.T) {
//verbose()
chk.PrintTitle("nurbs02. square with initial stress. run")
// fem
analysis := NewFEM("data/nurbs02.sim", "", true, false, false, false, chk.Verbose, 0)
// run simulation
err := analysis.Run()
if err != nil {
tst.Errorf("Run failed\n%v", err)
return
}
// domain
dom := analysis.Domains[0]
e := dom.Elems[0].(*ElemU)
io.PfYel("fex = %v\n", e.fex)
io.PfYel("fey = %v\n", e.fey)
la.PrintMat("K", e.K, "%10.2f", false)
// solution
var sol ana.CteStressPstrain
sol.Init(fun.Prms{
&fun.Prm{N: "qnH0", V: -20},
&fun.Prm{N: "qnV0", V: -20},
&fun.Prm{N: "qnH", V: -50},
&fun.Prm{N: "qnV", V: -100},
})
// check displacements
t := dom.Sol.T
tolu := 1e-16
for _, n := range dom.Nodes {
eqx := n.GetEq("ux")
eqy := n.GetEq("uy")
u := []float64{dom.Sol.Y[eqx], dom.Sol.Y[eqy]}
io.Pfyel("u = %v\n", u)
sol.CheckDispl(tst, t, u, n.Vert.C, tolu)
}
// check stresses
tols := 1e-13
for idx, ip := range e.IpsElem {
x := e.Cell.Shp.IpRealCoords(e.X, ip)
σ := e.States[idx].Sig
io.Pforan("σ = %v\n", σ)
sol.CheckStress(tst, t, σ, x, tols)
}
}
示例2: Test_sigini02
func Test_sigini02(tst *testing.T) {
//verbose()
chk.PrintTitle("sigini02")
// start simulation
if !Start("data/sigini02.sim", true, chk.Verbose) {
tst.Errorf("test failed\n")
return
}
defer End()
// run simulation
if !Run() {
tst.Errorf("test failed\n")
return
}
// allocate domain
distr := false
d := NewDomain(Global.Sim.Regions[0], distr)
if !d.SetStage(0, Global.Sim.Stages[0], distr) {
tst.Errorf("SetStage failed\n")
return
}
// read results
sum := ReadSum(Global.Dirout, Global.Fnkey)
io.Pforan("sum = %+v\n", sum)
ntout := len(sum.OutTimes)
d.In(sum, ntout-1, true)
// solution
var sol ana.CteStressPstrain
sol.Init(fun.Prms{
&fun.Prm{N: "qnH0", V: -20},
&fun.Prm{N: "qnV0", V: -20},
&fun.Prm{N: "qnH", V: -50},
&fun.Prm{N: "qnV", V: -100},
})
// check displacements
t := d.Sol.T
tolu := 1e-16
for _, n := range d.Nodes {
eqx := n.GetEq("ux")
eqy := n.GetEq("uy")
u := []float64{d.Sol.Y[eqx], d.Sol.Y[eqy]}
sol.CheckDispl(tst, t, u, n.Vert.C, tolu)
}
// check stresses
e := d.Elems[0].(*ElemU)
tols := 1e-13
for idx, ip := range e.IpsElem {
x := e.Shp.IpRealCoords(e.X, ip)
σ := e.States[idx].Sig
io.Pforan("σ = %v\n", σ)
sol.CheckStress(tst, t, σ, x, tols)
}
}
示例3: Test_contact01b
func Test_contact01b(tst *testing.T) {
//verbose()
chk.PrintTitle("contact01b")
// start simulation
analysis := NewFEM("data/contact01.sim", "", true, true, false, false, chk.Verbose, 0)
// for debugging Kb
//if true {
if false {
u_DebugKb(analysis, &testKb{
tst: tst, eid: 3, tol: 1e-7, verb: chk.Verbose,
ni: -1, nj: -1, itmin: 1, itmax: 1, tmin: 0.2, tmax: -1,
})
}
// run simulation
err := analysis.Run()
if err != nil {
io.PfRed("Run failed:\n%v", err)
tst.Errorf("Run failed:\n%v", err)
return
}
// check
//if true {
if false {
// domain
dom := analysis.Domains[0]
// solution
var sol ana.CteStressPstrain
sol.Init(fun.Prms{
&fun.Prm{N: "qnH", V: 0},
&fun.Prm{N: "qnV", V: -100},
})
// check displacements
t := dom.Sol.T
tolu := 1e-16
for _, n := range dom.Nodes {
eqx := n.GetEq("ux")
eqy := n.GetEq("uy")
u := []float64{dom.Sol.Y[eqx], dom.Sol.Y[eqy]}
io.Pfgreen("u = %v\n", u)
sol.CheckDispl(tst, t, u, n.Vert.C, tolu)
}
// check stresses
e := dom.Elems[3].(*ElemU)
tols := 1e-13
for idx, ip := range e.IpsElem {
x := e.Cell.Shp.IpRealCoords(e.X, ip)
σ := e.States[idx].Sig
io.Pforan("σ = %v\n", σ)
sol.CheckStress(tst, t, σ, x, tols)
}
}
}
示例4: Test_out01
//.........這裏部分代碼省略.........
chk.IntAssert(len(Ipkeys), 4)
for key, ips := range Ipkey2ips {
chk.Ints(tst, io.Sf("%s : ips", key), ips, utl.IntRange(4))
}
// load results
LoadResults(nil)
// check points
nlabels := []string{"A", "B", "C", "D"}
for _, l := range nlabels {
if _, ok := Results[l]; !ok {
chk.Panic("1: %q alias in Entities is not available", l)
}
}
plabels := []string{"a", "b", "c", "d"}
for _, l := range plabels {
if _, ok := Results[l]; !ok {
chk.Panic("2: %q alias in Entities is not available", l)
}
}
if _, ok := Results["right side"]; !ok {
chk.Panic("3: %q alias in Entities is not available", "right side")
}
// check u-keys
ukeys := []string{"ux", "uy"}
for _, l := range nlabels {
for _, p := range Results[l] {
//io.Pfyel("p = %v\n", p)
if p == nil {
chk.Panic("1: p is nil")
}
for _, key := range ukeys {
if _, ok := p.Vals[key]; !ok {
chk.Panic("%s is not available in point", key)
}
}
}
}
// check s-keys
skeys := fem.StressKeys(Dom.Sim.Ndim)
for _, l := range plabels {
for _, p := range Results[l] {
//io.Pfgreen("q = %v\n", p)
if p == nil {
chk.Panic("2: p is nil")
}
for _, key := range skeys {
if _, ok := p.Vals[key]; !ok {
chk.Panic("%s is not available in point", key)
}
}
}
}
// check GetRes
uxC := GetRes("ux", "C", 0)
uxR := GetRes("ux", "right side", -1)
io.Pforan("uxC = %v\n", uxC)
io.Pforan("uxR = %v\n", uxR)
chk.IntAssert(len(uxC), 2)
idx := len(uxC) - 1
chk.Vector(tst, "uxR", 1e-17, uxR, []float64{uxC[idx], uxC[idx]})
// solution
var sol ana.CteStressPstrain
sol.Init(fun.Prms{
&fun.Prm{N: "qnH", V: -50},
&fun.Prm{N: "qnV", V: -100},
})
// check displacements
tolu := 1e-15
for _, l := range nlabels {
x := GetCoords(l)
ux := GetRes("ux", l, 0)
uy := GetRes("uy", l, 0)
io.Pforan("ux=%v uy=%v\n", ux, uy)
for j, t := range Times {
io.Pfyel("t=%g\n", t)
sol.CheckDispl(tst, t, []float64{ux[j], uy[j]}, x, tolu)
}
}
// check stresses
tolσ := 1e-14
for _, l := range plabels {
x := GetCoords(l)
sx := GetRes("sx", l, 0)
sy := GetRes("sy", l, 0)
sz := GetRes("sz", l, 0)
sxy := GetRes("sxy", l, 0)
for j, t := range Times {
io.Pfyel("t=%g\n", t)
sol.CheckStress(tst, t, []float64{sx[j], sy[j], sz[j], sxy[j]}, x, tolσ)
}
}
}