gaussianwave.c (82bcd3d49ffed6252dd261f790745c0e54ecd545) gaussianwave.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

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

13#include <ceed.h>
14#include <petscdm.h>
15
16#include "../navierstokes.h"
17#include "../qfunctions/freestream_bc_type.h"
18
19PetscErrorCode NS_GAUSSIAN_WAVE(ProblemData *problem, DM dm, void *ctx, SimpleBC bc) {
20 User user = *(User *)ctx;
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

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

13#include <ceed.h>
14#include <petscdm.h>
15
16#include "../navierstokes.h"
17#include "../qfunctions/freestream_bc_type.h"
18
19PetscErrorCode NS_GAUSSIAN_WAVE(ProblemData *problem, DM dm, void *ctx, SimpleBC bc) {
20 User user = *(User *)ctx;
21 MPI_Comm comm = PETSC_COMM_WORLD;
21 MPI_Comm comm = user->comm;
22 Ceed ceed = user->ceed;
22 GaussianWaveContext gausswave_ctx;
23 FreestreamContext freestream_ctx;
24 NewtonianIdealGasContext newtonian_ig_ctx;
25 CeedQFunctionContext gausswave_context;
26
27 PetscFunctionBeginUser;
28 PetscCall(NS_NEWTONIAN_IG(problem, dm, ctx, bc));
29

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

51 PetscCall(PetscOptionsScalar("-amplitude", "Amplitude of the perturbation", NULL, amplitude, &amplitude, NULL));
52 PetscOptionsEnd();
53
54 width *= user->units->meter;
55 for (int i = 0; i < 3; i++) epicenter[i] *= user->units->meter;
56
57 // -- Set gausswave_ctx struct values
58 PetscCall(PetscCalloc1(1, &gausswave_ctx));
23 GaussianWaveContext gausswave_ctx;
24 FreestreamContext freestream_ctx;
25 NewtonianIdealGasContext newtonian_ig_ctx;
26 CeedQFunctionContext gausswave_context;
27
28 PetscFunctionBeginUser;
29 PetscCall(NS_NEWTONIAN_IG(problem, dm, ctx, bc));
30

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

52 PetscCall(PetscOptionsScalar("-amplitude", "Amplitude of the perturbation", NULL, amplitude, &amplitude, NULL));
53 PetscOptionsEnd();
54
55 width *= user->units->meter;
56 for (int i = 0; i < 3; i++) epicenter[i] *= user->units->meter;
57
58 // -- Set gausswave_ctx struct values
59 PetscCall(PetscCalloc1(1, &gausswave_ctx));
59 CeedQFunctionContextGetData(problem->apply_vol_rhs.qfunction_context, CEED_MEM_HOST, &newtonian_ig_ctx);
60 CeedQFunctionContextGetData(problem->apply_freestream.qfunction_context, CEED_MEM_HOST, &freestream_ctx);
60 PetscCallCeed(ceed, CeedQFunctionContextGetData(problem->apply_vol_rhs.qfunction_context, CEED_MEM_HOST, &newtonian_ig_ctx));
61 PetscCallCeed(ceed, CeedQFunctionContextGetData(problem->apply_freestream.qfunction_context, CEED_MEM_HOST, &freestream_ctx));
61
62 gausswave_ctx->amplitude = amplitude;
63 gausswave_ctx->width = width;
64 gausswave_ctx->S_infty = freestream_ctx->S_infty;
65 gausswave_ctx->newt_ctx = *newtonian_ig_ctx;
66 PetscCall(PetscArraycpy(gausswave_ctx->epicenter, epicenter, 3));
67
62
63 gausswave_ctx->amplitude = amplitude;
64 gausswave_ctx->width = width;
65 gausswave_ctx->S_infty = freestream_ctx->S_infty;
66 gausswave_ctx->newt_ctx = *newtonian_ig_ctx;
67 PetscCall(PetscArraycpy(gausswave_ctx->epicenter, epicenter, 3));
68
68 CeedQFunctionContextRestoreData(problem->apply_vol_rhs.qfunction_context, &newtonian_ig_ctx);
69 CeedQFunctionContextRestoreData(problem->apply_freestream.qfunction_context, &freestream_ctx);
69 PetscCallCeed(ceed, CeedQFunctionContextRestoreData(problem->apply_vol_rhs.qfunction_context, &newtonian_ig_ctx));
70 PetscCallCeed(ceed, CeedQFunctionContextRestoreData(problem->apply_freestream.qfunction_context, &freestream_ctx));
70
71
71 CeedQFunctionContextCreate(user->ceed, &gausswave_context);
72 CeedQFunctionContextSetData(gausswave_context, CEED_MEM_HOST, CEED_USE_POINTER, sizeof(*gausswave_ctx), gausswave_ctx);
73 CeedQFunctionContextSetDataDestroy(gausswave_context, CEED_MEM_HOST, FreeContextPetsc);
74 CeedQFunctionContextDestroy(&problem->ics.qfunction_context);
72 PetscCallCeed(ceed, CeedQFunctionContextCreate(user->ceed, &gausswave_context));
73 PetscCallCeed(ceed, CeedQFunctionContextSetData(gausswave_context, CEED_MEM_HOST, CEED_USE_POINTER, sizeof(*gausswave_ctx), gausswave_ctx));
74 PetscCallCeed(ceed, CeedQFunctionContextSetDataDestroy(gausswave_context, CEED_MEM_HOST, FreeContextPetsc));
75 PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->ics.qfunction_context));
75 problem->ics.qfunction_context = gausswave_context;
76
77 PetscFunctionReturn(PETSC_SUCCESS);
78}
76 problem->ics.qfunction_context = gausswave_context;
77
78 PetscFunctionReturn(PETSC_SUCCESS);
79}