@@ -87,7 +87,7 @@ class HMatrixVirt {
8787 int state = 0 ;
8888 bool factinplace = 0 ;
8989 virtual const std::map<std::string, std::string>& get_infos () const = 0;
90- virtual void mvprod_global (const K* const in, K* const out,const int & mu=1 ) const = 0;
90+ virtual void mvprod_global (const K* const in, K* const out, const char N= ' N ' , const int & mu=1 ) const = 0;
9191 virtual int nb_rows () const = 0;
9292 virtual int nb_cols () const = 0;
9393 virtual void cluster_to_target_permutation (const K* const in, K* const out) const = 0;
@@ -124,15 +124,20 @@ class HMatrixImpl : public HMatrixVirt<K> {
124124 std::map<std::string, std::string> infos;
125125 HMatrixImpl (htool::VirtualGenerator<K> &mat, std::shared_ptr<htool::Cluster<double >> t, std::shared_ptr<htool::Cluster<double >> s,const htool::HMatrixTreeBuilder<K,double >& hmatrix_tree_builder,string slvr,bool factinplace, MPI_Comm comm) : target_cluster(t), source_cluster(s), distributed_operator_holder(mat,*target_cluster,*source_cluster,hmatrix_tree_builder,comm),distributed_operator(distributed_operator_holder.distributed_operator), H(distributed_operator_holder.hmatrix), infos(htool::get_distributed_hmatrix_information(H,distributed_operator.get_comm())){this ->solver =slvr; this ->factinplace =factinplace;}
126126 const std::map<std::string, std::string>& get_infos () const { return infos; }
127- void mvprod_global (const K* const in, K* const out,const int & mu=1 ) const {
127+ void mvprod_global (const K* const in, K* const out, const char N= ' N ' , const int & mu=1 ) const {
128128 K* work=nullptr ;
129129 if (mu==1 ){
130- add_distributed_operator_vector_product_global_to_global (' N ' ,K (1 ),distributed_operator,in,K (0 ),out,work);
131- } else {
130+ add_distributed_operator_vector_product_global_to_global (N ,K (1 ),distributed_operator,in,K (0 ),out,work);
131+ } else if (N== ' N ' ) {
132132 htool::MatrixView<K> out_view (distributed_operator.get_target_partition ().get_global_size () ,mu,out);
133133 htool::MatrixView< const K> in_view (distributed_operator.get_source_partition ().get_global_size () ,mu,in);
134- add_distributed_operator_matrix_product_global_to_global (' N' ,K (1 ),distributed_operator,in_view,K (0 ),out_view,work);
135- }
134+ add_distributed_operator_matrix_product_global_to_global (N,K (1 ),distributed_operator,in_view,K (0 ),out_view,work);
135+ }
136+ else {
137+ htool::MatrixView<K> out_view (distributed_operator.get_source_partition ().get_global_size () ,mu,out);
138+ htool::MatrixView< const K> in_view (distributed_operator.get_target_partition ().get_global_size () ,mu,in);
139+ add_distributed_operator_matrix_product_global_to_global (N,K (1 ),distributed_operator,in_view,K (0 ),out_view,work);
140+ }
136141 }
137142 int nb_rows () const { return distributed_operator.get_target_partition ().get_global_size ();}
138143 int nb_cols () const { return distributed_operator.get_source_partition ().get_global_size ();}
@@ -463,9 +468,13 @@ void creationHMatrixtoBEMForm(const FESpace1 * Uh, const FESpace2 * Vh, const in
463468 typedef typename TMesh::RdHat TRdHat;
464469
465470 typedef typename std::conditional<SMesh::RdHat::d==1 ,bemtool::Mesh1D,bemtool::Mesh2D>::type MeshBemtool;
471+ typedef typename std::conditional<TMesh::RdHat::d==1 ,bemtool::Mesh1D,bemtool::Mesh2D>::type MeshBemtoolX;
466472 typedef typename std::conditional<SMesh::RdHat::d==1 ,bemtool::P0_1D,bemtool::P0_2D>::type P0;
467473 typedef typename std::conditional<SMesh::RdHat::d==1 ,bemtool::P1_1D,bemtool::P1_2D>::type P1;
468474 typedef typename std::conditional<SMesh::RdHat::d==1 ,bemtool::P2_1D,bemtool::P2_2D>::type P2;
475+ typedef typename std::conditional<TMesh::RdHat::d==1 ,bemtool::P0_1D,bemtool::P0_2D>::type P0X;
476+ typedef typename std::conditional<TMesh::RdHat::d==1 ,bemtool::P1_1D,bemtool::P1_2D>::type P1X;
477+ typedef typename std::conditional<TMesh::RdHat::d==1 ,bemtool::P2_1D,bemtool::P2_2D>::type P2X;
469478
470479 // size of the matrix
471480 int m=Uh->NbOfDF ;
@@ -486,9 +495,10 @@ void creationHMatrixtoBEMForm(const FESpace1 * Uh, const FESpace2 * Vh, const in
486495 const TMesh & ThV =Vh->Th ; // colunm
487496 bool samemesh = (void *)&Uh->Th == (void *)&Vh->Th ; // same Fem2D::Mesh +++ pot or kernel
488497
489- bemtool::Geometry node; MeshBemtool mesh;
498+ bemtool::Geometry node; bemtool::Geometry nodeX; MeshBemtool mesh; MeshBemtoolX meshX ;
490499 Mesh2Bemtool (ThU, node, mesh);
491-
500+ if (!samemesh && (VFBEM==1 ))
501+ Mesh2Bemtool (ThV, nodeX, meshX);
492502
493503 vector<double > pt (3 *n);
494504 vector<double > ps (3 *m);
@@ -634,15 +644,30 @@ void creationHMatrixtoBEMForm(const FESpace1 * Uh, const FESpace2 * Vh, const in
634644
635645 if (SP0) {
636646 bemtool::Dof<P0> dof (mesh);
637- ff_BIO_Generator<R,P0,SMesh>(generator,Ker,dof,alpha);
647+ if (samemesh)
648+ ff_BIO_Generator<R,P0,P0,SMesh,SMesh>(generator,Ker,dof,dof,alpha);
649+ else {
650+ bemtool::Dof<P0X> dofX (meshX);
651+ ff_BIO_Generator<R,P0X,P0,TMesh,SMesh>(generator,Ker,dofX,dof,alpha);
652+ }
638653 }
639654 else if (SP1) {
640655 bemtool::Dof<P1> dof (mesh,true );
641- ff_BIO_Generator<R,P1,SMesh>(generator,Ker,dof,alpha);
656+ if (samemesh)
657+ ff_BIO_Generator<R,P1,P1,SMesh,SMesh>(generator,Ker,dof,dof,alpha);
658+ else {
659+ bemtool::Dof<P1X> dofX (meshX,true );
660+ ff_BIO_Generator<R,P1X,P1,TMesh,SMesh>(generator,Ker,dofX,dof,alpha);
661+ }
642662 }
643663 else if (SP2) {
644664 bemtool::Dof<P2> dof (mesh,true );
645- ff_BIO_Generator<R,P2,SMesh>(generator,Ker,dof,alpha);
665+ if (samemesh)
666+ ff_BIO_Generator<R,P2,P2,SMesh,SMesh>(generator,Ker,dof,dof,alpha);
667+ else {
668+ bemtool::Dof<P2X> dofX (meshX,true );
669+ ff_BIO_Generator<R,P2X,P2,TMesh,SMesh>(generator,Ker,dofX,dof,alpha);
670+ }
646671 }
647672 else if (SRT0 && SRdHat::d == 2 ) {
648673 // BemKernel->typeKernel[0] == 6 :: MA_SL
0 commit comments