⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 psn_2d.h

📁 Finite Volume Poisson PDE Solver
💻 H
字号:
/*psn_lib/psn_2d.h*/
/***********************************************************************
    Finite Volume Poisson PDE Solver: C-Library & Matlab Toolbox
    Implements numerical solution of Poisson PDE
    in 2D  Cartesian and Cylindrical coordinates

    Copyright (C) 2004 Igor Kaufman
    Copyright (C) 2004 Lancaster University, UK

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


    Author's email: i.kaufman@lancaster.ac.uk

    APPLICATION    : 2D POISSON SOLVER
    VERSION        : 1.0
************************************************************************/
/*17.01.04*/

#ifndef PSN_2D
#define PSN_2D

enum PSN_METHODS {
  metPSOR=1,    //Iterative: Point Successive OverRelaxation
  metLSOR=2,    //Iterative:Line Successive OverRelaxation
  metADI=3  //Iterative: Alternative Direction Implicit
};

//Structure for 2d Poisson solution.
//Defines input parameters and results
//   typical usage:
//  psn_2d_struct psd;
//  psn_2d_struct_init(psd, Nx, Ny);
//  psd->Lx=....
//  psd->method=metLSOR;
//...
//  psn_2d_solver(psd);
//  psn_2d_struct_free(psd);

typedef struct {
   //Parameters
   size_t Nx;       //Number of INTERIOR points in X-dirextion
   size_t Ny;       //Number of INTERIOR points in Y-dirextion
   double Lx;       //X-size
   double Ly;       //Y-size
   int grid;        //Grid: 0-standard, 1 - centered
   int method;      //Solving method from PSN_METHODS
   double W;        //Over-relaxation factor, should be 1<=W<2
   double tol;      //Tolerance
   size_t max_step; //Max steps
   int crd;         // Cooord type: 0 - Cartesian, 1- Cylindrical

   //Boundary conditions  for mixed case:  alpha*U+beta*U'=gamma
   double alphaX[2];
   double betaX[2];
   double alphaY[2];
   double betaY[2];

   //Initial data
   PSN_MATRIX v; //rhs charge density matrix. Also contains BOUNDARY conditions - gamma vectors in v[0][row],...  ;
   PSN_MATRIX e; //rhs permittivity matrix. If NULL - vacuum solution

   //Results
   PSN_MATRIX u;            //lhs result potential matrix
   double error;            //resulting error
   double num_step;         //number of iteration steps
   int result;              //function result: 0-OK
   double *step_err;         //errors by step
}  psn_2d_struct;

int psn_2d_struct_init(psn_2d_struct *psd, const size_t Nx, const size_t Ny);
int psn_2d_struct_free(psn_2d_struct *psd);
int psn_2d_solver(psn_2d_struct *psd);


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -