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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4492 - (show annotations)
Tue Jul 2 01:44:11 2013 UTC (5 years, 9 months ago) by caltinay
File size: 6335 byte(s)
Finley changes that were held back while in release mode - moved more stuff
into finley namespace.

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 /// returns a reference to the matrix pattern
28 Paso_SystemMatrixPattern* Finley_getPattern(Finley_Mesh *mesh, bool reduce_row_order, bool reduce_col_order)
29 {
30 Paso_SystemMatrixPattern *out=NULL;
31 Finley_resetError();
32 /* make sure that the requested pattern is available */
33 if (reduce_row_order) {
34 if (reduce_col_order) {
35 if (mesh->ReducedReducedPattern==NULL)
36 mesh->ReducedReducedPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
37 } else {
38 if (mesh->ReducedFullPattern==NULL)
39 mesh->ReducedFullPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
40 }
41 } else {
42 if (reduce_col_order) {
43 if (mesh->FullReducedPattern==NULL)
44 mesh->FullReducedPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
45 } else {
46 if (mesh->FullFullPattern==NULL)
47 mesh->FullFullPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
48 }
49 }
50 if (Finley_noError()) {
51 if (reduce_row_order) {
52 if (reduce_col_order) {
53 out=Paso_SystemMatrixPattern_getReference(mesh->ReducedReducedPattern);
54 } else {
55 out=Paso_SystemMatrixPattern_getReference(mesh->ReducedFullPattern);
56 }
57 } else {
58 if (reduce_col_order) {
59 out=Paso_SystemMatrixPattern_getReference(mesh->FullReducedPattern);
60 } else {
61 out=Paso_SystemMatrixPattern_getReference(mesh->FullFullPattern);
62 }
63 }
64 }
65 return out;
66 }
67
68 Paso_SystemMatrixPattern* Finley_makePattern(Finley_Mesh *mesh, bool reduce_row_order, bool reduce_col_order)
69 {
70 Paso_SystemMatrixPattern* out=NULL;
71 Paso_Pattern *main_pattern = NULL, *col_couple_pattern=NULL, *row_couple_pattern=NULL;
72 Paso_Connector *col_connector, *row_connector;
73 Paso_Distribution *colDistribution=NULL, *rowDistribution=NULL;
74
75 Finley_resetError();
76
77 int myNumColTargets, myNumRowTargets;
78 int numColTargets, numRowTargets;
79 const int *colTarget, *rowTarget;
80
81 if (reduce_col_order) {
82 myNumColTargets=mesh->Nodes->getNumReducedDegreesOfFreedom();
83 numColTargets=mesh->Nodes->reducedDegreesOfFreedomMapping.getNumTargets();
84 colTarget=mesh->Nodes->borrowTargetReducedDegreesOfFreedom();
85 colDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
86 col_connector=mesh->Nodes->reducedDegreesOfFreedomConnector;
87 } else {
88 myNumColTargets=mesh->Nodes->getNumDegreesOfFreedom();
89 numColTargets=mesh->Nodes->degreesOfFreedomMapping.getNumTargets();
90 colTarget=mesh->Nodes->borrowTargetDegreesOfFreedom();
91 colDistribution=mesh->Nodes->degreesOfFreedomDistribution;
92 col_connector=mesh->Nodes->degreesOfFreedomConnector;
93 }
94
95 if (reduce_row_order) {
96 myNumRowTargets=mesh->Nodes->getNumReducedDegreesOfFreedom();
97 numRowTargets=mesh->Nodes->reducedDegreesOfFreedomMapping.getNumTargets();
98 rowTarget=mesh->Nodes->borrowTargetReducedDegreesOfFreedom();
99 rowDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
100 row_connector=mesh->Nodes->reducedDegreesOfFreedomConnector;
101 } else {
102 myNumRowTargets=mesh->Nodes->getNumDegreesOfFreedom();
103 numRowTargets=mesh->Nodes->degreesOfFreedomMapping.getNumTargets();
104 rowTarget=mesh->Nodes->borrowTargetDegreesOfFreedom();
105 rowDistribution=mesh->Nodes->degreesOfFreedomDistribution;
106 row_connector=mesh->Nodes->degreesOfFreedomConnector;
107 }
108 IndexList* index_list=new IndexList[numRowTargets];
109
110 #pragma omp parallel
111 {
112 // insert contributions from element matrices into columns index index_list:
113 IndexList_insertElements(index_list, mesh->Elements, reduce_row_order,
114 rowTarget, reduce_col_order, colTarget);
115 IndexList_insertElements(index_list, mesh->FaceElements,
116 reduce_row_order, rowTarget, reduce_col_order,
117 colTarget);
118 IndexList_insertElements(index_list, mesh->ContactElements,
119 reduce_row_order, rowTarget, reduce_col_order,
120 colTarget);
121 IndexList_insertElements(index_list, mesh->Points, reduce_row_order,
122 rowTarget, reduce_col_order, colTarget);
123 }
124
125 /* create pattern */
126 main_pattern=IndexList_createPattern(0, myNumRowTargets, index_list, 0,
127 myNumColTargets, 0);
128 col_couple_pattern=IndexList_createPattern(0, myNumRowTargets, index_list,
129 myNumColTargets, numColTargets,
130 -myNumColTargets);
131 row_couple_pattern=IndexList_createPattern(myNumRowTargets, numRowTargets,
132 index_list, 0, myNumColTargets, 0);
133
134 /* if everything is in order we can create the return value */
135 if (Finley_noError()) {
136 out=Paso_SystemMatrixPattern_alloc(MATRIX_FORMAT_DEFAULT,
137 rowDistribution, colDistribution, main_pattern,
138 col_couple_pattern, row_couple_pattern,
139 col_connector, row_connector);
140 }
141 delete[] index_list;
142 Paso_Pattern_free(main_pattern);
143 Paso_Pattern_free(col_couple_pattern);
144 Paso_Pattern_free(row_couple_pattern);
145 Esys_MPIInfo_noError(mesh->MPIInfo);
146 return out;
147 }
148

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/lapack2681/finley/src/Mesh_getPattern.cpp:2682-2741 /branches/pasowrap/finley/src/Mesh_getPattern.cpp:3661-3674 /branches/py3_attempt2/finley/src/Mesh_getPattern.cpp:3871-3891 /branches/restext/finley/src/Mesh_getPattern.cpp:2610-2624 /branches/ripleygmg_from_3668/finley/src/Mesh_getPattern.cpp:3669-3791 /branches/stage3.0/finley/src/Mesh_getPattern.cpp:2569-2590 /branches/symbolic_from_3470/finley/src/Mesh_getPattern.cpp:3471-3974 /release/3.0/finley/src/Mesh_getPattern.cpp:2591-2601 /trunk/finley/src/Mesh_getPattern.cpp:4257-4344

  ViewVC Help
Powered by ViewVC 1.1.26