69VTKExportModule :: VTKExportModule(
int n,
EngngModel *e) :
ExportModule(n, e), internalVarsToExport(), primaryVarsToExport() { }
72VTKExportModule :: ~VTKExportModule() { }
78 ExportModule :: initializeFrom(ir);
86 val = NodalRecoveryModel :: NRM_ZienkiewiczZhu;
88 stype = ( NodalRecoveryModel :: NodalRecoveryModelType ) val;
93VTKExportModule :: doOutput(
TimeStep *tStep,
bool forcedOutput)
101 fprintf(stream,
"# vtk DataFile Version 2.0\n");
102 fprintf( stream,
"Output for time %f\n", tStep->
giveTargetTime() );
103 fprintf(stream,
"ASCII\n");
105 fprintf(stream,
"DATASET UNSTRUCTURED_GRID\n");
114 fprintf(stream,
"POINTS %d double\n", nnodes);
123 for ( inode = 1; inode <= regionDofMans; inode++ ) {
125 for (
double s : coords ) {
126 fprintf( stream,
"%e ", s );
129 for (
int i = coords.giveSize() + 1; i <= 3; i++ ) {
130 fprintf(stream,
"%e ", 0.0);
133 fprintf(stream,
"\n");
136 int elemToProcess = 0;
137 int ncells, celllistsize = 0;
153 fprintf(stream,
"\nCELLS %d %d\n", elemToProcess, celllistsize);
155 IntArray regionNodalNumbers(nnodes);
168 fprintf(stream,
"%d ", nelemNodes);
169 for (
int i = 1; i <= nelemNodes; i++ ) {
170 fprintf(stream,
"%d ", regionNodalNumbers.
at( cellNodes.
at(i) ) - 1);
173 fprintf(stream,
"\n");
177 fprintf(stream,
"\nCELL_TYPES %d\n", elemToProcess);
184 fprintf(stream,
"%d\n", vtkCellType);
203VTKExportModule :: initialize()
206 ExportModule :: initialize();
211VTKExportModule :: terminate()
216VTKExportModule :: giveOutputStream(
TimeStep *tStep)
218 std :: string fileName;
221 if ( ( answer = fopen(fileName.c_str(),
"w") ) == NULL ) {
222 OOFEM_ERROR(
"failed to open file %s", fileName.c_str());
232 if ( elemGT == EGT_point ) {
234 }
else if ( elemGT == EGT_line_1 ) {
236 }
else if ( elemGT == EGT_line_2 ) {
238 }
else if ( elemGT == EGT_triangle_1 ) {
240 }
else if ( elemGT == EGT_triangle_2 ) {
242 }
else if ( elemGT == EGT_tetra_1 ) {
244 }
else if ( elemGT == EGT_tetra_2 ) {
246 }
else if ( elemGT == EGT_quad_1 ) {
248 }
else if ( elemGT == EGT_quad_2 ) {
250 }
else if ( elemGT == EGT_hexa_1 ) {
252 }
else if ( elemGT == EGT_hexa_2 ) {
254 }
else if ( elemGT == EGT_wedge_1 ) {
256 }
else if ( elemGT == EGT_wedge_2 ) {
266VTKExportModule :: giveNumberOfNodesPerCell(
int cellType)
268 switch ( cellType ) {
314 if ( ( elemGT == EGT_point ) ||
315 ( elemGT == EGT_line_1 ) || ( elemGT == EGT_line_2 ) ||
316 ( elemGT == EGT_triangle_1 ) || ( elemGT == EGT_triangle_2 ) ||
317 ( elemGT == EGT_tetra_1 ) || ( elemGT == EGT_tetra_2 ) ||
318 ( elemGT == EGT_quad_1 ) || ( elemGT == EGT_quad_2 ) ||
319 ( elemGT == EGT_hexa_1 ) || ( elemGT == EGT_wedge_1 ) ) {
321 answer.
resize(nelemNodes);
322 for ( i = 1; i <= nelemNodes; i++ ) {
325 }
else if ( elemGT == EGT_hexa_2 ) {
326 int HexaQuadNodeMapping [] = {
327 5, 8, 7, 6, 1, 4, 3, 2, 16, 15, 14, 13, 12, 11, 10, 9, 17, 20, 19, 18
330 answer.
resize(nelemNodes);
331 for ( i = 1; i <= nelemNodes; i++ ) {
334 }
else if ( elemGT == EGT_wedge_2 ) {
335 int WedgeQuadNodeMapping [] = {
336 4, 6, 5, 1, 3, 2, 12, 11, 10, 9, 8, 7, 13, 15, 14
339 answer.
resize(nelemNodes);
340 for ( i = 1; i <= nelemNodes; i++ ) {
350VTKExportModule :: giveNumberOfElementCells(
Element *elem)
354 if ( ( elemGT == EGT_point ) ||
355 ( elemGT == EGT_line_1 ) || ( elemGT == EGT_line_2 ) ||
356 ( elemGT == EGT_triangle_1 ) || ( elemGT == EGT_triangle_2 ) ||
357 ( elemGT == EGT_tetra_1 ) || ( elemGT == EGT_tetra_2 ) ||
358 ( elemGT == EGT_quad_1 ) || ( elemGT == EGT_quad_2 ) ||
359 ( elemGT == EGT_hexa_1 ) || ( elemGT == EGT_hexa_2 ) ||
360 ( elemGT == EGT_wedge_1 ) || ( elemGT == EGT_wedge_2 ) ) {
371VTKExportModule :: exportIntVars(FILE *stream,
TimeStep *tStep)
384 for ( i = 1; i <= n; i++ ) {
392VTKExportModule :: exportCellVars(FILE *stream,
int elemToProcess,
TimeStep *tStep)
401 fprintf(stream,
"\nCELL_DATA %d\n", elemToProcess);
405 case IST_MaterialNumber:
406 case IST_ElementNumber:
413 if ( type == IST_MaterialNumber || type == IST_CrossSectionNumber ) {
414 OOFEM_WARNING(
"Material numbers are deprecated, outputing cross section number instead...");
415 fprintf( stream,
"%d\n", elem->giveCrossSection()->giveNumber() );
416 }
else if ( type == IST_ElementNumber ) {
417 fprintf( stream,
"%d\n", elem->giveNumber() );
425 case IST_MaterialOrientation_x:
426 case IST_MaterialOrientation_y:
427 case IST_MaterialOrientation_z:
428 if ( type == IST_MaterialOrientation_x ) {
430 }
else if ( type == IST_MaterialOrientation_y ) {
438 if ( !elem->giveLocalCoordinateSystem(mtrx) ) {
443 fprintf( stream,
"%f %f %f\n", mtrx.
at(1, pos), mtrx.
at(2, pos), mtrx.
at(3, pos) );
466 for (
GaussPoint *gp: *elem->giveDefaultIntegrationRulePtr() ) {
467 elem->giveIPValue(temp, gp, type, tStep);
468 gptot += gp->giveWeight();
469 vec.
add(gp->giveWeight(), temp);
471 vec.
times(1 / gptot);
472 for (
int j = 1; j <= vec.
giveSize(); ++j ) {
473 fprintf( stream,
"%e ", vec.
at(j) );
475 fprintf(stream,
"\n");
480 for (
int indx = 1; indx < 9; ++indx ) {
483 for ( ielem = 1; ielem <= nelem; ielem++ ) {
485 elem->
giveIPValue(vec, elem->giveDefaultIntegrationRulePtr()->getIntegrationPoint(1), type, tStep);
486 fprintf( stream,
"%e ", vec.
at(indx) );
495 fprintf(stream,
"\n\n");
501VTKExportModule :: giveTotalRBRNumberOfNodes(
Domain *d)
511 std :: vector< char > map(nnodes);
515 for (
int j = 0; j < nnodes; j++ ) {
524 elemnodes = elem->giveNumberOfNodes();
525 for (
int ielemnode = 1; ielemnode <= elemnodes; ielemnode++ ) {
526 map [ elem->giveNode(ielemnode)->giveNumber() - 1 ] = 1;
530 for (
int j = 0; j < nnodes; j++ ) {
531 rbrnodes += map [ j ];
539VTKExportModule :: initRegionNodeNumbering(
IntArray ®ionNodalNumbers,
int ®ionDofMans,
540 int offset,
Domain *domain,
int reg,
int mode)
551 int currOffset = offset + 1;
553 regionNodalNumbers.
resize(nnodes);
554 regionNodalNumbers.
zero();
563 elemNodes = element->giveNumberOfNodes();
567 for (
int elementNode = 1; elementNode <= elemNodes; elementNode++ ) {
568 int node = element->giveNode(elementNode)->giveNumber();
569 if ( regionNodalNumbers.
at(node) == 0 ) {
573 regionNodalNumbers.
at(node) = 1;
581 for (
int i = 1; i <= nnodes; i++ ) {
582 if ( regionNodalNumbers.
at(i) ) {
583 regionNodalNumbers.
at(i) = currOffset++;
584 answer.
at( regionNodalNumbers.
at(i) ) = i;
588 regionNodalNumbers = answer;
590 for (
int i = 1; i <= nnodes; i++ ) {
591 if ( regionNodalNumbers.
at(i) ) {
592 regionNodalNumbers.
at(i) = currOffset++;
621 for (
int indx = 1; indx <= nindx; indx++ ) {
636 fprintf(stream,
"LOOKUP_TABLE default\n");
639 if ( !( ( valID == IST_DisplacementVector ) || ( valID == IST_MaterialInterfaceVal ) ) ) {
640 this->
smoother->recoverValues(elemSet, valID, tStep);
643 IntArray regionNodalNumbers(nnodes);
644 int regionDofMans = 0, offset = 0;
649 if ( !( ( valID == IST_DisplacementVector ) || ( valID == IST_MaterialInterfaceVal ) ) ) {
653 regionDofMans = nnodes;
656 for ( inode = 1; inode <= regionDofMans; inode++ ) {
657 if ( valID == IST_DisplacementVector ) {
660 for ( j = 1; j <= 3; j++ ) {
664 }
else if ( valID == IST_MaterialInterfaceVal ) {
672 this->
smoother->giveNodalVector( val, regionNodalNumbers.
at(inode) );
686 fprintf( stream,
"%e ", val->
at(1) );
688 fprintf(stream,
"%e ", 0.0);
692 for ( j = 1; j <= jsize; j++ ) {
693 fprintf( stream,
"%e ", val->
at(j) );
696 for ( j = jsize + 1; j <= 3; j++ ) {
697 fprintf(stream,
"0.0 ");
701 for (
int ii = 1; ii <= 6; ii++ ) {
703 t.
at(1, 1) = val->
at(ii);
704 }
else if ( ii == 2 ) {
705 t.
at(2, 2) = val->
at(ii);
706 }
else if ( ii == 3 ) {
707 t.
at(3, 3) = val->
at(ii);
708 }
else if ( ii == 4 ) {
709 t.
at(2, 3) = val->
at(ii);
710 t.
at(3, 2) = val->
at(ii);
711 }
else if ( ii == 5 ) {
712 t.
at(1, 3) = val->
at(ii);
713 t.
at(3, 1) = val->
at(ii);
714 }
else if ( ii == 6 ) {
715 t.
at(1, 2) = val->
at(ii);
716 t.
at(2, 1) = val->
at(ii);
720 for (
int ii = 1; ii <= 3; ii++ ) {
721 for (
int jj = 1; jj <= 3; jj++ ) {
722 fprintf( stream,
"%e ", t.
at(ii, jj) );
725 fprintf(stream,
"\n");
728 fprintf( stream,
"%e ", val->
at(indx) );
731 fprintf(stream,
"\n");
737VTKExportModule :: giveSmoother()
751VTKExportModule :: exportPrimaryVars(FILE *stream,
TimeStep *tStep)
772 if ( ( valID == DisplacementVector ) || ( valID == EigenVector ) || ( valID == VelocityVector ) ) {
774 }
else if ( ( valID == FluxVector ) || ( valID == PressureVector ) || ( valID == Temperature ) || ( valID == Humidity )) {
787 fprintf(stderr,
"exportPrimVarAs: unsupported variable type\n");
791 fprintf(stream,
"LOOKUP_TABLE default\n");
796 IntArray regionNodalNumbers(nnodes);
797 int regionDofMans = 0, offset = 0;
807 for (
int inode = 1; inode <= regionDofMans; inode++ ) {
810 if ( ( valID == DisplacementVector ) || ( valID == EigenVector ) || ( valID == VelocityVector ) ) {
814 for (
Dof *dof: *dman ) {
815 id = dof->giveDofID();
816 if ( (
id == V_u ) || (
id == D_u ) ) {
817 iVal.
at(1) = dof->giveUnknown(VM_Total, tStep);
818 }
else if ( (
id == V_v ) || (
id == D_v ) ) {
819 iVal.
at(2) = dof->giveUnknown(VM_Total, tStep);
820 }
else if ( (
id == V_w ) || (
id == D_w ) ) {
821 iVal.
at(3) = dof->giveUnknown(VM_Total, tStep);
824 }
else if ( (valID == FluxVector) || (valID == Humidity) ) {
827 for (
Dof *dof: *dman ) {
828 id = dof->giveDofID();
830 iVal.
at(1) = dof->giveUnknown(VM_Total, tStep);
833 }
else if ( valID == Temperature ) {
836 for (
Dof *dof: *dman ) {
837 id = dof->giveDofID();
839 iVal.
at(1) = dof->giveUnknown(VM_Total, tStep);
842 }
else if ( valID == PressureVector ) {
851 for ( j = 1; j <= nScalarComp; j++ ) {
852 fprintf( stream,
"%e ", iVal.
at(j) );
855 fprintf(stream,
"%e ", 0.0);
866 for ( j = 1; j <= jsize; j++ ) {
867 fprintf( stream,
"%e ", iVal.
at(j) );
870 for ( j = jsize + 1; j <= 3; j++ ) {
871 fprintf(stream,
"0.0 ");
875 fprintf(stream,
"\n");
878 fprintf(stream,
"\n");
893 for (
int j = 1; j <= size; j++ ) {
897 }
else if ( iType != IST_Undefined ) {
906 this->
giveSmoother()->recoverValues(elemSet, iType, tStep);
910 if ( size == recoveredVal->
giveSize() ) {
911 answer.
at(j) = recoveredVal->
at(j);
913 OOFEM_WARNING(
"recovered variable size mismatch for %d", iType);
#define REGISTER_ExportModule(class)
bool hasDofID(DofIDItem id) const
double giveCoordinate(int i) const
const FloatArray & giveCoordinates() const
Dof * giveDofWithID(int dofID) const
virtual double giveUnknown(ValueModeType mode, TimeStep *tStep)=0
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
Element * giveElement(int n)
std ::vector< std ::unique_ptr< Element > > & giveElements()
Node * giveNode(int i) const
virtual int giveNumberOfNodes() const
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
virtual Element_Geometry_Type giveGeometryType() const =0
std::string giveOutputBaseFileName(TimeStep *tStep)
EngngModel * emodel
Problem pointer.
bool testTimeStepOutput(TimeStep *tStep)
Domain * giveDomain() const
Index giveSize() const
Returns the size of receiver.
void zero()
Zeroes all coefficients of receiver.
void beTProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
void add(const FloatArray &src)
void resize(Index rows, Index cols)
void zero()
Zeroes all coefficient of receiver.
double at(std::size_t i, std::size_t j) const
void zero()
Sets all component to zero.
virtual double giveNodalScalarRepresentation(int)=0
FloatMatrix * giveLocalCoordinateTriplet()
bool hasLocalCS()
Returns nonzero if node has prescribed local coordinate system.
virtual double giveUpdatedCoordinate(int ic, TimeStep *tStep, double scale=1.)
double giveTargetTime()
Returns target time.
NodalRecoveryModel::NodalRecoveryModelType stype
Smoother type.
int giveTotalRBRNumberOfNodes(Domain *d)
FILE * giveOutputStream(TimeStep *tStep)
Returns the output stream for given solution step.
NodalRecoveryModel * giveSmoother()
Returns the internal smoother.
int giveCellType(Element *tStep)
std::unique_ptr< NodalRecoveryModel > smoother
Smoother.
void exportPrimVarAs(UnknownType valID, FILE *stream, TimeStep *tStep)
void exportIntVarAs(InternalStateType valID, InternalStateValueType type, FILE *stream, TimeStep *tStep)
void giveElementCell(IntArray &answer, Element *elem, int cell)
void getDofManPrimaryVariable(FloatArray &answer, DofManager *dman, IntArray &dofIDMask, ValueModeType mode, TimeStep *tStep, InternalStateType iType)
IntArray primaryVarsToExport
List of primary unknowns to export.
IntArray internalVarsToExport
List of InternalStateType values, identifying the selected vars for export.
IntArray cellVarsToExport
List of cell data to export.
void exportCellVars(FILE *stream, int elemToProcess, TimeStep *tStep)
void exportIntVars(FILE *stream, TimeStep *tStep)
void exportPrimaryVars(FILE *stream, TimeStep *tStep)
int giveNumberOfNodesPerCell(int cellType)
int initRegionNodeNumbering(IntArray ®ionNodalNumbers, int ®ionDofMans, int offset, Domain *domain, int reg, int mode)
int giveNumberOfElementCells(Element *)
#define OOFEM_WARNING(...)
#define OOFEM_LOG_DEBUG(...)
const char * __InternalStateTypeToString(InternalStateType _value)
FloatArrayF< N > min(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
@ Element_local
Element is local, there are no contributions from other domains to this element.
int giveInternalStateTypeSize(InternalStateValueType valType)
InternalStateValueType
Determines the type of internal variable.
@ ISVT_TENSOR_S3E
symmetric 3x3 tensor, packed with off diagonal components multiplied by 2 (engineering strain vector,...
@ ISVT_UNDEFINED
Undefined.
@ ISVT_TENSOR_S3
Symmetric 3x3 tensor.
@ ISVT_TENSOR_G
General tensor.
const char * __UnknownTypeToString(UnknownType _value)
ClassFactory & classFactory
InternalStateValueType giveInternalStateValueType(InternalStateType type)
#define _IFT_VTKExportModule_stype
#define _IFT_VTKExportModule_cellvars
#define _IFT_VTKExportModule_vars
#define _IFT_VTKExportModule_primvars