11 #include "Utilities.hpp"
21 "In ComputeCtAB, B and C must be distributed, but not CtAB.");
23 const int num_rows = B.
numRows();
25 const int num_rows_A = A.NumRows();
27 MFEM_VERIFY(C.
numRows() == num_rows_A,
"");
29 mfem::Vector Bvec(num_rows);
30 mfem::Vector ABvec(num_rows_A);
34 for (
int i = 0; i < num_cols; ++i) {
35 for (
int j = 0; j < num_rows; ++j) {
39 for (
int j = 0; j < num_rows_A; ++j) {
48 const HypreParVector& B,
53 "In ComputeCtAB_vec, C must be distributed, but not CtAB_vec");
55 MFEM_VERIFY(C.
numRows() == A.NumRows(),
"");
56 MFEM_VERIFY(B.GlobalSize() == A.GetGlobalNumRows(),
"");
58 HypreParVector* AB =
new HypreParVector(B);
66 const mfem::Vector &bb_max,
67 const mfem::Vector &t,
const double limit)
71 CAROM_VERIFY(t.Size() == bb_min.Size() && bb_min.Size() == bb_max.Size());
72 CAROM_VERIFY(limit >= 0.0 && limit <= 1.0);
73 for (
int i = 0; i < t.Size(); i++)
75 double domain_limit = limit * (bb_max[i] - bb_min[i]);
76 double mesh_center = 0.5 * (bb_max[i] + bb_min[i]);
79 if (std::abs((t(i) - mesh_center)) - (0.5 * domain_limit) > 1.0e-14)
81 std::cerr <<
"Error: value of t exceeds domain limit: t = " << t(
82 i) <<
", limit = " << 0.5 * domain_limit <<
"\n";
89 const double &fraction)
92 CAROM_VERIFY(fraction <= 1.0 && fraction >= -1.0);
93 return bb_min + (fraction + 1.0) * ((bb_max - bb_min) * 0.5);
100 CAROM_VERIFY(value <= bb_max && value >= bb_min);
101 return -1.0 + (value - bb_min) * ((2.0) / (bb_max - bb_min));
bool distributed() const
Returns true if the Matrix is distributed.
int numColumns() const
Returns the number of columns in the Matrix. This method will return the same value from each process...
Matrix * transposeMult(const Matrix &other) const
Multiplies the transpose of this Matrix with other and returns the product, reference version.
int numRows() const
Returns the number of rows of the Matrix on this processor.
bool distributed() const
Returns true if the Vector is distributed.
double map_to_ref_mesh(const double &bb_min, const double &bb_max, const double &fraction)
Maps a value from [-1, 1] to the corresponding mesh domain [bb_min, bb_max].
void ComputeCtAB(const HypreParMatrix &A, const CAROM::Matrix &B, const CAROM::Matrix &C, CAROM::Matrix &CtAB)
This function computes a reduced, non-distributed matrix C^t AB stored identically (redundantly) on e...
void ComputeCtAB_vec(const HypreParMatrix &A, const HypreParVector &B, const CAROM::Matrix &C, CAROM::Vector &CtAB_vec)
This function computes a reduced, non-distributed vector C^t AB stored identically (redundantly) on e...
double map_from_ref_mesh(const double &bb_min, const double &bb_max, const double &value)
Maps a value within mesh domain [bb_min, bb_max] to the corresponding value between [-1,...
void verify_within_portion(const mfem::Vector &bb_min, const mfem::Vector &bb_max, const mfem::Vector &t, const double limit)
Helper function to ensure that t is within a given percentage of the domain relative to the center of...