# Path: pymicro/core/global_variables.py
# XDMF_FIELD_TYPE = {1: 'Scalar', 2: 'Vector', 3: 'Vector', 6: 'Tensor6',
#                    9: 'Tensor'}
# 
# XDMF_IMAGE_GEOMETRY = {'3DImage': 'ORIGIN_DXDYDZ', '2DImage': 'ORIGIN_DXDY'}
# 
# XDMF_IMAGE_TOPOLOGY = {'3DImage': '3DCoRectMesh', '2DImage': '2DCoRectMesh'}
# 
# Path: pymicro/core/global_variables.py
# SD_GROUP_TYPES = ['Group', '2DImage', '3DImage', '2DMesh', '3DMesh']
# 
# SD_GRID_GROUPS = ['2DImage', '3DImage', '2DMesh', '3DMesh', 'emptyImage',
#                   'emptyMesh']
# 
# SD_IMAGE_GROUPS = {2:'2DImage', 3:'3DImage', 0:'emptyImage', -1:'Image'}
# 
# SD_MESH_GROUPS = {2:'2DMesh', 3:'3DMesh', 0:'emptyMesh', -1:'Mesh'}


import os
import subprocess
import shutil
import numpy as np
import tables
import lxml.builder
import BasicTools.Containers.UnstructuredMeshCreationTools as UMCT
            import re
        import BasicTools.Containers.ElementNames as EN
        import BasicTools.Containers.ElementNames as EN
from lxml import etree
from pathlib import Path
from BasicTools.Containers.ConstantRectilinearMesh import (
    ConstantRectilinearMesh)
from BasicTools.Containers.UnstructuredMesh import (UnstructuredMesh,
                                                    AllElements)
from BasicTools.Containers.MeshBase import MeshBase
from BasicTools.IO.XdmfTools import XdmfName,XdmfNumber
from pymicro.core.global_variables import (XDMF_FIELD_TYPE,
                                           XDMF_IMAGE_GEOMETRY,
                                           XDMF_IMAGE_TOPOLOGY)
from pymicro.core.global_variables import (SD_GROUP_TYPES, SD_GRID_GROUPS,
                                           SD_IMAGE_GROUPS, SD_MESH_GROUPS)
        from BasicTools.IO.UniversalReader import ReadMesh
        if len(field_shape) > 2:
            raise ValueError('Forbidden field shape. The field array must be'
                             ' of shape (Nvalues) or (Nvalues,Ndim). Received'
                             ' {}'.format(field_shape))
        node_field = False
        elem_field = False
        Nnodes = self.get_attribute('number_of_nodes', meshname)
        Nelem = np.sum(self.get_attribute('Number_of_elements', meshname))
        Nelem_bulk = np.sum(self.get_attribute('Number_of_bulk_elements',
                                               meshname))
        Nfield_values = field_shape[0]
        if len(field_shape) == 2:
            Field_dim = field_shape[1]
        else:
            Field_dim = 1
        if Nfield_values == Nnodes:
            node_field = True
            field_type='Nodal_field'
        elif Nfield_values == Nelem:
            elem_field = True
            field_type='Element_field'
        elif (Nfield_values % Nelem_bulk) == 0:
            elem_field = True
            field_type = 'IP_field'
        compatibility = node_field or elem_field
        if not(compatibility):
            raise ValueError('Field number of values ({}) is not conformant'
                             ' with mesh number of nodes ({}) or number of'
                             ' elements ({}).'
                             ''.format(Nfield_values, Nnodes, Nelem))

# Path: pymicro/core/global_variables.py
# XDMF_FIELD_TYPE = {1: 'Scalar', 2: 'Vector', 3: 'Vector', 6: 'Tensor6',
#                    9: 'Tensor'}
# 
# XDMF_IMAGE_GEOMETRY = {'3DImage': 'ORIGIN_DXDYDZ', '2DImage': 'ORIGIN_DXDY'}
# 
# XDMF_IMAGE_TOPOLOGY = {'3DImage': '3DCoRectMesh', '2DImage': '2DCoRectMesh'}
# 
# Path: pymicro/core/global_variables.py
# SD_GROUP_TYPES = ['Group', '2DImage', '3DImage', '2DMesh', '3DMesh']
# 
# SD_GRID_GROUPS = ['2DImage', '3DImage', '2DMesh', '3DMesh', 'emptyImage',
#                   'emptyMesh']
# 
# SD_IMAGE_GROUPS = {2:'2DImage', 3:'3DImage', 0:'emptyImage', -1:'Image'}
# 
# SD_MESH_GROUPS = {2:'2DMesh', 3:'3DMesh', 0:'emptyMesh', -1:'Mesh'}


# Path: pymicro/core/samples.py
import os
import subprocess
import shutil
import numpy as np
import tables
import lxml.builder
import BasicTools.Containers.UnstructuredMeshCreationTools as UMCT
            import re
        import BasicTools.Containers.ElementNames as EN
        import BasicTools.Containers.ElementNames as EN
from lxml import etree
from pathlib import Path
from BasicTools.Containers.ConstantRectilinearMesh import (
    ConstantRectilinearMesh)
from BasicTools.Containers.UnstructuredMesh import (UnstructuredMesh,
                                                    AllElements)
from BasicTools.Containers.MeshBase import MeshBase
from BasicTools.IO.XdmfTools import XdmfName,XdmfNumber
from pymicro.core.global_variables import (XDMF_FIELD_TYPE,
                                           XDMF_IMAGE_GEOMETRY,
                                           XDMF_IMAGE_TOPOLOGY)
from pymicro.core.global_variables import (SD_GROUP_TYPES, SD_GRID_GROUPS,
                                           SD_IMAGE_GROUPS, SD_MESH_GROUPS)
        from BasicTools.IO.UniversalReader import ReadMesh

        if len(field_shape) > 2:
            raise ValueError('Forbidden field shape. The field array must be'
                             ' of shape (Nvalues) or (Nvalues,Ndim). Received'
                             ' {}'.format(field_shape))
        node_field = False
        elem_field = False
        Nnodes = self.get_attribute('number_of_nodes', meshname)
        Nelem = np.sum(self.get_attribute('Number_of_elements', meshname))
        Nelem_bulk = np.sum(self.get_attribute('Number_of_bulk_elements',
                                               meshname))
        Nfield_values = field_shape[0]
        if len(field_shape) == 2:
            Field_dim = field_shape[1]
        else:
            Field_dim = 1
        if Nfield_values == Nnodes:
            node_field = True
            field_type='Nodal_field'
        elif Nfield_values == Nelem:
            elem_field = True
            field_type='Element_field'
        elif (Nfield_values % Nelem_bulk) == 0:
            elem_field = True
            field_type = 'IP_field'
        compatibility = node_field or elem_field
        if not(compatibility):
            raise ValueError('Field number of values ({}) is not conformant'
                             ' with mesh number of nodes ({}) or number of'
                             ' elements ({}).'
                             ''.format(Nfield_values, Nnodes, Nelem))

        if Field_dim not in XDMF_FIELD_TYPE: