|
[Sponsors] |
April 18, 2017, 15:49 |
Mesh generation fortran 90
|
#1 |
Disabled
Join Date: Apr 2017
Posts: 8
Rep Power: 9 |
Dear friends,
How can I generate mesh for the attached photo? Any sample code? Any reference? Thanks, Armin |
|
April 18, 2017, 20:13 |
References
|
#2 |
Senior Member
Selig
Join Date: Jul 2016
Posts: 213
Rep Power: 11 |
In the picture you have given, the person who wrote the problem set gave references. A paper thats a bit more theoretical is: https://arxiv.org/pdf/math/0607388.pdf
|
|
April 25, 2017, 03:00 |
|
#3 |
Disabled
Join Date: Apr 2017
Posts: 8
Rep Power: 9 |
wrote the code. is it correct for this problem?
program Adaptive_mesh implicit none integer ::n,i,j,iter real::deltax,deltay,deltat,c,tol,xx,yy,a,ap,error real,allocatable::W(:,,u(:,,x(:,,y(:,,xn(: ,,yn(:, write(*,*),' Enter partition n=... ' read(*,*)n allocate (x(n+1,n+1),y(n+1,n+1),W(n+1,n+1),u(n+1,n+1),xn(n+ 1,n+1),yn(n+1,n+1)) write(*,*),' Enter time step <0.01 ' read(*,*)deltat open(1,file='MESH.plt') open(2,file='ADAPTIVE MESH RESULT.plt') write(1,*)'VARIABLES= ,"X","Y"' write(1,*)'ZONE I=',n+1,'J=',n+1,'F=POINT' write(2,*)'VARIABLES= ,"X","Y"' write(2,*)'ZONE I=',n+1,'J=',n+1,'F=POINT' !constant variable tol=0.00001 c=100. iter=1 deltax=0.01 deltay=0.01 !mesh grid xx=0.0 yy=0.0 do i=1,n+1 do j=1,n+1 y(i,j)=yy x(i,j)=xx xx=xx+deltax write(1,*) x(i,j),y(i,j) end do xx=0.0 yy=yy+deltay end do 1001 error=0.0 deltax=1. deltay=1. !field of velocity do i=1,n+1 do j=1,n+1 u(i,j)=c*(exp(-(c**2)*(x(i,j)**2+y(i,j)**2))) end do end do ! w(i,j) a=0.0 do i=1,n+1 do j=1,n+1 w(i,j)=0.0 end do end do do i=2,n do j=2,n w(i,j)=sqrt(1.+(((u(i+1,j)-u(i-1,j))/(2.*deltax))**2.+((u(i,j+1)-u(i,j-1))/(2.*deltay))**2.)) ap=w(i,j) if(a<ap)then a=ap end if end do end do !x(i,j) and y(i,j) NEW do i=1,n+1 do j=1,n+1 xn(i,j)=x(i,j) yn(i,j)=y(i,j) end do end do do 100 i=2,n do 101 j=2,n x(i,j)=x(i,j)+(deltat/(2.*deltax**2.))*((w(i+1,j)+w(i,j))*(x(i+1,j)-x(i,j))-(w(i-1,j)+w(i,j))*(x(i,j)-x(i-1,j))& &+(w(i,j+1)+w(i,j))*(x(i,j+1)-x(i,j))-(w(i,j-1)+w(i,j))*(x(i,j)-x(i,j-1)))& &-a*deltat*((xn(i+1,j)+xn(i-1,j)+xn(i,j+1)+xn(i,j-1)-4.*xn(i,j))/(deltax**2))& &+a*deltat*((x(i+1,j)+x(i-1,j)+x(i,j+1)+x(i,j-1)-4.*x(i,j))/(deltax**2)) y(i,j)=y(i,j)+(deltat/(2.*deltay**2.))*((w(i+1,j)+w(i,j))*(y(i+1,j)-y(i,j))-(w(i-1,j)+w(i,j))*(y(i,j)-y(i-1,j))& &+(w(i,j+1)+w(i,j))*(y(i,j+1)-y(i,j))-(w(i,j-1)+w(i,j))*(y(i,j)-y(i,j-1)))& &-a*deltat*((yn(i+1,j)+yn(i-1,j)+yn(i,j+1)+yn(i,j-1)-4.*yn(i,j))/(deltay**2))& &+a*deltat*((y(i+1,j)+y(i-1,j)+y(i,j+1)+y(i,j-1)-4.*y(i,j))/(deltay**2)) error=error+abs(x(i,j)-xn(i,j)) 101 continue 100 continue if(error<tol)then goto 1000 else write(*,*) iter,error,a iter=iter+1 goto 1001 end if 1000 do i=1,n+1 do j=1,n+1 write(2,*) x(i,j),y(i,j) end do end do end program Sent from my P024 using CFD Online Forum mobile app |
|
April 25, 2017, 03:01 |
|
#4 | |
Disabled
Join Date: Apr 2017
Posts: 8
Rep Power: 9 |
Quote:
program Adaptive_mesh implicit none integer ::n,i,j,iter real::deltax,deltay,deltat,c,tol,xx,yy,a,ap,error real,allocatable::W(:,,u(:,,x(:,,y(:,,xn(: ,,yn(:, write(*,*),' Enter partition n=... ' read(*,*)n allocate (x(n+1,n+1),y(n+1,n+1),W(n+1,n+1),u(n+1,n+1),xn(n+ 1,n+1),yn(n+1,n+1)) write(*,*),' Enter time step <0.01 ' read(*,*)deltat open(1,file='MESH.plt') open(2,file='ADAPTIVE MESH RESULT.plt') write(1,*)'VARIABLES= ,"X","Y"' write(1,*)'ZONE I=',n+1,'J=',n+1,'F=POINT' write(2,*)'VARIABLES= ,"X","Y"' write(2,*)'ZONE I=',n+1,'J=',n+1,'F=POINT' !constant variable tol=0.00001 c=100. iter=1 deltax=0.01 deltay=0.01 !mesh grid xx=0.0 yy=0.0 do i=1,n+1 do j=1,n+1 y(i,j)=yy x(i,j)=xx xx=xx+deltax write(1,*) x(i,j),y(i,j) end do xx=0.0 yy=yy+deltay end do 1001 error=0.0 deltax=1. deltay=1. !field of velocity do i=1,n+1 do j=1,n+1 u(i,j)=c*(exp(-(c**2)*(x(i,j)**2+y(i,j)**2))) end do end do ! w(i,j) a=0.0 do i=1,n+1 do j=1,n+1 w(i,j)=0.0 end do end do do i=2,n do j=2,n w(i,j)=sqrt(1.+(((u(i+1,j)-u(i-1,j))/(2.*deltax))**2.+((u(i,j+1)-u(i,j-1))/(2.*deltay))**2.)) ap=w(i,j) if(a<ap)then a=ap end if end do end do !x(i,j) and y(i,j) NEW do i=1,n+1 do j=1,n+1 xn(i,j)=x(i,j) yn(i,j)=y(i,j) end do end do do 100 i=2,n do 101 j=2,n x(i,j)=x(i,j)+(deltat/(2.*deltax**2.))*((w(i+1,j)+w(i,j))*(x(i+1,j)-x(i,j))-(w(i-1,j)+w(i,j))*(x(i,j)-x(i-1,j))& &+(w(i,j+1)+w(i,j))*(x(i,j+1)-x(i,j))-(w(i,j-1)+w(i,j))*(x(i,j)-x(i,j-1)))& &-a*deltat*((xn(i+1,j)+xn(i-1,j)+xn(i,j+1)+xn(i,j-1)-4.*xn(i,j))/(deltax**2))& &+a*deltat*((x(i+1,j)+x(i-1,j)+x(i,j+1)+x(i,j-1)-4.*x(i,j))/(deltax**2)) y(i,j)=y(i,j)+(deltat/(2.*deltay**2.))*((w(i+1,j)+w(i,j))*(y(i+1,j)-y(i,j))-(w(i-1,j)+w(i,j))*(y(i,j)-y(i-1,j))& &+(w(i,j+1)+w(i,j))*(y(i,j+1)-y(i,j))-(w(i,j-1)+w(i,j))*(y(i,j)-y(i,j-1)))& &-a*deltat*((yn(i+1,j)+yn(i-1,j)+yn(i,j+1)+yn(i,j-1)-4.*yn(i,j))/(deltay**2))& &+a*deltat*((y(i+1,j)+y(i-1,j)+y(i,j+1)+y(i,j-1)-4.*y(i,j))/(deltay**2)) error=error+abs(x(i,j)-xn(i,j)) 101 continue 100 continue if(error<tol)then goto 1000 else write(*,*) iter,error,a iter=iter+1 goto 1001 end if 1000 do i=1,n+1 do j=1,n+1 write(2,*) x(i,j),y(i,j) end do end do end program Sent from my P024 using CFD Online Forum mobile app |
||
Tags |
fortran 90, grid, mesh |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[snappyHexMesh] No layers in a small gap | bobburnquist | OpenFOAM Meshing & Mesh Conversion | 6 | August 26, 2015 10:38 |
unstructured mesh generation with strictly constrained boundary in simple space | goujl | Mesh Generation & Pre-Processing | 0 | January 29, 2015 11:44 |
ISAAC code mesh generation | morteza08 | Main CFD Forum | 0 | June 15, 2012 10:26 |
Convergence moving mesh | lr103476 | OpenFOAM Running, Solving & CFD | 30 | November 19, 2007 15:09 |
Latest new in mesh generation | Robert Schneiders | Main CFD Forum | 0 | February 16, 2000 08:12 |