1 // Copyright (c) 2017-2023, 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 /// @file 8 /// Functions for setting up and projecting the velocity gradient 9 10 #include "../qfunctions/velocity_gradient_projection.h" 11 12 #include <petscdmplex.h> 13 14 #include "../navierstokes.h" 15 16 PetscErrorCode VelocityGradientProjectionCreateDM(NodalProjectionData grad_velo_proj, User user, PetscInt degree) { 17 PetscFE fe; 18 PetscSection section; 19 PetscInt dim; 20 21 PetscFunctionBeginUser; 22 grad_velo_proj->num_comp = 9; // 9 velocity gradient 23 24 PetscCall(DMClone(user->dm, &grad_velo_proj->dm)); 25 PetscCall(DMGetDimension(grad_velo_proj->dm, &dim)); 26 PetscCall(PetscObjectSetName((PetscObject)grad_velo_proj->dm, "Velocity Gradient Projection")); 27 28 PetscCall(PetscFECreateLagrange(PETSC_COMM_SELF, dim, grad_velo_proj->num_comp, PETSC_FALSE, degree, PETSC_DECIDE, &fe)); 29 PetscCall(PetscObjectSetName((PetscObject)fe, "Velocity Gradient Projection")); 30 PetscCall(DMAddField(grad_velo_proj->dm, NULL, (PetscObject)fe)); 31 PetscCall(DMCreateDS(grad_velo_proj->dm)); 32 PetscCall(DMPlexSetClosurePermutationTensor(grad_velo_proj->dm, PETSC_DETERMINE, NULL)); 33 34 PetscCall(DMGetLocalSection(grad_velo_proj->dm, §ion)); 35 PetscCall(PetscSectionSetFieldName(section, 0, "")); 36 PetscCall(PetscSectionSetComponentName(section, 0, 0, "VelocityGradientXX")); 37 PetscCall(PetscSectionSetComponentName(section, 0, 1, "VelocityGradientXY")); 38 PetscCall(PetscSectionSetComponentName(section, 0, 2, "VelocityGradientXZ")); 39 PetscCall(PetscSectionSetComponentName(section, 0, 3, "VelocityGradientYX")); 40 PetscCall(PetscSectionSetComponentName(section, 0, 4, "VelocityGradientYY")); 41 PetscCall(PetscSectionSetComponentName(section, 0, 5, "VelocityGradientYZ")); 42 PetscCall(PetscSectionSetComponentName(section, 0, 6, "VelocityGradientZX")); 43 PetscCall(PetscSectionSetComponentName(section, 0, 7, "VelocityGradientZY")); 44 PetscCall(PetscSectionSetComponentName(section, 0, 8, "VelocityGradientZZ")); 45 46 PetscCall(PetscFEDestroy(&fe)); 47 PetscFunctionReturn(0); 48 }; 49