OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
vtkxmlexportmodule.h
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 #ifndef vtkxmlexportmodule_h
36 #define vtkxmlexportmodule_h
37 
38 #include "exportmodule.h"
39 #include "intarray.h"
40 #include "nodalrecoverymodel.h"
41 #include "interface.h"
42 #include "internalstatevaluetype.h"
43 #include "integrationrule.h"
44 #include "xfem/xfemmanager.h"
45 
46 
47 #ifdef __VTK_MODULE
48  #include <vtkUnstructuredGrid.h>
49  #include <vtkSmartPointer.h>
50 #endif
51 
52 #include <string>
53 #include <list>
54 
56 
57 #define _IFT_VTKXMLExportModule_Name "vtkxml"
58 #define _IFT_VTKXMLExportModule_cellvars "cellvars"
59 #define _IFT_VTKXMLExportModule_vars "vars"
60 #define _IFT_VTKXMLExportModule_primvars "primvars"
61 #define _IFT_VTKXMLExportModule_externalForces "externalforces"
62 #define _IFT_VTKXMLExportModule_ipvars "ipvars"
63 #define _IFT_VTKXMLExportModule_stype "stype"
64 #define _IFT_VTKXMLExportModule_particleexportflag "particleexportflag"
65 
66 
67 namespace oofem {
68 class Node;
69 
71 class VTKPiece
72 {
73 public:
75  {
76  numCells = 0;
77  numNodes = 0;
78  }
79 
80  void clear();
81 
82  void setNumberOfNodes(int numNodes);
83  int giveNumberOfNodes() { return this->numNodes; }
84 
85  void setNumberOfCells(int numCells);
86  int giveNumberOfCells() { return this->numCells; }
87 
88  void setConnectivity(int cellNum, IntArray &nodes);
89  IntArray &giveCellConnectivity(int cellNum) { return this->connectivity [ cellNum - 1 ]; }
90 
91  void setCellType(int cellNum, int type) { this->elCellTypes.at(cellNum) = type; }
92  int giveCellType(int cellNum) { return this->elCellTypes.at(cellNum); }
93 
94  void setOffset(int cellNum, int offset) { this->elOffsets.at(cellNum) = offset; }
95  int giveCellOffset(int cellNum) { return this->elOffsets.at(cellNum); }
96 
97  void setNodeCoords(int nodeNum, FloatArray &coords);
98  FloatArray &giveNodeCoords(int nodeNum) { return this->nodeCoords [ nodeNum - 1 ]; }
99 
100  void setNumberOfPrimaryVarsToExport(int numVars, int numNodes);
101  void setNumberOfLoadsToExport(int numVars, int numNodes);
102  void setNumberOfInternalVarsToExport(int numVars, int numNodes);
103  void setNumberOfInternalXFEMVarsToExport(int numVars, int numEnrichmentItems, int numNodes);
104  void setNumberOfCellVarsToExport(int numVars, int numCells);
105 
106  void setPrimaryVarInNode(int varNum, int nodeNum, FloatArray valueArray);
107  FloatArray &givePrimaryVarInNode(int varNum, int nodeNum) { return this->nodeVars [ varNum - 1 ] [ nodeNum - 1 ]; }
108 
109  void setLoadInNode(int varNum, int nodeNum, FloatArray valueArray);
110  FloatArray &giveLoadInNode(int varNum, int nodeNum) { return this->nodeLoads [ varNum - 1 ] [ nodeNum - 1 ]; }
111 
112  void setInternalVarInNode(int varNum, int nodeNum, FloatArray valueArray);
113  FloatArray &giveInternalVarInNode(int varNum, int nodeNum) { return this->nodeVarsFromIS [ varNum - 1 ] [ nodeNum - 1 ]; }
114 
115  void setInternalXFEMVarInNode(int varNum, int eiNum, int nodeNum, FloatArray valueArray);
116  FloatArray &giveInternalXFEMVarInNode(int varNum, int eiNum, int nodeNum) { return this->nodeVarsFromXFEMIS [ varNum - 1 ] [ eiNum - 1 ] [ nodeNum - 1 ]; }
117 
118  void setCellVar(int varNum, int cellNum, FloatArray valueArray);
119  FloatArray &giveCellVar(int field, int cellNum) { return this->elVars [ field - 1 ] [ cellNum - 1 ]; }
120 
121 
122 private:
123  int numCells;
124  int numNodes;
127  std :: vector< FloatArray >nodeCoords; // all the nodes in the piece [node][coords]
128  std :: vector< IntArray >connectivity; // cell connectivity [cell][nodes]
129  std :: vector< std :: vector< FloatArray > >nodeVars; // [field][node][valArray]
130  std :: vector< std :: vector< FloatArray > >nodeLoads; // [field][node][valArray]
131  std :: vector< std :: vector< FloatArray > >nodeVarsFromIS; // [field][node][valArray]
132  std :: vector< std :: vector< std :: vector< FloatArray > > >nodeVarsFromXFEMIS; // [field][ei][node][valArray]
133  std :: vector< std :: vector< FloatArray > >elVars; // [el][field][valArray]
134 };
135 
136 
144 class OOFEM_EXPORT VTKXMLExportModule : public ExportModule
145 {
146 protected:
157 
160 
167 
170 
172  std :: list< std :: string >pvdBuffer;
173 
175  std :: list< std :: string >gpPvdBuffer;
176 
177 public:
179  VTKXMLExportModule(int n, EngngModel * e);
181  virtual ~VTKXMLExportModule();
182 
183  virtual IRResultType initializeFrom(InputRecord *ir);
184  virtual void doOutput(TimeStep *tStep, bool forcedOutput = false);
185  virtual void initialize();
186  virtual void terminate();
187  virtual const char *giveClassName() const { return "VTKXMLExportModule"; }
191  void exportPointDataHeader(FILE *fileStream, TimeStep *tStep);
192  void giveDataHeaders(std :: string &pointHeader, std :: string &cellHeader); // returns the headers
194  NodalRecoveryModel *giveSmoother();
196  NodalRecoveryModel *givePrimVarSmoother();
197 
198 
199 #ifdef __VTK_MODULE
200  vtkSmartPointer< vtkUnstructuredGrid >fileStream;
201  vtkSmartPointer< vtkPoints >nodes;
202  vtkSmartPointer< vtkIdList >elemNodeArray;
203 
204  vtkSmartPointer< vtkDoubleArray >intVarArray;
205  vtkSmartPointer< vtkDoubleArray >primVarArray;
206 #else
207  FILE *fileStream;
208 #endif
209 
211 
212  std :: vector < VTKPiece > defaultVTKPieces;
213 
218  static void computeIPAverage(FloatArray &answer, IntegrationRule *iRule, Element *elem, InternalStateType isType, TimeStep *tStep);
219 
220 protected:
221 
223  static void makeFullTensorForm(FloatArray &answer, const FloatArray &reducedForm, InternalStateValueType vtype);
224 
226  std :: string giveOutputFileName(TimeStep *tStep);
227 
229  FILE *giveOutputStream(TimeStep *tStep);
234  int giveCellType(Element *element);
238  int giveNumberOfNodesPerCell(int cellType);
242  void giveElementCell(IntArray &answer, Element *elem);
243 
244 
248  void exportIntVars(VTKPiece &piece, IntArray &mapG2L, IntArray &mapL2G, int ireg, TimeStep *tStep);
249 
250 
254  void exportPrimaryVars(VTKPiece &piece, IntArray &mapG2L, IntArray &mapL2G, int region, TimeStep *tStep);
255 
259  void exportExternalForces(VTKPiece &piece, IntArray &mapG2L, IntArray &mapL2G, int region, TimeStep *tStep);
260 
261 
262  // Tries to find the value of a primary field on the given DofManager.
263  // Some elements have different interpolation of some fields, and requires some additional code to compute node values (if available).
264 
265  void getNodalVariableFromPrimaryField(FloatArray &answer, DofManager *dman, TimeStep *tStep, UnknownType type, int ireg);
266  //
267 
268  //
269  // Exports single internal variable by smoothing.
270  //
271 
272  virtual void setupVTKPiece(VTKPiece &vtkPiece, TimeStep *tStep, int region);
273  void writeIntVars(VTKPiece &vtkPiece);
274  void writeXFEMVars(VTKPiece &vtkPiece);
275  void writePrimaryVars(VTKPiece &vtkPiece);
276  void writeCellVars(VTKPiece &vtkPiece);
277  void writeExternalForces(VTKPiece &vtkPiece);
278 
282  bool writeVTKPiece(VTKPiece &vtkPiece, TimeStep *tStep);
283 
284 
285  void exportXFEMVarAs(XFEMStateType xfemstype, IntArray &mapG2L, IntArray &mapL2G, int regionDofMans, int ireg, TimeStep *tStep, EnrichmentItem *ei);
286 
287  void getNodalVariableFromIS(FloatArray &answer, Node *node, TimeStep *tStep, InternalStateType type, int ireg);
288 
289  void getNodalVariableFromXFEMST(FloatArray &answer, Node *node, TimeStep *tStep, XFEMStateType xfemstype, int ireg, EnrichmentItem *ei);
290 
291 
292  // Exports cell variables (typically internal variables).
293  //
294 
295  void exportCellVars(VTKPiece &piece, const IntArray &elems, TimeStep *tStep);
296 
297  //
298  // Exports a single cell variable (typically an internal variable).
299  //
300  void getCellVariableFromIS(FloatArray &answer, Element *el, InternalStateType type, TimeStep *tStep);
306  void exportIntVarsInGpAs(IntArray valIDs, TimeStep *tStep);
307 
316  virtual int initRegionNodeNumbering(IntArray &mapG2L, IntArray &mapL2G,
317  int &regionDofMans,
318  int &totalcells,
319  Domain *domain, TimeStep *tStep, int reg);
323  void writeVTKCollection();
324 
326  void writeGPVTKCollection();
327 
328 #ifdef __VTK_MODULE
329  void writeVTKPointData(const char *name, vtkSmartPointer< vtkDoubleArray >varArray);
330 #else
331  void writeVTKPointData(FloatArray &valueArray);
332 #endif
333 
334 #ifdef __VTK_MODULE
335  void writeVTKCellData(const char *name, vtkSmartPointer< vtkDoubleArray >varArray);
336 #else
337  void writeVTKCellData(FloatArray &valueArray);
338 #endif
339 
340  // Export of composite elements (built up from several subcells)
341 
342  bool isElementComposite(Element *elem);
343  void exportCompositeElement(VTKPiece &vtkPiece, Element *el, TimeStep *tStep);
344  void exportCompositeElement(std::vector< VTKPiece > &vtkPieces, Element *el, TimeStep *tStep);
345 };
346 
347 
348 
349 
357 {
358 public:
360  virtual const char *giveClassName() const { return "VTKXMLExportModuleElementInterface"; }
361  virtual void giveCompositeExportData(VTKPiece &vtkPiece, IntArray &primaryVarsToExport, IntArray &internalVarsToExport, IntArray cellVarsToExport, TimeStep *tStep) { }
362  virtual void giveCompositeExportData(std::vector< VTKPiece > &vtkPieces, IntArray &primaryVarsToExport, IntArray &internalVarsToExport, IntArray cellVarsToExport, TimeStep *tStep) { }
363 };
364 } // end namespace oofem
365 #endif // vtkxmlexportmodule_h
void setInternalVarInNode(int varNum, int nodeNum, FloatArray valueArray)
void setInternalXFEMVarInNode(int varNum, int eiNum, int nodeNum, FloatArray valueArray)
InternalStateType
Type representing the physical meaning of element or constitutive model internal variable.
int giveCellType(int cellNum)
void setCellVar(int varNum, int cellNum, FloatArray valueArray)
Abstract class representing entity, which is included in the FE model using one (or more) global func...
IntArray ipInternalVarsToExport
List of internal variables to export directly in Integration Points (no smoothing to nodes) ...
Class and object Domain.
Definition: domain.h:115
std::vector< std::vector< FloatArray > > nodeVars
NodalRecoveryModel * smoother
Smoother.
void setNumberOfNodes(int numNodes)
void setNumberOfInternalVarsToExport(int numVars, int numNodes)
Elements with geometry defined as EGT_Composite are exported using individual pieces.
Abstract base class for all finite elements.
Definition: element.h:145
InternalStateValueType
Determines the type of internal variable.
Base class for dof managers.
Definition: dofmanager.h:113
std::vector< IntArray > connectivity
int giveCellOffset(int cellNum)
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
void setNumberOfCells(int numCells)
FloatArray & giveInternalVarInNode(int varNum, int nodeNum)
std::vector< FloatArray > nodeCoords
Abstract base class representing integration rule.
void setNumberOfLoadsToExport(int numVars, int numNodes)
std::vector< std::vector< FloatArray > > nodeVarsFromIS
std::list< std::string > pvdBuffer
Buffer for earlier time steps exported to *.pvd file.
void setNodeCoords(int nodeNum, FloatArray &coords)
FloatArray & giveLoadInNode(int varNum, int nodeNum)
void setLoadInNode(int varNum, int nodeNum, FloatArray valueArray)
IntArray cellVarsToExport
List of cell data to export.
std::vector< std::vector< std::vector< FloatArray > > > nodeVarsFromXFEMIS
void setCellType(int cellNum, int type)
void setNumberOfInternalXFEMVarsToExport(int numVars, int numEnrichmentItems, int numNodes)
IntArray internalVarsToExport
List of InternalStateType values, identifying the selected vars for export.
void setNumberOfPrimaryVarsToExport(int numVars, int numNodes)
void setNumberOfCellVarsToExport(int numVars, int numCells)
FloatArray & giveInternalXFEMVarInNode(int varNum, int eiNum, int nodeNum)
FloatArray & givePrimaryVarInNode(int varNum, int nodeNum)
UnknownType
Type representing particular unknown (its physical meaning).
Definition: unknowntype.h:55
virtual void giveCompositeExportData(std::vector< VTKPiece > &vtkPieces, IntArray &primaryVarsToExport, IntArray &internalVarsToExport, IntArray cellVarsToExport, TimeStep *tStep)
virtual const char * giveClassName() const
Returns class name of the receiver.
NodalRecoveryModel * primVarSmoother
Smoother for primary variables.
Represents VTK (Visualization Toolkit) export module.
bool particleExportFlag
particle export flag
IntArray externalForcesToExport
List of primary unknowns to export.
void setPrimaryVarInNode(int varNum, int nodeNum, FloatArray valueArray)
virtual void giveCompositeExportData(VTKPiece &vtkPiece, IntArray &primaryVarsToExport, IntArray &internalVarsToExport, IntArray cellVarsToExport, TimeStep *tStep)
Class representing vector of real numbers.
Definition: floatarray.h:82
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
virtual const char * giveClassName() const
IntArray primaryVarsToExport
List of primary unknowns to export.
void setOffset(int cellNum, int offset)
Class representing the general Input Record.
Definition: inputrecord.h:101
IntArray & giveCellConnectivity(int cellNum)
std::list< std::string > gpPvdBuffer
Buffer for earlier time steps with gauss points exported to *.gp.pvd file.
Class Interface.
Definition: interface.h:82
XFEMStateType
Definition: xfemmanager.h:92
NodalRecoveryModel::NodalRecoveryModelType stype
Smoother type.
std::vector< std::vector< FloatArray > > elVars
static IntArray redToFull
Map from Voigt to full tensor.
std::vector< VTKPiece > defaultVTKPieces
FloatArray & giveCellVar(int field, int cellNum)
void setConnectivity(int cellNum, IntArray &nodes)
std::vector< std::vector< FloatArray > > nodeLoads
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
the oofem namespace is to define a context or scope in which all oofem names are defined.
FloatArray & giveNodeCoords(int nodeNum)
Class implementing node in finite element mesh.
Definition: node.h:87
The base class for all recovery models, which perform nodal averaging or projection processes for int...
Class representing solution step.
Definition: timestep.h:80

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