MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
geometry.cc
Go to the documentation of this file.
1 
6 #include "globals.hh"
7 using namespace globals;
9 bool in_domain(\
10  double x , \
11  double y , \
12  double z )
13 {
14  if (x>0 && x<nx && y>0 && y<ny && z>0 && z<nz)
15  return true;
16  else
17  return false;
18 }
20 double *CrossProduct(\
21  double a[] ,\
22  double b[] )
23 {
24  double *cp;
25  cp = new double[3];
26  cp[0]=a[1]*b[2]-a[2]*b[1];
27  cp[1]=a[2]*b[0]-a[0]*b[2];
28  cp[2]=a[0]*b[1]-a[1]*b[0];
29  return(cp);
30 }
32 bool SameSide(\
33  double p1[] ,\
34  double p2[] ,\
35  double a[] ,\
36  double b[] )
37 {
38  bool dec;
39  double ba[3],p1a[3],p2a[3];
40  int i;
41 
42  for (i=0; i<3; i++) {
43  ba[i]=b[i]-a[i];
44  p1a[i]=p1[i]-a[i];
45  p2a[i]=p2[i]-a[i];
46  }
47  double *cp1=CrossProduct(ba,p1a);
48  double *cp2=CrossProduct(ba,p2a);
49  dec=false;
50  if ((cp1[0]*cp2[0]+cp1[1]*cp2[1]+cp1[2]*cp2[2])>=0) dec=true;
51  delete cp1;
52  delete cp2;
53  return(dec);
54 }
57  double p[] ,\
58  double a[] ,\
59  double b[] ,\
60  double c[] )
61 {
62  bool dec;
63  dec=false;
64  if (SameSide(p,a, b,c) && SameSide(p,b, a,c) && SameSide(p,c, a,b)) {
65  dec=true;
66  }
67  return(dec);
68 }
70 double porosity(int ***amat ) {
71  double por=0;
72  int i,j,k;
73  for (i = 0; i < nx; i++) {
74  for (j = 0; j < ny; j++) {
75  for (k = 0; k < nz; k++) {
76  if (amat[i][j][k]==0) por++;
77  }
78  }
79  }
80  por /= nx*ny*nz;
81  return(por);
82 }
real(dp) porosity
foam porosity
Definition: globals.f90:49
int nz
domain size in Z
Definition: globals.cc:21
real(dp), dimension(:), allocatable y
state variables
Definition: globals.f90:106
Defines global variables, macros, templates and namespace.
bool SameSide(double p1[], double p2[], double a[], double b[])
True if two points are in the same half-plane defined by other two points.
Definition: geometry.cc:32
double * CrossProduct(double a[], double b[])
Cross product of two points in 3D.
Definition: geometry.cc:20
bool in_domain(double x, double y, double z)
True if the point is in the domain, False otherwise.
Definition: geometry.cc:9
real(dp) por
porosity
Definition: constants.f90:42
int nx
domain size in X
Definition: globals.cc:19
bool PointInTriangle(double p[], double a[], double b[], double c[])
True if point lies in the triangle.
Definition: geometry.cc:56
real(dp) cp
heat capacity of the reaction mixture
Definition: globals.f90:49
namespace with global variables
Definition: globals.f90:8
integer p
number of internal nodes
Definition: globals.f90:29
int ny
domain size in Y
Definition: globals.cc:20