Esempio n. 1
0
 def setup(self):
     CHECK (self.mgr().db() != None) #, EXCEPTION_NULL_PTR,;);
     top = "algorithms/elasticity/" + self.name()
     #print(top)
     # construct the gsubmesh list        
     gsubmesh_names = self.mgr().db().DB_GET_STRING_LIST(top+"/gsubmeshes")
     for gsm in gsubmesh_names:
         gsubmesh = self._gmesh.find_gsubmesh(gsm)
         CHECK(gsubmesh is not None) #, EXCEPTION_NULL_PTR,;);
         self._gsubmeshes.append(gsubmesh);
 
     # create the geometry field
     zero = FIXED_VECTOR(3)
     geom_bfun_set = BFUN_SET.make(self._algo_refine.refinement_strategy(),self._gmesh)
     #print ( "geom_bfun_set._nbfuns_active = %d\n" % geom_bfun_set._nbfuns_active )
     #print ( "geom_bfun_set._nbfuns_total = %d\n" % geom_bfun_set._nbfuns_total )
     
     #nbfuns = len(geom_bfun_set._bfuns)
     #print("nbfuns=%d\n"%nbfuns)
     #for i in range(0,nbfuns):
     #    print(geom_bfun_set._bfuns[i])
     #print("nbfuns=%d\n"%nbfuns)
     #print ( geom_bfun_set._bfuns[0]._gcells )
     #for i in range(0,geom_bfun_set._nbfuns_active): #self._nbfuns_total
     #    print("fen_label = %d, no. of gcells = %d"%(geom_bfun_set._bfuns[i]._fen._id,len(geom_bfun_set._bfuns[i]._gcells)))
     
     #    #print("%d, nbfuns = %d\n"%(i,len(bfuns.)))
     #print(geom_bfun_set._bfun_dofparam_ids)
     
     self._geometry = FIELD_VECTOR("geometry",geom_bfun_set,zero)
     
     raise NotImplementedError
Esempio n. 2
0
 def read_gcell_file (self,file):
     
     read_gcell_flag = False
     
     content=[]
     with open(file,'r') as f:
         for line in f:
             content.append(line)
         
     for eid,line in enumerate(content):
         line = line.strip().split()
         
         fens = []
         for id in line:
             id = int(id)
             fen = self._gsubmesh.gmesh().find_fen(id)
             if fen is None:
                 print("Node " + str(id) + " not found\n")
                 CHECK (fen is not None) #, EXCEPTION_NULL_PTR,;);
             fens.append(fen)
     
         gcell = GCELL.make_gcell(self._gcell_type, "default", fens)
         if (gcell is None):
             print("While reading \"" + file + "\": making " + str(self._gcell_type))
             CHECK (gcell is not None)#, EXCEPTION_NULL_PTR,;);
         
         gcell.set_id(eid+1)
         self.add(gcell)
 
     read_gcell_flag = True
     return read_gcell_flag 
Esempio n. 3
0
 def __init__(self,db):
     self._db = db
     CHECK (self._db != None ) # , EXCEPTION_NULL_PTR,;);
     self._instance_count += 1
     CHECK (self._instance_count == 1) #, EXCEPTION_ILLEGAL_USE,;);
     
     self._mesh_mgr = MESH_MGR(self)
     self._mat_mgr  = MAT_MGR(self)
     self._load_mgr = LOAD_MGR(self)
Esempio n. 4
0
    def get_ref_fen(self, conn, ref_fens, indx):
        CHECK(len(ref_fens) == 1)
        CHECK(conn.manifold_dim() == self.manifold_dim())
        CHECK(conn.nfens() == self.nfens())
        CHECK(indx == 0)

        if (conn.fen(0) == self.fen(0)):
            return ref_fens[0]
        else:
            return 0
Esempio n. 5
0
 def dofparam_id(self,*args):
     
     #print("in dofparam_id, args is: ", end='')
     #print(args,end='')
     if isinstance( args[0], BFUN ):
         #print(". It is an BFUN, fen label = ",end='')
         bfun = args[0]
         #print(bfun._fen.id())
         CHECK (bfun.bfun_set() == self) #, EXCEPTION_BAD_ACCESS,;);
         
         if ( bfun.is_active() is not True ):
             return INVALID_BFUN_DOFPARAM_PAIR_ID # RAW
         else:
             return self.dofparam_id( bfun.fen() )
     
     elif isinstance( args[0], FEN ):
         #print(". It is an FEN, fen label = ",end='')
         fen = args[0]
         #print(fen.id())
         if ( fen.uniqobjid() >= len( self._bfun_dofparam_ids ) ):
             #print("fen.uniqobjid() >= len( self._bfun_dofparam_ids )\n" )
             #raise Exception
             #return sys.maxsize 
             return INVALID_BFUN_DOFPARAM_PAIR_ID
         else:
             return self._bfun_dofparam_ids[ fen.uniqobjid() ]
         
     else:
         print("Error, args is: ",end='')
         print(args)
         raise NotImplementedError            
Esempio n. 6
0
 def gmesh(self,name):
     if ( name in self._mesh_map ):
         return self._mesh_map[name]
     else:            
         gmesh = GMESH(name,self._mgr.db())
         CHECK(gmesh != None) # , EXCEPTION_NULL_PTR,;);
         self._mesh_map[name] = gmesh
         return gmesh
Esempio n. 7
0
    def build_gcell_to_bfun_dofparam_id_map(self):
        _M = self._gcell_to_bfun_dofparam_id_map
        _M = {}
        # Add empty lists to the map for all gcells active in the field
        #print(self._pairs)

        for j in range(0, len(self._pairs)):
            bfun = self._pairs[j].bfun()
            for k in range(0, bfun.ngcells()):
                if (bfun.gcell(k) not in _M):
                    _M[bfun.gcell(k)] = set()  # empty set

        # Now for each pair ...
        for j in range(0, len(self._pairs)):
            pair = self._pairs[j]
            bfun = pair.bfun()
            for k in range(0, bfun.ngcells()):  # ... loop over its cells
                gcell = bfun.gcell(k)
                CHECK(gcell in _M)  #, EXCEPTION_BAD_ACCESS,;);

                # ------------------------------------
                # First propagate your influence to
                # your ancestors
                # ------------------------------------
                parent = gcell.parent()

                while (parent is not None):

                    if (parent in _M):
                        _M[parent].add(j)

                    parent = parent.parent()

                # end while

                # ------------------------------------
                # Now for yourself and your children
                # ------------------------------------
                s = []
                s.append(gcell)  # push
                while (len(s) != 0):

                    agcell = s[-1]  # top element

                    s.pop()  #  working on this gcell

                    if (agcell in _M):  # This cell is active in the field
                        _M[agcell].add(j)

                    # end if

                    # work on the children too
                    for l in range(0, agcell.nchildren()):

                        s.append(agcell.child(l))
Esempio n. 8
0
 def __init__(self,fens):   
     GCELL.__init__(self)
     self._conn   = CONN_SOLID_8()
     
     self._conn._fens = fens
     
     CHECK( len(fens) == self._conn.nfens() )
     self.TYPE_NAME = "solid_h8"
     
     self._parent = None
     self._child  = []
Esempio n. 9
0
    def add (self,bfun):
        CHECK (self._in_constructor == True) #,EXCEPTION_ILLEGAL_USE,;); //RAW : now we are adding bfun in clone 
        CHECK(bfun.bfun_set() == self)#, EXCEPTION_ILLEGAL_USE,;);
        #print('In ADD\n')
        if (not self.is_present(bfun)):
            
            self.insert_bfun(bfun)
            
            if ( bfun.is_active() ): # if basis function has to be  active. 
     
               if ( not self.in_active_set(bfun) ): # but it was grouped among inactive
                    self.swap( self.dofparam_id( bfun.fen() ),self._nbfuns_active)
                    self._nbfuns_active += 1


            else: # if a basis function has to be inactive 
                
                if ( self.in_active_set(bfun) ): # but it was grouped among actives 
                   self.swap( self.dofparam_id(bfun.fen()), self._nbfuns_active-1)
                   self._nbfuns_active -= 1
Esempio n. 10
0
    def __init__(self, name, db):
        self._name = name
        self._fens = []
        self._gsubmeshes = []
        self._fen_map = {}
        self._max_fen_id = 0

        # FEN
        fens_param = db.DB_GET_STRING('algorithms/gmeshes/' + self._name +
                                      '/fen_file')
        CHECK(fens_param != None)  #, EXCEPTION_BAD_VALUE,;);
        CHECK(self.read_fens(fens_param))  #, EXCEPTION_BAD_VALUE,;);

        # GSUBMESH
        path = "algorithms/gmeshes/" + self._name + "/gsubmeshes"
        gsubmeshes_list = db.DB_GET_STRING_LIST(path)

        CHECK(len(gsubmeshes_list) != 0)  #, EXCEPTION_BAD_VALUE,;);
        for gsm in gsubmeshes_list:
            gsubmesh = GSUBMESH(gsm, db, self)
            self._gsubmeshes.append(gsubmesh)
Esempio n. 11
0
    def __init__(self, name, db, gmesh):
        self._name = name
        self._gcell_groups = []
        self._gmesh = gmesh

        # GCELL_GROUP
        path = "algorithms/gsubmeshes/" + self._name + "/gcell_groups"
        gcell_group_list = db.DB_GET_STRING_LIST(path)
        CHECK(len(gcell_group_list) != 0)  # EXCEPTION_BAD_VALUE,;);
        for gg_name in gcell_group_list:
            gcell_group = GCELL_GROUP(gg_name, db, self)
            self._gcell_groups.append(gcell_group)
Esempio n. 12
0
 def __init__(self,name,db,gsubmesh):
     self._name       = name
     self._gsubmesh   = gsubmesh
     self._gcell_type = ""
     self._gcells = []
     
     # type
     path = "algorithms/gcell_groups/" + self._name + "/type"
     self._gcell_type = db.DB_GET_STRING(path)
     #print(self._gcell_type)
     
     # conn_file
     path = "algorithms/gcell_groups/" + self._name + "/conn_file"
     gcell_file = db.DB_GET_STRING (path)
     CHECK(self.read_gcell_file(gcell_file))#, EXCEPTION_BAD_VALUE ,;);
Esempio n. 13
0
 def __init__(self, name, mgr ):
     
     ALGO.__init__(self, name, mgr)
     
     CHECK (self.mgr().db() != None) #, EXCEPTION_NULL_PTR,;);        
     
     self._gmesh       = None        
     top = 'algorithms/elasticity/' + self.name()
     gmesh_name = self.mgr().db().DB_GET_STRING(top + '/gmesh')
     #print(gmesh_name)
     self._gmesh = self.mgr().mesh_mgr().gmesh(gmesh_name)
     
     self._gsubmeshes  = []
     
     self._algo_refine = ALGO_REFINE(name, mgr, self._gmesh)
     self._geometry    = None
     self._u           = None
     self._ebc         = None
     self._algo_errest = None
Esempio n. 14
0
 def map_to_parent(self,param_loc, refparent, parent_param_loc):
     
     CHECK( isinstance(refparent,list) == True )
     
     if ( self._parent is not None ):
         
         xi = param_loc(0)
         eta = param_loc(1)
         theta = param_loc(2)
         
         for j in range(0,GCELL_SOLID_H8.NCHILDREN):
             
             if ( self == self._parent.child(j)):                
                 LO = 0
                 HI = 1
                 parent_param_loc[0] = (1 -    xi) / 2 * self._child_map[j][LO][0] + (1 +    xi) / 2 * self._child_map[j][HI][0]
                 parent_param_loc[1] = (1 -   eta) / 2 * self._child_map[j][LO][1] + (1 +   eta) / 2 * self._child_map[j][HI][1]
                 parent_param_loc[2] = (1 - theta) / 2 * self._child_map[j][LO][2] + (1 + theta) / 2 * self._child_map[j][HI][2]
                 refparent[0] = self._parent
                 return True
         
         # end loop
         
         return False # found no parent
Esempio n. 15
0
 def set_id(self,id):
     CHECK (self._id == None) #,EXCEPTION_ILLEGAL_USE,;);
     self._id = id
Esempio n. 16
0
 def __init__(self,mgr):
     self._mgr = mgr
     CHECK (self._mgr != None ) # , EXCEPTION_NULL_PTR,;);
     self._instance_count += 1
     CHECK (self._instance_count == 1) #, EXCEPTION_ILLEGAL_USE,;);
     self._mesh_map = {}
Esempio n. 17
0
 def bfun(self, dofparam_id):
     CHECK(dofparam_id !=
           INVALID_BFUN_DOFPARAM_PAIR_ID)  #, EXCEPTION_BAD_ACCESS,;);
     return self._pairs[dofparam_id].bfun()
Esempio n. 18
0
 def __init__(self,refinement_strategy,*args):
     
     if ( len(args) == 0 ):
         #print('zero args')
         self._in_constructor = True
         self._refinement_strategy = refinement_strategy
         self._gmesh      = None
         self._gsubmeshes = []
         self._bfuns      = []
         self._nbfuns_active     = 0
         self._nbfuns_total      = 0
         self._bfun_dofparam_ids = []
         self._in_constructor    = False
         self._mem_raise_size = 10
         
         if BFUN_SET.USE_PU:
             self._is_pu = False
     
     elif isinstance( args[0], GSUBMESH ):
         #print('gsubmesh args')
         
         gsubmeshes = args[0]
         
         self._mem_raise_size = 10
         self._in_constructor = True
         self._refinement_strategy = refinement_strategy
         
         self._gsubmeshes = []
         for gsm in gsubmeshes:
             CHECK (gsm is not None) #, EXCEPTION_NULL_PTR,;);
             self._gsubmeshes.append(gsm)
             
         self._gmesh = self._gsubmeshes[0].gmesh() # `local' field: constructed from submeshes
         self._bfuns         = []
         self._nbfuns_active = 0
         self._nbfuns_total  = 0
         self._bfun_dofparam_ids = []
         
         igcells = self.build_gcell_list()
         CHECK (len(igcells) != 0 ) #, EXCEPTION_BAD_VALUE,;);
         self.build_from_gcells (igcells, 0)
         
         if BFUN_SET.USE_PU:
             self._is_pu = False
         
         self._in_constructor = False
         
         
     elif isinstance( args[0], GMESH ):
         #print('gmesh args')
         
         gmesh = args[0]
         
         self._mem_raise_size = 10
         self._in_constructor = True
         self._refinement_strategy = refinement_strategy
                     
         self._gmesh = gmesh #  // `global' field: constructed from the mesh
         self._gsubmeshes = []
         
         for gsm in gmesh._gsubmeshes:
             self._gsubmeshes.append(gsm)
             
         self._bfuns         = []
         self._nbfuns_active = 0
         self._nbfuns_total  = 0
         self._bfun_dofparam_ids = []
         
         igcells = self.build_gcell_list()
         CHECK (len(igcells) != 0 ) #, EXCEPTION_BAD_VALUE,;);
         self.build_from_gcells(igcells, 0)
         
         if BFUN_SET.USE_PU:
             self._is_pu = False
         
         self._in_constructor = False
         
     else:
         raise NotImplementedError
Esempio n. 19
0
    def map_to_child(self, param_loc, refchild, child_param_loc):
        
        CHECK( isinstance(refchild,list) == True )
        # note: 
        #  only child_param_loc is modified
        #  refchild is NOT modified !!!!!!!!!!!!!!!
        # but refchild[0] is
        
        
        if (self.nchildren() == 0):
            return False

        xi    = param_loc(0)
        eta   = param_loc(1)
        theta = param_loc(2)        
        
        if (xi < 0):
            
            if (eta < 0):
                if (theta < 0):
                    refchild[0] = self._child[0]
                    child_param_loc[0] = 2 * xi    + 1
                    child_param_loc[1] = 2 * eta   + 1
                    child_param_loc[2] = 2 * theta + 1
                else:
                    refchild[0] = self._child[4]
                    child_param_loc[0] = 2 * xi    + 1
                    child_param_loc[1] = 2 * eta   + 1
                    child_param_loc[2] = 2 * theta - 1
            
            else: # if eta > 0
                
                if (theta < 0):
                    refchild[0] = self._child[3]
                    child_param_loc[0] = 2 * xi    + 1
                    child_param_loc[1] = 2 * eta   - 1
                    child_param_loc[2] = 2 * theta + 1
                else:
                    refchild[0] = self._child[7]
                    child_param_loc[0] = 2 * xi    + 1
                    child_param_loc[1] = 2 * eta   - 1
                    child_param_loc[2] = 2 * theta - 1
        
        else: # if xi > 0
            
            if (eta < 0):
                
                if (theta < 0):
                    
                    refchild[0] = self._child[1]
                    child_param_loc[0] = 2 * xi    - 1
                    child_param_loc[1] = 2 * eta   + 1
                    child_param_loc[2] = 2 * theta + 1
                
                else:
                    
                    refchild[0] = self._child[5]
                    child_param_loc[0] = 2 * xi    - 1
                    child_param_loc[1] = 2 * eta   + 1
                    child_param_loc[2] = 2 * theta - 1
      
            else: # if eta > 0
                
                if (theta < 0):
                    refchild[0] = self._child[2]
                    child_param_loc[0] = 2 * xi    - 1
                    child_param_loc[1] = 2 * eta   - 1
                    child_param_loc[2] = 2 * theta + 1
                else:
                    
                    refchild[0] = self._child[6]
                    child_param_loc[0] = 2 * xi    - 1
                    child_param_loc[1] = 2 * eta   - 1
                    child_param_loc[2] = 2 * theta - 1
  
        
        return True
Esempio n. 20
0
    def get_ref_fen(self, conn, ref_fens, indx):

        if (self.MANIFOLD_DIM == CONN_MANIFOLD_DIM.CONN_0_MANIFOLD
                and self.NFENS == 1 and self.NREFFENS == 1):

            #print('get_ref_fen(CONN_MANIFOLD_DIM.CONN_0_MANIFOLD,1,1)')
            CHECK(len(ref_fens) == 1)
            CHECK(conn.manifold_dim() == self.manifold_dim())
            CHECK(conn.nfens() == self.nfens())
            CHECK(indx == 0)

            if (conn.fen(0) == self.fen(0)):
                return ref_fens[0]
            else:
                return 0

        elif (self.MANIFOLD_DIM == CONN_MANIFOLD_DIM.CONN_1_MANIFOLD
              and self.NFENS == 2 and self.NREFFENS == 1):

            #print('get_ref_fen(CONN_MANIFOLD_DIM.CONN_1_MANIFOLD,2,1)')
            CHECK(len(ref_fens) == 1)
            CHECK(conn.manifold_dim() == self.manifold_dim())
            CHECK(conn.nfens() == self.nfens())
            CHECK(indx == 0)

            if ((conn.fen(0) == self.fen(0)) and (conn.fen(1) == self.fen(1))):
                return ref_fens[0]
            elif ((conn.fen(0) == self.fen(1))
                  and (conn.fen(1) == self.fen(0))):
                return ref_fens[0]
            else:
                return 0

        elif (self.MANIFOLD_DIM == CONN_MANIFOLD_DIM.CONN_2_MANIFOLD
              and self.NFENS == 4 and self.NREFFENS == 1):

            CHECK(len(ref_fens) == 1)
            CHECK(conn.manifold_dim() == self.manifold_dim())
            CHECK(conn.nfens() == self.nfens())
            CHECK(indx == 0)

            def CHK4(n0, n1, n2, n3):
                return ((conn.fen(0) == self.fen(n0))
                        and (conn.fen(1) == self.fen(n1))
                        and (conn.fen(2) == self.fen(n2))
                        and (conn.fen(3) == self.fen(n3)))

            if CHK4(0, 1, 2, 3):
                return ref_fens[0]
            elif CHK4(1, 2, 3, 0):
                return ref_fens[0]
            elif CHK4(2, 3, 0, 1):
                return ref_fens[0]
            elif CHK4(3, 0, 1, 2):
                return ref_fens[0]
            elif CHK4(3, 2, 1, 0):  # and then try the mirror configurations
                return ref_fens[0]
            elif CHK4(2, 1, 0, 3):
                return ref_fens[0]
            elif CHK4(1, 0, 3, 2):
                return ref_fens[0]
            elif CHK4(0, 3, 2, 1):
                return ref_fens[0]
            else:
                return 0

        elif (self.MANIFOLD_DIM == CONN_MANIFOLD_DIM.CONN_3_MANIFOLD
              and self.NFENS == 8 and self.NREFFENS == 1):

            CHECK(len(ref_fens) == 1)
            CHECK(conn.manifold_dim() == self.manifold_dim())
            CHECK(conn.nfens() == self.nfens())
            CHECK(indx == 0)

            # We could proceed as with the quadrilateral, but another option
            # is just to count the number of present nodes
            num_matched = 0
            for j in range(0, self.nfens()):
                to_match = self.fen(j)
                for k in range(0, self.nfens()):
                    if (to_match == conn.fen(k)):
                        num_matched += 1
                        break

            if (num_matched == 8):
                return ref_fens[0]
            else:
                return 0

        else:
            raise NotImplementedError
Esempio n. 21
0
 def add(self,gcell):        
     CHECK (self._gcell_type == gcell.type_name()) #, EXCEPTION_BAD_VALUE,;);
     self._gcells.append(gcell)
     gcell.set_gcell_group(self)