static int ParseEngineData(void* user, const char* section, const char* name, const char* value) { EngineData* data = user; // Look through the chemistry section and get the information we need. if (MATCH("chemistry", "engine")) strncpy(data->engine_name, value, kAlquimiaMaxStringLength); else if (MATCH("chemistry", "input_file")) strncpy(data->input_file, value, kAlquimiaMaxStringLength); else if (MATCH("chemistry", "hands_off")) data->hands_off = ValueIsTrue(value); return 1; }
// Input parsing stuff. See https://github.com/benhoyt/inih for details. static int ParseInput(void* user, const char* section, const char* name, const char* value) { TransportDriverInput* input = user; #define MATCH(s, n) (strcmp(section, s) == 0) && (strcmp(name, n) == 0) // Simulation section if (MATCH("simulation","description")) input->description = AlquimiaStringDup(value); else if (MATCH("simulation", "hands_off")) input->hands_off = ValueIsTrue(value); else if (MATCH("simulation","t_min")) input->t_min = atof(value); else if (MATCH("simulation","t_max")) input->t_max = atof(value); else if (MATCH("simulation","max_steps")) input->max_steps = atoi(value); else if (MATCH("simulation","timestep")) input->dt = atof(value); else if (MATCH("simulation", "cfl_factor")) input->cfl_factor = atof(value); // Domain section. else if (MATCH("domain", "x_min")) input->x_min = atof(value); else if (MATCH("domain", "x_max")) input->x_max = atof(value); else if (MATCH("domain", "num_cells")) input->num_cells = atoi(value); // Material section. else if (MATCH("material", "porosity")) input->porosity = atof(value); else if (MATCH("material", "saturation")) input->saturation = atof(value); // Flow section. else if (MATCH("flow", "temperature")) input->temperature = atof(value); else if (MATCH("flow", "velocity")) input->velocity = atof(value); // Chemistry section. else if (MATCH("chemistry", "engine")) input->chemistry_engine = AlquimiaStringDup(value); else if (MATCH("chemistry", "input_file")) input->chemistry_input_file = AlquimiaStringDup(value); else if (MATCH("chemistry", "initial_condition")) input->ic_name = AlquimiaStringDup(value); else if (MATCH("chemistry", "left_boundary_condition")) input->left_bc_name = AlquimiaStringDup(value); else if (MATCH("chemistry", "right_boundary_condition")) input->right_bc_name = AlquimiaStringDup(value); else if (MATCH("chemistry", "cation_exchange_capacity")) input->cation_exchange_capacity = atof(value); else if (MATCH("chemistry", "surface_site_density")) input->surface_site_density = atof(value); // Output section. else if (MATCH("output", "verbose")) input->verbose = ValueIsTrue(value); else if (MATCH("output", "type")) input->output_type = AlquimiaStringDup(value); else if (MATCH("output", "filename")) input->output_file = AlquimiaStringDup(value); return 1; }