openPMD / openPMD/openPMD-api

Writing 2D electric field using mesh and 2D array

Open
#1,321 2 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
C++
Stars
161
Forks
59
Avg merge
2d 22h
Merged PRs (30d)
7

Description

I would like to use the mesh component to store a 2D array containing let say the 2D `x` component electric field `E_x`

I tried something like

```
// Experimental remap in 2D
double ex_2d[field_x.l_sx][field_x.l_sy];

for (int i=0;i();
Extent global_extent = {field_x.l_sx * mpi_size, field_x.l_sy};
Dataset dataset = Dataset(datatype, global_extent);
if (0 == mpi_rank)
cout << "Prepared a Field Dataset of size " << dataset.extent[0] << "x"
<< dataset.extent[1] << " and Datatype " << dataset.dtype
<< '\n';

ex_mesh.resetDataset(dataset);

// example shows a 1D domain decomposition in first index
Offset chunk_offset = {field_x.l_dx, field_x.l_dy};
Extent chunk_extent = {field_x.l_sx, field_x.l_sy};
ex_mesh.storeChunk(shareRaw(ex_2d), chunk_offset, chunk_extent);
```
But it won't compile giving an error:
```
error: no matching function for call to 'shareRaw(double [field_x.field::l_sx][field_x.field::l_sy])'
ex_mesh.storeChunk(shareRaw(ex_2d), chunk_offset, chunk_extent);
```
How can i store a 2D array using the mesh record component? Do you have any example ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.