OOFEM 3.0
Loading...
Searching...
No Matches
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 - 2025 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
43namespace oofem {
44ExportModule :: 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 pythonExport = false;
51}
52
53
54ExportModule :: ~ExportModule()
55{ }
56
57
58void
84
85void ExportModule :: initialize(){
87}
88
89void ExportModule :: initializeElementSet(){
90 if ( regionSets.isEmpty() ){
91 // default: whole domain region
92 defaultElementSet.clear();
93 defaultElementSet.setDomain(emodel->giveDomain(1));
94 defaultElementSet.addAllElements();
95 }
96}
97
98
99int ExportModule :: giveNumberOfRegions()
100{
101 // Returns number of regions (aka sets)
102 if (regionSets.isEmpty())
103 return 1; // defaultElementSet
104 else
105 return this->regionSets.giveSize();
106}
107
108Set *ExportModule :: giveRegionSet(int i)
109{
110 if (regionSets.isEmpty()) {
111 return & this->defaultElementSet;
112 } else {
113 int setid = regionSets.at(i);
114 if ( setid > 0 ) {
115 return emodel->giveDomain(1)->giveSet(setid);
116 } else {
117 OOFEM_ERROR ("Bad set index");
118 }
119 }
120}
121
122std :: string
123ExportModule :: giveOutputBaseFileName(TimeStep *tStep)
124{
125 char fext [ 100 ];
126
127 if ( this->testSubStepOutput() ) {
128 // include tStep version in output file name
129 if ( this->emodel->isParallel() && this->emodel->giveNumberOfProcesses() > 1 ) {
130 sprintf( fext, "_%03d.m%d.%d.%d", emodel->giveRank(), this->number, tStep->giveNumber(), tStep->giveSubStepNumber() );
131 } else {
132 sprintf( fext, ".m%d.%d.%d", this->number, tStep->giveNumber(), tStep->giveSubStepNumber() );
133 }
134 return this->emodel->giveOutputBaseFileName() + fext;
135 } else {
136 if ( this->emodel->isParallel() && this->emodel->giveNumberOfProcesses() > 1 ) {
137 sprintf( fext, "_%03d.m%d.%d", emodel->giveRank(), this->number, tStep->giveNumber() );
138 } else {
139 sprintf( fext, ".m%d.%d", this->number, tStep->giveNumber() );
140 }
141 return this->emodel->giveOutputBaseFileName() + fext;
142 }
143}
144
145bool
146ExportModule :: testTimeStepOutput(TimeStep *tStep)
147{
148 if ( tstep_all_out_flag ) {
149 return true;
150 }
151
152 if ( tstep_step_out ) {
153 //if (((tStep->giveNumber()-emodel->giveNumberOfFirstStep()) % tstep_step_out) == 0) return 1;
154 if ( ( ( tStep->giveNumber() ) % tstep_step_out ) == 0 ) {
155 return 1;
156 }
157 }
158
159 for ( auto &step: tsteps_out ) {
160 // test if INCLUDED
161 if ( step.test( tStep->giveNumber() ) ) {
162 return true;
163 }
164 }
165
166 return 0;
167}
168
169bool
170ExportModule :: testDomainOutput(int n)
171{
172 if ( domain_all_flag ) {
173 return true;
174 }
175
176 return domainMask.findFirstIndexOf(n);
177}
178
179std :: string ExportModule :: errorInfo(const char *func) const
180{
181 return std :: string(this->giveClassName()) + "::" + func;
182}
183} // end namespace oofem
double timeScale
Scaling time in output, e.g. conversion from seconds to hours.
virtual const char * giveClassName() const =0
Returns class name of the receiver.
std ::list< Range > tsteps_out
List of user selected step numbers.
virtual void initializeElementSet()
int number
Component number.
bool pythonExport
Output is carried out as a python list instead of writing files.
bool tstep_all_out_flag
Indicates all steps selection.
int tstep_step_out
User timeStep Output step. Indicates every tstep_step_out-th step selected.
IntArray regionSets
regions represented by sets
Set defaultElementSet
Default region set.
IntArray domainMask
Domain selection mask.
EngngModel * emodel
Problem pointer.
bool domain_all_flag
Indicates all domains.
virtual bool hasField(InputFieldType id)=0
Returns true if record contains field identified by idString keyword.
int giveNumber()
Returns receiver's number.
Definition timestep.h:144
int giveSubStepNumber()
Returns receiver's substep number.
Definition timestep.h:155
#define OOFEM_ERROR(...)
Definition error.h:79
#define _IFT_ExportModule_domainall
#define _IFT_ExportModule_tstepall
#define _IFT_ExportModule_domainmask
#define _IFT_ExportModule_tstepsout
#define _IFT_ExportModule_tstepstep
#define _IFT_ExportModule_pythonexport
#define _IFT_ExportModule_subtstepsout
#define _IFT_ExportModule_regionsets
#define _IFT_ExportModule_timescale
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011