540 if (!espace_stockage_)
544 DoubleTab& valeurs_espace = espace_stockage_->valeurs();
549 bool champ_normal_faces = 0;
551 champ_normal_faces = 1;
556 DoubleTrav positions;
559 if (zvf.
xp().nb_dim() != 2)
567 positions = zvf.
xv();
572 positions = zvf.
xp();
573 positions.
resize(nb_elem_tot+nb_som_tot,dim);
574 ToDo_Kokkos(
"critical loop");
575 for (
int i1=nb_elem_tot; i1<nb_elem_tot+nb_som_tot; i1++)
576 for (
int i2=0; i2<dim; i2++)
577 positions(i1,i2) = som(i1-nb_elem_tot,i2);
592 const int max_nb_sources = 14;
593 if (nb_sources>max_nb_sources)
595 Cerr <<
"Increase max_nb_sources to " << nb_sources <<
" in Champ_base& Champ_Generique_Transformation::get_champ() !" << finl;
598 DoubleTravs sources_val(nb_sources);
599 IntTrav nb_comps(nb_sources);
600 Noms nom_source(nb_sources);
602 Noms compo(dim_compo);
606 for (
int so=0; so<nb_sources; so++)
611 const DoubleTab& source_so_val = source_so.
valeurs();
615 nb_compso = source_so.
nb_comp();
616 nb_comps(so) = nb_compso;
618 nom_source[so] = nom_champ[0];
623 compo[so*
dimension+comp] = compo_ch[comp];
628 if (directive!=directive_so)
630 sources_val[so].resize(nb_pos,nb_compso);
633 else if (directive ==
"CHAMP_FONC_QUAD_DG" and directive_so ==
"CHAMP_ELEM_DG")
636 int npoints = valeurs_espace.
dimension(1);
638 sources_val[so].resize(nelem,npoints);
641 else source_so.
valeur_aux(positions,sources_val[so]);
648 sources_val[so].resize(nn,1);
649 sources_val[so] = source_so_val;
652 sources_val[so] = source_so_val;
657 int nb_pos_tmp=valeurs_espace.
dimension(0);
658 if (nb_pos_tmp > sources_val[so].size())
660 Cerr <<
"\nError in Champ_Generique_Transformation::get_champ" << finl;
661 Cerr << nom_source[so] <<
" : Wrong number of elements." << finl;
674 Kokkos::Array<CDoubleTabView, max_nb_sources> sources;
675 for (
int so=0; so<nb_sources; so++)
676 sources[so] = sources_val[so].view_ro();
677 DoubleArrView valeurs =
static_cast<ArrOfDouble&
>(valeurs_espace).view_wo();
678 if (directive ==
"champ_fonc_quad_dg")
680 ToDo_Kokkos(
"Code but check test!");
681 int nb_elem = valeurs_espace.
dimension(0);
682 IntTab nb_points, ind_integ_points;
686 CIntArrView ind_integ_points_w =
static_cast<const ArrOfInt&
>(ind_integ_points).view_ro();
687 CIntArrView nb_points_w =
static_cast<const ArrOfInt&
>(nb_points).view_ro();
688 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_elem, KOKKOS_LAMBDA(
const int i)
690 for (
int pt=0; pt<nb_points_w(i); pt++)
692 int threadId = parser.
acquire();
693 int k = ind_integ_points_w(i)+pt;
694 for (
int so=0; so<nb_sources; so++)
695 for (
int j=0; j<dim; j++)
696 parser.
setVar(so*dim+j,sources[so](i,j*nb_pts_integ_max+pt), threadId);
697 valeurs(k) = parser.
eval(threadId);
701 end_gpu_timer(__KERNEL_NAME__);
705 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_pos, KOKKOS_LAMBDA(
const int i)
707 int threadId = parser.
acquire();
708 for (
int so=0; so<nb_sources; so++)
709 for (
int j=0; j<dim; j++)
710 parser.
setVar(so*dim+j,sources[so](i,j), threadId);
711 valeurs(i) = parser.
eval(threadId);
714 end_gpu_timer(__KERNEL_NAME__);
729 Kokkos::Array<CDoubleTabView, max_nb_sources> sources;
730 for (
int so=0; so<nb_sources; so++)
731 sources[so] = sources_val[so].view_ro();
732 CDoubleTabView face_normales = zvf.
face_normales().view_ro();
734 CDoubleTabView pos = positions.
view_ro();
736 DoubleArrView valeurs =
static_cast<ArrOfDouble&
>(valeurs_espace).view_wo();
737 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_pos, KOKKOS_LAMBDA(
const int i)
739 int threadId = fxyz0.
acquire();
740 for (
int j=0; j<dim; j++)
742 double pos_i_j = pos(i, j);
743 fxyz0.
setVar(j, pos_i_j, threadId);
744 fxyz1.
setVar(j, pos_i_j, threadId);
745 if (dim==3) fxyz2.
setVar(j, pos_i_j, threadId);
747 fxyz0.
setVar(3, temps, threadId);
748 fxyz1.
setVar(3, temps, threadId);
749 if (dim==3) fxyz2.
setVar(3, temps, threadId);
750 for (
int so=0; so<nb_sources; so++)
752 double var = sources[so](i,0);
753 fxyz0.
setVar(so+4,var, threadId);
754 fxyz1.
setVar(so+4,var, threadId);
755 if (dim==3) fxyz2.
setVar(so+4,var, threadId);
757 valeurs(i) = fxyz0.
eval(threadId) * face_normales(i, 0) / surface(i);
758 valeurs(i) += fxyz1.
eval(threadId) * face_normales(i, 1) / surface(i);
759 if (dim==3) valeurs(i) += fxyz2.
eval(threadId) * face_normales(i, 2) / surface(i);
762 end_gpu_timer(__KERNEL_NAME__);
766 if (directive==
"champ_fonc_quad_dg")
768 ToDo_Kokkos(
"critical");
769 IntTab nb_points, ind_integ_points;
770 int nb_elem = valeurs_espace.
dimension(0);
775 for (
int i=0; i<nb_elem; i++)
777 for (
int pt=0; pt<nb_points[i]; pt++)
779 int k = ind_integ_points[i]+pt;
780 double x = positions(k,0);
781 double y = positions(k,1);
782 double z = (
dimension>2 ? positions(k,2) : 0);
789 fxyz[j].setVar(3,temps);
790 for (
int so=0; so<nb_sources; so++)
792 const DoubleTab& source_so_val = sources_val[so];
793 fxyz[j].setVar(so+4,source_so_val(i,pt));
795 int l = nb_pts_integ_max*j + pt;
796 valeurs_espace(i,l) = fxyz[j].eval();
803 Kokkos::Array<CDoubleTabView, max_nb_sources> sources;
804 for (
int so=0; so<nb_sources; so++)
805 sources[so] = sources_val[so].view_ro();
807 CDoubleTabView pos = positions.
view_ro();
808 DoubleTabView valeurs = valeurs_espace.
view_wo();
813 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_pos, KOKKOS_LAMBDA(
const int i)
817 double z = (dim>2 ? pos(i,2) : 0);
818 int threadId = fxyzj.
acquire();
819 fxyzj.
setVar(0,x,threadId);
820 fxyzj.
setVar(1,y,threadId);
821 fxyzj.
setVar(2,z,threadId);
822 fxyzj.
setVar(3,temps,threadId);
823 for (
int so=0; so<nb_sources; so++)
824 fxyzj.
setVar(so+4,sources[so](i,0),threadId);
825 valeurs(i,j) = fxyzj.
eval(threadId);
828 end_gpu_timer(__KERNEL_NAME__);
835 const DoubleTab& source_so_val = sources_val[0];
836 projette(valeurs_espace,source_so_val,zvf,
localisation_,champ_normal_faces);
840 int num_compo =
les_fct.size()-1;
841 if ((num_compo<0)||(num_compo>=nb_compso))
843 Cerr<<
"Component number must be >=0 and < "<<nb_compso<<
" for composante option."<<finl;
847 CDoubleTabView source_so_val = sources_val[0].view_ro();
848 DoubleArrView v =
static_cast<ArrOfDouble&
>(valeurs_espace).view_wo();
851 CDoubleTabView face_normales = zvf.
face_normales().view_ro();
853 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_pos, KOKKOS_LAMBDA(
const int i)
855 v(i) = source_so_val(i, 0) * face_normales(i, num_compo) / surface(i);
857 end_gpu_timer(__KERNEL_NAME__);
861 if (directive==
"champ_fonc_quad_dg")
863 ToDo_Kokkos(
"Code but check test!");
864 IntTab nb_points, ind_integ_points;
865 int nb_elem = valeurs_espace.
dimension(0);
869 CIntArrView ind_integ_points_w =
static_cast<const ArrOfInt&
>(ind_integ_points).view_ro();
870 CIntArrView nb_points_w =
static_cast<const ArrOfInt&
>(nb_points).view_ro();
872 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_elem, KOKKOS_LAMBDA(
const int i)
874 for (
int pt=0; pt<nb_points_w[i]; pt++)
876 int k = ind_integ_points_w[i]+pt;
877 v(k) = source_so_val(i, num_compo*nb_pts_integ_max+pt);
880 end_gpu_timer(__KERNEL_NAME__);
884 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_pos, KOKKOS_LAMBDA(
const int i)
886 v(i) = source_so_val(i, num_compo);
888 end_gpu_timer(__KERNEL_NAME__);
904 if (directive ==
"champ_fonc_quad_dg")
906 ToDo_Kokkos(
"Code but check test!");
908 int nb_elem = valeurs_espace.
dimension(0);
909 Kokkos::Array<CDoubleTabView, max_nb_sources> sources;
910 for (
int so=0; so<nb_sources; so++)
911 sources[so] = sources_val[so].view_ro();
912 IntTab nb_points, ind_integ_points;
917 CIntArrView ind_integ_points_w =
static_cast<const ArrOfInt&
>(ind_integ_points).view_ro();
918 CIntArrView nb_points_w =
static_cast<const ArrOfInt&
>(nb_points).view_ro();
919 CDoubleTabView pos = positions.
view_ro();
920 DoubleTabView valeurs = valeurs_espace.
view_wo();
921 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_elem, KOKKOS_LAMBDA(
const int i)
923 for (
int pt=0; pt<nb_points_w(i); pt++)
925 int threadId = parser.
acquire();
926 int k = ind_integ_points_w(i)+pt;
927 double x = special ? 1e38 : pos(k,0);
928 double y = special ? 1e38 : pos(k,1);
929 double z = special ? 1e38 : (dim>2 ? pos(k,2) : 0);
930 parser.
setVar(0,x,threadId);
931 parser.
setVar(1,y,threadId);
932 parser.
setVar(2,z,threadId);
933 parser.
setVar(3,temps,threadId);
937 int j = nb_pts_integ_max*d + pt;
938 for (
int so=0; so<nb_sources; so++)
939 parser.
setVar(so+4,sources[so](i,j),threadId);
940 valeurs(i, j) = parser.
eval(threadId);
944 end_gpu_timer(__KERNEL_NAME__);
948 int line_size = valeurs_espace.
line_size();
951 Kokkos::Array<CDoubleTabView, max_nb_sources> sources;
952 for (
int so=0; so<nb_sources; so++)
953 sources[so] = sources_val[so].view_ro();
954 CDoubleTabView pos = positions.
view_ro();
955 CIntArrView nb_comp_sources =
static_cast<const ArrOfInt&
>(nb_comps).view_ro();
956 DoubleTabView valeurs = valeurs_espace.
view_wo();
957 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_pos, KOKKOS_LAMBDA(
const int i)
959 double x = special ? 1e38 : pos(i,0);
960 double y = special ? 1e38 : pos(i,1);
961 double z = special ? 1e38 : (dim>2 ? pos(i,2) : 0);
962 int threadId = parser.
acquire();
963 parser.
setVar(0,x,threadId);
964 parser.
setVar(1,y,threadId);
965 parser.
setVar(2,z,threadId);
966 parser.
setVar(3,temps,threadId);
969 for (
int so=0; so<nb_sources; so++)
970 parser.
setVar(so+4,sources[so](i,0),threadId);
971 valeurs(i, 0) = parser.
eval(threadId);
977 for (
int so=0; so<nb_sources; so++)
979 int nbcomp_loc = nb_comp_sources(so);
981 parser.
setVar(so+4,sources[so](i,j),threadId);
982 else if (nbcomp_loc == 1)
983 parser.
setVar(so+4,sources[so](i,0),threadId);
985 Process::Kokkos_exit(
"The arrays of values don't have compatibles dimensions in Champ_Generique_Transformation::get_champ()");
987 valeurs(i,j) = parser.
eval(threadId);
992 end_gpu_timer(__KERNEL_NAME__);
998 return espace_stockage_;