Commit 8e713246 authored by COULAUD Olivier's avatar COULAUD Olivier

Add Utils repository

removeMoment is a driver to remove the infinite field for ewald solution
Add manipFMA.py to manipulate ascii fma format with python
parent 7ae8ff1a
...@@ -507,7 +507,7 @@ public: ...@@ -507,7 +507,7 @@ public:
<< " asked in structure " <<(*dataToRead).getReadDataNumber() <<std::endl; << " asked in structure " <<(*dataToRead).getReadDataNumber() <<std::endl;
std::exit(EXIT_FAILURE); std::exit(EXIT_FAILURE);
} }
std::cout << " typeData[1] "<< typeData[1] << " "<<(*dataToRead).getReadDataNumber() <<" otherDataRead "<<otherDataRead <<std::endl; // std::cout << " typeData[1] "<< typeData[1] << " "<<(*dataToRead).getReadDataNumber() <<" otherDataRead "<<otherDataRead <<std::endl;
if(binaryFile && otherDataRead == 0 ){ if(binaryFile && otherDataRead == 0 ){
file->read((char*)((*dataToRead).getPtrFirstData()), sizeof(FReal)*(N*(*dataToRead).getReadDataNumber())); file->read((char*)((*dataToRead).getPtrFirstData()), sizeof(FReal)*(N*(*dataToRead).getReadDataNumber()));
} }
......
This diff is collapsed.
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 8 17:25:37 2014
@author: coulaud
"""
#Read file comming from Stamp
import numpy
#import sys
#Filename='/Users/coulaud/Dev/src/ScalFMM/scalfmmT/Data/cea-200-per.xyzqf'
#
# Read Header
#
#global nbRecordPerline,dataType,NbParticles,BoxWidth,Centre
dataType = 8
nbRecordPerline = 4
NbParticles = 0
BoxWidth = 1.0
Centre= (0.0,0.0,0.0)
#
def readFMAHeader(Filename):
"""
This function read the header of the FMA file Filename
"""
global nbRecordPerline,dataType,NbParticles,BoxWidth,Centre
f = open(Filename, 'r')
header1 = f.readline()
header2 = f.readline()
s1,s2=(item.strip() for item in header1.split())
dataType = int(s1)
nbRecordPerline = int(s2)
s1,s2,s3,s4,s5 = (item.strip() for item in header2.split())
NbParticles=int(s1)
BoxWidth=float(s2)*2
Centre = [float(s3),float(s4),float(s5)]
f.close()
return dataType,nbRecordPerline,NbParticles,BoxWidth,Centre
#
def readFMAfile(fileName):
"""
Read data from an ascci file il the FMA format
Return data (x,y,z,q) or (x,y,z,q,p,fx,fy,fz)
"""
global nbRecordPerline,dataType,NbParticles,BoxWidth,Centre
readFMAHeader(fileName)
print NbParticles
# Read data in a non compact mode
#
data = numpy.loadtxt(fileName,skiprows=2)
# if nbRecordPerline == 4 or nbRecordPerline == 8 :
data = numpy.loadtxt(fileName,skiprows=2)
# else:
#print " wrong data nbRecordPerline (",nbRecordPerline,"). Should be 4 or 8"
# os._exit()
return data,BoxWidth,Centre
#
def writeFMAfilefmt(fileName,data,boxWidth, centre,myformat):
"""
write data from an ascci file il the FMA format
Return data (x,y,z,q) or (x,y,z,q,p,fx,fy,fz)
"""
# f = open(fileName, "w")
s = ' 8 '+ str(numpy.shape(data)[1]) + '\n'
# f.write(s)
s= s + str(numpy.shape(data)[0])+ ' '+ str(boxWidth/2)+ ' '+ str(Centre[0])+ ' '+ str(Centre[1])+ ' '+ str(Centre[2])
# f.write(s)
# f.close()
numpy.savetxt(fileName,data,delimiter=' ',header=s,comments=' ',fmt=myformat)
def writeFMAfile(fileName,data,boxWidth, centre):
"""
write data from an ascci file il the FMA format
Return data (x,y,z,q) or (x,y,z,q,p,fx,fy,fz)
"""
# f = open(fileName, "w")
s = ' 8 '+ str(numpy.shape(data)[1]) + '\n'
# f.write(s)
s= s + str(numpy.shape(data)[0])+ ' '+ str(boxWidth/2)+ ' '+ str(Centre[0])+ ' '+ str(Centre[1])+ ' '+ str(Centre[2])
# f.write(s)
# f.close()
numpy.savetxt(fileName,data,delimiter=' ',header=s,comments=' ')
# -*- coding: utf-8 -*-
"""
Created on Sun May 11 16:32:08 2014
@author: coulaud
"""
import numpy as np
from random import *
import matplotlib.pyplot as plt
#
# Manipulation de fichier FMA
#
#Npart =0
#def readFMA(inputFile,N)
def readFMA(N, BoxSize) :
#
#part BoxSize,BoxCentre):
#
print __doc__
inputFile="/Users/coulaud/Dev/src/ScalFMM/scalfmmT/Data/prolate50.fma"
fichier = open(inputFile, "r")
A= fichier.readline().split()
N = int(A[0])
BoxSize = float(A[1])
fichier.close()
return N
def writeFMA(N, xyzq, outFile) :
#
#part BoxSize,BoxCentre):
#
print __doc__
# outFile="/Users/coulaud/Dev/src/ScalFMM/scalfmmT/Data/prolate50.fma"
fichier = open(outFile, "r")
# A= fichier.readline().split()
# N = int(A[0])
# BoxSize = float(A[1])
fichier.close()
def build1DDistribution(a, alpha,N):
xyzq = np.zeros((N, 4))
x = np.zeros(N)
y = np.zeros(N)
z = np.random.random_sample(N)
sa = sin(alpha)
ca = cos(alpha)
print a,alpha,ca,sa
for i in range(0, N):
x[i] = a*sa*z[i]*cos(z[i])
y[i] = a*sa*z[i]*sin(z[i])
z[i] = a*ca*z[i]
print i, x[i],y[i], z[i]
return x,y,z
...@@ -10,6 +10,7 @@ ccowingzitron@ucsd.edu ...@@ -10,6 +10,7 @@ ccowingzitron@ucsd.edu
cheekubadshah@sify.com cheekubadshah@sify.com
dhairyamal@gmail.com dhairyamal@gmail.com
fabien.casenave@gmail.com fabien.casenave@gmail.com
guillaume.fuhr@univ-amu.fr
jean-christophe.toussaint@grenoble.cnrs.fr jean-christophe.toussaint@grenoble.cnrs.fr
j8asic@gmail.com j8asic@gmail.com
joseluiscasalssainz@gmail.com joseluiscasalssainz@gmail.com
...@@ -29,6 +30,7 @@ ronojoy.adhikari@gmail.com ...@@ -29,6 +30,7 @@ ronojoy.adhikari@gmail.com
rxrjj@126.com rxrjj@126.com
samuel.thibault@labri.fr samuel.thibault@labri.fr
shujin.cao@163.com shujin.cao@163.com
t.ben.thompson@gmail.com
t.betcke@ucl.ac.uk t.betcke@ucl.ac.uk
vitoreafeliciano@msn.com vitoreafeliciano@msn.com
weygand@kit.edu weygand@kit.edu
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment