コード例 #1
0
ファイル: GDFtoDAT.py プロジェクト: binod65/OpenWARP
# Import the bemio.mesh_utilities module
import mesh
import numpy as np
import sys

gdfFile = sys.argv[1]
# Read WAMIT mesh
buoy = mesh.read(file_name=gdfFile)

# Save to a NEMOH mesh
buoy.write(mesh_format='NEMOH')
コード例 #2
0
#meshName = "L.msh"

comm = MPI.COMM_WORLD
size = comm.size
rank = comm.rank

if 1 == size:
    print "Lancer le script en parallele avec plus d'un processus !"
    exit(-1)
nbDoms = size
fich = open("output%03d" % rank, 'w')

fich.write("Décomposition sur %d domaines : je suis le domaine %d\n" %
           (nbDoms, rank))

m = mesh.read(meshName)
coords = m[0]
elt2verts = m[1]
nbVerts = coords.shape[0]
nbElts = elt2verts.shape[0]

fich.write("elt2verts global : %s\n" % repr(elt2verts))
begVert2Elts, vert2elts = mesh.compvert2elts(elt2verts)

etsDomains = splitter.splitEltMesh(nbDoms, nbVerts, elt2verts)
nbElts_loc = etsDomains[rank].shape[0]
fich.write("Nombre d'éléments contenus dans le domaine : %d\n" % nbElts_loc)

if rank == 0:
    elt2doms = np.zeros((nbElts, ), np.double)
    ia = 0.
コード例 #3
0
import splitter
from math import cos, sin, pi, sqrt
from scipy import sparse
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.tri as tri
import VisuSplitMesh as VSM
import VisuSolution as VS
from conjugate_gradient import *


def g(x, y):
    return cos(2 * pi * x) + sin(2 * pi * y)


m = mesh.read("CarreMedium.msh")
coords = m[0]
elt2verts = m[1]
nbVerts = coords.shape[0]
nbElts = elt2verts.shape[0]
print('nbVerts : {}'.format(nbVerts))
print('nbElts  : {}'.format(nbElts))
begVert2Elts, vert2elts = mesh.compvert2elts(elt2verts)

begRows, indCols = fem.comp_skel_csr_mat(elt2verts, (begVert2Elts, vert2elts))
nz = begRows[-1]
print("Number of non zero in sparse matrix : {}".format(nz))

spCoefs = np.zeros((nz, ), np.double)

for iElt in range(nbElts):
コード例 #4
0
ファイル: GDFtoDAT.py プロジェクト: NREL/OpenWARP
# Import the bemio.mesh_utilities module
import mesh
import numpy as np
import sys 

gdfFile = sys.argv[1]
# Read WAMIT mesh
buoy = mesh.read(file_name=gdfFile)

# Save to a NEMOH mesh
buoy.write(mesh_format='NEMOH')

コード例 #5
0
import splitter
from math import cos, sin, pi, sqrt
from scipy import sparse
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.tri as tri
import VisuSplitMesh as VSM
import VisuSolution as VS
from scipy.sparse import linalg as sp_linalg


def g(x, y):
    return cos(2 * pi * x) + sin(2 * pi * y)


m = mesh.read("CarreGros.msh")
coords = m[0]
print(coords)
elt2verts = m[1]
nbVerts = coords.shape[0]
nbElts = elt2verts.shape[0]
print('nbVerts : {}'.format(nbVerts))
print('nbElts  : {}'.format(nbElts))
begVert2Elts, vert2elts = mesh.compvert2elts(elt2verts)

begRows, indCols = fem.comp_skel_csr_mat(elt2verts, (begVert2Elts, vert2elts))
nz = begRows[-1]
print("Number of non zero in sparse matrix : {}".format(nz))

spCoefs = np.zeros((nz, ), np.double)
コード例 #6
0
# Duplication du communicateur :
comm = MPI.COMM_WORLD.Dup()
# Interrogation du contexte MPI :
rank = comm.rank
size = comm.size

# Ouverture d'un fichier nom unique mode simple
fileName = f"sortie{rank:03d}.txt"

file = open(fileName, mode="w")
file.write(f"Rang du processus : {rank}\n")
file.write(f"Nombre de processus : {size}\n")

########################

m = mesh.read("CarrePetit.msh")
coords = m[0]

elt2verts = m[1]
if rank == 0:
    print(coords)
    print(elt2verts)
nbVerts = coords.shape[0]
nbElts = elt2verts.shape[0]
file.write('nbVerts : {}\n'.format(nbVerts))
file.write('nbElts  : {}\n'.format(nbElts))
begVert2Elts, vert2elts = mesh.compvert2elts(elt2verts)
if rank == 0:
    print("\nvert2elts:\n")
    for i in range(len(begVert2Elts) - 1):
        print(vert2elts[begVert2Elts[i]:begVert2Elts[i + 1]])