OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
dmexportmodule.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 "dmexportmodule.h"
36 #include "timestep.h"
37 #include "engngm.h"
38 #include "dofmanager.h"
39 #include "dof.h"
40 #include "classfactory.h"
41 #include "domain.h"
42 
43 #include "../sm/EngineeringModels/structengngmodel.h" // JB
44 
45 namespace oofem {
47 
49 {
50  this->dofManList.clear();
51 }
52 
53 
55 { }
56 
57 
60 {
61  IRResultType result; // Required by IR_GIVE_FIELD macro
62 
63  // Read in dofMan's to export - defaults to all
65 
67 }
68 
69 
70 void
71 DofManExportModule :: doOutput(TimeStep *tStep, bool forcedOutput)
72 {
73  if ( !( testTimeStepOutput(tStep) || forcedOutput ) ) {
74  return;
75  }
76 
77  FILE *stream = this->giveOutputStream(tStep);
78  fprintf(stream, "%% DofMan DataFile Version 1.1\n"); // Version 1.1 ??
79  fprintf( stream, "%% Output for time %f\n", tStep->giveTargetTime() );
80 
81  DofManager *dm;
82  double x, y, z, displacement;
83  int domainIndex = 1;
84  Domain *d = emodel->giveDomain(domainIndex);
85  FloatArray reactions;
86 
87 
88  IntArray dofManMap, dofidMap, eqnMap;
89  StructuralEngngModel *strEngMod = dynamic_cast< StructuralEngngModel * >(emodel);
90  if ( strEngMod ) {
91  strEngMod->buildReactionTable(dofManMap, dofidMap, eqnMap, tStep, domainIndex);
92  strEngMod->computeReaction(reactions, tStep, 1);
93  }
94 
95 
96 
97  int nTotaldm = d->giveNumberOfDofManagers();
98  int ndmInList = this->dofManList.giveSize();
99 
100  int ndm = ( ndmInList > 0 ) ? ndmInList : nTotaldm;
101 
102  fprintf(stream, "%% Primary fields \n");
103  for ( int idm = 1; idm <= ndm; idm++ ) {
104  if ( ndm < nTotaldm ) {
105  dm = d->giveDofManager( this->dofManList.at(idm) );
106  } else {
107  dm = d->giveDofManager(idm);
108  }
109  x = dm->giveCoordinate(1);
110  y = dm->giveCoordinate(2);
111  z = dm->giveCoordinate(3);
112  fprintf(stream, "%d %g %g %g ", dm->giveNumber(), x, y, z);
113  for ( Dof *dof: *dm ) {
114  displacement = dof->giveUnknown(VM_Total, tStep);
115  fprintf(stream, " %g", displacement);
116  }
117  fprintf(stream, "\n");
118  }
119 
120 #if 0
121  fprintf(stream, "%% Reaction forces \n");
122  for ( int idm = 1; idm <= ndm; idm++ ) {
123  int dManNum = this->dofManList.at(idm);
124  dm = d->giveDofManager(dManNum);
125  fprintf(stream, "%d", dManNum);
126 
127  for ( int i = 1; i <= numRestrDofs; i++ ) {
128  if ( dofManMap.at(i) == dManNum ) { // dofman has reaction
129  //double reaction = reactions.at( eqnMap.at(i) );
130  double reaction = reactions.at(i);
131  fprintf(stream, " %g", reaction);
132  }
133  }
134  fprintf(stream, "\n");
135  }
136 
137  for ( int i = 1; i <= numRestrDofs; i++ ) {
138  double reaction = reactions.at(i);
139  fprintf(stream, " %g", reaction);
140  }
141 #endif
142  fclose(stream);
143 }
144 
145 FILE *
147 {
148  FILE *answer;
149 
150  std :: string fileName = this->giveOutputBaseFileName(tStep) + ".dm";
151  if ( ( answer = fopen(fileName.c_str(), "w") ) == NULL ) {
152  OOFEM_ERROR("failed to open file %s", fileName.c_str() );
153  }
154 
155  return answer;
156 }
157 } // end namespace
bool testTimeStepOutput(TimeStep *tStep)
Tests if given time step output is required.
Definition: exportmodule.C:148
Class and object Domain.
Definition: domain.h:115
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
Definition: domain.h:432
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
Represents DofManager export module.
double giveTargetTime()
Returns target time.
Definition: timestep.h:146
Base class for dof managers.
Definition: dofmanager.h:113
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
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
#define _IFT_DofManExportModule_dmlist
void buildReactionTable(IntArray &restrDofMans, IntArray &restrDofs, IntArray &eqn, TimeStep *tStep, int di)
Builds the reaction force table.
#define OOFEM_ERROR(...)
Definition: error.h:61
EngngModel * emodel
Problem pointer.
Definition: exportmodule.h:77
FILE * giveOutputStream(TimeStep *tStep)
Class representing vector of real numbers.
Definition: floatarray.h:82
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
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
virtual ~DofManExportModule()
Destructor.
Class representing the general Input Record.
Definition: inputrecord.h:101
This class implements extension of EngngModel for structural models.
void computeReaction(FloatArray &answer, TimeStep *tStep, int di)
Computes reaction forces.
virtual void doOutput(TimeStep *tStep, bool forcedOutput=false)
Writes the output.
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
Definition: intarray.h:203
virtual double giveCoordinate(int i)
Definition: dofmanager.h:380
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
Abstract class Dof represents Degree Of Freedom in finite element mesh.
Definition: dof.h:93
DofManager * giveDofManager(int n)
Service for accessing particular domain dof manager.
Definition: domain.C:314
std::string giveOutputBaseFileName(TimeStep *tStep)
Gives the appropriate name (minus specific file extension).
Definition: exportmodule.C:125
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:28 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011