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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6939 - (show annotations)
Mon Jan 20 03:37:18 2020 UTC (4 months, 1 week ago) by uqaeller
File size: 8032 byte(s)
Updated the copyright header.


1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2020 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
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-2017 by Centre for Geoscience Computing (GeoComp)
14 * Development from 2019 by School of Earth and Environmental Sciences
15 **
16 *****************************************************************************/
17
18 /****************************************************************************
19
20 Assemblage routines: prepares the assemble parameter set
21
22 *****************************************************************************/
23
24 #include "Assemble.h"
25
26 #ifdef ESYS_HAVE_PASO
27 #include <paso/SystemMatrix.h>
28 #endif
29
30 using escript::ValueError;
31
32 namespace finley {
33
34 AssembleParameters::AssembleParameters(const NodeFile* nodes,
35 const ElementFile* ef,
36 escript::ASM_ptr sm,
37 escript::Data& rhs,
38 bool reducedOrder) :
39 elements(ef),
40 S(sm),
41 F(rhs)
42 {
43 if (!rhs.isEmpty() && !rhs.actsExpanded()) {
44 throw ValueError("AssembleParameters: Right hand side is not expanded.");
45 }
46
47 #ifdef ESYS_HAVE_PASO
48 paso::SystemMatrix* pasoMat = sm ?
49 dynamic_cast<paso::SystemMatrix*>(sm.get()) : NULL;
50
51 // check the dimensions of matrix and rhs
52 if (pasoMat != NULL && !rhs.isEmpty()) {
53 const dim_t numRows = pasoMat->row_distribution->getMyNumComponents()*pasoMat->row_block_size;
54 if (!rhs.numSamplesEqual(1, numRows/pasoMat->logical_row_block_size)) {
55 throw ValueError("AssembleParameters: number of rows of matrix "
56 "and length of right hand side don't match.");
57 }
58 }
59 #endif
60
61 // get the number of equations and components
62 if (sm == NULL) {
63 if (rhs.isEmpty()) {
64 numEqu = numComp = 1;
65 } else {
66 numEqu = numComp = rhs.getDataPointSize();
67 }
68 } else {
69 if (!rhs.isEmpty() && rhs.getDataPointSize() != sm->getRowBlockSize()) {
70 throw ValueError("AssembleParameters: matrix row block size and "
71 "number of components of right hand side don't match.");
72 }
73 numEqu = sm->getRowBlockSize();
74 numComp = sm->getColumnBlockSize();
75 }
76 // set some defaults
77 row_DOF = nodes->borrowTargetDegreesOfFreedom();
78 row_DOF_UpperBound = nodes->getNumDegreesOfFreedom();
79 row_jac = ef->borrowJacobians(nodes, false, reducedOrder);
80 col_DOF = row_DOF;
81 col_DOF_UpperBound = row_DOF_UpperBound;
82 col_jac = row_jac;
83
84 #ifdef ESYS_HAVE_PASO
85 // get the information for the labeling of the degrees of freedom from
86 // the matrix
87 if (pasoMat) {
88 // Make sure # rows in matrix == num DOF for one of:
89 // full or reduced (use numLocalDOF for MPI)
90 const index_t numRows = pasoMat->row_distribution->getMyNumComponents()*pasoMat->row_block_size;
91 const index_t numCols = pasoMat->col_distribution->getMyNumComponents()*pasoMat->col_block_size;
92
93 if (numRows == numEqu * nodes->getNumDegreesOfFreedom()) {
94 } else if (numRows == numEqu * nodes->getNumReducedDegreesOfFreedom()) {
95 row_DOF_UpperBound = nodes->getNumReducedDegreesOfFreedom();
96 row_DOF = nodes->borrowTargetReducedDegreesOfFreedom();
97 row_jac = ef->borrowJacobians(nodes, true, reducedOrder);
98 } else {
99 throw ValueError("AssembleParameters: number of rows in matrix "
100 "does not match the number of degrees of freedom in mesh");
101 }
102 // Make sure # cols in matrix == num DOF for one of:
103 // full or reduced (use numLocalDOF for MPI)
104 if (numCols == this->numComp * nodes->getNumDegreesOfFreedom()) {
105 } else if (numCols == this->numComp * nodes->getNumReducedDegreesOfFreedom()) {
106 col_DOF_UpperBound = nodes->getNumReducedDegreesOfFreedom();
107 col_DOF = nodes->borrowTargetReducedDegreesOfFreedom();
108 col_jac = ef->borrowJacobians(nodes, true, reducedOrder);
109 } else {
110 throw ValueError("AssembleParameters: number of columns in matrix "
111 "does not match the number of degrees of freedom in mesh");
112 }
113 }
114 #endif
115
116 // get the information from right hand side
117 if (!rhs.isEmpty()) {
118 if (rhs.numSamplesEqual(1, nodes->getNumDegreesOfFreedom())) {
119 } else if (rhs.numSamplesEqual(1, nodes->getNumReducedDegreesOfFreedom())) {
120 row_DOF_UpperBound = nodes->getNumReducedDegreesOfFreedom();
121 row_DOF = nodes->borrowTargetReducedDegreesOfFreedom();
122 row_jac = ef->borrowJacobians(nodes, true, reducedOrder);
123 } else {
124 throw ValueError("AssembleParameters: length of RHS vector does not match the number of degrees of freedom in mesh");
125 }
126 #ifdef ESYS_HAVE_PASO
127 if (sm == NULL) {
128 col_DOF_UpperBound = this->row_DOF_UpperBound;
129 col_DOF = this->row_DOF;
130 col_jac = this->row_jac;
131 }
132 #else // trilinos case
133 col_DOF_UpperBound = this->row_DOF_UpperBound;
134 col_DOF = this->row_DOF;
135 col_jac = this->row_jac;
136 #endif
137 }
138
139 numSub = std::min(row_jac->numSub, col_jac->numSub);
140 numQuadSub = row_jac->numQuadTotal / numSub;
141 if (row_jac->numSides != col_jac->numSides) {
142 throw ValueError("AssembleParameters: number of sides for row and "
143 "column shape functions must match.");
144 }
145 if (row_jac->numDim != col_jac->numDim) {
146 throw ValueError("AssembleParameters: spatial dimension for row and "
147 "column shape function must match.");
148 }
149 if (ef->numNodes < row_jac->numShapesTotal) {
150 throw ValueError("AssembleParameters: too many nodes are expected by row.");
151 }
152 if (ef->numNodes < col_jac->numShapesTotal) {
153 throw ValueError("AssembleParameters: too many nodes are expected by col.");
154 }
155 if (row_jac->numElements != ef->numElements) {
156 throw ValueError("AssembleParameters: number of elements for row is wrong.");
157 }
158 if (col_jac->numElements != ef->numElements) {
159 throw ValueError("AssembleParameters: number of elements for column is wrong.");
160 }
161 if (row_jac->numQuadTotal != col_jac->numQuadTotal) {
162 throw ValueError("AssembleParameters: number of quadrature points for "
163 "row and column shape functions must match.");
164 }
165 // to consider different basis function for rows and columns this will
166 // require some work:
167 if (numQuadSub * numSub != row_jac->numQuadTotal) {
168 throw ValueError("AssembleParameters: number of quadrature points "
169 "for row is not correct.");
170 }
171 if (numQuadSub != row_jac->BasisFunctions->numQuadNodes) {
172 throw ValueError("AssembleParameters: Incorrect number of quadrature "
173 "points for row.");
174 }
175 if (numQuadSub != col_jac->BasisFunctions->numQuadNodes) {
176 throw ValueError("AssembleParameters: Incorrect number of quadrature "
177 "points for column.");
178 }
179
180 NN = elements->numNodes;
181 numQuadTotal = row_jac->numQuadTotal;
182 numElements = elements->numElements;
183 numDim = row_jac->numDim;
184 col_node = col_jac->node_selection;
185 row_node = row_jac->node_selection;
186 numSides = row_jac->numSides;
187 row_numShapesTotal = row_jac->numShapesTotal;
188 row_numShapes = row_jac->BasisFunctions->Type->numShapes;
189 col_numShapesTotal = col_jac->numShapesTotal;
190 col_numShapes = col_jac->BasisFunctions->Type->numShapes;
191 }
192
193 } // namespace finley
194

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26