# Mesh generation fortran 90

 Register Blogs Members List Search Today's Posts Mark Forums Read

April 18, 2017, 14: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
Attached Images
 IMG_20170418_225950.jpg (58.1 KB, 125 views)

 April 18, 2017, 19:13 References #2 Senior Member   Selig Join Date: Jul 2016 Posts: 213 Rep Power: 10 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 anon_o likes this.

 April 25, 2017, 02: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

April 25, 2017, 02:01
#4
Disabled

Join Date: Apr 2017
Posts: 8
Rep Power: 9
Quote:
 Originally Posted by selig5576 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
wrote the code. is it correct for this problem?

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=... '
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 '

open(1,file='MESH.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