void ZobristHashing::ExecuteMove(const Move& move) { if (move.HasUsedCell()) { // This move potentially shifts the TopLeft in our relative field // Trying to figure the new hash based on that move is complex // Rebasing the hash is faster _hash = RecaclulateHash(); return; } int positionTo = GetCellPosition(move.GetToCell()); int positionFrom = GetCellPosition(move.GetFromCell()); switch (move.GetMoveType()) { case INSERT: // Remove empty tile _hash ^= _hashValues[HasTile | IsEmpty][positionTo]; // Insert tile with player _hash ^= _hashValues[HasTile | GetDataForPlayer(move.GetToCell())][positionTo]; break; case STEP: { int toCellData = GetCellData(move.GetToCell()); // FROM // Remove tile with player _hash ^= _hashValues[toCellData][positionFrom]; // Insert empty tile _hash ^= _hashValues[HasTile | IsEmpty][positionFrom]; // TO // Remove empty tile _hash ^= _hashValues[HasTile | IsEmpty][positionTo]; // Insert tile with player _hash ^= _hashValues[toCellData][positionTo]; break; } case JUMP: { int toCellData = GetCellData(move.GetToCell()); // FROM // Remove tile with player (xor flipped as the board state has already been updated!) _hash ^= _hashValues[toCellData ^ IsFlipped][positionFrom]; // Insert empty tile _hash ^= _hashValues[HasTile | IsEmpty][positionFrom]; // TO // Remove empty tile _hash ^= _hashValues[HasTile | IsEmpty][positionTo]; // Insert tile with player _hash ^= _hashValues[toCellData][positionTo]; break; } } }
void ZobristHashing::UndoMove(const Move& move, Players player) { if (move.HasUsedCell()) { // This move potentially shifts the TopLeft in our relative field // Trying to figure the new hash based on that move is complex // Rebasing the hash is faster _hash = RecaclulateHash(); return; } int playerValue = (player == Max) ? IsMax : 0; int positionTo = GetCellPosition(move.GetToCell()); int positionFrom = GetCellPosition(move.GetFromCell()); switch (move.GetMoveType()) { case INSERT: // Remove the player with tile _hash ^= _hashValues[HasTile | playerValue][positionTo]; // Insert empty tile _hash ^= _hashValues[HasTile | IsEmpty][positionTo]; break; case STEP: { int cellData = GetCellData(move.GetFromCell()); // FROM // Remove empty tile _hash ^= _hashValues[HasTile | IsEmpty][positionFrom]; // Insert player _hash ^= _hashValues[cellData][positionFrom]; // TO // Remove player _hash ^= _hashValues[cellData][positionTo]; // Insert empty tile _hash ^= _hashValues[HasTile | IsEmpty][positionTo]; break; } case JUMP: { int cellData = GetCellData(move.GetFromCell()); // FROM // Remove empty tile _hash ^= _hashValues[HasTile | IsEmpty][positionFrom]; // Insert player _hash ^= _hashValues[cellData ^ IsFlipped][positionFrom]; // TO // Remove player _hash ^= _hashValues[cellData][positionTo]; // Insert player _hash ^= _hashValues[HasTile | IsEmpty][positionTo]; break; } } }
void Putcellinfo(int x, int y, struct CSV_INFO *csvinfo) /* セル番地の表示 */ { int i; char s[TBOX_X + 1]; for (i = 0; i < TBOX_X; i++) {s[i] = ' ';} s[0] = '('; s[9] = ')'; s[TBOX_X] = '\0'; i = setdec(y + 1, s, 7); // これは行番号 s[i--] = 0x41 + (x % 26); // ここから列番号 if (x > 25) s[i] = 0x40 + (x / 26); api_boxfilwin(win, 6, 26, 6 + TBOX_X * 8, 41, 8); api_putstrwin(win, 6, 26, 0, TBOX_X, s); // 表示1 i = GetCellData(s, csvinfo, csvinfo->comma[y][x], TBOX_X-12); if (i >= 0) { s[i] = 0; api_putstrwin(win, 86, 26, 0, i, s); // 表示2 } return; }
bool MappedMemoryArea::MoveAddressForward(Address const& rAddress, Address& rMovedAddress, s64 Offset) const { if (Offset == 0) { rMovedAddress = rAddress; return true; } TOffset MovedOffset = rAddress.GetOffset(); while (Offset--) { while (true) { auto spCellData = GetCellData(MovedOffset); if (spCellData != nullptr) MovedOffset += spCellData->GetLength(); // TODO: check intoverflow here else ++MovedOffset; if (IsCellPresent(MovedOffset)) break; if (MovedOffset > (m_VirtualBase.GetOffset() + GetSize())) return false; } } rMovedAddress = MakeAddress(MovedOffset); return true; }
bool MappedMemoryArea::GetNearestAddress(Address const& rAddress, Address& rNearestAddress) const { auto Offset = rAddress.GetOffset(); if (Offset < m_VirtualBase.GetOffset()) { rNearestAddress = m_VirtualBase; return true; } if (GetCellData(Offset) != nullptr) { rNearestAddress = MakeAddress(rAddress.GetOffset()); return true; } bool Found = false; do { // Avoid integer underflow if (Offset == 0x0) return false; --Offset; if (GetCellData(Offset) != nullptr) { Found = true; break; } } while (Offset >= m_VirtualBase.GetOffset()); if (Found == false) return false; rNearestAddress = MakeAddress(Offset); return true; }
CellPtr Cell::Divide() { // Check we're allowed to divide assert(!IsDead()); assert(mCanDivide); mCanDivide = false; // Reset properties of parent cell mpCellCycleModel->ResetForDivision(); mpSrnModel->ResetForDivision(); // Create copy of cell property collection to modify for daughter cell CellPropertyCollection daughter_property_collection = mCellPropertyCollection; // Remove the CellId from the daughter cell, as a new one will be assigned in the constructor daughter_property_collection.RemoveProperty<CellId>(); // Copy all cell data (note we create a new object not just copying the pointer) assert(daughter_property_collection.HasPropertyType<CellData>()); // Get the existing copy of the cell data and remove it from the daughter cell boost::shared_ptr<CellData> p_cell_data = GetCellData(); daughter_property_collection.RemoveProperty(p_cell_data); // Create a new cell data object using the copy constructor and add this to the daughter cell MAKE_PTR_ARGS(CellData, p_daughter_cell_data, (*p_cell_data)); daughter_property_collection.AddProperty(p_daughter_cell_data); // Copy all cell Vec data (note we create a new object not just copying the pointer) if (daughter_property_collection.HasPropertyType<CellVecData>()) { // Get the existing copy of the cell data and remove it from the daughter cell boost::shared_ptr<CellVecData> p_cell_vec_data = GetCellVecData(); daughter_property_collection.RemoveProperty(p_cell_vec_data); // Create a new cell data object using the copy constructor and add this to the daughter cell MAKE_PTR_ARGS(CellVecData, p_daughter_cell_vec_data, (*p_cell_vec_data)); daughter_property_collection.AddProperty(p_daughter_cell_vec_data); } // Create daughter cell with modified cell property collection CellPtr p_new_cell(new Cell(GetMutationState(), mpCellCycleModel->CreateCellCycleModel(), mpSrnModel->CreateSrnModel(), false, daughter_property_collection)); // Initialise properties of daughter cell p_new_cell->GetCellCycleModel()->InitialiseDaughterCell(); p_new_cell->GetSrnModel()->InitialiseDaughterCell(); // Set the daughter cell to inherit the apoptosis time of the parent cell p_new_cell->SetApoptosisTime(mApoptosisTime); return p_new_cell; }
// TODO: Check if this function works for every cases bool MappedMemoryArea::MoveAddressBackward(Address const& rAddress, Address& rMovedAddress, s64 Offset) const { if (Offset == 0) { rMovedAddress = rAddress; return true; } Offset = -Offset; TOffset MovedOff = rAddress.GetOffset(); TOffset PrevOff; TOffset MemAreaBegOff = m_VirtualBase.GetOffset(); while (true) { s32 SkippedOff = 0; for (PrevOff = MovedOff - 1; PrevOff >= MemAreaBegOff; --PrevOff) { auto spCellData = GetCellData(PrevOff); if (spCellData != nullptr) { SkippedOff -= spCellData->GetLength(); break; } ++SkippedOff; } if (SkippedOff < 0) SkippedOff = 0; if (SkippedOff == 0) --Offset; if (SkippedOff > Offset) Offset = 0; MovedOff = PrevOff; if (Offset == 0) { rMovedAddress = MakeAddress(MovedOff); return true; } if (MovedOff == MemAreaBegOff) return false; } return false; }
bool MappedMemoryArea::GetNextAddress(Address const& rAddress, Address& rNextAddress) const { TOffset LimitOffset = m_VirtualBase.GetOffset() + GetSize(); for (auto Offset = rAddress.GetOffset() + 1; Offset < LimitOffset; ++Offset) { auto pCurrentCell = GetCellData(Offset); if (pCurrentCell != nullptr) { rNextAddress = MakeAddress(Offset); return true; } } return false; }
long long ZobristHashing::RecaclulateHash() { long long hash = 0; for (int x = 0; x < 20; ++x) { for (int y = 0; y < 20; ++y) { const Vector2D position = Vector2D(x, y); int cellData = GetCellData(position); if (cellData == 0) { // This cell is completely empty continue; } hash ^= _hashValues[cellData][GetCellPosition(Vector2D(x, y))]; } } return hash; }
void PutCell(int bx, int by, struct CSV_INFO *csvinfo) { int i, tx = bx, ty = by, y; char s[11]; s[10] = '\0'; for (i = 0; i < 10; i++) {s[i] = ' ';} for (i=1; i<maxell_y;i++) { setdec(ty, s, 5); ty++; putstr(2, CELLSIZ_Y*i+2, 7, 12, 10, s); } for (i = 0; i < 10; i++) {s[i] = ' ';} i = 1; for (;;) { tx = bx + i - 2; if (tx > 25) s[4] = 0x40 + (tx / 26); s[5] = 0x41 + (tx % 26); putstr(CELLSIZ_X*i+2, 2, 7, 12, 10, s); i++; if (i >= maxell_x) break; } /* Read file */ for (y = 1; y < maxell_y; y++) { int x; for (x = 1; x < maxell_x; x++) { tx = bx+x-2; // tx, tyをリサイクル ty = by+y-2; for (i = 0; i < 10; i++) {s[i] = ' ';} putstr(CELLSIZ_X*x+2, CELLSIZ_Y*y+2, 0, 7, 10, s); i = GetCellData(s, csvinfo, csvinfo->comma[ty][tx], 10); if (i >= 0) { putstr(CELLSIZ_X*x+2, CELLSIZ_Y*y+2, 0, 7, 10, s); } } } return; }
/** Create the vtkStructuredGrid from the provided workspace @param progressUpdating: Reporting object to pass progress information up the stack. @return fully constructed vtkDataSet. */ vtkSmartPointer<vtkDataSet> vtkMDLineFactory::create(ProgressAction &progressUpdating) const { auto product = tryDelegatingCreation<IMDEventWorkspace, 1>(m_workspace, progressUpdating); if (product != nullptr) { return product; } else { g_log.warning() << "Factory " << this->getFactoryTypeName() << " is being used. You are viewing data with less than " "three dimensions in the VSI. \n"; IMDEventWorkspace_sptr imdws = doInitialize<IMDEventWorkspace, 1>(m_workspace); // Acquire a scoped read-only lock to the workspace (prevent segfault from // algos modifying ws) Mantid::Kernel::ReadLock lock(*imdws); const size_t nDims = imdws->getNumDims(); size_t nNonIntegrated = imdws->getNonIntegratedDimensions().size(); /* Write mask array with correct order for each internal dimension. */ auto masks = Mantid::Kernel::make_unique<bool[]>(nDims); for (size_t i_dim = 0; i_dim < nDims; ++i_dim) { bool bIntegrated = imdws->getDimension(i_dim)->getIsIntegrated(); masks[i_dim] = !bIntegrated; // TRUE for unmaksed, integrated dimensions are masked. } // Ensure destruction in any event. boost::scoped_ptr<IMDIterator> it( createIteratorWithNormalization(m_normalizationOption, imdws.get())); // Create 2 points per box. vtkNew<vtkPoints> points; points->SetNumberOfPoints(it->getDataSize() * 2); // One scalar per box vtkNew<vtkFloatArray> signals; signals->Allocate(it->getDataSize()); signals->SetName(vtkDataSetFactory::ScalarName.c_str()); signals->SetNumberOfComponents(1); size_t nVertexes; auto visualDataSet = vtkSmartPointer<vtkUnstructuredGrid>::New(); visualDataSet->Allocate(it->getDataSize()); vtkNew<vtkIdList> linePointList; linePointList->SetNumberOfIds(2); Mantid::API::CoordTransform const *transform = NULL; if (m_useTransform) { transform = imdws->getTransformToOriginal(); } Mantid::coord_t out[1]; auto useBox = std::vector<bool>(it->getDataSize()); double progressFactor = 0.5 / double(it->getDataSize()); double progressOffset = 0.5; size_t iBox = 0; do { progressUpdating.eventRaised(double(iBox) * progressFactor); Mantid::signal_t signal_normalized = it->getNormalizedSignal(); if (std::isfinite(signal_normalized) && m_thresholdRange->inRange(signal_normalized)) { useBox[iBox] = true; signals->InsertNextValue(static_cast<float>(signal_normalized)); auto coords = std::unique_ptr<coord_t[]>( it->getVertexesArray(nVertexes, nNonIntegrated, masks.get())); // Iterate through all coordinates. Candidate for speed improvement. for (size_t v = 0; v < nVertexes; ++v) { coord_t *coord = coords.get() + v * 1; size_t id = iBox * 2 + v; if (m_useTransform) { transform->apply(coord, out); points->SetPoint(id, out[0], 0, 0); } else { points->SetPoint(id, coord[0], 0, 0); } } } // valid number of vertexes returned else { useBox[iBox] = false; } ++iBox; } while (it->next()); for (size_t ii = 0; ii < it->getDataSize(); ++ii) { progressUpdating.eventRaised((double(ii) * progressFactor) + progressOffset); if (useBox[ii] == true) { vtkIdType pointIds = ii * 2; linePointList->SetId(0, pointIds + 0); // xyx linePointList->SetId(1, pointIds + 1); // dxyz visualDataSet->InsertNextCell(VTK_LINE, linePointList.GetPointer()); } // valid number of vertexes returned } signals->Squeeze(); points->Squeeze(); visualDataSet->SetPoints(points.GetPointer()); visualDataSet->GetCellData()->SetScalars(signals.GetPointer()); visualDataSet->Squeeze(); // Hedge against empty data sets if (visualDataSet->GetNumberOfPoints() <= 0) { vtkNullUnstructuredGrid nullGrid; visualDataSet = nullGrid.createNullData(); } vtkSmartPointer<vtkDataSet> dataset = visualDataSet; return dataset; } }
/** * Save an MD workspace to a vts/vtu file. * @param workspace: the workspace which is to be saved. * @param filename: the name of the file to which the workspace is to be saved. * @param normalization: the visual normalization option * @param recursionDepth: the recursion depth for MDEvent Workspaces determines * @param compressorType: the compression type used by VTK * from which level data should be displayed */ void SaveMDWorkspaceToVTKImpl::saveMDWorkspace( const Mantid::API::IMDWorkspace_sptr &workspace, const std::string &filename, VisualNormalization normalization, int recursionDepth, const std::string &compressorType) { auto isHistoWorkspace = boost::dynamic_pointer_cast<Mantid::API::IMDHistoWorkspace>(workspace) != nullptr; auto fullFilename = getFullFilename(filename, isHistoWorkspace); const vtkXMLWriter::CompressorType compressor = [&compressorType] { if (compressorType == "NONE") { return vtkXMLWriter::NONE; } else if (compressorType == "ZLIB") { return vtkXMLWriter::ZLIB; } else { // This should never happen. Mantid::Kernel::Logger g_log("SaveMDWorkspaceToVTK"); g_log.warning("Incorrect CompressorType: " + compressorType + ". Using CompressorType=NONE."); return vtkXMLWriter::NONE; } }(); // Define a time slice. auto time = selectTimeSliceValue(*workspace); // Get presenter and data set factory set up auto factoryChain = getDataSetFactoryChain(isHistoWorkspace, normalization, time); auto presenter = getPresenter(isHistoWorkspace, workspace, recursionDepth); // Create the vtk data NullProgressAction nullProgressA; NullProgressAction nullProgressB; auto dataSet = presenter->execute(factoryChain.get(), nullProgressA, nullProgressB); // Do an orthogonal correction dataSet = getDataSetWithOrthogonalCorrection(dataSet, presenter.get(), workspace, isHistoWorkspace); // ParaView 5.1 checks the range of the entire signal array, including blank // cells. if (isHistoWorkspace) { auto structuredGrid = vtkStructuredGrid::SafeDownCast(dataSet); vtkIdType imageSize = structuredGrid->GetNumberOfCells(); vtkNew<vtkFloatArray> signal; signal->SetNumberOfComponents(1); signal->SetNumberOfTuples(imageSize); auto oldSignal = structuredGrid->GetCellData()->GetScalars(); for (vtkIdType index = 0; index < imageSize; ++index) { if (structuredGrid->IsCellVisible(index)) { signal->SetComponent(index, 0, oldSignal->GetTuple1(index)); } else { signal->SetComponent(index, 0, std::numeric_limits<float>::quiet_NaN()); } } structuredGrid->GetCellData()->SetScalars(signal.GetPointer()); } // Write the data to the file vtkSmartPointer<vtkXMLWriter> writer = getXMLWriter(isHistoWorkspace); auto writeSuccessFlag = writeDataSetToVTKFile(writer, dataSet, fullFilename, compressor); if (!writeSuccessFlag) { throw std::runtime_error("SaveMDWorkspaceToVTK: VTK could not write " "your data set to a file."); } }
/** Create the vtkStructuredGrid from the provided workspace @param progressUpdating: Reporting object to pass progress information up the stack. @return fully constructed vtkDataSet. */ vtkSmartPointer<vtkDataSet> vtkMDHistoLineFactory::create(ProgressAction &progressUpdating) const { auto product = tryDelegatingCreation<MDHistoWorkspace, 1>(m_workspace, progressUpdating); if (product != nullptr) { return product; } else { g_log.warning() << "Factory " << this->getFactoryTypeName() << " is being used. You are viewing data with less than " "three dimensions in the VSI. \n"; Mantid::Kernel::ReadLock lock(*m_workspace); const int nBinsX = static_cast<int>(m_workspace->getXDimension()->getNBins()); const coord_t minX = m_workspace->getXDimension()->getMinimum(); coord_t incrementX = m_workspace->getXDimension()->getBinWidth(); const int imageSize = nBinsX; vtkNew<vtkPoints> points; points->Allocate(static_cast<int>(imageSize)); vtkNew<vtkFloatArray> signal; signal->Allocate(imageSize); signal->SetName(vtkDataSetFactory::ScalarName.c_str()); signal->SetNumberOfComponents(1); UnstructuredPoint unstructPoint; const int nPointsX = nBinsX; Column column(nPointsX); NullCoordTransform transform; // Mantid::API::CoordTransform* transform = // m_workspace->getTransformFromOriginal(); Mantid::coord_t in[3]; Mantid::coord_t out[3]; double progressFactor = 0.5 / double(nBinsX); double progressOffset = 0.5; // Loop through dimensions for (int i = 0; i < nPointsX; i++) { progressUpdating.eventRaised(progressFactor * double(i)); in[0] = minX + static_cast<coord_t>(i) * incrementX; // Calculate increment in x; float signalScalar = static_cast<float>(m_workspace->getSignalNormalizedAt(i)); if (!std::isfinite(signalScalar)) { // Flagged so that topological and scalar data is not applied. unstructPoint.isSparse = true; } else { if (i < (nBinsX - 1)) { signal->InsertNextValue(static_cast<float>(signalScalar)); } unstructPoint.isSparse = false; } transform.apply(in, out); unstructPoint.pointId = points->InsertNextPoint(out); column[i] = unstructPoint; } points->Squeeze(); signal->Squeeze(); auto visualDataSet = vtkSmartPointer<vtkUnstructuredGrid>::New(); visualDataSet->Allocate(imageSize); visualDataSet->SetPoints(points.GetPointer()); visualDataSet->GetCellData()->SetScalars(signal.GetPointer()); for (int i = 0; i < nBinsX - 1; i++) { progressUpdating.eventRaised((progressFactor * double(i)) + progressOffset); // Only create topologies for those cells which are not sparse. if (!column[i].isSparse) { vtkLine *line = vtkLine::New(); line->GetPointIds()->SetId(0, column[i].pointId); line->GetPointIds()->SetId(1, column[i + 1].pointId); visualDataSet->InsertNextCell(VTK_LINE, line->GetPointIds()); } } visualDataSet->Squeeze(); // Hedge against empty data sets if (visualDataSet->GetNumberOfPoints() <= 0) { vtkNullUnstructuredGrid nullGrid; visualDataSet = nullGrid.createNullData(); } vtkSmartPointer<vtkDataSet> dataset = visualDataSet; return dataset; } }
std::string dump(Mesh* mesh, int step, std::string fileName) const { auto _mesh = dynamic_cast<MeshType*>(mesh); assert_true(_mesh); LOG_DEBUG("Writing snapshot for mesh \"" << _mesh->getId() << "\" at step " << step << " to file " << fileName); auto grid = vtkSmartPointer<GridType>::New(); auto points = vtkSmartPointer<vtkPoints>::New(); auto contact = vtkSmartPointer<vtkIntArray>::New(); contact->SetName("contact"); auto border = vtkSmartPointer<vtkIntArray>::New(); border->SetName("border"); auto used = vtkSmartPointer<vtkIntArray>::New(); used->SetName("used"); auto norm = vtkSmartPointer<vtkDoubleArray>::New(); norm->SetName("norm"); norm->SetNumberOfComponents(3); auto vel = vtkSmartPointer<vtkDoubleArray>::New(); vel->SetName("velocity"); vel->SetNumberOfComponents(3); auto crack = vtkSmartPointer<vtkDoubleArray>::New(); crack->SetName("crack"); crack->SetNumberOfComponents(3); auto sxx = vtkSmartPointer<vtkDoubleArray>::New(); sxx->SetName("sxx"); auto sxy = vtkSmartPointer<vtkDoubleArray>::New(); sxy->SetName("sxy"); auto sxz = vtkSmartPointer<vtkDoubleArray>::New(); sxz->SetName("sxz"); auto syy = vtkSmartPointer<vtkDoubleArray>::New(); syy->SetName("syy"); auto syz = vtkSmartPointer<vtkDoubleArray>::New(); syz->SetName("syz"); auto szz = vtkSmartPointer<vtkDoubleArray>::New(); szz->SetName("szz"); auto compression = vtkSmartPointer<vtkDoubleArray>::New(); compression->SetName("compression"); auto tension = vtkSmartPointer<vtkDoubleArray>::New(); tension->SetName("tension"); auto shear = vtkSmartPointer<vtkDoubleArray>::New(); shear->SetName("shear"); auto deviator = vtkSmartPointer<vtkDoubleArray>::New(); deviator->SetName("deviator"); auto matId = vtkSmartPointer<vtkIntArray>::New(); matId->SetName("materialID"); auto rho = vtkSmartPointer<vtkDoubleArray>::New(); rho->SetName("rho"); auto mpiState = vtkSmartPointer<vtkIntArray>::New(); mpiState->SetName("mpiState"); auto nodePublicFlags = vtkSmartPointer<vtkIntArray>::New (); nodePublicFlags->SetName ("publicFlags"); auto nodePrivateFlags = vtkSmartPointer<vtkIntArray>::New (); nodePrivateFlags->SetName ("privateFlags"); auto nodeErrorFlags = vtkSmartPointer<vtkIntArray>::New (); nodeErrorFlags->SetName ("errorFlags"); auto nodeNumber = vtkSmartPointer<vtkIntArray>::New (); nodeNumber->SetName ("nodeNumber"); auto nodeBorderConditionId = vtkSmartPointer<vtkIntArray>::New (); nodeBorderConditionId->SetName ("borderConditionId"); auto nodeContactConditionId = vtkSmartPointer<vtkIntArray>::New(); nodeContactConditionId->SetName("contactState"); auto contactDestroyed = vtkSmartPointer<vtkIntArray>::New(); contactDestroyed->SetName("failedContacts"); auto nodeDestroyed = vtkSmartPointer<vtkIntArray>::New(); nodeDestroyed->SetName("failedNodes"); auto nodeFailureMeasure = vtkSmartPointer<vtkDoubleArray>::New(); nodeFailureMeasure->SetName("failureMeasure"); float _norm[3]; dumpMeshSpecificData(_mesh, grid, points); for (auto it = MeshNodeIterator<MeshType, snapshotterId>(_mesh); it.hasNext(); it++) { auto& node = *it; border->InsertNextValue(node.isBorder() ? 1 : 0); used->InsertNextValue(node.isUsed() ? 1 : 0); contact->InsertNextValue(node.isInContact() ? 1 : 0); if (node.isUsed() && node.isBorder()) _mesh->findBorderNodeNormal(node, _norm, _norm+1, _norm+2, false); else _norm[0] = _norm[1] = _norm[2] = 0.0; norm->InsertNextTuple(_norm); vel->InsertNextTuple(node.velocity); crack->InsertNextTuple(node.getCrackDirection().coords); sxx->InsertNextValue(node.sxx); sxy->InsertNextValue(node.sxy); sxz->InsertNextValue(node.sxz); syy->InsertNextValue(node.syy); syz->InsertNextValue(node.syz); szz->InsertNextValue(node.szz); compression->InsertNextValue(node.getCompression()); tension->InsertNextValue(node.getTension()); shear->InsertNextValue(node.getShear()); deviator->InsertNextValue(node.getDeviator()); matId->InsertNextValue(node.getMaterialId()); rho->InsertNextValue(node.getRho()); mpiState->InsertNextValue(node.isRemote() ? 1 : 0); nodePrivateFlags->InsertNextValue (node.getPrivateFlags()); nodePublicFlags->InsertNextValue (node.getPublicFlags()); nodeErrorFlags->InsertNextValue (node.getErrorFlags()); nodeBorderConditionId->InsertNextValue (node.getBorderConditionId()); nodeContactConditionId->InsertNextValue(node.getContactConditionId()); nodeNumber->InsertNextValue(node.number); contactDestroyed->InsertNextValue(node.isContactDestroyed() ? 1 : 0); nodeDestroyed->InsertNextValue(node.isDestroyed() ? 1 : 0); nodeFailureMeasure->InsertNextValue(node.getDamageMeasure()); } vtkFieldData* fd; if (useCells) fd = grid->GetCellData(); else fd = grid->GetPointData(); grid->SetPoints(points); fd->AddArray(contact); fd->AddArray(border); fd->AddArray(used); fd->AddArray(norm); fd->AddArray(crack); fd->AddArray(sxx); fd->AddArray(sxy); fd->AddArray(sxz); fd->AddArray(syy); fd->AddArray(syz); fd->AddArray(szz); fd->AddArray(compression); fd->AddArray(tension); fd->AddArray(shear); fd->AddArray(deviator); fd->AddArray(matId); fd->AddArray(rho); fd->AddArray(mpiState); fd->AddArray (nodePrivateFlags); fd->AddArray (nodePublicFlags); fd->AddArray (nodeErrorFlags); fd->AddArray (nodeBorderConditionId); fd->AddArray (nodeContactConditionId); fd->AddArray(vel); fd->AddArray(nodeNumber); fd->AddArray(contactDestroyed); fd->AddArray(nodeDestroyed); fd->AddArray(nodeFailureMeasure); // Write file auto writer = vtkSmartPointer<GridWriterType>::New(); writer->SetFileName(fileName.c_str()); #ifdef CONFIG_VTK_5 writer->SetInput(grid); #else writer->SetInputData(grid); #endif writer->Write(); return fileName; }