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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26