mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-02 05:49:09 -06:00
Minor performance updates
This commit is contained in:
parent
466f1947a3
commit
9855d7340f
@ -580,13 +580,14 @@ vertcatCollapseJacs(const std::vector<AutoDiffBlock<double> >& x)
|
||||
typedef Eigen::Triplet<double> Tri;
|
||||
std::vector<Tri> t;
|
||||
t.reserve(nnz);
|
||||
{
|
||||
int block_row_start = 0;
|
||||
M jac;
|
||||
for (int elem = 0; elem < nx; ++elem) {
|
||||
int block_col_start = 0;
|
||||
if (!x[elem].derivative().empty()) {
|
||||
for (int block = 0; block < num_blocks; ++block) {
|
||||
// const ADB::M& jac = x[elem].derivative()[block];
|
||||
M jac;
|
||||
x[elem].derivative()[block].toSparse(jac);
|
||||
for (M::Index k = 0; k < jac.outerSize(); ++k) {
|
||||
for (M::InnerIterator i(jac, k); i ; ++i) {
|
||||
@ -600,13 +601,14 @@ vertcatCollapseJacs(const std::vector<AutoDiffBlock<double> >& x)
|
||||
}
|
||||
block_row_start += x[elem].size();
|
||||
}
|
||||
}
|
||||
|
||||
// Build final jacobian.
|
||||
M comb_jac = M(size, num_cols);
|
||||
comb_jac.reserve(nnz);
|
||||
comb_jac.setFromTriplets(t.begin(), t.end());
|
||||
std::vector<ADB::M> jac(1);
|
||||
jac[0] = ADB::M(comb_jac);
|
||||
jac[0] = ADB::M(std::move(comb_jac));
|
||||
|
||||
// Use move semantics to return result efficiently.
|
||||
return ADB::function(std::move(val), std::move(jac));
|
||||
|
@ -211,11 +211,13 @@ namespace Opm
|
||||
typedef Eigen::SparseMatrix<double> Sp;
|
||||
Sp structure;
|
||||
eqs[0].derivative()[0].toSparse(structure);
|
||||
for (int phase = 1; phase < np; ++phase) {
|
||||
{
|
||||
Sp s0;
|
||||
for (int phase = 1; phase < np; ++phase) {
|
||||
eqs[phase].derivative()[0].toSparse(s0);
|
||||
structure += s0;
|
||||
}
|
||||
}
|
||||
|
||||
Eigen::SparseMatrix<double, Eigen::RowMajor> s = structure;
|
||||
|
||||
|
@ -112,8 +112,7 @@ namespace Opm
|
||||
M Bu;
|
||||
fastSparseProduct(B, u, Bu);
|
||||
// J -= Bu;
|
||||
Bu = Bu * -1.0;
|
||||
J = J + Bu;
|
||||
J = J + (Bu * -1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user