1 // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3 // 4 // SPDX-License-Identifier: BSD-2-Clause 5 // 6 // This file is part of CEED: http://github.com/ceed 7 8 /// @file 9 /// Implementation of the Synthetic Turbulence Generation (STG) algorithm 10 /// presented in Shur et al. 2014 11 12 #include <stdlib.h> 13 #include <math.h> 14 #include <petsc.h> 15 #include "../navierstokes.h" 16 #include "stg_shur14.h" 17 #include "../qfunctions/stg_shur14.h" 18 19 #ifndef M_PI 20 #define M_PI 3.14159265358979323846 21 #endif 22 23 STGShur14Context global_stg_ctx; 24 25 /* 26 * @brief Perform Cholesky decomposition on array of symmetric 3x3 matrices 27 * 28 * This assumes the input matrices are in order [11,22,33,12,13,23]. This 29 * format is also used for the output. 30 * 31 * @param[in] comm MPI_Comm 32 * @param[in] nprofs Number of matrices in Rij 33 * @param[in] Rij Array of the symmetric matrices [6,nprofs] 34 * @param[out] Cij Array of the Cholesky Decomposition matrices, [6,nprofs] 35 */ 36 PetscErrorCode CalcCholeskyDecomp(MPI_Comm comm, PetscInt nprofs, 37 const CeedScalar Rij[6][nprofs], CeedScalar Cij[6][nprofs]) { 38 PetscFunctionBeginUser; 39 for (PetscInt i=0; i<nprofs; i++) { 40 Cij[0][i] = sqrt(Rij[0][i]); 41 Cij[3][i] = Rij[3][i] / Cij[0][i]; 42 Cij[1][i] = sqrt(Rij[1][i] - pow(Cij[3][i], 2) ); 43 Cij[4][i] = Rij[4][i] / Cij[0][i]; 44 Cij[5][i] = (Rij[5][i] - Cij[3][i]*Cij[4][i]) / Cij[1][i]; 45 Cij[2][i] = sqrt(Rij[2][i] - pow(Cij[4][i], 2) - pow(Cij[5][i], 2)); 46 47 if (isnan(Cij[0][i]) || isnan(Cij[1][i]) || isnan(Cij[2][i])) 48 SETERRQ(comm, -1, "Cholesky decomposition failed at profile point %d. " 49 "Either STGInflow has non-SPD matrix or contains nan.", i+1); 50 } 51 PetscFunctionReturn(0); 52 } 53 54 55 /* 56 * @brief Open a PHASTA *.dat file, grabbing dimensions and file pointer 57 * 58 * This function opens the file specified by `path` using `PetscFOpen` and 59 * passes the file pointer in `fp`. It is not closed in this function, thus 60 * `fp` must be closed sometime after this function has been called (using 61 * `PetscFClose` for example). 62 * 63 * Assumes that the first line of the file has the number of rows and columns 64 * as the only two entries, separated by a single space 65 * 66 * @param[in] comm MPI_Comm for the program 67 * @param[in] path Path to the file 68 * @param[in] char_array_len Length of the character array that should contain each line 69 * @param[out] dims Dimensions of the file, taken from the first line of the file 70 * @param[out] fp File pointer to the opened file 71 */ 72 static PetscErrorCode OpenPHASTADatFile(const MPI_Comm comm, 73 const char path[PETSC_MAX_PATH_LEN], const PetscInt char_array_len, 74 PetscInt dims[2], FILE **fp) { 75 PetscErrorCode ierr; 76 PetscInt ndims; 77 char line[char_array_len]; 78 char **array; 79 80 PetscFunctionBeginUser; 81 ierr = PetscFOpen(comm, path, "r", fp); CHKERRQ(ierr); 82 ierr = PetscSynchronizedFGets(comm, *fp, char_array_len, line); CHKERRQ(ierr); 83 ierr = PetscStrToArray(line, ' ', &ndims, &array); CHKERRQ(ierr); 84 if (ndims != 2) SETERRQ(comm, -1, 85 "Found %d dimensions instead of 2 on the first line of %s", 86 ndims, path); 87 88 for (PetscInt i=0; i<ndims; i++) dims[i] = atoi(array[i]); 89 ierr = PetscStrToArrayDestroy(ndims, array); CHKERRQ(ierr); 90 PetscFunctionReturn(0); 91 } 92 93 /* 94 * @brief Get the number of rows for the PHASTA file at path 95 * 96 * Assumes that the first line of the file has the number of rows and columns 97 * as the only two entries, separated by a single space 98 * 99 * @param[in] comm MPI_Comm for the program 100 * @param[in] path Path to the file 101 * @param[out] nrows Number of rows 102 */ 103 static PetscErrorCode GetNRows(const MPI_Comm comm, 104 const char path[PETSC_MAX_PATH_LEN], PetscInt *nrows) { 105 PetscErrorCode ierr; 106 const PetscInt char_array_len = 512; 107 PetscInt dims[2]; 108 FILE *fp; 109 110 PetscFunctionBeginUser; 111 ierr = OpenPHASTADatFile(comm, path, char_array_len, dims, &fp); CHKERRQ(ierr); 112 *nrows = dims[0]; 113 ierr = PetscFClose(comm, fp); CHKERRQ(ierr); 114 PetscFunctionReturn(0); 115 } 116 117 /* 118 * @brief Read the STGInflow file and load the contents into stg_ctx 119 * 120 * Assumes that the first line of the file has the number of rows and columns 121 * as the only two entries, separated by a single space. 122 * Assumes there are 14 columns in the file 123 * 124 * Function calculates the Cholesky decomposition from the Reynolds stress 125 * profile found in the file 126 * 127 * @param[in] comm MPI_Comm for the program 128 * @param[in] path Path to the STGInflow.dat file 129 * @param[inout] stg_ctx STGShur14Context where the data will be loaded into 130 */ 131 static PetscErrorCode ReadSTGInflow(const MPI_Comm comm, 132 const char path[PETSC_MAX_PATH_LEN], STGShur14Context stg_ctx) { 133 PetscErrorCode ierr; 134 PetscInt ndims, dims[2]; 135 FILE *fp; 136 const PetscInt char_array_len=512; 137 char line[char_array_len]; 138 char **array; 139 140 PetscFunctionBeginUser; 141 142 ierr = OpenPHASTADatFile(comm, path, char_array_len, dims, &fp); CHKERRQ(ierr); 143 144 CeedScalar rij[6][stg_ctx->nprofs]; 145 CeedScalar *prof_dw = &stg_ctx->data[stg_ctx->offsets.prof_dw]; 146 CeedScalar *eps = &stg_ctx->data[stg_ctx->offsets.eps]; 147 CeedScalar *lt = &stg_ctx->data[stg_ctx->offsets.lt]; 148 CeedScalar (*ubar)[stg_ctx->nprofs] = (CeedScalar (*)[stg_ctx->nprofs]) 149 &stg_ctx->data[stg_ctx->offsets.ubar]; 150 151 for (PetscInt i=0; i<stg_ctx->nprofs; i++) { 152 ierr = PetscSynchronizedFGets(comm, fp, char_array_len, line); CHKERRQ(ierr); 153 ierr = PetscStrToArray(line, ' ', &ndims, &array); CHKERRQ(ierr); 154 if (ndims < dims[1]) SETERRQ(comm, -1, 155 "Line %d of %s does not contain enough columns (%d instead of %d)", i, 156 path, ndims, dims[1]); 157 158 prof_dw[i] = (CeedScalar) atof(array[0]); 159 ubar[0][i] = (CeedScalar) atof(array[1]); 160 ubar[1][i] = (CeedScalar) atof(array[2]); 161 ubar[2][i] = (CeedScalar) atof(array[3]); 162 rij[0][i] = (CeedScalar) atof(array[4]); 163 rij[1][i] = (CeedScalar) atof(array[5]); 164 rij[2][i] = (CeedScalar) atof(array[6]); 165 rij[3][i] = (CeedScalar) atof(array[7]); 166 rij[4][i] = (CeedScalar) atof(array[8]); 167 rij[5][i] = (CeedScalar) atof(array[9]); 168 lt[i] = (CeedScalar) atof(array[12]); 169 eps[i] = (CeedScalar) atof(array[13]); 170 171 if (prof_dw[i] < 0) SETERRQ(comm, -1, 172 "Distance to wall in %s cannot be negative", path); 173 if (lt[i] < 0) SETERRQ(comm, -1, 174 "Turbulent length scale in %s cannot be negative", path); 175 if (eps[i] < 0) SETERRQ(comm, -1, 176 "Turbulent dissipation in %s cannot be negative", path); 177 178 } 179 CeedScalar (*cij)[stg_ctx->nprofs] = (CeedScalar (*)[stg_ctx->nprofs]) 180 &stg_ctx->data[stg_ctx->offsets.cij]; 181 ierr = CalcCholeskyDecomp(comm, stg_ctx->nprofs, rij, cij); CHKERRQ(ierr); 182 ierr = PetscFClose(comm, fp); CHKERRQ(ierr); 183 PetscFunctionReturn(0); 184 } 185 186 /* 187 * @brief Read the STGRand file and load the contents into stg_ctx 188 * 189 * Assumes that the first line of the file has the number of rows and columns 190 * as the only two entries, separated by a single space. 191 * Assumes there are 7 columns in the file 192 * 193 * @param[in] comm MPI_Comm for the program 194 * @param[in] path Path to the STGRand.dat file 195 * @param[inout] stg_ctx STGShur14Context where the data will be loaded into 196 */ 197 static PetscErrorCode ReadSTGRand(const MPI_Comm comm, 198 const char path[PETSC_MAX_PATH_LEN], 199 STGShur14Context stg_ctx) { 200 PetscErrorCode ierr; 201 PetscInt ndims, dims[2]; 202 FILE *fp; 203 const PetscInt char_array_len = 512; 204 char line[char_array_len]; 205 char **array; 206 207 PetscFunctionBeginUser; 208 ierr = OpenPHASTADatFile(comm, path, char_array_len, dims, &fp); CHKERRQ(ierr); 209 210 CeedScalar *phi = &stg_ctx->data[stg_ctx->offsets.phi]; 211 CeedScalar (*d)[stg_ctx->nmodes] = (CeedScalar (*)[stg_ctx->nmodes]) 212 &stg_ctx->data[stg_ctx->offsets.d]; 213 CeedScalar (*sigma)[stg_ctx->nmodes] = (CeedScalar (*)[stg_ctx->nmodes]) 214 &stg_ctx->data[stg_ctx->offsets.sigma]; 215 216 for (PetscInt i=0; i<stg_ctx->nmodes; i++) { 217 ierr = PetscSynchronizedFGets(comm, fp, char_array_len, line); CHKERRQ(ierr); 218 ierr = PetscStrToArray(line, ' ', &ndims, &array); CHKERRQ(ierr); 219 if (ndims < dims[1]) SETERRQ(comm, -1, 220 "Line %d of %s does not contain enough columns (%d instead of %d)", i, 221 path, ndims, dims[1]); 222 223 d[0][i] = (CeedScalar) atof(array[0]); 224 d[1][i] = (CeedScalar) atof(array[1]); 225 d[2][i] = (CeedScalar) atof(array[2]); 226 phi[i] = (CeedScalar) atof(array[3]); 227 sigma[0][i] = (CeedScalar) atof(array[4]); 228 sigma[1][i] = (CeedScalar) atof(array[5]); 229 sigma[2][i] = (CeedScalar) atof(array[6]); 230 } 231 ierr = PetscFClose(comm, fp); CHKERRQ(ierr); 232 PetscFunctionReturn(0); 233 } 234 235 /* 236 * @brief Read STG data from input paths and put in STGShur14Context 237 * 238 * Reads data from input paths and puts them into a STGShur14Context object. 239 * Data stored initially in `*pstg_ctx` will be copied over to the new 240 * STGShur14Context instance. 241 * 242 * @param[in] comm MPI_Comm for the program 243 * @param[in] dm DM for the program 244 * @param[in] stg_inflow_path Path to STGInflow.dat file 245 * @param[in] stg_rand_path Path to STGRand.dat file 246 * @param[inout] pstg_ctx Pointer to STGShur14Context where the data will be loaded into 247 */ 248 PetscErrorCode GetSTGContextData(const MPI_Comm comm, const DM dm, 249 char stg_inflow_path[PETSC_MAX_PATH_LEN], 250 char stg_rand_path[PETSC_MAX_PATH_LEN], 251 STGShur14Context *pstg_ctx, 252 const CeedScalar ynodes[]) { 253 PetscErrorCode ierr; 254 PetscInt nmodes, nprofs; 255 STGShur14Context stg_ctx; 256 PetscFunctionBeginUser; 257 258 // Get options 259 ierr = GetNRows(comm, stg_rand_path, &nmodes); CHKERRQ(ierr); 260 ierr = GetNRows(comm, stg_inflow_path, &nprofs); CHKERRQ(ierr); 261 if (nmodes > STG_NMODES_MAX) 262 SETERRQ(comm, 1, "Number of wavemodes in %s (%d) exceeds STG_NMODES_MAX (%d). " 263 "Change size of STG_NMODES_MAX and recompile", stg_rand_path, nmodes, 264 STG_NMODES_MAX); 265 266 { 267 STGShur14Context s; 268 ierr = PetscCalloc1(1, &s); CHKERRQ(ierr); 269 *s = **pstg_ctx; 270 s->nmodes = nmodes; 271 s->nprofs = nprofs; 272 s->offsets.sigma = 0; 273 s->offsets.d = nmodes*3; 274 s->offsets.phi = s->offsets.d + nmodes*3; 275 s->offsets.kappa = s->offsets.phi + nmodes; 276 s->offsets.prof_dw = s->offsets.kappa + nmodes; 277 s->offsets.ubar = s->offsets.prof_dw + nprofs; 278 s->offsets.cij = s->offsets.ubar + nprofs*3; 279 s->offsets.eps = s->offsets.cij + nprofs*6; 280 s->offsets.lt = s->offsets.eps + nprofs; 281 s->offsets.ynodes = s->offsets.lt + nprofs; 282 PetscInt total_num_scalars = s->offsets.ynodes + s->nynodes; 283 s->total_bytes = sizeof(*stg_ctx) + total_num_scalars*sizeof(stg_ctx->data[0]); 284 ierr = PetscMalloc(s->total_bytes, &stg_ctx); CHKERRQ(ierr); 285 *stg_ctx = *s; 286 ierr = PetscFree(s); CHKERRQ(ierr); 287 } 288 289 ierr = ReadSTGInflow(comm, stg_inflow_path, stg_ctx); CHKERRQ(ierr); 290 ierr = ReadSTGRand(comm, stg_rand_path, stg_ctx); CHKERRQ(ierr); 291 292 if (stg_ctx->nynodes > 0) { 293 CeedScalar *ynodes_ctx = &stg_ctx->data[stg_ctx->offsets.ynodes]; 294 for (PetscInt i=0; i<stg_ctx->nynodes; i++) ynodes_ctx[i] = ynodes[i]; 295 } 296 297 // -- Calculate kappa 298 { 299 CeedScalar *kappa = &stg_ctx->data[stg_ctx->offsets.kappa]; 300 CeedScalar *prof_dw = &stg_ctx->data[stg_ctx->offsets.prof_dw]; 301 CeedScalar *lt = &stg_ctx->data[stg_ctx->offsets.lt]; 302 CeedScalar le, le_max=0; 303 304 CeedPragmaSIMD 305 for (PetscInt i=0; i<stg_ctx->nprofs; i++) { 306 le = PetscMin(2*prof_dw[i], 3*lt[i]); 307 if (le_max < le) le_max = le; 308 } 309 CeedScalar kmin = M_PI/le_max; 310 311 CeedPragmaSIMD 312 for (PetscInt i=0; i<stg_ctx->nmodes; i++) { 313 kappa[i] = kmin*pow(stg_ctx->alpha, i); 314 } 315 } //end calculate kappa 316 317 ierr = PetscFree(*pstg_ctx); CHKERRQ(ierr); 318 *pstg_ctx = stg_ctx; 319 PetscFunctionReturn(0); 320 } 321 322 PetscErrorCode SetupSTG(const MPI_Comm comm, const DM dm, ProblemData *problem, 323 User user, const bool prescribe_T, 324 const CeedScalar theta0, const CeedScalar P0, 325 const CeedScalar ynodes[], const CeedInt nynodes) { 326 PetscErrorCode ierr; 327 char stg_inflow_path[PETSC_MAX_PATH_LEN] = "./STGInflow.dat"; 328 char stg_rand_path[PETSC_MAX_PATH_LEN] = "./STGRand.dat"; 329 PetscBool mean_only = PETSC_FALSE, 330 use_stgstrong = PETSC_FALSE; 331 CeedScalar u0 = 0.0, 332 alpha = 1.01; 333 CeedQFunctionContext stg_context; 334 NewtonianIdealGasContext newtonian_ig_ctx; 335 PetscFunctionBeginUser; 336 337 // Get options 338 PetscOptionsBegin(comm, NULL, "STG Boundary Condition Options", NULL); 339 ierr = PetscOptionsString("-stg_inflow_path", "Path to STGInflow.dat", NULL, 340 stg_inflow_path, stg_inflow_path, 341 sizeof(stg_inflow_path), NULL); CHKERRQ(ierr); 342 ierr = PetscOptionsString("-stg_rand_path", "Path to STGInflow.dat", NULL, 343 stg_rand_path,stg_rand_path, 344 sizeof(stg_rand_path), NULL); CHKERRQ(ierr); 345 ierr = PetscOptionsReal("-stg_alpha", "Growth rate of the wavemodes", NULL, 346 alpha, &alpha, NULL); CHKERRQ(ierr); 347 ierr = PetscOptionsReal("-stg_u0", "Advective velocity for the fluctuations", 348 NULL, u0, &u0, NULL); CHKERRQ(ierr); 349 ierr = PetscOptionsBool("-stg_mean_only", "Only apply mean profile", 350 NULL, mean_only, &mean_only, NULL); CHKERRQ(ierr); 351 ierr = PetscOptionsBool("-stg_strong", "Enforce STG inflow strongly", 352 NULL, use_stgstrong, &use_stgstrong, NULL); CHKERRQ(ierr); 353 PetscOptionsEnd(); 354 355 ierr = PetscCalloc1(1, &global_stg_ctx); CHKERRQ(ierr); 356 global_stg_ctx->alpha = alpha; 357 global_stg_ctx->u0 = u0; 358 global_stg_ctx->is_implicit = user->phys->implicit; 359 global_stg_ctx->prescribe_T = prescribe_T; 360 global_stg_ctx->mean_only = mean_only; 361 global_stg_ctx->theta0 = theta0; 362 global_stg_ctx->P0 = P0; 363 global_stg_ctx->nynodes = nynodes; 364 365 { 366 // Calculate dx assuming constant spacing 367 PetscReal domain_min[3], domain_max[3], domain_size[3]; 368 ierr = DMGetBoundingBox(dm, domain_min, domain_max); CHKERRQ(ierr); 369 for (PetscInt i=0; i<3; i++) domain_size[i] = domain_max[i] - domain_min[i]; 370 371 PetscInt nmax = 3, faces[3]; 372 ierr = PetscOptionsGetIntArray(NULL, NULL, "-dm_plex_box_faces", faces, &nmax, 373 NULL); CHKERRQ(ierr); 374 global_stg_ctx->dx = domain_size[0]/faces[0]; 375 global_stg_ctx->dz = domain_size[2]/faces[2]; 376 } 377 378 CeedQFunctionContextGetData(problem->apply_vol_rhs.qfunction_context, 379 CEED_MEM_HOST, &newtonian_ig_ctx); 380 global_stg_ctx->newtonian_ctx = *newtonian_ig_ctx; 381 CeedQFunctionContextRestoreData(problem->apply_vol_rhs.qfunction_context, 382 &newtonian_ig_ctx); 383 384 ierr = GetSTGContextData(comm, dm, stg_inflow_path, stg_rand_path, 385 &global_stg_ctx, ynodes); CHKERRQ(ierr); 386 387 CeedQFunctionContextCreate(user->ceed, &stg_context); 388 CeedQFunctionContextSetData(stg_context, CEED_MEM_HOST, 389 CEED_USE_POINTER, global_stg_ctx->total_bytes, global_stg_ctx); 390 CeedQFunctionContextSetDataDestroy(stg_context, CEED_MEM_HOST, 391 FreeContextPetsc); 392 CeedQFunctionContextRegisterDouble(stg_context, "solution time", 393 offsetof(struct STGShur14Context_, time), 1, 394 "Phyiscal time of the solution"); 395 396 CeedQFunctionContextDestroy(&problem->ics.qfunction_context); 397 problem->ics.qfunction = ICsSTG; 398 problem->ics.qfunction_loc = ICsSTG_loc; 399 problem->ics.qfunction_context = stg_context; 400 401 if (use_stgstrong) { 402 // Use default boundary integral QF (BoundaryIntegral) in newtonian.h 403 problem->bc_from_ics = PETSC_FALSE; 404 } else { 405 problem->apply_inflow.qfunction = STGShur14_Inflow; 406 problem->apply_inflow.qfunction_loc = STGShur14_Inflow_loc; 407 problem->apply_inflow_jacobian.qfunction = STGShur14_Inflow_Jacobian; 408 problem->apply_inflow_jacobian.qfunction_loc = STGShur14_Inflow_Jacobian_loc; 409 CeedQFunctionContextReferenceCopy(stg_context, 410 &problem->apply_inflow.qfunction_context); 411 CeedQFunctionContextReferenceCopy(stg_context, 412 &problem->apply_inflow_jacobian.qfunction_context); 413 problem->bc_from_ics = PETSC_TRUE; 414 } 415 416 PetscFunctionReturn(0); 417 } 418 419 static inline PetscScalar FindDy(const PetscScalar ynodes[], 420 const PetscInt nynodes, const PetscScalar y) { 421 422 const PetscScalar half_mindy = 0.5 * (ynodes[1] - ynodes[0]); 423 // ^^assuming min(dy) is first element off the wall 424 PetscInt idx = -1; // Index 425 426 for (PetscInt i=0; i<nynodes; i++) { 427 if (y < ynodes[i] + half_mindy) { 428 idx = i; break; 429 } 430 } 431 if (idx == 0) return ynodes[1] - ynodes[0]; 432 else if (idx == nynodes-1) return ynodes[nynodes-2] - ynodes[nynodes-1]; 433 else return 0.5 * (ynodes[idx+1] - ynodes[idx-1]); 434 } 435 436 // Function passed to DMAddBoundary 437 PetscErrorCode StrongSTGbcFunc(PetscInt dim, PetscReal time, 438 const PetscReal x[], PetscInt Nc, PetscScalar bcval[], void *ctx) { 439 PetscFunctionBeginUser; 440 441 const STGShur14Context stg_ctx = (STGShur14Context) ctx; 442 PetscScalar qn[stg_ctx->nmodes], u[3], ubar[3], cij[6], eps, lt; 443 const bool mean_only = stg_ctx->mean_only; 444 const PetscScalar dx = stg_ctx->dx; 445 const PetscScalar dz = stg_ctx->dz; 446 const PetscScalar mu = stg_ctx->newtonian_ctx.mu; 447 const PetscScalar theta0 = stg_ctx->theta0; 448 const PetscScalar P0 = stg_ctx->P0; 449 const PetscScalar cv = stg_ctx->newtonian_ctx.cv; 450 const PetscScalar cp = stg_ctx->newtonian_ctx.cp; 451 const PetscScalar Rd = cp - cv; 452 453 const CeedScalar rho = P0 / (Rd * theta0); 454 InterpolateProfile(x[1], ubar, cij, &eps, <, stg_ctx); 455 if (!mean_only) { 456 const PetscInt nynodes = stg_ctx->nynodes; 457 const PetscScalar *ynodes = &stg_ctx->data[stg_ctx->offsets.ynodes]; 458 const PetscScalar h[3] = {dx, FindDy(ynodes, nynodes, x[1]), dz}; 459 CalcSpectrum(x[1], eps, lt, h, mu/rho, qn, stg_ctx); 460 STGShur14_Calc(x, time, ubar, cij, qn, u, stg_ctx); 461 } else { 462 for (CeedInt j=0; j<3; j++) u[j] = ubar[j]; 463 } 464 465 bcval[0] = rho; 466 bcval[1] = rho * u[0]; 467 bcval[2] = rho * u[1]; 468 bcval[3] = rho * u[2]; 469 PetscFunctionReturn(0); 470 } 471 472 PetscErrorCode SetupStrongSTG(DM dm, SimpleBC bc, ProblemData *problem) { 473 PetscErrorCode ierr; 474 DMLabel label; 475 const PetscInt comps[] = {0, 1, 2, 3}; 476 const PetscInt num_comps = 4; 477 PetscFunctionBeginUser; 478 479 ierr = DMGetLabel(dm, "Face Sets", &label); CHKERRQ(ierr); 480 // Set wall BCs 481 if (bc->num_inflow > 0) { 482 ierr = DMAddBoundary(dm, DM_BC_ESSENTIAL, "STG", label, 483 bc->num_inflow, bc->inflows, 0, num_comps, 484 comps, (void(*)(void))StrongSTGbcFunc, 485 NULL, global_stg_ctx, NULL); CHKERRQ(ierr); 486 } 487 488 PetscFunctionReturn(0); 489 } 490