示例#1
0
 def __init__(self, mesh_file=None, dim=3):
     self.dimension = dim
     self.mb = core.Core()
     self.mtu = topo_util.MeshTopoUtil(self.mb)
     if mesh_file is not None:
         self.mb.load_file(mesh_file)
         self.run()
示例#2
0
    def __init__(self, inputname_dict, inputname_h5m):
        global kkeys
        self.__verif = False
        self.kkeys = kkeys
        os.chdir('configs')
        with open(inputname_dict, 'r') as stream:
            self.info = yaml.load(stream)
        os.chdir('..')
        self.Ltot = self.info[self.kkeys[0]]['L']

        self.mb = core.Core()
        self.mb.load_file(inputname_h5m)
        self.mtu = topo_util.MeshTopoUtil(self.mb)
        self.sk = skinner.Skinner(self.mb)
        self.root_set = self.mb.get_root_set()
        self.all_volumes = self.mb.get_entities_by_dimension(self.root_set, 3)
        # e_tags = self.mb.tag_get_tags_on_entity(self.all_volumes[0])
        # print(e_tags)
        # import pdb; pdb.set_trace()
        self.all_nodes = self.mb.get_entities_by_dimension(0, 0)
        self.mtu.construct_aentities(self.all_nodes)
        self.all_faces = self.mb.get_entities_by_dimension(self.root_set, 2)
        self.all_edges = self.mb.get_entities_by_dimension(self.root_set, 1)
        self.vols_centroids = np.array(
            [self.mtu.get_average_position([v]) for v in self.all_volumes])
        self.ns = (len(self.all_volumes))
        self.gravity = self.info[key_gravity]

        self.DefineLenghtNv0()
        self.__verif = True
示例#3
0
    def __init__(self, coords, elements, point_type, center):
        self.mb = core.Core()
        #self.point_type = np.concatenate((np.array([-1]), point_type))
        self.point_type = point_type
        verts = self.mb.create_vertices(coords)
        self.rs = self.mb.get_root_set()

        elements = elements + np.ones(elements.shape)
        self.tag_handle = self.mb.tag_get_handle("Teste", 1, types.MB_TYPE_INTEGER, types.MB_TAG_DENSE, create_if_missing = True)
        self.tag_node = self.mb.tag_get_handle("Nodes", 1, types.MB_TYPE_INTEGER, types.MB_TAG_DENSE, create_if_missing = True)

        for el in elements:
            tetra = self.mb.create_element(types.MBTET, el.ravel().astype("uint64"))

        # self.mtu = topo_util.MeshTopoUtil(self.mb)
        # self.mtu.construct_aentities(verts)
        #self.mtu.construct_aentities(verts)
        #self.elements = self.mb.get_entities_by_dimension(0, 3)
        self.mtu = topo_util.MeshTopoUtil(self.mb)
        self.all_elements = self.mb.get_entities_by_dimension(0, 3)
        self.nodes = self.mb.get_entities_by_dimension(0, 0)
        self.faces = self.skinner(self.all_elements)
        self.boundary_nodes = self.find_boundary_nodes()
        self.boundary_elements = self.find_boundary_elements()

        self.desired_bnodes = np.array(self.nodes)[self.point_type == 0]
        self.find_simple_bad()
        #self.select(self.boundary_nodes)
        #self.remove_vol(self.all_elements[0:120])
        #self.find_bad_vol()
        #import pdb; pdb.set_trace()
        #self.smooth()
        #import pdb; pdb.set_trace()
        self.create_vtk()
示例#4
0
    def __init__(self):
        global parent_parent_dir, mesh_dir
        self.dimension = 3
        self.mb = core.Core()
        self.root_set = self.mb.get_root_set()
        self.mtu = topo_util.MeshTopoUtil(self.mb)

        with open("inputs.yaml", 'r') as stream:
            data_loaded = yaml.load(stream)

        input_name = data_loaded['input_name']
        ext_msh = mesh_dir + '/' + input_name + '.msh'
        self.ext_out = input_name + '_out_initial_mesh3D'
        self.ext_out_h5m = self.ext_out + '.h5m'
        self.mb.load_file(ext_msh)

        self.all_volumes = self.mb.get_entities_by_dimension(0, self.dimension)
        self.all_nodes = self.mb.get_entities_by_dimension(0, 0)
        self.mtu.construct_aentities(self.all_nodes)
        self.all_faces = self.mb.get_entities_by_dimension(0, 2)
        lx = data_loaded['lx']
        ly = data_loaded['ly']
        lz = data_loaded['lz']
        self.hs = [lx, ly, lz]
        self.Areas = np.array([ly * lz, lx * lz, lx * ly])
        self.mi = 1.0
        self.data = dict()
        self.entities = dict()
        self.tags = dict()
        self.tags_to_infos = dict()
        self.entities_to_tags = dict()
示例#5
0
    def __init__(self):
        os.chdir(input_dir)
        with open("input_mesh_generator.yaml", 'r') as stream:
            data_loaded_mesh = yaml.load(stream)
            # data_loaded = yaml.load(stream, Loader=yaml.FullLoader)
            # data_loaded = yaml.full_load(stream)

        with open("input_wells.yaml", 'r') as stream:
            data_loaded_wells = yaml.load(stream)
            # data_loaded = yaml.load(stream, Loader=yaml.FullLoader)
            # data_loaded = yaml.full_load(stream)

        self.data_loaded = data_loaded_mesh
        file_name = data_loaded_mesh['file_name']
        self.file_name = file_name
        # self.Lz = float(data_loaded_mesh['mesh_size'][2])
        name_mesh = file_name + '_wells.h5m'
        self.mb = core.Core()
        self.mtu = topo_util.MeshTopoUtil(self.mb)
        mesh_file = name_mesh
        os.chdir(flying_dir)
        self.mb.load_file(mesh_file)
        names_tags = np.load('tags_wells.npy')
        self.tags = utpy.get_all_tags_2(self.mb, names_tags)
        self.all_nodes, self.all_edges, self.all_faces, self.all_volumes = utpy.get_all_entities(
            self.mb)

        import pdb
        pdb.set_trace()
示例#6
0
    def __init__(self, coarse_ratio, mesh_size, block_size, moab):

        self.coarse_ratio = coarse_ratio
        self.mesh_size = mesh_size
        self.block_size = block_size

        self.verts = None  # Array containing MOAB vertex entities
        self.elems = []  # List containing MOAB volume entities

        self.coarse_verts = None  # Array containing MOAB vertex entities for
        #                           the coarse mesh
        self.coarse_elems = []  # List containig MOAB volume entities for the
        #                         coarse mesh

        self.primals = {}  # Mapping from tuples (idx, dy, idz) to Coarse
        #                    volumes
        self.primal_ids = []

        self.primals_adj = []

        self.perm = []

        # MOAB boilerplate
        self.mb = moab
        self.root_set = self.mb.get_root_set()
        self.mesh_topo_util = topo_util.MeshTopoUtil(self.mb)

        # Pytrilinos boilerplate
        self.comm = Epetra.PyComm()
        self.mlList = {
            "max levels": 3,
            "output": 10,
            "smoother: type": "symmetric Gauss-Seidel",
            "aggregation: type": "Uncoupled"
        }
示例#7
0
    def __init__(self):
        shutil.rmtree(flying_dir)
        os.makedirs(flying_dir)
        self.__verif = True
        with open("input_mesh_generator.yaml", 'r') as stream:
            data_loaded = yaml.load(stream)
            # data_loaded = yaml.load(stream, Loader=yaml.FullLoader)
            # data_loaded = yaml.full_load(stream)

        with open("input_wells.yaml", 'r') as stream:
            data_wells = yaml.load(stream)
            # data_loaded = yaml.load(stream, Loader=yaml.FullLoader)
            # data_loaded = yaml.full_load(stream)

        self.data_loaded = data_loaded
        self.tags = dict()
        self.mb = core.Core()
        self.mtu = topo_util.MeshTopoUtil(self.mb)
        self.nblocks = data_loaded['nblocks']
        self.mesh_size = data_loaded['mesh_size']
        self.blocksize = self.mesh_size / self.nblocks
        hx = self.blocksize[0]
        hy = self.blocksize[1]
        hz = self.blocksize[2]
        self.Area = np.array([hy * hz, hx * hz, hy * hx])
        self.mi = data_wells['dados_monofasico']['mi']
        self.gama = data_wells['dados_monofasico']['gama']
示例#8
0
    def persistent_load(self, pid):
        type_tag = pid[0]
        if type_tag == "core":
            if self.mb is None:
                mb = core.Core()
                mb.load_file(f'{self.file_name}.h5m')
                self.mb = mb
            return self.mb
        elif type_tag == "mtu":
            if self.mb is None:
                raise pickle.UnpicklingError("core is missing")
            if self.mtu is None:
                mtu = topo_util.MeshTopoUtil(self.mb)
            return self.mtu
        elif type_tag == "skinner":
            if self.mb is None:
                raise pickle.UnpicklingError("core is missing")
            if self.skinner is None:
                self.skinner = skinner.Skinner(self.mb)
            return self.skinner
        elif type_tag == "range":
            r = rng.Range(pid[1])
            return r
        elif type_tag == "tag":
            if self.mb is None:
                raise pickle.UnpicklingError("core is missing")
            return self.mb.tag_get_handle(pid[1])

        else:
            print()
            raise pickle.UnpicklingError(
                f'unsupported persistent object {pid}')
示例#9
0
    def _compute_adjacencies(self, moab):
        """Computes adjacencies and stores them as tags.

        Parameters
        ----------
        moab: MOAB mesh object
            Mesh used to compute the adjacencies. The get_bridge_adjacencies
            method from the topo_util module is used to compute the
            adjacencies.
        """
        mesh_topo_util = topo_util.MeshTopoUtil(moab)
        root_set = moab.get_root_set()

        all_verts = moab.get_entities_by_dimension(root_set, 0)
        mesh_topo_util.construct_aentities(all_verts)

        for (from_dim, bridge_dim, to_dim, layers) in self.adjacencies:
            ents = moab.get_entities_by_dimension(root_set, from_dim)

            adj_tag_name = "__adj_tag_{0}{1}{2}{3}".format(
                from_dim, bridge_dim, to_dim, layers)

            adj_tag = moab.tag_get_handle(adj_tag_name, 1,
                                          types.MB_TYPE_HANDLE,
                                          types.MB_TAG_SPARSE, True)

            for ent in ents:
                adjs_meshset = moab.create_meshset()
                adjs = mesh_topo_util.get_bridge_adjacencies(
                    ent, bridge_dim, to_dim, layers)

                moab.add_entities(adjs_meshset, adjs)

                moab.tag_set_data(adj_tag, ent, adjs_meshset)
示例#10
0
    def __init__(self, mesh_file, dim=3):
        self.dimension = dim
        self.mb = core.Core()
        self.root_set = self.mb.get_root_set()
        self.mtu = topo_util.MeshTopoUtil(self.mb)
        self.mb.load_file(mesh_file)
        self.all_volumes = self.mb.get_entities_by_dimension(0, 3)
        self.all_nodes = self.mb.get_entities_by_dimension(0, 0)
        self.mtu.construct_aentities(self.all_nodes)
        self.all_faces = self.mb.get_entities_by_dimension(0, 2)
        self.all_edges = self.mb.get_entities_by_dimension(0, 1)
        self.handleDic = {}
        [self.boundary_nodes, self.boundary_edges, self.boundary_faces, self.boundary_volumes] = self.skinner_operation()

        self.internal_nodes = rng.subtract(self.all_nodes, self.boundary_nodes)
        self.internal_edges = rng.subtract(self.all_edges, self.boundary_edges)
        self.internal_faces = rng.subtract(self.all_faces, self.boundary_faces)
        self.internal_volumes = rng.subtract(self.all_volumes, self.boundary_volumes)

        self.init_id()
        self.check_integrity()
        self.create_id_visualization()
        # self.flag_dic = {}
        [self.flag_list, self.flag_dic] = self.read_flags()

        self.create_flag_visualization()

        # swtich on/off
        self.parallel_meshset = self.create_parallel_meshset()
        self.create_parallel_visualization()
示例#11
0
def load_adm_mesh():
    n_levels = 3
    parent_dir = os.path.dirname(os.path.abspath(__file__))
    parent_parent_dir = os.path.dirname(parent_dir)
    input_dir = os.path.join(parent_parent_dir, 'input')
    flying_dir = os.path.join(parent_parent_dir, 'flying')
    bifasico_dir = os.path.join(flying_dir, 'bifasico')
    utils_dir = os.path.join(parent_parent_dir, 'utils')
    processor_dir = os.path.join(parent_parent_dir, 'processor')

    os.chdir(input_dir)
    with open("inputs.yaml", 'r') as stream:
        data_loaded = yaml.load(stream)
        # data_loaded = yaml.load(stream, Loader=yaml.FullLoader)
        # data_loaded = yaml.full_load(stream)

    input_file = data_loaded['input_file']
    ext_h5m_adm = input_file + '_malha_adm.h5m'
    ADM = data_loaded['ADM']
    tempos_impr = data_loaded['tempos_vpi_impressao']
    contar_loop = data_loaded['contar_loop']
    contar_tempo = data_loaded['contar_tempo']
    imprimir_sempre = data_loaded['imprimir_sempre']

    mb = core.Core()
    mtu = topo_util.MeshTopoUtil(mb)
    os.chdir(flying_dir)
    mb.load_file(ext_h5m_adm)
    list_names_tags = np.load('list_names_tags.npy')
    # list_names_tags = np.delete(list_names_tags, np.where(list_names_tags == 'L_TOT')[0])
    # names_tags_with_level = np.load('names_tags_with_level.npy')
    tags_1 = get_all_tags_2(mb, list_names_tags)
    os.chdir(parent_dir)

    return mb, mtu, tags_1, input_file, ADM, tempos_impr, contar_loop, contar_tempo, imprimir_sempre
示例#12
0
    def __init__(self, mesh_file, dim=3):
        self.dimension = dim
        self.mb = core.Core()
        self.root_set = self.mb.get_root_set()
        self.mtu = topo_util.MeshTopoUtil(self.mb)

        self.mb.load_file(mesh_file)

        self.physical_tag = self.mb.tag_get_handle("MATERIAL_SET")
        self.physical_sets = self.mb.get_entities_by_type_and_tag(
            0, types.MBENTITYSET, np.array((self.physical_tag, )),
            np.array((None, )))

        self.dirichlet_tag = self.mb.tag_get_handle("Dirichlet", 1,
                                                    types.MB_TYPE_DOUBLE,
                                                    types.MB_TAG_SPARSE, True)

        self.neumann_tag = self.mb.tag_get_handle("Neumann", 1,
                                                  types.MB_TYPE_DOUBLE,
                                                  types.MB_TAG_SPARSE, True)

        #self.perm_tag = self.mb.tag_get_handle(
        #    "Permeability", 9, types.MB_TYPE_DOUBLE, types.MB_TAG_SPARSE, True)

        self.source_tag = self.mb.tag_get_handle("Source term", 1,
                                                 types.MB_TYPE_DOUBLE,
                                                 types.MB_TAG_SPARSE, True)

        self.all_volumes = self.mb.get_entities_by_dimension(0, self.dimension)

        self.all_nodes = self.mb.get_entities_by_dimension(0, 0)

        self.mtu.construct_aentities(self.all_nodes)
        self.all_faces = self.mb.get_entities_by_dimension(
            0, self.dimension - 1)

        self.dirichlet_faces = set()
        self.neumann_faces = set()
        self.mi = 1.0
        '''self.GLOBAL_ID_tag = self.mb.tag_get_handle(
            "Global_ID", 1, types.MB_TYPE_INTEGER, types.MB_TAG_DENSE, True)'''

        self.create_tags()
        self.mb.tag_set_data(self.ids_volumes_tag, self.all_volumes,
                             np.arange(len(self.all_volumes)))
        self.mb.tag_set_data(self.ids_faces_tag, self.all_faces,
                             np.arange(len(self.all_faces)))
        self.set_k()
        self.set_phi()
        # self.set_k_and_phi_structured_spe10()
        self.set_volumes()
        #self.set_information("PERM", self.all_volumes, 3)
        self.get_boundary_faces()
        self.set_vols_centroids()
        self.gravity = False
        self.gama = 10
        # self.set_keq_simple()
        self.set_keq_structured()
示例#13
0
    def __init__(self, mesh_file, dim=2):
        self.dimension = dim
        self.mb = core.Core()
        self.root_set = self.mb.get_root_set()
        self.mtu = topo_util.MeshTopoUtil(self.mb)

        self.mb.load_file(mesh_file)

        self.physical_tag = self.mb.tag_get_handle("MATERIAL_SET")
        self.physical_sets = self.mb.get_entities_by_type_and_tag(
            0, types.MBENTITYSET, np.array((self.physical_tag, )),
            np.array((None, )))

        self.dirichlet_tag = self.mb.tag_get_handle("Dirichlet", 1,
                                                    types.MB_TYPE_DOUBLE,
                                                    types.MB_TAG_SPARSE, True)

        self.neumann_tag = self.mb.tag_get_handle("Neumann", 1,
                                                  types.MB_TYPE_DOUBLE,
                                                  types.MB_TAG_SPARSE, True)

        #self.perm_tag = self.mb.tag_get_handle(
        #    "Permeability", 9, types.MB_TYPE_DOUBLE, types.MB_TAG_SPARSE, True)

        self.source_tag = self.mb.tag_get_handle("Source term", 1,
                                                 types.MB_TYPE_DOUBLE,
                                                 types.MB_TAG_SPARSE, True)

        self.all_volumes = self.mb.get_entities_by_dimension(0, self.dimension)
        self.all_nodes = self.mb.get_entities_by_dimension(0, 0)

        self.mtu.construct_aentities(self.all_nodes)
        self.all_faces = self.mb.get_entities_by_dimension(
            0, self.dimension - 1
        )  #ADJs=np.array([M1.mb.get_adjacencies(face, 3) for face in M1.all_faces])

        self.all_edges = self.mb.get_entities_by_dimension(0, 1)
        self.dirichlet_faces = set()
        self.neumann_faces = set()
        '''self.GLOBAL_ID_tag = self.mb.tag_get_handle(
            "Global_ID", 1, types.MB_TYPE_INTEGER, types.MB_TAG_DENSE, True)'''

        self.create_tags()
        #self.set_k_and_phi_structured_spe10()
        #self.set_information("PERM", self.all_volumes, 3)
        #self.get_boundary_faces()
        self.gravity = False
        self.gama = 10
        self.mi = 1
        t0 = time.time()
        # print('set area')
        #self.get_kequiv_by_face_quad(self.all_faces)
        '''
        print('set area')
        for f in self.all_faces:
            self.set_area(f)'''
        # print("took",time.time()-t0)
        self.get_faces_boundary
示例#14
0
    def __init__(self, mb=None, mtu=None):
        if mb == None:
            raise RuntimeError('Defina o mb core do pymoab')
        if mtu == None:
            raise RuntimeError('Defina o mtu do pymoab')

        self.list_tags = [mb.tag_get_handle(name) for name in OtherUtils.list_names_tags]
        self.mb = mb
        self.mtu = topo_util.MeshTopoUtil(mb)
示例#15
0
    def __init__(self, mesh_file):

        self.mesh_file = mesh_file
        self.mb = core.Core()
        self.root_set = self.mb.get_root_set()
        self.mtu = topo_util.MeshTopoUtil(self.mb)
        self.material_set_tag = self.mb.tag_get_handle("MATERIAL_SET", 1,
                                                       types.MB_TYPE_INTEGER,
                                                       types.MB_TAG_SPARSE,
                                                       True)
示例#16
0
文件: pymoab_utils.py 项目: jpra2/MAD
    def get_all_entities(mb):
        mtu = topo_util.MeshTopoUtil(mb)
        root_set = mb.get_root_set()
        all_volumes = mb.get_entities_by_dimension(0, 3)
        all_nodes = mb.get_entities_by_dimension(0, 0)
        mtu.construct_aentities(all_nodes)
        all_faces = mb.get_entities_by_dimension(0, 2)
        all_edges = mb.get_entities_by_dimension(0, 1)

        return [all_nodes, all_edges, all_faces, all_volumes]
示例#17
0
 def __init__(self):
     self.mb = core.Core()
     self.root_set = self.mb.get_root_set()
     self.mtu = topo_util.MeshTopoUtil(self.mb)
     self.dimension = 3
     self.tags = dict()
     self.datas = dict()
     self.excluir = []
     self.n_levels = 2
     with open("inputs.yaml", 'r') as stream:
         data_loaded = yaml.load(stream)
     self.data_loaded = data_loaded
示例#18
0
    def __init__(self, mb=None, comm=None):
        if mb == None:
            raise RuntimeError('Defina o mb core do pymoab')
        elif comm == None:
            raise RuntimeError('Defina o comm do trilinos')

        self.list_tags = [
            mb.tag_get_handle(name) for name in OtherUtils.list_names_tags
        ]
        self.mb = mb
        self.comm = comm
        self.mtu = topo_util.MeshTopoUtil(mb)
        self.gravity = True
示例#19
0
    def __init__(self, inputfile):

        self.comm = Epetra.PyComm()
        self.mb = core.Core()
        self.mb.load_file(inputfile)
        self.mtu = topo_util.MeshTopoUtil(self.mb)
        self.root_set = self.mb.get_root_set()
        self.all_volumes = self.mb.get_entities_by_dimension(self.root_set, 3)
        self.all_faces = self.mb.get_entities_by_dimension(self.root_set, 2)
        self.nf = len(self.all_volumes)
        self.create_tags()
        self.create_elems_wirebasket()
        self.map_wirebasket = dict(zip(self.elems_wirebasket, range(self.nf)))
        self.get_wells()
        self.primals1 = self.mb.get_entities_by_type_and_tag(
            self.root_set, types.MBENTITYSET,
            np.array([self.prilmal_ids1_tag]), np.array([None]))
        self.nc1 = len(self.primals1)
        self.primals2 = self.mb.get_entities_by_type_and_tag(
            self.root_set, types.MBENTITYSET,
            np.array([self.prilmal_ids2_tag]), np.array([None]))

        all_gids = self.mb.tag_get_data(self.global_id0_tag,
                                        self.all_volumes,
                                        flat=True)
        minim = min(all_gids)
        all_gids = all_gids - minim
        self.mb.tag_set_data(self.global_id0_tag, self.all_volumes, all_gids)

        ids_nv1 = self.mb.tag_get_data(self.L1_tag,
                                       self.all_volumes,
                                       flat=True)
        ids_nv1 -= 1
        self.mb.tag_set_data(self.L1_tag, self.all_volumes, ids_nv1)

        Lx = 27
        Ly = 27
        Lz = 9

        self.tz = Lz
        self.gama = 10.0
        self.mi = 1.0

        l1 = 3
        l2 = 9

        nc1 = Lx * Ly * Lz / (l1**3)
        nc2 = Lx * Ly * Lz / (l2**3)

        self.run()
示例#20
0
def test_get_bridge_adjacencies():
    mb = core.Core()

    coords = np.array((0, 0, 0, 1, 0, 0, 1, 1, 1), dtype='float64')
    verts = mb.create_vertices(coords)
    verts = np.array(((verts[0], verts[1], verts[2]), ), dtype='uint64')
    tris = mb.create_elements(types.MBTRI, verts)

    mtu = topo_util.MeshTopoUtil(mb)

    rs = mb.get_root_set()
    tris = mb.get_entities_by_dimension(rs, 2)
    adj_verts = mtu.get_bridge_adjacencies(tris, 0, 0, 1)

    assert (adj_verts == verts).all()
示例#21
0
def test_get_average_position():
    mb = core.Core()

    coords = np.array((0, 0, 0, 1, 0, 0, 1, 1, 1), dtype='float64')
    verts = mb.create_vertices(coords)
    verts = np.array(((verts[0], verts[1], verts[2]), ), dtype='uint64')
    tris = mb.create_elements(types.MBTRI, verts)

    mtu = topo_util.MeshTopoUtil(mb)

    rs = mb.get_root_set()
    tris = mb.get_entities_by_dimension(rs, 2)
    avg_pos = mtu.get_average_position(tris)

    np.testing.assert_almost_equal(avg_pos, coords.reshape(3, 3).mean(axis=0))
示例#22
0
文件: define_wells.py 项目: jpra2/MAD
    def set_dirichlet(mb, volumes, value, gravity, gama=None, Lz=None):
        mtu = topo_util.MeshTopoUtil(mb)
        cents = np.array([mtu.get_average_position([v]) for v in volumes])
        if gravity == False:
            pressao = np.repeat(value, len(volumes))

        elif gravity == True:
            z_elems_d = -1*cents[:,2]
            delta_z = z_elems_d + Lz
            pressao = gama*(delta_z) + value
        ###############################################
        else:
            print("Defina se existe gravidade (True) ou nao (False)")

        DefineWells.mb.tag_set_data(DefineWells.dirichlet_tag, volumes, pressao)
示例#23
0
    def __init__(self, mb, physical):
        self.physical_manager = physical
        self.moab = mb
        self.tag2entset = {}
        self.id_map = {}
        self.mesh_topo_util = topo_util.MeshTopoUtil(mb)
        self.meshsets = {'ROOT': mb.get_root_set()}
        self.tags = {}

        self.ran_kernels = set()

        self.matrix_manager = MatrixManager()

        self._save_tags()
        self._save_physical_tags()
        self._generate_dense_elements()
        self._create_matrix_maps()
        self._create_id_maps()
示例#24
0
def test_construct_aentities():
    mb = core.Core()

    coords = np.array((0, 0, 0, 1, 0, 0, 1, 1, 1), dtype='float64')
    verts = mb.create_vertices(coords)
    verts_array = np.array(((verts[0], verts[1], verts[2]), ), dtype='uint64')
    mb.create_elements(types.MBTRI, verts_array)

    mtu = topo_util.MeshTopoUtil(mb)

    edges_before = mb.get_entities_by_dimension(0, 1)

    mtu.construct_aentities(verts)

    edges_after = mb.get_entities_by_dimension(0, 1)

    assert edges_before != edges_after
    assert len(edges_after) == 3
示例#25
0
 def __init__(self, mesh_file):
     self.mb = core.Core()
     self.mtu = topo_util.MeshTopoUtil(self.mb)
     self.mb.load_file(mesh_file)
     self.all_nodes, self.all_edges, self.all_faces, self.all_volumes = utpy.get_all_entities(
         self.mb)
     self.tags = LoadMesh.load_tags(self.mb)
     self.matrices = LoadMesh.load_matrices()
     self.ADJs = np.array(
         [self.mb.get_adjacencies(face, 3) for face in self.all_faces])
     self.all_centroids = np.array(
         [self.mtu.get_average_position([v]) for v in self.all_volumes])
     self.wirebasket_elems, self.wirebasket_numbers, self.mv = LoadMesh.load_wirebasket_elems(
         self.mb, self.tags)
     self.meshset_levels, self.L2_meshset = LoadMesh.load_meshsets_level(
         self.mb, self.tags)
     self.all_boundary_faces = LoadMesh.load_all_bound_faces(
         self.mb, self.tags)
    def __init__(self, mesh_file, dim=3):
        self.dimension = dim
        self.mb = core.Core()
        self.root_set = self.mb.get_root_set()
        self.mtu = topo_util.MeshTopoUtil(self.mb)

        self.mb.load_file(mesh_file)

        self.physical_tag = self.mb.tag_get_handle("MATERIAL_SET")
        self.physical_sets = self.mb.get_entities_by_type_and_tag(
            0, types.MBENTITYSET, np.array((self.physical_tag, )),
            np.array((None, )))

        self.dirichlet_tag = self.mb.tag_get_handle("Dirichlet", 1,
                                                    types.MB_TYPE_DOUBLE,
                                                    types.MB_TAG_SPARSE, True)

        self.neumann_tag = self.mb.tag_get_handle("Neumann", 1,
                                                  types.MB_TYPE_DOUBLE,
                                                  types.MB_TAG_SPARSE, True)

        self.perm_tag = self.mb.tag_get_handle("Permeability", 9,
                                               types.MB_TYPE_DOUBLE,
                                               types.MB_TAG_SPARSE, True)

        self.source_tag = self.mb.tag_get_handle("Source term", 1,
                                                 types.MB_TYPE_DOUBLE,
                                                 types.MB_TAG_SPARSE, True)

        self.all_volumes = self.mb.get_entities_by_dimension(0, self.dimension)

        self.all_nodes = self.mb.get_entities_by_dimension(0, 0)

        self.mtu.construct_aentities(self.all_nodes)
        self.all_faces = self.mb.get_entities_by_dimension(
            0, self.dimension - 1)

        self.dirichlet_faces = set()
        self.neumann_faces = set()
        '''self.GLOBAL_ID_tag = self.mb.tag_get_handle(
            "Global_ID", 1, types.MB_TYPE_INTEGER, types.MB_TAG_DENSE, True)'''

        self.create_tags()
        self.get_faces_boundary()
示例#27
0
 def __init__(self, coords, elements, neighbors, center):
     self.mb = core.Core()
     self.mtu = topo_util.MeshTopoUtil(self.mb)
     skin = sk.Skinner(self.mb)
     verts = self.mb.create_vertices(coords)
     import pdb; pdb.set_trace()
     rs = self.mb.get_root_set()
     #import pdb; pdb.set_trace()
     #import pdb; pdb.set_trace()
     import pdb; pdb.set_trace()
     elements = elements + np.ones(elements.shape)
     tag_handle = self.mb.tag_get_handle("Teste", 1, types.MB_TYPE_INTEGER, types.MB_TAG_DENSE, create_if_missing = True)
     for el in elements:
         tetra = self.mb.create_element(types.MBTET, el.ravel().astype("uint64"))
     #self.mtu.construct_aentities(verts)
     elements = self.mb.get_entities_by_dimension(0, 3)
     for index,el in enumerate(elements):
         self.mb.tag_set_data(tag_handle,el,index)
     self.mb.write_file("delaunayVIEW.vtk")
示例#28
0
def carregar_dados_anterior(data_loaded, loop):

    from utils import pymoab_utils as utpy

    parent_dir = os.path.dirname(os.path.abspath(__file__))
    parent_parent_dir = os.path.dirname(parent_dir)
    input_dir = os.path.join(parent_parent_dir, 'input')
    flying_dir = os.path.join(parent_parent_dir, 'flying')
    bifasico_dir = os.path.join(flying_dir, 'bifasico')
    bifasico_sol_direta_dir = os.path.join(bifasico_dir, 'sol_direta')
    bifasico_sol_multiescala_dir = os.path.join(bifasico_dir, 'sol_multiescala')
    utils_dir = os.path.join(parent_parent_dir, 'utils')

    ADM = data_loaded['ADM']
    input_file = data_loaded['input_file']

    if ADM:
        caminho = bifasico_sol_multiescala_dir
        ext_h5m = input_file + 'sol_multiescala_' + str(loop) + '.h5m'
    else:
        caminho = bifasico_sol_direta_dir
        ext_h5m = input_file + 'sol_direta_' + str(loop) + '.h5m'

    os.chdir(caminho)
    mb = core.Core()
    mtu = topo_util.MeshTopoUtil(mb)
    mb.load_file(ext_h5m)
    name_historico = 'historico_' + str(loop) + '.npy'
    historico = np.load(name_historico)
    t_loop = historico[1]
    vpi = historico[0]

    os.chdir(flying_dir)
    list_names_tags = np.load('list_names_tags.npy')
    tags_1 = utpy.get_all_tags_2(mb, list_names_tags)
    tempos_impr = data_loaded['tempos_vpi_impressao']
    contar_loop = data_loaded['contar_loop']
    contar_tempo = data_loaded['contar_tempo']
    imprimir_sempre = data_loaded['imprimir_sempre']
    all_nodes, all_edges, all_faces, all_volumes = utpy.get_all_entities(mb)

    return mb, mtu, tags_1, input_file, ADM, tempos_impr, contar_loop, contar_tempo, imprimir_sempre, all_nodes, all_edges, all_faces, all_volumes, t_loop, vpi
示例#29
0
 def __init__(self, mesh_file):
     self.mesh_file = mesh_file
     self.mb = core.Core()
     self.mb.load_file(mesh_file)
     self.mtu = topo_util.MeshTopoUtil(self.mb)
     self.dirichlet_tag = self.mb.tag_get_handle("DIRICHLET", 1,
                                                 types.MB_TYPE_DOUBLE,
                                                 types.MB_TAG_SPARSE, True)
     self.neumann_tag = self.mb.tag_get_handle("NEUMANN", 1,
                                               types.MB_TYPE_DOUBLE,
                                               types.MB_TAG_SPARSE, True)
     self.permeability_tag = self.mb.tag_get_handle("PERMEABILITY", 9,
                                                    types.MB_TYPE_DOUBLE,
                                                    types.MB_TAG_SPARSE,
                                                    True)
     self.source_tag = self.mb.tag_get_handle("SOURCE", 1,
                                              types.MB_TYPE_DOUBLE,
                                              types.MB_TAG_SPARSE, True)
     self.centroid_tag = self.mb.tag_get_handle("CENTROID", 3,
                                                types.MB_TYPE_DOUBLE,
                                                types.MB_TAG_SPARSE, True)
示例#30
0
    def __init__(self):
        global input_dir
        global flying_dir
        global bifasico_sol_direta_dir
        global bifasico_sol_multiescala_dir
        os.chdir(input_dir)
        with open("inputs.yaml", 'r') as stream:
            data_loaded = yaml.load(stream)
            # data_loaded = yaml.load(stream, Loader=yaml.FullLoader)
            # data_loaded = yaml.full_load(stream)

        input_file = data_loaded['input_file']
        self.input_file = input_file
        ext_h5m_adm = input_file + '_malha_adm.h5m'

        self.mb = core.Core()
        self.mtu = topo_util.MeshTopoUtil(self.mb)
        self.data_loaded = data_loaded
        converter_unidades = data_loaded['converter_unidades']
        ADM = data_loaded['ADM']
        ler_anterior = np.load('ler_anterior.npy')[0]
        self.ler_anterior = ler_anterior
        if ler_anterior == False:
            os.chdir(flying_dir)
            self.mb.load_file(ext_h5m_adm)
            self.ultimo_loop = 0
            self.vpi = 0.0
            self.t = 0.0

        else:
            os.chdir(input_dir)
            ultimo_loop = np.load('ultimo_loop.npy')[0]
            self.ultimo_loop = ultimo_loop
            if ADM == False:
                ext_h5m = input_file + 'sol_direta_' + str(
                    ultimo_loop) + '.h5m'
                os.chdir(bifasico_sol_direta_dir)
                self.mb.load_file(ext_h5m)
            else:
                ext_h5m = input_file + 'sol_direta_' + str(
                    ultimo_loop) + '.h5m'
                os.chdir(bifasico_sol_direta_dir)
                self.mb.load_file(ext_h5m)
            hist = np.load('historico_' + str(ultimo_loop) + '.npy')
            self.vpi = hist[0]
            self.t = hist[1]

        self.all_volumes = self.mb.get_entities_by_dimension(0, 3)
        self.all_nodes = self.mb.get_entities_by_dimension(0, 0)
        self.mtu.construct_aentities(self.all_nodes)
        self.all_faces = self.mb.get_entities_by_dimension(0, 2)
        self.all_edges = self.mb.get_entities_by_dimension(0, 1)
        self.tags = LoadADMMesh.load_tags(self.mb)
        self.tags.update(
            LoadADMMesh.create_tags_bifasico(self.mb, ADM, self.all_nodes))

        self.volumes_d = self.mb.get_entities_by_type_and_tag(
            0, types.MBHEX, np.array([self.tags['P']]), np.array([None]))
        self.volumes_n = self.mb.get_entities_by_type_and_tag(
            0, types.MBHEX, np.array([self.tags['Q']]), np.array([None]))

        self.mi_w = float(data_loaded['dados_bifasico']['mi_w'])
        self.mi_o = float(data_loaded['dados_bifasico']['mi_o'])
        self.gama_w = float(data_loaded['dados_bifasico']['gama_w'])
        self.gama_o = float(data_loaded['dados_bifasico']['gama_o'])
        self.Sor = float(data_loaded['dados_bifasico']['Sor'])
        self.Swc = float(data_loaded['dados_bifasico']['Swc'])
        self.nw = float(data_loaded['dados_bifasico']['nwater'])
        self.no = float(data_loaded['dados_bifasico']['noil'])
        self.loops = int(data_loaded['dados_bifasico']['loops'])
        self.total_time = float(data_loaded['dados_bifasico']['total_time'])
        self.gravity = data_loaded['gravity']

        if not ler_anterior and converter_unidades:
            setinfo.convert_to_SI(self.mb, self.tags, self.all_volumes,
                                  self.all_faces, self.all_nodes,
                                  self.volumes_d, self.volumes_n)

        if ADM:
            self.internos, self.faces, self.arestas, self.vertices, \
            self.wirebasket_elems, self.mv, self.bound_faces_nv, \
            self.wirebasket_numbers, self.meshsets_levels, self.finos0, self.intermediarios, \
            self.L2_meshset, self.faces_adjs_by_dual, self.intern_adjs_by_dual = LoadADMMesh.load_elems_adm(self.mb, self.tags)

        self.wirebasket_elems_nv1 = LoadADMMesh.load_wirebasket_elems_nv1(
            self.mb, self.tags)

        if len(self.volumes_n) == 0:
            self.wells_injector, self.wells_producer = setinfo.injector_producer_press(
                self.mb, self.gama_w, self.gama_o, self.gravity,
                self.all_nodes, self.volumes_d, self.tags)

        else:
            self.wells_injector, self.wells_producer = setinfo.injector_producer(
                self.mb, self.gama_w, self.gama_o, self.gravity,
                self.all_nodes, self.volumes_d, self.volumes_n, self.tags)

        self.all_boundary_faces = self.mb.get_entities_by_handle(
            self.mb.tag_get_data(self.tags['FACES_BOUNDARY'], 0, flat=True)[0])
        self.all_faces_in = rng.subtract(self.all_faces,
                                         self.all_boundary_faces)
        self.Adjs = np.array([
            np.array(self.mb.get_adjacencies(f, 3)) for f in self.all_faces_in
        ])
        self.all_centroids = self.mb.tag_get_data(self.tags['CENT'],
                                                  self.all_volumes)
        self.all_kharm = self.mb.tag_get_data(self.tags['KHARM'],
                                              self.all_faces_in,
                                              flat=True)
        self.ADM = ADM
        self.vv = self.mb.create_meshset()
        self.mb.add_entities(self.vv, self.all_volumes)

        if not ler_anterior:
            LoadADMMesh.set_sat_in(self.mb, self.wells_injector,
                                   self.all_volumes, self.tags,
                                   self.all_centroids)