Skip to content
This repository was archived by the owner on Dec 5, 2020. It is now read-only.

Commit

Permalink
The general organization has been modified and a file was added.
Browse files Browse the repository at this point in the history
A bug regarding the stress calculation was fixed.
  • Loading branch information
Marco Mazzeo committed Jul 27, 2007
1 parent 8b99a0c commit d59a9e5
Show file tree
Hide file tree
Showing 6 changed files with 446 additions and 371 deletions.
106 changes: 106 additions & 0 deletions Code/config.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// In this file all the declarations and some simple functions are reported.

#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include "config.h"

int STABLE = 1;
int UNSTABLE = 0;

// the constants needed to define the configuration of the lattice
// sites follow

unsigned int SOLID_TYPE = 0U;
unsigned int FLUID_TYPE = 1U;
unsigned int INLET_TYPE = 2U;
unsigned int OUTLET_TYPE = 3U;
unsigned int NULL_TYPE = 4U;

unsigned int BOUNDARIES = 4U;
unsigned int INLET_BOUNDARY = 0U;
unsigned int OUTLET_BOUNDARY = 1U;
unsigned int WALL_BOUNDARY = 2U;
unsigned int CHARACTERISTIC_BOUNDARY = 3U;

unsigned int SITE_TYPE_BITS = 2U;
unsigned int BOUNDARY_CONFIG_BITS = 14U;
unsigned int BOUNDARY_DIR_BITS = 4U;
unsigned int BOUNDARY_ID_BITS = 10U;

unsigned int BOUNDARY_CONFIG_SHIFT = 2U; // SITE_TYPE_BITS;
unsigned int BOUNDARY_DIR_SHIFT = 16U; // BOUNDARY_CONFIG_SHIFT + BOUNDARY_CONFIG_BITS;
unsigned int BOUNDARY_ID_SHIFT = 20U; // BOUNDARY_DIR_SHIFT + BOUNDARY_DIR_BITS;

unsigned int SITE_TYPE_MASK = ((1U << 2U) - 1U); // ((1U << SITE_TYPE_BITS) - 1U);
unsigned int BOUNDARY_CONFIG_MASK = ((1U << 14U) - 1U) << 2U; // ((1U << BOUNDARY_CONFIG_BITS) - 1U) << BOUNDARY_CONFIG_SHIFT;
unsigned int BOUNDARY_DIR_MASK = ((1U << 4U) - 1U) << 16U; //((1U << BOUNDARY_DIR_BITS) - 1U) << BOUNDARY_DIR_SHIFT;
unsigned int BOUNDARY_ID_MASK = ((1U << 10U) - 1U) << 20U; // ((1U << BOUNDARY_ID_BITS) - 1U) << BOUNDARY_ID_SHIFT
unsigned int CHARACTERISTIC_MASK = 1U << 31U;

// square of the speed of sound

double Cs2 = 3.0 / 8.0;


// parameters related to the lattice directions

int e_x[] = { 0, 1,-1, 0, 0, 0, 0, 1,-1, 1,-1, 1,-1, 1,-1};
int e_y[] = { 0, 0, 0, 1,-1, 0, 0, 1,-1, 1,-1,-1, 1,-1, 1};
int e_z[] = { 0, 0, 0, 0, 0, 1,-1, 1,-1,-1, 1, 1,-1,-1, 1};
int inv_dir[] = {0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13};


double *f_old = NULL, *f_new = NULL;

int *f_id = NULL;

Velocity *vel = NULL;


short int f_data[4*SHARED_DISTRIBUTIONS_MAX];

double f_to_send[SHARED_DISTRIBUTIONS_MAX];
double f_to_recv[SHARED_DISTRIBUTIONS_MAX];

int f_send_id[SHARED_DISTRIBUTIONS_MAX];
int f_recv_iv[SHARED_DISTRIBUTIONS_MAX];



// some simple functions

int min (int a, int b)
{
if (a < b)
{
return a;
}
else
{
return b;
}
}


int max (int a, int b)
{
if (a > b)
{
return a;
}
else
{
return b;
}
}


double myClock ()
{
return (double)clock () / (double)CLOCKS_PER_SEC;
}
124 changes: 47 additions & 77 deletions Code/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,53 @@
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <rpc/types.h>
#include <rpc/xdr.h>

int STABLE = 1;
int UNSTABLE = 0;
extern int STABLE;
extern int UNSTABLE;

// the constants needed to define the configuration of the lattice
// sites follow

unsigned int SOLID_TYPE = 0U;
unsigned int FLUID_TYPE = 1U;
unsigned int INLET_TYPE = 2U;
unsigned int OUTLET_TYPE = 3U;
unsigned int NULL_TYPE = 4U;

unsigned int BOUNDARIES = 4U;
unsigned int INLET_BOUNDARY = 0U;
unsigned int OUTLET_BOUNDARY = 1U;
unsigned int WALL_BOUNDARY = 2U;
unsigned int CHARACTERISTIC_BOUNDARY = 3U;

unsigned int SITE_TYPE_BITS = 2U;
unsigned int BOUNDARY_CONFIG_BITS = 14U;
unsigned int BOUNDARY_DIR_BITS = 4U;
unsigned int BOUNDARY_ID_BITS = 10U;

unsigned int BOUNDARY_CONFIG_SHIFT = 2U; // SITE_TYPE_BITS;
unsigned int BOUNDARY_DIR_SHIFT = 16U; // BOUNDARY_CONFIG_SHIFT + BOUNDARY_CONFIG_BITS;
unsigned int BOUNDARY_ID_SHIFT = 20U; // BOUNDARY_DIR_SHIFT + BOUNDARY_DIR_BITS;

unsigned int SITE_TYPE_MASK = ((1U << 2U) - 1U); // ((1U << SITE_TYPE_BITS) - 1U);
unsigned int BOUNDARY_CONFIG_MASK = ((1U << 14U) - 1U) << 2U; // ((1U << BOUNDARY_CONFIG_BITS) - 1U) << BOUNDARY_CONFIG_SHIFT;
unsigned int BOUNDARY_DIR_MASK = ((1U << 4U) - 1U) << 16U; //((1U << BOUNDARY_DIR_BITS) - 1U) << BOUNDARY_DIR_SHIFT;
unsigned int BOUNDARY_ID_MASK = ((1U << 10U) - 1U) << 20U; // ((1U << BOUNDARY_ID_BITS) - 1U) << BOUNDARY_ID_SHIFT
unsigned int CHARACTERISTIC_MASK = 1U << 31U;
extern unsigned int SOLID_TYPE;
extern unsigned int FLUID_TYPE;
extern unsigned int INLET_TYPE;
extern unsigned int OUTLET_TYPE;
extern unsigned int NULL_TYPE;

extern unsigned int BOUNDARIES;
extern unsigned int INLET_BOUNDARY;
extern unsigned int OUTLET_BOUNDARY;
extern unsigned int WALL_BOUNDARY;
extern unsigned int CHARACTERISTIC_BOUNDARY;

extern unsigned int SITE_TYPE_BITS;
extern unsigned int BOUNDARY_CONFIG_BITS;
extern unsigned int BOUNDARY_DIR_BITS;
extern unsigned int BOUNDARY_ID_BITS;

extern unsigned int BOUNDARY_CONFIG_SHIFT ; // SITE_TYPE_BITS;
extern unsigned int BOUNDARY_DIR_SHIFT; // BOUNDARY_CONFIG_SHIFT + BOUNDARY_CONFIG_BITS;
extern unsigned int BOUNDARY_ID_SHIFT; // BOUNDARY_DIR_SHIFT + BOUNDARY_DIR_BITS;

extern unsigned int SITE_TYPE_MASK; // ((1U << SITE_TYPE_BITS) - 1U);
extern unsigned int BOUNDARY_CONFIG_MASK; // ((1U << BOUNDARY_CONFIG_BITS) - 1U) << BOUNDARY_CONFIG_SHIFT;
extern unsigned int BOUNDARY_DIR_MASK; //((1U << BOUNDARY_DIR_BITS) - 1U) << BOUNDARY_DIR_SHIFT;
extern unsigned int BOUNDARY_ID_MASK; // ((1U << BOUNDARY_ID_BITS) - 1U) << BOUNDARY_ID_SHIFT
extern unsigned int CHARACTERISTIC_MASK;

// square of the speed of sound

double Cs2 = 3.0 / 8.0;
extern double Cs2;


// parameters related to the lattice directions

int e_x[] = { 0, 1,-1, 0, 0, 0, 0, 1,-1, 1,-1, 1,-1, 1,-1};
int e_y[] = { 0, 0, 0, 1,-1, 0, 0, 1,-1, 1,-1,-1, 1,-1, 1};
int e_z[] = { 0, 0, 0, 0, 0, 1,-1, 1,-1,-1, 1, 1,-1,-1, 1};
int inv_dir[] = {0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13};
extern int e_x[];
extern int e_y[];
extern int e_z[];
extern int inv_dir[];


#define MACROSCOPIC_PARS 5
Expand Down Expand Up @@ -165,20 +166,20 @@ struct Net
};


double *f_old, *f_new;
extern double *f_old, *f_new;

int *f_id;
extern int *f_id;

Velocity *vel;
extern Velocity *vel;


short int f_data[4*SHARED_DISTRIBUTIONS_MAX];
extern short int f_data[4*SHARED_DISTRIBUTIONS_MAX];

double f_to_send[SHARED_DISTRIBUTIONS_MAX];
double f_to_recv[SHARED_DISTRIBUTIONS_MAX];
extern double f_to_send[SHARED_DISTRIBUTIONS_MAX];
extern double f_to_recv[SHARED_DISTRIBUTIONS_MAX];

int f_send_id[SHARED_DISTRIBUTIONS_MAX];
int f_recv_iv[SHARED_DISTRIBUTIONS_MAX];
extern int f_send_id[SHARED_DISTRIBUTIONS_MAX];
extern int f_recv_iv[SHARED_DISTRIBUTIONS_MAX];


// declarations of all the functions used
Expand All @@ -194,7 +195,11 @@ void lbmFeq (double f[], double *density, double *v_x, double *v_y, double *v_z,
void lbmFeq (double density, double v_x, double v_y, double v_z, double f_eq[]);
void lbmDensityAndVelocity (double f[], double *density, double *v_x, double *v_y, double *v_z);
double lbmStress (double f[]);
void CalculateBC (double f[], unsigned int site_data,double *vx, double *vy, double *vz, LBM *lbm);
void lbmCalculateBC (double f[], unsigned int site_data,double *vx, double *vy, double *vz, LBM *lbm);
void lbmInit (char *system_file_name, char *parameters_file_name, char *checkpoint_file_name,
LBM *lbm, Net *net);
int lbmCycle (int write_checkpoint, int check_convergence, int *is_converged, LBM *lbm, Net *net);
void lbmEnd (LBM *lbm);

void netFindTopology (Net *net);
void netInit (LBM *lbm, Net *net);
Expand All @@ -206,39 +211,4 @@ void lbmSetInitialConditions (LBM *lbm, Net *net);
void lbmWriteConfig (int stability, char *output_file_name, int is_checkpoint, LBM *lbm, Net *net);



// some simple functions

int min (int a, int b)
{
if (a < b)
{
return a;
}
else
{
return b;
}
}


int max (int a, int b)
{
if (a > b)
{
return a;
}
else
{
return b;
}
}


double myClock ()
{
return (double)clock () / (double)CLOCKS_PER_SEC;
}


#endif // __config_h__
4 changes: 2 additions & 2 deletions Code/io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void lbmReadParameters (LBM *lbm)
lbm->viscosity = ((2.0 * lbm->tau - 1.0) / 6.0);

lbm->omega = -1.0 / lbm->tau;
lbm->stress_par = (1 - 2.0 / lbm->tau) / sqrt(2.0);
lbm->stress_par = (1.0 - 1.0 / (2.0 * lbm->tau)) / sqrt(2.0);

fscanf (parameters_file, "%i\n", &lbm->checkpoint_frequency);
fscanf (parameters_file, "%i\n", &lbm->convergence_frequency);
Expand Down Expand Up @@ -372,7 +372,7 @@ void lbmWriteConfig (int stability, char *output_file_name, int is_checkpoint, L
macroscopic_par_buffer[m*MACROSCOPIC_PARS+2] = (float)vy;
macroscopic_par_buffer[m*MACROSCOPIC_PARS+3] = (float)vz;
macroscopic_par_buffer[m*MACROSCOPIC_PARS+4] =
(float)(-lbm->stress_par * sqrt(lbmStress (f_neq)));
(float)(lbm->stress_par * sqrt(lbmStress (f_neq)));
}
}
if (net->id != 0 && net->proc_id[ n ] == net->id)
Expand Down
Loading

0 comments on commit d59a9e5

Please sign in to comment.