Mod: salome: multicore computation + export

This commit is contained in:
L-Nafaryus 2021-02-19 19:36:53 +05:00
parent fa04aece32
commit c6d13d28c0
No known key found for this signature in database
GPG Key ID: C76D8DCD2727DBB7
14 changed files with 88 additions and 53 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
__pycache__ __pycache__
build/
logs/

0
doc/report.tex Normal file
View File

0
doc/title.tex Normal file
View File

View File

@ -2,20 +2,44 @@ import os
import subprocess import subprocess
import multiprocessing import multiprocessing
path = os.getcwd() src = os.getcwd()
cube = os.path.join(path, "cube/main.py") build = os.path.join(src, "../build")
if not os.path.exists(build):
os.makedirs(build)
###
alpha = [0.1, 0.15, 0.2] alpha = [0.1, 0.15, 0.2]
simpleCubic = os.path.join(src, "simple-cubic/main.py")
# Body-centered cubic
#bcCubic = os.path.join(path, "bc-cubic/main.py")
# Face-centered cubic
#fcCubic = os.path.join(path, "fc-cubic/main.py")
###
processes = [] processes = []
structure = ["simple-cubic"] #, "bc-cubic", "fc-cubic"]
def salome(exePath, arg): def salome(src_path, build_path, arg):
subprocess.run(["salome", "start", "-t", exePath, "args:%s" % arg]) subprocess.run(["salome", "start", "-t", src_path, "args:{},{}".format(build_path, arg)])
for c in alpha: for s in structure:
print("starting process") s_path = os.path.join(build, s)
p = multiprocessing.Process(target = salome, args = (cube, c))
processes.append(p)
p.start()
for process in processes: for c in alpha:
process.join() src_path = os.path.join(src, "%s/main.py" % s)
build_path = os.path.join(s_path, str(c))
if not os.path.exists(build_path):
os.makedirs(build_path)
print("starting process")
p = multiprocessing.Process(target = salome, args = (src_path, build_path, c))
processes.append(p)
p.start()
for process in processes:
process.join()

View File

@ -16,21 +16,25 @@ FoamFile
dimensions [0 1 -1 0 0 0 0]; dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField boundaryField
{ {
inlet inlet
{ {
type ; type pressureInletVelocity;
valut uniform (0 0 0);
} }
outlet outlet
{ {
type ; type zeroGradient;
} }
wall wall
{ {
type ; type fixedValue;
value uniform (0 0 0);
} }
} }

View File

@ -16,21 +16,25 @@ FoamFile
dimensions [0 2 -2 0 0 0 0]; dimensions [0 2 -2 0 0 0 0];
internaleField uniform 0;
boundaryField boundaryField
{ {
inlet inlet
{ {
type fixedValue; type fixedValue;
value uniform 1;
} }
outlet outlet
{ {
type fixedValue; type fixedValue;
value uniform 0;
} }
wall wall
{ {
type ; type zeroGradient;
} }
} }

View File

@ -17,8 +17,6 @@ FoamFile
transportModel Newtonian; transportModel Newtonian;
rho 1;
nu 1e-05; nu 1e-05;
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,6 +1,4 @@
import os, sys import os, sys
#print(os.getcwd())
#sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import salome import salome
salome.salome_init() salome.salome_init()
@ -8,7 +6,8 @@ salome.salome_init()
import geometry, mesh import geometry, mesh
#alpha = [ 0.1, 0.15, 0.2 ] #alpha = [ 0.1, 0.15, 0.2 ]
coef = float(sys.argv[1]) build_path = str(sys.argv[1])
coef = float(sys.argv[2])
#for coef in alpha: #for coef in alpha:
print("alpha = {}".format(coef)) print("alpha = {}".format(coef))
@ -25,13 +24,12 @@ isDone = PoreMesh.Compute()
status = "Succesfully" if isDone else "Mesh is not computed" status = "Succesfully" if isDone else "Mesh is not computed"
print(status) print(status)
#try: try:
# dirname = os.path.dirname(__file__) filename = os.path.join(build_path, "mesh.unv")
# filename = os.path.join(dirname, '../build/mesh.unv') PoreMesh.ExportUNV(filename)
# PoreMesh.ExportUNV( filename ) pass
# pass except:
#except: print('ExportUNV() failed. Invalid file name?')
# print('ExportUNV() failed. Invalid file name?')
if salome.sg.hasDesktop(): if salome.sg.hasDesktop():
salome.sg.updateObjBrowser() salome.sg.updateObjBrowser()

View File

@ -47,23 +47,33 @@ runTimeModifiable true;
functions functions
{ {
momErr flowRatePatch(name=inlet)
{ {
type momentumError; name inlet;
libs (fieldFunctionObjects); type surfaceFieldValue;
executeControl writeTime; libs ( "libfieldFunctionObjects.so" );
writeControl writeTime; writeControl timeStep;
writeInterval 1;
writeFields false;
log false;
regionType patch;
fields ( phi );
operation sum;
} }
contErr flowRatePatch(name=outlet)
{ {
type div; name outlet;
libs (fieldFunctionObjects); type surfaceFieldValue;
field phi; libs ( "libfieldFunctionObjects.so" );
executeControl writeTime; writeControl timeStep;
writeControl writeTime; writeInterval 1;
writeFields false;
log false;
regionType patch;
fields ( phi );
operation sum;
} }
} }

View File

@ -10,20 +10,17 @@ FoamFile
version 2.0; version 2.0;
format ascii; format ascii;
class dictionary; class dictionary;
location "constant"; object decomposeParDict;
object turbulenceProperties;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType RAS; numberOfSubdomains 4;
RAS method simple;
coeffs
{ {
RASModel SpalartAllmaras; n (2 2 1);
turbulence on;
printCoeffs on;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -29,8 +29,6 @@ divSchemes
{ {
default none; default none;
div(phi,U) bounded Gauss linearUpwind grad(U); div(phi,U) bounded Gauss linearUpwind grad(U);
// div(phi,nuTilda) bounded Gauss linearUpwind grad(nuTilda);
// div((nuEff*dev2(T(grad(U))))) Gauss linear;
} }
laplacianSchemes laplacianSchemes