Actual source code: meshCSR.c
1: #ifdef PETSC_RCS_HEADER
2: static char vcid[] = "$Id: meshCSR.c,v 1.19 2000/10/17 13:48:57 knepley Exp $";
3: #endif
5: /*
6: Defines the interface to the CSR mesh functions
7: */
9: #include src/mesh/meshimpl.h
11: /*@
12: MeshCreateLocalCSR - Returns the local mesh in CSR format. All off
13: processor edges are ignored, and only the symmetric part of the matrix
14: is stored if symmetric is true.
16: Not collective
18: Input Parameters:
19: + mesh - The mesh
20: . numBC - [Optional] The number of constrained nodes to be eliminated
21: . bcNodes - [Optional] The numbers of constrained nodes
22: - symmetric - Whether to return the entire adjacency list
24: Output Parameters:
25: + numVertices - The number of vertices in the graph
26: . numEdges - The number of edges in the graph.
27: . vertOffsets - The list of offsets into the neighbor array for each vertex
28: . vertNeighbors - The list of vertex neighbors
29: - vertCoords - The list of vertex coordinates
31: Note:
32: If any array, such as vertCoords, is passed as PETSC_NULL, then no return
33: value will be calculated.
35: Level: advanced
37: .keywords: mesh, partition, CSR
38: .seealso: MeshDestroyLocalCSR(), MeshPartition()
39: @*/
40: int MeshCreateLocalCSR(Mesh mesh, int *numVertices, int *numEdges, int **vertOffsets, int **vertNeighbors,
41: double **vertCoords, int numBC, int *bcNodes, PetscTruth symmetric)
42: {
43: int num;
53: if (numBC > 0) {
55: num = numBC;
56: } else {
57: num = 0;
58: }
59: if (!mesh->ops->createlocalcsr) {
60: SETERRQ(PETSC_ERR_SUP, "Not supported by this Mesh object");
61: }
62: PetscLogEventBegin(MESH_CreateLocalCSR, mesh, 0, 0, 0);
63: (*mesh->ops->createlocalcsr)(mesh, numVertices, numEdges, vertOffsets, vertNeighbors, vertCoords, num, bcNodes, symmetric);
64:
65: PetscLogEventEnd(MESH_CreateLocalCSR, mesh, 0, 0, 0);
66: return(0);
67: }
69: /*@
70: MeshDestroyLocalCSR - Destroys the local mesh in CSR format
72: Not collective
74: Input Parameters:
75: + mesh - The mesh
76: . vertOffsets - The list of offsets into the neighbor array for each element
77: . vertNeighbors - The list of element neighbors
78: - vertCoords - The list of vertex coordinates
80: Level: advanced
82: .keywords: mesh, partition
83: .seealso: MeshCreateLocalCSR(), MeshPartition()
84: @*/
85: int MeshDestroyLocalCSR(Mesh mesh, int *vertOffsets, int *vertNeighbors, double *vertCoords)
86: {
91: if (vertOffsets != PETSC_NULL) {
92: PetscFree(vertOffsets);
93: }
94: if (vertNeighbors != PETSC_NULL) {
95: PetscFree(vertNeighbors);
96: }
97: if (vertCoords != PETSC_NULL) {
98: PetscFree(vertCoords);
99: }
100: return(0);
101: }
103: /*@
104: MeshCreateFullCSR - Returns the full mesh including all nodes in CSR format.
106: Not collective
108: Input Parameters:
109: + mesh - The mesh
110: - constrain - The flag for including connection between constrained nodes
112: Output Parameters:
113: + numVertices - The number of vertices in the graph
114: . numEdges - The number of edges in the graph.
115: . vertOffsets - List of offsets into the neighbor array for each vertex
116: - vertNeighbors - List of vertex neighbors
118: Level: advanced
120: .keywords: mesh, partition, CSR
121: .seealso: MeshDestroyFullCSR(), MeshPartition()
122: @*/
123: int MeshCreateFullCSR(Mesh mesh, PetscTruth constrain, int *numVertices, int *numEdges, int **vertOffsets, int **vertNeighbors)
124: {
133: if ((mesh->partitioned) && (mesh->part->numProcs > 1)) {
134: SETERRQ(PETSC_ERR_SUP, "Not yet supported on multiple processors");
135: }
136: if (!mesh->ops->createfullcsr) {
137: SETERRQ(PETSC_ERR_SUP, "Not supported by this Mesh object");
138: }
139: PetscLogEventBegin(MESH_CreateFullCSR, mesh, 0, 0, 0);
140: (*mesh->ops->createfullcsr)(mesh, constrain, numVertices, numEdges, vertOffsets, vertNeighbors);
141: PetscLogEventEnd(MESH_CreateFullCSR, mesh, 0, 0, 0);
142: return(0);
143: }
145: /*@
146: MeshDestroyFullCSR - Destroys the full mesh in CSR format
148: Not collective
150: Input Parameters:
151: + mesh - The mesh
152: . vertOffsets - List of offsets into the neighbor array for each element
153: - vertNeighbors - List of element neighbors
155: Level: advanced
157: .keywords: mesh, partition
158: .seealso: MeshCreateFullCSR(), MeshPartition()
159: @*/
160: int MeshDestroyFullCSR(Mesh mesh, int *vertOffsets, int *vertNeighbors)
161: {
166: PetscFree(vertOffsets);
167: PetscFree(vertNeighbors);
168: return(0);
169: }
171: /*@
172: MeshCreateDualCSR - Returns the dual of the mesh in distributed CSR format
174: Collective on Mesh
176: Input Parameter:
177: . mesh - The mesh
179: Output Parameters:
180: + elemOffsets - List of offsets into the neighbor array for each element
181: . elemNeighbors - List of element neighbors
182: . edgeWeights - [Optional] List of edge weights for the dual graph
183: - weight - [Optional] Weight for each edge
185: Level: advanced
187: .keywords: mesh, partition, dual
188: .seealso: MeshDestroyDualCSR(), MeshPartition()
189: @*/
190: int MeshCreateDualCSR(Mesh mesh, int **elemOffsets, int **elemNeighbors, int **edgeWeights, int weight)
191: {
199: if (!mesh->ops->createdualcsr) {
200: SETERRQ(PETSC_ERR_SUP, "Not supported by this Mesh object");
201: }
202: PetscLogEventBegin(MESH_CreateDualCSR, mesh, 0, 0, 0);
203: (*mesh->ops->createdualcsr)(mesh, elemOffsets, elemNeighbors, edgeWeights, weight);
204: PetscLogEventEnd(MESH_CreateDualCSR, mesh, 0, 0, 0);
205: return(0);
206: }
208: /*@
209: MeshDestroyDualCSR - Destroys the dual of the mesh in distributed CSR format
211: Not collective
213: Input Parameters:
214: + mesh - The mesh
215: . elemOffsets - List of offsets into the neighbor array for each element
216: . elemNeighbors - List of element neighbors
217: - edgeWeights - List of edge weights for the dual graph
219: Level: advanced
221: .keywords: mesh, partition, dual
222: .seealso: MeshCreateDualCSR(), MeshPartition()
223: @*/
224: int MeshDestroyDualCSR(Mesh mesh, int *elemOffsets, int *elemNeighbors, int *edgeWeights)
225: {
230: PetscFree(elemOffsets);
231: PetscFree(elemNeighbors);
232: if (edgeWeights != PETSC_NULL) {
233: PetscFree(edgeWeights);
234: }
235: return(0);
236: }