mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Vector construction is now value oriented.
No longer initialised and constructed in two places.
This commit is contained in:
parent
6c70d2938d
commit
37a47711e5
@ -148,18 +148,18 @@ namespace{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void to_petsc_vec( const double* x, Vec v ) {
|
Vec to_petsc_vec( const double* x, int size ) {
|
||||||
if( !v ) OPM_THROW( std::runtime_error,
|
|
||||||
"PETSc CopySolution: Invalid PETSc vector." );
|
|
||||||
|
|
||||||
PetscScalar* vec;
|
PetscScalar* vec;
|
||||||
PetscInt size;
|
Vec v;
|
||||||
|
|
||||||
|
VecSetSizes( v, PETSC_DECIDE, size );
|
||||||
|
VecSetFromOptions( v );
|
||||||
|
|
||||||
VecGetLocalSize( v, &size );
|
|
||||||
VecGetArray( v, &vec );
|
VecGetArray( v, &vec );
|
||||||
|
|
||||||
std::memcpy( vec, x, size * sizeof( double ) );
|
std::memcpy( vec, x, size * sizeof( double ) );
|
||||||
|
|
||||||
VecRestoreArray( v, &vec );
|
VecRestoreArray( v, &vec );
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void from_petsc_vec( double* x, Vec v ) {
|
void from_petsc_vec( double* x, Vec v ) {
|
||||||
@ -255,7 +255,7 @@ namespace{
|
|||||||
|
|
||||||
OEM_DATA t( size );
|
OEM_DATA t( size );
|
||||||
t.A = to_petsc_mat( size, nonzeros, ia, ja, sa );
|
t.A = to_petsc_mat( size, nonzeros, ia, ja, sa );
|
||||||
to_petsc_vec( rhs, t.rhs );
|
t.rhs = to_petsc_vec( rhs, size );
|
||||||
|
|
||||||
solve_system( t, ksp_type, pc_type, rtol_, atol_, dtol_, maxits_, ksp_view_ );
|
solve_system( t, ksp_type, pc_type, rtol_, atol_, dtol_, maxits_, ksp_view_ );
|
||||||
from_petsc_vec( solution, t.solution );
|
from_petsc_vec( solution, t.solution );
|
||||||
|
Loading…
Reference in New Issue
Block a user