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__
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 multiprocessing
path = os.getcwd()
cube = os.path.join(path, "cube/main.py")
src = os.getcwd()
build = os.path.join(src, "../build")
if not os.path.exists(build):
os.makedirs(build)
###
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 = []
structure = ["simple-cubic"] #, "bc-cubic", "fc-cubic"]
def salome(exePath, arg):
subprocess.run(["salome", "start", "-t", exePath, "args:%s" % arg])
def salome(src_path, build_path, arg):
subprocess.run(["salome", "start", "-t", src_path, "args:{},{}".format(build_path, arg)])
for c in alpha:
print("starting process")
p = multiprocessing.Process(target = salome, args = (cube, c))
processes.append(p)
p.start()
for s in structure:
s_path = os.path.join(build, s)
for process in processes:
process.join()
for c in alpha:
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];
internalField uniform (0 0 0);
boundaryField
{
inlet
{
type ;
type pressureInletVelocity;
valut uniform (0 0 0);
}
outlet
{
type ;
type zeroGradient;
}
wall
{
type ;
type fixedValue;
value uniform (0 0 0);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,8 +29,6 @@ divSchemes
{
default none;
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