Contact Us
 

Contact CIMNE

    International Center for Numerical Methods in Engineering
    C1 Building, Campus Norte UPC
    Gran Capitan, s/n
    08034 Barcelona, Spain

 
 
Aditional information
 Prev:  Executing the calculation with a concentrated weightMain page
 Next:  The main program



NOTE: In this example, a code for the program will be developed in C. Nevertheless, any programming language may be used.

The code of the program that calculates the center of mass (cmas2d.c) is as follows:

The cmas2d.c file

#include <stdio.h>

#include <stdlib.h>

#include <malloc.h>

#include <math.h>

#define MAXMAT 1000

#define MAXCND 1000

char projname[1024];

int i, ielem, inod, icnd;

double *x, *y;

int *N, *imat;

int nodc[MAXCND];

double rho[MAXMAT], wval[MAXCND];

int Nelem, Nnod, Nmat, Ncnd;

double x_CG, y_CG;

void input(void);

void calculate(void);

void output(void);

Declaration of variables and constants used in the program.

void main (int argc, char *argv[]) {

strcpy (projname, argv[1]);

input();

calculate();

output();

}

Aditional information




 Prev:  Executing the calculation with a concentrated weightMain page
 Next:  The main program