/[escript]/branches/doubleplusgood/paso/src/SystemMatrixPattern.cpp
ViewVC logotype

Contents of /branches/doubleplusgood/paso/src/SystemMatrixPattern.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4275 - (show annotations)
Tue Mar 5 09:32:52 2013 UTC (6 years, 1 month ago) by jfenwick
File size: 6146 byte(s)
some experiments
1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16
17 /************************************************************************************/
18
19 /* Paso: SystemMatrixPattern */
20
21 /************************************************************************************/
22
23 /* Author: Lutz Gross, l.gross@uq.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 Esys_resetError();
45
46 if (output_distribution->mpi_info != input_distribution->mpi_info ) {
47 Esys_setError(SYSTEM_ERROR,"Paso_SystemMatrixPattern_alloc: output_distribution and input_distribution MPI communicators don't match.");
48 return NULL;
49 }
50 if (output_distribution->mpi_info != col_connector->mpi_info ) {
51 Esys_setError(SYSTEM_ERROR,"Paso_SystemMatrixPattern_alloc: output_distribution and col_connector MPI communicators don't match.");
52 return NULL;
53 }
54 if (output_distribution->mpi_info != row_connector->mpi_info ) {
55 Esys_setError(SYSTEM_ERROR,"Paso_SystemMatrixPattern_alloc: output_distribution and row_connector MPI communicators don't match.");
56 return NULL;
57 }
58
59
60 if (mainPattern->type != type) {
61 Esys_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: type of mainPattern does not match expected type.");
62 }
63 if (col_couplePattern->type != type) {
64 Esys_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: type of col_couplePattern does not match expected type.");
65 }
66 if (row_couplePattern->type != type) {
67 Esys_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: type of row_couplePattern does not match expected type.");
68 }
69 if (col_couplePattern->numOutput != mainPattern->numOutput) {
70 Esys_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: number of outputs for couple and main pattern don't match.");
71 }
72 if (mainPattern->numOutput != Paso_Distribution_getMyNumComponents(output_distribution)) {
73 Esys_setError(VALUE_ERROR,"Paso_SystemMatrixPattern_alloc: number of outputs and given distribution don't match.");
74 }
75 if (mainPattern->numInput != Paso_Distribution_getMyNumComponents(input_distribution)) {
76 Esys_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 Esys_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 Esys_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
85 out=new Paso_SystemMatrixPattern;
86 if (Esys_checkPtr(out)) return NULL;
87 out->type=type;
88 out->reference_counter=1;
89 out->mainPattern=Paso_Pattern_getReference(mainPattern);
90 out->row_couplePattern=Paso_Pattern_getReference(row_couplePattern);
91 out->col_couplePattern=Paso_Pattern_getReference(col_couplePattern);
92 out->row_connector=Paso_Connector_getReference(row_connector);
93 out->col_connector=Paso_Connector_getReference(col_connector);
94 out->output_distribution=Paso_Distribution_getReference(output_distribution);
95 out->input_distribution=Paso_Distribution_getReference(input_distribution);
96 out->mpi_info= Esys_MPIInfo_getReference(output_distribution->mpi_info);
97 #ifdef Paso_TRACE
98 printf("Paso_SystemMatrixPattern_alloc: system matrix pattern has been allocated.\n");
99 #endif
100 return out;
101 }
102
103 /* returns a reference to in */
104
105 Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_getReference(Paso_SystemMatrixPattern* in) {
106 if (in!=NULL) {
107 ++(in->reference_counter);
108 }
109 return in;
110 }
111
112 /* deallocates a SystemMatrixPattern: */
113
114 void Paso_SystemMatrixPattern_free(Paso_SystemMatrixPattern* in) {
115 if (in!=NULL) {
116 in->reference_counter--;
117 if (in->reference_counter<=0) {
118 Paso_Pattern_free(in->mainPattern);
119 Paso_Pattern_free(in->row_couplePattern);
120 Paso_Pattern_free(in->col_couplePattern);
121 Paso_Connector_free(in->row_connector);
122 Paso_Connector_free(in->col_connector);
123 Paso_Distribution_free(in->output_distribution);
124 Paso_Distribution_free(in->input_distribution);
125 Esys_MPIInfo_free(in->mpi_info);
126 delete in;
127 #ifdef Paso_TRACE
128 printf("Paso_SystemMatrixPattern_free: system matrix pattern has been deallocated.\n");
129 #endif
130 }
131 }
132 }
133 dim_t Paso_SystemMatrixPattern_getNumOutput(Paso_SystemMatrixPattern* in) {
134 if (in!=NULL) {
135 return 0;
136 } else {
137 return in->mainPattern->numOutput;
138 }
139 }
140

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26