/[escript]/trunk/paso/src/SystemMatrixPattern.c
ViewVC logotype

Annotation of /trunk/paso/src/SystemMatrixPattern.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (hide annotations)
Thu Sep 25 23:11:13 2008 UTC (11 years, 4 months ago) by ksteube
File MIME type: text/plain
File size: 6797 byte(s)
Copyright updated in all files

1 ksteube 1312
2     /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 by University of Queensland
5     * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13 dhawcroft 631
14 ksteube 1811
15 jgs 150 /**************************************************************/
16    
17     /* Paso: SystemMatrixPatternPattern */
18    
19     /**************************************************************/
20 ksteube 1312
21 jgs 150 /* Author: gross@access.edu.au */
22    
23     /**************************************************************/
24    
25     #include "Paso.h"
26     #include "SystemMatrixPattern.h"
27    
28     /**************************************************************/
29    
30     /* allocates a SystemMatrixPattern */
31    
32 ksteube 1312 Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_alloc(int type,
33     Paso_Distribution *output_distribution,
34     Paso_Distribution *input_distribution,
35     Paso_Pattern* mainPattern,
36 gross 1552 Paso_Pattern* col_couplePattern,
37     Paso_Pattern* row_couplePattern,
38     Paso_Connector* col_connector,
39     Paso_Connector* row_connector)
40 ksteube 1312 {
41     Paso_SystemMatrixPattern*out=NULL;
42 gross 1552 Paso_resetError();
43 ksteube 1312
44 gross 1552 if (output_distribution->mpi_info != input_distribution->mpi_info ) {
45     Paso_setError(SYSTEM_ERROR,"Paso_SystemMatrixPattern_alloc: output_distribution and input_distribution mpi communicator don't match.");
46     return NULL;
47     }
48     if (output_distribution->mpi_info != col_connector->mpi_info ) {
49     Paso_setError(SYSTEM_ERROR,"Paso_SystemMatrixPattern_alloc: output_distribution and col_connector mpi communicator don't match.");
50     return NULL;
51     }
52     if (output_distribution->mpi_info != row_connector->mpi_info ) {
53     Paso_setError(SYSTEM_ERROR,"Paso_SystemMatrixPattern_alloc: output_distribution and row_connector mpi communicator don't match.");
54     return NULL;
55     }
56 ksteube 1312
57 jgs 150
58 ksteube 1312 if (mainPattern->type != type) {
59     Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: type of mainPattern does not match expected type.");
60 gross 415 }
61 gross 1552 if (col_couplePattern->type != type) {
62     Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: type of col_couplePattern does not match expected type.");
63 jgs 150 }
64 gross 1552 if (row_couplePattern->type != type) {
65     Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: type of row_couplePattern does not match expected type.");
66     }
67     if (col_couplePattern->numOutput != mainPattern->numOutput) {
68 ksteube 1312 Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: number of output for couple and main pattern don't match.");
69 jgs 150 }
70 ksteube 1312 if (mainPattern->numOutput != Paso_Distribution_getMyNumComponents(output_distribution)) {
71     Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: number of output and given distribution don't match.");
72     }
73     if (mainPattern->numInput != Paso_Distribution_getMyNumComponents(input_distribution)) {
74 gross 1552 Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: number of input for main pattern and number of send components in connector don't match.");
75 ksteube 1312 }
76 gross 1552 if (col_couplePattern->numInput != col_connector->recv->numSharedComponents) {
77     Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: number of inputs for column couple pattern and number of received components in connector don't match.");
78 ksteube 1312 }
79 gross 1552 if (row_couplePattern->numOutput != row_connector->recv->numSharedComponents) {
80     Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: number of inputs for row couple pattern and number of received components in connector don't match.");
81 ksteube 1312 }
82 gross 1552 if (mainPattern->output_block_size != col_couplePattern->output_block_size) {
83     Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: output block sizes of main and column couple pattern do not match.");
84 ksteube 1312 }
85 gross 1552 if (mainPattern->input_block_size != col_couplePattern->input_block_size) {
86     Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: input block sizes of main and column couple pattern do not match.");
87     }
88     if (mainPattern->output_block_size != row_couplePattern->output_block_size) {
89     Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: output block sizes of main and row couple pattern do not match.");
90     }
91     if (mainPattern->input_block_size != col_couplePattern->input_block_size) {
92     Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: input block sizes of main and row couple pattern do not match.");
93     }
94 jgs 150
95     out=MEMALLOC(1,Paso_SystemMatrixPattern);
96     if (Paso_checkPtr(out)) return NULL;
97 ksteube 1312 out->type=type;
98 jgs 150 out->reference_counter=1;
99 ksteube 1312 out->mainPattern=Paso_Pattern_getReference(mainPattern);
100 gross 1552 out->row_couplePattern=Paso_Pattern_getReference(row_couplePattern);
101     out->col_couplePattern=Paso_Pattern_getReference(col_couplePattern);
102     out->row_connector=Paso_Connector_getReference(row_connector);
103     out->col_connector=Paso_Connector_getReference(col_connector);
104 ksteube 1312 out->output_distribution=Paso_Distribution_getReference(output_distribution);
105     out->input_distribution=Paso_Distribution_getReference(input_distribution);
106 gross 1552 out->mpi_info= Paso_MPIInfo_getReference(output_distribution->mpi_info);
107 jgs 150 #ifdef Paso_TRACE
108     printf("Paso_SystemMatrixPattern_dealloc: system matrix pattern as been allocated.\n");
109     #endif
110     return out;
111     }
112    
113     /* returns a reference to in */
114    
115     Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_reference(Paso_SystemMatrixPattern* in) {
116     if (in!=NULL) {
117     ++(in->reference_counter);
118     }
119     return in;
120     }
121    
122     /* deallocates a SystemMatrixPattern: */
123    
124 ksteube 1312 void Paso_SystemMatrixPattern_free(Paso_SystemMatrixPattern* in) {
125 jgs 150 if (in!=NULL) {
126     in->reference_counter--;
127     if (in->reference_counter<=0) {
128 ksteube 1312 Paso_Pattern_free(in->mainPattern);
129 gross 1552 Paso_Pattern_free(in->row_couplePattern);
130     Paso_Pattern_free(in->col_couplePattern);
131     Paso_Connector_free(in->row_connector);
132     Paso_Connector_free(in->col_connector);
133 ksteube 1312 Paso_Distribution_free(in->output_distribution);
134     Paso_Distribution_free(in->input_distribution);
135     Paso_MPIInfo_free(in->mpi_info);
136 jgs 150 MEMFREE(in);
137     #ifdef Paso_TRACE
138 ksteube 1312 printf("Paso_SystemMatrixPattern_free: system matrix pattern as been deallocated.\n");
139 jgs 150 #endif
140     }
141     }
142     }
143 gross 1361 dim_t Paso_SystemMatrixPattern_getNumOutput(Paso_SystemMatrixPattern* in) {
144     if (in!=NULL) {
145     return 0;
146     } else {
147     return in->mainPattern->numOutput;
148     }
149     }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26