mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
AutoDiffBlock: revert changes in operator /.
equalSparsityPattern: also include outer index in check.
This commit is contained in:
parent
23036e8096
commit
75ffd897da
@ -342,7 +342,6 @@ namespace Opm
|
|||||||
jac[block] = D2*jac_[block];
|
jac[block] = D2*jac_[block];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//jac[block] = D2*jac_[block] + D1*rhs.jac_[block];
|
|
||||||
jac[block] = D2*jac_[block];
|
jac[block] = D2*jac_[block];
|
||||||
jac[block] += D1*rhs.jac_[block];
|
jac[block] += D1*rhs.jac_[block];
|
||||||
}
|
}
|
||||||
@ -368,8 +367,6 @@ namespace Opm
|
|||||||
M D1(val_.matrix().asDiagonal());
|
M D1(val_.matrix().asDiagonal());
|
||||||
M D2(rhs.val_.matrix().asDiagonal());
|
M D2(rhs.val_.matrix().asDiagonal());
|
||||||
M D3((1.0/(rhs.val_*rhs.val_)).matrix().asDiagonal());
|
M D3((1.0/(rhs.val_*rhs.val_)).matrix().asDiagonal());
|
||||||
M D4;
|
|
||||||
M D5;
|
|
||||||
#pragma omp parallel for schedule(dynamic)
|
#pragma omp parallel for schedule(dynamic)
|
||||||
for (int block = 0; block < num_blocks; ++block) {
|
for (int block = 0; block < num_blocks; ++block) {
|
||||||
assert(jac_[block].rows() == rhs.jac_[block].rows());
|
assert(jac_[block].rows() == rhs.jac_[block].rows());
|
||||||
@ -378,31 +375,14 @@ namespace Opm
|
|||||||
jac[block] = M( D3.rows(), jac_[block].cols() );
|
jac[block] = M( D3.rows(), jac_[block].cols() );
|
||||||
}
|
}
|
||||||
else if( jac_[block].nonZeros() == 0 ) {
|
else if( jac_[block].nonZeros() == 0 ) {
|
||||||
#pragma omp critical
|
jac[block] = D3 * ( D1*rhs.jac_[block]) * (-1.0);
|
||||||
if( D4.rows() == 0 ) {
|
|
||||||
D4 = D3 * D1 * (-1.0);
|
|
||||||
}
|
|
||||||
jac[block] = D4*rhs.jac_[block];
|
|
||||||
}
|
}
|
||||||
else if ( rhs.jac_[block].nonZeros() == 0 )
|
else if ( rhs.jac_[block].nonZeros() == 0 )
|
||||||
{
|
{
|
||||||
#pragma omp critical
|
jac[block] = D3 * (D2*jac_[block]);
|
||||||
if( D5.rows() == 0 ) {
|
|
||||||
D5 = D3 * D2 ;
|
|
||||||
}
|
|
||||||
jac[block] = D5*jac_[block];
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#pragma omp critical
|
jac[block] = D3 * (D2*jac_[block] + (D1*rhs.jac_[block]*(-1.0)));
|
||||||
if( D4.rows() == 0 ) {
|
|
||||||
D4 = D3 * D1 * (-1.0);
|
|
||||||
}
|
|
||||||
#pragma omp critical
|
|
||||||
if( D5.rows() == 0 ) {
|
|
||||||
D5 = D3 * D2 ;
|
|
||||||
}
|
|
||||||
jac[block] = D5*jac_[block];
|
|
||||||
jac[block] += D4*rhs.jac_[block];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return function(val_ / rhs.val_, std::move(jac));
|
return function(val_ / rhs.val_, std::move(jac));
|
||||||
|
@ -188,60 +188,57 @@ equalSparsityPattern(const Lhs& lhs, const Rhs& rhs)
|
|||||||
if( equal )
|
if( equal )
|
||||||
{
|
{
|
||||||
typedef typename Eigen::internal::remove_all<Lhs>::type::Index Index;
|
typedef typename Eigen::internal::remove_all<Lhs>::type::Index Index;
|
||||||
const Index nnz = lhs.nonZeros();
|
|
||||||
|
|
||||||
// outer indices
|
|
||||||
const Index* rhsO = rhs.outerIndexPtr();
|
|
||||||
const Index* lhsO = lhs.outerIndexPtr();
|
|
||||||
|
|
||||||
// inner indices
|
|
||||||
const Index* rhsJ = rhs.innerIndexPtr();
|
|
||||||
const Index* lhsJ = lhs.innerIndexPtr();
|
|
||||||
|
|
||||||
const Index outerSize = lhs.outerSize();
|
const Index outerSize = lhs.outerSize();
|
||||||
if( outerSize != rhs.outerSize() )
|
if( outerSize != rhs.outerSize() )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Index nnz = lhs.nonZeros();
|
||||||
|
|
||||||
|
// outer indices
|
||||||
|
const Index* rhsOuter = rhs.outerIndexPtr();
|
||||||
|
const Index* lhsOuter = lhs.outerIndexPtr();
|
||||||
|
|
||||||
|
// inner indices
|
||||||
|
const Index* rhsInner = rhs.innerIndexPtr();
|
||||||
|
const Index* lhsInner = lhs.innerIndexPtr();
|
||||||
|
|
||||||
bool equalOuter = true;
|
bool equalOuter = true;
|
||||||
bool equalInner = true;
|
bool equalInner = true;
|
||||||
const Index size = std::min( outerSize+1, nnz );
|
const Index size = std::min( outerSize+1, nnz );
|
||||||
for( Index i=0; i<size; ++i)
|
for( Index i=0; i<size; ++i)
|
||||||
{
|
{
|
||||||
equalOuter &= (lhsO[ i ] == rhsO[ i ]);
|
equalOuter &= (lhsOuter[ i ] == rhsOuter[ i ]);
|
||||||
equalInner &= (lhsJ[ i ] == rhsJ[ i ]);
|
equalInner &= (lhsInner[ i ] == rhsInner[ i ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! equalOuter || ! equalInner ) return false ;
|
if( ! equalOuter || ! equalInner ) {
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
if( outerSize+1 < nnz )
|
if( outerSize+1 < nnz )
|
||||||
{
|
{
|
||||||
for(Index i=outerSize+1; i<nnz; ++i)
|
for(Index i=outerSize+1; i<nnz; ++i)
|
||||||
{
|
{
|
||||||
if( lhsJ[ i ] != rhsJ[ i ] ) return false;
|
if( lhsInner[ i ] != rhsInner[ i ] ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( outerSize+1 > nnz )
|
else if( outerSize+1 > nnz )
|
||||||
{
|
{
|
||||||
for(Index o=nnz; o<=outerSize; ++o )
|
for(Index o=nnz; o<=outerSize; ++o )
|
||||||
{
|
{
|
||||||
if( lhsO[ o ] != rhsO[ o ] )
|
if( lhsOuter[ o ] != rhsOuter[ o ] ) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return equalOuter && equalInner;
|
return equalOuter && equalInner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
for(Index o=0; o<=outerSize; ++o )
|
|
||||||
{
|
|
||||||
if( lhsO[ o ] != rhsO[ o ] )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return equal;
|
return equal;
|
||||||
|
Loading…
Reference in New Issue
Block a user