<commit_before>#include <stdio.h>
#include <math.h>

#include "snapshot.h"
#include "types.h"

void snapshotSim(simBac *sim, errorCode *err)
{
    //For the csv file
    cInt chk = fprintf(sim->t_series_file, "%.6e,%" TYPES_WRITE ",%" \
        TYPES_WRITE ",%.6e\n", sim->t, sim->num_bac, sim->num_pro, sim->c_b);

    if(chk < 0)
    {
        *err = PRINT_FAIL;
        return;
    }

    //for the VTK file
    FILE *vtk_f;
    char vtk_file_name[LIMITS_MAX_LINE_LEN];
    snprintf(vtk_file_name, LIMITS_MAX_LINE_LEN, "pos_%s_%.4f.vtk", \
        sim->param.name_run, floor(sim->t/sim->param.snap_freq));
    
    vtk_f = fopen(vtk_file_name, "w");

    if(!vtk_f)
    {
        *err = ERR_CREATE_FILE;
        return;
    }

    chk = fprintf(vtk_f, "# vtk DataFile Version 2.0\n"
        "%s \nASCII \nDATASET POLYDATA \nPOINTS %" TYPES_WRITE 
        " float \n", vtk_file_name, sim->num_bac);
    if(chk < 0)
    {
        *err = PRINT_FAIL;
        goto ss_jmp1;
    }
    
    for (cInt i = 0; i < LIMITS_MAX_BACT; ++i)
    {
        if (sim->graph.bacteria[i].used)
        {
            chk = fprintf(vtk_f, "%.6e %.6e %.6e\n", \
                sim->graph.bacteria[i].pos[0],sim->graph.bacteria[i].pos[1], \
                sim->graph.bacteria[i].pos[2]);

            if(chk < 0)
            {
                *err = PRINT_FAIL;
                goto ss_jmp1;
            }

            
        }
    }
    
    for (cInt i = 0; i < LIMITS_MAX_BACT; ++i)
    {
        if (sim->graph.bacteria[i].used)
        {        
            chk = fprintf(vtk_f, "%" TYPES_WRITE"\n", (cInt)sim->graph.bacteria[i].enz );
            if(chk < 0)
            {
                *err = PRINT_FAIL;<commit_msg>added middle part of vtk file<commit_after>#include <stdio.h>
#include <math.h>

#include "snapshot.h"
#include "types.h"

void snapshotSim(simBac *sim, errorCode *err)
{
    //For the csv file
    cInt chk = fprintf(sim->t_series_file, "%.6e,%" TYPES_WRITE ",%" \
        TYPES_WRITE ",%.6e\n", sim->t, sim->num_bac, sim->num_pro, sim->c_b);

    if(chk < 0)
    {
        *err = PRINT_FAIL;
        return;
    }

    //for the VTK file
    FILE *vtk_f;
    char vtk_file_name[LIMITS_MAX_LINE_LEN];
    snprintf(vtk_file_name, LIMITS_MAX_LINE_LEN, "pos_%s_%.4f.vtk", \
        sim->param.name_run, floor(sim->t/sim->param.snap_freq));
    
    vtk_f = fopen(vtk_file_name, "w");

    if(!vtk_f)
    {
        *err = ERR_CREATE_FILE;
        return;
    }

    chk = fprintf(vtk_f, "# vtk DataFile Version 2.0\n"
        "%s \nASCII \nDATASET POLYDATA \nPOINTS %" TYPES_WRITE 
        " float \n", vtk_file_name, sim->num_bac);
    if(chk < 0)
    {
        *err = PRINT_FAIL;
        goto ss_jmp1;
    }
    
    for (cInt i = 0; i < LIMITS_MAX_BACT; ++i)
    {
        if (sim->graph.bacteria[i].used)
        {
            chk = fprintf(vtk_f, "%.6e %.6e %.6e\n", \
                sim->graph.bacteria[i].pos[0],sim->graph.bacteria[i].pos[1], \
                sim->graph.bacteria[i].pos[2]);

            if(chk < 0)
            {
                *err = PRINT_FAIL;
                goto ss_jmp1;
            }

            
        }
    }
    
    snprintf("POINT_DATA %" TYPES_WRITE "\n SCALARS enzyme" TYPES_WRITE  "float\n" "LOOKUP_TABLE Producers\n"
    
    for (cInt i = 0; i < LIMITS_MAX_BACT; ++i)
    {
        if (sim->graph.bacteria[i].used)
        {        
            chk = fprintf(vtk_f, "%" TYPES_WRITE"\n", (cInt)sim->graph.bacteria[i].enz );
            if(chk < 0)
            {
                *err = PRINT_FAIL;
{'fraction_non_alphanumeric': 0.15590639977445728, 'fraction_numerical': 0.010713278827177897, 'mean_word_length': 1.7440061871616397, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5283060', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1417, 'n_words': 241}