1*51ee423eSJames Wright // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2*51ee423eSJames Wright // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3*51ee423eSJames Wright // 4*51ee423eSJames Wright // SPDX-License-Identifier: BSD-2-Clause 5*51ee423eSJames Wright // 6*51ee423eSJames Wright // This file is part of CEED: http://github.com/ceed 7*51ee423eSJames Wright 8*51ee423eSJames Wright /// @file 9*51ee423eSJames Wright /// Utility functions for setting up statistics collection 10*51ee423eSJames Wright 11*51ee423eSJames Wright #include "../navierstokes.h" 12*51ee423eSJames Wright 13*51ee423eSJames Wright PetscErrorCode CreateStatsDM(User user, ProblemData *problem, PetscInt degree, SimpleBC bc) { 14*51ee423eSJames Wright user->spanstats.num_comp_stats = 1; 15*51ee423eSJames Wright PetscFunctionBeginUser; 16*51ee423eSJames Wright 17*51ee423eSJames Wright // Get DM from surface 18*51ee423eSJames Wright { 19*51ee423eSJames Wright DMLabel label; 20*51ee423eSJames Wright PetscCall(DMGetLabel(user->dm, "Face Sets", &label)); 21*51ee423eSJames Wright PetscCall(DMPlexLabelComplete(user->dm, label)); 22*51ee423eSJames Wright PetscCall(DMPlexFilter(user->dm, label, 1, &user->spanstats.dm)); 23*51ee423eSJames Wright PetscCall(DMProjectCoordinates(user->spanstats.dm, NULL)); // Ensure that a coordinate FE exists 24*51ee423eSJames Wright } 25*51ee423eSJames Wright 26*51ee423eSJames Wright PetscCall(PetscObjectSetName((PetscObject)user->spanstats.dm, "Spanwise_Stats")); 27*51ee423eSJames Wright PetscCall(DMSetOptionsPrefix(user->spanstats.dm, "spanstats_")); 28*51ee423eSJames Wright PetscCall(PetscOptionsSetValue(NULL, "-spanstats_dm_sparse_localize", "0")); // [Jed] Not relevant because not periodic in this direction 29*51ee423eSJames Wright 30*51ee423eSJames Wright PetscCall(DMSetFromOptions(user->spanstats.dm)); 31*51ee423eSJames Wright PetscCall(DMViewFromOptions(user->spanstats.dm, NULL, "-dm_view")); // -spanstats_dm_view (option includes prefix) 32*51ee423eSJames Wright { 33*51ee423eSJames Wright PetscFE fe; 34*51ee423eSJames Wright DMLabel label; 35*51ee423eSJames Wright 36*51ee423eSJames Wright PetscCall(PetscFECreateLagrange(PETSC_COMM_SELF, problem->dim - 1, user->spanstats.num_comp_stats, PETSC_FALSE, degree, PETSC_DECIDE, &fe)); 37*51ee423eSJames Wright PetscCall(PetscObjectSetName((PetscObject)fe, "stats")); 38*51ee423eSJames Wright PetscCall(DMAddField(user->spanstats.dm, NULL, (PetscObject)fe)); 39*51ee423eSJames Wright PetscCall(DMCreateDS(user->spanstats.dm)); 40*51ee423eSJames Wright PetscCall(DMGetLabel(user->spanstats.dm, "Face Sets", &label)); 41*51ee423eSJames Wright 42*51ee423eSJames Wright // // Set wall BCs 43*51ee423eSJames Wright // if (bc->num_wall > 0) { 44*51ee423eSJames Wright // PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "wall", label, bc->num_wall, bc->walls, 0, bc->num_comps, bc->wall_comps, 45*51ee423eSJames Wright // (void (*)(void))problem->bc, NULL, problem->bc_ctx, NULL)); 46*51ee423eSJames Wright // } 47*51ee423eSJames Wright // // Set slip BCs in the x direction 48*51ee423eSJames Wright // if (bc->num_slip[0] > 0) { 49*51ee423eSJames Wright // PetscInt comps[1] = {1}; 50*51ee423eSJames Wright // PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "slipx", label, bc->num_slip[0], bc->slips[0], 0, 1, comps, (void (*)(void))NULL, NULL, 51*51ee423eSJames Wright // problem->bc_ctx, NULL)); 52*51ee423eSJames Wright // } 53*51ee423eSJames Wright // // Set slip BCs in the y direction 54*51ee423eSJames Wright // if (bc->num_slip[1] > 0) { 55*51ee423eSJames Wright // PetscInt comps[1] = {2}; 56*51ee423eSJames Wright // PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "slipy", label, bc->num_slip[1], bc->slips[1], 0, 1, comps, (void (*)(void))NULL, NULL, 57*51ee423eSJames Wright // problem->bc_ctx, NULL)); 58*51ee423eSJames Wright // } 59*51ee423eSJames Wright // // Set slip BCs in the z direction 60*51ee423eSJames Wright // if (bc->num_slip[2] > 0) { 61*51ee423eSJames Wright // PetscInt comps[1] = {3}; 62*51ee423eSJames Wright // PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "slipz", label, bc->num_slip[2], bc->slips[2], 0, 1, comps, (void (*)(void))NULL, NULL, 63*51ee423eSJames Wright // problem->bc_ctx, NULL)); 64*51ee423eSJames Wright // } 65*51ee423eSJames Wright 66*51ee423eSJames Wright PetscCall(DMPlexSetClosurePermutationTensor(user->spanstats.dm, PETSC_DETERMINE, NULL)); 67*51ee423eSJames Wright PetscCall(PetscFEDestroy(&fe)); 68*51ee423eSJames Wright } 69*51ee423eSJames Wright 70*51ee423eSJames Wright PetscSection section; 71*51ee423eSJames Wright PetscCall(DMGetLocalSection(user->spanstats.dm, §ion)); 72*51ee423eSJames Wright PetscCall(PetscSectionSetFieldName(section, 0, "")); 73*51ee423eSJames Wright PetscCall(PetscSectionSetComponentName(section, 0, 0, "Test")); 74*51ee423eSJames Wright // PetscCall(PetscSectionSetComponentName(section, 0, 0, "Mean Velocity Products XX")); 75*51ee423eSJames Wright // PetscCall(PetscSectionSetComponentName(section, 0, 1, "Mean Velocity Products YY")); 76*51ee423eSJames Wright // PetscCall(PetscSectionSetComponentName(section, 0, 2, "Mean Velocity Products ZZ")); 77*51ee423eSJames Wright // PetscCall(PetscSectionSetComponentName(section, 0, 3, "Mean Velocity Products YZ")); 78*51ee423eSJames Wright // PetscCall(PetscSectionSetComponentName(section, 0, 4, "Mean Velocity Products XZ")); 79*51ee423eSJames Wright // PetscCall(PetscSectionSetComponentName(section, 0, 5, "Mean Velocity Products XY")); 80*51ee423eSJames Wright 81*51ee423eSJames Wright // Vec test; 82*51ee423eSJames Wright // PetscCall(DMCreateLocalVector(user->spanstats.dm, &test)); 83*51ee423eSJames Wright // PetscCall(VecZeroEntries(test)); 84*51ee423eSJames Wright // PetscCall(VecViewFromOptions(test, NULL, "-test_view")); 85*51ee423eSJames Wright 86*51ee423eSJames Wright PetscFunctionReturn(0); 87*51ee423eSJames Wright } 88