39 const double*
const u,
49 fprintf(stderr,
"Error in ComputeShear()\n");
50 fprintf(stderr,
" shear force array is not NULL!\n");
54 if (!solver->
flag_ib)
return(0);
56 int nfacets_local = IB->nfacets_local;
62 if (nfacets_local > 0) {
64 (*sf) = (
double*) calloc (nv*nfacets_local,
sizeof(
double));
66 if (physics->
Re > 0) {
68 for (
int n = 0; n < nfacets_local; n++) {
78 v[k] += ( alpha[j] * u[_MODEL_NVARS_*nodes[j]+k] );
81 double rho_c, uvel_c, vvel_c, wvel_c, energy_c, pressure_c;
89 v[k] += ( alpha[j] * u[_MODEL_NVARS_*nodes[j]+k] );
92 double rho_ns, uvel_ns, vvel_ns, wvel_ns, energy_ns, pressure_ns;
95 double u_x = (uvel_ns - uvel_c) / fmap[n].dx;
96 double v_x = (vvel_ns - vvel_c) / fmap[n].dx;
97 double w_x = (wvel_ns - wvel_c) / fmap[n].dx;
99 double u_y = (uvel_ns - uvel_c) / fmap[n].dy;
100 double v_y = (vvel_ns - vvel_c) / fmap[n].dy;
101 double w_y = (wvel_ns - wvel_c) / fmap[n].dy;
103 double u_z = (uvel_ns - uvel_c) / fmap[n].dz;
104 double v_z = (vvel_ns - vvel_c) / fmap[n].dz;
105 double w_z = (wvel_ns - wvel_c) / fmap[n].dz;
111 double T = physics->
gamma*pressure_c/rho_c;
113 double inv_Re = 1.0/physics->
Re;
115 double tau_x = (mu*inv_Re) * (2*u_x*nx + (u_y+v_x)*ny + (u_z+w_x)*nz);
116 double tau_y = (mu*inv_Re) * ((v_x+u_y)*nx + 2*v_y*ny + (v_z+w_y)*nz);
117 double tau_z = (mu*inv_Re) * ((w_x+u_z)*nx + (w_y+v_z)*ny + 2*w_z*nz);
119 (*sf)[n*nv+
_XDIR_] = tau_x;
120 (*sf)[n*nv+
_YDIR_] = tau_y;
121 (*sf)[n*nv+
_ZDIR_] = tau_z;
123 (*sf)[n*nv+
_ZDIR_+1] = sqrt(tau_x*tau_x + tau_y*tau_y + tau_z*tau_z);
140 const double*
const p_surface,
141 const double*
const T_surface,
142 const double*
const ngrad_p_surface,
143 const double*
const ngrad_T_surface,
144 const double*
const shear,
157 double* p_surface_g = NULL;
160 fprintf(stderr,
"IBAssembleGlobalFacetData() returned with an error.\n");
163 double* T_surface_g = NULL;
166 fprintf(stderr,
"IBAssembleGlobalFacetData() returned with an error.\n");
169 double* ngrad_p_surface_g = NULL;
172 fprintf(stderr,
"IBAssembleGlobalFacetData() returned with an error.\n");
175 double* ngrad_T_surface_g = NULL;
178 fprintf(stderr,
"IBAssembleGlobalFacetData() returned with an error.\n");
181 double* shear_g = NULL;
184 fprintf(stderr,
"IBAssembleGlobalFacetData() returned with an error.\n");
195 out = fopen(filename,
"w");
196 fprintf(out,
"TITLE = \"Surface data created by HyPar.\"\n");
197 fprintf(out,
"VARIABLES = \"X\", \"Y\", \"Z\", ");
198 fprintf(out,
"\"Surface_Pressure\", ");
199 fprintf(out,
"\"Surface_Temperature\", ");
200 fprintf(out,
"\"Normal_Grad_Surface_Pressure\", ");
201 fprintf(out,
"\"Normal_Grad_Surface_Temperature\", ");
202 fprintf(out,
"\"Shear_x\", ");
203 fprintf(out,
"\"Shear_y\", ");
204 fprintf(out,
"\"Shear_z\", ");
205 fprintf(out,
"\"Shear_magn\"");
207 fprintf(out,
"ZONE N = %d, E = %d, DATAPACKING = POINT, ZONETYPE = FETRIANGLE\n",3*nfacets_global,nfacets_global);
209 for (
int n = 0; n < nfacets_global; n++) {
210 fprintf( out,
"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\n",
216 ngrad_p_surface_g[n],
217 ngrad_T_surface_g[n],
222 fprintf( out,
"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\n",
228 ngrad_p_surface_g[n],
229 ngrad_T_surface_g[n],
234 fprintf( out,
"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\n",
240 ngrad_p_surface_g[n],
241 ngrad_T_surface_g[n],
247 for (
int n = 0; n < nfacets_global; n++) fprintf(out,
"%d %d %d\n",3*n+1,3*n+2,3*n+3);
251 if (p_surface_g) free(p_surface_g);
252 if (T_surface_g) free(T_surface_g);
253 if (ngrad_p_surface_g) free(ngrad_p_surface_g);
254 if (ngrad_T_surface_g) free(ngrad_T_surface_g);
255 if (shear_g) free(shear_g);
274 if (!solver->
flag_ib)
return(0);
278 double* pressure = (
double*) calloc (npts,
sizeof(
double));
281 fprintf(stderr,
"Error in NavierStokes3DIBForces()\n");
282 fprintf(stderr,
" NavierStokes3DComputePressure() returned with error.\n");
285 double* temperature = (
double*) calloc(npts,
sizeof(
double));
288 fprintf(stderr,
"Error in NavierStokes3DIBForces()\n");
289 fprintf(stderr,
" NavierStokes3DComputeTemperature() returned with error.\n");
294 double* p_surface = NULL;
297 fprintf(stderr,
"Error in NavierStokes3DIBForces()\n");
298 fprintf(stderr,
" IBComputeFacetVar() returned with error.\n");
302 double* T_surface = NULL;
305 fprintf(stderr,
"Error in NavierStokes3DIBForces()\n");
306 fprintf(stderr,
" IBComputeFacetVar() returned with error.\n");
310 double *ngrad_p_surface = NULL;
313 fprintf(stderr,
"Error in NavierStokes3DIBForces()\n");
314 fprintf(stderr,
" IBComputeNormalGradient() returned with error.\n");
318 double *ngrad_T_surface = NULL;
321 fprintf(stderr,
"Error in NavierStokes3DIBForces()\n");
322 fprintf(stderr,
" IBComputeNormalGradient() returned with error.\n");
326 double *shear = NULL;
329 fprintf(stderr,
"Error in NavierStokes3DIBForces()\n");
330 fprintf(stderr,
" ComputeShear() returned with error.\n");
335 if (solver->
nsims == 1) {
342 strcat(surface_filename,
"_");
343 strcat(surface_filename, index);
344 strcat(surface_filename,
"_");
346 strcat(surface_filename,
".dat");
348 printf(
"Writing immersed body surface data file %s.\n",surface_filename);
359 fprintf(stderr,
"Error in NavierStokes3DIBForces()\n");
360 fprintf(stderr,
" WriteSurfaceData() returned with error\n");
366 if (p_surface) free(p_surface);
367 if (T_surface) free(T_surface);
368 if (ngrad_p_surface) free(ngrad_p_surface);
369 if (ngrad_T_surface) free(ngrad_T_surface);
370 if (shear) free(shear);
#define _NavierStokes3DGetFlowVar_(u, stride, rho, vx, vy, vz, e, P, gamma)
int npoints_local_wghosts
#define _ArraySetValue_(x, size, value)
static int ComputeShear(void *s, void *m, const double *const u, double **const sf)
double interp_coeffs[_IB_NNODES_]
int NavierStokes3DComputePressure(double *P, const double *const u, void *s)
3D Navier Stokes equations (compressible flows)
Structure containing variables for immersed boundary implementation.
Structure defining a facet.
Structure defining a facet map.
Structures and function definitions for immersed boundaries.
void GetStringFromInteger(int, char *, int)
static int WriteSurfaceData(void *m, void *ib, const double *const p_surface, const double *const T_surface, const double *const ngrad_p_surface, const double *const ngrad_T_surface, const double *const shear, char *filename)
int IBAssembleGlobalFacetData(void *, void *, const double *const, double **const, int)
int NavierStokes3DComputeTemperature(double *T, const double *const u, void *s)
MPI related function definitions.
#define _MAX_STRING_SIZE_
int IBComputeFacetVar(void *, void *, const double *const, int, double **const)
char op_overwrite[_MAX_STRING_SIZE_]
Contains function definitions for common mathematical functions.
double interp_coeffs_ns[_IB_NNODES_]
int interp_nodes_ns[_IB_NNODES_]
int interp_nodes[_IB_NNODES_]
Contains structure definition for hypar.
Structure containing variables and parameters specific to the 3D Navier Stokes equations. This structure contains the physical parameters, variables, and function pointers specific to the 3D Navier-Stokes equations.
Some basic definitions and macros.
Contains macros and function definitions for common array operations.
Structure of MPI-related variables.
int IBComputeNormalGradient(void *, void *, const double *const, int, double **const)
Structure containing all solver-specific variables and functions.
int NavierStokes3DIBForces(void *s, void *m, double a_t)
Some common functions used here and there.
static const int _NavierStokes3D_stride_