OOFEM 3.0
Loading...
Searching...
No Matches
quasicontinuumvtkxmlexportmodule.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
36#include "vtkxmlexportmodule.h"
37#include "element.h"
38#include "gausspoint.h"
39#include "timestep.h"
40#include "engngm.h"
41#include "node.h"
42#include "dof.h"
43#include "materialinterface.h"
44#include "mathfem.h"
45#include "cltypes.h"
46#include "material.h"
47#include "classfactory.h"
48#include "crosssection.h"
50
51
52namespace oofem {
54
55
56QuasicontinuumVTKXMLExportModule :: QuasicontinuumVTKXMLExportModule(int n, EngngModel *e) : VTKXMLExportModule(n, e), internalVarsToExport(), primaryVarsToExport()
57{}
58
59
60QuasicontinuumVTKXMLExportModule :: ~QuasicontinuumVTKXMLExportModule()
61{}
62
63
64void
65QuasicontinuumVTKXMLExportModule :: initializeFrom(InputRecord &ir)
66{
67 VTKXMLExportModule :: initializeFrom(ir);
68
71}
72
73
74
75void
76QuasicontinuumVTKXMLExportModule :: setupVTKPiece(ExportRegion &vtkPiece, TimeStep *tStep, Set & region)
77{
78 // Stores all neccessary data (of a region) in a VTKPiece so it can be exported later.
79
80 Domain *d = emodel->giveDomain(1);
81 Element *elem;
82
83 // Assemble local->global and global->local region map and get number of
84 // single cells to process, the composite cells exported individually.
85 this->initRegionNodeNumbering(vtkPiece, d, tStep, region);
86 const IntArray& mapG2L = vtkPiece.getMapG2L();
87 const IntArray& mapL2G = vtkPiece.getMapL2G();
88 const int numNodes = vtkPiece.giveNumberOfNodes();
89 const int numRegionEl = vtkPiece.giveNumberOfCells();
90
91 if ( numNodes > 0 && numRegionEl > 0 ) {
92 // Export nodes as vtk vertices
93 vtkPiece.setNumberOfNodes(numNodes);
94 for ( int inode = 1; inode <= numNodes; inode++ ) {
95 const auto &coords = d->giveNode( mapL2G.at(inode) )->giveCoordinates();
96 vtkPiece.setNodeCoords(inode, coords);
97 }
98
99
100 //-------------------------------------------
101 // Export all the cell data for the piece
102 //-------------------------------------------
103 IntArray cellNodes;
104 vtkPiece.setNumberOfCells(numRegionEl);
105
106 int offset = 0;
107 int cellNum = 0;
108 IntArray elems = region.giveElementList();
109 for ( int ei = 1; ei <= elems.giveSize(); ei++ ) {
110 int elNum = elems.at(ei);
111 elem = d->giveElement(elNum);
112
113
115 // Skip elements that are deactivated by QC
116 if ( !emodel->isElementActivated(elem) ) {
117 continue;
118 }
119 }
120
121 // Skip elements that:
122 // are inactivated or of composite type ( these are exported individually later)
123 if ( this->isElementComposite(elem) || !elem->isActivated(tStep) ) {
124 continue;
125 }
126
127 //skip materials with casting time > current time
128 if ( !elem->isCast(tStep) ) {
129 continue;
130 }
131
132 if ( elem->giveParallelMode() != Element_local ) {
133 continue;
134 }
135
136 cellNum++;
137
138 // Set the connectivity
139 this->giveElementCell(cellNodes, elem); // node numbering of the cell with according to the VTK format
140
141 // Map from global to local node numbers for the current piece
142 int numElNodes = cellNodes.giveSize();
143 IntArray connectivity(numElNodes);
144 for ( int i = 1; i <= numElNodes; i++ ) {
145 connectivity.at(i) = mapG2L.at( cellNodes.at(i) );
146 }
147
148 vtkPiece.setConnectivity(cellNum, connectivity);
149
150 vtkPiece.setCellType( cellNum, this->giveCellType(elem) ); // VTK cell type
151
152 offset += numElNodes;
153 vtkPiece.setOffset(cellNum, offset);
154 }
155
158
159 // Export primary, internal and XFEM variables as nodal quantities
161 this->exportIntVars(this->defaultVTKPiece, region, internalVarsToExport, *smoother, tStep);
163 this->exportCellVars(this->defaultVTKPiece, region, cellVarsToExport, tStep);
164 } // end of default piece for simple geometry elements
165}
166
167
168
169
170
171int
172QuasicontinuumVTKXMLExportModule :: initRegionNodeNumbering(ExportRegion& piece,
173 Domain *domain, TimeStep *tStep, Set& region)
174{
175 // regionG2LNodalNumbers is array with mapping from global numbering to local region numbering.
176 // The i-th value contains the corresponding local region number (or zero, if global numbar is not in region).
177
178 // regionL2GNodalNumbers is array with mapping from local to global numbering.
179 // The i-th value contains the corresponding global node number.
180
181
182 int nnodes = domain->giveNumberOfDofManagers();
183 int elemNodes;
184 int elementNode, node;
185 int currOffset = 1;
186 Element *element;
187
188 IntArray &regionG2LNodalNumbers = piece.getMapG2L();
189 IntArray &regionL2GNodalNumbers = piece.getMapL2G();
190
191 regionG2LNodalNumbers.resize(nnodes);
192 regionG2LNodalNumbers.zero();
193 int regionDofMans = 0;
194 int regionSingleCells = 0;
195
196 const IntArray& elements = region.giveElementList();
197 for ( int ie = 1; ie <= elements.giveSize(); ie++ ) {
198 int ielem = elements.at(ie);
199 element = domain->giveElement(ielem);
200
201
203 if ( !domain->giveEngngModel()->isElementActivated(element) ) {
204 continue; // skip elements deactovated by QC
205 }
206 }
207
208 if ( this->isElementComposite(element) ) {
209 continue; // composite cells exported individually
210 }
211
212 if ( !element->isActivated(tStep) ) { //skip inactivated elements
213 continue;
214 }
215
216 //skip materials with casting time > current time
217 if ( !element->isCast(tStep) ) {
218 continue;
219 }
220
221 if ( element->giveParallelMode() != Element_local ) {
222 continue;
223 }
224
225 regionSingleCells++;
226 elemNodes = element->giveNumberOfNodes();
227 // elemSides = element->giveNumberOfSides();
228
229 // determine local region node numbering
230 for ( elementNode = 1; elementNode <= elemNodes; elementNode++ ) {
231 node = element->giveNode(elementNode)->giveNumber();
232 if ( regionG2LNodalNumbers.at(node) == 0 ) { // assign new number
233 /* mark for assignment. This is done later, as it allows to preserve
234 * natural node numbering.
235 */
236 regionG2LNodalNumbers.at(node) = 1;
237 regionDofMans++;
238 }
239 }
240 }
241
242 piece.setNumberOfCells(regionSingleCells);
243 piece.setNumberOfNodes(regionDofMans);
244
245 regionL2GNodalNumbers.resize(regionDofMans);
246
247 for ( int i = 1; i <= nnodes; i++ ) {
248 if ( regionG2LNodalNumbers.at(i) ) {
249 regionG2LNodalNumbers.at(i) = currOffset++;
250 regionL2GNodalNumbers.at( regionG2LNodalNumbers.at(i) ) = i;
251 }
252 }
253
254 return 1;
255}
256} // end namespace oofem
#define REGISTER_ExportModule(class)
const FloatArray & giveCoordinates() const
Definition dofmanager.h:390
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
Definition domain.h:461
Element * giveElement(int n)
Definition domain.C:165
Node * giveNode(int n)
Definition domain.h:398
EngngModel * giveEngngModel()
Definition domain.C:419
Node * giveNode(int i) const
Definition element.h:629
virtual bool isActivated(TimeStep *tStep)
Definition element.C:838
virtual int giveNumberOfNodes() const
Definition element.h:703
elementParallelMode giveParallelMode() const
Definition element.h:1139
virtual bool isCast(TimeStep *tStep)
Definition element.C:853
virtual bool isElementActivated(int elemNum)
Definition engngm.h:1214
EngngModel * emodel
Problem pointer.
Stores all neccessary data (of a region) in a VTKPiece so it can be exported later.
IntArray & getMapL2G()
void setCellType(int cellNum, int type)
void setConnectivity(int cellNum, IntArray &nodes)
IntArray & getMapG2L()
void setOffset(int cellNum, int offset)
void setNumberOfCells(int numCells)
void setNodeCoords(int nodeNum, const FloatArray &coords)
void setNumberOfNodes(int numNodes)
int giveNumber() const
Definition femcmpnn.h:104
void resize(int n)
Definition intarray.C:73
void zero()
Sets all component to zero.
Definition intarray.C:52
int & at(std::size_t i)
Definition intarray.h:104
int giveSize() const
Definition intarray.h:211
IntArray internalVarsToExport
List of InternalStateType values, identifying the selected vars for export.
IntArray cellVarsToExport
List of cell data to export.
int initRegionNodeNumbering(ExportRegion &p, Domain *domain, TimeStep *tStep, Set &region) override
IntArray primaryVarsToExport
List of primary unknowns to export.
const IntArray & giveElementList()
Definition set.C:158
bool isElementComposite(Element *elem)
void exportCellVars(ExportRegion &piece, Set &region, IntArray &cellVarsToExport, TimeStep *tStep)
Exports cell variables (typically internal variables).
void giveElementCell(IntArray &answer, Element *elem)
int giveCellType(Element *element)
virtual void exportIntVars(ExportRegion &piece, Set &region, IntArray &internalVarsToExport, NodalRecoveryModel &smoother, TimeStep *tStep)
void exportExternalForces(ExportRegion &piece, int region, TimeStep *tStep)
virtual void exportPrimaryVars(ExportRegion &piece, Set &region, IntArray &primaryVarsToExport, NodalRecoveryModel &smoother, TimeStep *tStep)
std::unique_ptr< NodalRecoveryModel > smoother
Smoother.
IntArray externalForcesToExport
List of primary unknowns to export.
NodalRecoveryModel * givePrimVarSmoother()
Returns the smoother for primary variables (nodal averaging).
NodalRecoveryModel * giveSmoother()
Returns the internal smoother.
std::unique_ptr< NodalRecoveryModel > primVarSmoother
Smoother for primary variables.
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75
@ Element_local
Element is local, there are no contributions from other domains to this element.
Definition element.h:88
#define _IFT_QuasicontinuumVTKXMLExportModule_ExportDeactivatedElements

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