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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1552 - (hide annotations)
Thu May 8 08:52:41 2008 UTC (11 years, 7 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 ksteube 1312
2 jgs 150 /* $Id$ */
3    
4 ksteube 1312 /*******************************************************
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 dhawcroft 631
16 jgs 150 /**************************************************************/
17    
18     /* Paso: SystemMatrixPatternPattern */
19    
20     /**************************************************************/
21 ksteube 1312
22     /* Copyrights by ACcESS Australia 2003, 2004,2005, 2006, 2007 */
23 jgs 150 /* 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 ksteube 1312 Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_alloc(int type,
35     Paso_Distribution *output_distribution,
36     Paso_Distribution *input_distribution,
37     Paso_Pattern* mainPattern,
38 gross 1552 Paso_Pattern* col_couplePattern,
39     Paso_Pattern* row_couplePattern,
40     Paso_Connector* col_connector,
41     Paso_Connector* row_connector)
42 ksteube 1312 {
43     Paso_SystemMatrixPattern*out=NULL;
44 gross 1552 Paso_resetError();
45 ksteube 1312
46 gross 1552 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 ksteube 1312
59 jgs 150
60 ksteube 1312 if (mainPattern->type != type) {
61     Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: type of mainPattern does not match expected type.");
62 gross 415 }
63 gross 1552 if (col_couplePattern->type != type) {
64     Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: type of col_couplePattern does not match expected type.");
65 jgs 150 }
66 gross 1552 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 ksteube 1312 Paso_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: number of output for couple and main pattern don't match.");
71 jgs 150 }
72 ksteube 1312 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 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.");
77 ksteube 1312 }
78 gross 1552 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 ksteube 1312 }
81 gross 1552 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 ksteube 1312 }
84 gross 1552 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 ksteube 1312 }
87 gross 1552 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 jgs 150
97     out=MEMALLOC(1,Paso_SystemMatrixPattern);
98     if (Paso_checkPtr(out)) return NULL;
99 ksteube 1312 out->type=type;
100 jgs 150 out->reference_counter=1;
101 ksteube 1312 out->mainPattern=Paso_Pattern_getReference(mainPattern);
102 gross 1552 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 ksteube 1312 out->output_distribution=Paso_Distribution_getReference(output_distribution);
107     out->input_distribution=Paso_Distribution_getReference(input_distribution);
108 gross 1552 out->mpi_info= Paso_MPIInfo_getReference(output_distribution->mpi_info);
109 jgs 150 #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 ksteube 1312 void Paso_SystemMatrixPattern_free(Paso_SystemMatrixPattern* in) {
127 jgs 150 if (in!=NULL) {
128     in->reference_counter--;
129     if (in->reference_counter<=0) {
130 ksteube 1312 Paso_Pattern_free(in->mainPattern);
131 gross 1552 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 ksteube 1312 Paso_Distribution_free(in->output_distribution);
136     Paso_Distribution_free(in->input_distribution);
137     Paso_MPIInfo_free(in->mpi_info);
138 jgs 150 MEMFREE(in);
139     #ifdef Paso_TRACE
140 ksteube 1312 printf("Paso_SystemMatrixPattern_free: system matrix pattern as been deallocated.\n");
141 jgs 150 #endif
142     }
143     }
144     }
145 gross 1361 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