| densitycurrent.c (82bcd3d49ffed6252dd261f790745c0e54ecd545) | densitycurrent.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 9/// Utility functions for setting up DENSITY_CURRENT 10 11#include "../qfunctions/densitycurrent.h" 12 13#include <ceed.h> 14#include <petscdm.h> 15 16#include "../navierstokes.h" 17 18PetscErrorCode NS_DENSITY_CURRENT(ProblemData *problem, DM dm, void *ctx, SimpleBC bc) { | 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/// Utility functions for setting up DENSITY_CURRENT 10 11#include "../qfunctions/densitycurrent.h" 12 13#include <ceed.h> 14#include <petscdm.h> 15 16#include "../navierstokes.h" 17 18PetscErrorCode NS_DENSITY_CURRENT(ProblemData *problem, DM dm, void *ctx, SimpleBC bc) { |
| 19 MPI_Comm comm = PETSC_COMM_WORLD; | |
| 20 User user = *(User *)ctx; | 19 User user = *(User *)ctx; |
| 20 MPI_Comm comm = user->comm; 21 Ceed ceed = user->ceed; |
|
| 21 DensityCurrentContext dc_ctx; 22 CeedQFunctionContext density_current_context; 23 NewtonianIdealGasContext newtonian_ig_ctx; 24 25 PetscFunctionBeginUser; 26 PetscCall(NS_NEWTONIAN_IG(problem, dm, ctx, bc)); 27 PetscCall(PetscCalloc1(1, &dc_ctx)); 28 // ------------------------------------------------------ 29 // SET UP DENSITY_CURRENT 30 // ------------------------------------------------------ | 22 DensityCurrentContext dc_ctx; 23 CeedQFunctionContext density_current_context; 24 NewtonianIdealGasContext newtonian_ig_ctx; 25 26 PetscFunctionBeginUser; 27 PetscCall(NS_NEWTONIAN_IG(problem, dm, ctx, bc)); 28 PetscCall(PetscCalloc1(1, &dc_ctx)); 29 // ------------------------------------------------------ 30 // SET UP DENSITY_CURRENT 31 // ------------------------------------------------------ |
| 31 CeedQFunctionContextDestroy(&problem->ics.qfunction_context); | 32 PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->ics.qfunction_context)); |
| 32 problem->ics.qfunction = ICsDC; 33 problem->ics.qfunction_loc = ICsDC_loc; 34 35 // ------------------------------------------------------ 36 // Create the libCEED context 37 // ------------------------------------------------------ 38 CeedScalar theta0 = 300.; // K 39 CeedScalar thetaC = -15.; // K --- 49 unchanged lines hidden (view full) --- 89 dc_ctx->rc = rc; 90 dc_ctx->center[0] = center[0]; 91 dc_ctx->center[1] = center[1]; 92 dc_ctx->center[2] = center[2]; 93 dc_ctx->dc_axis[0] = dc_axis[0]; 94 dc_ctx->dc_axis[1] = dc_axis[1]; 95 dc_ctx->dc_axis[2] = dc_axis[2]; 96 | 33 problem->ics.qfunction = ICsDC; 34 problem->ics.qfunction_loc = ICsDC_loc; 35 36 // ------------------------------------------------------ 37 // Create the libCEED context 38 // ------------------------------------------------------ 39 CeedScalar theta0 = 300.; // K 40 CeedScalar thetaC = -15.; // K --- 49 unchanged lines hidden (view full) --- 90 dc_ctx->rc = rc; 91 dc_ctx->center[0] = center[0]; 92 dc_ctx->center[1] = center[1]; 93 dc_ctx->center[2] = center[2]; 94 dc_ctx->dc_axis[0] = dc_axis[0]; 95 dc_ctx->dc_axis[1] = dc_axis[1]; 96 dc_ctx->dc_axis[2] = dc_axis[2]; 97 |
| 97 CeedQFunctionContextGetData(problem->apply_vol_rhs.qfunction_context, CEED_MEM_HOST, &newtonian_ig_ctx); | 98 PetscCallCeed(ceed, CeedQFunctionContextGetData(problem->apply_vol_rhs.qfunction_context, CEED_MEM_HOST, &newtonian_ig_ctx)); |
| 98 dc_ctx->newtonian_ctx = *newtonian_ig_ctx; | 99 dc_ctx->newtonian_ctx = *newtonian_ig_ctx; |
| 99 CeedQFunctionContextRestoreData(problem->apply_vol_rhs.qfunction_context, &newtonian_ig_ctx); 100 CeedQFunctionContextCreate(user->ceed, &density_current_context); 101 CeedQFunctionContextSetData(density_current_context, CEED_MEM_HOST, CEED_USE_POINTER, sizeof(*dc_ctx), dc_ctx); 102 CeedQFunctionContextSetDataDestroy(density_current_context, CEED_MEM_HOST, FreeContextPetsc); | 100 PetscCallCeed(ceed, CeedQFunctionContextRestoreData(problem->apply_vol_rhs.qfunction_context, &newtonian_ig_ctx)); 101 PetscCallCeed(ceed, CeedQFunctionContextCreate(user->ceed, &density_current_context)); 102 PetscCallCeed(ceed, CeedQFunctionContextSetData(density_current_context, CEED_MEM_HOST, CEED_USE_POINTER, sizeof(*dc_ctx), dc_ctx)); 103 PetscCallCeed(ceed, CeedQFunctionContextSetDataDestroy(density_current_context, CEED_MEM_HOST, FreeContextPetsc)); |
| 103 problem->ics.qfunction_context = density_current_context; 104 105 PetscFunctionReturn(PETSC_SUCCESS); 106} | 104 problem->ics.qfunction_context = density_current_context; 105 106 PetscFunctionReturn(PETSC_SUCCESS); 107} |