Flow123d
output_tmp.cc
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2007 Technical University of Liberec. All rights reserved.
4  *
5  * Please make a following refer to Flow123d on your project site if you use the program for any purpose,
6  * especially for academic research:
7  * Flow123d, Research Centre: Advanced Remedial Technologies, Technical University of Liberec, Czech Republic
8  *
9  * This program is free software; you can redistribute it and/or modify it under the terms
10  * of the GNU General Public License version 3 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with this program; if not,
17  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.
18  *
19  *
20  * $Id$
21  * $Revision$
22  * $LastChangedBy$
23  * $LastChangedDate$
24  *
25  * @file output_tmp.cc
26  * @brief The functions for outputs to EVIL file formats.
27  *
28  */
29 
30 #if 0
31 
32 #include "io/output.h"
33 #include "xio.h"
34 #include "mesh.h"
35 //#include "problem.h"
36 
37 /**
38  * \brief This function does some initialization of evil file format.
39  */
40 void output_flow_field_init(char *fname)
41 {
42  FILE *out;
43 
44  if( OptGetBool("Output", "Write_output_file", "no") == false )
45  return;
46 
47  xprintf( Msg, "%s: Writing output files... %s ", __func__, fname);
48 
49  out = xfopen( fname, "wt" );
50  xfprintf( out, "$DataFormat\n" );
51  xfprintf( out, "1.0 0 %d\n", sizeof( double ) );
52  xfprintf( out, "$EndDataFormat\n" );
53  xfclose( out );
54 
55  xprintf( Msg, "O.K.\n");
56 }
57 
58 /**
59  * \brief This function write data to evil file format.
60  */
61 void output_flow_field_in_time(struct Problem *problem, double time)
62 {
63  Mesh* mesh = (Mesh*) ConstantDB::getInstance()->getObject(MESH::MAIN_INSTANCE);
64 
65  int i,cit;
66  ElementIter ele;
67  FILE *out;
68  char dbl_fmt[ 16 ];
69 
70  ASSERT(!( problem == NULL ),"NULL as argument of function output_flow_field_in_time()\n");
71  if( OptGetBool("Output", "Write_output_file", "no") == false )
72  return;
73 
74  xprintf( Msg, "%s: Writing output file %s ... ", __func__, problem->out_fname_2);
75 
76  out = xfopen( problem->out_fname_2, "at" );
77  sprintf( dbl_fmt, "%%.%dg ", ConstantDB::getInstance()->getInt("Out_digit"));
78  xfprintf( out, "$FlowField\n" );
79  xfprintf( out, "T = ");
80  xfprintf( out, dbl_fmt, time);
81  xfprintf( out, "\n%d\n", mesh->n_elements() );
82  cit = 0;
83 
84  FOR_ELEMENTS( ele ) {
85  xfprintf( out, "%d ", cit);
86  xfprintf( out, "%d ", ele.id());
87  xfprintf( out, dbl_fmt, ele->scalar);
88  xfprintf( out, " %d ", ele->n_sides);
89  for (i = 0; i < ele->n_sides; i++)
90  xfprintf( out, dbl_fmt, ele->side[i]->scalar);
91  xfprintf( out, "\t");
92  for (i = 0; i < ele->n_sides; i++)
93  xfprintf( out, dbl_fmt, ele->side[i]->flux);
94  xfprintf( out, "\t");
95  xfprintf( out, "%d ", ele->n_neighs_vv);
96  for (i = 0; i < ele->n_neighs_vv; i++)
97  xfprintf( out, "%d ", ele->neigh_vv[i]->id);
98  xfprintf( out, "\n" );
99  cit ++;
100  }
101  xfprintf( out, "$EndFlowField\n\n" );
102  xfclose( out );
103 
104  xprintf( Msg, "O.K.\n");
105 }
106 
107 #endif