58 #include <vtkPoints.h>
59 #include <vtkPointData.h>
60 #include <vtkDoubleArray.h>
61 #include <vtkCellArray.h>
62 #include <vtkCellData.h>
63 #include <vtkXMLUnstructuredGridWriter.h>
64 #include <vtkXMLPUnstructuredGridWriter.h>
65 #include <vtkUnstructuredGrid.h>
66 #include <vtkSmartPointer.h>
100 std::ofstream streamF;
105 streamF = std::ofstream(fileName);
108 if ( !streamF.good() ) {
109 OOFEM_ERROR(
"failed to open file %s", fileName.c_str() );
130 for (
int nodeIndx = 1; nodeIndx <= mapL2G.
giveSize(); nodeIndx++ ) {
154 if ( xfemstype == XFEMST_LevelSetPhi ) {
158 }
else if ( xfemstype == XFEMST_LevelSetGamma ) {
162 }
else if ( xfemstype == XFEMST_NodeEnrMarker ) {
172 answer.
resize(ncomponents);
177 answer.
at(1) = valSize ? val->
at(1) : 0.0;
204 ( void ) ncomponents;
213 vtkSmartPointer< vtkDoubleArray >varArray = vtkSmartPointer< vtkDoubleArray >::New();
214 varArray->SetName(name);
215 varArray->SetNumberOfComponents(ncomponents);
216 varArray->SetNumberOfTuples(numNodes);
217 for (
int inode = 1; inode <= numNodes; inode++ ) {
219 for (
int i = 1; i <= ncomponents; ++i ) {
220 varArray->SetComponent(inode - 1, i - 1, valueArray.
at(i) );
226 this->
fileStream <<
"<DataArray type=\"Float64\" Name=\"" << name <<
"\" NumberOfComponents=\"" << ncomponents <<
"\" format=\"ascii\"> ";
227 for (
int inode = 1; inode <= numNodes; inode++ ) {
239 std::string scalars, vectors, tensors;
245 for (
int enrItIndex = 1; enrItIndex <= nEnrIt; enrItIndex++ ) {
257 pointHeader =
"<PointData Scalars=\"" + scalars +
"\" "
258 +
"Vectors=\"" + vectors +
"\" "
259 +
"Tensors=\"" + tensors +
"\" >\n";
274 this->
fileStream = vtkSmartPointer< vtkUnstructuredGrid >::New();
275 this->nodes = vtkSmartPointer< vtkPoints >::New();
276 this->elemNodeArray = vtkSmartPointer< vtkIdList >::New();
283 current = localtime(& now);
288 this->
fileStream <<
"<!-- TimeStep " << tStep->
giveTargetTime() *
timeScale <<
" Computed " << current->tm_year + 1900 <<
"-" << setw(2) << current->tm_mon + 1 <<
"-" << setw(2) << current->tm_mday <<
" at " << current->tm_hour <<
":" << current->tm_min <<
":" << setw(2) << current->tm_sec <<
" -->\n";
289 this->
fileStream <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
298 int anyPieceNonEmpty = 0;
306 for (
int pieceNum = 1; pieceNum <= nPiecesToExport; pieceNum++ ) {
314 std::string pointHeader, cellHeader;
321 for (
int enrItIndex = 1; enrItIndex <= nEnrIt; enrItIndex++ ) {
340 for (
int pieceNum = 1; pieceNum <= nPiecesToExport; pieceNum++ ) {
342 for (
int i = 1; i <= elements.
giveSize(); i++ ) {
353 std::string pointHeader, cellHeader;
358 for (
int enrItIndex = 1; enrItIndex <= nEnrIt; enrItIndex++ ) {
374 if ( anyPieceNonEmpty == 0 ) {
376 this->
fileStream <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\">\n";
377 this->
fileStream <<
"<Cells>\n<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"> </DataArray>\n</Cells>\n";
391 vtkSmartPointer< vtkXMLPUnstructuredGridWriter >writer = vtkSmartPointer< vtkXMLPUnstructuredGridWriter >::New();
393 writer->SetNumberOfPieces(this->
emodel->giveNumberOfProcesses() );
394 writer->SetStartPiece(this->
emodel->giveRank() );
395 writer->SetEndPiece(this->
emodel->giveRank() );
399 vtkSmartPointer< vtkXMLUnstructuredGridWriter >writer = vtkSmartPointer< vtkXMLUnstructuredGridWriter >::New();
402 writer->SetFileName(fname.c_str() );
408 writer->SetDataModeToAscii();
411 this->
fileStream <<
"</UnstructuredGrid>\n</VTKFile>";
#define REGISTER_ExportModule(class)
const FloatArray & giveCoordinates() const
Element * giveElement(int n)
XfemManager * giveXfemManager()
elementParallelMode giveParallelMode() const
bool evalNodeEnrMarkerInNode(double &oNodeEnrMarker, int iNodeInd) const
bool evalLevelSetTangInNode(double &oLevelSet, int iNodeInd, const FloatArray &iGlobalCoord) const
bool evalLevelSetNormalInNode(double &oLevelSet, int iNodeInd, const FloatArray &iGlobalCoord) const
double timeScale
Scaling time in output, e.g. conversion from seconds to hours.
std::string giveOutputBaseFileName(TimeStep *tStep)
virtual void initializeFrom(InputRecord &ir)
Initializes receiver according to object description stored in input record.
bool pythonExport
Output is carried out as a python list instead of writing files.
Set * giveRegionSet(int i)
Returns element set.
int giveNumberOfRegions()
Returns number of regions (aka regionSets).
EngngModel * emodel
Problem pointer.
bool testTimeStepOutput(TimeStep *tStep)
Stores all neccessary data (of a region) in a VTKPiece so it can be exported later.
void setInternalXFEMVarInNode(int varNum, int eiNum, int nodeNum, FloatArray valueArray)
FloatArray & giveInternalXFEMVarInNode(int varNum, int eiNum, int nodeNum)
void setNumberOfInternalVarsToExport(const IntArray &ists, int numNodes)
Index giveSize() const
Returns the size of receiver.
void resizeWithValues(Index s, std::size_t allocChunk=0)
double giveTargetTime()
Returns target time.
int giveNumber()
Returns receiver's number.
bool isElementComposite(Element *elem)
static void makeFullTensorForm(FloatArray &answer, const FloatArray &reducedForm, InternalStateValueType vtype)
Gives the full form of given symmetrically stored tensors, missing components are filled with zeros.
virtual void setupVTKPiece(ExportRegion &vtkPiece, TimeStep *tStep, Set ®ion)
IntArray internalVarsToExport
List of InternalStateType values, identifying the selected vars for export.
std::unique_ptr< NodalRecoveryModel > smoother
Smoother.
void exportCompositeElement(ExportRegion &vtkPiece, Element *el, TimeStep *tStep)
ExportRegion defaultVTKPiece
void writeVTKPointData(FloatArray &valueArray)
std::vector< ExportRegion > defaultVTKPieces
bool writeVTKPieceProlog(ExportRegion &vtkPiece, TimeStep *tStep)
bool writeVTKPieceEpilog(ExportRegion &vtkPiece, TimeStep *tStep)
std::string giveOutputFileName(TimeStep *tStep)
Returns the filename for the given time step.
virtual ~VTKXMLXFemExportModule()
Destructor.
void initializeFrom(InputRecord &ir) override
Initializes receiver according to object description stored in input record.
VTKXMLXFemExportModule(int n, EngngModel *e)
Constructor. Creates empty Output Manager. By default all components are selected.
void getNodalVariableFromXFEMST(FloatArray &answer, Node *node, TimeStep *tStep, XFEMStateType xfemstype, Set ®ion, EnrichmentItem *ei)
void giveDataHeaders(std::string &pointHeader, std::string &cellHeader) override
std::ofstream giveOutputStream(TimeStep *tStep)
Returns the output stream for given solution step.
bool writeXFEMVars(ExportRegion &vtkPiece, int field, int enrItIndex)
void doOutput(TimeStep *tStep, bool forcedOutput=false) override
void exportIntVars2(ExportRegion &vtkPiece, Set ®ion, int field, int enrItIndex, IntArray &internalVarsToExport, NodalRecoveryModel &smoother, TimeStep *tStep)
InternalStateValueType giveXFEMStateValueType(XFEMStateType type)
EnrichmentItem * giveEnrichmentItem(int n)
int giveNumberOfEnrichmentItems() const
@ Element_local
Element is local, there are no contributions from other domains to this element.
const char * __XFEMStateTypeToString(XFEMStateType _value)
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_TENSOR_S3
Symmetric 3x3 tensor.
@ ISVT_TENSOR_G
General tensor.