47 #ifndef MUI_SAMPLER_RBF_H_
48 #define MUI_SAMPLER_RBF_H_
50 #include "../../general/util.h"
51 #include "../../uniface.h"
52 #include "../../linear_algebra/solver.h"
55 #include <sys/types.h>
61 template<
typename CONFIG = default_config,
62 typename O_TP =
typename CONFIG::REAL,
typename I_TP = O_TP>
68 using REAL =
typename CONFIG::REAL;
69 using INT =
typename CONFIG::INT;
73 static const bool QUIET = CONFIG::QUIET;
74 static const bool DEBUG = CONFIG::DEBUG;
127 bool conservative =
false,
bool smoothFunc =
false,
bool generateMatrix =
true,
128 const std::string &writeFileAddress = std::string(),
REAL cutOff = 1
e-9,
129 REAL cgSolveTol = 1
e-6,
INT cgMaxIter = 0,
INT pouSize = 50,
130 INT precond = 1, MPI_Comm local_comm = MPI_COMM_NULL) :
154 s_ = std::pow(-std::log(cutOff), 0.5) /
r_;
176 createError = mkdir(
writeFileAddress_.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
178 if (createError != 0 && createError != EEXIST)
179 EXCEPTION(std::runtime_error(
"MUI Error [sampler_rbf.h]: Problem creating RBF matrix folder"));
183 template<
template<
typename,
typename >
class CONTAINER>
190 const clock_t begin_time = clock();
195 std::cout <<
"MUI [sampler_rbf.h]: Matrices generated in: "
196 <<
static_cast<double>(clock() - begin_time) / CLOCKS_PER_SEC <<
"s ";
198 std::cout << std::endl
199 <<
" Average CG error: " << error << std::endl;
204 EXCEPTION(std::runtime_error(
"MUI Error [sampler_rbf.h]: RBF matrix not found, call readRBFMatrix() first"));
209 std::cout <<
"MUI [sampler_rbf.h]: Number of remote points: " << data_points.size()
210 <<
" at rank " <<
local_rank_ <<
" out of total ranks "
212 std::cout <<
"MUI [sampler_rbf.h]: Number of local points: " <<
pts_.size()
213 <<
" at rank " <<
local_rank_ <<
" out of total ranks "
215 std::cout <<
"MUI [sampler_rbf.h]: Number of ghost local points: " <<
ptsGhost_.size()
216 <<
" at rank " <<
local_rank_ <<
" out of total ranks "
218 std::cout <<
"MUI [sampler_rbf.h]: Number of extended local points: "
220 <<
" out of total ranks " <<
local_size_ << std::endl;
226 if (
sizeof(xPtsExtend) == 0) {
227 throw "MUI Error [sampler_rbf.h]: Error zero xPtsExtend element exception";
229 else if (
sizeof(xPtsExtend) < 0) {
230 throw "MUI Error [sampler_rbf.h]: Error invalid xPtsExtend element exception";
232 else if (
sizeof(xPtsExtend[0]) == 0) {
233 throw "MUI Error [sampler_rbf.h]: Division by zero value of xPtsExtend[0] exception";
235 else if (
sizeof(xPtsExtend[0]) < 0) {
236 throw "MUI Error [sampler_rbf.h]: Division by invalid value of xPtsExtend[0] exception";
238 xPtsExtendSize =
sizeof(xPtsExtend) /
sizeof(xPtsExtend[0]);
240 catch (
const char *msg) {
241 std::cerr << msg << std::endl;
243 for (
int i = 0; i < xPtsExtendSize; ++i) {
244 std::cout << xPtsExtend[i] <<
" ";
246 std::cout << std::endl;
251 return normsq(focus - b) < std::numeric_limits<REAL>::epsilon();
254 if (p == std::end(
pts_))
255 EXCEPTION(std::runtime_error(
"MUI Error [sampler_rbf.h]: Point not found. Must pre-set points for RBF interpolation"));
257 auto i = std::distance(
pts_.begin(), p);
258 REAL tolerance = 1
e-5;
260 for (
size_t j = 0; j < data_points.size(); j++) {
267 if (
normsq(
remote_pts_[j] - data_points[j].first) < (std::numeric_limits<REAL>::epsilon() + tolerance)){
275 return normsq(data_p - b) < (std::numeric_limits<REAL>::epsilon() + tolerance);
279 std::cout<<
"Missing Remote points: " << data_points[j].first[0] <<
" " << data_points[j].first[1] <<
" Size of remote_pts_: " <<
remote_pts_.size()<<
" at rank: " <<
local_rank_ << std::endl;
280 EXCEPTION(std::runtime_error(
"MUI Error [sampler_rbf.h]: Remote point not found. Must use the same set of remote points as used to construct the RBF coupling matrix"));
283 auto new_j = std::distance(
remote_pts_.begin(), remote_p);
288 sum += HElement * data_points[j].second;
309 pts_.emplace_back(pt);
324 std::ifstream inputFileMatrixSize(readFileAddress +
"/matrixSize.dat");
326 if (!inputFileMatrixSize) {
327 std::cerr <<
"MUI Error [sampler_rbf.h]: Could not locate the file address of matrixSize.dat"
332 std::vector<INT> tempV;
333 while (std::getline(inputFileMatrixSize, tempS)) {
335 if (tempS[0] ==
'/' && tempS[1] ==
'/')
337 std::stringstream lineStream(tempS);
339 while (std::getline(lineStream, tempSS,
',')) {
340 tempV.emplace_back(std::stoi(tempSS));
353 std::ifstream inputFileCAB(readFileAddress +
"/connectivityAB.dat");
357 <<
"MUI Error [sampler_rbf.h]: Could not locate the file address on the connectivityAB.dat"
365 while (std::getline(inputFileCAB, tempS)) {
367 if (tempS[0] ==
'/' && tempS[1] ==
'/')
369 std::stringstream lineStream(tempS);
371 std::vector<INT> tempV;
372 while (std::getline(lineStream, tempSS,
',')) {
373 tempV.emplace_back(std::stoi(tempSS));
381 std::ifstream inputFileCAA(readFileAddress +
"/connectivityAA.dat");
385 <<
"MUI Error [sampler_rbf.h]: Could not locate the file address on the connectivityAA.dat"
391 <<
"MUI Error [sampler_rbf.h]: Error on the size of connectivityAA matrix in matrixSize.dat. Number of rows: "
393 <<
". Make sure matrices were generated with the smoothing function switched on."
402 while (std::getline(inputFileCAA, tempS)) {
404 if (tempS[0] ==
'/' && tempS[1] ==
'/')
406 std::stringstream lineStream(tempS);
408 std::vector<INT> tempV;
409 while (std::getline(lineStream, tempSS,
',')) {
410 tempV.emplace_back(std::stoi(tempSS));
422 std::ifstream inputFileHMatrix(readFileAddress +
"/Hmatrix.dat");
424 if (!inputFileHMatrix) {
425 std::cerr <<
"MUI Error [sampler_rbf.h]: Could not locate the file address on the Hmatrix.dat"
429 inputFileHMatrix >>
H_;
433 <<
") is not NOT equal to Hrow_ (" <<
Hrow_ <<
"), or"
434 << std::endl <<
"column of H_ (" <<
H_.
get_cols()
435 <<
") is not NOT equal to Hcol_ (" <<
Hcol_ <<
")"
440 std::ifstream inputFileRemotePoints(readFileAddress +
"/remotePoints.dat");
442 if (!inputFileRemotePoints) {
443 std::cerr <<
"MUI Error [sampler_rbf.h]: Could not locate the file address on the Hmatrix.dat"
449 EXCEPTION(std::runtime_error(
"MUI Error [sampler_rbf.h]: CONFIG::D must equal to remote point dimension in remotePoints.dat"));
453 while (std::getline(inputFileRemotePoints, tempS)) {
455 if (tempS[0] ==
'/' && tempS[1] ==
'/')
457 std::stringstream lineStream(tempS);
461 while (std::getline(lineStream, tempSS,
',')) {
463 tempP[temp_i] =
static_cast<REAL>(std::stold(tempSS));
478 std::pair<point_type, point_type>
localBoundingBox(
const std::vector<point_type> pt)
const {
482 if (CONFIG::D == 1) {
486 else if (CONFIG::D == 2) {
492 else if (CONFIG::D == 3) {
501 throw "MUI Error [sampler_rbf.h]: Invalid value of CONFIG::D exception";
504 catch (
const char *msg) {
505 std::cerr << msg << std::endl;
508 for (
auto xPts : pt) {
512 if (xPts[0] > lbbMax[0])
514 if (xPts[0] < lbbMin[0])
518 if (xPts[0] > lbbMax[0])
520 if (xPts[0] < lbbMin[0])
522 if (xPts[1] > lbbMax[1])
524 if (xPts[1] < lbbMin[1])
528 if (xPts[0] > lbbMax[0])
530 if (xPts[0] < lbbMin[0])
532 if (xPts[1] > lbbMax[1])
534 if (xPts[1] < lbbMin[1])
536 if (xPts[2] > lbbMax[2])
538 if (xPts[2] < lbbMin[2])
542 throw "MUI Error [sampler_rbf.h]: Invalid value of CONFIG::D exception";
545 catch (
const char *msg) {
546 std::cerr << msg << std::endl;
549 return std::make_pair(lbbMin, lbbMax);
555 lbbExtendMin = lbb.first;
556 lbbExtendMax = lbb.second;
557 for (
INT i = 0; i < CONFIG::D; ++i) {
558 lbbExtendMax[i] += r;
559 lbbExtendMin[i] -= r;
561 return std::make_pair(lbbExtendMin, lbbExtendMax);
565 std::pair<std::vector<std::pair<INT, INT>>, std::vector<std::pair<INT, std::vector<point_type>>>>
getGhostPointsToSend(
566 std::pair<point_type, point_type> lbbExtend, MPI_Comm local_world,
567 int local_rank,
int local_size)
const {
568 std::pair<INT, std::pair<point_type, point_type>> localBB, globalBB[local_size];
571 localBB.first = local_rank;
572 localBB.second.first = lbbExtend.second;
573 localBB.second.second = lbbExtend.first;
576 MPI_Allgather(&localBB,
577 sizeof(std::pair<
INT, std::pair<point_type, point_type>>),
579 sizeof(std::pair<
INT, std::pair<point_type, point_type>>),
580 MPI_BYTE, local_world);
584 for (
auto xGlobalBB : globalBB) {
585 std::cout <<
"MUI [sampler_rbf.h]: globalBBs: " << xGlobalBB.first <<
" "
586 << xGlobalBB.second.first[0] <<
" "
587 << xGlobalBB.second.first[1] <<
" "
588 << xGlobalBB.second.second[0] <<
" "
589 << xGlobalBB.second.second[1] <<
" at rank "
595 std::vector<std::pair<INT, INT>> ghostPointsCountToSend;
596 for (
auto xGlobalBB : globalBB) {
597 if (xGlobalBB.first == local_rank)
599 ghostPointsCountToSend.push_back(std::make_pair(xGlobalBB.first, 0));
603 std::vector<std::pair<INT, std::vector<point_type>>> ghostPointsToSend;
604 for (
size_t i = 0; i <
pts_.size(); ++i) {
605 for (
auto xGlobalBB : globalBB) {
606 if (xGlobalBB.first == local_rank)
611 if ((
pts_[i][0] <= xGlobalBB.second.first[0])
612 && (
pts_[i][0] >= xGlobalBB.second.second[0])) {
614 auto ghostPointsToSendIter =
615 std::find_if(ghostPointsToSend.begin(),
616 ghostPointsToSend.end(),
617 [xGlobalBB](std::pair<
INT, std::vector<point_type>> b) {
618 return b.first == xGlobalBB.first;
621 auto ghostPointsCountToSendIter = std::find_if(
622 ghostPointsCountToSend.begin(),
623 ghostPointsCountToSend.end(),
624 [xGlobalBB](std::pair<INT, INT> b) {
625 return b.first == xGlobalBB.first;
628 if (ghostPointsToSendIter
629 == std::end(ghostPointsToSend)) {
630 std::vector<point_type> vecPointTemp {
pts_[i] };
631 ghostPointsToSend.push_back(std::make_pair(xGlobalBB.first, vecPointTemp));
634 ghostPointsToSendIter->second.push_back(
pts_[i]);
636 assert(ghostPointsCountToSendIter != std::end(ghostPointsCountToSend));
638 ++ghostPointsCountToSendIter->second;
643 if ((
pts_[i][0] <= xGlobalBB.second.first[0])
644 && (
pts_[i][0] >= xGlobalBB.second.second[0])
645 && (
pts_[i][1] <= xGlobalBB.second.first[1])
646 && (
pts_[i][1] >= xGlobalBB.second.second[1])) {
648 auto ghostPointsToSendIter =
649 std::find_if(ghostPointsToSend.begin(),
650 ghostPointsToSend.end(),
651 [xGlobalBB](std::pair<
INT, std::vector<point_type>> b) {
652 return b.first == xGlobalBB.first;
655 auto ghostPointsCountToSendIter = std::find_if(
656 ghostPointsCountToSend.begin(),
657 ghostPointsCountToSend.end(),
658 [xGlobalBB](std::pair<INT, INT> b) {
659 return b.first == xGlobalBB.first;
662 if (ghostPointsToSendIter
663 == std::end(ghostPointsToSend)) {
664 std::vector<point_type> vecPointTemp {
pts_[i] };
665 ghostPointsToSend.push_back(std::make_pair(xGlobalBB.first, vecPointTemp));
668 ghostPointsToSendIter->second.push_back(
pts_[i]);
670 assert(ghostPointsCountToSendIter != std::end(ghostPointsCountToSend));
672 ++ghostPointsCountToSendIter->second;
677 if ((
pts_[i][0] <= xGlobalBB.second.first[0])
678 && (
pts_[i][0] >= xGlobalBB.second.second[0])
679 && (
pts_[i][1] <= xGlobalBB.second.first[1])
680 && (
pts_[i][1] >= xGlobalBB.second.second[1])
681 && (
pts_[i][2] <= xGlobalBB.second.first[2])
682 && (
pts_[i][2] >= xGlobalBB.second.second[2])) {
684 auto ghostPointsToSendIter =
685 std::find_if(ghostPointsToSend.begin(),
686 ghostPointsToSend.end(),
687 [xGlobalBB](std::pair<
INT, std::vector<point_type>> b) {
688 return b.first == xGlobalBB.first;
691 auto ghostPointsCountToSendIter = std::find_if(
692 ghostPointsCountToSend.begin(),
693 ghostPointsCountToSend.end(),
694 [xGlobalBB](std::pair<INT, INT> b) {
695 return b.first == xGlobalBB.first;
698 if (ghostPointsToSendIter
699 == std::end(ghostPointsToSend)) {
700 std::vector<point_type> vecPointTemp {
pts_[i] };
701 ghostPointsToSend.push_back(std::make_pair(xGlobalBB.first, vecPointTemp));
704 ghostPointsToSendIter->second.push_back(
pts_[i]);
706 assert(ghostPointsCountToSendIter != std::end(ghostPointsCountToSend));
708 ++ghostPointsCountToSendIter->second;
713 throw "MUI Error [sampler_rbf.h]: Invalid value of CONFIG::D exception";
716 catch (
const char *msg) {
717 std::cerr << msg << std::endl;
724 std::cout <<
"MUI [sampler_rbf.h]: Total size of GhostPointsToSend "
725 << ghostPointsToSend.size() <<
" at rank " << local_rank
727 for (
auto xGhostPointsToSend : ghostPointsToSend) {
728 std::cout <<
"MUI [sampler_rbf.h]: xGhostPointsToSend to rank "
729 << xGhostPointsToSend.first <<
" at rank " << local_rank
731 for (
auto xVectPts : xGhostPointsToSend.second) {
732 std::cout <<
"MUI [sampler_rbf.h]: " << xVectPts[0] <<
" " << xVectPts[1]
733 <<
" at rank " << local_rank << std::endl;
736 for (
auto xGhostPointsCountToSend : ghostPointsCountToSend) {
737 std::cout <<
"MUI [sampler_rbf.h]: xGhostPointsCountToSend to rank "
738 << xGhostPointsCountToSend.first <<
" has "
739 << xGhostPointsCountToSend.second
744 return std::make_pair(ghostPointsCountToSend, ghostPointsToSend);
749 std::vector<std::pair<INT, INT>> ghostPointsCountToSend,
750 std::vector<std::pair<
INT, std::vector<point_type>>> ghostPointsToSend,
751 MPI_Comm local_world,
int local_rank)
const {
752 std::vector<point_type> ptsGhost;
753 std::vector<std::pair<INT, INT>> ghostPointsCountToRecv;
754 for (
auto xGhostPointsCountToSend : ghostPointsCountToSend) {
755 assert(xGhostPointsCountToSend.first != local_rank);
756 assert(xGhostPointsCountToSend.second >= 0);
759 MPI_Send(&xGhostPointsCountToSend.second, 1, MPI_INT,
760 xGhostPointsCountToSend.first, 0, local_world);
761 int pointsCountTemp = -1;
762 MPI_Recv(&pointsCountTemp, 1, MPI_INT,
763 xGhostPointsCountToSend.first, 0, local_world,
765 assert(pointsCountTemp >= 0);
766 ghostPointsCountToRecv.push_back(
767 std::make_pair(xGhostPointsCountToSend.first,
771 if (xGhostPointsCountToSend.second != 0) {
772 auto ghostPointsToSendIter = std::find_if(
773 ghostPointsToSend.begin(), ghostPointsToSend.end(),
774 [xGhostPointsCountToSend](
775 std::pair<
INT, std::vector<point_type>> b) {
776 return b.first == xGhostPointsCountToSend.first;
779 assert(ghostPointsToSendIter->second.size() ==
static_cast<size_t>(xGhostPointsCountToSend.second));
781 int buffer_size = ghostPointsToSendIter->second.size() *
sizeof(
point_type);
782 char *buffer =
new char[buffer_size];
784 for (
auto &pointElement : ghostPointsToSendIter->second) {
785 MPI_Pack(&pointElement,
sizeof(
point_type), MPI_BYTE,
786 buffer, buffer_size, &position, local_world);
788 MPI_Send(buffer, position, MPI_PACKED, xGhostPointsCountToSend.first, 1, local_world);
793 for (
auto xsend : ghostPointsToSendIter->second) {
794 std::cout <<
"MUI [sampler_rbf.h]: Send ghost point to rank "
795 << xGhostPointsCountToSend.first
796 <<
" with value of " << xsend[0] <<
" "
797 << xsend[1] <<
" at rank " << local_rank
804 auto ghostPointsCountToRecvIter = std::find_if(
805 ghostPointsCountToRecv.begin(),
806 ghostPointsCountToRecv.end(),
807 [xGhostPointsCountToSend](std::pair<INT, INT> b) {
808 return b.first == xGhostPointsCountToSend.first;
811 if (ghostPointsCountToRecvIter->second != 0) {
812 std::vector<point_type> vecPointTemp;
814 MPI_Probe(ghostPointsCountToRecvIter->first, 1, local_world,
817 MPI_Get_count(&status, MPI_PACKED, &buffer_size);
818 char *buffer =
new char[buffer_size];
819 MPI_Recv(buffer, buffer_size, MPI_PACKED,
820 ghostPointsCountToRecvIter->first, 1, local_world,
824 MPI_Get_elements(&status, MPI_BYTE, &count);
825 vecPointTemp.resize(count /
sizeof(
point_type));
826 for (
auto &pointElement : vecPointTemp) {
827 MPI_Unpack(buffer, buffer_size, &position, &pointElement,
831 for (
auto xvecPointTemp : vecPointTemp) {
832 ptsGhost.emplace_back(xvecPointTemp);
835 std::cout <<
"MUI [sampler_rbf.h]: Receive ghost point from rank "
836 << ghostPointsCountToRecvIter->first
837 <<
" with value of " << xvecPointTemp[0] <<
" "
838 << xvecPointTemp[1] <<
" at rank " << local_rank
852 std::pair<std::vector<std::pair<INT, INT>>, std::vector<std::pair<INT, std::vector<point_type>>>>
858 std::cout <<
"MUI [sampler_rbf.h]: Local bounding box: " << lbb.second[0] <<
" "
859 << lbb.second[1] <<
" " << lbb.first[0] <<
" "
861 <<
" out of total ranks " <<
local_size_ << std::endl;
862 std::cout <<
"MUI [sampler_rbf.h]: Extended local bounding box: "
863 << lbbExtend.second[0] <<
" " << lbbExtend.second[1]
864 <<
" " << lbbExtend.first[0] <<
" "
865 << lbbExtend.first[1] <<
" at rank " <<
local_rank_
866 <<
" out of total ranks " <<
local_size_ << std::endl;
874 template<
template<
typename,
typename >
class CONTAINER>
875 REAL computeRBFtransformationMatrix(
const CONTAINER<ITYPE, CONFIG> &data_points,
const std::string &fileAddress)
const {
876 bool writeMatrix = !fileAddress.empty();
891 if (data_points.size() <
N_sp_)
892 N_sp_ = data_points.size();
895 N_sp_ = data_points.size();
903 REAL errorReturn = 0;
906 buildConnectivityConservative(data_points,
N_sp_, writeMatrix, fileAddress);
908 buildConnectivityConsistent(data_points,
N_sp_, writeMatrix, fileAddress);
914 buildConnectivitySmooth(
M_ap_, writeMatrix, fileAddress);
920 std::ofstream outputFileMatrixSize(fileAddress +
"/matrixSize.dat");
922 if (!outputFileMatrixSize) {
924 <<
"MUI Error [sampler_rbf.h]: Could not locate the file address of matrixSize.dat!"
929 <<
"// *********************************************************************************************************************************************";
930 outputFileMatrixSize <<
"\n";
932 <<
"// **** This is the 'matrixSize.dat' file of the RBF spatial sampler of the MUI library";
933 outputFileMatrixSize <<
"\n";
935 <<
"// **** This file contains the size (number of rows and number of columns) of the Point Connectivity Matrix (N) and the Coupling Matrix (H).";
936 outputFileMatrixSize <<
"\n";
938 <<
"// **** The file uses the Comma-Separated Values (CSV) format and the ASCII format with the meanings as follows: ";
939 outputFileMatrixSize <<
"\n";
941 <<
"// **** The number of rows of the Point Connectivity Matrix (N), ";
942 outputFileMatrixSize <<
"\n";
944 <<
"// **** The number of columns of the Point Connectivity Matrix (N),";
945 outputFileMatrixSize <<
"\n";
947 <<
"// **** The number of rows of the Point Connectivity Matrix (M) (for smoothing), ";
948 outputFileMatrixSize <<
"\n";
950 <<
"// **** The number of columns of the Point Connectivity Matrix (M) (for smoothing),";
951 outputFileMatrixSize <<
"\n";
953 <<
"// **** The number of rows of the Coupling Matrix (H),";
954 outputFileMatrixSize <<
"\n";
956 <<
"// **** The number of columns of the Coupling Matrix (H)";
957 outputFileMatrixSize <<
"\n";
959 <<
"// **** The size of remote points";
960 outputFileMatrixSize <<
"\n";
962 <<
"// **** The dimension of remote points";
963 outputFileMatrixSize <<
"\n";
965 <<
"// *********************************************************************************************************************************************";
966 outputFileMatrixSize <<
"\n";
967 outputFileMatrixSize <<
"// ";
968 outputFileMatrixSize <<
"\n";
970 outputFileMatrixSize <<
",";
972 outputFileMatrixSize <<
",";
975 outputFileMatrixSize <<
",";
977 outputFileMatrixSize <<
",";
980 outputFileMatrixSize <<
"0";
981 outputFileMatrixSize <<
",";
982 outputFileMatrixSize <<
"0";
983 outputFileMatrixSize <<
",";
986 outputFileMatrixSize <<
",";
988 outputFileMatrixSize <<
",";
989 outputFileMatrixSize << data_points.size();
990 outputFileMatrixSize <<
",";
991 outputFileMatrixSize << CONFIG::D;
992 outputFileMatrixSize <<
"\n";
1005 std::ofstream outputFileHMatrix(fileAddress +
"/Hmatrix.dat");
1007 if (!outputFileHMatrix) {
1009 <<
"MUI Error [sampler_rbf.h]: Could not locate the file address of Hmatrix.dat!"
1014 <<
"// ************************************************************************************************";
1015 outputFileHMatrix <<
"\n";
1017 <<
"// **** This is the 'Hmatrix.dat' file of the RBF spatial sampler of the MUI library";
1018 outputFileHMatrix <<
"\n";
1020 <<
"// **** This file contains the entire matrix of the Coupling Matrix (H).";
1021 outputFileHMatrix <<
"\n";
1023 <<
"// **** The file uses the Comma-Separated Values (CSV) format with ASCII for the entire H matrix";
1024 outputFileHMatrix <<
"\n";
1026 <<
"// ************************************************************************************************";
1027 outputFileHMatrix <<
"\n";
1028 outputFileHMatrix <<
"// ";
1029 outputFileHMatrix <<
"\n";
1030 outputFileHMatrix <<
H_;
1039 template<
template<
typename,
typename >
class CONTAINER>
1040 inline REAL buildMatrixConsistent(
const CONTAINER<ITYPE, CONFIG> &data_points,
const size_t NP,
1041 const size_t MP,
bool smoothing,
bool pou)
const {
1042 REAL errorReturn = 0;
1043 std::pair<INT, REAL> iterErrorReturn(0, 0);
1045 for (
size_t row = 0; row <
ptsExtend_.size(); row++) {
1046 linalg::sparse_matrix<INT, REAL> Css;
1047 linalg::sparse_matrix<INT, REAL> Aas;
1049 Css.resize((1 + NP + CONFIG::D), (1 + NP + CONFIG::D));
1050 Aas.resize((1 + NP + CONFIG::D), 1);
1054 linalg::sparse_matrix<INT, REAL> Css_coo((1 + NP + CONFIG::D),(1 + NP + CONFIG::D),
"COO");
1056 for (
size_t i = 0; i < NP; i++) {
1057 for (
size_t j = i; j < NP; j++) {
1062 data_points[glob_i].first
1063 - data_points[glob_j].first);
1067 Css_coo.set_value(i, j, w,
false);
1070 Css_coo.set_value(j, i, w,
false);
1077 for (
size_t i = 0; i < NP; i++) {
1078 Css_coo.set_value(i, NP, 1,
false);
1079 Css_coo.set_value(NP, i, 1,
false);
1085 for (
INT dim = 0; dim < CONFIG::D; dim++) {
1086 Css_coo.set_value(i, (NP + dim + 1),
1087 data_points[glob_i].first[dim],
false);
1090 Css_coo.set_value((NP + dim + 1), i,
1091 data_points[glob_i].first[dim],
false);
1100 linalg::sparse_matrix<INT, REAL> Aas_coo((1 + NP + CONFIG::D),1,
"COO");
1102 for (
size_t j = 0; j < NP; j++) {
1108 Aas_coo.set_value(j, 0, rbf(d),
false);
1112 Aas_coo.set_value(NP, 0, 1,
false);
1115 for (
int dim = 0; dim < CONFIG::D; dim++) {
1116 Aas_coo.set_value((NP + dim + 1), 0,
ptsExtend_[row][dim],
false);
1121 linalg::sparse_matrix<INT, REAL> H_i;
1125 iterErrorReturn = cg.solve();
1126 H_i = cg.getSolution();
1129 linalg::diagonal_preconditioner<INT, REAL> M(Css);
1131 iterErrorReturn = cg.solve();
1132 H_i = cg.getSolution();
1136 <<
"MUI Error [sampler_rbf.h]: Invalid CG Preconditioner function number ("
1138 <<
"Please set the CG Preconditioner function number (precond_) as: "
1139 << std::endl <<
"precond_=0 (No Preconditioner); "
1140 << std::endl <<
"precond_=1 (Diagonal Preconditioner); " << std::endl;
1145 std::cout <<
"MUI [sampler_rbf.h]: #iterations of H_i: " << iterErrorReturn.first
1146 <<
". Error of H_i: " << iterErrorReturn.second
1150 errorReturn += iterErrorReturn.second;
1153 for (
size_t j = 0; j < NP; j++) {
1159 for (
size_t j = 0; j < NP; j++) {
1166 errorReturn /=
static_cast<REAL>(
pts_.size());
1169 for (
size_t row = 0; row <
ptsExtend_.size(); row++) {
1170 for (
size_t j = 0; j < NP; j++) {
1175 for (
size_t k = 0; k < MP; k++) {
1177 if (row_k ==
static_cast<INT>(row)) {
1178 std::cerr <<
"MUI Error [sampler_rbf.h]: Invalid row_k value: " << row_k
1182 h_j_sum += std::pow(dist_h_i(row, row_k), -2.);
1185 for (
size_t k = 0; k < MP; k++) {
1187 if (row_k ==
static_cast<INT>(row)) {
1188 std::cerr <<
"MUI Error [sampler_rbf.h]: Invalid row_k value: " << row_k
1192 REAL w_i = ((std::pow(dist_h_i(row, row_k), -2.)) / (h_j_sum));
1202 linalg::sparse_matrix<INT,REAL> Css;
1203 linalg::sparse_matrix<INT,REAL> Aas;
1205 Css.resize((1 + data_points.size() + CONFIG::D), (1 + data_points.size() + CONFIG::D));
1206 Aas.resize(
ptsExtend_.size(), (1 + data_points.size() + CONFIG::D));
1210 linalg::sparse_matrix<INT, REAL> Css_coo((1 + data_points.size() + CONFIG::D),(1 + data_points.size() + CONFIG::D),
"COO");
1212 for (
size_t i = 0; i < data_points.size(); i++ ) {
1213 for (
size_t j = i; j < data_points.size(); j++ ) {
1214 auto d =
norm(data_points[i].first - data_points[j].first);
1218 Css_coo.set_value((i + CONFIG::D + 1), (j + CONFIG::D + 1), w,
false);
1222 Css_coo.set_value((j + CONFIG::D + 1), (i + CONFIG::D + 1), w,
false);
1231 linalg::sparse_matrix<INT, REAL> Aas_coo(
ptsExtend_.size(),(1 + data_points.size() + CONFIG::D),
"COO");
1233 for (
size_t i = 0; i <
ptsExtend_.size(); i++ ) {
1234 for (
size_t j = 0; j < data_points.size(); j++ ) {
1239 Aas_coo.set_value(i, (j + CONFIG::D + 1), rbf(d),
false);
1246 linalg::sparse_matrix<INT,REAL> Aas_trans = Aas.transpose();
1248 linalg::sparse_matrix<INT, REAL> H_more;
1252 iterErrorReturn = cg.solve();
1253 H_more = cg.getSolution();
1256 linalg::diagonal_preconditioner<INT, REAL> M(Css);
1258 iterErrorReturn = cg.solve();
1259 H_more = cg.getSolution();
1263 <<
"MUI Error [sampler_rbf.h]: Invalid CG Preconditioner function number ("
1265 <<
"Please set the CG Preconditioner function number (precond_) as: "
1266 << std::endl <<
"precond_=0 (No Preconditioner); "
1267 << std::endl <<
"precond_=1 (Diagonal Preconditioner); " << std::endl;
1272 std::cout <<
"MUI [sampler_rbf.h]: #iterations of H_more: " << iterErrorReturn.first
1273 <<
". Error of H_more: " << iterErrorReturn.second
1277 errorReturn = iterErrorReturn.second;
1280 for (
size_t i = 0; i < data_points.size(); i++ ) {
1281 for (
size_t j = 0; j <
ptsExtend_.size(); j++ ) {
1287 for (
size_t i = 0; i < data_points.size(); i++ ) {
1288 for (
size_t j = 0; j <
ptsExtend_.size(); j++ ) {
1289 H_.
set_value(j, i, H_more.get_value((i + CONFIG::D + 1), j));
1295 for (
size_t row = 0; row <
ptsExtend_.size(); row++ ) {
1296 for (
size_t j = 0; j < data_points.size(); j++ ) {
1299 for (
size_t k = 0; k < MP; k++ ) {
1301 if ( row_k ==
static_cast<INT>(row) )
1302 std::cerr <<
"Invalid row_k value: " << row_k << std::endl;
1304 h_j_sum += std::pow(dist_h_i(row, row_k), -2.);
1307 for (
size_t k = 0; k < MP; k++ ) {
1309 if ( row_k ==
static_cast<INT>(row) )
1310 std::cerr <<
"Invalid row_k value: " << row_k << std::endl;
1312 REAL w_i = ((std::pow(dist_h_i(row, row_k), -2.)) / (h_j_sum));
1325 template<
template<
typename,
typename >
class CONTAINER>
1326 inline REAL buildMatrixConservative(
1327 const CONTAINER<ITYPE, CONFIG> &data_points,
const size_t NP,
1328 const size_t MP,
bool smoothing,
bool pou)
const {
1329 REAL errorReturn = 0;
1330 std::pair<INT, REAL> iterErrorReturn(0, 0);
1332 for (
size_t row = 0; row < data_points.size(); row++) {
1333 linalg::sparse_matrix<INT, REAL> Css;
1334 linalg::sparse_matrix<INT, REAL> Aas;
1336 Css.resize((1 + NP + CONFIG::D), (1 + NP + CONFIG::D));
1337 Aas.resize((1 + NP + CONFIG::D), 1);
1341 linalg::sparse_matrix<INT, REAL> Css_coo((1 + NP + CONFIG::D),(1 + NP + CONFIG::D),
"COO");
1343 for (
size_t i = 0; i < NP; i++) {
1344 for (
size_t j = i; j < NP; j++) {
1352 Css_coo.set_value(i, j, w,
false);
1355 Css_coo.set_value(j, i, w,
false);
1362 for (
size_t i = 0; i < NP; i++) {
1363 Css_coo.set_value(i, NP, 1,
false);
1365 Css_coo.set_value(NP, i, 1,
false);
1370 for (
INT dim = 0; dim < CONFIG::D; dim++) {
1371 Css_coo.set_value(i, (NP + dim + 1),
ptsExtend_[glob_i][dim],
false);
1373 Css_coo.set_value((NP + dim + 1), i,
ptsExtend_[glob_i][dim],
false);
1382 linalg::sparse_matrix<INT, REAL> Aas_coo((1 + NP + CONFIG::D),1,
"COO");
1384 for (
size_t j = 0; j < NP; j++) {
1390 Aas_coo.set_value(j, 0, rbf(d),
false);
1395 Aas_coo.set_value(NP, 0, 1,
false);
1398 for (
int dim = 0; dim < CONFIG::D; dim++) {
1399 Aas_coo.set_value((NP + dim + 1), 0, data_points[row].first[dim],
false);
1404 linalg::sparse_matrix<INT, REAL> H_i;
1408 iterErrorReturn = cg.solve();
1409 H_i = cg.getSolution();
1412 linalg::diagonal_preconditioner<INT, REAL> M(Css);
1414 iterErrorReturn = cg.solve();
1415 H_i = cg.getSolution();
1419 <<
"MUI Error [sampler_rbf.h]: Invalid CG Preconditioner function number ("
1421 <<
"Please set the CG Preconditioner function number (precond_) as: "
1422 << std::endl <<
"precond_=0 (No Preconditioner); "
1423 << std::endl <<
"precond_=1 (Diagonal Preconditioner); " << std::endl;
1428 std::cout <<
"MUI [sampler_rbf.h]: #iterations of H_i: " << iterErrorReturn.first
1429 <<
". Error of H_i: " << iterErrorReturn.second
1433 errorReturn += iterErrorReturn.second;
1436 for (
size_t j = 0; j < NP; j++) {
1442 for (
size_t j = 0; j < NP; j++) {
1449 errorReturn /=
static_cast<REAL>(data_points.size());
1452 for (
size_t row = 0; row < data_points.size(); row++) {
1453 for (
size_t j = 0; j < NP; j++) {
1458 for (
size_t k = 0; k < MP; k++) {
1460 if (row_k ==
static_cast<INT>(row_i)) {
1461 std::cerr <<
"MUI Error [sampler_rbf.h]: Invalid row_k value: " << row_k
1465 h_j_sum += std::pow(dist_h_i(row_i, row_k), -2.);
1468 for (
size_t k = 0; k < MP; k++) {
1470 if (row_k ==
static_cast<INT>(row_i)) {
1471 std::cerr <<
"MUI Error [sampler_rbf.h]: Invalid row_k value: " << row_k
1475 REAL w_i = ((std::pow(dist_h_i(row_i, row_k), -2.))
1487 linalg::sparse_matrix<INT,REAL> Css;
1488 linalg::sparse_matrix<INT,REAL> Aas;
1491 Aas.resize(data_points.size(), (1 +
ptsExtend_.size() + CONFIG::D));
1495 linalg::sparse_matrix<INT, REAL> Css_coo((1 +
ptsExtend_.size() + CONFIG::D),(1 +
ptsExtend_.size() + CONFIG::D),
"COO");
1497 for (
size_t i = 0; i <
ptsExtend_.size(); i++ ) {
1498 for (
size_t j = i; j <
ptsExtend_.size(); j++ ) {
1503 Css_coo.set_value((i + CONFIG::D + 1), (j + CONFIG::D + 1), w,
false);
1507 Css_coo.set_value((j + CONFIG::D + 1), (i + CONFIG::D + 1), w,
false);
1517 linalg::sparse_matrix<INT, REAL> Aas_coo(data_points.size(),(1 +
ptsExtend_.size() + CONFIG::D),
"COO");
1519 for (
size_t i = 0; i < data_points.size(); i++ ) {
1520 for (
size_t j = 0; j <
ptsExtend_.size(); j++ ) {
1524 Aas_coo.set_value(i, (j + CONFIG::D + 1), rbf(d),
false);
1531 linalg::sparse_matrix<INT,REAL> Aas_trans = Aas.transpose();
1533 linalg::sparse_matrix<INT, REAL> H_more;
1537 iterErrorReturn = cg.solve();
1538 H_more = cg.getSolution();
1541 linalg::diagonal_preconditioner<INT, REAL> M(Css);
1543 iterErrorReturn = cg.solve();
1544 H_more = cg.getSolution();
1548 <<
"MUI Error [sampler_rbf.h]: Invalid CG Preconditioner function number ("
1550 <<
"Please set the CG Preconditioner function number (precond_) as: "
1551 << std::endl <<
"precond_=0 (No Preconditioner); "
1552 << std::endl <<
"precond_=1 (Diagonal Preconditioner); " << std::endl;
1557 std::cout <<
"MUI [sampler_rbf.h]: #iterations of H_more: " << iterErrorReturn.first
1558 <<
". Error of H_more: " << iterErrorReturn.second
1562 errorReturn = iterErrorReturn.second;
1565 for (
size_t i = 0; i <
ptsExtend_.size(); i++ ) {
1566 for (
size_t j = 0; j < data_points.size(); j++ ) {
1572 for (
size_t i = 0; i <
ptsExtend_.size(); i++ ) {
1573 for (
size_t j = 0; j < data_points.size(); j++ ) {
1574 H_.
set_value(i, j, H_more.get_value((i + CONFIG::D + 1), j));
1580 for (
size_t row = 0; row <
ptsExtend_.size(); row++ ) {
1581 for (
size_t j = 0; j < data_points.size(); j++ ) {
1584 for (
size_t k = 0; k < MP; k++ ) {
1586 if ( row_k ==
static_cast<INT>(row) )
1587 std::cerr <<
"Invalid row_k value: " << row_k << std::endl;
1589 h_j_sum += std::pow(dist_h_i(row, row_k), -2.);
1592 for (
size_t k = 0; k < MP; k++ ) {
1594 if ( row_k ==
static_cast<INT>(row) )
1595 std::cerr <<
"Invalid row_k value: " << row_k << std::endl;
1597 REAL w_i = ((std::pow(dist_h_i(row, row_k), -2.)) / (h_j_sum));
1610 template<
template<
typename,
typename >
class CONTAINER>
1611 inline void buildConnectivityConsistent(
const CONTAINER<ITYPE, CONFIG> &data_points,
const size_t NP,
bool writeMatrix,
1612 const std::string& fileAddress)
const {
1613 std::ofstream outputFileCAB;
1614 std::ofstream outputFileRemotePoints;
1616 outputFileCAB.open(fileAddress +
"/connectivityAB.dat");
1618 if (!outputFileCAB) {
1620 <<
"MUI Error [sampler_rbf.h]: Could not locate the file address on the connectivityAB.dat"
1625 <<
"// ************************************************************************************************";
1626 outputFileCAB <<
"\n";
1628 <<
"// **** This is the 'connectivityAB.dat' file of the RBF spatial sampler of the MUI library";
1629 outputFileCAB <<
"\n";
1631 <<
"// **** This file contains the entire matrix of the Point Connectivity Matrix (N).";
1632 outputFileCAB <<
"\n";
1634 <<
"// **** The file uses the Comma-Separated Values (CSV) format with ASCII for the entire N matrix";
1635 outputFileCAB <<
"\n";
1637 <<
"// ************************************************************************************************";
1638 outputFileCAB <<
"\n";
1639 outputFileCAB <<
"// ";
1640 outputFileCAB <<
"\n";
1643 outputFileRemotePoints.open(fileAddress +
"/remotePoints.dat");
1645 if (!outputFileRemotePoints) {
1647 <<
"MUI Error [sampler_rbf.h]: Could not locate the file address on the remotePoints.dat"
1651 outputFileRemotePoints
1652 <<
"// ************************************************************************************************";
1653 outputFileRemotePoints <<
"\n";
1654 outputFileRemotePoints
1655 <<
"// **** This is the 'remotePoints.dat' file of the RBF spatial sampler of the MUI library";
1656 outputFileRemotePoints <<
"\n";
1657 outputFileRemotePoints
1658 <<
"// **** This file contains the remote points in the correct order that build the coupling matrix H.";
1659 outputFileRemotePoints <<
"\n";
1660 outputFileRemotePoints
1661 <<
"// **** The file uses the Comma-Separated Values (CSV) format with ASCII for the entire N matrix";
1662 outputFileRemotePoints <<
"\n";
1663 outputFileRemotePoints
1664 <<
"// ************************************************************************************************";
1665 outputFileRemotePoints <<
"\n";
1666 outputFileRemotePoints <<
"// ";
1667 outputFileRemotePoints <<
"\n";
1673 for (
size_t i = 0; i <
ptsExtend_.size(); i++) {
1674 INT pointsCount = 0;
1675 for (
size_t n = 0; n < NP; n++) {
1678 for (
size_t j = 0; j < data_points.size(); j++) {
1681 return static_cast<size_t>(k) == j;
1693 if (n == 0 && d <
twor_)
1699 if (writeMatrix && (n < NP - 1))
1700 outputFileCAB << bestj <<
",";
1701 else if (writeMatrix)
1702 outputFileCAB << bestj;
1705 if (writeMatrix && i <
ptsExtend_.size() - 1)
1706 outputFileCAB <<
'\n';
1709 for (
size_t i = 0; i < data_points.size(); i++) {
1712 for (
INT dim = 0; dim < CONFIG::D; dim++) {
1713 pointTemp[dim] = data_points[i].first[dim];
1719 for (
INT dim = 0; dim < CONFIG::D; dim++) {
1721 if (dim == (CONFIG::D - 1)) {
1722 outputFileRemotePoints <<
'\n';
1724 outputFileRemotePoints <<
",";
1731 outputFileCAB.close();
1732 outputFileRemotePoints.close();
1736 template<
template<
typename,
typename >
class CONTAINER>
1737 inline void buildConnectivityConservative(
const CONTAINER<ITYPE, CONFIG> &data_points,
const size_t NP,
bool writeMatrix,
1738 const std::string& fileAddress)
const {
1739 std::ofstream outputFileCAB;
1740 std::ofstream outputFileRemotePoints;
1742 outputFileCAB.open(fileAddress +
"/connectivityAB.dat");
1744 if (!outputFileCAB) {
1746 <<
"MUI Error [sampler_rbf.h]: Could not locate the file address on the connectivityAB.dat"
1751 <<
"// ************************************************************************************************";
1752 outputFileCAB <<
"\n";
1754 <<
"// **** This is the 'connectivityAB.dat' file of the RBF spatial sampler of the MUI library";
1755 outputFileCAB <<
"\n";
1757 <<
"// **** This file contains the entire matrix of the Point Connectivity Matrix (N).";
1758 outputFileCAB <<
"\n";
1760 <<
"// **** The file uses the Comma-Separated Values (CSV) format with ASCII for the entire N matrix";
1761 outputFileCAB <<
"\n";
1763 <<
"// ************************************************************************************************";
1764 outputFileCAB <<
"\n";
1765 outputFileCAB <<
"// ";
1766 outputFileCAB <<
"\n";
1769 outputFileRemotePoints.open(fileAddress +
"/remotePoints.dat");
1771 if (!outputFileRemotePoints) {
1773 <<
"MUI Error [sampler_rbf.h]: Could not locate the file address on the remotePoints.dat"
1777 outputFileRemotePoints
1778 <<
"// ************************************************************************************************";
1779 outputFileRemotePoints <<
"\n";
1780 outputFileRemotePoints
1781 <<
"// **** This is the 'remotePoints.dat' file of the RBF spatial sampler of the MUI library";
1782 outputFileRemotePoints <<
"\n";
1783 outputFileRemotePoints
1784 <<
"// **** This file contains the remote points in the correct order that build the coupling matrix H.";
1785 outputFileRemotePoints <<
"\n";
1786 outputFileRemotePoints
1787 <<
"// **** The file uses the Comma-Separated Values (CSV) format with ASCII for the entire N matrix";
1788 outputFileRemotePoints <<
"\n";
1789 outputFileRemotePoints
1790 <<
"// ************************************************************************************************";
1791 outputFileRemotePoints <<
"\n";
1792 outputFileRemotePoints <<
"// ";
1793 outputFileRemotePoints <<
"\n";
1799 for (
size_t i = 0; i < data_points.size(); i++) {
1800 INT pointsCount = 0;
1801 for (
size_t n = 0; n < NP; n++) {
1804 for (
size_t j = 0; j <
ptsExtend_.size(); j++) {
1807 return static_cast<size_t>(k) == j;
1819 if (n == 0 && d <
twor_)
1825 if (writeMatrix && n < NP - 1)
1826 outputFileCAB << bestj <<
",";
1827 else if (writeMatrix)
1828 outputFileCAB << bestj;
1831 if (writeMatrix && i <
ptsExtend_.size() - 1)
1832 outputFileCAB <<
'\n';
1835 for (
INT dim = 0; dim < CONFIG::D; dim++) {
1836 pointTemp[dim] = data_points[i].first[dim];
1841 for (
INT dim = 0; dim < CONFIG::D; dim++) {
1843 if (dim == (CONFIG::D - 1)) {
1844 outputFileRemotePoints <<
'\n';
1846 outputFileRemotePoints <<
",";
1853 outputFileCAB.close();
1854 outputFileRemotePoints.close();
1858 void buildConnectivitySmooth(
const size_t MP,
bool writeMatrix,
const std::string& fileAddress)
const {
1859 std::ofstream outputFileCAA;
1862 outputFileCAA.open(fileAddress +
"/connectivityAA.dat");
1864 if (!outputFileCAA) {
1866 <<
"MUI Error [sampler_rbf.h]: Could not locate the file address on the connectivityAA.dat!"
1871 <<
"// ************************************************************************************************";
1872 outputFileCAA <<
"\n";
1874 <<
"// **** This is the 'connectivityAA.dat' file of the RBF spatial sampler of the MUI library";
1875 outputFileCAA <<
"\n";
1877 <<
"// **** This file contains the entire matrix of the Point Connectivity Matrix (M) (for smoothing).";
1878 outputFileCAA <<
"\n";
1880 <<
"// **** The file uses the Comma-Separated Values (CSV) format with ASCII for the entire N matrix";
1881 outputFileCAA <<
"\n";
1883 <<
"// ************************************************************************************************";
1884 outputFileCAA <<
"\n";
1885 outputFileCAA <<
"// ";
1886 outputFileCAA <<
"\n";
1892 for (
size_t i = 0; i <
ptsExtend_.size(); i++) {
1893 for (
size_t n = 0; n < MP; n++) {
1896 for (
size_t j = 0; j <
ptsExtend_.size(); j++) {
1902 return static_cast<size_t>(i) == j;
1917 if (writeMatrix && n < MP - 1)
1918 outputFileCAA << bestj <<
",";
1919 else if (writeMatrix)
1920 outputFileCAA << bestj;
1923 if (writeMatrix && i <
ptsExtend_.size() - 1)
1924 outputFileCAA <<
'\n';
1928 outputFileCAA.close();
1933 auto d =
norm(x1 - x2);
1942 return (d <
r_) ? std::exp(-(
s_ *
s_ * d * d)) : 0.;
1945 return std::pow((1. - d), 2.);
1948 return (std::pow((1. - d), 4.)) * ((4. * d) + 1.);
1951 return (std::pow((1. - d), 6)) * ((35. * d * d) + (18. * d) + 3.);
1954 return (std::pow((1. - d), 8.))
1955 * ((32. * d * d * d) + (25. * d * d) + (8. * d) + 1.);
1958 <<
"MUI Error [sampler_rbf.h]: invalid RBF basis function number ("
1960 <<
"Please set the RBF basis function number (basisFunc_) as: "
1961 << std::endl <<
"basisFunc_=0 (Gaussian); " << std::endl
1962 <<
"basisFunc_=1 (Wendland's C0); " << std::endl
1963 <<
"basisFunc_=2 (Wendland's C2); " << std::endl
1964 <<
"basisFunc_=3 (Wendland's C4); " << std::endl
1965 <<
"basisFunc_=4 (Wendland's C6); " << std::endl;
1971 inline REAL dist_h_i(
INT ptsExtend_i,
INT ptsExtend_j)
const {
1972 switch (CONFIG::D) {
1974 return std::sqrt((std::pow((
ptsExtend_[ptsExtend_i][0]
1977 return std::sqrt((std::pow((
ptsExtend_[ptsExtend_i][0]
1982 return std::sqrt((std::pow((
ptsExtend_[ptsExtend_i][0]
1989 std::cerr <<
"MUI Error [sampler_rbf.h]: CONFIG::D must equal 1-3" << std::endl;
1996 const std::vector<point_type>
pts_;
Definition: geometry.h:92
ITYPE get_rows() const
Definition: matrix_io_info.h:579
void set_zero()
Definition: matrix_manipulation.h:418
void set_value(ITYPE, ITYPE, VTYPE, bool=true)
Definition: matrix_manipulation.h:292
VTYPE get_value(ITYPE, ITYPE) const
Definition: matrix_io_info.h:523
void resize(ITYPE, ITYPE)
Definition: matrix_manipulation.h:62
ITYPE get_cols() const
Definition: matrix_io_info.h:585
Definition: sampler_rbf.h:63
bool initialised_
Definition: sampler_rbf.h:2004
REAL cgSolveTol_
Definition: sampler_rbf.h:2011
I_TP ITYPE
Definition: sampler_rbf.h:67
REAL r_
Definition: sampler_rbf.h:1995
std::vector< std::vector< INT > > connectivityAA_
Definition: sampler_rbf.h:2028
std::pair< std::vector< std::pair< INT, INT > >, std::vector< std::pair< INT, std::vector< point_type > > > > getGhostPointsToSend(std::pair< point_type, point_type > lbbExtend, MPI_Comm local_world, int local_rank, int local_size) const
Definition: sampler_rbf.h:565
size_t N_sp_
Definition: sampler_rbf.h:2014
void addFetchPoint(point_type pt)
Definition: sampler_rbf.h:308
INT CABcol_
Definition: sampler_rbf.h:2007
const INT basisFunc_
Definition: sampler_rbf.h:1997
void preSetFetchPointsExtend(std::vector< point_type > &pts)
Definition: sampler_rbf.h:303
typename CONFIG::EXCEPTION EXCEPTION
Definition: sampler_rbf.h:71
std::vector< std::vector< INT > > connectivityAB_
Definition: sampler_rbf.h:2027
void addFetchPointGhost(point_type pt)
Definition: sampler_rbf.h:318
std::pair< point_type, point_type > localExtendBoundingBox(std::pair< point_type, point_type > lbb, REAL r) const
Definition: sampler_rbf.h:553
std::vector< point_type > distributeGhostPoints(std::vector< std::pair< INT, INT >> ghostPointsCountToSend, std::vector< std::pair< INT, std::vector< point_type >>> ghostPointsToSend, MPI_Comm local_world, int local_rank) const
Definition: sampler_rbf.h:748
typename CONFIG::REAL REAL
Definition: sampler_rbf.h:68
INT CAAcol_
Definition: sampler_rbf.h:2022
INT Hrow_
Definition: sampler_rbf.h:2008
int local_size_
Definition: sampler_rbf.h:2017
const std::string writeFileAddress_
Definition: sampler_rbf.h:2002
geometry::any_shape< CONFIG > support(point_type focus, REAL domain_mag) const
Definition: sampler_rbf.h:294
bool pouEnabled_
Definition: sampler_rbf.h:2010
std::vector< point_type > ptsGhost_
Definition: sampler_rbf.h:2025
void preSetFetchPoints(std::vector< point_type > &pts)
Definition: sampler_rbf.h:298
static const bool DEBUG
Definition: sampler_rbf.h:74
INT CABrow_
Definition: sampler_rbf.h:2006
const bool consistent_
Definition: sampler_rbf.h:1999
REAL twor_
Definition: sampler_rbf.h:2019
const bool conservative_
Definition: sampler_rbf.h:1998
std::vector< point_type > ptsExtend_
Definition: sampler_rbf.h:2026
INT remote_pts_num_
Definition: sampler_rbf.h:2023
INT cgMaxIter_
Definition: sampler_rbf.h:2012
typename CONFIG::point_type point_type
Definition: sampler_rbf.h:70
void readRBFMatrix(const std::string &readFileAddress) const
Definition: sampler_rbf.h:323
typename CONFIG::INT INT
Definition: sampler_rbf.h:69
size_t M_ap_
Definition: sampler_rbf.h:2015
void addFetchPointExtend(point_type pt)
Definition: sampler_rbf.h:313
linalg::sparse_matrix< INT, REAL > H_
Definition: sampler_rbf.h:2029
std::pair< point_type, point_type > localBoundingBox(const std::vector< point_type > pt) const
Definition: sampler_rbf.h:478
INT Hcol_
Definition: sampler_rbf.h:2009
REAL s_
Definition: sampler_rbf.h:2020
INT precond_
Definition: sampler_rbf.h:2003
O_TP OTYPE
Definition: sampler_rbf.h:66
OTYPE filter(point_type focus, const CONTAINER< ITYPE, CONFIG > &data_points) const
Definition: sampler_rbf.h:184
INT CAArow_
Definition: sampler_rbf.h:2021
linalg::sparse_matrix< INT, REAL > H_toSmooth_
Definition: sampler_rbf.h:2030
MPI_Comm local_mpi_comm_world_
Definition: sampler_rbf.h:2005
int local_rank_
Definition: sampler_rbf.h:2016
const bool generateMatrix_
Definition: sampler_rbf.h:2001
std::vector< point_type > remote_pts_
Definition: sampler_rbf.h:2031
INT remote_pts_dim_
Definition: sampler_rbf.h:2024
const bool smoothFunc_
Definition: sampler_rbf.h:2000
const std::vector< point_type > pts_
Definition: sampler_rbf.h:1996
sampler_rbf(REAL r, const std::vector< point_type > &pts, INT basisFunc=0, bool conservative=false, bool smoothFunc=false, bool generateMatrix=true, const std::string &writeFileAddress=std::string(), REAL cutOff=1e-9, REAL cgSolveTol=1e-6, INT cgMaxIter=0, INT pouSize=50, INT precond=1, MPI_Comm local_comm=MPI_COMM_NULL)
Definition: sampler_rbf.h:126
static const bool QUIET
Definition: sampler_rbf.h:73
void facilitateGhostPoints() const
Definition: sampler_rbf.h:848
SCALAR sum(vexpr< E, SCALAR, D > const &u)
Definition: point.h:362
SCALAR max(vexpr< E, SCALAR, D > const &u)
Definition: point.h:350
SCALAR normsq(vexpr< E, SCALAR, D > const &u)
Definition: point.h:380
SCALAR norm(vexpr< E, SCALAR, D > const &u)
Definition: point.h:386