14 #include "allocation.hh" 15 #include "geometry.hh" 16 #include "skeleton.hh" 23 int main(
int argc,
char *argv[])
28 int *center_x, *center_y, *center_z;
40 string inputsFilename=
"foamreconstr.in";
42 string outputFilename;
44 string VTKInputFilename;
45 string GnuplotSkeletonFilename;
47 string GnuplotAltSkeletonFilename;
49 string descriptorsFilename;
51 string parametersFilename;
55 GnuplotSkeletonFilename,GnuplotAltSkeletonFilename,descriptorsFilename,\
58 string VTKOutputFilename=outputFilename+
".vtk";
59 string DXOutputFilename=outputFilename+
".dat";
65 ncell = 1 + (
nx - 1) /
sx ;
66 ncell = ncell * (1 + (
ny - 1) /
sy);
67 ncell = ncell * (1 + (
nz - 1) /
sz);
72 center_x = (
int *)calloc((
size_t)
ncell,
sizeof(int));
73 center_y = (
int *)calloc((
size_t)
ncell,
sizeof(int));
74 center_z = (
int *)calloc((
size_t)
ncell,
sizeof(int));
75 if (center_x == NULL || center_y == NULL || center_z == NULL) {
76 fprintf (stderr,
"Insufficient memory.\n");
86 fprintf (stderr,
"Insufficient memory.\n");
89 for (i = 0; i <
nx; i++)
90 for (j = 0; j <
ny; j++)
91 for (k = 0; k <
nz; k++)
110 remove(GnuplotSkeletonFilename.c_str());
114 saveToGnuplot(GnuplotAltSkeletonFilename,sv,incmax,vert,vinc,\
120 fprintf (stderr,
"Insufficient memory.\n");
124 struct fn1_params params = {sv,incmax,vmax,vert,vinc,smat,\
132 for (i=0;i<maxit;i++) {
141 cout <<
"Didn't find initial interval" << endl;
151 cout <<
"porosity of struts only " << por_s << endl;
168 for (i = 0; i <
nx; i++)
169 for (j = 0; j <
ny; j++)
170 for (k = 0; k <
nz; k++)
171 smat[i][j][k] = smat[i][j][k] + amat[i][j][k];
173 fs=(1-por_s)/(1-por);
175 cout <<
"porosity " << por << endl;
176 cout <<
"polymer in struts " << fs << endl;
bool openCell
make open cell foam
double porosity(int ***amat)
Calculates porosity.
void importFoamSkeleton(string filename, double **vert, int **vinc, int vmax, int incmax, int &sv, bool report)
Load geometric tessellation, move it to the domain and store it.
void saveDescriptors(string filename, double por, double fs, bool report)
Saves morphology descriptors (porosity and strut content) to a file.
bool progress_report
show detailed progress report
double dedge
parameter influencing size of struts in cell edges
void makeWalls(int ***amat, int ncell, int *center_x, int *center_y, int *center_z, bool report)
Creates walls based on position of seeds and Voronoi tessellation.
void readParameters(string filename, string &outputFilename, string &VTKInputFilename, string &GnuplotSkeletonFilename, string &GnuplotAltSkeletonFilename, string &descriptorsFilename, string ¶metersFilename)
bool save_voro_diag1
gnuplot Voronoi diagram
bool createEdges
create struts at cell edges
void saveToGnuplot(string filename, int sv, int incmax, double **vert, int **vinc, bool report)
Saves tessellation diagram to gnuplot file.
bool save_vtk
save file in new paraview style
int *** free_3Dmatrix(int ***amat)
free 3D integer matrix
bool save_voro_diag2
alternative gnuplot Voronoi diagram
double ** alloc_dmatrix(int nx, int ny)
allocate 2D double matrix
int optim(void *params, double &m, double &a, double &b, bool report)
GSL minimizer for univariate scalar function.
int *** allocateFromVTK(string filename, int ***amat, bool report)
Allocates the matrix from dimensions read from VTK file.
void saveToDX(const char *filename, int ***amat, bool report)
Saves morphology to DX file.
Defines global variables, macros, templates and namespace.
int ** alloc_matrix(int nx, int ny)
allocate 2D integer matrix
bool save_dat
save file in old dx style
void saveParameters(string filename, double dedge, bool report)
Saves parameters (dedge) to a file.
int main(int argc, char *argv[])
Reads parameters. Creates struts and walls. Saves foam morphology to a file.
int ** free_matrix(int **amat)
free 2D integer matrix
integer ncell
number of cells
void saveToVTK(const char *filename, int ***amat, bool report)
Saves morphology to VTK file.
bool createNodes
create struts at cell vertices
struct for passing paramaters to GSL function
integer nz
spatial discretization
namespace with global variables
void importFromVTK(string filename, int ***amat, bool report)
Reads morphology from VTK file. Changes amat.
double ** free_dmatrix(double **amat)
free 2D double matrix
void createSeeds(int &ncell, int *center_x, int *center_y, int *center_z, bool report)
Initialization of seeds. Stores positions of seeds.
bool import_vtk
import morphology from vtk
int *** alloc_3Dmatrix(int nx, int ny, int nz)
allocate 3D integer matrix
void makeFoamSkeleton(string filename, int ncell, int *center_x, int *center_y, int *center_z, bool report)
Make geometric tessellation using voro++ and store it to a file.