/[escript]/trunk/ripley/src/RipleyDomain.cpp
ViewVC logotype

Diff of /trunk/ripley/src/RipleyDomain.cpp

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

revision 4210 by jfenwick, Tue Jan 22 09:30:23 2013 UTC revision 4211 by caltinay, Mon Feb 18 23:54:46 2013 UTC
# Line 252  bool RipleyDomain::probeInterpolationOnD Line 252  bool RipleyDomain::probeInterpolationOnD
252              return (fsType_target != Nodes &&              return (fsType_target != Nodes &&
253                      fsType_target != DegreesOfFreedom);                      fsType_target != DegreesOfFreedom);
254          case Elements:          case Elements:
255            case ReducedElements:
256              return (fsType_target==Elements ||              return (fsType_target==Elements ||
257                      fsType_target==ReducedElements);                      fsType_target==ReducedElements);
258          case FaceElements:          case FaceElements:
259            case ReducedFaceElements:
260              return (fsType_target==FaceElements ||              return (fsType_target==FaceElements ||
261                      fsType_target==ReducedFaceElements);                      fsType_target==ReducedFaceElements);
         case ReducedElements:  
         case ReducedFaceElements:  
262          case Points:          case Points:
263              return (fsType_target==fsType_source);              return (fsType_target==fsType_source);
264    
# Line 293  void RipleyDomain::interpolateOnDomain(e Line 293  void RipleyDomain::interpolateOnDomain(e
293      // simplest case: 1:1 copy      // simplest case: 1:1 copy
294      if (inFS==outFS) {      if (inFS==outFS) {
295          copyData(target, *const_cast<escript::Data*>(&in));          copyData(target, *const_cast<escript::Data*>(&in));
296      // not allowed: reduced->non-reduced      // not allowed: reduced nodes/dof->non-reduced nodes/dof
297      } else if ((inFS==ReducedNodes || inFS==ReducedDegreesOfFreedom)      } else if ((inFS==ReducedNodes || inFS==ReducedDegreesOfFreedom)
298              && (outFS==Nodes || outFS==DegreesOfFreedom)) {              && (outFS==Nodes || outFS==DegreesOfFreedom)) {
299          throw RipleyException("interpolateOnDomain: Cannot interpolate reduced data to non-reduced data.");          throw RipleyException("interpolateOnDomain: Cannot interpolate reduced data to non-reduced data.");
# Line 303  void RipleyDomain::interpolateOnDomain(e Line 303  void RipleyDomain::interpolateOnDomain(e
303              averageData(target, *const_cast<escript::Data*>(&in));              averageData(target, *const_cast<escript::Data*>(&in));
304          else          else
305              copyData(target, *const_cast<escript::Data*>(&in));              copyData(target, *const_cast<escript::Data*>(&in));
306        } else if ((inFS==ReducedElements && outFS==Elements)
307                || (inFS==ReducedFaceElements && outFS==FaceElements)) {
308            multiplyData(target, *const_cast<escript::Data*>(&in));
309      } else {      } else {
310          switch (inFS) {          switch (inFS) {
311              case Nodes:              case Nodes:
# Line 818  void RipleyDomain::setNewX(const escript Line 821  void RipleyDomain::setNewX(const escript
821  }  }
822    
823  //protected  //protected
824    void RipleyDomain::copyData(escript::Data& out, escript::Data& in) const
825    {
826        const dim_t numComp = in.getDataPointSize();
827        out.requireWrite();
828    #pragma omp parallel for
829        for (index_t i=0; i<in.getNumSamples(); i++) {
830            const double* src = in.getSampleDataRO(i);
831            copy(src, src+numComp, out.getSampleDataRW(i));
832        }
833    }
834    
835    //protected
836  void RipleyDomain::averageData(escript::Data& out, escript::Data& in) const  void RipleyDomain::averageData(escript::Data& out, escript::Data& in) const
837  {  {
838      const dim_t numComp = in.getDataPointSize();      const dim_t numComp = in.getDataPointSize();
# Line 837  void RipleyDomain::averageData(escript:: Line 852  void RipleyDomain::averageData(escript::
852  }  }
853    
854  //protected  //protected
855  void RipleyDomain::copyData(escript::Data& out, escript::Data& in) const  void RipleyDomain::multiplyData(escript::Data& out, escript::Data& in) const
856  {  {
857      const dim_t numComp = in.getDataPointSize();      const dim_t numComp = in.getDataPointSize();
858        const dim_t dpp = out.getNumDataPointsPerSample();
859      out.requireWrite();      out.requireWrite();
860  #pragma omp parallel for  #pragma omp parallel for
861      for (index_t i=0; i<in.getNumSamples(); i++) {      for (index_t i=0; i<in.getNumSamples(); i++) {
862          const double* src = in.getSampleDataRO(i);          const double* src = in.getSampleDataRO(i);
863          copy(src, src+numComp, out.getSampleDataRW(i));          double* dest = out.getSampleDataRW(i);
864            for (index_t c=0; c<numComp; c++) {
865                for (index_t q=0; q<dpp; q++)
866                    dest[c+q*numComp] = src[c];
867            }
868      }      }
869  }  }
870    

Legend:
Removed from v.4210  
changed lines
  Added in v.4211

  ViewVC Help
Powered by ViewVC 1.1.26