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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2608 - (show annotations)
Tue Aug 18 01:25:18 2009 UTC (10 years, 2 months ago) by jfenwick
File MIME type: text/plain
File size: 5950 byte(s)
Updating Lutz' email

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 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: Lutz Gross, l.gross@uq.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
83 out=MEMALLOC(1,Paso_SystemMatrixPattern);
84 if (Paso_checkPtr(out)) return NULL;
85 out->type=type;
86 out->reference_counter=1;
87 out->mainPattern=Paso_Pattern_getReference(mainPattern);
88 out->row_couplePattern=Paso_Pattern_getReference(row_couplePattern);
89 out->col_couplePattern=Paso_Pattern_getReference(col_couplePattern);
90 out->row_connector=Paso_Connector_getReference(row_connector);
91 out->col_connector=Paso_Connector_getReference(col_connector);
92 out->output_distribution=Paso_Distribution_getReference(output_distribution);
93 out->input_distribution=Paso_Distribution_getReference(input_distribution);
94 out->mpi_info= Paso_MPIInfo_getReference(output_distribution->mpi_info);
95 #ifdef Paso_TRACE
96 printf("Paso_SystemMatrixPattern_dealloc: system matrix pattern as been allocated.\n");
97 #endif
98 return out;
99 }
100
101 /* returns a reference to in */
102
103 Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_getReference(Paso_SystemMatrixPattern* in) {
104 if (in!=NULL) {
105 ++(in->reference_counter);
106 }
107 return in;
108 }
109
110 /* deallocates a SystemMatrixPattern: */
111
112 void Paso_SystemMatrixPattern_free(Paso_SystemMatrixPattern* in) {
113 if (in!=NULL) {
114 in->reference_counter--;
115 if (in->reference_counter<=0) {
116 Paso_Pattern_free(in->mainPattern);
117 Paso_Pattern_free(in->row_couplePattern);
118 Paso_Pattern_free(in->col_couplePattern);
119 Paso_Connector_free(in->row_connector);
120 Paso_Connector_free(in->col_connector);
121 Paso_Distribution_free(in->output_distribution);
122 Paso_Distribution_free(in->input_distribution);
123 Paso_MPIInfo_free(in->mpi_info);
124 MEMFREE(in);
125 #ifdef Paso_TRACE
126 printf("Paso_SystemMatrixPattern_free: system matrix pattern as been deallocated.\n");
127 #endif
128 }
129 }
130 }
131 dim_t Paso_SystemMatrixPattern_getNumOutput(Paso_SystemMatrixPattern* in) {
132 if (in!=NULL) {
133 return 0;
134 } else {
135 return in->mainPattern->numOutput;
136 }
137 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26