18
rallel Method for solving Coupled PDE its application in simulation of thin composite fi By: E. Nedaaee IASBS

Parallel Method for solving a Coupled PDE

  • Upload
    tamra

  • View
    54

  • Download
    0

Embed Size (px)

DESCRIPTION

Parallel Method for solving a Coupled PDE and its application in simulation of thin composite films. By: E. Nedaaee IASBS. What is thin film. Our Model:. , the order parameter which represents the difference between the densities of the two types of particles of the surface - PowerPoint PPT Presentation

Citation preview

Page 1: Parallel Method for solving a  Coupled PDE

Parallel Method for solving a

Coupled PDE and its application in simulation of thin composite films

Parallel Method for solving a

Coupled PDE and its application in simulation of thin composite films

By: E. NedaaeeIASBS

Page 2: Parallel Method for solving a  Coupled PDE

What is thin film

Page 3: Parallel Method for solving a  Coupled PDE

is thermal fluctuations of the flux of the incoming particles, such that

represents the fluctuations in the density of the incoming particles with

, the order parameter which represents the difference between the densities of the two types of particles of the surface , the height of the surface

II ),()(2

.)(

I ),(2

)(2

2232

222

tXhmc

hbmmhaumrmmKm

tXmhhh

mt

ht

)()(2),().,( ttXXDtXtx dmmm

)()(2),().,( ttXXDtXtx dhhh

),( tXh

),( tXm

h

m

Our Model:

Page 4: Parallel Method for solving a  Coupled PDE

0)()(8

)4(

))(())((4

)()4(

0)(2

)()(8

)4(

211

11

211

11

12

111

11

11

11

12

11

11

11

11

11

11

11

112

311111

11

11

112

1

21211

11

211

112

111

11

11

112

1

mijnij

nij

nji

nji

nij

nij

nij

nij

nji

nji

nij

nij

nij

nij

nij

nji

nji

nji

nji

nij

nij

nij

nij

nij

nji

nji

nij

nij

ijhnij

nij

nij

nji

nji

nij

nij

nij

nji

nji

nij

nij

hhhhmx

tc

hhhhhmx

tb

mmhhmmhhx

ta

mtutmrmmmmmx

tKmm

mt

hhhhx

t

hhhhhx

thh

Discretization

Fully implicit finite difference method

Page 5: Parallel Method for solving a  Coupled PDE

nj

ni

i

j

ni

i

j

ni

i

:

1

2:

1

1:

1

m

h

Page 6: Parallel Method for solving a  Coupled PDE

Start

Initial Conditions

maxtt

Solve Nonlinear Set of Equations.

Finish

mm

hh

uuold

uuold

ttt

Yes

No

Algorithm

Page 7: Parallel Method for solving a  Coupled PDE

Nonlinear SolverNewton-Raphson Method

0),,,( 21 ni xxxF

)()()( 2

1

XOxx

FXFXXF j

n

j j

iii

j

iij x

FJ

)(.)()( 2XOXJXFXXF

)(. XFXJ

Page 8: Parallel Method for solving a  Coupled PDE

Initial guess for X

Solve.

)(. XFXJ

Set.XXX oldnew

X

FNo Yes Return newX

Solving this linear set of equations by Conjugate-Gradient method and

store J with sparse manner

Page 9: Parallel Method for solving a  Coupled PDE

Parallelization MethodDomain Decomposition

maxtt

Solve Nonlinear Set of Equations. In each domain

mm

hh

uut

uut

Yes

No

z

Solve Nonlinear Set of Equations. In each domain uut

Finish

mm

hh

uuold

uuold

ttt

No

Yes

B.C. Exchange

Page 10: Parallel Method for solving a  Coupled PDE
Page 11: Parallel Method for solving a  Coupled PDE

MPI_Init(&argc, &argv);MPI_Comm_size(MPI_COMM_WORLD, &nump);MPI_Comm_rank(MPI_COMM_WORLD, &myrank);nump_row = (int) sqrt(nump);dims[0] = nump_row; dims[1] = nump_row;periods[0] = periods[1] = 1;

MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, 0, &comm);MPI_Comm_rank(comm, &myrank);MPI_Cart_coords(comm, myrank, 2, coords);MPI_Type_hvector(np,1,(np+2)*sizeof(double), MPI_DOUBLE, &BC);MPI_Type_commit(&BC);

Page 12: Parallel Method for solving a  Coupled PDE

rcoords[0] = coords[0]; rcoords[1] = coords[1]+1; if(coords[1] == (nump_row-1)) rcoords[1] = 0;

lcoords[0] = coords[0]; lcoords[1] = coords[1]-1; if(coords[1] == 0) lcoords[1] = nump_row - 1;

bcoords[1] = coords[1]; bcoords[0] = coords[0]+1; if(coords[0] == (nump_row-1)) bcoords[0] = 0;

tcoords[1] = coords[1]; tcoords[0] = coords[0]-1; if(coords[0] == 0) tcoords[0] = nump_row - 1;

MPI_Cart_rank(comm, lcoords, &left);MPI_Cart_rank(comm, rcoords, &right);MPI_Cart_rank(comm, tcoords, &top);MPI_Cart_rank(comm, bcoords, &buttom);

Page 13: Parallel Method for solving a  Coupled PDE

MPI_File_open(comm, fh_m_out,MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh_m);

MPI_File_open(comm, fh_h_out,MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh_h);

MPI_Barrier(comm);

lsizes[0] = np;lsizes[1] = np;

gsizes[0] = np*nump_row*file_size;gsizes[1] = np*nump_row;

memsizes[0] = lsizes[0] + 2;memsizes[1] = lsizes[1] + 2;

start_indices[0] = start_indices[1] = 1;

MPI_Type_create_subarray(2,memsizes, lsizes, start_indices, MPI_ORDER_C,MPI_DOUBLE, &memtype);

MPI_Type_commit(&memtype);

Page 14: Parallel Method for solving a  Coupled PDE

start_indices[0] = coords[0]*lsizes[0]+count_ind*np*nump_row; start_indices[1] = coords[1]*lsizes[1];

MPI_Type_create_subarray(2,gsizes,lsizes,start_indices,MPI_ORDER_C,MPI_DOUBLE,&filetype);

MPI_Type_commit(&filetype);

MPI_File_set_view(fh_m, 0, MPI_DOUBLE, filetype, "native", MPI_INFO_NULL);

MPI_File_set_view(fh_h, 0, MPI_DOUBLE, filetype, "native", MPI_INFO_NULL);

MPI_File_write_all(fh_m,u_m, 1, memtype, &status);MPI_Wait(&req, &status);MPI_File_write_all(fh_h,u_h, 1, memtype, &status);MPI_Wait(&req, &status);MPI_Barrier(comm);count_ind +=1;

Page 15: Parallel Method for solving a  Coupled PDE

for(;;){ vecfunc(x); newt(x, &check,vecfunc);

MPI_Barrier(comm);BC_exchange(left,right,top,buttom);MPI_Barrier(comm);pnorm_s = NORM(x,x_temp);

MPI_Allreduce(&pnorm_s, &pnorm_r, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);

if(sqrt(pnorm_r) <= 1.e-9) break;for(int i = 1; i<= 2*np*np; i++)

x_temp[i] = x[i];count +=1;

}

Page 16: Parallel Method for solving a  Coupled PDE

void BC_exchange(int left, int right, int top, int buttom){

/*send and received from left neighbor*/ MPI_Isend(&u_h[1][1],np,MPI_DOUBLE, top,0,MPI_COMM_WORLD, &requests[0]); MPI_Irecv(&u_h[0][1],np,MPI_DOUBLE, top,0,MPI_COMM_WORLD, &requests[1]); /*send and received from right neighbor*/ MPI_Isend(&u_h[np][1],np,MPI_DOUBLE, buttom,0,MPI_COMM_WORLD, &requests[2]); MPI_Irecv(&u_h[np+1][1],np,MPI_DOUBLE,buttom,0,MPI_COMM_WORLD, &requests[3]); /*send and received from top neighbor*/ MPI_Isend(&u_h[1][np],1,BC, right,0,MPI_COMM_WORLD, &requests[4]); MPI_Irecv(&u_h[1][np+1],1,BC,right,0,MPI_COMM_WORLD, &requests[5]);

/*send and received from bottom neighbor*/ MPI_Isend(&u_h[1][1],1,BC, left,0,MPI_COMM_WORLD, &requests[6]); MPI_Irecv(&u_h[1][0],1,BC, left,0,MPI_COMM_WORLD, &requests[7]);

MPI_Waitall(8,requests, statuses);

Page 17: Parallel Method for solving a  Coupled PDE
Page 18: Parallel Method for solving a  Coupled PDE