How to use the pyamg.adapt_mesh function in pyamg

To help you get started, we’ve selected a few pyamg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github su2code / SU2 / TestCases / py_wrapper / adap_amg / launch_adap.py View on Github external
nMarker_All = SU2Error.GetnMarker_CfgFile()
      mesh['markers'] = np.empty(nMarker_All+1, 'object')
      mesh['markers'][0] = int(options.nDim)
      for iMarker in range(1,nMarker_All+1):
        mesh['markers'][iMarker] = SU2Error.GetMarker_CfgFile_TagBound(iMarker-1)

      # Remesh options
      remesh_options                = {}
      remesh_options['Lp']          = 1
      remesh_options['gradation']   = 1.8
      remesh_options['logfile']     = "amg.log"

      # Run pyAMG
      print("Running pyAMG.")
      try:
        mesh_new = pyamg.adapt_mesh(mesh, remesh_options)        
      except:
          sys.stderr("## ERROR : pyamg failed.\n")
          raise

      mesh_new['markers'] = mesh['markers']
      mesh_new['dimension'] = mesh['dimension']

      current_mesh = "mesh_new.meshb"
      current_solution = "mesh_new.solb" 

      su2amg.write_mesh(current_mesh, current_solution, mesh_new)

      if options.nDim == 2:
        sendSolAdap = mesh_new['solution']
        sendPoiAdap = mesh_new['xy']
        sendTriAdap = mesh_new['Triangles']
github su2code / SU2 / SU2_PY / SU2 / amginria / interface.py View on Github external
'mesh_in': 'current.meshb', 'mesh_out': 'current.new.meshb'}
    ''' 
    
    
    if 'xy' in mesh:    mesh['xy']  = mesh['xy'].tolist()
    if 'xyz' in mesh:   mesh['xyz'] = mesh['xyz'].tolist()
    
    if 'Edges' in mesh:      mesh['Edges']      = mesh['Edges'].tolist() 
    if 'Triangles' in mesh:  mesh['Triangles']  = mesh['Triangles'].tolist()
    if 'Tetrahedra' in mesh: mesh['Tetrahedra'] = mesh['Tetrahedra'].tolist()   

    if 'sensor' in mesh: mesh['sensor'] = mesh['sensor'].tolist()
    if 'metric' in mesh: mesh['metric'] = mesh['metric'].tolist()
    
    try:
        mesh_new = pyamg.adapt_mesh(mesh, remesh_options)        
    except:
        sys.stderr("## ERROR : pyamg failed.\n")
        raise
    
    return mesh_new