blasius.c (62e4d60268e230cef74205c1d882ea17bc7435fd) blasius.c (a424bcd0dd58ea8f8b80ddde5af211268f0b358a)
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

--- 218 unchanged lines hidden (view full) ---

227 PetscCall(DMSetCoordinatesLocal(dm, vec_coords));
228
229 PetscFunctionReturn(PETSC_SUCCESS);
230}
231
232PetscErrorCode NS_BLASIUS(ProblemData *problem, DM dm, void *ctx, SimpleBC bc) {
233 User user = *(User *)ctx;
234 MPI_Comm comm = user->comm;
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

--- 218 unchanged lines hidden (view full) ---

227 PetscCall(DMSetCoordinatesLocal(dm, vec_coords));
228
229 PetscFunctionReturn(PETSC_SUCCESS);
230}
231
232PetscErrorCode NS_BLASIUS(ProblemData *problem, DM dm, void *ctx, SimpleBC bc) {
233 User user = *(User *)ctx;
234 MPI_Comm comm = user->comm;
235 Ceed ceed = user->ceed;
235 PetscBool use_stg = PETSC_FALSE;
236 BlasiusContext blasius_ctx;
237 NewtonianIdealGasContext newtonian_ig_ctx;
238 CeedQFunctionContext blasius_context;
239
240 PetscFunctionBeginUser;
241 PetscCall(NS_NEWTONIAN_IG(problem, dm, ctx, bc));
242 PetscCall(PetscCalloc1(1, &blasius_ctx));

--- 54 unchanged lines hidden (view full) ---

297 PetscReal *mesh_ynodes = NULL;
298 PetscInt mesh_nynodes = 0;
299 if (strcmp(mesh_ynodes_path, "")) {
300 PetscCall(GetYNodeLocs(comm, mesh_ynodes_path, &mesh_ynodes, &mesh_nynodes));
301 }
302 PetscCall(ModifyMesh(comm, dm, problem->dim, mesh_growth, mesh_Ndelta, mesh_refine_height, mesh_top_angle, &mesh_ynodes, &mesh_nynodes));
303
304 // Some properties depend on parameters from NewtonianIdealGas
236 PetscBool use_stg = PETSC_FALSE;
237 BlasiusContext blasius_ctx;
238 NewtonianIdealGasContext newtonian_ig_ctx;
239 CeedQFunctionContext blasius_context;
240
241 PetscFunctionBeginUser;
242 PetscCall(NS_NEWTONIAN_IG(problem, dm, ctx, bc));
243 PetscCall(PetscCalloc1(1, &blasius_ctx));

--- 54 unchanged lines hidden (view full) ---

298 PetscReal *mesh_ynodes = NULL;
299 PetscInt mesh_nynodes = 0;
300 if (strcmp(mesh_ynodes_path, "")) {
301 PetscCall(GetYNodeLocs(comm, mesh_ynodes_path, &mesh_ynodes, &mesh_nynodes));
302 }
303 PetscCall(ModifyMesh(comm, dm, problem->dim, mesh_growth, mesh_Ndelta, mesh_refine_height, mesh_top_angle, &mesh_ynodes, &mesh_nynodes));
304
305 // Some properties depend on parameters from NewtonianIdealGas
305 CeedQFunctionContextGetData(problem->apply_vol_rhs.qfunction_context, CEED_MEM_HOST, &newtonian_ig_ctx);
306 PetscCallCeed(ceed, CeedQFunctionContextGetData(problem->apply_vol_rhs.qfunction_context, CEED_MEM_HOST, &newtonian_ig_ctx));
306
307 blasius_ctx->weakT = weakT;
308 blasius_ctx->U_inf = U_inf;
309 blasius_ctx->T_inf = T_inf;
310 blasius_ctx->T_wall = T_wall;
311 blasius_ctx->delta0 = delta0;
312 blasius_ctx->P0 = P0;
313 blasius_ctx->n_cheb = N;

--- 6 unchanged lines hidden (view full) ---

320 PetscCall(DMGetBoundingBox(dm, domain_min, domain_max));
321 blasius_ctx->x_inflow = domain_min[0];
322 blasius_ctx->eta_max = 5 * domain_max[1] / blasius_ctx->delta0;
323 }
324 PetscBool diff_filter_mms = PETSC_FALSE;
325 PetscCall(PetscOptionsGetBool(NULL, NULL, "-diff_filter_mms", &diff_filter_mms, NULL));
326 if (!use_stg && !diff_filter_mms) PetscCall(ComputeChebyshevCoefficients(blasius_ctx));
327
307
308 blasius_ctx->weakT = weakT;
309 blasius_ctx->U_inf = U_inf;
310 blasius_ctx->T_inf = T_inf;
311 blasius_ctx->T_wall = T_wall;
312 blasius_ctx->delta0 = delta0;
313 blasius_ctx->P0 = P0;
314 blasius_ctx->n_cheb = N;

--- 6 unchanged lines hidden (view full) ---

321 PetscCall(DMGetBoundingBox(dm, domain_min, domain_max));
322 blasius_ctx->x_inflow = domain_min[0];
323 blasius_ctx->eta_max = 5 * domain_max[1] / blasius_ctx->delta0;
324 }
325 PetscBool diff_filter_mms = PETSC_FALSE;
326 PetscCall(PetscOptionsGetBool(NULL, NULL, "-diff_filter_mms", &diff_filter_mms, NULL));
327 if (!use_stg && !diff_filter_mms) PetscCall(ComputeChebyshevCoefficients(blasius_ctx));
328
328 CeedQFunctionContextRestoreData(problem->apply_vol_rhs.qfunction_context, &newtonian_ig_ctx);
329 PetscCallCeed(ceed, CeedQFunctionContextRestoreData(problem->apply_vol_rhs.qfunction_context, &newtonian_ig_ctx));
329
330
330 CeedQFunctionContextCreate(user->ceed, &blasius_context);
331 CeedQFunctionContextSetData(blasius_context, CEED_MEM_HOST, CEED_USE_POINTER, sizeof(*blasius_ctx), blasius_ctx);
332 CeedQFunctionContextSetDataDestroy(blasius_context, CEED_MEM_HOST, FreeContextPetsc);
331 PetscCallCeed(ceed, CeedQFunctionContextCreate(user->ceed, &blasius_context));
332 PetscCallCeed(ceed, CeedQFunctionContextSetData(blasius_context, CEED_MEM_HOST, CEED_USE_POINTER, sizeof(*blasius_ctx), blasius_ctx));
333 PetscCallCeed(ceed, CeedQFunctionContextSetDataDestroy(blasius_context, CEED_MEM_HOST, FreeContextPetsc));
333
334
334 CeedQFunctionContextDestroy(&problem->ics.qfunction_context);
335 PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->ics.qfunction_context));
335 problem->ics.qfunction_context = blasius_context;
336 if (use_stg) {
337 PetscCall(SetupSTG(comm, dm, problem, user, weakT, T_inf, P0, mesh_ynodes, mesh_nynodes));
338 } else if (diff_filter_mms) {
339 PetscCall(DifferentialFilter_MMS_ICSetup(problem));
340 } else {
341 problem->apply_inflow.qfunction = Blasius_Inflow;
342 problem->apply_inflow.qfunction_loc = Blasius_Inflow_loc;
343 problem->apply_inflow_jacobian.qfunction = Blasius_Inflow_Jacobian;
344 problem->apply_inflow_jacobian.qfunction_loc = Blasius_Inflow_Jacobian_loc;
336 problem->ics.qfunction_context = blasius_context;
337 if (use_stg) {
338 PetscCall(SetupSTG(comm, dm, problem, user, weakT, T_inf, P0, mesh_ynodes, mesh_nynodes));
339 } else if (diff_filter_mms) {
340 PetscCall(DifferentialFilter_MMS_ICSetup(problem));
341 } else {
342 problem->apply_inflow.qfunction = Blasius_Inflow;
343 problem->apply_inflow.qfunction_loc = Blasius_Inflow_loc;
344 problem->apply_inflow_jacobian.qfunction = Blasius_Inflow_Jacobian;
345 problem->apply_inflow_jacobian.qfunction_loc = Blasius_Inflow_Jacobian_loc;
345 CeedQFunctionContextReferenceCopy(blasius_context, &problem->apply_inflow.qfunction_context);
346 CeedQFunctionContextReferenceCopy(blasius_context, &problem->apply_inflow_jacobian.qfunction_context);
346 PetscCallCeed(ceed, CeedQFunctionContextReferenceCopy(blasius_context, &problem->apply_inflow.qfunction_context));
347 PetscCallCeed(ceed, CeedQFunctionContextReferenceCopy(blasius_context, &problem->apply_inflow_jacobian.qfunction_context));
347 }
348 PetscCall(PetscFree(mesh_ynodes));
349 PetscFunctionReturn(PETSC_SUCCESS);
350}
348 }
349 PetscCall(PetscFree(mesh_ynodes));
350 PetscFunctionReturn(PETSC_SUCCESS);
351}