不知火舞的被虐|伊人天伊人天天综合网|博洛尼亚天气|任你懆这里只有精品4|久久美日韩精品久久|掌中之物漫画免费阅读观看|0丨d老妇

marc焊接仿真二次開發-以幾何位置激活生死單元的方法? 50

瀏覽:2655

二次開發指南上和網上關于生死單元的二次開發uactive()大多都是用單元號作的。這樣在遍歷單元格時很容易判斷所遍歷的單元生死狀態,但對模型分網的網格單元號是有要求的。二次開發指南上網格單元號沿焊接路徑方向有規律增加。可是對于不在marc上建模分網的焊接模型,網格號很難滿足上述要求。

此時想用遍歷單元與移動的熱源中心相對位置來決定是否激活單元。我們看到二次開發指南中將生死單元狀態另寫入以文件中,仿照此方法,在初始化網格生死狀態后,將所有會出現生死狀態變化的單元的單元號和生死狀態寫入一.txt文件。進入焊接工況下,為判斷遍歷單元生死狀態以決定生死操作,先將.txt文件讀入二維向量,進行生死操作后刪除原.txt文件,再將更新后的二維數組數據重新寫入.txt文件。

這種方法效率極低,運行極慢。各位仿真大佬有沒有效率更高的方法,十分感謝。另附現有代碼。

另外,marc程序中是否有與fluent相似的數據結構,即用單元的結構體鏈表存儲各個單元的各向參數。我看到elevar()函數可以調出的項里沒有單元的生死狀態。

還有,弱弱問一句,死單元里有溫度和熱流等參數嗎?

代碼如下:

subroutine uactive(m,n,mode,irststr,irststn,inc,time,timinc) 

   include 'D:\MSC.Software\Marc\2016.0.0\marc2016\common\implicit'

   dimension m(2)

   real,dimension(3)::coordin                      !定義坐標    

   integer,dimension(35354,2)::modee

c    

c   用來控制單元狀態的子程序 

c   輸入參數: 

c   M(1) 單元號 

c   M(2) 在自適應分析中為母單元號 

c   N 積分點號 

c   INC 增量步號 

c   TIME 增量步開始的時間 

c   TIMINC 時間增量 

c    

c   輸出參數: 

c   MODE: 單元的死活狀態 

c  =-1,定義死單元 

c  =1,定義活單元 

c  =2,保持單元狀態不變 

c   IRSTSTR:等于1時表示重新設置單元應力為0  

c   IRSTSTN:等于1時表示重新設置單元應變為0  

c* * * * * 

cc  添加三個公共變量, 

cc  foreInc保存增量步 

cc  iopen文件打開標志 

cc  iend計算完成標志 

   common/check/foreInc,iopen,iend 

   data iopen,iend/0,0/ 

   real x0,y0,z0,x1,y1,z1,alpha,v,r,omega

c   (x0,y0,z0)為圓心位置,(x1,y1,z1)為熱源中心位置,v為激光掃描線速度,r為掃描路徑半徑,omega為激光掃描角速度,alpha為參數方程參量

c   在0-19.5s階段,即第一層熔覆過程,設置圓心位置為修復層上表面圓心,

c   在19.5-43.5s階段,即第二層熔覆過程,設置圓心位置為修復層上表面圓心    

   integer::ie,mode,icode,kcus,nn !ie 為單元號,icode=0直接返回坐標,連續體單元kcus=1

   real::dist,dire !dist為遍歷單元到熱源中心距離,dire為數量積

   ie=m(1);

   if(ie.gt.25712.and.ie.lt.502035) return  !set直接跳過

   icode=0;kcus=1;nn=n

   call elmvar(icode,m,nn,kcus,coordin)                       

cc    

   if(time.le.19.5) then

   x0=175.54; y0=187.363;z0=-187.388

   else if (time.gt.19.5.and.time.le.43.5)then  

   x0=178.72;y0=190.471; z0=-185.311

   end if

c   設置激光掃描的線速度常數10,定義角速度omega

   v=10;omega=v/r;pi=3.1415926

c   設置激光掃描熱源中心位置參數方程重要參量alpha

   if(time.le.13)then 

   r=19;alpha=omega*time

   else if (time.gt.13.and.time.le.19.5)then

   r=9;alpha=omega*time-13*omega

   else if(time.gt.19.5.and.time.le.35.5)then 

   r=24;alpha=omega*time-19.5*time

   else if (time.gt.35.5.and.time.le.43.5)then 

   r=12;alpha=omega*time-35.5*time

   end if

c   設置激光熱源中心位置,假定熱源在法線(1,1,1)的平面上運動

    x1=x0+(cos(alpha)-sin(alpha))*r/1.4142135

    y1=y0+cos(alpha)*r/1.4142135

    z1=z0+(cos(alpha)+sin(alpha))*r/1.73205081             熱源位置     

cc

   dist=sqrt((coordin(1)-x1)**2+(coordin(2)-y1)**2

   $+(coordin(3)-z1)**2)                       積分點熱源距離 

    dire=3.18*(175.54-coordin(1))+3.108*(187.363-coordin(2))

   $+2.077*(-187.388-coordin(3))                   數量積確定位置

    

c   初始激活第一層熱源周圍0.5mm的單元 ,死單元存入for96 

    if (inc.eq.0) then                          

     if(dist.le.0.5)then 

       if(dire.ge.0)then 

         mode=1

        else mode=-1

        end if

     else mode=-1

     end if

c  死單元初始化

   open(95,file='mode.txt',position='append')

   write(95,*)ie,mode

   close(95)

   go to 11

   end if

   open(95,file='mode.txt',status='old')

   do im=1,35454

     read(95,*) modee(im,1),modee(im,2)

   if(ie.eq.modee(im,1)) then

     mode=modee(im,2)

   end if 

   end do

   close (95)

      

     if(time+timinc.le.19.5)then 

       if(mode.eq.-1)then

         if(dist.le.11)then 

           if(dire.ge.0)then

             mode=1

           else mode=-1

           end if

         else mode=-1 

         end if

       else 

       return

        end if

        end if

   if(time+timinc.le.43.5.and.time+timinc.gt.19.5)then  

      if(mode.eq.-1)then

       if(dist.le.12)  then 

        mode=1

       else mode=-1;

       end if

            else mode=-1;

            end if

   else 

   return

        end if

c    一輪生死單元判斷過后,更新mode.txt,并記錄死單元

    open(95,file='mode.txt',status='old')

   close(95,status='delete')

c 刪除原mode.txt文件,再重建更新

    open(95,file='mode.txt',status='new')

    do im=1,35454

      write(95,*) modee(im,1),modee(im,2)

            end do

    close(95)

    

c   

cc 

c   將當前增量步的死單元號寫入文件 fort.96 中 

c   以便查看或者進行其他的處理 

    

  11 if(mode.eq.-1) then 

      write(96,*) 'deactivating element ', ie, ' increment ', inc 

   endif 

cc 

cc  新建一個過程文件 PostHide.proc 用來輔助后處理 

     if(iopen.eq.0) then 

      iopen=1 

      foreInc=inc 

      open(50,file='PostHide.proc',status='unknown') 

      close(50,status='delete') 

      open(50,file='PostHide.proc',status='new') 

      write(50,*)'*select_elements' 

   endif 

   if(iend.eq.0) then !判斷是否到最后增量步 

    if(inc.eq.foreInc) then !判斷增量步是否變化 

    if(mode.eq.-1) write(50,*) ie !寫入當前增量步的死單元號 

    else 

    write(50,*)'#' !選擇結束標志 

    write(50,*)'*invisible_selected' !使選中單元不可見 

    write(50,200) (inc-1) !顯示第 (inc-1) 增量步 

 200  format('*post_skip_to',i5,/,'*select_elements') 

    write(50,*)'*animation_save' !保存當前窗口圖形 

cc 

    if(mode.eq.-1) write(50,*) ie 

    foreInc=inc 

    endif 

    if(inc.eq.435) then !到最后一步,置 iend=1  

    iend=1 

    write(50,*)'#' 

    write(50,*)'*invisible_selected' 

    write(50,*)'*animation_save' 

    endif 

   endif 

cc  

c* * * * * 

   return 

   end 

代碼尚未跑通,見笑了

邀請回答 我來回答

當前暫無回答

回答可獲贈 200金幣

沒解決?試試專家一對一服務

換一批
    App下載
    技術鄰APP
    工程師必備
    • 項目客服
    • 培訓客服
    • 平臺客服

    TOP