📄 cfield.cpp
字号:
/*==============================================================================
O F E L I
Object Finite Element Library
==============================================================================
Copyright (C) 1998 - 2004 Rachid Touzani
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; Version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the :
Free Software Foundation
Inc., 59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
==============================================================================
c f i e l d
A Program to convert various formats of field files
==============================================================================*/
#include "Mesh.h"
#include "FDF.h"
#include "NodeVect.h"
#include "FromToFDF.h"
using namespace OFELI;
int main(int argc, char *argv[])
{
char file[FILENAME_LENGTH], input_file[FILENAME_LENGTH];
char output_file[FILENAME_LENGTH], descript_file[FILENAME_LENGTH];
char mesh_file[FILENAME_LENGTH], ext[20];
int flag = 1;
int wm = 0;
FILE *fp=NULL, *fdesc=NULL;
cout << "\n\n";
cout << "cfield, version 1.1, Copyright (c) 1998 - 2004 by Rachid Touzani\n";
cout << "cfield comes with ABSOLUTELY NO WARRANTY.\n";
cout << "This is free software, and your are allowed to redistribute it\n";
cout << "under certain conditions. Details are distributed with the software." << endl;
// Expand arguments
if (argc < 4) {
cout << "\nUsage: cfield <file> <input extension> <output format> [<options>]";
cout << "\n\nAvailable output formats are:\n";
cout << "\n -gmsh : Gmsh Postprocessing File (*.pos)";
cout << "\n -gpl : Gnuplot File (*.gpl)";
cout << "\n -tec : Tecplot file (*.dat)";
cout << "\n -vig : Vigie file (*.vig)";
cout << "\n -vigt : Same as -vig except that it adds time dimension (for 1-D and 2-D) (*.vigt)";
cout << "\n -vtk : vtk file (*.vtk)";
cout << "\n -wm : Save on plot file the mesh for each time step";
cout << endl;
return 0;
}
strcpy(file,argv[1]);
strcpy(ext,argv[2]);
if (strcmp(argv[3],"-gpl") == 0)
flag = 1;
else if (strcmp(argv[3],"-tec") == 0)
flag = 2;
else if (strcmp(argv[3],"-vig") == 0)
flag = 3;
else if (strcmp(argv[3],"-vigt") == 0)
flag = 4;
else if (strcmp(argv[3],"-vtk") == 0)
flag = 5;
else if (strcmp(argv[3],"-gmsh") == 0)
flag = 6;
if (argc > 5)
if (strcmp(argv[4],"-wm") == 0)
wm = 1;
cout << " cfield\n\n A Program to convert field files\n\n";
//----------
// I N P U T
//----------
strcpy(mesh_file,strcat(strcpy(file,argv[1]),".m"));
Mesh mesh(mesh_file);
strcpy(input_file,strcat(strcpy(file,argv[1]),"."));
strcat(input_file,ext);
NodeVect<double> v(mesh);
FDF ff(input_file,FDF_READ);
//------------
// O U T P U T
//------------
int option = 0;
switch (flag) {
// GnuPlot File
case 1 : strcpy(output_file,strcat(strcpy(file,argv[1]),".gpl"));
cout << "Saving gnuplot file " << output_file << " ...\n";
FDF2Gnuplot(output_file,mesh,ff,v);
break;
// TecPlot File
case 2 : strcpy(output_file,strcat(strcpy(file,argv[1]),"_tecplot.dat"));
cout << "Saving Tecplot file " << output_file << " ...\n";
FDF2Tecplot(output_file,mesh,ff,v,option++,wm);
break;
// Vigie File time index's variables
case 3 : strcpy(output_file,strcat(strcpy(file,argv[1]),".vig"));
fp = fopen(output_file,"w");
cout << "Saving Vigie file " << output_file << " ...\n";
strcpy(descript_file,strcat(strcpy(file,argv[1]),".desc"));
fdesc = fopen(descript_file,"w");
cout << "Saving description file " << descript_file << " ...\n";
fprintf(fdesc,"ascii%dd \n",mesh.Dim());
fprintf(fdesc,"%s \n",output_file);
FDF2Vigie(fp,fdesc,input_file,mesh,v,option,wm);
break;
// Vigie File where we add the time as a new dimension
case 4 : strcpy(output_file,strcat(strcpy(file,argv[1]),".vigt"));
fp = fopen(output_file,"w");
cout << "Saving Vigie file " << output_file << " ...\n";
strcpy(descript_file,strcat(strcpy(file,argv[1]),".desc"));
fdesc = fopen(descript_file,"w");
cout << "Saving Description file " << descript_file << " ...\n";
fprintf(fdesc,"ascii%dd \n",mesh.Dim()+1);
fprintf(fdesc,"%s \n",output_file);
FDF2VigiewTime(fp,fdesc,input_file,mesh,v,option,wm);
break;
// vtk File
case 5 : strcpy(output_file,strcat(strcpy(file,argv[1]),".vtk"));
cout << "Saving vtk file " << output_file << " ...\n";
FDF2VTK(output_file,mesh,ff,v);
break;
// Gmsh File
case 6 : strcpy(output_file,strcat(strcpy(file,argv[1]),".pos"));
cout << "Saving Gmsh file " << output_file << " ...\n";
FDF2Gmsh(output_file,mesh,ff,v);
break;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -