www.pudn.com > simulator.zip > General_initial.cpp
#include "General_ext.h"
extern void parameter_initialize(void);
void interact_input(void);
void input_M_K_matrix(void);
void input_D_V_initial(void);
void readfile_input(void);
void read_string(FILE *, char []);
void built_in_input(void);
void Rayleigh_damping_matrix(float[]);
/**************************************************************************/
/* Function: parameter_initialize */
/**************************************************************************/
void parameter_initialize(void)
{
int type_of_input;
printf("\n How do you want to input data ?");
printf("\n '1' interactively,");
printf("\n '2' from a *.inp input file,");
printf("\n '3' using the already built-in data in the function built_in_input() : ");
scanf("%d",&type_of_input);
if (type_of_input<1 || type_of_input>3) { printf("\n\n Error in input your option !\n\n"); abort(); }
printf("\n\n");
switch (type_of_input)
{
case 1 : interact_input(); break;
case 2 : readfile_input(); break;
case 3 : built_in_input(); break;
default : break;
}
for( int i=0; iMAX_CTRL_CHAN) { printf("\n\n Error in input Num_dof !\n\n"); abort(); }
printf("\n 2.1 Enter the mass coefficients [unit : Kg]");
printf("\n 2.2 Enter the stiffness coefficients [unit : N/m]\n");
input_M_K_matrix();
printf("\n 3. Enter your option for the time domain integration method,");
printf("\n '0' for the AG_f_diss method");
printf("\n '1' for the Alpha method");
printf("\n '2' for the Newmark method");
printf("\n '3' for the Integration_Newmark method");
printf("\n '> 3' for the default (central difference) method : ");
scanf("%d", &integration_method);
if (integration_method<0) { printf("\n\n Error in input integration_method !\n\n"); abort(); }
if (integration_method==0) {
printf("\n Input '1' for the 1st (Alpha) of AG_f_diss schemes");
printf("\n '2' for the 2nd (Gamma) of AG_f_diss schemes : ");
scanf("%d", &i_type); }
if (integration_method==1) {
printf("\n Input ALPHA for integration, suggested range [-0.5,0] : ");
scanf("%f",&Alfa);
if (Alfa<-.5f || Alfa>0.f) { printf("\n\n Error in input Alfa !\n\n"); abort(); }
Beta = .25f*(1.f-Alfa)*(1.f-Alfa);
Gama = .5f*(1.f-2.f*Alfa); }
if (integration_method==2 || integration_method==3) {
printf("\n Input Beta for integration : ");
scanf("%f",&Beta);
printf(" Input Gamma for integration : ");
scanf("%f",&Gama); }
printf("\n 4. Enter the option for damping");
printf("\n '0' for no damping");
printf("\n '1' to input individual coefficients");
printf("\n '2' to input coefficients of proportional damping");
printf("\n '3' for the Rayleigh damping (only for Num_dof = 3) : ");
scanf("%d",&type_of_damping);
if (type_of_damping<0 || type_of_damping>3) { printf("\n\n Error in input your option !\n\n"); abort(); }
switch (type_of_damping)
{
case no_damping :
{
for ( i=0; i2) { printf("\n\n Error in input load_type !\n\n"); abort(); }
if (type_of_load==2)
{
printf("\n 7.1 Enter the time step for the GM record [unit sec] : ");
scanf("%f",&Gm_dt);
if (Gm_dt<=0.f) { printf("\n\n Error in input Gm_dt !\n\n"); abort(); }
printf(" 7.2 Enter the number of points for the GM record : ");
scanf("%d",&Gm_pts);
if (Gm_pts<1) { printf("\n\n Error in input Gm_pts !\n\n"); abort(); }
printf(" 7.3 Enter the file name of the GM record : ");
scanf("%s",&fname1);
strcpy(fname2,fname1);
strcat(fname2,".dat");
if ( strlen(fname2) == 0 || (inp_gm = fopen(fname2, "r")) == NULL ) //open GM record file
{
printf("\n Unable to open input file, make sure the file exists.");
}
else
{
for(i=0; i0.f) { printf("\n\n Error in input Alfa !\n\n"); abort(); }
Beta = .25f*(1.f-Alfa)*(1.f-Alfa);
Gama = .5f*(1.f-2.f*Alfa); } //read Alfa
if (integration_method==2 || integration_method==3)
{ read_string(inp_read,line);
sscanf(line,"%f\n",&Beta);
read_string(inp_read,line);
sscanf(line,"%f\n",&Gama); } //read Beta and Gama
read_string(inp_read,line);
sscanf(line, "%d\n", &type_of_damping); //type of damping required
if (type_of_damping<0 || type_of_damping>3) { printf("\n\n Error in input damp_input !\n\n"); abort(); }
switch (type_of_damping)
{
case no_damping :
{
for ( i=0; i2) { printf("\n\n Error in input load_type !\n\n"); abort(); }
if (type_of_load==2) //GM record
{
read_string(inp_read,line);
sscanf(line,"%d %f %f\n", &Gm_pts, &Gm_dt, &Gm_fact);
if (Gm_pts<1 || Gm_dt<=0.f) { printf("\n\n Error in input GM parameters !\n\n"); abort(); }
read_string(inp_read,line);
sscanf(line,"%s\n",&fname2);
if ((inp_gm=fopen(fname2, "r"))==NULL ) //open GM record file
{
printf("\n\n Unable to open GM file, make sure the file exists.\n\n");
abort();
}
for (i=0; i