Move a gridpoint

Hi,

I wrote the following FISH to help me to cancel and create tetrahedron with the final aim of modifying the position of a gridpoint.

Since there is no a specific function to move a single gridpoint of the grid before the solve command (maybe I’m wrong), I tried to modify the position of a gridpoint by cancelling all the zone pointing to that gridpoint and replacing them with new zones.

The problem of creating a tetrahedron is to input the four vertex points in a specific position, in the way the vectors point 0 – point 1, point 0 – point 2, point 0 – point 3 is a right-handed coordinate system, to have positive volume:

To check if the coord system is right-handed I used the following condition:

V = (Dx x Dy) ° Dz /6 > 0

where x is the cross product, ° is the dot product and Dx, Dy, Dz are the vectors p1-p0, p2-p0, p3-p0. If the volume is < 0, then I exchange Dx with Dy to obtain a positive volume as (Dx x Dy) = - (Dy x Dx).

In my specific case, from the check, one volume is negative due to the gridpoint move and the above condition is capable to catch it and to create a positive volume zone.

The original gridpoint is erased when the last zone is deleted.
image
image

Here below the code:

fish define move_gp(gp_ID,x_coord,y_coord,z_coord)

;
    global coor_list = list.create(12)
    local pnt_gp = gp.find(gp_ID) 
    local zn_list = gp.zone(pnt_gp)
    global zn_num = list.size(zn_list)
    global check = list.create(zn_num)
    global zn_vol = list.create(zn_num)
    global zn_quality = list.create(zn_num)
    global kk = 0
    ;
    loop foreach pnt_zn zn_list
        ;
        jj = 1
        gp_list = zone.gp(pnt_zn) 
        zn_ID = zone.id(pnt_zn)
        zn_group = zone.group(pnt_zn,"Zoning")
        zn_vol(kk+1) = zone.vol(pnt_zn)
        zn_vol(kk+1) = zone.test.quality(pnt_zn,2)
        
        ;
        loop foreach pnt_pn gp_list
            ;
            coor_list(jj) = gp.pos.x(pnt_pn)
            coor_list(jj+1) = gp.pos.y(pnt_pn)
            coor_list(jj+2) = gp.pos.z(pnt_pn)
            ;
            if gp.id(pnt_pn) == gp_ID then
                ;
                coor_list(jj) = x_coord
                coor_list(jj+1) = y_coord
                coor_list(jj+2) = z_coord
                ;
            endif
            ;
            jj = jj+3
            ;
        endloop
        ;
        ;Check Coord Sys
        Dx = list.sequence((coor_list(4)-coor_list(1)),(coor_list(5)-coor_list(2)),(coor_list(6)-coor_list(3)))
        Dy = list.sequence((coor_list(7)-coor_list(1)),(coor_list(8)-coor_list(2)),(coor_list(9)-coor_list(3)))
        Dz =  list.sequence((coor_list(10)-coor_list(1)),(coor_list(11)-coor_list(2)),(coor_list(12)-coor_list(3)))
        ;
        check(kk+1) = ((Dx(2)*Dy(3)-Dx(3)*Dy(2))*Dz(1)+(Dx(3)*Dy(1)-Dx(1)*Dy(3))*Dz(2)+(Dx(1)*Dy(2)-Dx(2)*Dy(1))*Dz(3))/6.
        ;
        if check(kk+1) < 0 then
            ;
            mov_1 = list.sequence(coor_list(7),coor_list(8),coor_list(9))
            mov_2 = list.sequence(coor_list(4),coor_list(5),coor_list(6))
            coor_list(4) = mov_1(1)
            coor_list(5) = mov_1(2)
            coor_list(6) = mov_1(3)
            coor_list(7) = mov_2(1)
            coor_list(8) = mov_2(2)
            coor_list(9) = mov_2(3)
            ;
        endif
        ;
        command
            ;
            zone delete range id [zn_ID]
            zone create tetrahedron point 0 ([coor_list(1)],[coor_list(2)],[coor_list(3)]) ...
                                    point 1 ([coor_list(4)],[coor_list(5)],[coor_list(6)]) ...
                                    point 2 ([coor_list(7)],[coor_list(8)],[coor_list(9)]) ...
                                    point 3 ([coor_list(10)],[coor_list(11)],[coor_list(12)]) ...
                                    size 1 1 1 group [string(check(kk+1))] slot "Zoning"
            ;
        endcommand
        ;
        kk = kk+1
        ;
    endloop
    ;
    loop ii (1,zn_num)
        ;
        var = (check(ii)-zn_vol(ii))/zn_vol(ii)
        ;
        command
            print @check([ii])
            print @zn_vol([ii])
            ;print @zn_vol([ii])
            ;print @var
        endcommand
    endloop
end
[move_gp(67745,346.39,144.54,216.92)]

Moving a single gridpoint should work with the zone gridpoint initialize position and the appropriate range.

Hi markus,
does it work before the solve command and with large-strain off?

Yes. It simply changes the gridpoint position. That has nothing to do with large-strain or solving.
Edit: Please not that you have to make sure yourself that you don’t create an invalid element by this.

Hi markus,
zone gridpoint initialize position works fine as well as the FISH function.
Is it sufficient to check if the volume is positive to have valid zone?

There are multiple zone condition metrics in FLAC3D, accessible either via FISH or by plotting zone condition. If the zone is (too) bad, it will also simply not start and complain about illegal geometry.

1 Like