Hi,

You can simply is VecISCopy.
Have  a look at the construction of isU and friends at ex26.c:291, and calls to VecISCopy around line 357.

Blaise


On Apr 17, 2023, at 6:54 PM, James Wright <jrwrigh....@gmail.com> wrote:

Thanks for the reply! The `Vec`s are created through DMs, not sections, but DMPlex uses sections, so I think this still applies. Super/Sub `DM`s sounds like a good solution. The only thing that I'm not seeing in the examples is being able to take `Vec` data from one a sub `DM`'s `Vec` to a super `DM`'s `Vec`.

To be a bit more explicit, let's say I have 3 fields, A, B, C. I'm imagining creating a "main" `DM` with those fields and then creating sub `DM`s, dmA, dmB, dmC. I need to have, in  a single `Vec` fields B and C, A and C together. So I'd create two super DMs dm_AC and dm_BC.

If I have a global `Vec` on dm_BC, is it possible that I can get the C data onto a dm_AC `Vec`? I think I could using SubVectors and VecISCopy, but am not entirely sure. There doesn't appear to be an example in the tutorials anywhere that puts these pieces together in this way.

Thanks,
James Wright
Graduate Research Assistant, PhD
University of Colorado Boulder
Cell: (864) 498 8869 
Website: jameswright.xyz


On Mon, Apr 17, 2023 at 12:42 PM Blaise Bourdin <bour...@mcmaster.ca> wrote:
Hi,

If you have created your vectors using sections, all you need is to call DMCreateSuperDM. See src/dm/impls/plex/tests/ex26.c:300 for an example.

Blaise

On Apr 17, 2023, at 1:30 PM, James Wright <jrwrigh....@gmail.com> wrote:

Hello,

I currently have two DMPlex objects, both `DMClone`ed from the same "original" DMPlex object. They have different fields with different numbers of components on each of them. I would like to compose certain components from each into a single contiguous array. I'd also like to do this from a DMGlobal vector. What is the best/most robust way to do that?

Obviously I can just `VecGetArrayRead` each of the vectors and loop through them manually, but that relies on knowledge of the array data layout. There's `DMPlexGetLocalOffsets`, but since I want to use the global Vec, there isn't a corresponding `DMPlexGetGlobalOffsets` (that I can see anyways). This manually looping would also require that the underlying arrangement of the DOFs is the same between the two DMPlex objects, but I assume this is true from the `DMClone` operation.

Thanks,
James Wright
Graduate Research Assistant, PhD
University of Colorado Boulder
Cell: (864) 498 8869 
Website: jameswright.xyz

— 
Canada Research Chair in Mathematical and Computational Aspects of Solid Mechanics (Tier 1)
Professor, Department of Mathematics & Statistics
Hamilton Hall room 409A, McMaster University
1280 Main Street West, Hamilton, Ontario L8S 4K1, Canada 
https://www.math.mcmaster.ca/bourdin | +1 (905) 525 9140 ext. 27243


— 
Canada Research Chair in Mathematical and Computational Aspects of Solid Mechanics (Tier 1)
Professor, Department of Mathematics & Statistics
Hamilton Hall room 409A, McMaster University
1280 Main Street West, Hamilton, Ontario L8S 4K1, Canada 
https://www.math.mcmaster.ca/bourdin | +1 (905) 525 9140 ext. 27243

Reply via email to