1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include <iostream>
#include <cmath>
#include <stdio.h> /* printf */
#include <math.h> /* ceil */
#define PI 3.141592653589793
using namespace std;
int main()
{
float N=8;
float M=8;
float Q=N;
float stiff=1;
float L=2;
float dx=L/(N-1);//h
float ds=2;
float x[8]={1,4,9,0,3,2,7,5};
float y[8]={1,4,9,0,3,2,7,5};
///////////////////////////////
int i,j;
float force1[8]={0};
force1[0]=(x[1]-2*x[0]+x[7])/pow(ds,2);
for(i=1;i<7;i++){
force1[i]=(x[i+1]-2*x[i]+x[i-1])/pow(ds,2);
};
force1[7]=(x[0]-2*x[7]+x[6])/pow(ds,2);
float force2[8]={0};
force2[0]=(y[1]-2*y[0]+y[7])/pow(ds,2);
for(i=1;i<7;i++){
force2[i]=(y[i+1]-2*y[i]+y[i-1])/pow(ds,2);
};
force2[7]=(y[0]-2*y[7]+y[6])/pow(ds,2);
////////////////////////////////////////
float F1[8][8]={0};
float F2[8][8]={0};
for (int i=0,i<=7,i++){
int x1=ceil((x[i]+1)/dx);
int x2 =ceil((y[i]+1)/dx);
for(int k=0,k<=3,k++){
for(int h=0, h<=3,h++){
int ii=x1+1-k %8;
int jj=x2+1-h %8;
F1[ii][jj]+=force1[i]*(ds/(16*power(dx,2))*(1+cos((PI/(2*dx))*(dx*(x1+1-k)-x[i])))*(1+cos((PI/(2*dx))*(dx*(x2+1-h)-y[i])));
};
};
};
return{0};
}
|