OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
exportmodule.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 "exportmodule.h"
36 #include "timestep.h"
37 #include "engngm.h"
38 #include "domain.h"
39 
40 #include <cstdarg>
41 
42 
43 namespace oofem {
44 ExportModule :: ExportModule(int n, EngngModel *e) : tsteps_out(), domainMask(), regionSets(), defaultElementSet( 0, e->giveDomain(1) )
45 {
46  this->number = n;
47  emodel = e;
48  regionSets.resize(0);
49  timeScale = 1.;
50 }
51 
52 
54 { }
55 
56 
59 {
60  IRResultType result; // Required by IR_GIVE_FIELD macro
61 
63 
64  tstep_step_out = 0;
66 
68 
71 
73 
74  if ( !domain_all_flag ) {
75  domainMask.clear();
77  }
78 
80 
82 
83  return IRRT_OK;
84 }
85 
88 }
89 
91  if ( regionSets.isEmpty() ){
92  // default: whole domain region
96  }
97 }
98 
99 
101 {
102  // Returns number of regions (aka sets)
103  if (regionSets.isEmpty())
104  return 1; // defaultElementSet
105  else
106  return this->regionSets.giveSize();
107 }
108 
110 {
111  if (regionSets.isEmpty()) {
112  return & this->defaultElementSet;
113  } else {
114  int setid = regionSets.at(i);
115  if ( setid > 0 ) {
116  return emodel->giveDomain(1)->giveSet(setid);
117  } else {
118  OOFEM_ERROR ("Bad set index");
119  return & this->defaultElementSet;
120  }
121  }
122 }
123 
124 std :: string
126 {
127  char fext [ 100 ];
128 
129  if ( this->testSubStepOutput() ) {
130  // include tStep version in output file name
131  if ( this->emodel->isParallel() && this->emodel->giveNumberOfProcesses() > 1 ) {
132  sprintf( fext, "_%03d.m%d.%d.%d", emodel->giveRank(), this->number, tStep->giveNumber(), tStep->giveSubStepNumber() );
133  } else {
134  sprintf( fext, ".m%d.%d.%d", this->number, tStep->giveNumber(), tStep->giveSubStepNumber() );
135  }
136  return this->emodel->giveOutputBaseFileName() + fext;
137  } else {
138  if ( this->emodel->isParallel() && this->emodel->giveNumberOfProcesses() > 1 ) {
139  sprintf( fext, "_%03d.m%d.%d", emodel->giveRank(), this->number, tStep->giveNumber() );
140  } else {
141  sprintf( fext, ".m%d.%d", this->number, tStep->giveNumber() );
142  }
143  return this->emodel->giveOutputBaseFileName() + fext;
144  }
145 }
146 
147 bool
149 {
150  if ( tstep_all_out_flag ) {
151  return true;
152  }
153 
154  if ( tstep_step_out ) {
155  //if (((tStep->giveNumber()-emodel->giveNumberOfFirstStep()) % tstep_step_out) == 0) return 1;
156  if ( ( ( tStep->giveNumber() ) % tstep_step_out ) == 0 ) {
157  return 1;
158  }
159  }
160 
161  for ( auto &step: tsteps_out ) {
162  // test if INCLUDED
163  if ( step.test( tStep->giveNumber() ) ) {
164  return true;
165  }
166  }
167 
168  return 0;
169 }
170 
171 bool
173 {
174  if ( domain_all_flag ) {
175  return true;
176  }
177 
178  return domainMask.findFirstIndexOf(n);
179 }
180 
181 std :: string ExportModule :: errorInfo(const char *func) const
182 {
183  return std :: string(this->giveClassName()) + "::" + func;
184 }
185 } // end namespace oofem
#define _IFT_ExportModule_domainall
Definition: exportmodule.h:52
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
#define _IFT_ExportModule_tstepall
Definition: exportmodule.h:48
IntArray regionSets
regions represented by sets
Definition: exportmodule.h:98
bool isEmpty() const
Checks if receiver is empty (i.e., zero sized).
Definition: intarray.h:208
#define _IFT_ExportModule_timescale
Definition: exportmodule.h:55
virtual const char * giveClassName() const =0
Returns class name of the receiver.
virtual bool hasField(InputFieldType id)=0
Returns true if record contains field identified by idString keyword.
virtual void initialize()
Definition: exportmodule.C:86
bool isParallel() const
Returns true if receiver in parallel mode.
Definition: engngm.h:1056
IntArray domainMask
Domain selection mask.
Definition: exportmodule.h:95
int giveNumberOfProcesses() const
Returns the number of collaborating processes.
Definition: engngm.h:1060
#define _IFT_ExportModule_tstepstep
Definition: exportmodule.h:49
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
std::string errorInfo(const char *func) const
Returns string for prepending output (used by error reporting macros).
Definition: exportmodule.C:181
int giveSubStepNumber()
Returns receiver&#39;s substep number.
Definition: timestep.h:137
int giveNumber()
Returns receiver&#39;s number.
Definition: timestep.h:129
bool domain_all_flag
Indicates all domains.
Definition: exportmodule.h:93
#define OOFEM_ERROR(...)
Definition: error.h:61
bool testSubStepOutput()
Initializes receiver.
Definition: exportmodule.h:138
void clear()
Clears the array (zero size).
Definition: intarray.h:177
bool tstep_substeps_out_flag
Flag turning output in solution step substeps/itarations.
Definition: exportmodule.h:90
EngngModel * emodel
Problem pointer.
Definition: exportmodule.h:77
virtual void initializeElementSet()
Fill regionSets with all elements if regionSets is initially empty.
Definition: exportmodule.C:90
Set defaultElementSet
Default region set.
Definition: exportmodule.h:107
Set of elements, boundaries, edges and/or nodes.
Definition: set.h:66
virtual ~ExportModule()
Destructor.
Definition: exportmodule.C:53
Set * giveRegionSet(int i)
Returns element set.
Definition: exportmodule.C:109
Set * giveSet(int n)
Service for accessing particular domain set.
Definition: domain.C:363
void resize(int n)
Checks size of receiver towards requested bounds.
Definition: intarray.C:124
int tstep_step_out
User timeStep Output step. Indicates every tstep_step_out-th step selected.
Definition: exportmodule.h:81
bool tstep_all_out_flag
Indicates all steps selection.
Definition: exportmodule.h:79
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
#define _IFT_ExportModule_domainmask
Definition: exportmodule.h:53
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
int number
Component number.
Definition: exportmodule.h:75
int giveRank() const
Returns domain rank in a group of collaborating processes (0..groupSize-1)
Definition: engngm.h:1058
void addAllElements()
Initialize the element set to contain all elements in the receiver domain.
Definition: set.C:212
bool testDomainOutput(int n)
Test if domain output is required.
Definition: exportmodule.C:172
double timeScale
Scaling time in output, e.g. conversion from seconds to hours.
Definition: exportmodule.h:101
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
void clear()
Clears the entire set.
Definition: set.C:228
int giveSize() const
Definition: intarray.h:203
the oofem namespace is to define a context or scope in which all oofem names are defined.
Domain * giveDomain(int n)
Service for accessing particular problem domain.
Definition: engngm.C:1720
std::list< Range > tsteps_out
List of user selected step numbers.
Definition: exportmodule.h:83
int giveNumberOfRegions()
Returns number of regions (aka regionSets)
Definition: exportmodule.C:100
ExportModule(int n, EngngModel *e)
Constructor. Creates empty Output Manager with number n.
Definition: exportmodule.C:44
std::string giveOutputBaseFileName(TimeStep *tStep)
Gives the appropriate name (minus specific file extension).
Definition: exportmodule.C:125
virtual void setDomain(Domain *d)
Sets associated Domain.
Definition: femcmpnn.h:105
#define _IFT_ExportModule_regionsets
Definition: exportmodule.h:54
#define _IFT_ExportModule_subtstepsout
Definition: exportmodule.h:51
Class representing solution step.
Definition: timestep.h:80
int findFirstIndexOf(int value) const
Finds index of first occurrence of given value in array.
Definition: intarray.C:331
#define _IFT_ExportModule_tstepsout
Definition: exportmodule.h:50

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:28 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011