source: CIVL/examples/mpi-omp/AMG2013/sstruct_mv/HYPRE_sstruct_stencil.c@ 397ae5f

main test-branch
Last change on this file since 397ae5f was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*BHEADER**********************************************************************
2 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
3 * Produced at the Lawrence Livermore National Laboratory.
4 * This file is part of HYPRE. See file COPYRIGHT for details.
5 *
6 * HYPRE is free software; you can redistribute it and/or modify it under the
7 * terms of the GNU Lesser General Public License (as published by the Free
8 * Software Foundation) version 2.1 dated February 1999.
9 *
10 * $Revision: 2.4 $
11 ***********************************************************************EHEADER*/
12
13
14
15/******************************************************************************
16 *
17 * HYPRE_SStructStencil interface
18 *
19 *****************************************************************************/
20
21#include "headers.h"
22
23/*--------------------------------------------------------------------------
24 * HYPRE_SStructStencilCreate
25 *--------------------------------------------------------------------------*/
26
27int
28HYPRE_SStructStencilCreate( int ndim,
29 int size,
30 HYPRE_SStructStencil *stencil_ptr )
31{
32 int ierr = 0;
33
34 hypre_SStructStencil *stencil;
35 hypre_StructStencil *sstencil;
36 int *vars;
37
38 stencil = hypre_TAlloc(hypre_SStructStencil, 1);
39 ierr = HYPRE_StructStencilCreate(ndim, size, &sstencil);
40 vars = hypre_CTAlloc(int, hypre_StructStencilSize(sstencil));
41
42 hypre_SStructStencilSStencil(stencil) = sstencil;
43 hypre_SStructStencilVars(stencil) = vars;
44 hypre_SStructStencilRefCount(stencil) = 1;
45
46 *stencil_ptr = stencil;
47
48 return ierr;
49}
50
51/*--------------------------------------------------------------------------
52 * HYPRE_SStructStencilDestroy
53 *--------------------------------------------------------------------------*/
54
55int
56HYPRE_SStructStencilDestroy( HYPRE_SStructStencil stencil )
57{
58 int ierr = 0;
59
60 if (stencil)
61 {
62 hypre_SStructStencilRefCount(stencil) --;
63 if (hypre_SStructStencilRefCount(stencil) == 0)
64 {
65 HYPRE_StructStencilDestroy(hypre_SStructStencilSStencil(stencil));
66 hypre_TFree(hypre_SStructStencilVars(stencil));
67 hypre_TFree(stencil);
68 }
69 }
70
71 return ierr;
72}
73
74/*--------------------------------------------------------------------------
75 * HYPRE_SStructStencilSetEntry
76 *--------------------------------------------------------------------------*/
77
78int
79HYPRE_SStructStencilSetEntry( HYPRE_SStructStencil stencil,
80 int entry,
81 int *offset,
82 int var )
83{
84 int ierr;
85 hypre_StructStencil *sstencil = hypre_SStructStencilSStencil(stencil);
86
87 ierr = HYPRE_StructStencilSetElement(sstencil, entry, offset);
88 hypre_SStructStencilVar(stencil, entry) = var;
89
90 return ierr;
91}
92
93
Note: See TracBrowser for help on using the repository browser.