/// <summary> /// 問題を設定する /// </summary> /// <returns></returns> private bool setNewProblem() { bool success = false; try { if( ProbNo == 0 ) { CurTime = 0; uint id_base = 0; CIDConvEAMshCad conv = null; using(CCadObj2D cad2d = new CCadObj2D()) { // define shape IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(0,1.0) ); pts.Add( new CVector2D(5,1.0) ); pts.Add( new CVector2D(5,2.0) ); pts.Add( new CVector2D(0,2.0) ); cad2d.AddPolygon( pts ); World.Clear(); id_base = World.AddMesh( new CMesher2D(cad2d,0.2) ); conv = World.GetIDConverter(id_base); } //////////////// Id_disp = World.MakeField_FieldElemDim(id_base, 2, FIELD_TYPE.VECTOR2, FIELD_DERIVATION_TYPE.VALUE | FIELD_DERIVATION_TYPE.VELOCITY | FIELD_DERIVATION_TYPE.ACCELERATION, ELSEG_TYPE.CORNER); uint Id_disp_fix0; { // get fixed field IList<uint> aIdEAFix = new List<uint>(); aIdEAFix.Add( conv.GetIdEA_fromCad(2,CAD_ELEM_TYPE.EDGE) ); Id_disp_fix0 = World.GetPartialField(Id_disp,aIdEAFix); } if (FieldValueSetter != null) { FieldValueSetter.Dispose(); } FieldValueSetter = new CFieldValueSetter(Id_disp_fix0, World); FieldValueSetter.SetMathExp("sin(t)", 0, FIELD_DERIVATION_TYPE.VALUE,World); FieldValueSetter.SetMathExp("sin(0.5*t)",1, FIELD_DERIVATION_TYPE.VALUE,World); // set linear system Ls.Clear(); Ls.AddPattern_Field(Id_disp,World); Ls.SetFixedBoundaryCondition_Field(Id_disp_fix0,World); // set Preconditioner Prec.SetFillInLevel(0); Prec.SetLinearSystem(Ls.GetLs()); DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerEdge(Id_disp,false,World) ); DrawerAry.PushBack( new CDrawerFace(Id_disp,false,World) ); //DrawerAry.PushBack( new CDrawerEdge(Id_disp,true ,World) ); DrawerAry.InitTrans(Camera); } success = true; } catch (Exception exception) { Console.WriteLine(exception.Message + " " + exception.StackTrace); } ProbNo++; if (ProbNo == ProbCnt) ProbNo = 0; return success; }
/// <summary> /// コンストラクタ /// </summary> public MainLogic() { Disposed = false; Camera = new CCamera(); DrawerAry = new CDrawerArrayField(); World = new CFieldWorld(); FieldValueSetter = new CFieldValueSetter(); Ls = new CLinearSystem_Field(); Prec = new CPreconditioner_ILU(); // Glutのアイドル時処理でなく、タイマーで再描画イベントを発生させる MyTimer.Tick +=(sender, e) => { Glut.glutPostRedisplay(); }; MyTimer.Interval = 1000 / 60; }
/// <summary> /// 使用中のリソースをすべてクリーンアップします。 /// </summary> /// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param> protected virtual void Dispose(bool disposing) { if (Disposed) { return; } Disposed = true; MyTimer.Enabled = false; if (DrawerAry != null) { DrawerAry.Clear(); DrawerAry.Dispose(); DrawerAry = null; } if (Camera != null) { Camera.Dispose(); Camera = null; } if (World != null) { World.Clear(); World.Dispose(); World = null; } if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); FieldValueSetter = null; } if (Ls != null) { Ls.Clear(); Ls.Dispose(); Ls = null; } if (Prec != null) { Prec.Clear(); Prec.Dispose(); Prec = null; } }
/// <summary> /// 問題を設定する /// </summary> /// <returns></returns> private bool setNewProblem() { bool success = false; try { if (ProbNo == 0) { Id_base = 0; using(CCadObj2D cad2d = new CCadObj2D()) { IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(-0.5,-0.5) ); pts.Add( new CVector2D( 0.5,-0.5) ); pts.Add( new CVector2D( 0.5, 0.5) ); pts.Add( new CVector2D(-0.5, 0.5) ); uint id_l0 = cad2d.AddPolygon( pts ).id_l_add; World.Clear(); Id_base = World.AddMesh( new CMesher2D(cad2d,0.02) ); } Id_field_val = World.MakeField_FieldElemDim(Id_base, 2, FIELD_TYPE.SCALAR); System.Diagnostics.Debug.Assert( World.IsIdField(Id_field_val) ); clearFieldValueSetterAry(FieldValueSetterAry); { CFieldValueSetter fvs = new CFieldValueSetter(Id_field_val, World); fvs.SetMathExp("sin(10*sqrt(x^2+y^2)-2*PI*t)", 0, FIELD_DERIVATION_TYPE.VALUE, World); FieldValueSetterAry.Add(fvs); } DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerFace(Id_field_val, true, World, Id_field_val, -1.0, 1.0) ); DrawerAry.InitTrans( Camera ); } else if( ProbNo == 1 ) { clearFieldValueSetterAry(FieldValueSetterAry); CFieldValueSetter fvs = new CFieldValueSetter(Id_field_val, World); fvs.SetMathExp("sin(2*PI*x-t)*sin(2*PI*y-t)", 0, FIELD_DERIVATION_TYPE.VALUE, World); FieldValueSetterAry.Add(fvs); } else if( ProbNo == 2 ) { string mshfn = "../../../input_file/rect_quad.msh"; //string mshfn = "../../../input_file/hexa_tri.msh"; if (File.Exists(mshfn)) { using(CMesher2D msh2d = new CMesher2D()) { msh2d.ReadFromFile_GiDMsh(mshfn); World.Clear(); Id_base = World.AddMesh( msh2d ); Id_field_val = World.MakeField_FieldElemDim(Id_base,2,FIELD_TYPE.SCALAR); clearFieldValueSetterAry(FieldValueSetterAry); { CFieldValueSetter fvs = new CFieldValueSetter(Id_field_val, World); fvs.SetMathExp("sin(0.5*sqrt((x+1)^2+y^2)-0.1*t)", 0, FIELD_DERIVATION_TYPE.VALUE, World); FieldValueSetterAry.Add(fvs); } DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerFace(Id_field_val, true, World, Id_field_val, -1.0, 1.0) ); DrawerAry.InitTrans( Camera); } } else { Console.WriteLine("not exist:{0}", mshfn); MessageBox.Show(string.Format("メッシュファイル:{0}がありません", mshfn)); } } else if( ProbNo == 3 ) { using(CCadObj2D cad2d = new CCadObj2D()) { IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(-0.5,-0.5) ); pts.Add( new CVector2D( 0.5,-0.5) ); pts.Add( new CVector2D( 0.5, 0.5) ); pts.Add( new CVector2D(-0.5, 0.5) ); uint id_l0 = cad2d.AddPolygon( pts ).id_l_add; using(CMesher2D mesh2d = new CMesher2D(cad2d, 0.07)) using(CMesh3D_Extrude mesh3d = new CMesh3D_Extrude()) { mesh3d.Extrude(mesh2d, 1.0, 0.07); World.Clear(); Id_base = World.AddMesh( mesh3d ); } } Id_field_val = World.MakeField_FieldElemDim(Id_base,2,FIELD_TYPE.SCALAR); clearFieldValueSetterAry(FieldValueSetterAry); { CFieldValueSetter fvs = new CFieldValueSetter(Id_field_val,World); fvs.SetMathExp("sin(10*sqrt(x^2+y^2+z^2)-PI*t)", 0, FIELD_DERIVATION_TYPE.VALUE,World); FieldValueSetterAry.Add(fvs); } DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerFace(Id_field_val, true, World, Id_field_val, -1.0, 1.0) ); DrawerAry.InitTrans( Camera ); } else if( ProbNo == 4 ) { string mshfn = "../../../input_file/hexa_tri.msh"; if (File.Exists(mshfn)) { using(CMesher2D mesh2d = new CMesher2D()) using(CMesh3D_Extrude mesh3d = new CMesh3D_Extrude()) { mesh2d.ReadFromFile_GiDMsh(mshfn); mesh3d.Extrude(mesh2d, 5.0, 0.5); World.Clear(); Id_base = World.AddMesh( mesh3d ); } Id_field_val = World.MakeField_FieldElemDim(Id_base, 2, FIELD_TYPE.SCALAR); clearFieldValueSetterAry(FieldValueSetterAry); { CFieldValueSetter fvs = new CFieldValueSetter(Id_field_val,World); fvs.SetMathExp("sin(1.0*sqrt(x^2+y^2+z^2)-2*PI*t)", 0, FIELD_DERIVATION_TYPE.VALUE, World); FieldValueSetterAry.Add(fvs); } DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerFace(Id_field_val, true, World, Id_field_val, -1.0, 1.0) ); DrawerAry.InitTrans( Camera ); } else { Console.WriteLine("not exist:{0}", mshfn); MessageBox.Show(string.Format("メッシュファイル:{0}がありません", mshfn)); } } else if( ProbNo == 5 ) { using(CCadObj2D cad2d = new CCadObj2D()) { IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(-0.5,-0.5) ); pts.Add( new CVector2D( 0.5,-0.5) ); pts.Add( new CVector2D( 0.5, 0.5) ); pts.Add( new CVector2D(-0.5, 0.5) ); uint id_l0 = cad2d.AddPolygon( pts ).id_l_add; cad2d.AddVertex(CAD_ELEM_TYPE.EDGE, 1, new CVector2D(0.0, -0.5) ); cad2d.AddVertex(CAD_ELEM_TYPE.EDGE, 3, new CVector2D(0.0, 0.5) ); cad2d.ConnectVertex_Line(5,6); World.Clear(); Id_base = World.AddMesh( new CMesher2D(cad2d,0.02) ); } CIDConvEAMshCad conv = World.GetIDConverter(Id_base); Id_field_val = World.MakeField_FieldElemDim(Id_base, 2, FIELD_TYPE.SCALAR); System.Diagnostics.Debug.Assert( World.IsIdField(Id_field_val) ); { uint id_field0 = World.GetPartialField(Id_field_val, conv.GetIdEA_fromCad(1, CAD_ELEM_TYPE.LOOP)); System.Diagnostics.Debug.Assert( World.IsIdField(id_field0) ); uint id_field1 = World.GetPartialField(Id_field_val, conv.GetIdEA_fromCad(2, CAD_ELEM_TYPE.LOOP)); System.Diagnostics.Debug.Assert( World.IsIdField(id_field1) ); clearFieldValueSetterAry(FieldValueSetterAry); CFieldValueSetter fvs0 = new CFieldValueSetter(id_field0, World); fvs0.SetMathExp("sin(10*sqrt((x+0.5)^2+y^2)-2*PI*t)", 0, FIELD_DERIVATION_TYPE.VALUE, World); FieldValueSetterAry.Add(fvs0); CFieldValueSetter fvs1 = new CFieldValueSetter(id_field1, World); fvs1.SetMathExp("sin(10*sqrt((x-0.5)^2+y^2)-2*PI*t)", 0, FIELD_DERIVATION_TYPE.VALUE, World); FieldValueSetterAry.Add(fvs1); } DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerFace(Id_field_val, true, World, Id_field_val, -1.0, 1.0) ); DrawerAry.InitTrans( Camera ); } else if( ProbNo == 6 ) { using(CCadObj2D cad2d = new CCadObj2D()) { IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(-0.5,-0.5) ); pts.Add( new CVector2D( 0.5,-0.5) ); pts.Add( new CVector2D( 0.5, 0.5) ); pts.Add( new CVector2D(-0.5, 0.5) ); cad2d.AddPolygon( pts ); cad2d.AddVertex(CAD_ELEM_TYPE.EDGE, 1, new CVector2D(0.0, -0.5) ); cad2d.AddVertex(CAD_ELEM_TYPE.EDGE, 3, new CVector2D(0.0, 0.5) ); cad2d.ConnectVertex_Line(5,6); World.Clear(); Id_base = World.AddMesh( new CMesher2D(cad2d, 0.05) ); } CIDConvEAMshCad conv = World.GetIDConverter(Id_base); Id_field_val = World.MakeField_FieldElemAry(Id_base, conv.GetIdEA_fromCad(1, CAD_ELEM_TYPE.LOOP), FIELD_TYPE.SCALAR, FIELD_DERIVATION_TYPE.VALUE, ELSEG_TYPE.CORNER); clearFieldValueSetterAry(FieldValueSetterAry); { CFieldValueSetter fvs = new CFieldValueSetter(Id_field_val,World); fvs.SetMathExp("sin(10*sqrt((x+0.5)^2+y^2)-2*PI*t)", 0, FIELD_DERIVATION_TYPE.VALUE,World); FieldValueSetterAry.Add(fvs); } DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerFace(Id_field_val, true, World, Id_field_val, -1.0, 1.0) ); //DrawerAry.PushBack( new CDrawerFace(Id_field_val, true, World) ); DrawerAry.InitTrans( Camera ); } else if( ProbNo == 7 ) { uint id_field_grad = World.MakeField_FieldElemDim(Id_field_val, 2, FIELD_TYPE.VECTOR2,FIELD_DERIVATION_TYPE.VALUE, ELSEG_TYPE.BUBBLE); { CFieldValueSetter fvs = new CFieldValueSetter(id_field_grad, World); fvs.SetMathExp("0.1*sin(t)", 0, FIELD_DERIVATION_TYPE.VALUE, World); fvs.SetMathExp("0.1*cos(t)", 1, FIELD_DERIVATION_TYPE.VALUE, World); FieldValueSetterAry.Add(fvs); } DrawerAry.PushBack( new CDrawerVector(id_field_grad, World) ); DrawerAry.InitTrans( Camera ); } else if( ProbNo == 8 ) { string mshfn = "../../../input_file/cylinder_tet.msh"; if (File.Exists(mshfn)) { using(CMesher3D mesh3d = new CMesher3D()) { mesh3d.ReadFromFile_GiDMsh(mshfn); World.Clear(); Id_base = World.AddMesh( mesh3d ); } Id_field_val = World.MakeField_FieldElemDim(Id_base, 3, FIELD_TYPE.SCALAR); uint id_field_grad = World.MakeField_FieldElemDim(Id_field_val, 3, FIELD_TYPE.VECTOR3, FIELD_DERIVATION_TYPE.VALUE, ELSEG_TYPE.BUBBLE); clearFieldValueSetterAry(FieldValueSetterAry); { CFieldValueSetter fvs = new CFieldValueSetter(Id_field_val,World); fvs.SetMathExp("sin(t+0.5*x)", 0, FIELD_DERIVATION_TYPE.VALUE, World); FieldValueSetterAry.Add(fvs); } { CFieldValueSetter fvs = new CFieldValueSetter(id_field_grad, World); fvs.SetGradient(Id_field_val, World); FieldValueSetterAry.Add(fvs); } DrawerAry.Clear(); //DrawerAry.PushBack( new CDrawerFaceContour(Id_field_val,World,-1.0,1.0) ); DrawerAry.PushBack( new CDrawerVector(id_field_grad,World) ); DrawerAry.PushBack( new CDrawerEdge(id_field_grad,true,World) ); DrawerAry.InitTrans( Camera ); } else { Console.WriteLine("not exist:{0}", mshfn); MessageBox.Show(string.Format("メッシュファイル:{0}がありません", mshfn)); } } else if( ProbNo == 9 ) { string mshfn = "../../../input_file/cylinder_hex.msh"; if (File.Exists(mshfn)) { using(CMesher3D mesh3d = new CMesher3D()) { mesh3d.ReadFromFile_GiDMsh(mshfn); World.Clear(); Id_base = World.AddMesh( mesh3d ); } Id_field_val = World.MakeField_FieldElemDim(Id_base, 3, FIELD_TYPE.SCALAR); uint id_field_grad = World.MakeField_FieldElemDim(Id_field_val, 3, FIELD_TYPE.VECTOR3, FIELD_DERIVATION_TYPE.VALUE, ELSEG_TYPE.BUBBLE); clearFieldValueSetterAry(FieldValueSetterAry); { CFieldValueSetter fvs = new CFieldValueSetter(Id_field_val, World); fvs.SetMathExp("sin(t+0.5*x)", 0, FIELD_DERIVATION_TYPE.VALUE, World); FieldValueSetterAry.Add(fvs); } { CFieldValueSetter fvs = new CFieldValueSetter(id_field_grad, World); fvs.SetGradient(Id_field_val, World); FieldValueSetterAry.Add(fvs); } DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerVector(id_field_grad, World) ); DrawerAry.PushBack( new CDrawerEdge(id_field_grad,true, World) ); DrawerAry.InitTrans( Camera ); } else { Console.WriteLine("not exist:{0}", mshfn); MessageBox.Show(string.Format("メッシュファイル:{0}がありません", mshfn)); } } else if( ProbNo == 10 ) { //string mshfn = "../../../input_file/rect_quad.msh"; string mshfn = "../../../input_file/hexa_tri.msh"; if (File.Exists(mshfn)) { using(CMesher2D msh2d = new CMesher2D()) { msh2d.ReadFromFile_GiDMsh(mshfn); World.Clear(); Id_base = World.AddMesh( msh2d ); } Id_field_val = World.MakeField_FieldElemDim(Id_base, 2, FIELD_TYPE.SCALAR, FIELD_DERIVATION_TYPE.VALUE, ELSEG_TYPE.BUBBLE); clearFieldValueSetterAry(FieldValueSetterAry); { CFieldValueSetter fvs = new CFieldValueSetter(Id_field_val, World); fvs.SetMathExp("sin(x+y-0.1*t)", 0, FIELD_DERIVATION_TYPE.VALUE, World); FieldValueSetterAry.Add(fvs); } DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerFace(Id_field_val,true,World,Id_field_val,-1.0,1.0) ); DrawerAry.InitTrans(Camera); } else { Console.WriteLine("not exist:{0}", mshfn); MessageBox.Show(string.Format("メッシュファイル:{0}がありません", mshfn)); } } else if( ProbNo == 11 ) { //string mshfn = "../../../input_file/rect_quad.msh"; string mshfn = "../../../input_file/hexa_tri.msh"; if (File.Exists(mshfn)) { using(CMesher2D msh2d = new CMesher2D()) using(CMesh3D_Extrude mesh3d = new CMesh3D_Extrude()) { msh2d.ReadFromFile_GiDMsh(mshfn); mesh3d.Extrude(msh2d, 5.0, 1); World.Clear(); Id_base = World.AddMesh( mesh3d ); } Id_field_val = World.MakeField_FieldElemDim(Id_base, 3, FIELD_TYPE.SCALAR, FIELD_DERIVATION_TYPE.VALUE, ELSEG_TYPE.BUBBLE); clearFieldValueSetterAry(FieldValueSetterAry); { CFieldValueSetter fvs = new CFieldValueSetter(Id_field_val, World); fvs.SetMathExp("sin(0.5*sqrt(x^2+y^2+z^2)-2*PI*t)", 0, FIELD_DERIVATION_TYPE.VALUE, World); FieldValueSetterAry.Add(fvs); } DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerFace(Id_field_val,true,World, Id_field_val,-1.0,1.0) ); //DrawerAry.PushBack( new CDrawerFace(Id_field_val,true,World) ); DrawerAry.InitTrans(Camera); } else { Console.WriteLine("not exist:{0}", mshfn); MessageBox.Show(string.Format("メッシュファイル:{0}がありません", mshfn)); } } else if( ProbNo == 12 ) { // scalar field and vector field using(CCadObj2D cad2d = new CCadObj2D()) { IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(-0.5,-0.5) ); pts.Add( new CVector2D( 0.5,-0.5) ); pts.Add( new CVector2D( 0.5, 0.5) ); pts.Add( new CVector2D(-0.5, 0.5) ); uint id_l0 = cad2d.AddPolygon( pts ).id_l_add; World.Clear(); Id_base = World.AddMesh( new CMesher2D(cad2d, 0.1) ); } Id_field_val = World.MakeField_FieldElemDim(Id_base, 2, FIELD_TYPE.SCALAR, FIELD_DERIVATION_TYPE.VALUE, ELSEG_TYPE.CORNER|ELSEG_TYPE.BUBBLE); System.Diagnostics.Debug.Assert( World.IsIdField(Id_field_val) ); uint id_field_vec = World.MakeField_FieldElemDim(Id_base, 2, FIELD_TYPE.VECTOR2, FIELD_DERIVATION_TYPE.VALUE, ELSEG_TYPE.CORNER|ELSEG_TYPE.BUBBLE); System.Diagnostics.Debug.Assert( World.IsIdField(id_field_vec) ); clearFieldValueSetterAry(FieldValueSetterAry); { CFieldValueSetter fvs = new CFieldValueSetter(Id_field_val, World); fvs.SetMathExp("sin(10*sqrt(x^2+y^2)-2*PI*t)", 0, FIELD_DERIVATION_TYPE.VALUE, World); FieldValueSetterAry.Add(fvs); } { CFieldValueSetter fvs = new CFieldValueSetter(id_field_vec, World); fvs.SetMathExp("0.05*sin(t)", 0, FIELD_DERIVATION_TYPE.VALUE, World); fvs.SetMathExp("0.05*cos(t)", 1, FIELD_DERIVATION_TYPE.VALUE, World); FieldValueSetterAry.Add(fvs); } DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerFace(Id_field_val, true, World, Id_field_val, -1.0, 1.0) ); DrawerAry.PushBack( new CDrawerVector(id_field_vec, World) ); DrawerAry.InitTrans( Camera ); } success = true; } catch (Exception exception) { Console.WriteLine(exception.Message + " " + exception.StackTrace); } ProbNo++; if (ProbNo == ProbCnt) ProbNo = 0; return success; }
/// <summary> /// 問題を設定する /// </summary> /// <returns></returns> private bool setNewProblem() { bool success = false; try { if ( ProbNo == 0 ) { using (CCadObj2D cad2d = new CCadObj2D()) using (CMesh3D_Extrude msh3d = new CMesh3D_Extrude()) { // 形を作る IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(0.0,0.0) ); pts.Add( new CVector2D(5.0,0.0) ); pts.Add( new CVector2D(5.0,1.0) ); pts.Add( new CVector2D(0.0,1.0) ); cad2d.AddPolygon( pts ); msh3d.Extrude( new CMesher2D(cad2d,0.4), 1.0, 0.4 );// 突き出しによって3次元メッシュを作る World.Clear(); Id_base = World.AddMesh( msh3d ); } CIDConvEAMshCad conv = World.GetIDConverter(Id_base); Solid.SetDomain_Field(Id_base,World); Solid.SetYoungPoisson(250, 0.3);// ヤング率とポアソン比の設定 //Solid.SetGeometricalNonLinear();// 幾何学的非線形性を考慮する Solid.UnSetGeometricalNonLinear(); Solid.SetStationary(); Dt = 0.1; Solid.SetTimeIntegrationParameter(Dt,0.6); //Solid.SetSaveStiffMat(); //uint id_field_bc0 = Solid.AddFixElemAry(7,World); uint id_field_bc1 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(2,CAD_ELEM_TYPE.EDGE,2),World); FieldValueSetter = new CFieldValueSetter(id_field_bc1,World); FieldValueSetter.SetMathExp("sin(5*sin(0.1*t))", 1,FIELD_DERIVATION_TYPE.VALUE, World);// bc1_fieldのy座標に単振動を追加 FieldValueSetter.SetMathExp("cos(5*sin(0.1*t))", 2,FIELD_DERIVATION_TYPE.VALUE, World);// bc1_fieldのy座標に単振動を追加 // 描画オブジェクトの登録 DrawerAry.Clear(); Id_field_disp = Solid.GetIdField_Disp(); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); } else if ( ProbNo == 1 ) { Solid.UnSetStationary(); Solid.UnSetGeometricalNonLinear();// 幾何学的非線形性を考慮しない Solid.UnSetSaveStiffMat();// 全剛性行列を保存する. } else if ( ProbNo == 2 ) { Solid.SetGeometricalNonLinear(); } else if ( ProbNo == 3 ) { CIDConvEAMshCad conv = World.GetIDConverter(Id_base); uint id_field_bc0 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(4,CAD_ELEM_TYPE.EDGE,2),World); Solid.SetStationary(); } else if ( ProbNo == 4 ) { Solid.UnSetStationary(); } else if ( ProbNo == 5 ) { string mshfn = "../../../input_file/cylinder_tet.msh"; if (File.Exists(mshfn)) { using (CMesher3D mesh3d = new CMesher3D()) { mesh3d.ReadFromFile_GiDMsh(mshfn); World.Clear(); Id_base = World.AddMesh( mesh3d ); } Solid.SetDomain_Field(Id_base,World); Solid.SetYoungPoisson(200, 0.43);// ヤング率とポアソン比の設定 Solid.UnSetGeometricalNonLinear();// 幾何学的非線形性を考慮しない. Solid.UnSetStationary(); Solid.UnSetSaveStiffMat(); uint id_field_bc0 = Solid.AddFixElemAry(3,World); uint id_field_bc1 = Solid.AddFixElemAry(4,World); FieldValueSetter = new CFieldValueSetter(id_field_bc1,World); FieldValueSetter.SetMathExp("5*sin(2*t)^2", 0, FIELD_DERIVATION_TYPE.VALUE, World);// bc1_fieldのy座標に単振動を追加 // 描画オブジェクトの登録 DrawerAry.Clear(); Id_field_disp = Solid.GetIdField_Disp(); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); } else { Console.WriteLine("not exist:{0}", mshfn); MessageBox.Show(string.Format("メッシュファイル:{0}がありません", mshfn)); } } else if ( ProbNo == 6 ) { Solid.SetStationary(); } else if ( ProbNo == 7 ) { string mshfn = "../../../input_file/rect_quad.msh"; if (File.Exists(mshfn)) { using (CMesher2D mesh2d = new CMesher2D()) using (CMesh3D_Extrude mesh3d = new CMesh3D_Extrude()) { mesh2d.ReadFromFile_GiDMsh(mshfn); mesh3d.Extrude(mesh2d, 5.0, 0.5 ); World.Clear(); Id_base = World.AddMesh(mesh3d); } CIDConvEAMshCad conv = World.GetIDConverter(Id_base); Solid.SetDomain_Field(Id_base,World); Solid.SetYoungPoisson(100, 0.3);// ヤング率とポアソン比の設定 Solid.UnSetSaveStiffMat(); Solid.UnSetStationary(); Dt = 0.1; Solid.SetTimeIntegrationParameter(Dt,0.52); //Solid.SetGeometricalNonLinear();// 幾何学的非線形性を考慮する. Solid.UnSetGeometricalNonLinear();// 幾何学的非線形性を考慮しない. uint id_field_bc0 = Solid.AddFixElemAry(conv.GetIdEA_fromMshExtrude(1,1),World); uint id_field_bc1 = Solid.AddFixElemAry(conv.GetIdEA_fromMshExtrude(3,2),World); FieldValueSetter = new CFieldValueSetter(id_field_bc1,World); FieldValueSetter.SetMathExp("2*sin(t)", 0,FIELD_DERIVATION_TYPE.VALUE, World);// bc1_fieldのy座標に単振動を追加 // 描画オブジェクトの登録 DrawerAry.Clear(); Id_field_disp = Solid.GetIdField_Disp(); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); } else { Console.WriteLine("not exist:{0}", mshfn); MessageBox.Show(string.Format("メッシュファイル:{0}がありません", mshfn)); } } else if ( ProbNo == 8 ) { Solid.UnSetGeometricalNonLinear(); // 幾何学的非線形性を考慮しない Solid.SetStationary(); } success = true; } catch (Exception exception) { Console.WriteLine(exception.Message + " " + exception.StackTrace); } ProbNo++; if (ProbNo == ProbCnt) ProbNo = 0; return success; }
/// <summary> /// 使用中のリソースをすべてクリーンアップします。 /// </summary> /// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param> protected virtual void Dispose(bool disposing) { if (Disposed) { return; } Disposed = true; if (DrawerAry != null) { DrawerAry.Clear(); DrawerAry.Dispose(); DrawerAry = null; } if (Camera != null) { Camera.Dispose(); Camera = null; } if (Solid != null) { Solid.Clear(); Solid.Dispose(); Solid = null; } if (World != null) { World.Clear(); World.Dispose(); World = null; } if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); FieldValueSetter = null; } }
///////////////////////////////////////////////// // 定数 ///////////////////////////////////////////////// /// <summary> /// コンストラクタ /// </summary> public MainLogic() { Disposed = false; Camera = new CCamera(); DrawerAry = new CDrawerArrayField(); World = new CFieldWorld(); FieldValueSetter = new CFieldValueSetter(); Solid = new CEqn_Solid3D_Linear(); // Glutのアイドル時処理でなく、タイマーで再描画イベントを発生させる MyTimer.Tick += (sender, e) => { Glut.glutPostRedisplay(); }; MyTimer.Interval = 1000 / 60; }
/// <summary> /// 問題を設定する /// </summary> /// <returns></returns> private bool setNewProblem() { bool success = false; try { if (ProbNo == 0) { // linear Solid stationary analysis Id_field_disp_fix0 = 0; Id_field_temp = 0; Id_field_stress = 0; Id_field_equiv_stress = 0; //////////////// uint id_base = 0; CIDConvEAMshCad conv = null; using (CCadObj2D cad2d = new CCadObj2D()) { { // define shape IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(0.0,0.0) ); pts.Add( new CVector2D(5.0,0.0) ); pts.Add( new CVector2D(5.0,1.0) ); pts.Add( new CVector2D(0.0,1.0) ); cad2d.AddPolygon( pts ); } World.Clear(); id_base = World.AddMesh( new CMesher2D(cad2d,0.1) ); conv = World.GetIDConverter(id_base); } Solid.Clear(); Solid.UpdateDomain_Field(id_base, World); Solid.SetSaveStiffMat(false); Solid.SetStationary(true); // Setting Material Parameter Solid.SetYoungPoisson(10.0,0.3,true); // planter stress Solid.SetGeometricalNonlinear(false); Solid.SetGravitation(0.0,0.0); Solid.SetTimeIntegrationParameter(Dt,0.7); uint id_field_bc0 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(2,CAD_ELEM_TYPE.EDGE),World); uint id_field_bc1 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(4,CAD_ELEM_TYPE.EDGE),World); if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); } FieldValueSetter = new CFieldValueSetter(id_field_bc0,World); FieldValueSetter.SetMathExp("sin(t*PI*2*0.1)", 1,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field y axis // Setting Visualiziation DrawerAry.Clear(); Id_field_disp = Solid.GetIdField_Disp(); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); // set view transformation } else if( ProbNo == 1 ) // save stiffness matrix for the efficency of computation { Solid.SetSaveStiffMat(true); } else if( ProbNo == 2 ) // non-stationary analysis { Solid.SetSaveStiffMat(true); Solid.SetStationary(false); } else if( ProbNo == 3 ) // set stiffer material { Solid.SetYoungPoisson(50,0.3,true); } else if( ProbNo == 4 ) // set more stiffer material { Solid.SetYoungPoisson(100,0.3,true); } else if( ProbNo == 5 ) // geometrical non-linear stationaly { Solid.SetStationary(true); Solid.SetGeometricalNonlinear(true); } else if( ProbNo == 6 ) // geometrical non-linear non-stationary { Solid.SetYoungPoisson(10,0.0,true); Solid.SetStationary(false); Solid.SetGeometricalNonlinear(true); } else if( ProbNo == 7 ) // display equivalent stress field in deformedconfigulation { Id_field_equiv_stress = World.MakeField_FieldElemDim(Id_field_disp, 2, DelFEM4NetFem.Field.FIELD_TYPE.SCALAR, DelFEM4NetFem.Field.FIELD_DERIVATION_TYPE.VALUE, DelFEM4NetFem.Field.ELSEG_TYPE.BUBBLE); Solid.SetGeometricalNonlinear(false); Solid.SetStationary(true); // set up visualization DrawerAry.Clear(); Id_field_disp = Solid.GetIdField_Disp(); DrawerAry.PushBack( new CDrawerFace(Id_field_equiv_stress,false,World,Id_field_equiv_stress, 0,0.5) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); // init view transformation } else if( ProbNo == 8 ) // display equivalent stress field in initial configulation { // set up visualization DrawerAry.Clear(); Id_field_disp = Solid.GetIdField_Disp(); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World,Id_field_equiv_stress, 0,0.5) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); // init view transformation } else if( ProbNo == 9 ) // thermal-Solid analysis { Id_field_equiv_stress = 0; Id_field_stress = 0; //////////////// uint id_base = 0; CIDConvEAMshCad conv = null; using (CCadObj2D cad2d = new CCadObj2D()) { { // define shape IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(0.0,0.0) ); pts.Add( new CVector2D(3.0,0.0) ); pts.Add( new CVector2D(3.0,1.0) ); pts.Add( new CVector2D(2.0,1.0) ); pts.Add( new CVector2D(1.0,1.0) ); pts.Add( new CVector2D(0.0,1.0) ); cad2d.AddPolygon( pts ); } World.Clear(); id_base = World.AddMesh( new CMesher2D(cad2d,0.1) ); conv = World.GetIDConverter(id_base); } Solid.UpdateDomain_Field(id_base,World); Solid.SetSaveStiffMat(false); Solid.SetStationary(true); // set material property Solid.SetYoungPoisson(10.0,0.3,true); // set planer stress Solid.SetGeometricalNonlinear(false); // geometricaly linear model Solid.SetGravitation(0.0,-0.1); Solid.SetTimeIntegrationParameter(Dt); // set time setp uint id_field_bc0 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(2,CAD_ELEM_TYPE.EDGE),World); uint id_field_bc1 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(6,CAD_ELEM_TYPE.EDGE),World); // set temparature field Id_field_temp = World.MakeField_FieldElemDim(Id_field_disp, 2, DelFEM4NetFem.Field.FIELD_TYPE.SCALAR, DelFEM4NetFem.Field.FIELD_DERIVATION_TYPE.VALUE, DelFEM4NetFem.Field.ELSEG_TYPE.CORNER); if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); } FieldValueSetter = new CFieldValueSetter(Id_field_temp,World); FieldValueSetter.SetMathExp("sin(6.28*y)*sin(x)*sin(t)", 0,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field y axis Solid.SetThermalStress(Id_field_temp); Solid.ClearFixElemAry(3,World); DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false, World, Id_field_temp, -1,1) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); // set view transformation } else if( ProbNo == 10 ) // show contour in undeformed configuration { DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerFace(Id_field_temp,true, World, Id_field_temp, -1,1) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); // set view transformation } else if( ProbNo == 11 ) // stop considering thermal-effect { Solid.SetThermalStress(0); } else if( ProbNo == 12 ) { uint id_base = 0; CIDConvEAMshCad conv = null; // get ID converter using(CCadObj2D cad2d = new CCadObj2D()) { { // define shape IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(0.0,0.0) ); pts.Add( new CVector2D(1.0,0.0) ); pts.Add( new CVector2D(1.0,1.0) ); pts.Add( new CVector2D(0.0,1.0) ); uint id_l = cad2d.AddPolygon( pts ).id_l_add; uint id_v1 = cad2d.AddVertex(CAD_ELEM_TYPE.LOOP,id_l, new CVector2D(0.3,0.2)).id_v_add; uint id_v2 = cad2d.AddVertex(CAD_ELEM_TYPE.LOOP,id_l, new CVector2D(0.7,0.2)).id_v_add; uint id_v3 = cad2d.AddVertex(CAD_ELEM_TYPE.LOOP,id_l, new CVector2D(0.7,0.8)).id_v_add; uint id_v4 = cad2d.AddVertex(CAD_ELEM_TYPE.LOOP,id_l, new CVector2D(0.3,0.8)).id_v_add; cad2d.ConnectVertex_Line(id_v1,id_v2); cad2d.ConnectVertex_Line(id_v2,id_v3); cad2d.ConnectVertex_Line(id_v3,id_v4); cad2d.ConnectVertex_Line(id_v4,id_v1); } World.Clear(); id_base = World.AddMesh( new CMesher2D(cad2d,0.05) ); conv = World.GetIDConverter(id_base); // get ID converter } Solid.SetDomain_FieldEA(id_base,conv.GetIdEA_fromCad(1,CAD_ELEM_TYPE.LOOP),World); Solid.SetSaveStiffMat(true); Solid.SetStationary(true); Solid.SetTimeIntegrationParameter(Dt); // set time step Solid.SetYoungPoisson(2.5,0.3,true); // planer stress Solid.SetGeometricalNonlinear(false); // set geometrical liner Solid.SetGravitation(0.0,0.0); // set gravitation uint id_field_bc1 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(3,CAD_ELEM_TYPE.EDGE),World); uint id_field_bc2 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(1,CAD_ELEM_TYPE.EDGE),World); if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); } FieldValueSetter = new CFieldValueSetter(id_field_bc1,World); FieldValueSetter.SetMathExp("0.3*sin(1.5*t)", 0,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field x axis FieldValueSetter.SetMathExp("0.1*(cos(t)+1)", 1,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field y axis // set visualization DrawerAry.Clear(); Id_field_disp = Solid.GetIdField_Disp(); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); // set view transformation } else if( ProbNo == 13 ) { Solid.SetSaveStiffMat(true); } else if( ProbNo == 14 ) { Solid.SetSaveStiffMat(false); Solid.SetStationary(false); } else if( ProbNo == 15 ){ Solid.SetStationary(true); Solid.SetGeometricalNonlinear(true); } else if( ProbNo == 16 ){ Solid.SetStationary(false); Solid.SetGeometricalNonlinear(true); } else if( ProbNo == 17 ) // hard and soft Solid are connected { uint id_base = 0; CIDConvEAMshCad conv = null; using(CCadObj2D cad2d = new CCadObj2D()) { // define shape IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(0.0,0.0) ); pts.Add( new CVector2D(1.0,0.0) ); pts.Add( new CVector2D(1.0,1.0) ); pts.Add( new CVector2D(0.0,1.0) ); cad2d.AddPolygon( pts ); uint id_v1 = cad2d.AddVertex(CAD_ELEM_TYPE.EDGE,1, new CVector2D(0.5,0.0)).id_v_add; uint id_v2 = cad2d.AddVertex(CAD_ELEM_TYPE.EDGE,3, new CVector2D(0.5,1.0)).id_v_add; cad2d.ConnectVertex_Line(id_v1,id_v2); World.Clear(); id_base = World.AddMesh( new CMesher2D(cad2d,0.05) ); conv = World.GetIDConverter(id_base); // get ID converter } Solid.SetDomain_FieldEA(id_base,conv.GetIdEA_fromCad(2,CAD_ELEM_TYPE.LOOP),World); Solid.SetTimeIntegrationParameter(Dt); Solid.SetSaveStiffMat(false); Solid.SetStationary(true); Solid.SetYoungPoisson(3.0,0.3,true); Solid.SetGeometricalNonlinear(false); // set geometrically linear model Solid.SetGravitation(0.0,0.0); uint id_field_bc1 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(3,CAD_ELEM_TYPE.EDGE),World); uint id_field_bc2 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(5,CAD_ELEM_TYPE.EDGE),World); if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); } FieldValueSetter = new CFieldValueSetter(id_field_bc1,World); FieldValueSetter.SetMathExp("0.3*sin(1.5*t)", 0,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field x axis FieldValueSetter.SetMathExp("0.1*(cos(t)+1)+0.1", 1,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field y axis // set up visualization DrawerAry.Clear(); Id_field_disp = Solid.GetIdField_Disp(); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); //DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.PushBack( new CDrawerEdge(id_base,true,World) ); DrawerAry.InitTrans(Camera); // set view trnsformation } else if( ProbNo == 18 ) { Solid.SetSaveStiffMat(true); } else if( ProbNo == 19 ) { Solid.SetSaveStiffMat(false); Solid.SetStationary(false); } else if( ProbNo == 20 ) { Solid.SetStationary(true); Solid.SetGeometricalNonlinear(true); } else if( ProbNo == 21 ) { Solid.SetStationary(false); Solid.SetGeometricalNonlinear(true); } else if( ProbNo == 22 ) // 4 different type of Solid combined { uint id_base = 0; CIDConvEAMshCad conv = null; using(CCadObj2D cad2d = new CCadObj2D()) { // define shape IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(0.0,0.0) ); pts.Add( new CVector2D(2.0,0.0) ); pts.Add( new CVector2D(2.0,0.5) ); pts.Add( new CVector2D(0.0,0.5) ); cad2d.AddPolygon( pts ); uint id_v5 = cad2d.AddVertex(CAD_ELEM_TYPE.EDGE,1, new CVector2D(1.5,0.0)).id_v_add; uint id_v3 = cad2d.AddVertex(CAD_ELEM_TYPE.EDGE,1, new CVector2D(1.0,0.0)).id_v_add; uint id_v1 = cad2d.AddVertex(CAD_ELEM_TYPE.EDGE,1, new CVector2D(0.5,0.0)).id_v_add; uint id_v2 = cad2d.AddVertex(CAD_ELEM_TYPE.EDGE,3, new CVector2D(0.5,0.5)).id_v_add; uint id_v4 = cad2d.AddVertex(CAD_ELEM_TYPE.EDGE,3, new CVector2D(1.0,0.5)).id_v_add; uint id_v6 = cad2d.AddVertex(CAD_ELEM_TYPE.EDGE,3, new CVector2D(1.5,0.5)).id_v_add; cad2d.ConnectVertex_Line(id_v1,id_v2); cad2d.ConnectVertex_Line(id_v3,id_v4); cad2d.ConnectVertex_Line(id_v5,id_v6); World.Clear(); id_base = World.AddMesh( new CMesher2D(cad2d,0.05) ); conv = World.GetIDConverter(id_base); // get ID converter } Solid.UpdateDomain_Field(id_base,World); // set domain of Solid analysis Solid.SetTimeIntegrationParameter(Dt); // set time step Solid.SetSaveStiffMat(false); Solid.SetStationary(true); // set material property Solid.SetYoungPoisson(1.0,0.3,true); Solid.SetGeometricalNonlinear(false); Solid.SetGravitation(0.0,-0.0); { // St.Venant-Kirchhoff material DelFEM4NetFem.Eqn.CEqn_Solid2D eqn = Solid.GetEquation(conv.GetIdEA_fromCad(1,CAD_ELEM_TYPE.LOOP)); eqn.SetGeometricalNonlinear(true); Solid.SetEquation(eqn); } { // soft elastic material DelFEM4NetFem.Eqn.CEqn_Solid2D eqn = Solid.GetEquation(conv.GetIdEA_fromCad(2,CAD_ELEM_TYPE.LOOP)); eqn.SetYoungPoisson(0.1,0.3,true); Solid.SetEquation(eqn); } uint Id_field_temp = World.MakeField_FieldElemAry(id_base, conv.GetIdEA_fromCad(3,CAD_ELEM_TYPE.LOOP), DelFEM4NetFem.Field.FIELD_TYPE.SCALAR, DelFEM4NetFem.Field.FIELD_DERIVATION_TYPE.VALUE, DelFEM4NetFem.Field.ELSEG_TYPE.CORNER); if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); } FieldValueSetter = new CFieldValueSetter(Id_field_temp,World); FieldValueSetter.SetMathExp("0.1*sin(3.14*4*y)*sin(2*t)", 0,FIELD_DERIVATION_TYPE.VALUE, World); { // linear elastic material concidering thrmal-Solid DelFEM4NetFem.Eqn.CEqn_Solid2D eqn = Solid.GetEquation(conv.GetIdEA_fromCad(3,CAD_ELEM_TYPE.LOOP)); eqn.SetThermalStress(Id_field_temp); Solid.SetEquation(eqn); } { // hard elastic material DelFEM4NetFem.Eqn.CEqn_Solid2D eqn = Solid.GetEquation(conv.GetIdEA_fromCad(4,CAD_ELEM_TYPE.LOOP)); eqn.SetYoungPoisson(10,0.3,true); Solid.SetEquation(eqn); } Id_field_disp_fix0 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(2,CAD_ELEM_TYPE.EDGE),World); // set up visualization DrawerAry.Clear(); Id_field_disp = Solid.GetIdField_Disp(); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); //DrawerAry.PushBack( new CDrawerEdge(id_base,false,World) ); DrawerAry.InitTrans(Camera); // set view transformation } else if( ProbNo == 23 ) { Solid.SetRho(0.0001); Solid.SetStationary(false); if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); } FieldValueSetter = new CFieldValueSetter(Id_field_disp_fix0,World); FieldValueSetter.SetMathExp("0.5*cos(2*t)", 1,FIELD_DERIVATION_TYPE.VALUE, World); } else if( ProbNo == 24 ) { uint id_base = 0; CIDConvEAMshCad conv = null; using(CCadObj2D cad2d = new CCadObj2D()) { // define shape IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(0.0,0.0) ); pts.Add( new CVector2D(2.0,0.0) ); pts.Add( new CVector2D(2.0,1.0) ); pts.Add( new CVector2D(0.0,1.0) ); cad2d.AddPolygon( pts ); uint id_v1 = cad2d.AddVertex(CAD_ELEM_TYPE.EDGE,1, new CVector2D(1.0,0.0)).id_v_add; uint id_v2 = cad2d.AddVertex(CAD_ELEM_TYPE.EDGE,3, new CVector2D(1.0,1.0)).id_v_add; cad2d.ConnectVertex_Line(id_v1,id_v2); World.Clear(); id_base = World.AddMesh( new CMesher2D(cad2d,0.05) ); conv = World.GetIDConverter(id_base); // ID converter } Solid.UpdateDomain_Field(id_base,World); // set displacement field Solid.SetTimeIntegrationParameter(Dt); // set time step Solid.SetSaveStiffMat(false); Solid.SetStationary(false); // set material property Solid.SetYoungPoisson(1.0,0.3,true); // planter stress Solid.SetGeometricalNonlinear(false); Solid.SetGravitation(0.0,-0.0); Solid.SetRho(0.001); { // soft elastic material DelFEM4NetFem.Eqn.CEqn_Solid2D eqn = Solid.GetEquation(conv.GetIdEA_fromCad(1,CAD_ELEM_TYPE.LOOP)); eqn.SetYoungPoisson(0.1,0.3,true); Solid.SetEquation(eqn); } { // hard elastic material DelFEM4NetFem.Eqn.CEqn_Solid2D eqn = Solid.GetEquation(conv.GetIdEA_fromCad(2,CAD_ELEM_TYPE.LOOP)); eqn.SetYoungPoisson(100000000,0.3,true); Solid.SetEquation(eqn); } //Id_field_disp_fix0 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(2,1),World); uint id_field_bc1 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(4,CAD_ELEM_TYPE.EDGE),World); if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); } FieldValueSetter = new CFieldValueSetter(id_field_bc1,World); FieldValueSetter.SetMathExp("0.3*sin(1.5*t)", 0,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field x axis FieldValueSetter.SetMathExp("0.1*(cos(t)+1)+0.1", 1,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field y axis // set up visualization DrawerAry.Clear(); Id_field_disp = Solid.GetIdField_Disp(); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.InitTrans(Camera); // initialize view transmation } else if( ProbNo == 25 ) { uint id_base = 0; CIDConvEAMshCad conv = null; uint id_base2 = 0; using(CCadObj2D cad2d = new CCadObj2D()) { uint id_l; uint id_e1,id_e2,id_e3,id_e4,id_e5; { // define shape IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(0.0,0.0) ); pts.Add( new CVector2D(0.2,0.0) ); pts.Add( new CVector2D(1.0,0.0) ); pts.Add( new CVector2D(1.0,1.0) ); pts.Add( new CVector2D(0.0,1.0) ); id_l = cad2d.AddPolygon( pts ).id_l_add; uint id_v1 = cad2d.AddVertex(CAD_ELEM_TYPE.LOOP, id_l, new CVector2D(0.2,0.5) ).id_v_add; id_e1 = cad2d.ConnectVertex_Line(2,id_v1).id_e_add; uint id_v2 = cad2d.AddVertex(CAD_ELEM_TYPE.LOOP, id_l, new CVector2D(0.5,0.2) ).id_v_add; uint id_v3 = cad2d.AddVertex(CAD_ELEM_TYPE.LOOP, id_l, new CVector2D(0.5,0.5) ).id_v_add; uint id_v4 = cad2d.AddVertex(CAD_ELEM_TYPE.LOOP, id_l, new CVector2D(0.5,0.8) ).id_v_add; uint id_v5 = cad2d.AddVertex(CAD_ELEM_TYPE.LOOP, id_l, new CVector2D(0.8,0.5) ).id_v_add; uint id_v6 = cad2d.AddVertex(CAD_ELEM_TYPE.LOOP, id_l, new CVector2D(0.3,0.5) ).id_v_add; id_e2 = cad2d.ConnectVertex_Line(id_v2,id_v3).id_e_add; id_e3 = cad2d.ConnectVertex_Line(id_v3,id_v4).id_e_add; id_e4 = cad2d.ConnectVertex_Line(id_v3,id_v5).id_e_add; id_e5 = cad2d.ConnectVertex_Line(id_v3,id_v6).id_e_add; } using(CMesher2D mesh2d = new CMesher2D(cad2d,0.1)) { World.Clear(); id_base = World.AddMesh(mesh2d); conv = World.GetIDConverter(id_base); // get ID converter { // cut mesh IList<uint> mapVal2Co = null; IList< IList<int> > aLnods = null; { IList<uint> aIdMsh_Inc = new List<uint>(); aIdMsh_Inc.Add( mesh2d.GetElemID_FromCadID(id_l,CAD_ELEM_TYPE.LOOP) ); IList<uint> aIdMshCut = new List<uint>(); aIdMshCut.Add( mesh2d.GetElemID_FromCadID(id_e1,CAD_ELEM_TYPE.EDGE) ); aIdMshCut.Add( mesh2d.GetElemID_FromCadID(id_e2,CAD_ELEM_TYPE.EDGE) ); aIdMshCut.Add( mesh2d.GetElemID_FromCadID(id_e3,CAD_ELEM_TYPE.EDGE) ); aIdMshCut.Add( mesh2d.GetElemID_FromCadID(id_e4,CAD_ELEM_TYPE.EDGE) ); aIdMshCut.Add( mesh2d.GetElemID_FromCadID(id_e5,CAD_ELEM_TYPE.EDGE) ); mesh2d.GetClipedMesh(out aLnods, out mapVal2Co, aIdMsh_Inc,aIdMshCut); } IList<uint> aIdEA_Inc = new List<uint>(); aIdEA_Inc.Add( conv.GetIdEA_fromCad(1,CAD_ELEM_TYPE.LOOP) ); id_base2 = World.SetCustomBaseField(id_base,aIdEA_Inc, aLnods, mapVal2Co); } } // mesh2d } // cad2d Solid.UpdateDomain_Field(id_base2, World); Solid.SetSaveStiffMat(false); Solid.SetStationary(true); // set material parameter Solid.SetYoungPoisson(10.0,0.3,true); Solid.SetGeometricalNonlinear(false); Solid.SetGravitation(0.0,0.0); Solid.SetTimeIntegrationParameter(Dt,0.7); uint id_field_bc0 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(3,CAD_ELEM_TYPE.EDGE),World); uint id_field_bc1 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(5,CAD_ELEM_TYPE.EDGE),World); if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); } FieldValueSetter = new CFieldValueSetter(id_field_bc0,World); FieldValueSetter.SetMathExp("0.1*sin(t*PI*2*0.1)", 0,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field x axis FieldValueSetter.SetMathExp("0.1*(1-cos(t*PI*2*0.1))",1,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field y axis // set visualization DrawerAry.Clear(); Id_field_disp = Solid.GetIdField_Disp(); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); // set view transformation } else if( ProbNo == 26 ) { uint id_base = 0; CIDConvEAMshCad conv = null; uint id_base2 = 0; using(CCadObj2D cad2d = new CCadObj2D()) { uint id_e; uint id_l; { // define shape IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(0.0,0.0) ); pts.Add( new CVector2D(5.0,0.0) ); pts.Add( new CVector2D(5.0,2.0) ); pts.Add( new CVector2D(0.0,2.0) ); id_l = cad2d.AddPolygon( pts ).id_l_add; uint id_v1 = cad2d.AddVertex(CAD_ELEM_TYPE.EDGE, 3, new CVector2D(2.5,2.0)).id_v_add; uint id_v2 = cad2d.AddVertex(CAD_ELEM_TYPE.LOOP, id_l, new CVector2D(2.5,1.0)).id_v_add; id_e = cad2d.ConnectVertex_Line(id_v1,id_v2).id_e_add; } using(CMesher2D mesh2d = new CMesher2D(cad2d,0.2)) { World.Clear(); CurTime = 0; id_base = World.AddMesh(mesh2d); conv = World.GetIDConverter(id_base); id_base2 = 0; { // cut mesh IList<uint> mapVal2Co = new List<uint>(); IList< IList<int> > aLnods = new List<IList<int>>(); { IList<uint> aIdMsh_Inc = new List<uint>(); aIdMsh_Inc.Add( mesh2d.GetElemID_FromCadID(id_l,CAD_ELEM_TYPE.LOOP) ); IList<uint> aIdMshCut = new List<uint>(); aIdMshCut.Add( mesh2d.GetElemID_FromCadID(id_e,CAD_ELEM_TYPE.EDGE) ); mesh2d.GetClipedMesh(out aLnods, out mapVal2Co, aIdMsh_Inc,aIdMshCut); } IList<uint> aIdEA_Inc = new List<uint>(); aIdEA_Inc.Add( conv.GetIdEA_fromCad(id_l,CAD_ELEM_TYPE.LOOP) ); id_base2 = World.SetCustomBaseField(id_base,aIdEA_Inc, aLnods,mapVal2Co); } } // mesh2d } // cad2d Solid.UpdateDomain_Field(id_base2, World); Solid.SetSaveStiffMat(false); Solid.SetStationary(true); // set material parameter Solid.SetYoungPoisson(10.0,0.3,true); // set planer stress Solid.SetGeometricalNonlinear(false); Solid.SetGravitation(0.0,0.0); Solid.SetTimeIntegrationParameter(Dt,0.7); uint id_field_bc0 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(2,CAD_ELEM_TYPE.EDGE),World); uint id_field_bc1 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(4,CAD_ELEM_TYPE.EDGE),World); if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); } FieldValueSetter = new CFieldValueSetter(id_field_bc0,World); FieldValueSetter.SetMathExp("0.5*(1-cos(t*PI*2*0.1))", 0,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field x axis FieldValueSetter.SetMathExp("0.2*sin(t*PI*2*0.1)", 1,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field y axis Id_field_disp = Solid.GetIdField_Disp(); Id_field_equiv_stress = World.MakeField_FieldElemDim(Id_field_disp,2, DelFEM4NetFem.Field.FIELD_TYPE.SCALAR, DelFEM4NetFem.Field.FIELD_DERIVATION_TYPE.VALUE, DelFEM4NetFem.Field.ELSEG_TYPE.BUBBLE); // set up visualization DrawerAry.Clear(); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World,Id_field_equiv_stress) ); //DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); // set transformation } else if( ProbNo == 27 ) { uint id_base = 0; CIDConvEAMshCad conv = null; using(CCadObj2D cad2d = new CCadObj2D()) { // define shape IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(0.0,0.0) ); pts.Add( new CVector2D(3.0,0.0) ); pts.Add( new CVector2D(3.0,1.0) ); pts.Add( new CVector2D(0.0,1.0) ); cad2d.AddPolygon( pts ); World.Clear(); id_base = World.AddMesh( new CMesher2D(cad2d,0.3) ); conv = World.GetIDConverter(id_base); // Get ID converter } Solid.Clear(); Solid.UpdateDomain_Field(id_base, World); Solid.SetSaveStiffMat(false); Solid.SetStationary(true); // Setting Material Parameter Solid.SetYoungPoisson(2,0.3,true); // planter stress Solid.SetGeometricalNonlinear(false); Solid.SetGravitation(0.0,0.0); Solid.SetTimeIntegrationParameter(Dt,0.7); uint id_field_bc0 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(2,CAD_ELEM_TYPE.EDGE),World); uint id_field_bc1 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(4,CAD_ELEM_TYPE.EDGE),World); if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); } FieldValueSetter = new CFieldValueSetter(id_field_bc0,World); FieldValueSetter.SetMathExp("0.5*sin(t*PI*2*0.1)", 0,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field x axis FieldValueSetter.SetMathExp("0.3*(1-cos(t*PI*2*0.1))",1,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field y axis Id_field_disp = Solid.GetIdField_Disp(); Id_field_stress = World.MakeField_FieldElemDim(Id_field_disp,2, DelFEM4NetFem.Field.FIELD_TYPE.STSR2, DelFEM4NetFem.Field.FIELD_DERIVATION_TYPE.VALUE, DelFEM4NetFem.Field.ELSEG_TYPE.BUBBLE); //Id_field_equiv_stress = World.MakeField_FieldElemDim(Id_field_disp,2, // DelFEM4NetFem.Field.FIELD_TYPE.SCALAR, // DelFEM4NetFem.Field.FIELD_DERIVATION_TYPE.VALUE, // DelFEM4NetFem.Field.ELSEG_TYPE.BUBBLE); // set up visualization DrawerAry.Clear(); //DrawerAry.PushBack( new CDrawerFace(Id_field_equiv_stress,false,World,Id_field_equiv_stress, 0,0.5) ); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerVector(Id_field_stress,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); // init view transformation } else if( ProbNo == 28 ) { uint id_base = 0; CIDConvEAMshCad conv = null; using(CCadObj2D cad2d = new CCadObj2D()) { // define shape IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(0.0,0.0) ); pts.Add( new CVector2D(0.2,0.0) ); pts.Add( new CVector2D(0.2,0.5) ); pts.Add( new CVector2D(0.8,0.5) ); pts.Add( new CVector2D(0.8,0.0) ); pts.Add( new CVector2D(1.0,0.0) ); pts.Add( new CVector2D(1.0,0.7) ); pts.Add( new CVector2D(0.6,0.7) ); pts.Add( new CVector2D(0.4,0.7) ); pts.Add( new CVector2D(0.0,0.7) ); cad2d.AddPolygon( pts ); World.Clear(); id_base = World.AddMesh( new CMesher2D(cad2d,0.1) ); conv = World.GetIDConverter(id_base); // Get ID converter } Solid.Clear(); Solid.UpdateDomain_Field(id_base, World); Solid.SetSaveStiffMat(false); Solid.SetStationary(true); // Setting Material Parameter Solid.SetYoungPoisson(2,0.1,true); // planter stress Solid.SetGeometricalNonlinear(false); Solid.SetGravitation(0.0,0.0); Solid.SetTimeIntegrationParameter(Dt,0.7); uint id_field_bc0; { IList<uint> aIdEA = new List<uint>(); aIdEA.Add(conv.GetIdEA_fromCad(1,CAD_ELEM_TYPE.EDGE)); aIdEA.Add(conv.GetIdEA_fromCad(5,CAD_ELEM_TYPE.EDGE)); id_field_bc0 = Solid.AddFixElemAry(aIdEA,World); } uint id_field_bc1 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(8,CAD_ELEM_TYPE.EDGE),World); if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); } FieldValueSetter = new CFieldValueSetter(id_field_bc1,World); FieldValueSetter.SetMathExp("-0.03*(1-cos(t*PI*2*0.1))", 1,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field x axis Id_field_disp = Solid.GetIdField_Disp(); Id_field_stress = World.MakeField_FieldElemDim(Id_field_disp,2, DelFEM4NetFem.Field.FIELD_TYPE.STSR2, DelFEM4NetFem.Field.FIELD_DERIVATION_TYPE.VALUE, DelFEM4NetFem.Field.ELSEG_TYPE.BUBBLE); //Id_field_equiv_stress = World.MakeField_FieldElemDim(Id_field_disp,2, // DelFEM4NetFem.Field.FIELD_TYPE.SCALAR, // DelFEM4NetFem.Field.FIELD_DERIVATION_TYPE.VALUE, // DelFEM4NetFem.Field.ELSEG_TYPE.BUBBLE); // set up visualization DrawerAry.Clear(); //DrawerAry.PushBack( new CDrawerFace(Id_field_equiv_stress,false,World,Id_field_equiv_stress, 0,0.5) ); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerVector(Id_field_stress,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); // init view transformation } else if( ProbNo == 29 ) { uint id_base = 0; CIDConvEAMshCad conv = null; using(CCadObj2D cad2d = new CCadObj2D()) { // define shape IList<CVector2D> pts = new List<CVector2D>(); pts.Add( new CVector2D(0.0,0.0) ); pts.Add( new CVector2D(0.2,0.0) ); pts.Add( new CVector2D(0.2,0.5) ); pts.Add( new CVector2D(0.8,0.5) ); pts.Add( new CVector2D(0.8,0.3) ); pts.Add( new CVector2D(1.0,0.3) ); pts.Add( new CVector2D(1.0,0.7) ); pts.Add( new CVector2D(0.6,0.7) ); pts.Add( new CVector2D(0.4,0.7) ); pts.Add( new CVector2D(0.0,0.7) ); cad2d.AddPolygon( pts ); World.Clear(); id_base = World.AddMesh( new CMesher2D(cad2d,0.1) ); conv = World.GetIDConverter(id_base); // Get ID converter } Solid.Clear(); Solid.UpdateDomain_Field(id_base, World); Solid.SetSaveStiffMat(false); Solid.SetStationary(true); // Setting Material Parameter Solid.SetYoungPoisson(2,0.1,true); // planter stress Solid.SetGeometricalNonlinear(false); Solid.SetGravitation(0.0,0.0); Solid.SetTimeIntegrationParameter(Dt,0.7); uint id_field_bc0; { IList<uint> aIdEA = new List<uint>(); aIdEA.Add(conv.GetIdEA_fromCad(1,CAD_ELEM_TYPE.EDGE)); //aIdEA.Add(conv.GetIdEA_fromCad(5,CAD_ELEM_TYPE.EDGE)); id_field_bc0 = Solid.AddFixElemAry(aIdEA,World); } uint id_field_bc1 = Solid.AddFixElemAry(conv.GetIdEA_fromCad(8,CAD_ELEM_TYPE.EDGE),World); if (FieldValueSetter != null) { FieldValueSetter.Clear(); FieldValueSetter.Dispose(); } FieldValueSetter = new CFieldValueSetter(id_field_bc1,World); FieldValueSetter.SetMathExp("-0.03*(1-cos(t*PI*2*0.1))", 1,FIELD_DERIVATION_TYPE.VALUE, World); // oscilate bc1_field x axis Id_field_disp = Solid.GetIdField_Disp(); Id_field_stress = World.MakeField_FieldElemDim(Id_field_disp,2, DelFEM4NetFem.Field.FIELD_TYPE.STSR2, DelFEM4NetFem.Field.FIELD_DERIVATION_TYPE.VALUE, DelFEM4NetFem.Field.ELSEG_TYPE.BUBBLE); //Id_field_equiv_stress = World.MakeField_FieldElemDim(Id_field_disp,2, // DelFEM4NetFem.Field.FIELD_TYPE.SCALAR, // DelFEM4NetFem.Field.FIELD_DERIVATION_TYPE.VALUE, // DelFEM4NetFem.Field.ELSEG_TYPE.BUBBLE); // set up visualization DrawerAry.Clear(); //DrawerAry.PushBack( new CDrawerFace(Id_field_equiv_stress,false,World,Id_field_equiv_stress, 0,0.5) ); DrawerAry.PushBack( new CDrawerFace(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerVector(Id_field_stress,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,false,World) ); DrawerAry.PushBack( new CDrawerEdge(Id_field_disp,true ,World) ); DrawerAry.InitTrans(Camera); // init view transformation } success = true; } catch (Exception exception) { Console.WriteLine(exception.Message + " " + exception.StackTrace); } ProbNo++; if (ProbNo == ProbCnt) ProbNo = 0; return success; }