diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8c3a3b622..b17fe1d27 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,7 @@ stages: - prepare - python - compile + - setup - fortran - performance - deploy @@ -161,8 +162,10 @@ compile_Marc: - master - release + +################################################################################################### setup_grid: - stage: compile + stage: setup script: - module load $IntelCompiler $MPI_Intel $PETSc_Intel - BUILD_DIR=$(mktemp -d) @@ -174,7 +177,7 @@ setup_grid: - release setup_mesh: - stage: compile + stage: setup script: - module load $IntelCompiler $MPI_Intel $PETSc_Intel - BUILD_DIR=$(mktemp -d) diff --git a/python/damask/_grid.py b/python/damask/_grid.py index 36fa6411b..c984dd000 100644 --- a/python/damask/_grid.py +++ b/python/damask/_grid.py @@ -1,8 +1,8 @@ +import os import copy +import warnings import multiprocessing as mp from functools import partial -import os -import warnings import numpy as np import pandas as pd @@ -20,7 +20,7 @@ class Grid: Geometry definition for grid solvers. Create and manipulate geometry definitions for storage as VTK - image data files ('.vit' extension). A grid contains the + image data files ('.vti' extension). A grid contains the material ID (referring to the entry in 'material.yaml') and the physical size. """ @@ -166,9 +166,7 @@ class Grid: Grid-based geometry from file. """ - if str(fname).endswith('.vtr'): - warnings.warn('Support for vtr files will be removed in DAMASK 3.1.0', DeprecationWarning,2) - v = VTK.load(fname) + v = VTK.load(fname if str(fname).endswith('.vti') else str(fname)+'.vti') comments = v.get_comments() cells = np.array(v.vtk_data.GetDimensions())-1 bbox = np.array(v.vtk_data.GetBounds()).reshape(3,2).T diff --git a/python/damask/_vtk.py b/python/damask/_vtk.py index b525ef35e..7761b7758 100644 --- a/python/damask/_vtk.py +++ b/python/damask/_vtk.py @@ -1,4 +1,5 @@ import os +import warnings import multiprocessing as mp from pathlib import Path @@ -69,8 +70,6 @@ class VTK: """ Create VTK of type vtk.vtkRectilinearGrid. - This is the common type for grid solver results. - Parameters ---------- grid : iterable of int, len (3) @@ -86,6 +85,7 @@ class VTK: VTK-based geometry without nodal or cell data. """ + warnings.warn('Support for vtr files will be removed in DAMASK 3.1.0', DeprecationWarning,2) vtk_data = vtk.vtkRectilinearGrid() vtk_data.SetDimensions(*(np.array(grid)+1)) coord = [np_to_vtk(np.linspace(origin[i],origin[i]+size[i],grid[i]+1),deep=True) for i in [0,1,2]] @@ -179,8 +179,8 @@ class VTK: Parameters ---------- fname : str or pathlib.Path - Filename for reading. Valid extensions are .vtr, .vtu, .vtp, and .vtk. - dataset_type : {'vtkRectilinearGrid', 'vtkUnstructuredGrid', 'vtkPolyData'}, optional + Filename for reading. Valid extensions are .vti, .vtr, .vtu, .vtp, and .vtk. + dataset_type : {'vtkImageData', ''vtkRectilinearGrid', 'vtkUnstructuredGrid', 'vtkPolyData'}, optional Name of the vtk.vtkDataSet subclass when opening a .vtk file. Returns diff --git a/src/grid/discretization_grid.f90 b/src/grid/discretization_grid.f90 index 3fa6205ea..ff985eb6a 100644 --- a/src/grid/discretization_grid.f90 +++ b/src/grid/discretization_grid.f90 @@ -164,9 +164,9 @@ subroutine readVTI(grid,geomSize,origin,material) integer, dimension(:), intent(out), allocatable :: & material - character(len=:), allocatable :: fileContent, dataType, headerType, temp - logical :: inFile,inGrid,gotCoordinates,gotCellData,compressed - integer :: fileUnit, myStat, coord + character(len=:), allocatable :: fileContent, dataType, headerType + logical :: inFile,inImage,gotCellData,compressed + integer :: fileUnit, myStat integer(pI64) :: & fileLength, & !< length of the geom file (in characters) startPos, endPos, & @@ -186,39 +186,37 @@ subroutine readVTI(grid,geomSize,origin,material) close(fileUnit) inFile = .false. - inGrid = .false. - gotCoordinates = .false. + inImage = .false. gotCelldata = .false. !-------------------------------------------------------------------------------------------------- -! interpret XML file +! parse XML file startPos = 1_pI64 do while (startPos < len(fileContent,kind=pI64)) endPos = startPos + index(fileContent(startPos:),IO_EOL,kind=pI64) - 2_pI64 if (endPos < startPos) endPos = len(fileContent,kind=pI64) ! end of file without new line - if(.not. inFile) then + if (.not. inFile) then if(index(fileContent(startPos:endPos),'',kind=pI64) /= 0_pI64) then + if (index(fileContent(startPos:endPos),'',kind=pI64) /= 0_pI64) then gotCellData = .true. do while (index(fileContent(startPos:endPos),'',kind=pI64) == 0_pI64) - if(index(fileContent(startPos:endPos),' @brief determine size and origin from coordinates !------------------------------------------------------------------------------------------------ - subroutine cellsSizeOrigin(header) + subroutine cellsSizeOrigin(c,s,o,header) - character(len=*), intent(in) :: header + integer, dimension(3), intent(out) :: c + real(pReal), dimension(3), intent(out) :: s,o + character(len=*), intent(in) :: header character(len=:), allocatable :: temp - real(pReal), dimension(:), allocatable :: coords,delta,origin + real(pReal), dimension(:), allocatable :: delta integer, dimension(:), allocatable :: stringPos integer :: i @@ -265,15 +265,17 @@ subroutine readVTI(grid,geomSize,origin,material) if (getXMLValue(header,'Direction') /= '1 0 0 0 1 0 0 0 1') & call IO_error(error_ID = 844, ext_msg = 'coordinate order') - temp = getXMLValue(header,'Origin') - origin = [(IO_floatValue(temp,IO_stringPos(temp),i),i=1,3)] + temp = getXMLValue(header,'WholeExtent') + if (any([(IO_floatValue(temp,IO_stringPos(temp),i),i=1,5,2)] /= 0)) & + call IO_error(error_ID = 844, ext_msg = 'coordinate start') + c = [(IO_floatValue(temp,IO_stringPos(temp),i),i=2,6,2)] + temp = getXMLValue(header,'Spacing') delta = [(IO_floatValue(temp,IO_stringPos(temp),i),i=1,3)] - temp = getXMLValue(header,'WholeExtent') - grid = [(IO_floatValue(temp,IO_stringPos(temp),i),i=2,6,2)] + s = delta * real(c,pReal) - - geomSize = delta * real(grid,pReal) + temp = getXMLValue(header,'Origin') + o = [(IO_floatValue(temp,IO_stringPos(temp),i),i=1,3)] end subroutine