/[escript]/trunk/finley/src/Mesh_getPattern.c
ViewVC logotype

Contents of /trunk/finley/src/Mesh_getPattern.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4286 - (show annotations)
Thu Mar 7 04:28:11 2013 UTC (6 years, 5 months ago) by caltinay
File MIME type: text/plain
File size: 6797 byte(s)
Assorted spelling fixes.

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 /* Finley: Mesh */
20
21 /************************************************************************************/
22
23 #include "Mesh.h"
24 #include "IndexList.h"
25
26 /************************************************************************************/
27
28 /* returns a reference to the matrix pattern */
29
30 Paso_SystemMatrixPattern* Finley_getPattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order) {
31 Paso_SystemMatrixPattern *out=NULL;
32 Finley_resetError();
33 /* make sure that the requested pattern is available */
34 if (reduce_row_order) {
35 if (reduce_col_order) {
36 if (mesh->ReducedReducedPattern==NULL) mesh->ReducedReducedPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
37 } else {
38 if (mesh->ReducedFullPattern==NULL) mesh->ReducedFullPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
39 }
40 } else {
41 if (reduce_col_order) {
42 if (mesh->FullReducedPattern==NULL) mesh->FullReducedPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
43 } else {
44 if (mesh->FullFullPattern==NULL) mesh->FullFullPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
45 }
46 }
47 if (Finley_noError()) {
48 if (reduce_row_order) {
49 if (reduce_col_order) {
50 out=Paso_SystemMatrixPattern_getReference(mesh->ReducedReducedPattern);
51 } else {
52 out=Paso_SystemMatrixPattern_getReference(mesh->ReducedFullPattern);
53 }
54 } else {
55 if (reduce_col_order) {
56 out=Paso_SystemMatrixPattern_getReference(mesh->FullReducedPattern);
57 } else {
58 out=Paso_SystemMatrixPattern_getReference(mesh->FullFullPattern);
59 }
60 }
61 }
62 return out;
63 }
64 Paso_SystemMatrixPattern* Finley_makePattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order) {
65 Paso_SystemMatrixPattern* out=NULL;
66 Paso_Pattern *main_pattern = NULL, *col_couple_pattern=NULL, *row_couple_pattern=NULL;
67 Paso_Connector *col_connector, *row_connector;
68 Finley_IndexList* index_list=NULL;
69 Finley_NodeMapping *colMap=NULL, *rowMap=NULL;
70 Paso_Distribution *colDistribution=NULL, *rowDistribution=NULL;
71
72 index_t i;
73 Finley_resetError();
74
75 if (reduce_col_order) {
76 colMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
77 colDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
78 col_connector=mesh->Nodes->reducedDegreesOfFreedomConnector;
79
80 } else {
81 colMap=mesh->Nodes->degreesOfFreedomMapping;
82 colDistribution=mesh->Nodes->degreesOfFreedomDistribution;
83 col_connector=mesh->Nodes->degreesOfFreedomConnector;
84 }
85
86 if (reduce_row_order) {
87 rowMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
88 rowDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
89 row_connector=mesh->Nodes->reducedDegreesOfFreedomConnector;
90 } else {
91 rowMap=mesh->Nodes->degreesOfFreedomMapping;
92 rowDistribution=mesh->Nodes->degreesOfFreedomDistribution;
93 row_connector=mesh->Nodes->degreesOfFreedomConnector;
94 }
95
96 index_list=TMPMEMALLOC(rowMap->numTargets,Finley_IndexList);
97 if (! Finley_checkPtr(index_list)) {
98
99 #pragma omp parallel private(i)
100 {
101 #pragma omp for schedule(static)
102 for(i=0;i<rowMap->numTargets;++i) {
103 index_list[i].extension=NULL;
104 index_list[i].n=0;
105 }
106 /* insert contributions from element matrices into columns index index_list: */
107 Finley_IndexList_insertElements(index_list,mesh->Elements,
108 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
109 Finley_IndexList_insertElements(index_list,mesh->FaceElements,
110 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
111 Finley_IndexList_insertElements(index_list,mesh->ContactElements,
112 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
113 Finley_IndexList_insertElements(index_list,mesh->Points,
114 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
115
116 }
117
118 /* create pattern */
119 main_pattern=Finley_IndexList_createPattern(0,Paso_Distribution_getMyNumComponents(rowDistribution),index_list,
120 0,Paso_Distribution_getMyNumComponents(colDistribution),
121 0);
122 col_couple_pattern=Finley_IndexList_createPattern(0,Paso_Distribution_getMyNumComponents(rowDistribution),index_list,
123 Paso_Distribution_getMyNumComponents(colDistribution),colMap->numTargets,
124 -Paso_Distribution_getMyNumComponents(colDistribution));
125 row_couple_pattern=Finley_IndexList_createPattern(Paso_Distribution_getMyNumComponents(rowDistribution),rowMap->numTargets,index_list,
126 0,Paso_Distribution_getMyNumComponents(colDistribution),
127 0);
128
129 /* if everything is in order we can create the return value */
130 if (Finley_noError()) {
131 out=Paso_SystemMatrixPattern_alloc(MATRIX_FORMAT_DEFAULT,
132 rowDistribution,
133 colDistribution,
134 main_pattern,
135 col_couple_pattern,
136 row_couple_pattern,
137 col_connector,
138 row_connector);
139 }
140 /* clean up */
141 if (index_list!=NULL) {
142 #pragma omp parallel for private(i)
143 for(i=0;i<rowMap->numTargets;++i) Finley_IndexList_free(index_list[i].extension);
144 }
145 TMPMEMFREE(index_list);
146 Paso_Pattern_free(main_pattern);
147 Paso_Pattern_free(col_couple_pattern);
148 Paso_Pattern_free(row_couple_pattern);
149 }
150 Esys_MPIInfo_noError(mesh->MPIInfo);
151 return out;
152 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26