/[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 4803 - (show annotations)
Wed Mar 26 06:52:28 2014 UTC (5 years, 9 months ago) by caltinay
File size: 6118 byte(s)
Removed obsolete wrappers for malloc and friends.
Paso_Pattern -> paso::Pattern

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 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 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17
18 /****************************************************************************
19
20 Finley: Mesh
21
22 *****************************************************************************/
23
24 #include "Mesh.h"
25 #include "IndexList.h"
26
27 namespace finley {
28
29 /// returns a reference to the matrix pattern
30 paso::SystemMatrixPattern* Mesh::getPattern(bool reduce_row_order, bool reduce_col_order)
31 {
32 paso::SystemMatrixPattern *out=NULL;
33 resetError();
34 /* make sure that the requested pattern is available */
35 if (reduce_row_order) {
36 if (reduce_col_order) {
37 if (ReducedReducedPattern==NULL)
38 ReducedReducedPattern=makePattern(reduce_row_order,reduce_col_order);
39 } else {
40 if (ReducedFullPattern==NULL)
41 ReducedFullPattern=makePattern(reduce_row_order,reduce_col_order);
42 }
43 } else {
44 if (reduce_col_order) {
45 if (FullReducedPattern==NULL)
46 FullReducedPattern=makePattern(reduce_row_order,reduce_col_order);
47 } else {
48 if (FullFullPattern==NULL)
49 FullFullPattern=makePattern(reduce_row_order,reduce_col_order);
50 }
51 }
52 if (noError()) {
53 if (reduce_row_order) {
54 if (reduce_col_order) {
55 out=paso::SystemMatrixPattern_getReference(ReducedReducedPattern);
56 } else {
57 out=paso::SystemMatrixPattern_getReference(ReducedFullPattern);
58 }
59 } else {
60 if (reduce_col_order) {
61 out=paso::SystemMatrixPattern_getReference(FullReducedPattern);
62 } else {
63 out=paso::SystemMatrixPattern_getReference(FullFullPattern);
64 }
65 }
66 }
67 return out;
68 }
69
70 paso::SystemMatrixPattern* Mesh::makePattern(bool reduce_row_order, bool reduce_col_order)
71 {
72 paso::SystemMatrixPattern* out=NULL;
73 paso::Pattern *main_pattern = NULL, *col_couple_pattern=NULL, *row_couple_pattern=NULL;
74 paso::Connector *col_connector, *row_connector;
75 Paso_Distribution *colDistribution=NULL, *rowDistribution=NULL;
76
77 resetError();
78
79 int myNumColTargets, myNumRowTargets;
80 int numColTargets, numRowTargets;
81 const int *colTarget, *rowTarget;
82
83 if (reduce_col_order) {
84 myNumColTargets=Nodes->getNumReducedDegreesOfFreedom();
85 numColTargets=Nodes->reducedDegreesOfFreedomMapping.getNumTargets();
86 colTarget=Nodes->borrowTargetReducedDegreesOfFreedom();
87 colDistribution=Nodes->reducedDegreesOfFreedomDistribution;
88 col_connector=Nodes->reducedDegreesOfFreedomConnector;
89 } else {
90 myNumColTargets=Nodes->getNumDegreesOfFreedom();
91 numColTargets=Nodes->degreesOfFreedomMapping.getNumTargets();
92 colTarget=Nodes->borrowTargetDegreesOfFreedom();
93 colDistribution=Nodes->degreesOfFreedomDistribution;
94 col_connector=Nodes->degreesOfFreedomConnector;
95 }
96
97 if (reduce_row_order) {
98 myNumRowTargets=Nodes->getNumReducedDegreesOfFreedom();
99 numRowTargets=Nodes->reducedDegreesOfFreedomMapping.getNumTargets();
100 rowTarget=Nodes->borrowTargetReducedDegreesOfFreedom();
101 rowDistribution=Nodes->reducedDegreesOfFreedomDistribution;
102 row_connector=Nodes->reducedDegreesOfFreedomConnector;
103 } else {
104 myNumRowTargets=Nodes->getNumDegreesOfFreedom();
105 numRowTargets=Nodes->degreesOfFreedomMapping.getNumTargets();
106 rowTarget=Nodes->borrowTargetDegreesOfFreedom();
107 rowDistribution=Nodes->degreesOfFreedomDistribution;
108 row_connector=Nodes->degreesOfFreedomConnector;
109 }
110 IndexList* index_list=new IndexList[numRowTargets];
111
112 #pragma omp parallel
113 {
114 // insert contributions from element matrices into columns index index_list:
115 IndexList_insertElements(index_list, Elements, reduce_row_order,
116 rowTarget, reduce_col_order, colTarget);
117 IndexList_insertElements(index_list, FaceElements,
118 reduce_row_order, rowTarget, reduce_col_order,
119 colTarget);
120 IndexList_insertElements(index_list, ContactElements,
121 reduce_row_order, rowTarget, reduce_col_order,
122 colTarget);
123 IndexList_insertElements(index_list, Points, reduce_row_order,
124 rowTarget, reduce_col_order, colTarget);
125 }
126
127 /* create pattern */
128 main_pattern=IndexList_createPattern(0, myNumRowTargets, index_list, 0,
129 myNumColTargets, 0);
130 col_couple_pattern=IndexList_createPattern(0, myNumRowTargets, index_list,
131 myNumColTargets, numColTargets,
132 -myNumColTargets);
133 row_couple_pattern=IndexList_createPattern(myNumRowTargets, numRowTargets,
134 index_list, 0, myNumColTargets, 0);
135
136 // if everything is in order we can create the return value
137 if (noError()) {
138 out = new paso::SystemMatrixPattern(MATRIX_FORMAT_DEFAULT,
139 rowDistribution, colDistribution, main_pattern,
140 col_couple_pattern, row_couple_pattern,
141 col_connector, row_connector);
142 }
143 delete[] index_list;
144 paso::Pattern_free(main_pattern);
145 paso::Pattern_free(col_couple_pattern);
146 paso::Pattern_free(row_couple_pattern);
147 Esys_MPIInfo_noError(MPIInfo);
148 return out;
149 }
150
151 } // namespace finley
152

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