Actual source code: ex8.c
petsc-3.6.4 2016-04-12
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: DMDACreate1d(PETSC_COMM_SELF,DM_BOUNDARY_NONE,n1,1,1,NULL,&load->L2);
20: DMCompositeCreate(PETSC_COMM_SELF,&load->load);
21: return(0);
22: }
24: typedef struct {
25: DM network;
26: DM n1,n2;
27: } Network;
29: typedef struct {
30: DM generator;
31: DM g1,g2;
32: } Generator;
34: typedef struct {
35: DM city;
36: Load load;
37: Network network;
38: Generator generator;
39: } City;
41: typedef struct {
42: DM state;
43: City *cities;
44: PetscInt n;
45: } State;
47: typedef struct {
48: DM unitedstates;
49: State *states;
50: PetscInt n;
51: } UnitedStates;
55: int main(int argc,char **argv)
56: {
58: UnitedStates unitedstates;
60: PetscInitialize(&argc,&argv,(char*)0,help);
62: PetscFinalize();
63: return 0;
64: }