void BarycentricMapperRegularGridTopology<CudaVec3f1Types,CudaVec3f1Types>::applyJT( In::VecDeriv& out, const Out::VecDeriv& in )
{
    calcMapT();
    if (map.size() == 0) return;
    unsigned int gridsize[3] = { (unsigned int)topology->getNx(), (unsigned int)topology->getNy(), (unsigned int)topology->getNz() };
    unsigned int insize = out.size();

    RegularGridMapperCuda3f1_applyJT(insize, maxNOut, gridsize, mapT.deviceRead(), out.deviceWrite(), in.deviceRead());
}
void BarycentricMapperSparseGridTopology<CudaVec3f1Types,CudaVec3f1Types>::applyJT( In::VecDeriv& out, const Out::VecDeriv& in )
{
    buildTranslate(out.size());
    SparseGridMapperCuda3f1_applyJT(out.size(), CudaTnb.deviceRead(),CudaTst.deviceRead(),CudaTid.deviceRead(),CudaTVal.deviceRead(), out.deviceWrite(), in.deviceRead());
}
void BarycentricMapperMeshTopology<CudaVec3f1Types,CudaVec3f1Types>::applyJT( In::VecDeriv& out, const Out::VecDeriv& in )
{
    if (size == 0) return;
    calcMapT();
    MeshMapperCuda3f1_applyPEq(insize, maxNOut, mapT.deviceRead(), out.deviceWrite(), in.deviceRead());
}
void BarycentricMapperSparseGridTopology<CudaVec3fTypes,CudaVec3fTypes>::applyJT( In::VecDeriv& out, const Out::VecDeriv& in )
{
    buildTranslate(out.size());
    SparseGridMapperCuda3f_applyJT(out.size(), CudaTnb.deviceRead(),CudaTst.deviceRead(),CudaTid.deviceRead(),CudaTVal.deviceRead(), out.deviceWrite(), in.deviceRead());
    /*
            for ( unsigned int i=0;i<map.size();i++ ) {
                    Out::Deriv v = in[i];
            const topology::SparseGridTopology::Hexa cube = this->topology->getHexahedron ( map[i].in_index );
                    const OutReal fx = ( OutReal ) map[i].baryCoords[0];
                    const OutReal fy = ( OutReal ) map[i].baryCoords[1];
                    const OutReal fz = ( OutReal ) map[i].baryCoords[2];
                    out[cube[0]] += v * ( ( 1-fx ) * ( 1-fy ) * ( 1-fz ) );
                    out[cube[1]] += v * ( (   fx ) * ( 1-fy ) * ( 1-fz ) );
                    out[cube[3]] += v * ( ( 1-fx ) * (   fy ) * ( 1-fz ) );
                    out[cube[2]] += v * ( (   fx ) * (   fy ) * ( 1-fz ) );
                    out[cube[4]] += v * ( ( 1-fx ) * ( 1-fy ) * (   fz ) );
                    out[cube[5]] += v * ( (   fx ) * ( 1-fy ) * (   fz ) );
                    out[cube[7]] += v * ( ( 1-fx ) * (   fy ) * (   fz ) );
                    out[cube[6]] += v * ( (   fx ) * (   fy ) * (   fz ) );
            }
    */
// 	for ( unsigned int o=0;o<out.size();o++ ) {
// 	    for (unsigned n=CudaTst[o];n<CudaTst[o]+CudaTnb[o];n++) {
// 	      out[o] += in[CudaTid[n]] * CudaTVal[n];
// 	    }
// 	}



}