On Tue, Dec 12, 2023 at 12:23 PM Brandon Denton via petsc-users < petsc-users@mcs.anl.gov> wrote:
> Good Afternoon, > > I am currently working on an Inviscid Navier-Stokes problem and would like > to apply DM_BC_NATURAL boundary conditions to my domain. Looking through > the example files on petsc.org, I noticed that in almost all cases there > are the following series of calls. > > PetscCall(DMAddBoundary(dm, DM_BC_NATURAL, "wall", label, 1, &id, 0, 0, > NULL, NULL, NULL, user, &bd)); > PetscCall(PetscDSGetBoundary(ds, bd, &wf, NULL, NULL, NULL, NULL, NULL, > NULL, NULL, NULL, NULL, NULL, NULL)); > PetscCall(PetscWeakFormSetIndexBdResidual(wf, label, id, 0, 0, 0, f0_bd_u, > 0, NULL)); > > Is this the standard way of applying Natural boundary conditions in PETSc > for FEM? > Yes. The problem is that AddBoundary was designed just to deliver boundary values, but inhomogeneous Neumann conditions really want weak forms, and the weak form interface came later. It is a little clunky. > Also, I noticed in the signature for the f0_bd_u function, there is a > const PetscReal n[] array. What is this array and what information does it > hold. Is it the normal vector at the point? > That is the normal at the evaluation point. Thanks, Matt > static void f0_bd_u(PetscInt dim, PetscInt Nf, PetscInt NfAux, const > PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const > PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const > PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const > PetscScalar a_x[], PetscReal t, const PetscReal x[], const PetscReal n[], > PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) > > Thank you in advance for your time. > Brandon > > > > > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>