@@ -554,8 +554,8 @@ void HyperReduction<SnapshotsLists...>::offlineGappyDEIM(
554554 adding.rowwise () += norma.transpose ();
555555 Eigen::VectorXd denom = (adding.array ().pow (1 . /
556556 V.cols ()).matrix ()).rowwise ().prod ();
557- max = ((mp_not_mask. head (n_cells) .asDiagonal () * num). array () /
558- denom.array ()).maxCoeff (& ind_max, & c1);
557+ max = ((mp_not_mask ( Eigen::seq ( 0 , Eigen::indexing::last, vectorial_dim)) .asDiagonal () * num)
558+ . array () / denom.array ()).maxCoeff (& ind_max, & c1);
559559 }
560560 else
561561 {
@@ -732,8 +732,8 @@ void HyperReduction<SnapshotsLists...>::offlineECP(List<Eigen::MatrixXd>& listSn
732732
733733 for (unsigned int ith_field = 0 ; ith_field < vectorial_dim; ith_field++)
734734 {
735- Eigen::MatrixXd block = listSnapshotsModes[ith_subspace]. block ( ith_field* n_cells, 0 , n_cells,
736- n_modesCurrent ).transpose ();
735+ Eigen::MatrixXd block = listSnapshotsModes[ith_subspace]( Eigen::seq ( ith_field,
736+ Eigen::indexing::last, vectorial_dim), Eigen::indexing::all ).transpose ();
737737
738738 if (predictVolume)
739739 {
@@ -815,8 +815,8 @@ void HyperReduction<SnapshotsLists...>::offlineECP(List<Eigen::MatrixXd>& listSn
815815
816816 while (nodePoints->size () < n_nodes)
817817 {
818- max = ((b.transpose () * A * mp_not_mask. head (
819- n_cells) .asDiagonal ()).colwise ().sum ()).maxCoeff (& r1, & ind_max);
818+ max = ((b.transpose () * A * mp_not_mask ( Eigen::seq ( 0 , Eigen::indexing::last, vectorial_dim))
819+ .asDiagonal ()).colwise ().sum ()).maxCoeff (& r1, & ind_max);
820820 updateNodes (P, ind_max, mp_not_mask);
821821 n_modesPrevious = 0 ;
822822 for (int ith_subspace = 0 ; ith_subspace < n_subspaces; ith_subspace++)
@@ -873,7 +873,7 @@ void HyperReduction<SnapshotsLists...>::offlineECP(List<Eigen::MatrixXd>& listSn
873873 if (n_subspaces == 1 )
874874 {
875875 basisMatrix = listSnapshotsModes[0 ];
876- quadratureWeights = quadratureWeightsSubspaces[0 ];
876+ quadratureWeights = EigenFunctions::reorderVectorFromDim ( quadratureWeightsSubspaces[0 ], vectorial_dim) ;
877877 evaluateWPU (P, basisMatrix, normalizingWeights, quadratureWeights);
878878 cnpy::save (basisMatrix, folderMethod + " /basisMatrix.npy" );
879879 cnpy::save (quadratureWeights, folderMethod + " /quadratureWeights.npy" );
@@ -884,6 +884,8 @@ void HyperReduction<SnapshotsLists...>::offlineECP(List<Eigen::MatrixXd>& listSn
884884 Eigen::MatrixXd quadratureWeightsMerged (n_nodes, n_subspaces);
885885 for (int ith_subspace = 0 ; ith_subspace < n_subspaces; ith_subspace++)
886886 {
887+ quadratureWeightsSubspaces[ith_subspace] = EigenFunctions::reorderVectorFromDim (
888+ quadratureWeightsSubspaces[ith_subspace], vectorial_dim);
887889 cnpy::save (quadratureWeightsSubspaces[ith_subspace], folderMethod + " /quadratureWeights_subspace" +
888890 std::to_string (ith_subspace+1 ) + " .npy" );
889891 quadratureWeightsMerged.col (ith_subspace) = quadratureWeightsSubspaces[ith_subspace];
@@ -942,9 +944,9 @@ void HyperReduction<SnapshotsLists...>::initSeeds(Eigen::VectorXd mp_not_mask,
942944
943945 for (unsigned int ith_field = 0 ; ith_field < vectorial_dim; ith_field++)
944946 {
945- P.insert (index + ith_field * n_cells ,
946- vectorial_dim * trueSeeds + ith_field) = 1 ;
947- mp_not_mask (index + ith_field * n_cells ) = 0 ;
947+ P.insert (index * vectorial_dim + ith_field ,
948+ trueSeeds * vectorial_dim + ith_field) = 1 ;
949+ mp_not_mask (index * vectorial_dim + ith_field ) = 0 ;
948950 }
949951
950952 trueSeeds++;
@@ -982,14 +984,14 @@ void HyperReduction<SnapshotsLists...>::updateNodes(Eigen::SparseMatrix<double>
982984 {
983985 for (unsigned int ith_field = 0 ; ith_field < vectorial_dim; ith_field++)
984986 {
985- P.insert (nodes[ith_node] + ith_field * n_cells ,
986- ith_node + ith_field * (step + 1 ) ) = 1 ;
987+ P.insert (nodes[ith_node] * vectorial_dim + ith_field ,
988+ ith_node * vectorial_dim + ith_field ) = 1 ;
987989 }
988990 }
989991
990992 for (unsigned int ith_field = 0 ; ith_field < vectorial_dim; ith_field++)
991993 {
992- mp_not_mask (ind + ith_field * n_cells ) = 0 ;
994+ mp_not_mask (ind * vectorial_dim + ith_field ) = 0 ;
993995 }
994996}
995997
@@ -1021,8 +1023,8 @@ void HyperReduction<SnapshotsLists...>::updateNodesRemove(Eigen::SparseMatrix<do
10211023 {
10221024 for (unsigned int ith_field = 0 ; ith_field < vectorial_dim; ith_field++)
10231025 {
1024- P.insert (nodes[ith_node] + ith_field * n_cells ,
1025- ith_node + ith_field*(step + 1 ) ) = 1 ;
1026+ P.insert (nodes[ith_node] * vectorial_dim + ith_field ,
1027+ ith_node * vectorial_dim + ith_field ) = 1 ;
10261028 }
10271029 }
10281030 // Not updating mp_not_mask : we are not choosing again a node that we removed
@@ -1062,7 +1064,7 @@ void HyperReduction<SnapshotsLists...>::initReshapeMat(
10621064 {
10631065 for (unsigned int ith_field = 0 ; ith_field < vectorial_dim; ith_field++)
10641066 {
1065- reshapeMat.insert (i, i + n_cells * ith_field) = 1 ;
1067+ reshapeMat.insert (i, i * vectorial_dim + ith_field) = 1 ;
10661068 }
10671069 }
10681070
@@ -1307,4 +1309,27 @@ List<label> HyperReduction<SnapshotsLists...>::global2local(
13071309 return localPoints;
13081310}
13091311
1312+ template <typename ... SnapshotsLists>
1313+ Eigen::SparseMatrix<double > HyperReduction<SnapshotsLists...>::maskToOtherDim(int newDim)
1314+ {
1315+ if (!(newDim > 0 ))
1316+ {
1317+ Info << " The integer for the HyperReduction::maskToOtherDim method must be positive. Aborting" << endl;
1318+ abort ();
1319+ }
1320+ else
1321+ {
1322+ Eigen::SparseMatrix<double > output (n_cells * newDim, nodes.size () * newDim);
1323+ for (int ith_node = 0 ; ith_node < nodes.size (); ith_node++)
1324+ {
1325+ for (unsigned int ith_field = 0 ; ith_field < newDim; ith_field++)
1326+ {
1327+ output.insert (nodes[ith_node] * newDim + ith_field,
1328+ ith_node * newDim + ith_field) = 1 ;
1329+ }
1330+ }
1331+ return output;
1332+ }
1333+ }
1334+
13101335#endif
0 commit comments