OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
outputexportmodule.C
Go to the documentation of this file.
1 /*
2  *
3  * ##### ##### ###### ###### ### ###
4  * ## ## ## ## ## ## ## ### ##
5  * ## ## ## ## #### #### ## # ##
6  * ## ## ## ## ## ## ## ##
7  * ## ## ## ## ## ## ## ##
8  * ##### ##### ## ###### ## ##
9  *
10  *
11  * OOFEM : Object Oriented Finite Element Code
12  *
13  * Copyright (C) 1993 - 2013 Borek Patzak
14  *
15  *
16  *
17  * Czech Technical University, Faculty of Civil Engineering,
18  * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28  * Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free Software
32  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33  */
34 
35 #include <vector>
36 #include <cstdio>
37 
38 #include "outputexportmodule.h"
39 #include "engngm.h"
40 #include "domain.h"
41 #include "node.h"
42 #include "element.h"
43 #include "timestep.h"
44 #include "classfactory.h"
45 
46 namespace oofem {
48 
49 OutputExportModule :: OutputExportModule(int n, EngngModel *e) : ExportModule(n, e), outputStream(NULL)
50 {
51 }
52 
55 {
56  IRResultType result; // Required by IR_GIVE_FIELD macro
57 
58  nodeSets.clear();
62 
63  result = ExportModule :: initializeFrom(ir);
64 
65  auto *file = giveOutputStream();
66 
67  fprintf(file, "%s", PRG_HEADER);
68  fprintf(file, "\nStarting analysis on: %s\n", ctime(& emodel->giveStartTime()) );
69  fprintf(file, "%s\n", emodel->giveDescription().c_str());
70 
71  return result;
72 }
73 
74 FILE *
76 {
77  if ( this->outputStream ) return this->outputStream;
78  this->outputStream = fopen(emodel->giveOutputBaseFileName().c_str(), "w");
79  if ( !this->outputStream ) {
80  OOFEM_ERROR("Can't open output file %s", emodel->giveOutputBaseFileName().c_str());
81  }
82  return this->outputStream;
83 }
84 
85 void
86 OutputExportModule :: doOutput(TimeStep *tStep, bool forcedOutput)
87 {
88  if ( !( testTimeStepOutput(tStep) || forcedOutput ) ) {
89  return;
90  }
91 
92  FILE *file = this->giveOutputStream();
93 
94  fprintf(file, "\n==============================================================");
95  fprintf(file, "\nOutput for time %.8e ", tStep->giveTargetTime() * emodel->giveVariableScale(VST_Time) );
96  fprintf(file, "\n==============================================================\n");
97 
98  emodel->printOutputAt(file, tStep, nodeSets, elementSets);
99 
100  fprintf(file, "\nUser time consumed by solution step %d: %.3f [s]\n\n", tStep->giveNumber(), emodel->giveSolutionStepTime());
101 }
102 
103 void
105 {
106  FILE *out = this->giveOutputStream();
107  int rhrs, rmin, rsec, uhrs, umin, usec;
108  time_t endTime = time(NULL);
109 
110  emodel->giveAnalysisTime(rhrs, rmin, rsec, uhrs, umin, usec);
111 
112  fprintf(out, "\nFinishing analysis on: %s\n", ctime(& endTime) );
113  fprintf(out, "Real time consumed: %03dh:%02dm:%02ds\n", rhrs, rmin, rsec);
114  fprintf(out, "User time consumed: %03dh:%02dm:%02ds\n\n\n", uhrs, umin, usec);
115 }
116 
117 } // end namespace oofem
#define _IFT_OutputExportModule_elementSets
Standard output for OOFEM.
bool testTimeStepOutput(TimeStep *tStep)
Tests if given time step output is required.
Definition: exportmodule.C:148
std::string giveOutputBaseFileName()
Returns base output file name to which extensions, like .out .vtu .osf should be added.
Definition: engngm.h:363
IntArray nodeSets
Set which contains nodes which should be exported.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
virtual void doOutput(TimeStep *tStep, bool forcedOutput=false)
Writes the output.
IntArray elementSets
Set which contains elements which should be exported.
double giveTargetTime()
Returns target time.
Definition: timestep.h:146
Represents export output module - a base class for all output modules.
Definition: exportmodule.h:71
int giveNumber()
Returns receiver&#39;s number.
Definition: timestep.h:129
#define OOFEM_ERROR(...)
Definition: error.h:61
virtual double giveVariableScale(VarScaleType varId)
Returns the scale factor for given variable type.
Definition: engngm.h:1087
void clear()
Clears the array (zero size).
Definition: intarray.h:177
virtual void terminate()
Terminates the receiver.
EngngModel * emodel
Problem pointer.
Definition: exportmodule.h:77
const time_t & giveStartTime()
Definition: engngm.h:345
double giveSolutionStepTime()
Returns the user time of the current simulation step in seconds.
Definition: engngm.C:1802
#define _IFT_OutputExportModule_nodeSets
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Definition: exportmodule.C:58
Class representing the general Input Record.
Definition: inputrecord.h:101
virtual void printOutputAt(FILE *file, TimeStep *tStep)
Prints output of receiver to output domain stream, for given time step.
Definition: engngm.C:695
const std::string & giveDescription() const
Definition: engngm.h:344
void giveAnalysisTime(int &rhrs, int &rmin, int &rsec, int &uhrs, int &umin, int &usec)
Returns the real and user time for the analysis.
Definition: engngm.C:1808
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
the oofem namespace is to define a context or scope in which all oofem names are defined.
Class representing solution step.
Definition: timestep.h:80
REGISTER_ExportModule(ErrorCheckingExportModule)

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:30 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011