17int main(
int argc,
char *argv[])
19 PetscSession::getInstance(argc,argv);
21 PetscPrintf(PETSC_COMM_WORLD,
"\n=== Vector: A distributed (double) example ==========\n\n");
26 double deltax = 1.0/(Nx-1);
27 double deltaxSq = deltax*deltax;
28 double deltay = 1.0/(Ny-1);
29 double deltaySq = deltay*deltay;
30 DistributedMatrix<double> matA( N, N, 5, 4 );
31 DistributedVector<double> vecB( N );
33 for(std::size_t j = 0; j < Ny; ++j ) {
34 matA.set_elt(j,j,1.0);
38 for(std::size_t i = 1; i < Nx-1; ++i ) {
39 matA.set_elt( i*Ny, i*Ny, 1.0 );
40 vecB.set_elt( i*Ny, 0.0 );
41 for(std::size_t j = 1; j < Ny-1; ++j ) {
47 value.
push_back( -2.0/deltaySq - 2.0/deltaxSq);
54 matA.set_row( i*Ny+j, index, value );
55 vecB.set_elt( i*Ny+j, 1.0 );
57 matA.set_elt( i*Ny+Ny-1, i*Ny+Ny-1, 1.0 );
58 vecB.set_elt( i*Ny+Ny-1, 0.0 );
60 for(std::size_t j = 0; j < Ny; ++j ) {
61 matA.set_elt( Ny*(Nx-1) + j , Ny*(Nx-1) + j, 1.0 );
62 vecB.set_elt( Ny*(Nx-1) + j, 0.0 );
65 matA.final_assembly();
66 vecB.final_assembly();
71 DistributedLinearSystem<double> system( &matA, &vecB );
74 cout << vecB.two_norm() <<
"\n";
Specification of a sparse-storage distributed linear system class.
A matrix class that constructs a SPARSE/DISTRIBUTED matrix using PETSc.
A class that constructs a SPARSE/DISTRIBUTED vector using PETSc.
An DenseVector class – a dense vector object.
void push_back(const _Type &fill)
A pass-thru definition of push_back.
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...