constant_boundary.c 6.41 KB
Newer Older
Simone Butzer's avatar
Simone Butzer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
/*------------------------------------------------------------------------
 * Copyright (C) 2015 For the list of authors, see file AUTHORS.
 *
 * This file is part of IFOS3D.
 * 
 * IFOS3D is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 2.0 of the License only.
 * 
 * IFOS3D is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with IFOS3D. See file COPYING and/or 
 * <http://www.gnu.org/licenses/gpl-2.0.html>.
--------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------
 * 
 * S. Butzer 2015
 * ------------------------------------------------------------------------*/

#include "fd.h"

void constant_boundary(int nx1, int nx2, int ny1, int ny2, int nz1, int nz2, float ***  pi, float ***  u, float *** rho){


	/*extern int FREE_SURF;*/
	extern int NPROCX, NPROCY, NPROCZ, POS[4];
	extern int FW,NX, NY;

	int i, j, k,dum1,dum2;
	int dist=4;
	dum1=1;
	dum2=NY;
	

	if (POS[1]==0){	
		if (POS[2]==0){
			dum1=2;
			for (i=1;i<=FW+dist;i++){
				for (k=nz1;k<=nz2;k++){
					u[1][i][k]=u[1][FW+1+dist][k];
					pi[1][i][k]= pi[1][FW+1+dist][k];
					rho[1][i][k]= rho[1][FW+1+dist][k];
				}
			}
		}
		if (POS[2]==NPROCY-1){
			dum2=NY-1; 
			for (i=1;i<=FW+dist;i++){
				for (k=nz1;k<=nz2;k++){
					u[NY][i][k]=u[NY][FW+1+dist][k];
					pi[NY][i][k]= pi[NY][FW+1+dist][k];
					rho[NY][i][k]= rho[NY][FW+1+dist][k];
				}
			}
		}
		for (j=dum1;j<=dum2;j++){
			for (i=1;i<=FW+dist;i++){
				for (k=nz1;k<=nz2;k++){
					u[j][i][k]=(3.0*u[j][FW+1+dist][k]+u[j-1][FW+1+dist][k]+u[j+1][FW+1+dist][k]+u[j][FW+1+dist][k-1]+u[j][FW+1+dist][k+1]+u[j][FW+2+dist][k])/8.0;
					pi[j][i][k]= (3.0*pi[j][FW+1+dist][k]+pi[j-1][FW+1+dist][k]+pi[j+1][FW+1+dist][k]+pi[j][FW+1+dist][k-1]+pi[j][FW+1+dist][k+1]+pi[j][FW+2+dist][k])/8.0;
					rho[j][i][k]= (3.0*rho[j][FW+1+dist][k]+rho[j-1][FW+1+dist][k]+rho[j+1][FW+1+dist][k]+rho[j][FW+1+dist][k-1]+rho[j][FW+1+dist][k+1]+rho[j][FW+2+dist][k])/8.0;
				}
			}
		}

	}
	

	if(POS[1]==NPROCX-1){
	  	if (POS[2]==0){
			dum1=2;
			for (i=nx2+1-dist;i<=nx2+FW;i++){
				for (k=nz1;k<=nz2;k++){
					u[1][i][k]=u[1][nx2-dist][k];
					pi[1][i][k]= pi[1][nx2-dist][k];
					rho[1][i][k]= rho[1][nx2-dist][k];
				}
			}
		}
		if (POS[2]==NPROCY-1){
			dum2=NY-1; 
			for (i=nx2+1-dist;i<=nx2+FW;i++){
				for (k=nz1;k<=nz2;k++){
					u[NY][i][k]=u[NY][nx2-dist][k];
					pi[NY][i][k]= pi[NY][nx2-dist][k];
					rho[NY][i][k]= rho[NY][nx2-dist][k];
				}
			}
		}
		for (j=dum1;j<=dum2;j++){
			for (i=nx2+1-dist;i<=nx2+FW;i++){
				for (k=nz1;k<=nz2;k++){
					u[j][i][k]=(3.0*u[j][nx2-dist][k]+u[j-1][nx2-dist][k]+u[j+1][nx2-dist][k]+u[j][nx2-dist][k-1]+u[j][nx2-dist][k+1]+u[j][nx2-1-dist][k])/8.0;
					pi[j][i][k]=(3.0*pi[j][nx2-dist][k]+pi[j-1][nx2-dist][k]+pi[j+1][nx2-dist][k]+pi[j][nx2-dist][k-1]+pi[j][nx2-dist][k+1]+pi[j][nx2-1-dist][k])/8.0;
					rho[j][i][k]=(3.0*rho[j][nx2-dist][k]+rho[j-1][nx2-dist][k]+rho[j+1][nx2-dist][k]+rho[j][nx2-dist][k-1]+rho[j][nx2-dist][k+1]+rho[j][nx2-1-dist][k])/8.0;
				}
			}
		}
	}

	if(POS[3]==0){
		if (POS[2]==0){
			dum1=2;
			for (i=1;i<=NX;i++){
				for (k=1;k<=FW+dist;k++){
					u[1][i][k]=u[1][i][FW+1+dist];
					pi[1][i][k]= pi[1][i][FW+1+dist];
					rho[1][i][k]= rho[1][i][FW+1+dist];
				}
			}
		}
		if (POS[2]==NPROCY-1){
			dum2=NY-1; 
			for (i=1;i<=NX;i++){
				for (k=1;k<=FW+dist;k++){
					u[NY][i][k]=u[NY][i][FW+1+dist];
					pi[NY][i][k]= pi[NY][i][FW+1+dist];	
					rho[NY][i][k]= rho[NY][i][FW+1+dist];
				}
			}
		}
		if(POS[1]==0){
			for (j=dum1;j<=dum2;j++){
				for (i=1;i<=FW+dist;i++){
					for (k=1;k<=FW+dist;k++){
						u[j][i][k]=u[j][i][FW+1+dist];
						pi[j][i][k]=pi[j][i][FW+1+dist];
						rho[j][i][k]=rho[j][i][FW+1+dist];
					}
				}
			}
		}
		if(POS[1]==NPROCX-1){
			for (j=dum1;j<=dum2;j++){
				for (i=nx2+1-dist;i<=nx2+FW;i++){
					for (k=1;k<=FW+dist;k++){
						u[j][i][k]=u[j][i][FW+1+dist];
						pi[j][i][k]=pi[j][i][FW+1+dist];
						rho[j][i][k]=rho[j][i][FW+1+dist];
					}
				}
			}
		}
		
		
		
		for (j=dum1;j<=dum2;j++){
			for (i=nx1;i<=nx2;i++){
				for (k=1;k<=FW+dist;k++){
					u[j][i][k]=(3.0*u[j][i][FW+1+dist]+u[j-1][i][FW+1+dist]+u[j+1][i][FW+1+dist]+u[j][i-1][FW+1+dist]+u[j][i+1][FW+1+dist]+u[j][i][FW+2+dist])/8.0;
					pi[j][i][k]=(3.0*pi[j][i][FW+1+dist]+pi[j-1][i][FW+1+dist]+pi[j+1][i][FW+1+dist]+pi[j][i-1][FW+1+dist]+pi[j][i+1][FW+1+dist]+pi[j][i][FW+2+dist])/8.0;
					rho[j][i][k]=(3.0*rho[j][i][FW+1+dist]+rho[j-1][i][FW+1+dist]+rho[j+1][i][FW+1+dist]+rho[j][i-1][FW+1+dist]+rho[j][i+1][FW+1+dist]+rho[j][i][FW+2+dist])/8.0;
				}
			}
		}
	
	
	}


	if(POS[3]==NPROCZ-1){	
		if (POS[2]==0){
			dum1=2;
			for (i=1;i<=NX;i++){
				for (k=nz2+1-dist;k<=nz2+FW;k++){
					u[1][i][k]=u[1][i][nz2-dist];
					pi[1][i][k]= pi[1][i][nz2-dist];
					rho[1][i][k]= rho[1][i][nz2-dist];
				}
			}
		}
		if (POS[2]==NPROCY-1){
			dum2=NY-1; 
			for (i=1;i<=NX;i++){
				for (k=nz2+1-dist;k<=nz2+FW;k++){
					u[NY][i][k]=u[NY][i][nz2-dist];
					pi[NY][i][k]= pi[NY][i][nz2-dist];
					rho[NY][i][k]= rho[NY][i][nz2-dist];
				}
			}
		}
		if(POS[1]==0){
			for (j=dum1;j<=dum2;j++){
				for (i=1;i<=FW+dist;i++){
					for (k=nz2+1-dist;k<=nz2+FW;k++){
						u[j][i][k]=u[j][i][nz2-dist];
						pi[j][i][k]=pi[j][i][nz2-dist];
						rho[j][i][k]=rho[j][i][nz2-dist];
					}
				}
			}
		}
		if(POS[1]==NPROCX-1){
			for (j=dum1;j<=dum2;j++){
				for (i=nx2+1-dist;i<=nx2+FW;i++){
					for (k=nz2+1-dist;k<=nz2+FW;k++){
						u[j][i][k]=u[j][i][nz2-dist];
						pi[j][i][k]=pi[j][i][nz2-dist];
						rho[j][i][k]=rho[j][i][nz2-dist];
					}
				}
			}
		}
		for (j=dum1;j<=dum2;j++){
			for (i=nx1;i<=nx2;i++){
				for (k=nz2+1-dist;k<=nz2+FW;k++){
					u[j][i][k]=(3.0*u[j][i][nz2-dist]+u[j-1][i][nz2-dist]+u[j+1][i][nz2-dist]+u[j][i-1][nz2-dist]+u[j][i+1][nz2-dist]+u[j][i][nz2-1-dist])/8.0;
					pi[j][i][k]=(3.0*pi[j][i][nz2-dist]+pi[j-1][i][nz2-dist]+pi[j+1][i][nz2-dist]+pi[j][i-1][nz2-dist]+pi[j][i+1][nz2-dist]+pi[j][i][nz2-dist-1])/8.0;
					rho[j][i][k]=(3.0*rho[j][i][nz2-dist]+rho[j-1][i][nz2-dist]+rho[j+1][i][nz2-dist]+rho[j][i-1][nz2-dist]+rho[j][i+1][nz2-dist]+rho[j][i][nz2-dist-1])/8.0;
				}
			}
		}

	}


}