OOFEM 3.0
Loading...
Searching...
No Matches
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 - 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 "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
44
45namespace oofem {
47
48DofManExportModule :: DofManExportModule(int n, EngngModel *e) : ExportModule(n, e)
49{
50 this->dofManList.clear();
51}
52
53
54DofManExportModule :: ~DofManExportModule()
55{ }
56
57
58void
59DofManExportModule :: initializeFrom(InputRecord &ir)
60{
61 ExportModule :: initializeFrom(ir);
62
63 // Read in dofMan's to export - defaults to all
65}
66
67
68void
69DofManExportModule :: doOutput(TimeStep *tStep, bool forcedOutput)
70{
71 if ( !( testTimeStepOutput(tStep) || forcedOutput ) ) {
72 return;
73 }
74
75 FILE *stream = this->giveOutputStream(tStep);
76 fprintf(stream, "%% DofMan DataFile Version 1.1\n"); // Version 1.1 ??
77 fprintf( stream, "%% Output for time %f\n", tStep->giveTargetTime() );
78
79 DofManager *dm;
80 double x, y, z, displacement;
81 int domainIndex = 1;
82 Domain *d = emodel->giveDomain(domainIndex);
83 FloatArray reactions;
84
85
86 IntArray dofManMap, dofidMap, eqnMap;
87 StructuralEngngModel *strEngMod = dynamic_cast< StructuralEngngModel * >(emodel);
88 if ( strEngMod ) {
89 strEngMod->buildReactionTable(dofManMap, dofidMap, eqnMap, tStep, domainIndex);
90 strEngMod->computeReaction(reactions, tStep, 1);
91 }
92
93
94
95 int nTotaldm = d->giveNumberOfDofManagers();
96 int ndmInList = this->dofManList.giveSize();
97
98 int ndm = ( ndmInList > 0 ) ? ndmInList : nTotaldm;
99
100 fprintf(stream, "%% Primary fields \n");
101 for ( int idm = 1; idm <= ndm; idm++ ) {
102 if ( ndm < nTotaldm ) {
103 dm = d->giveDofManager( this->dofManList.at(idm) );
104 } else {
105 dm = d->giveDofManager(idm);
106 }
107 x = dm->giveCoordinate(1);
108 y = dm->giveCoordinate(2);
109 z = dm->giveCoordinate(3);
110 fprintf(stream, "%d %g %g %g ", dm->giveNumber(), x, y, z);
111 for ( Dof *dof: *dm ) {
112 displacement = dof->giveUnknown(VM_Total, tStep);
113 fprintf(stream, " %g", displacement);
114 }
115 fprintf(stream, "\n");
116 }
117
118#if 0
119 fprintf(stream, "%% Reaction forces \n");
120 for ( int idm = 1; idm <= ndm; idm++ ) {
121 int dManNum = this->dofManList.at(idm);
122 dm = d->giveDofManager(dManNum);
123 fprintf(stream, "%d", dManNum);
124
125 for ( int i = 1; i <= numRestrDofs; i++ ) {
126 if ( dofManMap.at(i) == dManNum ) { // dofman has reaction
127 //double reaction = reactions.at( eqnMap.at(i) );
128 double reaction = reactions.at(i);
129 fprintf(stream, " %g", reaction);
130 }
131 }
132 fprintf(stream, "\n");
133 }
134
135 for ( int i = 1; i <= numRestrDofs; i++ ) {
136 double reaction = reactions.at(i);
137 fprintf(stream, " %g", reaction);
138 }
139#endif
140 fclose(stream);
141}
142
143FILE *
144DofManExportModule :: giveOutputStream(TimeStep *tStep)
145{
146 FILE *answer;
147
148 std :: string fileName = this->giveOutputBaseFileName(tStep) + ".dm";
149 if ( ( answer = fopen(fileName.c_str(), "w") ) == NULL ) {
150 OOFEM_ERROR("failed to open file %s", fileName.c_str() );
151 }
152
153 return answer;
154}
155} // end namespace
#define REGISTER_ExportModule(class)
FILE * giveOutputStream(TimeStep *tStep)
double giveCoordinate(int i) const
Definition dofmanager.h:383
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
Definition domain.h:461
DofManager * giveDofManager(int n)
Definition domain.C:317
std::string giveOutputBaseFileName(TimeStep *tStep)
EngngModel * emodel
Problem pointer.
bool testTimeStepOutput(TimeStep *tStep)
int giveNumber() const
Definition femcmpnn.h:104
double & at(Index i)
Definition floatarray.h:202
int & at(std::size_t i)
Definition intarray.h:104
void buildReactionTable(IntArray &restrDofMans, IntArray &restrDofs, IntArray &eqn, TimeStep *tStep, int di)
void computeReaction(FloatArray &answer, TimeStep *tStep, int di)
double giveTargetTime()
Returns target time.
Definition timestep.h:164
#define _IFT_DofManExportModule_dmlist
#define OOFEM_ERROR(...)
Definition error.h:79
#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