OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
homexportmodule.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 "homexportmodule.h"
36 #include "timestep.h"
37 #include "element.h"
38 #include "gausspoint.h"
39 #include "engngm.h"
40 #include "material.h"
41 #include "classfactory.h"
42 
43 namespace oofem {
45 
47 
49 
52 {
53  IRResultType result; // Required by IR_GIVE_FIELD macro
55  this->scale = 1.;
57  //this->matnum.clear();
58  //IR_GIVE_OPTIONAL_FIELD(ir, this->matnum, _IFT_HOMExportModule_matnum);
60 }
61 
62 void
63 HOMExportModule :: doOutput(TimeStep *tStep, bool forcedOutput)
64 {
65  if ( !( testTimeStepOutput(tStep) || forcedOutput ) ) {
66  return;
67  }
68 
69  bool volExported = false;
70  fprintf(this->stream, "%.3e ", tStep->giveIntrinsicTime()*this->timeScale);
71  IntArray elements;
72  //assemble list of eligible elements. Elements can be present more times in a list but averaging goes just once over each element.
73  elements.resize(0);
74  for ( int ireg = 1; ireg <= this->giveNumberOfRegions(); ireg++ ) {
75  elements.followedBy(this->giveRegionSet(ireg)->giveElementList());
76  }
77  //elements.printYourself();
78 
79  for ( int ist: ists ) {
80  FloatArray ipState, avgState;
81  double VolTot = 0.;
82  Domain *d = emodel->giveDomain(1);
83  for ( auto &elem : d->giveElements() ) {
84  //printf("%d ", elem -> giveNumber());
85  if ( elements.contains(elem -> giveNumber()) ){
86  for ( GaussPoint *gp: *elem->giveDefaultIntegrationRulePtr() ) {
87  double dV = elem->computeVolumeAround(gp);
88  VolTot += dV;
89  elem->giveGlobalIPValue(ipState, gp, (InternalStateType)ist, tStep);
90  avgState.add(dV, ipState);
91  }
92  }
93  }
94 
95  if ( !volExported ) {
96  fprintf(this->stream, "%.3e ", VolTot);
97  volExported = true;
98  }
99  avgState.times( 1. / VolTot * this->scale );
100  fprintf(this->stream, "%d ", avgState.giveSize());
101  for ( auto s: avgState ) {
102  fprintf(this->stream, "%e ", s);
103  }
104  fprintf(this->stream, " ");
105  }
106  fprintf(this->stream, "\n" );
107  fflush(this->stream);
108 }
109 
110 void
112 {
113  std :: string fileName = emodel->giveOutputBaseFileName() + ".hom";
114  if ( ( this->stream = fopen(fileName.c_str(), "w") ) == NULL ) {
115  OOFEM_ERROR( "failed to open file %s", fileName.c_str() );
116  }
117 
118  fprintf(this->stream, "#Time Volume ");
119  for ( int var: this->ists ) {
120  fprintf(this->stream, "%s ", __InternalStateTypeToString( ( InternalStateType ) var) );
121  }
122  fprintf(this->stream, "\n" );
123  fflush(this->stream);
124 
125 
127 
129 }
130 
131 void
133 {
134  fclose(this->stream);
135 }
136 } // end namespace oofem
InternalStateType
Type representing the physical meaning of element or constitutive model internal variable.
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
Class and object Domain.
Definition: domain.h:115
virtual void initialize()
IntArray ists
Material numbers over which averaging is performed. - replaced by &#39;regionsets&#39;.
virtual void terminate()
Terminates the receiver.
Represents HOM (Homogenization) export module.
#define _IFT_HOMExportModule_scale
virtual void initialize()
Definition: exportmodule.C:86
Represents export output module - a base class for all output modules.
Definition: exportmodule.h:71
Class implementing an array of integers.
Definition: intarray.h:61
FILE * stream
Stream for file.
virtual void doOutput(TimeStep *tStep, bool forcedOutput=false)
Writes the output.
virtual ~HOMExportModule()
Destructor.
#define OOFEM_ERROR(...)
Definition: error.h:61
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 * giveRegionSet(int i)
Returns element set.
Definition: exportmodule.C:109
void resize(int n)
Checks size of receiver towards requested bounds.
Definition: intarray.C:124
double giveIntrinsicTime()
Returns intrinsic time, e.g. time in which constitutive model is evaluated.
Definition: timestep.h:148
Class representing vector of real numbers.
Definition: floatarray.h:82
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
#define _IFT_HOMExportModule_ISTs
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
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
std::vector< std::unique_ptr< Element > > & giveElements()
Definition: domain.h:279
const char * __InternalStateTypeToString(InternalStateType _value)
Definition: cltypes.C:298
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
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
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
int giveNumberOfRegions()
Returns number of regions (aka regionSets)
Definition: exportmodule.C:100
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
Class representing integration point in finite element program.
Definition: gausspoint.h:93
Class representing solution step.
Definition: timestep.h:80
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
REGISTER_ExportModule(ErrorCheckingExportModule)
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156
double scale
Scale of all homogenized values.

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