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

Barry Smith bsmith at petsc.dev
Wed Nov 8 14:20:54 CST 2023


   PETSc hashing is done by leveraging the great package khash. Take a look at include/petsc/private/hashtable.h and hashijkey.h for how we use kash to automatically generate the code for a particular key. Just make your tolerance smaller than the smallest diameters of your cells.


   Barry


> On Nov 8, 2023, at 2:47 PM, Jed Brown <jed at jedbrown.org> wrote:
> 
> I don't think you want to hash floating point values, but I've had a number of reasons to want spatial hashing for near-neighbor queries in PETSc and that would be a great contribution. (Spatial hashes have a length scale and compute integer bins.)
> 
> Brandon Denton via petsc-users <petsc-users at mcs.anl.gov> writes:
> 
>> 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



More information about the petsc-users mailing list