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

📄 init.c

📁 利用语言编写的有限元分析软件
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
 *  ============================================================================= 
 *  ALADDIN Version 1.0 :
 *               init.c : Initialize symbol table
 *                                                                     
 *  Copyright (C) 1995 by Mark Austin, Xiaoguang Chen, and Wane-Jang Lin
 *  Institute for Systems Research,                                           
 *  University of Maryland, College Park, MD 20742                                   
 *                                                                     
 *  This software is provided "as is" without express or implied warranty.
 *  Permission is granted to use this software for any on any computer system
 *  and to redistribute it freely, subject to the following restrictions:
 * 
 *  1. The authors are not responsible for the consequences of use of
 *     this software, even if they arise from defects in the software.
 *  2. The origin of this software must not be misrepresented, either
 *     by explicit claim or by omission.
 *  3. Altered versions must be plainly marked as such, and must not
 *     be misrepresented as being the original software.
 *  4. This notice is to remain intact.
 *                                                                    
 *  Written by: Mark Austin, Xiaoguang Chen, and Wane-Jang Lin      December 1995
 *  ============================================================================= 
 */

#include <math.h>
#ifdef  __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif

#include "defs.h"
#include "units.h"
#include "matrix.h"
#include "fe_database.h"
#include "symbol.h"
#include "elmt.h"
#include "code.h"
#include "fe_functions.h"
#include "y.tab.h"

extern QUANTITY                *Sqrt(), *Fabs(), *Pow();
extern QUANTITY    *Log(), *Log10(), *Exp(), *Integer();
extern QUANTITY         *Sin(), *Cos(), *Tan(), *Atan();
extern QUANTITY                               *Random();

static struct {
	char	*name;
	double	cval;
	}  consts[] = {
		"PI", 		3.14159265358979323846,
		"E",		2.71828182845904523536,
		"GAMMA",	0.57721566490153286060,
		"DEG",	       57.29577951308232087680,
	};

#define NO_CONSTANTS (sizeof(consts)/sizeof(consts[0]))

static struct {
	char	*name;
	int	kval;
	} keywords[] = {
		    "if",       IF,
		  "else",       ELSE,
		  "then",       THEN,
		 "while",       WHILE,
		 "print",       PRINT,
                   "for",       FOR,
		  "quit",       QUIT,
		 "break",       BREAK,
	    "SetUnitsOn",       SET_UNITS_ON,
           "SetUnitsOff",       SET_UNITS_OFF,
	};

#define NO_KEYWORDS (sizeof(keywords)/sizeof(keywords[0]))

/* 
 *  --------------------------
 *  Builtin Quantity Functions 
 *  --------------------------
 */

static struct {
	char	       *name;
	QUANTITY  *(*func)();
	} builtin_quantity[] = {
		"random",	Random,
	};

#define NO_BUILTIN_QUANTITY (sizeof(builtin_quantity)/sizeof(builtin_quantity[0]))

static struct {
	char    	     *name;
	QUANTITY 	*(*func)();
	} builtin1_quantity[] = {

        /* mathematic functions */

		"sin",		Sin,
		"cos",		Cos,
		"tan",		Tan,
		"atan",		Atan,
		"log",		Log,
		"log10",	Log10,
		"exp",		Exp,
		"int",		Integer,
		"sqrt",		Sqrt,
		"abs",		Fabs,
              "QDimenLess",     QuantityUnitsLess,

	};

#define NO_BUILTIN1_QUANTITY (sizeof(builtin1_quantity)/sizeof(builtin1_quantity[0]))

static struct {
	char	       *name;
	QUANTITY  *(*func)();
	} builtin2_quantity[] = {
		"pow",		Pow,
	};

#define NO_BUILTIN2_QUANTITY (sizeof(builtin2_quantity)/sizeof(builtin2_quantity[0]))

static struct {
	char          *name;
	QUANTITY *(*func)();
	} builtin3_quantity[] = {
              "QuanCast",    QuantityCast,
		   "Det",	MatrixDet,
		   "Max",	MatrixMax,
		   "Min",	MatrixMin,
		"L2Norm",    MatrixL2Norm,
	};

#define NO_BUILTIN3_QUANTITY (sizeof(builtin3_quantity)/sizeof(builtin3_quantity[0]))

/* 
 *  ---------------------------------------------------
 *  Builtin Matrix and FE Functions with 0,1 and 2 args
 *  ---------------------------------------------------
 */

static struct {
	char           *name;
	MATRIX    *(*func)();
	} builtin_matrix[] = {
	              "Stiff",  Form_Stiffness,
	       "ExternalLoad", 	Form_External_Load,
	     "EquivNodalLoad", 	Form_Equiv_Nodal_Load,
	};

#define NO_BUILTIN_MATRIX (sizeof(builtin_matrix)/sizeof(builtin_matrix[0]))

static struct {
	char           *name;
	MATRIX    *(*func)();
	} builtin1_matrix[] = {
		       "Copy", 	MatrixCopy,
		  "Dimension", 	MatrixDimension,
	          "Decompose",  MatrixLU,
		      "Trans", 	MatrixTranspose,
		     "Matrix",  MatrixAllocate,
		       "Diag",  MatrixDiag,
		       "Zero",  MatrixZero,
		        "One",  MatrixOne,
                 "MDimenLess",  MatrixUnitsLess,
                    "Inverse",  MatrixInverse,
	       	       "Mass", 	Form_Mass,
                 "Eigenvalue",  Extract_Eigenvalue,
                "Eigenvector",  Extract_Eigenvector,

                   "GetCoord",  Get_Coord,
                    "GetNode",  Get_Node,
                     "GetDof",  Get_Dof,
                 "GetSection",  Get_Section,
                "GetMaterial",  Get_Material,
	};

#define NO_BUILTIN1_MATRIX (sizeof(builtin1_matrix)/sizeof(builtin1_matrix[0]))

static struct {
	char           *name;
	MATRIX    *(*func)();
	} builtin2_matrix[] = {
		      "Solve",    MatrixSolve,
	       "Substitution",    MatrixFB,
                   "GetDispl",    Get_Displ,
                  "GetStress",    Get_Stress,
	};

#define NO_BUILTIN2_MATRIX (sizeof(builtin2_matrix)/sizeof(builtin2_matrix[0]))

static struct {
        char           *name;
        MATRIX   * (*func)();
        } builtin3_matrix[] = {
                "Eigen",  Solve_Eigen,
        };

#define NO_BUILTIN3_MATRIX (sizeof(builtin3_matrix)/sizeof(builtin3_matrix[0]))

static struct {
        char            *name;
        MATRIX     *(*func)();
        } builtinvar_matrix[] = {
	       "InternalLoad",  Form_Internal_Load,
                "PrintStress",  Print_Stress,
                "PrintMatrix",  MatrixPrintVar,
             "PrintMatrixCast", MatrixPrint,
	        "ColumnUnits",  MatrixColumnUnits,
	           "RowUnits",  MatrixRowUnits,
                    "Extract",  MatrixExtract,
                        "Put",  MatrixPut,
        };

#define NO_BUILTINVar_MATRIX (sizeof(builtinvar_matrix)/sizeof(builtinvar_matrix[0]))

/* ------------------------------------
 * Finite Element Functions and Objects
 * ------------------------------------ */

static struct {
	char        *name;
	void	(*func)();
	} fe_mesh[] = {
	      "StartMesh",     Start_Mesh,
	        "EndMesh",       End_Mesh,
	      "PrintMesh",     Print_Mesh,
	};

#define NO_FE_MESH (sizeof(fe_mesh)/sizeof(fe_mesh[0]))

static struct {
	char        *name;
	void	(*func)();
	} fe_node[] = {
		"AddNode",	 Add_Node, 
		"FixNode",	 Fix_Node,
               "NodeLoad",      Node_Load,
	};

#define NO_FE_NODE (sizeof(fe_node)/sizeof(fe_node[0]))

static struct {
	char        *name;
	int          kval;
	} fe_function[] = {
         "UpdateResponse",     UPDATERESPONSE,
	     "PrintDispl",     PRINT_DISPL,
	};

#define NO_FE_FUNCTION (sizeof(fe_function)/sizeof(fe_function[0]))

static struct {

⌨️ 快捷键说明

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