📄 visl.c
字号:
/*--------------------------------------------------------------------------Free Finite Element Package Copyright (c) 2002-2006 by Joerg FrochteAll rights reserved.Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditionsare met:1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOTLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FORA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER ORCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, ORPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDINGNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THISSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.----------------------------------------------------------------------------*/# include "visl.h"/** * \file * \brief Exports data for visualisation e.g. with gnuplot or freepdeplot * \author Joerg Frochte */void visl_write_gnuplotdata (char *filename, MESH * mesh, VECTOR * u){ VECTOR *x; VECTOR *y; int i=0; x = meml_vector_new(mesh->number_of_points); y = meml_vector_new(mesh->number_of_points); for (i=0;i<mesh->number_of_points;i++) { x->data[i] = mesh->points->data[2*i]; y->data[i] = mesh->points->data[2*i+1]; } meml_vector_export2dat (filename,3,x,y,u); meml_vector_free(x); meml_vector_free(y);}int visl_write_plotdata (char *filename, const LEGEND legende, MESH * mesh, VECTOR * u1, VECTOR * u2){ FILE *tempdata; char typ = 's'; int j, tempint; float tempfloat; if (u2 != NULL) { if (u1->dim != u2->dim) { fprintf (stderr, "visl_write_plotdata: " "The vectors must be of the same size.\n\n"); return (EXIT_FAILURE); } typ = 'f'; } tempdata = fopen (filename, "wb"); /* globale daten */ fwrite (&typ, sizeof (char), 1, tempdata); fwrite (&legende, sizeof (LEGEND), 1, tempdata); /* die daten pro frame */ tempint = mesh->number_of_triangles; fwrite (&tempint, sizeof (int), 1, tempdata); fwrite (mesh->triangles->data, sizeof (int), mesh->number_of_triangles * 3, tempdata); tempint = mesh->points->dim / 2; fwrite (&tempint, sizeof (int), 1, tempdata); for (j = 0; j < mesh->points->dim; j++) { tempfloat = mesh->points->data[j]; fwrite (&tempfloat, sizeof (float), 1, tempdata); } for (j = 0; j < mesh->number_of_points; j++) { tempfloat = u1->data[j]; fwrite (&tempfloat, sizeof (float), 1, tempdata); } if (u2 != NULL) { for (j = 0; j < mesh->number_of_points ; j++) { tempfloat = u2->data[j]; fwrite (&tempfloat, sizeof (float), 1, tempdata); } } fclose (tempdata); return (EXIT_SUCCESS);}char visl_load_plotdata (char *filename, LEGEND * legende, VECTOR ** points, INDEXARRAY ** triangles, VECTOR ** u1, VECTOR ** u2){ FILE *tempdata; char typ = 's'; int j; float tempfloat; int number_of_triangles; int number_of_points; tempdata = fopen (filename, "r"); /* globale daten */ fread (&typ, sizeof (char), 1, tempdata); fread (legende, sizeof (LEGEND), 1, tempdata); /* die daten pro frame */ fread (&(number_of_triangles), sizeof (int), 1, tempdata); (*triangles) = meml_indexarray_new(number_of_triangles*3); fread ( (*triangles)->data, sizeof (int), number_of_triangles * 3, tempdata); fread (&(number_of_points), sizeof (int), 1, tempdata); (*points) = meml_vector_new(number_of_points*2); for (j = 0; j < 2*number_of_points; j++) { fread (&tempfloat, sizeof (float), 1, tempdata); (*points)->data[j] = tempfloat; } (*u1) = meml_vector_new(number_of_points); for (j = 0; j < number_of_points; j++) { fread (&tempfloat, sizeof (float), 1, tempdata); (*u1)->data[j] = tempfloat; } if (typ == 'f') { (*u2) = meml_vector_new(number_of_points); for (j = 0; j < number_of_points; j++) { fread (&tempfloat, sizeof (float), 1, tempdata); (*u2)->data[j] = tempfloat; } } fclose (tempdata); return (typ);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -