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 "../navierstokes.h" 12 #include "../qfunctions/densitycurrent.h" 13 14 PetscErrorCode NS_DENSITY_CURRENT(ProblemData *problem, DM dm, void *setup_ctx, 15 void *ctx) { 16 17 PetscInt ierr; 18 ierr = NS_NEWTONIAN_IG(problem, dm, setup_ctx, ctx); CHKERRQ(ierr); 19 SetupContext setup_context = *(SetupContext *)setup_ctx; 20 User user = *(User *)ctx; 21 MPI_Comm comm = PETSC_COMM_WORLD; 22 PetscFunctionBeginUser; 23 24 // ------------------------------------------------------ 25 // SET UP DENSITY_CURRENT 26 // ------------------------------------------------------ 27 problem->ics = ICsDC; 28 problem->ics_loc = ICsDC_loc; 29 problem->bc = Exact_DC; 30 31 // ------------------------------------------------------ 32 // Create the libCEED context 33 // ------------------------------------------------------ 34 CeedScalar rc = 1000.; // m (Radius of bubble) 35 PetscReal center[3], dc_axis[3] = {0, 0, 0}; 36 PetscReal domain_min[3], domain_max[3], domain_size[3]; 37 ierr = DMGetBoundingBox(dm, domain_min, domain_max); CHKERRQ(ierr); 38 for (int i=0; i<3; i++) domain_size[i] = domain_max[i] - domain_min[i]; 39 40 // ------------------------------------------------------ 41 // Command line Options 42 // ------------------------------------------------------ 43 PetscOptionsBegin(comm, NULL, "Options for DENSITY_CURRENT problem", NULL); 44 ierr = PetscOptionsScalar("-rc", "Characteristic radius of thermal bubble", 45 NULL, rc, &rc, NULL); CHKERRQ(ierr); 46 for (int i=0; i<3; i++) center[i] = .5*domain_size[i]; 47 PetscInt n = problem->dim; 48 ierr = PetscOptionsRealArray("-center", "Location of bubble center", 49 NULL, center, &n, NULL); CHKERRQ(ierr); 50 n = problem->dim; 51 ierr = PetscOptionsRealArray("-dc_axis", 52 "Axis of density current cylindrical anomaly, or {0,0,0} for spherically symmetric", 53 NULL, dc_axis, &n, NULL); CHKERRQ(ierr); 54 { 55 PetscReal norm = PetscSqrtReal(PetscSqr(dc_axis[0]) + PetscSqr(dc_axis[1]) + 56 PetscSqr(dc_axis[2])); 57 if (norm > 0) { 58 for (int i=0; i<3; i++) dc_axis[i] /= norm; 59 } 60 } 61 62 PetscOptionsEnd(); 63 64 PetscScalar meter = user->units->meter; 65 rc = fabs(rc) * meter; 66 for (int i=0; i<3; i++) center[i] *= meter; 67 68 setup_context->rc = rc; 69 setup_context->center[0] = center[0]; 70 setup_context->center[1] = center[1]; 71 setup_context->center[2] = center[2]; 72 setup_context->dc_axis[0] = dc_axis[0]; 73 setup_context->dc_axis[1] = dc_axis[1]; 74 setup_context->dc_axis[2] = dc_axis[2]; 75 76 PetscFunctionReturn(0); 77 } 78 79 PetscErrorCode SetupContext_DENSITY_CURRENT(Ceed ceed, CeedData ceed_data, 80 AppCtx app_ctx, SetupContext setup_ctx, Physics phys) { 81 PetscFunctionBeginUser; 82 PetscInt ierr = SetupContext_NEWTONIAN_IG(ceed, ceed_data, app_ctx, setup_ctx, 83 phys); 84 CHKERRQ(ierr); 85 PetscFunctionReturn(0); 86 } 87 88 PetscErrorCode PRINT_DENSITY_CURRENT(Physics phys, SetupContext setup_ctx, 89 AppCtx app_ctx) { 90 MPI_Comm comm = PETSC_COMM_WORLD; 91 PetscErrorCode ierr; 92 PetscFunctionBeginUser; 93 94 ierr = PetscPrintf(comm, 95 " Problem:\n" 96 " Problem Name : %s\n" 97 " Stabilization : %s\n", 98 app_ctx->problem_name, StabilizationTypes[phys->stab]); 99 CHKERRQ(ierr); 100 101 PetscFunctionReturn(0); 102 } 103