Actual source code: ex8.c

petsc-3.8.4 2018-03-24
Report Typos and Errors

  2: static char help[] = "Tests imbedding DMComposites inside DMComposites.\n\n";

  4:  #include <petscdm.h>
  5:  #include <petscdmda.h>
  6:  #include <petscdmcomposite.h>

  8: typedef struct {
  9:   DM load;
 10:   DM L1,L2;
 11: } Load;

 13: PetscErrorCode LoadCreate(PetscInt n1, PetscInt n2, Load *load)
 14: {

 17:   PetscNew(&load);
 18:   DMDACreate1d(PETSC_COMM_SELF,DM_BOUNDARY_NONE,n1,1,1,NULL,&load->L1);
 19:   DMSetFromOptions(load->L1);
 20:   DMSetUp(load->L1);
 21:   DMDACreate1d(PETSC_COMM_SELF,DM_BOUNDARY_NONE,n1,1,1,NULL,&load->L2);
 22:   DMSetFromOptions(load->L2);
 23:   DMSetUp(load->L2);
 24:   DMCompositeCreate(PETSC_COMM_SELF,&load->load);
 25:   return(0);
 26: }

 28: typedef struct {
 29:   DM network;
 30:   DM n1,n2;
 31: } Network;

 33: typedef struct {
 34:   DM generator;
 35:   DM g1,g2;
 36: } Generator;

 38: typedef struct {
 39:   DM        city;
 40:   Load      load;
 41:   Network   network;
 42:   Generator generator;
 43: } City;

 45: typedef struct {
 46:   DM       state;
 47:   City     *cities;
 48:   PetscInt n;
 49: } State;

 51: typedef struct {
 52:   DM       unitedstates;
 53:   State    *states;
 54:   PetscInt n;
 55: } UnitedStates;

 57: int main(int argc,char **argv)
 58: {
 60:   UnitedStates   unitedstates;

 62:   PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
 63:   PetscFinalize();
 64:   return ierr;
 65: }