[petsc-users] DMNetwork - how to interprete the arguments of DMNetworkSetSizes ?
Zhang, Hong
hzhang at mcs.anl.gov
Thu Nov 7 13:53:55 CST 2019
Alex,
DMNetwork is under active development, thus our manual might not be updated. I'll check it.
I'm attaching a paper which might be used as a manual for the latest DMNetwork.
For your case, Nsubnet = 1, which is determined by application, not number of processes.
There are several examples using DMNetwork in petsc, e.g., under ~petsc,
$ git grep DMNetworkCreate *
...
src/ksp/ksp/examples/tutorials/network/ex1.c: ierr = DMNetworkCreate(PETSC_COMM_WORLD,&dmnetwork);CHKERRQ(ierr);
src/ksp/ksp/examples/tutorials/network/ex1_nest.c: ierr = DMNetworkCreate(PETSC_COMM_WORLD,&networkdm);CHKERRQ(ierr);
src/ksp/ksp/examples/tutorials/network/ex2.c: ierr = DMNetworkCreate(PETSC_COMM_WORLD,&networkdm);CHKERRQ(ierr);
src/snes/examples/tutorials/network/ex1.c: ierr = DMNetworkCreate(PETSC_COMM_WORLD,&networkdm);CHKERRQ(ierr);
src/snes/examples/tutorials/network/power/power.c: ierr = DMNetworkCreate(PETSC_COMM_WORLD,&networkdm);CHKERRQ(ierr);
src/snes/examples/tutorials/network/power/power2.c: ierr = DMNetworkCreate(PETSC_COMM_WORLD,&networkdm);CHKERRQ(ierr);
src/snes/examples/tutorials/network/water/water.c: ierr = DMNetworkCreate(PETSC_COMM_WORLD,&networkdm);CHKERRQ(ierr);
src/ts/examples/tutorials/network/wash/pipes1.c: ierr = DMNetworkCreate(PETSC_COMM_WORLD,&networkdm);CHKERRQ(ierr);
src/ts/examples/tutorials/power_grid/stability_9bus/ex9busdmnetwork.c: ierr = DMNetworkCreate(PETSC_COMM_WORLD,&networkdm);CHKERRQ(ierr);
Hong
On Thu, Nov 7, 2019 at 11:12 AM von Ramm, Alexander via petsc-users <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>> wrote:
Hello together,
I'm trying to figure out how to create a DMNetwork, but the proper way to set the parameters eludes me (also there is some discrepancy between the manual https://www.mcs.anl.gov/petsc/petsc-current/docs/manual.pdf (page 166) and the online documenation https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMNetwork/DMNetworkSetSizes.html ).
Currently I'm trying to set a up a simple Network with 8 nodes and 7 edges and distribute it over 2 processors. In the call DMNetworkSetSizes does Nsubnet need to be 1 (one global network, without any further subnetworks) or 2 (one subnetwork per processor) (my guess would be the former).
My current attempt looks like the following:
int main( int argc, char *argv[]) {
PetscInitialize(&argc, &argv, NULL, NULL);
DM dm;
PetscInt NSubnet = 1;
PetscInt nV[1] = {8};
PetscInt nE[1] = {7};
PetscInt NsubnetCouple = 0;
PetscInt nec[0];
DMNetworkCreate(PETSC_COMM_WORLD, &dm);
DMNetworkSetSizes(dm, NSubnet, nV, nE, NsubnetCouple, nec);
PetscInt *edgeList;
PetscMalloc1(14, &edgeList);
edgeList[0] = 0;
edgeList[1] = 4;
edgeList[2] = 1;
edgeList[3] = 4;
edgeList[4] = 2;
edgeList[5] = 5;
edgeList[6] = 3;
edgeList[7] = 5;
edgeList[8] = 4;
edgeList[9] = 6;
edgeList[10] = 5;
edgeList[11] = 6;
edgeList[12] = 6;
edgeList[13] = 7;
PetscInt *edges[1];
edges[0] = edgeList;
DMNetworkSetEdgeList(dm, edges, NULL);
DMNetworkLayoutSetUp(dm);
return 0;
}
Except from the Online Documenation I wasn't able to find any information/example where newest version Petsc was used when setting up a DMNetwork. (I found a few examples using older versions, however I could not figure out how these could solved using the newest version). If some could explain to me the the correct interpretation of the parameters of DMNetworkSetSizes ? Any pointers to examples using the newest API would also be much appreciated.
Thanks and best Regards,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20191107/3050221f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dmnetwork-2019.pdf
Type: application/pdf
Size: 1415801 bytes
Desc: dmnetwork-2019.pdf
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20191107/3050221f/attachment-0001.pdf>
More information about the petsc-users
mailing list