MASA-0.44.0
laplacian.h
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // MASA - Manufactured Analytical Solutions Abstraction Library
5 //
6 // Copyright (C) 2010,2011,2012,2013 The PECOS Development Team
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the Version 2.1 GNU Lesser General
10 // Public License as published by the Free Software Foundation.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Lesser General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
20 // Boston, MA 02110-1301 USA
21 //
22 //-----------------------------------------------------------------------el-
23 // $Id$
24 //--------------------------------------------------------------------------
25 
26 #include<assert.h>
27 #include<stdio.h>
28 #include<stdlib.h>
29 #include<masa.h>
30 #include<math.h>
31 
32 /* Primary model data-structure */
33 
34 typedef struct pstruct {
35  double *phi;
36  double *rhs;
37  double **A;
38  double h;
39  int n;
40  int npts;
41  int pad;
42 } pstruct;
43 
44 /* Supported finite-difference stencils */
45 
46 enum fd_types
47  {
48  central_2nd_order,
49  central_4th_order
50  };
51 
52 /* Function prototypes */
53 
54  void apply_bcs (pstruct *model);
55  void assemble_matrix (const int fd_method, pstruct *model);
56  void compute_error (pstruct *model);
57 double compute_l2_error (pstruct *model);
58  int converged (double *a, double *b, double eps, const int n, double *diff);
59  void enforce_dirichlet_bc (const int col_id, const int row_id, const double value, pstruct *model);
60  void init_masa (pstruct *model);
61  void print_matrix (pstruct *model);
62  void problem_initialize (const int, const double length, pstruct *model);
63  void solve_gauss (pstruct *model);
64  void solve_cg (pstruct *model);
65 
66 /* conjugate gradient */
67 
68 int cg(int n,double* A,double* b,double* x,double* residual,int* iterations);
void enforce_dirichlet_bc(const int row_id, const int col_id, const double value, pstruct *model)
Enforces a Dirichlet BC in the model system by nullifying all but the diagonal entry for the row corr...
Definition: laplacian_utils.c:84
double * rhs
Definition: laplacian.h:36
double * phi
Definition: laplacian.h:35
int npts
Definition: laplacian.h:40
void init_masa(pstruct *model)
Initializes MASA library and applies right-hand side forcing function at all solution points...
Definition: laplacian_utils.c:40
void print_matrix(pstruct *model)
Prints model system matrix and right-hand side vector to stdout.
Definition: laplacian_utils.c:108
double h
Definition: laplacian.h:38
void assemble_matrix(const int fd_method, pstruct *model)
Assembles system matrix entries using a finite-difference approximation. The fd_method parameter cont...
Definition: laplacian_utils.c:141
double ** A
Definition: laplacian.h:37
int n
Definition: laplacian.h:39
int pad
Definition: laplacian.h:41
Definition: laplacian.h:34

Generated on Tue Apr 21 2015 10:22:49 for MASA-0.44.0 by  doxygen 1.8.5