Commit 10bfbb51 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

n fluids : missing python

parent 3ba83798
This diff is collapsed.
......@@ -38,25 +38,23 @@ typedef struct {
char *tag;
int field;
void (*apply)(int n, const double *x, double *bnd);
}StrongBoundary;
} StrongBoundary;
typedef struct {
double epsilon;
double rho;
double mu;
double alpha;
double *rho;
double *mu;
double g;
Mesh *mesh;
MeshTree *mesh_tree;
double *porosity;
double *old_porosity;
double *compacity;
double *old_compacity;
double *solution;
double *solution_explicit;
double *node_volume;
int n_strong_boundaries;
StrongBoundary *strong_boundaries;
HXTLinearSystem *linear_system;
int n_particles;
double *particle_uvw;
double *particle_position;
......@@ -65,6 +63,7 @@ typedef struct {
double *particle_mass;
double *particle_force;
int *particle_element_id;
int n_fluids;
} FluidProblem;
int fluid_problem_export(const FluidProblem *problem, const char *output_dir, double t, int iter);
......@@ -75,7 +74,7 @@ void fluid_problem_compute_node_particle_force(FluidProblem *problem, double dt,
int fluid_problem_implicit_euler(FluidProblem *problem, double dt);
void fluid_problem_set_particles(FluidProblem *problem, int n, double *mass, double *volume, double *position, double *velocity, long int *elid, int init);
void fluid_problem_free(FluidProblem *problem);
FluidProblem *fluid_problem_new(const char *mesh_file_name, double g, double mu, double rho, double epsilon, int n_strong_boundaries, StrongBoundary *strong_boundaries, int noGrains);
FluidProblem *fluid_problem_new(const char *mesh_file_name, double g, double *mu, double *rho, double epsilon, int n_strong_boundaries, StrongBoundary *strong_boundaries, int noGrains, int n_fluids);
void fluid_problem_adapt_mesh(FluidProblem *problem, double lcmax, double lcmin, double n_el);
int *fluid_problem_particle_element_id(FluidProblem *problem);
int fluid_problem_n_particles(FluidProblem *problem);
......
......@@ -38,7 +38,7 @@ int fluid_problem_export(const FluidProblem *problem, const char *output_dir, do
}
if(mesh_write_msh(problem->mesh, f))
return -1;
if(mesh_write_msh_scalar(problem->mesh, f, "porosity", t, iter, problem->porosity, 1, 0))
if(mesh_write_msh_scalar(problem->mesh, f, "compacity", t, iter, problem->compacity, 1, 0))
return -1;
int comp[]={0,1,2};
if(mesh_write_msh_vector(problem->mesh, f, "uv", t, iter, problem->solution, n_fields, comp))
......@@ -101,11 +101,11 @@ int fluid_problem_import_vtk(FluidProblem *problem, const char *filename)
else if (!strcasecmp(e.name,"PointData")) {
if (problem->solution)
free(problem->solution);
problem->solution = malloc(sizeof(double)*(DIMENSION+1)*m->n_nodes);
problem->solution = (double*)malloc(sizeof(double)*(DIMENSION+1)*m->n_nodes);
while(mb_read_vtk_data_array(r,&a) != 0){
if(!strcasecmp(a.name,"Porosity")) {
free(problem->porosity);
problem->porosity = mb_vtk_data_array_to_double(&a,m->n_nodes,1);
if(!strcasecmp(a.name,"Compacity")) {
free(problem->compacity);
problem->compacity = mb_vtk_data_array_to_double(&a,m->n_nodes,1);
}
else if(!strcasecmp(a.name,"Pressure")) {
double *p = mb_vtk_data_array_to_double(&a,m->n_nodes,1);
......@@ -134,12 +134,12 @@ int fluid_problem_import_vtk(FluidProblem *problem, const char *filename)
mb_xml_read_element(r,&fielddataelement);
int n_phys=0;
int n_phys_alloc = 10;
MBVtkDataArray *phys = malloc(sizeof(MBVtkDataArray)*10);
MBVtkDataArray *phys =(MBVtkDataArray*) malloc(sizeof(MBVtkDataArray)*10);
while(mb_read_vtk_data_array(r,&a) != 0){
if(!strncasecmp(a.name,"Physical ",9)) {
if (n_phys == n_phys_alloc) {
n_phys_alloc *= 2;
phys = realloc(phys,n_phys_alloc*sizeof(MBVtkDataArray));
phys = (MBVtkDataArray*)realloc(phys,n_phys_alloc*sizeof(MBVtkDataArray));
}
phys[n_phys++] = a;
}
......@@ -152,11 +152,11 @@ int fluid_problem_import_vtk(FluidProblem *problem, const char *filename)
free(m->phys_name[i]);
free(m->phys_nodes[i]);
}
m->phys_id=realloc(m->phys_id,n_phys*sizeof(int));
m->phys_dimension=realloc(m->phys_dimension,n_phys*sizeof(int));
m->phys_n_nodes=realloc(m->phys_n_nodes,n_phys*sizeof(int));
m->phys_name = realloc(m->phys_name,n_phys*sizeof(char*));
m->phys_nodes = realloc(m->phys_nodes,n_phys*sizeof(int*));
m->phys_id = (int*)realloc(m->phys_id,n_phys*sizeof(int));
m->phys_dimension = (int*)realloc(m->phys_dimension,n_phys*sizeof(int));
m->phys_n_nodes = (int*)realloc(m->phys_n_nodes,n_phys*sizeof(int));
m->phys_name = (char**)realloc(m->phys_name,n_phys*sizeof(char*));
m->phys_nodes = (int**)realloc(m->phys_nodes,n_phys*sizeof(int*));
for(int i = 0; i < n_phys; ++i) {
MBVtkDataArray a = phys[i];
int p, n;
......@@ -221,9 +221,9 @@ int fluid_problem_export_vtk(const FluidProblem *problem, const char *output_dir
fprintf(f,"\n</DataArray>\n");
fprintf(f,"</Cells>\n");
fprintf(f,"<PointData Scalars=\"Porosity Pressure\" Vectors=\"Velocity\">\n");
fprintf(f,"<DataArray Name=\"Porosity\" NumberOfComponents = \"1\" type=\"Float64\" format=\"ascii\">\n");
fprintf(f,"<DataArray Name=\"Compacity\" NumberOfComponents = \"1\" type=\"Float64\" format=\"ascii\">\n");
for (int i = 0; i < mesh->n_nodes; ++i) {
fprintf(f, "%g ", problem->porosity[i]);
fprintf(f, "%g ", problem->compacity[i]);
}
fprintf(f,"\n</DataArray>\n");
fprintf(f,"<DataArray Name=\"Pressure\" NumberOfComponents = \"1\" type=\"Float64\" format=\"ascii\">\n");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment