Commit dade8415 authored by Kenneth Loenbaek's avatar Kenneth Loenbaek
Browse files

Added sim_set_default_args to make the 2D reader work

parent 13bf8fef
......@@ -241,17 +241,9 @@ def sim2names(filename_RST, name_out="fields"):
def sim2dict(filename_RST, filename_XXD=None, load_names=None, read_default=True, blocks=None, load_ghost=False,
as_matrix=False, is2D=None, vectors=None):
# If no grid filename is set
if filename_XXD is None:
proj_name = filename_RST[:filename_RST.index(".RST")]
if proj_name+".X3D" in os.listdir("."):
filename_XXD = proj_name + ".X3D"
elif proj_name+".X2D" in os.listdir("."):
filename_XXD = proj_name + ".X2D"
else:
raise ValueError("Could not find grid a suitable .XXD file in current dir with project name: %s"%proj_name)
is2D = XXD_set_default_args(filename_XXD, load_names, read_default, is2D)[1]
filename_XXD, load_names, vectors, fields_in_vectors, is2D = sim_set_default_args(filename_RST, filename_XXD,
load_names, read_default, vectors,
is2D)
# Read grid data
XXD, bsize_XXD, nblock_XXD = XXD2dict(filename_XXD, load_names, read_default, blocks, load_ghost, as_matrix, is2D)
......@@ -267,6 +259,22 @@ def sim2dict(filename_RST, filename_XXD=None, load_names=None, read_default=True
RST.update(XXD)
return RST, bsize_XXD, nblock_XXD
def sim_set_default_args(filename_RST, filename_XXD, load_names, read_default, vectors, is2D):
# If no grid filename is set
if filename_XXD is None:
proj_name = filename_RST[:filename_RST.index(".RST")]
if proj_name + ".X3D" in os.listdir("."):
filename_XXD = proj_name + ".X3D"
elif proj_name + ".X2D" in os.listdir("."):
filename_XXD = proj_name + ".X2D"
else:
raise ValueError(
"Could not find grid a suitable .XXD file in current dir with project name: %s" % proj_name)
load_names, is2D = XXD_set_default_args(filename_XXD, load_names, read_default, is2D)
load_names, vectors, fields_in_vectors = RST_set_default_args(load_names, read_default, vectors)
return filename_XXD, load_names, vectors, fields_in_vectors, is2D
def initialize_data_array(nblocks, bsize, dtype=float, vec=False, is2D=False):
exp = 2 if is2D else 3
if vec:
......
from vtk.numpy_interface import dataset_adapter as dsa
from vtk import (vtkMultiBlockDataSet, vtkPoints, vtkStructuredGrid,
vtkTransformFilter, vtkTransform, vtkArrayCalculator, vtkCompositeDataSet)
from .ellipsys2dict import XXD2dict, sim2dict, RST_set_default_args, XXD_set_default_args
from .ellipsys2dict import XXD2dict, sim2dict, sim_set_default_args
def XXD2vtk(filname, load_attr=True, blocks=None, load_ghost=False, is2D=None, mblock=None):
# Initializing multiblock
......@@ -53,8 +53,9 @@ def sim2vtk(filename_RST, filename_XXD=None, load_names=None, read_default=True,
mblock = vtkMultiBlockDataSet()
# Reading data
load_names, vectors, fields_in_vectors = RST_set_default_args(load_names, read_default, vectors)
load_names, is2D = XXD_set_default_args(filename_XXD, load_names, read_default, is2D)
filename_XXD, load_names, vectors, fields_in_vectors, is2D = sim_set_default_args(filename_RST, filename_XXD,
load_names, read_default, vectors,
is2D)
if "points" not in load_names: # Forcing points to always be present
load_names.add("points")
sim, bsize, nblock_out = sim2dict(filename_RST, filename_XXD, load_names, read_default, blocks, load_ghost,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment