CppNoddy  0.92
Loading...
Searching...
No Matches
Functions
DistributedVector_petscd.cpp File Reference

A superficial sanity check of copy and two_norm. More...

#include <DistributedVector.h>
#include <Types.h>
#include "../Utils_Fill.h"
#include <mpi.h>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

A superficial sanity check of copy and two_norm.

Definition in file DistributedVector_petscd.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 15 of file DistributedVector_petscd.cpp.

16{
17 PetscSession::getInstance(argc,argv);
18
19 PetscPrintf(PETSC_COMM_WORLD, "\n=== Vector: A distributed (double) example ==========\n\n");
20
21 DistributedVector<double> vecA( 10 );
22
23 DenseVector<int> indices( 5, 0 );
24 DenseVector<double> values( 5, 1.0);
25 for ( auto i = 0; i < 5; i++ ) {
26 indices[i] = 2*i;
27 values[i] = 2*i;
28 }
29 vecA.set( indices, values );
30 vecA.final_assembly();
31
32 auto vecB = vecA;
33
34 vecA.view();
35 //vecB.view();
36 PetscPrintf(PETSC_COMM_WORLD, "%f", vecA.two_norm() - vecB.two_norm() );
37
38 if ( vecA.two_norm() - vecB.two_norm() > 1.e-12 )
39 {
40 PetscPrintf(PETSC_COMM_WORLD, "\033[1;31;48m * FAILED \033[0m\n");
41 return 1;
42 }
43 PetscPrintf(PETSC_COMM_WORLD, "\033[1;32;48m * PASSED \033[0m\n");
44 return 0;
45
46}
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34

© 2012

R.E. Hewitt