Exemplo n.º 1
0
def gmshInfo(fname, dim, *args, **kwargs):
    ''' Construct a MeshInfo from a gmsh dictionary '''
    
    if dim==2:
        gmsh_elem_key=2 # Key for triangle element in Gmsh 
        gmsh_face_key=1 # Key for line element in Gmsh
    elif dim==3:
        gmsh_elem_key=4 # Key for tetrahedral element in Gmsh
        gmsh_face_key=2 # Key for triangle element in Gmsh
    
    gmsh_dict=gmsh_reader(fname)
    
    # Pick out the coordinates of the vertices that we actually need
    nodes = gmsh_dict['nodes'][:,0:dim]
    
    els=filter(lambda e : e['type']==gmsh_elem_key, gmsh_dict['elements'].values())
    
    # This is the element->vertex map.  This establishes a canonical element ordering
    elements = map(lambda e: sorted(e['nodes']), els)
    
    # Create a map from the elements to their geometric Identities
    elemIdentity = map(lambda e: e['geomEntity'], els)
    
    # These are the physical entities in the mesh.
    boundaries = map(lambda f: (f['physEntity'], tuple(sorted(f['nodes']))), filter(lambda e : e['type']==gmsh_face_key, gmsh_dict['elements'].values()))
    return SimplicialMeshInfo(nodes, elements, elemIdentity, boundaries, dim, *args, **kwargs)
Exemplo n.º 2
0
from scipy.sparse.linalg.dsolve.linsolve import spsolve 
from pypwdg.mesh.gmsh_reader import gmsh_reader
from pypwdg.mesh.mesh import gmshMesh
from pypwdg.core.physics import assemble
from pypwdg.core.boundary_data import zero_impedance, dirichlet
from pypwdg.utils.quadrature import trianglequadrature
from pypwdg.utils.timing import print_timing
from pypwdg.core.evaluation import Evaluator, EvalElementError
from pypwdg.output.vtk_output import VTKStructuredPoints
from pypwdg.output.vtk_output import VTKGrid
from pypwdg.mesh.meshutils import MeshQuadratures
from pypwdg.core.vandermonde import LocalVandermondes



mesh_dict=gmsh_reader('../../examples/3D/scattmesh.msh')
mesh=gmshMesh(mesh_dict,dim=3)
boundaryentities = [82, 83]


Nq = 16
Np = 3
dirs = cubeRotations(cubeDirections(Np))
quad=trianglequadrature(Nq)


elttobasis = [[PlaneWaves(dirs, k)]] * mesh.nelements

params={'alpha':.5, 'beta':.5,'delta':.5}

l_coeffs=[-1j*k, 1]