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

Diff of /branches/trilinos_from_5897/dudley/src/Assemble_CopyElementData.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6078 by caltinay, Wed Mar 2 04:13:26 2016 UTC revision 6079 by caltinay, Mon Mar 21 12:22:38 2016 UTC
# Line 14  Line 14 
14  *  *
15  *****************************************************************************/  *****************************************************************************/
16    
 /****************************************************************************  
   
   Assemblage routines: copies data between elements  
   
 *****************************************************************************/  
   
17  #include "Assemble.h"  #include "Assemble.h"
18  #include "ShapeTable.h"  #include "ShapeTable.h"
19  #include "Util.h"  #include "Util.h"
20    
21  namespace dudley {  namespace dudley {
22    
23  void Assemble_CopyElementData(Dudley_ElementFile* elements, escript::Data* out, const escript::Data* in)  void Assemble_CopyElementData(const ElementFile* elements, escript::Data& out,
24                                  const escript::Data& in)
25  {  {
26      if (!elements)      if (!elements)
27          return;          return;
28    
29      dim_t numQuad;      dim_t numQuad = (hasReducedIntegrationOrder(in) ?
30      if (Assemble_reducedIntegrationOrder(in)) {              QuadNums[elements->numDim][0] : QuadNums[elements->numDim][1]);
         numQuad = QuadNums[elements->numDim][0];  
     } else {  
         numQuad = QuadNums[elements->numDim][1];  
     }  
31    
32        // check out and in
33      const dim_t numElements = elements->numElements;      const dim_t numElements = elements->numElements;
34      const int numComps = out->getDataPointSize();      const int numComps = out.getDataPointSize();
35    
36      // check out and in      if (numComps != in.getDataPointSize()) {
     if (numComps != in->getDataPointSize())  
     {  
37          throw DudleyException("Assemble_CopyElementData: number of components of input and output Data do not match.");          throw DudleyException("Assemble_CopyElementData: number of components of input and output Data do not match.");
38      } else if (!in->numSamplesEqual(numQuad, numElements)) {      } else if (!in.numSamplesEqual(numQuad, numElements)) {
39          throw DudleyException("Assemble_CopyElementData: illegal number of samples of input Data object");          throw DudleyException("Assemble_CopyElementData: illegal number of samples of input Data object");
40      } else if (!out->numSamplesEqual(numQuad, numElements)) {      } else if (!out.numSamplesEqual(numQuad, numElements)) {
41          throw DudleyException("Assemble_CopyElementData: illegal number of samples of output Data object");          throw DudleyException("Assemble_CopyElementData: illegal number of samples of output Data object");
42      } else if (!out->actsExpanded()) {      } else if (!out.actsExpanded()) {
43          throw DudleyException("Assemble_CopyElementData: expanded Data object is expected for output data.");          throw DudleyException("Assemble_CopyElementData: expanded Data object is expected for output data.");
44      } else {      } else {
45          out->requireWrite();          out.requireWrite();
46          if (in->actsExpanded()) {          if (in.actsExpanded()) {
47              const size_t len_size = numComps * numQuad * sizeof(double);              const size_t len_size = numComps * numQuad * sizeof(double);
48  #pragma omp parallel for  #pragma omp parallel for
49              for (index_t n = 0; n < numElements; n++)              for (index_t n = 0; n < numElements; n++)
50                  memcpy(out->getSampleDataRW(n), in->getSampleDataRO(n), len_size);                  memcpy(out.getSampleDataRW(n), in.getSampleDataRO(n), len_size);
51          } else {          } else {
52              const size_t len_size = numComps * sizeof(double);              const size_t len_size = numComps * sizeof(double);
53  #pragma omp parallel for  #pragma omp parallel for
54              for (index_t n = 0; n < numElements; n++) {              for (index_t n = 0; n < numElements; n++) {
55                  const double* in_array = in->getSampleDataRO(n);                  const double* in_array = in.getSampleDataRO(n);
56                  double* out_array = out->getSampleDataRW(n);                  double* out_array = out.getSampleDataRW(n);
57                  for (int q = 0; q < numQuad; q++)                  for (int q = 0; q < numQuad; q++)
58                      memcpy(out_array + q * numComps, in_array, len_size);                      memcpy(out_array + q * numComps, in_array, len_size);
59              }              }

Legend:
Removed from v.6078  
changed lines
  Added in v.6079

  ViewVC Help
Powered by ViewVC 1.1.26