Chi-Tech
petsc_utils_01_createVec.cc
Go to the documentation of this file.
1#include "petsc_utils.h"
2
3#include "chi_log.h"
4
5//###################################################################
6/**Creates a general vector.
7 *
8This is a macro for:
9\code
10Vec x;
11VecCreate(PETSC_COMM_WORLD,&x);
12VecSetType(x,VECMPI);
13VecSetSizes(x, local_size, global_size);
14VecSetOption(x,VEC_IGNORE_NEGATIVE_INDICES,PETSC_TRUE);
15
16return x;
17\endcode*/
19CreateVector(int64_t local_size, int64_t global_size)
20{
21 Vec x;
22 VecCreate(PETSC_COMM_WORLD,&x);
23 VecSetType(x,VECMPI);
24 VecSetSizes(x, local_size, global_size);
25 VecSetOption(x,VEC_IGNORE_NEGATIVE_INDICES,PETSC_TRUE);
26
27 return x;
28}
29
30//###################################################################
31/**Creates a general vector.
32 *
33This is a macro for:
34\code
35VecCreate(PETSC_COMM_WORLD,&x);
36VecSetType(x,VECMPI);
37VecSetSizes(x, local_size, global_size);
38VecSetOption(x,VEC_IGNORE_NEGATIVE_INDICES,PETSC_TRUE);
39\endcode*/
41CreateVector(Vec& x, int64_t local_size, int64_t global_size)
42{
43 VecCreate(PETSC_COMM_WORLD,&x);
44 VecSetType(x,VECMPI);
45 VecSetSizes(x, local_size, global_size);
46 VecSetOption(x,VEC_IGNORE_NEGATIVE_INDICES,PETSC_TRUE);
47}
48
49//###################################################################
50/**Creates a general vector with ghost value support.
51 *
52This is a macro for:
53\code
54Vec x;
55VecCreateGhost(PETSC_COMM_WORLD,
56 local_size,
57 global_size,
58 nghosts,
59 ghost_indices.data(),
60 &x);
61
62VecSetOption(x,VEC_IGNORE_NEGATIVE_INDICES,PETSC_TRUE);
63
64return x;
65\endcode*/
67CreateVectorWithGhosts(int64_t local_size, int64_t global_size,
68 int64_t nghosts,
69 const std::vector<int64_t>& ghost_indices)
70{
71 Vec x;
72 VecCreateGhost(PETSC_COMM_WORLD,
73 local_size,
74 global_size,
75 nghosts,
76 (ghost_indices.empty())? NULL : ghost_indices.data(),
77 &x);
78
79 VecSetOption(x,VEC_IGNORE_NEGATIVE_INDICES,PETSC_TRUE);
80
81 return x;
82}
Vec CreateVectorWithGhosts(int64_t local_size, int64_t global_size, int64_t nghosts, const std::vector< int64_t > &ghost_indices)
Vec CreateVector(int64_t local_size, int64_t global_size)
struct _p_Vec * Vec