/[escript]/branches/trilinos_from_5897/dudley/src/Assemble_CopyNodalData.cpp
ViewVC logotype

Contents of /branches/trilinos_from_5897/dudley/src/Assemble_CopyNodalData.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6079 - (show annotations)
Mon Mar 21 12:22:38 2016 UTC (2 years, 11 months ago) by caltinay
File size: 5286 byte(s)
Big commit - making dudley much more like finley to make it more
managable. Fixed quite a few issues that had been fixed in finley.
Disposed of all ReducedNode/ReducedDOF entities that dudley never supported.
Compiles and passes tests.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The 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 #include "Assemble.h"
18 #include "Util.h"
19
20 namespace dudley {
21
22 void Assemble_CopyNodalData(const NodeFile* nodes, escript::Data& out,
23 const escript::Data& in)
24 {
25 if (!nodes)
26 return;
27
28 const int mpiSize = nodes->MPIInfo->size;
29 const int numComps = out.getDataPointSize();
30 const int in_data_type = in.getFunctionSpace().getTypeCode();
31 const int out_data_type = out.getFunctionSpace().getTypeCode();
32
33 // check out and in
34 if (numComps != in.getDataPointSize()) {
35 throw DudleyException("Assemble_CopyNodalData: number of components of input and output Data do not match.");
36 } else if (!out.actsExpanded()) {
37 throw DudleyException("Assemble_CopyNodalData: expanded Data object is expected for output data.");
38 }
39
40 // more sophisticated test needed for overlapping node/DOF counts
41 if (in_data_type == DUDLEY_NODES) {
42 if (!in.numSamplesEqual(1, nodes->getNumNodes())) {
43 throw DudleyException("Assemble_CopyNodalData: illegal number of samples of input Data object");
44 }
45 } else if (in_data_type == DUDLEY_DEGREES_OF_FREEDOM) {
46 if (!in.numSamplesEqual(1, nodes->getNumDegreesOfFreedom())) {
47 throw DudleyException("Assemble_CopyNodalData: illegal number of samples of input Data object");
48 }
49 if ((((out_data_type == DUDLEY_NODES) || (out_data_type == DUDLEY_DEGREES_OF_FREEDOM)) && !in.actsExpanded() && (mpiSize > 1))) {
50
51 throw DudleyException("Assemble_CopyNodalData: DUDLEY_DEGREES_OF_FREEDOM to DUDLEY_NODES or DUDLEY_DEGREES_OF_FREEDOM requires expanded input data on more than one processor.");
52 }
53 } else {
54 throw DudleyException("Assemble_CopyNodalData: illegal function space type for target object");
55 }
56
57 dim_t numOut = 0;
58 switch (out_data_type) {
59 case DUDLEY_NODES:
60 numOut = nodes->getNumNodes();
61 break;
62
63 case DUDLEY_DEGREES_OF_FREEDOM:
64 numOut = nodes->getNumDegreesOfFreedom();
65 break;
66
67 default:
68 throw escript::ValueError("Assemble_CopyNodalData: illegal function space type for source object");
69 }
70
71 if (!out.numSamplesEqual(1, numOut)) {
72 throw escript::ValueError("Assemble_CopyNodalData: illegal number of samples of output Data object");
73 }
74
75 const size_t numComps_size = numComps * sizeof(double);
76
77 /**************************** DUDLEY_NODES ******************************/
78 if (in_data_type == DUDLEY_NODES) {
79 out.requireWrite();
80 if (out_data_type == DUDLEY_NODES) {
81 #pragma omp parallel for
82 for (index_t n = 0; n < numOut; n++) {
83 memcpy(out.getSampleDataRW(n), in.getSampleDataRO(n), numComps_size);
84 }
85 } else if (out_data_type == DUDLEY_DEGREES_OF_FREEDOM) {
86 const index_t* map = nodes->borrowDegreesOfFreedomTarget();
87 #pragma omp parallel for
88 for (index_t n = 0; n < numOut; n++) {
89 memcpy(out.getSampleDataRW(n), in.getSampleDataRO(map[n]),
90 numComps_size);
91 }
92 }
93 /********************** DUDLEY_DEGREES_OF_FREEDOM ***********************/
94 } else if (in_data_type == DUDLEY_DEGREES_OF_FREEDOM) {
95 out.requireWrite();
96 if (out_data_type == DUDLEY_NODES) {
97 paso::Coupler_ptr coupler(new paso::Coupler(nodes->degreesOfFreedomConnector, numComps));
98 // safe provided coupler->copyAll is called before the pointer
99 // in "in" is invalidated
100 const_cast<escript::Data*>(&in)->resolve();
101 coupler->startCollect(in.getDataRO());
102 const double* recv_buffer = coupler->finishCollect();
103 const index_t upperBound = nodes->getNumDegreesOfFreedom();
104 const index_t* target = nodes->borrowTargetDegreesOfFreedom();
105 #pragma omp parallel for
106 for (index_t n = 0; n < numOut; n++) {
107 const index_t k = target[n];
108 if (k < upperBound) {
109 memcpy(out.getSampleDataRW(n), in.getSampleDataRO(k),
110 numComps_size);
111 } else {
112 memcpy(out.getSampleDataRW(n),
113 &recv_buffer[(k - upperBound) * numComps],
114 numComps_size);
115 }
116 }
117 } else if (out_data_type == DUDLEY_DEGREES_OF_FREEDOM) {
118 #pragma omp parallel for
119 for (index_t n = 0; n < numOut; n++) {
120 memcpy(out.getSampleDataRW(n), in.getSampleDataRO(n),
121 numComps_size);
122 }
123 }
124 } // in_data_type
125 }
126
127 } // namespace dudley
128

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26