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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1
2 /*******************************************************
3 *
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
14
15 /**************************************************************/
16
17 /* Paso: SystemMatrixPatternPattern */
18
19 /**************************************************************/
20
21 /* 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 Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_alloc(int type,
33 Paso_Distribution *output_distribution,
34 Paso_Distribution *input_distribution,
35 Paso_Pattern* mainPattern,
36 Paso_Pattern* col_couplePattern,
37 Paso_Pattern* row_couplePattern,
38 Paso_Connector* col_connector,
39 Paso_Connector* row_connector)
40 {
41 Paso_SystemMatrixPattern*out=NULL;
42 Paso_resetError();
43
44 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
57
58 if (mainPattern->type != type) {
59 Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: type of mainPattern does not match expected type.");
60 }
61 if (col_couplePattern->type != type) {
62 Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: type of col_couplePattern does not match expected type.");
63 }
64 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 Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: number of output for couple and main pattern don't match.");
69 }
70 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 Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: number of input for main pattern and number of send components in connector don't match.");
75 }
76 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 }
79 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 }
82 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 }
85 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
95 out=MEMALLOC(1,Paso_SystemMatrixPattern);
96 if (Paso_checkPtr(out)) return NULL;
97 out->type=type;
98 out->reference_counter=1;
99 out->mainPattern=Paso_Pattern_getReference(mainPattern);
100 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 out->output_distribution=Paso_Distribution_getReference(output_distribution);
105 out->input_distribution=Paso_Distribution_getReference(input_distribution);
106 out->mpi_info= Paso_MPIInfo_getReference(output_distribution->mpi_info);
107 #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 void Paso_SystemMatrixPattern_free(Paso_SystemMatrixPattern* in) {
125 if (in!=NULL) {
126 in->reference_counter--;
127 if (in->reference_counter<=0) {
128 Paso_Pattern_free(in->mainPattern);
129 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 Paso_Distribution_free(in->output_distribution);
134 Paso_Distribution_free(in->input_distribution);
135 Paso_MPIInfo_free(in->mpi_info);
136 MEMFREE(in);
137 #ifdef Paso_TRACE
138 printf("Paso_SystemMatrixPattern_free: system matrix pattern as been deallocated.\n");
139 #endif
140 }
141 }
142 }
143 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