1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
/* Routine to process the output of the finite element cycles
and to turn them into a coherent suite of files.
*/
#include <math.h>
#if(!defined __GNUC__)
#include <malloc.h>
#include <stdlib.h> /* for "system" command */
#endif
#ifndef __sunos__ /* string manipulations */
#include <strings.h>
#else
#if(!defined __GNUC__)
#include <string.h>
#endif
#endif
#if(!defined __GNUC__)
#include <rpc/rpc.h>
#include <rpc/xdr.h>
#endif
#include "element_definitions.h"
#include "global_defs.h"
/* Output files are created, if requested, using the global filename plus a numerical tag.
Data is stored according to type:
1. Nodal information (for a given timestep)
2. Horizontal averages (for a given timestep)
3. Surface observables (and other slices) (for a given timestep).
4. Large-scale averages recorded as time sequence.
The format of the output is a header including individual column labels
which are required because the information stored can vary. The
comment character in these files is a `#' terminated by the end of the
line.
NOTE FOR IMPROVEMENT: THE NODE OUTPUT STRING CAN BE USED FOR THE COLUMN LABELLING
INSTEAD OF DOING THE CHECKING TWICE.
*/
void generic_data_storage(
struct All_variables *E,
int file_number
)
{
int i,j,k,ii,number,node,data_length,sample,l,m,el;
int record_everything,checkpt_and_log,only_timelog;
char output_file[255];
char output_filePPM[255];
char command[255];
FILE *fp;
int i_tmp,block,tr;
float f_tmp;
double d_tmp;
float *data_array;
static int been_here=0;
static int time_files=0;
float test;
standard_precision storage_timing,checkpt_timing;
standard_precision time,time1,CPU_time();
standard_precision errorva,errorvr,errorra,errorrr,R,Gc,G,sum1,sum2,sum,sumcte,sumerrorav,sumerrorar,sumerrorrv,sumerrorrr;
standard_precision CC,DD,Co,Si,MM,ave,delta,AA,BB,ta,mu,sigma,omeg,eta1,eta2,eta3,fact,Q,QQ,VV[5];
standard_precision lN[ELNMAX+1],visc,visc_bulk,theo_GR,axial_stress,stress;
standard_precision vel[1000],velfft[1000],mag ;
standard_precision Omega0,Omega1,Omega2,xsie,xsip,kk,a,b,c,k0 ;
standard_precision maxP,minP,meanP,S11,S12,S22,deflection,upper,lower ;
const int dofs = E->mesh.dof;
const int dims = E->mesh.nsd;
const int nno = E->mesh.nno;
const int outputcase = E->control.outputcase;
/* The data files are written permanently once every "storage_timesteps" steps.
This is computed in the mean sense .... once the time since the last
write exceeds "storage_timesteps" * the mean timestep then the data are
saved for posterity. Otherwise they are just checkpointed
to the .00000. files */
/*i=524 ;
fprintf(E->fp2,"%.7e %.7e %.7e %.7e %.7e \n",E->monitor.elapsed_time,
E->tracer.S11[i],E->tracer.S22[i],E->tracer.S12[i],E->tracer.Pt[i]);*/
fflush(E->fp1) ;
fflush(E->fp2) ;
/* If timings have already been supplied, then use these.
Otherwise compute them */
if(E->control.storage_timing != 0.0)
storage_timing = E->control.storage_timing;
else if(E->advection.total_timesteps != 0)
storage_timing = (E->monitor.elapsed_time/E->advection.total_timesteps) * E->control.storage_timesteps;
if(E->control.checkpt_timing != 0.0)
checkpt_timing = E->control.checkpt_timing;
else if(E->advection.total_timesteps != 0)
checkpt_timing = (E->monitor.elapsed_time/E->advection.total_timesteps) * E->control.checkpt_timesteps;
/* What to do ? */
record_everything = checkpt_and_log = 0;
if(E->monitor.solution_cycles == 1) {
record_everything = 1;
checkpt_and_log=1;
}
else if ((E->monitor.elapsed_time - E->monitor.time_of_last_store) > storage_timing) {
record_everything = 1;
checkpt_and_log = 1;
E->monitor.time_of_last_store = E->monitor.time_of_last_checkpt = E->monitor.elapsed_time;
}
else if ((E->monitor.elapsed_time - E->monitor.time_of_last_checkpt) > checkpt_timing) {
E->monitor.time_of_last_checkpt = E->monitor.elapsed_time;
checkpt_and_log = 1;
}
time1=CPU_time();
/* Periodic boundary conditions do not calculate anything on the
wrapped around edge nodes. These must be copied before storing
the data */
if(E->mesh.periodic_x || E->mesh.periodic_y) {
flogical_mesh_to_real(E,E->NQ[E->mesh.levmax],E->mesh.levmax);
flogical_mesh_to_real(E,E->T,E->mesh.levmax);
flogical_mesh_to_real(E,E->Psi,E->mesh.levmax);
flogical_mesh_to_real(E,E->V[1],E->mesh.levmax);
flogical_mesh_to_real(E,E->V[2],E->mesh.levmax);
if(3==dofs) {
flogical_mesh_to_real(E,E->V[3],E->mesh.levmax);
}
else if(6==dofs) {
flogical_mesh_to_real(E,E->V[3],E->mesh.levmax);
flogical_mesh_to_real(E,E->V[4],E->mesh.levmax);
flogical_mesh_to_real(E,E->V[5],E->mesh.levmax);
flogical_mesh_to_real(E,E->V[6],E->mesh.levmax);
}
}
if(checkpt_and_log) {
/* As it is time-consuming to compute the nodal plastic strain
value, do this only if it needs to be printed out ... */
if((strstr(E->control.node_data.which_data_types,"Pstn"))) {
if(E->advection.timesteps > 0)
gs_tracers_to_nodes(E,E->Pstrain,NULL,NULL,NULL,E->tracer.edotp_integrated,E->mesh.levmax,0);
}
/* Generate pixmap for 2D data */
if((E->control.verbose || checkpt_and_log) && E->mesh.nsd == 2 && !E->control.CYLINDER && !E->control.SPHERE) {
sprintf(output_filePPM,"%s.%05d.ppm",E->control.data_file,file_number);/*sprintf(output_file,"Fichier.ppm");*//*Test*/
generate_2Ddata_pixmap(E,output_filePPM);
}
}
been_here++;
return;
free(output_file);
free(output_filePPM);
free(command);
} |
Partager