~meshing/meshing/urop

« back to all changes in this revision

Viewing changes to shape/testParamForGeo.c

  • Committer: Adam Candy
  • Date: 2013-07-23 18:17:18 UTC
  • Revision ID: adam.candy@imperial.ac.uk-20130723181718-vi35hxtsvopa74z4
Final fix (hopefully).
Licensing formally implemented.  Please update your branches and any derivative works.
Additional tidying and restructure.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
//  
22
22
//////////////////////////////////////////////////////////////////////////
23
23
 
24
 
#include <stdio.h>
25
 
#include <string.h>
26
 
#include <stlib.h>
27
 
 
28
 
#define VAL 10
29
 
#define SUCCESS 1
30
 
#define MATH_EVAL_LINE 38
31
 
#define BUFFER_SIZE 300
32
 
 
33
 
int showMesh(void) {
34
 
        int i = system("gmsh -2 box.geo");
35
 
        if (i==-1)
36
 
                return i;
37
 
        system("gmsh box.msh");
38
 
        return SUCCESS
39
 
}
40
 
 
41
 
void changeMathEval(int new) {
42
 
        FILE *read;
43
 
  read = fopen("box.geo","r");
44
 
        FILE *write;
45
 
        write = fopen("temp.geo","w");
46
 
        if (write==NULL) {
47
 
          perror("ERROR in opening file to write\n");
48
 
    exit(EXIT_FAILURE);
49
 
        }
50
 
  char *buffer = (char *) malloc(BUFFER_SIZE * sizeof(char));
51
 
  if (read==NULL) {
52
 
    perror("ERROR in opening file\n");
53
 
    exit(EXIT_FAILURE);
54
 
  }
55
 
        int i = 1;
56
 
  while (!feof(read)){
57
 
    memset(buffer, 0, ((sizeof(char))*BUFFER_SIZE));
58
 
    fgets (buffer, BUFFER_SIZE, read); 
59
 
                if (i==MATH_EVAL_LINE) {
60
 
                        char *temp = calloc(BUFFER_SIZE);
61
 
                        temp = strncpy(temp,buffer,strlen(buffer)-5);
62
 
                        char *num = calloc((new/10) + 2);
63
 
                        temp = strcpy(temp,itoa(new,num,10));
64
 
                        fputs(temp,write);
65
 
                        fputs(";\n",write);
66
 
                        free(temp);
67
 
                        free(num);
68
 
                } else {
69
 
                        fputs(buffer,write);
70
 
                }
71
 
                i++;
72
 
  }
73
 
  free(buffer);
74
 
        free(read);
75
 
        free(write);
76
 
  fclose(read);
77
 
}
78
 
 
79
 
int main(void) {
80
 
        for ( int i = 0; i< ; i+=15) {
81
 
                changeMathEval(i);
82
 
                showMesh();
83
 
 
84
 
        }
85
 
}
 
24
//////////////////////////////////////////////////////////////////////////
 
25
//  
 
26
//  Generation of boundary representation from arbitrary geophysical
 
27
//  fields and initialisation for anisotropic, unstructured meshing.
 
28
//  
 
29
//  Copyright (C) 2011-2013 Dr Adam S. Candy, adam.candy@imperial.ac.uk
 
30
//  
 
31
//  This program is free software: you can redistribute it and/or modify
 
32
//  it under the terms of the GNU General Public License as published by
 
33
//  the Free Software Foundation, either version 3 of the License, or
 
34
//  (at your option) any later version.
 
35
//  
 
36
//  This program is distributed in the hope that it will be useful,
 
37
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
38
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
39
//  GNU General Public License for more details.
 
40
//  
 
41
//  You should have received a copy of the GNU General Public License
 
42
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
43
//  
 
44
//////////////////////////////////////////////////////////////////////////
 
45