[petsc-users] DMNetwork - how to interprete the arguments of DMNetworkSetSizes ?

von Ramm, Alexander Alexander.vonRamm at lrz.de
Fri Nov 8 01:06:22 CST 2019


Hi Shri, Hi Hong,
thanks a lot for the information. This already helps a lot.
Best,
Alex
________________________________________
From: Abhyankar, Shrirang G <shrirang.abhyankar at pnnl.gov>
Sent: Thursday, November 7, 2019 9:47:17 PM
To: von Ramm, Alexander; petsc-users at mcs.anl.gov
Subject: Re: [petsc-users] DMNetwork - how to interprete the arguments of DMNetworkSetSizes ?

From: petsc-users <petsc-users-bounces at mcs.anl.gov> on behalf of "von Ramm, Alexander via petsc-users" <petsc-users at mcs.anl.gov>
Reply-To: "von Ramm, Alexander" <Alexander.vonRamm at lrz.de>
Date: Thursday, November 7, 2019 at 11:12 AM
To: "petsc-users at mcs.anl.gov" <petsc-users at mcs.anl.gov>
Subject: [petsc-users] DMNetwork - how to interprete the arguments of DMNetworkSetSizes ?

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

Thanks for pointing out the discrepancy. We’ll update the user manual.

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

Yes, Nsubnet = 1 for your application since you just have a single network, i.e., no subnetworks.

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

You do not need nec. You can simply set it to NULL.

        DMNetworkCreate(PETSC_COMM_WORLD, &dm);

        DMNetworkSetSizes(dm, NSubnet, nV, nE, NsubnetCouple, nec);

DMNetworkSetSizes(dm, NSubnet, nV, nE, NsubnetCouple, NULL);

        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.

Most of the examples with DMNetwork have a single network (Nsubnet = 1), except src/snes/examples/tutorials/network/ex1.c. This is a water + electric network simulation that has two subnetworks.

Shri

Thanks and best Regards,
Alex





More information about the petsc-users mailing list