1*457a5831SJames Wright // Copyright (c) 2017-2023, Lawrence Livermore National Security, LLC and other CEED contributors. 2*457a5831SJames Wright // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3*457a5831SJames Wright // 4*457a5831SJames Wright // SPDX-License-Identifier: BSD-2-Clause 5*457a5831SJames Wright // 6*457a5831SJames Wright // This file is part of CEED: http://github.com/ceed 7*457a5831SJames Wright /// @file 8*457a5831SJames Wright /// Functions for setting up and projecting the velocity gradient 9*457a5831SJames Wright 10*457a5831SJames Wright #include "../qfunctions/velocity_gradient_projection.h" 11*457a5831SJames Wright 12*457a5831SJames Wright #include <petscdmplex.h> 13*457a5831SJames Wright 14*457a5831SJames Wright #include "../navierstokes.h" 15*457a5831SJames Wright 16*457a5831SJames Wright PetscErrorCode VelocityGradientProjectionCreateDM(NodalProjectionData grad_velo_proj, User user, PetscInt degree) { 17*457a5831SJames Wright PetscFE fe; 18*457a5831SJames Wright PetscSection section; 19*457a5831SJames Wright PetscInt dim; 20*457a5831SJames Wright 21*457a5831SJames Wright PetscFunctionBeginUser; 22*457a5831SJames Wright grad_velo_proj->num_comp = 9; // 9 velocity gradient 23*457a5831SJames Wright 24*457a5831SJames Wright PetscCall(DMClone(user->dm, &grad_velo_proj->dm)); 25*457a5831SJames Wright PetscCall(DMGetDimension(grad_velo_proj->dm, &dim)); 26*457a5831SJames Wright PetscCall(PetscObjectSetName((PetscObject)grad_velo_proj->dm, "Velocity Gradient Projection")); 27*457a5831SJames Wright 28*457a5831SJames Wright PetscCall(PetscFECreateLagrange(PETSC_COMM_SELF, dim, grad_velo_proj->num_comp, PETSC_FALSE, degree, PETSC_DECIDE, &fe)); 29*457a5831SJames Wright PetscCall(PetscObjectSetName((PetscObject)fe, "Velocity Gradient Projection")); 30*457a5831SJames Wright PetscCall(DMAddField(grad_velo_proj->dm, NULL, (PetscObject)fe)); 31*457a5831SJames Wright PetscCall(DMCreateDS(grad_velo_proj->dm)); 32*457a5831SJames Wright PetscCall(DMPlexSetClosurePermutationTensor(grad_velo_proj->dm, PETSC_DETERMINE, NULL)); 33*457a5831SJames Wright 34*457a5831SJames Wright PetscCall(DMGetLocalSection(grad_velo_proj->dm, §ion)); 35*457a5831SJames Wright PetscCall(PetscSectionSetFieldName(section, 0, "")); 36*457a5831SJames Wright PetscCall(PetscSectionSetComponentName(section, 0, 0, "VelocityGradientXX")); 37*457a5831SJames Wright PetscCall(PetscSectionSetComponentName(section, 0, 1, "VelocityGradientXY")); 38*457a5831SJames Wright PetscCall(PetscSectionSetComponentName(section, 0, 2, "VelocityGradientXZ")); 39*457a5831SJames Wright PetscCall(PetscSectionSetComponentName(section, 0, 3, "VelocityGradientYX")); 40*457a5831SJames Wright PetscCall(PetscSectionSetComponentName(section, 0, 4, "VelocityGradientYY")); 41*457a5831SJames Wright PetscCall(PetscSectionSetComponentName(section, 0, 5, "VelocityGradientYZ")); 42*457a5831SJames Wright PetscCall(PetscSectionSetComponentName(section, 0, 6, "VelocityGradientZX")); 43*457a5831SJames Wright PetscCall(PetscSectionSetComponentName(section, 0, 7, "VelocityGradientZY")); 44*457a5831SJames Wright PetscCall(PetscSectionSetComponentName(section, 0, 8, "VelocityGradientZZ")); 45*457a5831SJames Wright 46*457a5831SJames Wright PetscCall(PetscFEDestroy(&fe)); 47*457a5831SJames Wright PetscFunctionReturn(0); 48*457a5831SJames Wright }; 49