[petsc-users] Saving Multiple DMPlexes to a single HDF5 File

2024-01-05 Thread Brandon Denton via petsc-users
Happy New Year!

I'm attempting to save multiple DMPlexes to a single HDF5 file. During my 
solution, I make modification to the DMPlex and would like to track and store 
these changes as the solution progresses. Currently, I the program writes the 
DMPlex to the HDF5 file the first time I call DMView() but throws an error the 
2nd time I call DMView() to save the modified DMPlex. In my program, I would 
like to save more than 2  modfied DMPlexes to the same file. My current attempt 
at this process is outlined below with the error message copied at the end.

Any help you could give to get me over this hump is appreciated.

Thank you.
Brandon


​--- Relevant Current Code Segments 

/*  Command Line Variable */
-dm_view_test hdf5:mesh_test_all.h5

/* Create initial DMPlex from file and Name it */
PetscCall(DMPlexCreateFromFile(comm, ctx.filename, "EGADS", PETSC_TRUE, 
));
PetscCall(PetscObjectSetName((PetscObject)dmNozzle, "nozzle_mesh"));

/* Get viewer from command line options. If found, then get and check 
ViewerType and ViewerFormat */
/* Change ViewerFormat to PETSC_VIEWER_HDF5_PETSC per DMView() documation for 
saving multiple DMPlexes */
/* to a single file. Note: ViewerFormat Defaults to PETSC_VIEWER_DEFAULT when 
PetscOPtionsGetViewer() called */
PetscCall(PetscOptionsGetViewer(PETSC_COMM_WORLD, NULL, NULL, "-dm_view_test", 
, , ));
if (flg) {
PetscCall(PetscPrintf(PETSC_COMM_SELF, "  flg = TRUE \n"));
PetscCall(PetscViewerGetType(viewer, ));
PetscCall(PetscViewerPushFormat(viewer, PETSC_VIEWER_HDF5_PETSC));  // 
PetscOptionsGetViewer returns  as PETSC_VIEWER_DEFAULT need 
PETSC_VIEWER_HDF5_PETSC to save multiple DMPlexes in a single .h5 file.
PetscCall(PetscViewerGetFormat(viewer, ));
PetscCall(PetscPrintf(PETSC_COMM_SELF, "  viewer type = %s \n", viewType));
PetscCall(PetscPrintf(PETSC_COMM_SELF, "  viewer format = %d \n", 
viewFormat));
  }

/* Save Initial DMPlex to HDF5 file */
PetscCall(DMView(dmNozzle, viewer));

/* Code makes modifications to DMPlex not shown here */

/* Set new name for modified DMPlex and attempt to write to HDF5 file - Fails */
PetscCall(PetscObjectSetName((PetscObject)dmNozzle, "nozzle_meshes_1"));
PetscCall(DMView(dmNozzle, viewer));  // <-- Fails here

 End of Relevant Code Segments 

- ERROR MESSAGE -
HDF5-DIAG: Error detected in HDF5 (1.12.1) thread 0:
  #000: H5D.c line 779 in H5Dset_extent(): unable to set dataset extent
major: Dataset
minor: Can't set value
  #001: H5VLcallback.c line 2326 in H5VL_dataset_specific(): unable to execute 
dataset specific callback
major: Virtual Object Layer
minor: Can't operate on object
  #002: H5VLcallback.c line 2289 in H5VL__dataset_specific(): unable to execute 
dataset specific callback
major: Virtual Object Layer
minor: Can't operate on object
  #003: H5VLnative_dataset.c line 325 in H5VL__native_dataset_specific(): 
unable to set extent of dataset
major: Dataset
minor: Unable to initialize object
  #004: H5Dint.c line 3045 in H5D__set_extent(): unable to modify size of 
dataspace
major: Dataset
minor: Unable to initialize object
  #005: H5S.c line 1847 in H5S_set_extent(): dimension cannot exceed the 
existing maximal size (new: 386 max: 98)
major: Dataspace
minor: Bad value
[0]PETSC ERROR: - Error Message 
--
[0]PETSC ERROR: Error in external library
[0]PETSC ERROR: Error in HDF5 call H5Dset_extent() Status -1
[0]PETSC ERROR: WARNING! There are unused option(s) set! Could be the program 
crashed before usage or a spelling mistake, etc!
[0]PETSC ERROR:   Option left: name:-dm_plex_geom_without_snap_to_geom value: 0 
source: command line
[0]PETSC ERROR:   Option left: name:-dm_view1 value: 
hdf5:mesh_minSA_vol_abstract.h5 source: command line
[0]PETSC ERROR:   Option left: name:-dm_view10 value: hdf5:mesh_minSA_itr5.h5 
source: command line
[0]PETSC ERROR:   Option left: name:-dm_view11 value: hdf5:mesh_minSA_itr20.h5 
source: command line
[0]PETSC ERROR:   Option left: name:-dm_view12 value: hdf5:mesh_minSA_itr50.h5 
source: command line
[0]PETSC ERROR:   Option left: name:-dm_view13 value: hdf5:mesh_minSA_itr100.h5 
source: command line
[0]PETSC ERROR:   Option left: name:-dm_view14 value: hdf5:mesh_minSA_itr150.h5 
source: command line
[0]PETSC ERROR:   Option left: name:-dm_view15 value: hdf5:mesh_minSA_itr200.h5 
source: command line
[0]PETSC ERROR:   Option left: name:-dm_view2 value: 
hdf5:mesh_minSA_vol_abstract_inflated.h5 source: command line
[0]PETSC ERROR:   Option left: name:-dm_view22 value: 
hdf5:mesh_minSA_itr200r1.h5 source: command line
[0]PETSC ERROR:   Option left: name:-dm_view23 value: 
hdf5:mesh_minSA_itr200r2.h5 source: command line
[0]PETSC ERROR:   Option left: name:-dm_view3 value: 
hdf5:mesh_minSA_vol_abstract_Refine.h5 source: command line
[0]PETSC ERROR:   Option left: name:-dm_view4 value: 

[petsc-users] Applying Natural Boundary Conditions using PETSc FEM Technology

2023-12-12 Thread Brandon Denton via petsc-users
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, , 0, 0, NULL, 
NULL, NULL, user, ));
PetscCall(PetscDSGetBoundary(ds, bd, , 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? 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?

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






Re: [petsc-users] Storing Values using a Triplet for using later

2023-11-09 Thread Brandon Denton via petsc-users
Good Morning,

Thank you Matt, Jed, and Barry. I will looking into each of these suggestions a 
report back.

-Brandon

From: Matthew Knepley 
Sent: Wednesday, November 8, 2023 4:18 PM
To: Brandon Denton 
Cc: petsc-users@mcs.anl.gov 
Subject: Re: [petsc-users] Storing Values using a Triplet for using later

On Wed, Nov 8, 2023 at 2:40 PM Brandon Denton via petsc-users 
mailto:petsc-users@mcs.anl.gov>> wrote:
Good Afternoon,

Is there a structure within PETSc that allows storage of a value using a triple 
similar to PetscHMapIJSet with the key using a struct{PetscScalar i, j, k;}?

I'm trying to access mesh information (the shape function coefficients I will 
calculate prior to their use) who's values I want to store in the auxiliary 
array available in the Residual Functions of PETSc's FEM infrastructure. After 
some trial and error work, I've come to the realization that the coordinates 
(x[]) available in the auxiliary functions is the centroid of the cell/element 
currently being evaluated. This triplet is unique for each cell/element for a 
valid mesh so I think it's reasonable to use this triplet as a key for looking 
up stored values unique to each cell/element. My plan is to attached the map to 
the Application Context, also available to Auxiliary Functions, to enable these 
calculations.

Does such a map infrastructure exist within PETSc? If so, could you point me to 
a reference for it? If not, does anyone have any suggestions on how to solve 
this problem?

As Jed says, this is a spatial hash. I have a primitive spatial hash now. You 
can use DMLocatePoints() to find the cell containing a point (like the 
centroid). Let me know if this does not work or if I misunderstand the problem.

  Thanks!

Matt

Thank you in advance for your time.
Brandon Denton



--
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/>


[petsc-users] Storing Values using a Triplet for using later

2023-11-08 Thread Brandon Denton via petsc-users
Good Afternoon,

Is there a structure within PETSc that allows storage of a value using a triple 
similar to PetscHMapIJSet with the key using a struct{PetscScalar i, j, k;}?

I'm trying to access mesh information (the shape function coefficients I will 
calculate prior to their use) who's values I want to store in the auxiliary 
array available in the Residual Functions of PETSc's FEM infrastructure. After 
some trial and error work, I've come to the realization that the coordinates 
(x[]) available in the auxiliary functions is the centroid of the cell/element 
currently being evaluated. This triplet is unique for each cell/element for a 
valid mesh so I think it's reasonable to use this triplet as a key for looking 
up stored values unique to each cell/element. My plan is to attached the map to 
the Application Context, also available to Auxiliary Functions, to enable these 
calculations.

Does such a map infrastructure exist within PETSc? If so, could you point me to 
a reference for it? If not, does anyone have any suggestions on how to solve 
this problem?

Thank you in advance for your time.
Brandon Denton



Re: [petsc-users] FEM Implementation of NS with SUPG Stabilization

2023-10-11 Thread Brandon Denton via petsc-users
How exactly does the aux data work? What is typically available there? Is it 
something the user can populate?



From: Matthew Knepley 
Sent: Wednesday, October 11, 2023 8:07 PM
To: Brandon Denton 
Cc: Jed Brown ; petsc-users 
Subject: Re: [petsc-users] FEM Implementation of NS with SUPG Stabilization

On Wed, Oct 11, 2023 at 4:15 PM Brandon Denton 
mailto:blden...@buffalo.edu>> wrote:
By natural coordinates, I am referring to the reference element coordinates. 
Usually these are represented as (xi, eta, zeta) in the literature.

Yes. I would like to have the Jacobian and the derivatives of the map available 
within PetscDSSetResidual() f0 and f1 functions.

Yes, we can get these passed an aux data.

  I believe DMPlexComputeCellGeometryFEM() function provides this information. 
Is there a way to get the cell, shape functions as well? It not, can we talk 
about this more? I would like to understand how the shape functions are 
addressed within PETSc. Dr. Kirk's approach uses the shape function gradients 
in its SUPG parameter. I'd love to talk with you about this is more detail.

There should be a way to formulate this in a basis independent way.  I would 
much prefer that to
explicit inclusion of the basis.

  Thanks,

 Matt

From: Matthew Knepley mailto:knep...@gmail.com>>
Sent: Wednesday, October 11, 2023 3:13 PM
To: Brandon Denton mailto:blden...@buffalo.edu>>
Cc: Jed Brown mailto:j...@jedbrown.org>>; petsc-users 
mailto:petsc-users@mcs.anl.gov>>
Subject: Re: [petsc-users] FEM Implementation of NS with SUPG Stabilization

On Wed, Oct 11, 2023 at 2:09 PM Brandon Denton 
mailto:blden...@buffalo.edu>> wrote:
Thank you for the discussion.

Are we agreed then that the derivatives of the natural coordinates are required 
for the described approach? If so, is this something PETSc can currently do 
within the point-wise residual functions?

I am not sure what natural coordinates are. Do we just mean the Jacobian, 
derivatives of the map between reference and real coordinates? If so, yes the 
Jacobian is available. Right now I do not pass it
directly, but passing it is easy.

  Thanks,

 Matt

Matt - Thank you for the command line option for the 2nd derivatives. Those 
will be needed to implement the discussed approach. Specifically in the 
stabilization and shock capture parameters. (Ref.: B. Kirk's Thesis). What is a 
good reference for the usual SUPG method you are referencing? I've been looking 
through my textbooks but haven't found a good reference.

Jed - Thank you for the link. I will review the information on it.

Sorry about the attachment. I will upload it to this thread later (I'm at work 
right now and I can't do it from here).

From: Jed Brown mailto:j...@jedbrown.org>>
Sent: Wednesday, October 11, 2023 1:38 PM
To: Matthew Knepley mailto:knep...@gmail.com>>
Cc: Brandon Denton mailto:blden...@buffalo.edu>>; 
petsc-users mailto:petsc-users@mcs.anl.gov>>
Subject: Re: [petsc-users] FEM Implementation of NS with SUPG Stabilization

Matthew Knepley mailto:knep...@gmail.com>> writes:

> On Wed, Oct 11, 2023 at 1:03 PM Jed Brown 
> mailto:j...@jedbrown.org>> wrote:
>
>> I don't see an attachment, but his thesis used conservative variables and
>> defined an effective length scale in a way that seemed to assume constant
>> shape function gradients. I'm not aware of systematic literature comparing
>> the covariant and contravariant length measures on anisotropic meshes, but
>> I believe most people working in the Shakib/Hughes approach use the
>> covariant measure. Our docs have a brief discussion of this choice.
>>
>> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Flibceed.org%2Fen%2Flatest%2Fexamples%2Ffluids%2F%23equation-eq-peclet=05%7C01%7Cbldenton%40buffalo.edu%7Cd9372f934b26455371a708dbca80dc8e%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638326427028053956%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=skMsKDmpBxiaXtBSqhsyckvVpTOkGqDsNJIYo22Ywps%3D=0
>>
>> Matt, I don't understand how the second derivative comes into play as a
>> length measure on anistropic meshes -- the second derivatives can be
>> uniformly zero and yet you still need a length measure.
>>
>
> I was talking about the usual SUPG where we just penalize the true residual.

I think you're focused on computing the strong diffusive flux (which can be 
done using second derivatives or by a projection; the latter produces somewhat 
better results). But you still need a length scale and that's most naturally 
computed using the derivative of reference coordinates with respect to physical 
(or equivalently, the associated metric tensor).


--
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


Re: [petsc-users] FEM Implementation of NS with SUPG Stabilization

2023-10-11 Thread Brandon Denton via petsc-users
By natural coordinates, I am referring to the reference element coordinates. 
Usually these are represented as (xi, eta, zeta) in the literature.

Yes. I would like to have the Jacobian and the derivatives of the map available 
within PetscDSSetResidual() f0 and f1 functions.  I believe 
DMPlexComputeCellGeometryFEM() function provides this information. Is there a 
way to get the cell, shape functions as well? It not, can we talk about this 
more? I would like to understand how the shape functions are addressed within 
PETSc. Dr. Kirk's approach uses the shape function gradients in its SUPG 
parameter. I'd love to talk with you about this is more detail.







From: Matthew Knepley 
Sent: Wednesday, October 11, 2023 3:13 PM
To: Brandon Denton 
Cc: Jed Brown ; petsc-users 
Subject: Re: [petsc-users] FEM Implementation of NS with SUPG Stabilization

On Wed, Oct 11, 2023 at 2:09 PM Brandon Denton 
mailto:blden...@buffalo.edu>> wrote:
Thank you for the discussion.

Are we agreed then that the derivatives of the natural coordinates are required 
for the described approach? If so, is this something PETSc can currently do 
within the point-wise residual functions?

I am not sure what natural coordinates are. Do we just mean the Jacobian, 
derivatives of the map between reference and real coordinates? If so, yes the 
Jacobian is available. Right now I do not pass it
directly, but passing it is easy.

  Thanks,

 Matt

Matt - Thank you for the command line option for the 2nd derivatives. Those 
will be needed to implement the discussed approach. Specifically in the 
stabilization and shock capture parameters. (Ref.: B. Kirk's Thesis). What is a 
good reference for the usual SUPG method you are referencing? I've been looking 
through my textbooks but haven't found a good reference.

Jed - Thank you for the link. I will review the information on it.

Sorry about the attachment. I will upload it to this thread later (I'm at work 
right now and I can't do it from here).

From: Jed Brown mailto:j...@jedbrown.org>>
Sent: Wednesday, October 11, 2023 1:38 PM
To: Matthew Knepley mailto:knep...@gmail.com>>
Cc: Brandon Denton mailto:blden...@buffalo.edu>>; 
petsc-users mailto:petsc-users@mcs.anl.gov>>
Subject: Re: [petsc-users] FEM Implementation of NS with SUPG Stabilization

Matthew Knepley mailto:knep...@gmail.com>> writes:

> On Wed, Oct 11, 2023 at 1:03 PM Jed Brown 
> mailto:j...@jedbrown.org>> wrote:
>
>> I don't see an attachment, but his thesis used conservative variables and
>> defined an effective length scale in a way that seemed to assume constant
>> shape function gradients. I'm not aware of systematic literature comparing
>> the covariant and contravariant length measures on anisotropic meshes, but
>> I believe most people working in the Shakib/Hughes approach use the
>> covariant measure. Our docs have a brief discussion of this choice.
>>
>> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Flibceed.org%2Fen%2Flatest%2Fexamples%2Ffluids%2F%23equation-eq-peclet=05%7C01%7Cbldenton%40buffalo.edu%7Cd9372f934b26455371a708dbca80dc8e%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638326427028053956%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=skMsKDmpBxiaXtBSqhsyckvVpTOkGqDsNJIYo22Ywps%3D=0
>>
>> Matt, I don't understand how the second derivative comes into play as a
>> length measure on anistropic meshes -- the second derivatives can be
>> uniformly zero and yet you still need a length measure.
>>
>
> I was talking about the usual SUPG where we just penalize the true residual.

I think you're focused on computing the strong diffusive flux (which can be 
done using second derivatives or by a projection; the latter produces somewhat 
better results). But you still need a length scale and that's most naturally 
computed using the derivative of reference coordinates with respect to physical 
(or equivalently, the associated metric tensor).


--
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/


Re: [petsc-users] FEM Implementation of NS with SUPG Stabilization

2023-10-11 Thread Brandon Denton via petsc-users
Thank you for the discussion.

Are we agreed then that the derivatives of the natural coordinates are required 
for the described approach? If so, is this something PETSc can currently do 
within the point-wise residual functions?

Matt - Thank you for the command line option for the 2nd derivatives. Those 
will be needed to implement the discussed approach. Specifically in the 
stabilization and shock capture parameters. (Ref.: B. Kirk's Thesis). What is a 
good reference for the usual SUPG method you are referencing? I've been looking 
through my textbooks but haven't found a good reference.

Jed - Thank you for the link. I will review the information on it.

Sorry about the attachment. I will upload it to this thread later (I'm at work 
right now and I can't do it from here).

From: Jed Brown 
Sent: Wednesday, October 11, 2023 1:38 PM
To: Matthew Knepley 
Cc: Brandon Denton ; petsc-users 
Subject: Re: [petsc-users] FEM Implementation of NS with SUPG Stabilization

Matthew Knepley  writes:

> On Wed, Oct 11, 2023 at 1:03 PM Jed Brown  wrote:
>
>> I don't see an attachment, but his thesis used conservative variables and
>> defined an effective length scale in a way that seemed to assume constant
>> shape function gradients. I'm not aware of systematic literature comparing
>> the covariant and contravariant length measures on anisotropic meshes, but
>> I believe most people working in the Shakib/Hughes approach use the
>> covariant measure. Our docs have a brief discussion of this choice.
>>
>> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Flibceed.org%2Fen%2Flatest%2Fexamples%2Ffluids%2F%23equation-eq-peclet=05%7C01%7Cbldenton%40buffalo.edu%7Cd9372f934b26455371a708dbca80dc8e%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638326427028053956%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=skMsKDmpBxiaXtBSqhsyckvVpTOkGqDsNJIYo22Ywps%3D=0
>>
>> Matt, I don't understand how the second derivative comes into play as a
>> length measure on anistropic meshes -- the second derivatives can be
>> uniformly zero and yet you still need a length measure.
>>
>
> I was talking about the usual SUPG where we just penalize the true residual.

I think you're focused on computing the strong diffusive flux (which can be 
done using second derivatives or by a projection; the latter produces somewhat 
better results). But you still need a length scale and that's most naturally 
computed using the derivative of reference coordinates with respect to physical 
(or equivalently, the associated metric tensor).


Re: [petsc-users] FEM Implementation of NS with SUPG Stabilization

2023-10-11 Thread Brandon Denton via petsc-users
I was thinking about trying to implement Ben Kirk's approach to Navier-Stokes 
(see attached paper; Section 5). His approach uses these quantities to align 
the orientation of the unstructured element/cell with the fluid velocity to 
apply the stabilization/upwinding and to detect shocks.

If you have an example of the approach you mentioned, could you please send it 
over so I can review it?

On Oct 11, 2023 6:02 AM, Matthew Knepley  wrote:
On Tue, Oct 10, 2023 at 9:34 PM Brandon Denton via petsc-users 
mailto:petsc-users@mcs.anl.gov>> wrote:
Good Evening,

I am looking to implement a form of Navier-Stokes with SUPG Stabilization and 
shock capturing using PETSc's FEM infrastructure. In this implementation, I 
need access to the cell's shape function gradients and natural coordinate 
gradients for calculations within the point-wise residual calculations. How do 
I get these quantities at the quadrature points? The signatures for fo and f1 
don't seem to contain this information.

Are you sure you need those? Darsh and I implemented SUPG without that. You 
would need local second derivative information, which you can get using 
-dm_ds_jet_degree 2. If you check in an example, I can go over it.

  Thanks,

 Matt

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/>


Re: [petsc-users] FEM Implementation of NS with SUPG Stabilization

2023-10-10 Thread Brandon Denton via petsc-users
My initial plan was to write a new code using only PETSc. However, I don't see 
how to do what I want within the point-wise residual function. Am I missing 
something?

Yes. I would be interested in collaborating on the ceed-fluids. I took a quick 
look at the links you provided and it looks interesting. I'll warn you though. 
I'm a Mechanical Engineer by trade/training. The calculus and programming 
sometimes take me a little while to wrap my head around. Let me know how I can 
help. In the meantime, I'll continue to review the information you sent over.

From: Jed Brown 
Sent: Tuesday, October 10, 2023 10:18 PM
To: Brandon Denton ; petsc-users@mcs.anl.gov 

Subject: Re: [petsc-users] FEM Implementation of NS with SUPG Stabilization

Do you want to write a new code using only PETSc or would you be up for 
collaborating on ceed-fluids, which is a high-performance compressible SUPG 
solver based on DMPlex with good GPU support? It uses the metric to compute 
covariant length for stabilization. We have YZƁ shock capturing, though it 
hasn't been tested much beyond shock tube experiments. (Most of our work has 
been low Mach.)

https://libceed.org/en/latest/examples/fluids/
https://github.com/CEED/libCEED/blob/main/examples/fluids/qfunctions/stabilization.h#L76


On Tue, Oct 10, 2023, at 7:34 PM, Brandon Denton via petsc-users wrote:
Good Evening,

I am looking to implement a form of Navier-Stokes with SUPG Stabilization and 
shock capturing using PETSc's FEM infrastructure. In this implementation, I 
need access to the cell's shape function gradients and natural coordinate 
gradients for calculations within the point-wise residual calculations. How do 
I get these quantities at the quadrature points? The signatures for fo and f1 
don't seem to contain this information.

Thank you in advance for your time.
Brandon



[petsc-users] FEM Implementation of NS with SUPG Stabilization

2023-10-10 Thread Brandon Denton via petsc-users
Good Evening,

I am looking to implement a form of Navier-Stokes with SUPG Stabilization and 
shock capturing using PETSc's FEM infrastructure. In this implementation, I 
need access to the cell's shape function gradients and natural coordinate 
gradients for calculations within the point-wise residual calculations. How do 
I get these quantities at the quadrature points? The signatures for fo and f1 
don't seem to contain this information.

Thank you in advance for your time.
Brandon


Re: [petsc-users] PETSc :: FEM Help

2023-08-04 Thread Brandon Denton via petsc-users
Good Morning Prof. Knepley,

Thank you for the update. I am now able to run the code. However, it does not 
appear to solve the problem correctly. The only results available are the 
initial conditions (temp = 100). In the problem, one face is set to 1400 and 
another face is set to 100. Since the faces are at opposite ends of the 
geometry, we would expect a roughly linear temperature profile from 1400 to 
100. What am I missing to get the output to show this proper result.

Thank you.
Brandon



From: Matthew Knepley 
Sent: Tuesday, August 1, 2023 10:23 AM
To: Brandon Denton 
Cc: petsc-users@mcs.anl.gov 
Subject: Re: [petsc-users] PETSc :: FEM Help

Sorry about this. I signed up for a conference without the work done, with 
predictable results. I have just returned home.

There were just a few small problems. First, the labels were attached to 
dmSurface, but you wanted them on dm. They got destroyed with dmSurface before 
setting the BC. Second, the declarations of the point function were missing the 
constant arguments. Third, the PetscFEDestroy() was missing and extra DM 
creations were there. I have fixed these and am attaching the new source. It 
runs for me but I have not checked the answer.

  Thanks,

 Matt

On Wed, Jun 7, 2023 at 11:05 AM Brandon Denton via petsc-users 
mailto:petsc-users@mcs.anl.gov>> wrote:
Good Morning,

I'm trying to verify that the CAD -> PETSc/DMPlex methods I've developed can be 
used for FEM analyses using PETSc. Attached is my current attempt where I 
import a CAD STEP file to create a volumetric tetrahedral discretization 
(DMPlex),  designate boundary condition points using DMLabels, and solve the 
Laplace problem (heat) with Dirichlet conditions on each end. At command line I 
indicate the STEP file with the -filename option and the dual space degree with 
-petscspace_degree 2. The run ends with either a SEGV Fault or a General MPI 
Communication Error.

Could you please look over the attached file to tell me if what I'm doing to 
set up the FEM problem is wrong?

Thank you in advance for your time and help.
-Brandon

TYPICAL ERROR MESSAGE
[0]PETSC ERROR: - Error Message 
--
[0]PETSC ERROR: General MPI error
[0]PETSC ERROR: MPI error 605109765 Invalid communicator, error stack:
PMPI_Comm_get_attr(344): MPI_Comm_get_attr(comm=0x0, 
comm_keyval=-1539309568, attribute_val=0x7ffe75a58848, flag=0x7ffe75a58844) 
failed
MPII_Comm_get_attr(257): MPIR_Comm_get_attr(comm=0x0, 
comm_keyval=-1539309568, attribute_val=0x7ffe75a58848, flag=0x7ffe75a58844) 
failed
MPII_Comm_get_attr(53).: Invalid communicator
[0]PETSC ERROR: WARNING! There are option(s) set that were not used! Could be 
the program crashed before they were used or a spelling mistake, etc!
[0]PETSC ERROR:   Option left: name:-dm_plex_refine_without_snap_to_geom value: 
0 source: command line
[0]PETSC ERROR:   Option left: name:-dm_refine value: 1 source: command line
[0]PETSC ERROR:   Option left: name:-snes_monitor (no value) source: command 
line
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Development GIT revision: v3.18.5-1817-gd2497b8de4c  GIT 
Date: 2023-05-22 18:44:03 +
[0]PETSC ERROR: ./thermal on a  named XPS. by bdenton Wed Jun  7 11:03:43 2023
[0]PETSC ERROR: Configure options --with-make-np=16 
--prefix=/mnt/c/Users/Brandon/software/libs/petsc/3.19.1-gitlab/gcc/11.2.0/mpich/3.4.2/openblas/0.3.17/opt
 --with-debugging=false --COPTFLAGS="-O3 -mavx" --CXXOPTFLAGS="-O3 -mavx" 
--FOPTFLAGS=-O3 --with-shared-libraries=1 
--with-mpi-dir=/mnt/c/Users/Brandon/software/libs/mpich/3.4.2/gcc/11.2.0 
--with-mumps=true --download-mumps=1 --with-metis=true --download-metis=1 
--with-parmetis=true --download-parmetis=1 --with-superlu=true 
--download-superlu=1 --with-superludir=true --download-superlu_dist=1 
--with-blacs=true --download-blacs=1 --with-scalapack=true 
--download-scalapack=1 --with-hypre=true --download-hypre=1 
--with-hdf5-dir=/mnt/c/Users/Brandon/software/libs/hdf5/1.12.1/gcc/11.2.0 
--with-valgrind-dir=/mnt/c/Users/Brandon/software/apps/valgrind/3.14.0 
--with-blas-lib="[/mnt/c/Users/Brandon/software/libs/openblas/0.3.17/gcc/11.2.0/lib/libopenblas.so]"
 
--with-lapack-lib="[/mnt/c/Users/Brandon/software/libs/openblas/0.3.17/gcc/11.2.0/lib/libopenblas.so]"
 --LDFLAGS= --with-tetgen=true --download-tetgen=1 --download-ctetgen=1 
--download-opencascade=1 --download-egads
[0]PETSC ERROR: #1 PetscObjectName() at 
/mnt/c/Users/Brandon/software/builddir/petsc-3.19.1-gitlab/src/sys/objects/pname.c:119
[0]PETSC ERROR: #2 PetscObjectGetName() at 
/mnt/c/Users/Brandon/software/builddir/petsc-3.19.1-gitlab/src/sys/objects/pgname.c:27
[0]PETSC ERROR: #3 PetscDSAddBoundary() at 
/mnt/c/Users/Brandon/software/builddir/petsc-3.19.1-gitlab/src/dm/dt/inter

[petsc-users] PETSc :: FEM Help

2023-06-07 Thread Brandon Denton via petsc-users
Good Morning,

I'm trying to verify that the CAD -> PETSc/DMPlex methods I've developed
can be used for FEM analyses using PETSc. Attached is my current attempt
where I import a CAD STEP file to create a volumetric tetrahedral
discretization (DMPlex),  designate boundary condition points using
DMLabels, and solve the Laplace problem (heat) with Dirichlet conditions on
each end. At command line I indicate the STEP file with the -filename
option and the dual space degree with -petscspace_degree 2. The run ends
with either a SEGV Fault or a General MPI Communication Error.

Could you please look over the attached file to tell me if what I'm doing
to set up the FEM problem is wrong?

Thank you in advance for your time and help.
-Brandon

TYPICAL ERROR MESSAGE
[0]PETSC ERROR: - Error Message
--
[0]PETSC ERROR: General MPI error
[0]PETSC ERROR: MPI error 605109765 Invalid communicator, error stack:
PMPI_Comm_get_attr(344): MPI_Comm_get_attr(comm=0x0,
comm_keyval=-1539309568, attribute_val=0x7ffe75a58848, flag=0x7ffe75a58844)
failed
MPII_Comm_get_attr(257): MPIR_Comm_get_attr(comm=0x0,
comm_keyval=-1539309568, attribute_val=0x7ffe75a58848, flag=0x7ffe75a58844)
failed
MPII_Comm_get_attr(53).: Invalid communicator
[0]PETSC ERROR: WARNING! There are option(s) set that were not used! Could
be the program crashed before they were used or a spelling mistake, etc!
[0]PETSC ERROR:   Option left: name:-dm_plex_refine_without_snap_to_geom
value: 0 source: command line
[0]PETSC ERROR:   Option left: name:-dm_refine value: 1 source: command line
[0]PETSC ERROR:   Option left: name:-snes_monitor (no value) source:
command line
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Development GIT revision: v3.18.5-1817-gd2497b8de4c
GIT Date: 2023-05-22 18:44:03 +
[0]PETSC ERROR: ./thermal on a  named XPS. by bdenton Wed Jun  7 11:03:43
2023
[0]PETSC ERROR: Configure options --with-make-np=16
--prefix=/mnt/c/Users/Brandon/software/libs/petsc/3.19.1-gitlab/gcc/11.2.0/mpich/3.4.2/openblas/0.3.17/opt
--with-debugging=false --COPTFLAGS="-O3 -mavx" --CXXOPTFLAGS="-O3 -mavx"
--FOPTFLAGS=-O3 --with-shared-libraries=1
--with-mpi-dir=/mnt/c/Users/Brandon/software/libs/mpich/3.4.2/gcc/11.2.0
--with-mumps=true --download-mumps=1 --with-metis=true --download-metis=1
--with-parmetis=true --download-parmetis=1 --with-superlu=true
--download-superlu=1 --with-superludir=true --download-superlu_dist=1
--with-blacs=true --download-blacs=1 --with-scalapack=true
--download-scalapack=1 --with-hypre=true --download-hypre=1
--with-hdf5-dir=/mnt/c/Users/Brandon/software/libs/hdf5/1.12.1/gcc/11.2.0
--with-valgrind-dir=/mnt/c/Users/Brandon/software/apps/valgrind/3.14.0
--with-blas-lib="[/mnt/c/Users/Brandon/software/libs/openblas/0.3.17/gcc/11.2.0/lib/libopenblas.so]"
--with-lapack-lib="[/mnt/c/Users/Brandon/software/libs/openblas/0.3.17/gcc/11.2.0/lib/libopenblas.so]"
--LDFLAGS= --with-tetgen=true --download-tetgen=1 --download-ctetgen=1
--download-opencascade=1 --download-egads
[0]PETSC ERROR: #1 PetscObjectName() at
/mnt/c/Users/Brandon/software/builddir/petsc-3.19.1-gitlab/src/sys/objects/pname.c:119
[0]PETSC ERROR: #2 PetscObjectGetName() at
/mnt/c/Users/Brandon/software/builddir/petsc-3.19.1-gitlab/src/sys/objects/pgname.c:27
[0]PETSC ERROR: #3 PetscDSAddBoundary() at
/mnt/c/Users/Brandon/software/builddir/petsc-3.19.1-gitlab/src/dm/dt/interface/dtds.c:3404
[0]PETSC ERROR: #4 DMAddBoundary() at
/mnt/c/Users/Brandon/software/builddir/petsc-3.19.1-gitlab/src/dm/interface/dm.c:7828
[0]PETSC ERROR: #5 main() at
/mnt/c/Users/Brandon/Documents/School/Dissertation/Software/EGADS-dev/thermal_v319/thermal_nozzle.c:173
[0]PETSC ERROR: PETSc Option Table entries:
[0]PETSC ERROR: -dm_plex_geom_print_model 1 (source: command line)
[0]PETSC ERROR: -dm_plex_geom_shape_opt 0 (source: command line)
[0]PETSC ERROR: -dm_plex_refine_without_snap_to_geom 0 (source: command
line)
[0]PETSC ERROR: -dm_refine 1 (source: command line)
[0]PETSC ERROR: -filename ./examples/Nozzle_example.stp (source: command
line)
[0]PETSC ERROR: -petscspace_degree 2 (source: command line)
[0]PETSC ERROR: -snes_monitor (source: command line)
[0]PETSC ERROR: End of Error Message ---send entire
error message to petsc-ma...@mcs.anl.gov--
application called MPI_Abort(MPI_COMM_SELF, 98) - process 0
[unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=98
:
system msg for write_line failure : Bad file descriptor
static const char help[] = "Test of FEA DMPlex w/CAD functionality";

#include 

/* User-defined Work Context  */
typedef struct {
PetscInt  dummy;
char filename[PETSC_MAX_PATH_LEN];// context containing CAD filename 
from command line
} AppCtx;


void f0_function(PetscInt dim, PetscInt Nf, PetscInt NfAux,
  const PetscInt uOff[], const PetscInt uOff_x[], const