operators_s.c 6.21 KB
Newer Older
tilman.metz's avatar
tilman.metz 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
/*------------------------------------------------------------------------
 * Copyright (C) 2015 For the list of authors, see file AUTHORS.
 *
 * This file is part of SOFI2D.
 *
 * SOFI2D 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.
 *
 * SOFI2D 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 SOFI2D. See file COPYING and/or
  * <http://www.gnu.org/licenses/gpl-2.0.html>.
--------------------------------------------------------------------------*/

/* $Id: operators_s.c 819 2015-04-17 11:07:06Z tmetz $ */

/*------------------------------------------------------------------------
 * FD Operators (Order 2-12) for the particle velocity components (used in 
 * the update functions of the boundary frame).
 *    
 * ----------------------------------------------------------------------*/

#include "fd.h"

/*FD Operators Order 2-12  ----------------------------------------------------------------------------------------------------*/
void operator_s_fd2 ( int i, int j,float  * vxx, float * vyx,float * vxy,float * vyy, float **vx, float **vy,float * hc )
{
	float  dhi;
	extern float DH;

	dhi = 1.0/DH;

	*vxx = hc[1]* ( vx[j][i]  -vx[j][i-1] ) *dhi;
	*vyx = hc[1]* ( vy[j][i+1]-vy[j][i] ) *dhi;
	*vxy = hc[1]* ( vx[j+1][i]-vx[j][i] ) *dhi;
	*vyy = hc[1]* ( vy[j][i]  -vy[j-1][i] ) *dhi;
}

void operator_s_fd4 ( int i, int j,float  * vxx, float * vyx,float * vxy,float * vyy, float **vx, float **vy,float * hc )
{
	float  dhi;
	extern float DH;

	dhi = 1.0/DH;

	*vxx = ( hc[1]* ( vx[j][i]  -vx[j][i-1] )
	         + hc[2]* ( vx[j][i+1]-vx[j][i-2] ) ) *dhi;

	*vyx = ( hc[1]* ( vy[j][i+1]-vy[j][i] )
	         + hc[2]* ( vy[j][i+2]-vy[j][i-1] ) ) *dhi;

	*vxy = ( hc[1]* ( vx[j+1][i]-vx[j][i] )
	         + hc[2]* ( vx[j+2][i]-vx[j-1][i] ) ) *dhi;

	*vyy = ( hc[1]* ( vy[j][i]  -vy[j-1][i] )
	         + hc[2]* ( vy[j+1][i]-vy[j-2][i] ) ) *dhi;
}

void operator_s_fd6 ( int i, int j,float  * vxx, float * vyx,float * vxy,float * vyy, float **vx, float **vy,float * hc )
{
	float  dhi;
	extern float DH;

	dhi = 1.0/DH;
	*vxx = ( hc[1]* ( vx[j][i]  -vx[j][i-1] )
	         + hc[2]* ( vx[j][i+1]-vx[j][i-2] )
	         + hc[3]* ( vx[j][i+2]-vx[j][i-3] ) ) *dhi;

	*vyx = ( hc[1]* ( vy[j][i+1]-vy[j][i] )
	         + hc[2]* ( vy[j][i+2]-vy[j][i-1] )
	         + hc[3]* ( vy[j][i+3]-vy[j][i-2] ) ) *dhi;

	*vxy = ( hc[1]* ( vx[j+1][i]-vx[j][i] )
	         + hc[2]* ( vx[j+2][i]-vx[j-1][i] )
	         + hc[3]* ( vx[j+3][i]-vx[j-2][i] ) ) *dhi;

	*vyy = ( hc[1]* ( vy[j][i]  -vy[j-1][i] )
	         + hc[2]* ( vy[j+1][i]-vy[j-2][i] )
	         + hc[3]* ( vy[j+2][i]-vy[j-3][i] ) ) *dhi;
}

void operator_s_fd8 ( int i, int j,float  * vxx, float * vyx,float * vxy,float * vyy, float **vx, float **vy,float * hc )
{
	float  dhi;
	extern float DH;

	dhi = 1.0/DH;

	*vxx = ( hc[1]* ( vx[j][i]  -vx[j][i-1] )
	         + hc[2]* ( vx[j][i+1]-vx[j][i-2] )
	         + hc[3]* ( vx[j][i+2]-vx[j][i-3] )
	         + hc[4]* ( vx[j][i+3]-vx[j][i-4] ) ) *dhi;

	*vyx = ( hc[1]* ( vy[j][i+1]-vy[j][i] )
	         + hc[2]* ( vy[j][i+2]-vy[j][i-1] )
	         + hc[3]* ( vy[j][i+3]-vy[j][i-2] )
	         + hc[4]* ( vy[j][i+4]-vy[j][i-3] ) ) *dhi;

	*vxy = ( hc[1]* ( vx[j+1][i]-vx[j][i] )
	         + hc[2]* ( vx[j+2][i]-vx[j-1][i] )
	         + hc[3]* ( vx[j+3][i]-vx[j-2][i] )
	         + hc[4]* ( vx[j+4][i]-vx[j-3][i] ) ) *dhi;

	*vyy = ( hc[1]* ( vy[j][i]  -vy[j-1][i] )
	         + hc[2]* ( vy[j+1][i]-vy[j-2][i] )
	         + hc[3]* ( vy[j+2][i]-vy[j-3][i] )
	         + hc[4]* ( vy[j+3][i]-vy[j-4][i] ) ) *dhi;
}

void operator_s_fd10 ( int i, int j,float  * vxx, float * vyx,float * vxy,float * vyy, float **vx, float **vy,float * hc )
{
	float  dhi;
	extern float DH;

	dhi = 1.0/DH;
	*vxx = ( hc[1]* ( vx[j][i]  -vx[j][i-1] )
	         + hc[2]* ( vx[j][i+1]-vx[j][i-2] )
	         + hc[3]* ( vx[j][i+2]-vx[j][i-3] )
	         + hc[4]* ( vx[j][i+3]-vx[j][i-4] )
	         + hc[5]* ( vx[j][i+4]-vx[j][i-5] )
	       ) *dhi;
	*vyy = ( hc[1]* ( vy[j][i]  -vy[j-1][i] )
	         + hc[2]* ( vy[j+1][i]-vy[j-2][i] )
	         + hc[3]* ( vy[j+2][i]-vy[j-3][i] )
	         + hc[4]* ( vy[j+3][i]-vy[j-4][i] )
	         + hc[5]* ( vy[j+4][i]-vy[j-5][i] )
	       ) *dhi;
	*vyx = ( hc[1]* ( vy[j][i+1]-vy[j][i] )
	         + hc[2]* ( vy[j][i+2]-vy[j][i-1] )
	         + hc[3]* ( vy[j][i+3]-vy[j][i-2] )
	         + hc[4]* ( vy[j][i+4]-vy[j][i-3] )
	         + hc[5]* ( vy[j][i+5]-vy[j][i-4] )
	       ) *dhi;
	*vxy = ( hc[1]* ( vx[j+1][i]-vx[j][i] )
	         + hc[2]* ( vx[j+2][i]-vx[j-1][i] )
	         + hc[3]* ( vx[j+3][i]-vx[j-2][i] )
	         + hc[4]* ( vx[j+4][i]-vx[j-3][i] )
	         + hc[5]* ( vx[j+5][i]-vx[j-4][i] )
	       ) *dhi;
}

void operator_s_fd12 ( int i, int j,float  * vxx, float * vyx,float * vxy,float * vyy, float **vx, float **vy,float * hc )
{
	float  dhi;
	extern float DH;

	dhi = 1.0/DH;
	*vxx = ( hc[1]* ( vx[j][i]  -vx[j][i-1] )
	         + hc[2]* ( vx[j][i+1]-vx[j][i-2] )
	         + hc[3]* ( vx[j][i+2]-vx[j][i-3] )
	         + hc[4]* ( vx[j][i+3]-vx[j][i-4] )
	         + hc[5]* ( vx[j][i+4]-vx[j][i-5] )
	         + hc[6]* ( vx[j][i+5]-vx[j][i-6] )
	       ) *dhi;
	*vyy = ( hc[1]* ( vy[j][i]  -vy[j-1][i] )
	         + hc[2]* ( vy[j+1][i]-vy[j-2][i] )
	         + hc[3]* ( vy[j+2][i]-vy[j-3][i] )
	         + hc[4]* ( vy[j+3][i]-vy[j-4][i] )
	         + hc[5]* ( vy[j+4][i]-vy[j-5][i] )
	         + hc[6]* ( vy[j+5][i]-vy[j-6][i] )
	       ) *dhi;
	*vyx = ( hc[1]* ( vy[j][i+1]-vy[j][i] )
	         + hc[2]* ( vy[j][i+2]-vy[j][i-1] )
	         + hc[3]* ( vy[j][i+3]-vy[j][i-2] )
	         + hc[4]* ( vy[j][i+4]-vy[j][i-3] )
	         + hc[5]* ( vy[j][i+5]-vy[j][i-4] )
	         + hc[6]* ( vy[j][i+6]-vy[j][i-5] )
	       ) *dhi;
	*vxy = ( hc[1]* ( vx[j+1][i]-vx[j][i] )
	         + hc[2]* ( vx[j+2][i]-vx[j-1][i] )
	         + hc[3]* ( vx[j+3][i]-vx[j-2][i] )
	         + hc[4]* ( vx[j+4][i]-vx[j-3][i] )
	         + hc[5]* ( vx[j+5][i]-vx[j-4][i] )
	         + hc[6]* ( vx[j+6][i]-vx[j-5][i] )
	       ) *dhi;
}