Skip to content
Snippets Groups Projects
Commit b15cf9b0 authored by Adrien Crovato's avatar Adrien Crovato
Browse files

Merge remote-tracking branch 'origin/master' into adrien

parents 5234a504 125887c1
No related branches found
No related tags found
1 merge request!53Update flow and windows libs
Pipeline #1372 passed
Showing
with 396 additions and 0 deletions
......@@ -20,71 +20,199 @@ from PyTrilinos import Teuchos
import katropton.utilities as u
defaut_params = {
'Is exp': True,
'Is random': True,
'Correlation length X': 20.,
'Correlation length Y': 20.,
'Correlation length Z': 0.,
'Number of KL Terms X': 5,
'Number of KL Terms Y': 5,
'Number of KL Terms Z': 3,
'Dispersion level': 0.1,
'gamma': 4368992.,
'MueLu xml from current_dir': True,
'MueLu xml use template': True,
'MueLu xml file name': '/SIMPLE_gs.xml',
'MueLu xml template file name': '/../preconditioners/SIMPLE_gs.xml.in',
'MueLu xml params name': ['$BLOCK_00_STRIDING_INFO', '$BLOCK_11_STRIDING_INFO',
'$BLOCK_00_GS_sweeps', '$BLOCK_11_GS_sweeps',
'$BLOCK_00_GS_damping', '$BLOCK_11_GS_damping',
'$SCHUR_omega', '$SimpleSmoother_damping'],
'Is exp':
True,
'Is random':
True,
'Correlation length X':
20.,
'Correlation length Y':
20.,
'Correlation length Z':
0.,
'Number of KL Terms X':
5,
'Number of KL Terms Y':
5,
'Number of KL Terms Z':
3,
'Dispersion level':
0.1,
'gamma':
4368992.,
'MueLu xml from current_dir':
True,
'MueLu xml use template':
True,
'MueLu xml file name':
'/SIMPLE_gs.xml',
'MueLu xml template file name':
'/../preconditioners/SIMPLE_gs.xml.in',
'MueLu xml params name': [
'$BLOCK_00_STRIDING_INFO', '$BLOCK_11_STRIDING_INFO',
'$BLOCK_00_GS_sweeps', '$BLOCK_11_GS_sweeps', '$BLOCK_00_GS_damping',
'$BLOCK_11_GS_damping', '$SCHUR_omega', '$SimpleSmoother_damping'
],
'MueLu xml params': ['3', '3', '10', '10', '1.6', '1.6', '0.5', '1.'],
'Write matrix and vectors': False,
'Write txt files': False,
'inner clamped': False
'Write matrix and vectors':
False,
'Write txt files':
False,
'inner clamped':
False
}
def get_parameters(case_id, first_sample_id):
"""
This function returns the python dictionary that includes
the parameters for a given test case
"""
p = defaut_params
if case_id == 0:
p['Is random'] = False
elif case_id == 1:
nuw = 128
p['Correlation length'] = 20.
p['Dispersion level'] = 0.1
elif case_id == 2:
nuw = 128
p['Correlation length'] = 20.
p['Dispersion level'] = 0.3
elif case_id == 3:
nuw = 128
p['Correlation length'] = 5.
p['Dispersion level'] = 0.1
elif case_id == 4:
nuw = 128
p['Correlation length'] = 5.
p['Dispersion level'] = 0.3
elif case_id == 5:
nuw = 128
p['Correlation length'] = 2.
p['Dispersion level'] = 0.1
elif case_id == 6:
nuw = 128
p['Correlation length'] = 2.
p['Dispersion level'] = 0.3
elif case_id == 7:
nuw = 128
p['Correlation length'] = 20.
p['Dispersion level'] = 0.01
elif case_id == 8:
nuw = 128
p['Correlation length'] = 5.
p['Dispersion level'] = 0.01
elif case_id == 9:
nuw = 128
p['Correlation length'] = 2.
p['Dispersion level'] = 0.01
if p['Is random'] == True:
p['Wavenumber cutoff'] = 8.
p['Wavenumber discretization points'] = nuw
p['Number Z of previously drawn samples'] = first_sample_id * nuw**2
p['Number Phi of previously drawn samples'] = first_sample_id * nuw**2
p['MueLu xml file name'] = '/SIMPLE_MG.xml'
p['MueLu xml template file name'] = '/../preconditioners/SIMPLE_gs_direct_lvl.xml.in'
p['MueLu xml params name'] = [
'$BLOCK_00_STRIDING_INFO', '$BLOCK_11_STRIDING_INFO',
'$BLOCK_00_GS_sweeps', '$BLOCK_00_GS_damping', '$SCHUR_omega',
'$SimpleSmoother_damping', "$N_LVLS", "$N_SIZES", "$EXPORT_DATA",
"$SimpleSmoother_sweeps"
]
p['MueLu xml params'] = [
'3', '3', '3', '0.8', '0.8', '1', '2', '18', "true", '1'
]
p['Is exp'] = False
p['gamma'] = 0.
p['Write vtk files'] = False
return p
def Compute_QoIs(filename):
import tboxVtk.reader as vtkR
import tboxVtk.lineExtractor as vtkC
QoI = np.zeros((4,))
QoI = np.zeros((4, ))
reader = vtkR.Reader()
reader.open(filename)
cutter = vtkC.LineExtractor(reader.reader.GetOutputPort())
c_output = cutter.cut(1, [5., 5., 0.5, ], [
10., 5., 0.5, ], tag_name='volume_id')
c_output = cutter.cut(1, [
5.,
5.,
0.5,
], [
10.,
5.,
0.5,
],
tag_name='volume_id')
pts, tri, vals = cutter.extract(c_output, ['von Mises'], atPoint=False)
QoI[0] = vals['von Mises'][0]
c_output = cutter.cut(1, [5., 5., 0.5, ], [
5., 10., 0.5, ], tag_name='volume_id')
c_output = cutter.cut(1, [
5.,
5.,
0.5,
], [
5.,
10.,
0.5,
],
tag_name='volume_id')
pts, tri, vals = cutter.extract(c_output, ['von Mises'], atPoint=False)
QoI[1] = vals['von Mises'][0]
c_output = cutter.cut(1, [5., 5., 0.5, ], [
0., 5., 0.5, ], tag_name='volume_id')
c_output = cutter.cut(1, [
5.,
5.,
0.5,
], [
0.,
5.,
0.5,
],
tag_name='volume_id')
pts, tri, vals = cutter.extract(c_output, ['von Mises'], atPoint=False)
QoI[2] = vals['von Mises'][0]
c_output = cutter.cut(1, [5., 5., 0.5, ], [
5., 0., 0.5, ], tag_name='volume_id')
c_output = cutter.cut(1, [
5.,
5.,
0.5,
], [
5.,
0.,
0.5,
],
tag_name='volume_id')
pts, tri, vals = cutter.extract(c_output, ['von Mises'], atPoint=False)
QoI[3] = vals['von Mises'][0]
return QoI
class plate_model(object):
def __init__(self, ensemble_size, randomVariable, msh, comm, file_dir, current_dir, p=defaut_params):
def __init__(self,
ensemble_size,
randomVariable,
msh,
comm,
file_dir,
current_dir,
p=defaut_params):
if p['MueLu xml use template']:
old_strings = p['MueLu xml params name']
new_strings = p['MueLu xml params']
muelu_xml_in = file_dir + p['MueLu xml template file name']
u.replace_strings(muelu_xml_in, current_dir +
p['MueLu xml file name'], old_strings, new_strings)
u.replace_strings(muelu_xml_in,
current_dir + p['MueLu xml file name'],
old_strings, new_strings)
pbl = m.Problem(msh, comm)
......@@ -95,16 +223,16 @@ class plate_model(object):
d = 0.
m.Medium(pbl, "body", "test", E, nu, k, d)
m.Dirichlet(pbl, "clamped xyz", "Clamped", 1, 0.,
1, 0., 1, 0., 0, 0., ensemble_size)
m.Dirichlet(pbl, "clamped xy", "Clamped", 1, 0.,
1, 0., 0, 0., 0, 0., ensemble_size)
m.Dirichlet(pbl, "clamped y", "Clamped", 0, 0.,
1, 0., 0, 0., 0, 0., ensemble_size)
m.Dirichlet(pbl, "clamped xyz", "Clamped", 1, 0., 1, 0., 1, 0., 0, 0.,
ensemble_size)
m.Dirichlet(pbl, "clamped xy", "Clamped", 1, 0., 1, 0., 0, 0., 0, 0.,
ensemble_size)
m.Dirichlet(pbl, "clamped y", "Clamped", 0, 0., 1, 0., 0, 0., 0, 0.,
ensemble_size)
if p['inner clamped']:
m.Dirichlet(pbl, "inner boundary", "Clamped", 1,
0., 1, 0., 1, 0., 0, 0., ensemble_size)
m.Dirichlet(pbl, "inner boundary", "Clamped", 1, 0., 1, 0., 1, 0.,
0, 0., ensemble_size)
norm = tbox.Vector3d(0, 0, -1)
cont = m.Contact(pbl, 'inner part boundary', 'contact', norm)
......@@ -114,14 +242,14 @@ class plate_model(object):
zero = np.zeros(ensemble_size)
one = np.ones(ensemble_size)
m.Neumann(pbl, 'load 1', 'load', 0, zero, 1,
f, 0, zero, 0, one, ensemble_size)
m.Neumann(pbl, 'load 2', 'load', 0, zero, 1, -
f, 0, zero, 0, one, ensemble_size)
m.Neumann(pbl, 'load 1', 'load', 0, zero, 1, f, 0, zero, 0, one,
ensemble_size)
m.Neumann(pbl, 'load 2', 'load', 0, zero, 1, -f, 0, zero, 0, one,
ensemble_size)
solverList = Teuchos.ParameterList()
solverList['Ensemble Convergence Tolerance'] = 1e-8
solverList['Maximum Iterations'] = 1000
solverList['Ensemble Convergence Tolerance'] = 1e-7
solverList['Maximum Iterations'] = 500
solverList['Verbosity'] = 33
solverList['Flexible Gmres'] = False
solverList['Output Style'] = 1
......@@ -144,6 +272,7 @@ class plate_model(object):
solverList['Write matrix and vectors'] = p['Write matrix and vectors']
solverList['Write txt files'] = p['Write txt files']
solverList['Write vtk files'] = p['Write vtk files']
if p["Is exp"]:
num_random_variables = randomVariable.shape[1]
......@@ -167,22 +296,31 @@ class plate_model(object):
randomParams['End Y'] = 10.
randomParams['End Z'] = 1.
randomParams['Number random variables'] = num_random_variables
randomParams['Correlation length X'] = p['Correlation length X']
randomParams['Correlation length Y'] = p['Correlation length Y']
randomParams['Correlation length Z'] = p['Correlation length Z']
randomParams['Number of KL Terms X'] = p['Number of KL Terms X']
randomParams['Number of KL Terms Y'] = p['Number of KL Terms Y']
randomParams['Number of KL Terms Z'] = p['Number of KL Terms Z']
randomParams['Correlation length X'] = p[
'Correlation length X']
randomParams['Correlation length Y'] = p[
'Correlation length Y']
randomParams['Correlation length Z'] = p[
'Correlation length Z']
randomParams['Number of KL Terms X'] = p[
'Number of KL Terms X']
randomParams['Number of KL Terms Y'] = p[
'Number of KL Terms Y']
randomParams['Number of KL Terms Z'] = p[
'Number of KL Terms Z']
randomParams['Maximum Nonlinear Solver Iterations'] = 5000
randomParams['Bound Perturbation Size'] = 1E-10
else:
randomParams['Correlation length'] = p['Correlation length']
randomParams['Wavenumber cutoff'] = p['Wavenumber cutoff']
randomParams['Wavenumber discretization points'] = p['Wavenumber discretization points']
randomParams['Number Z of previously drawn samples'] = p['Number Z of previously drawn samples']
randomParams['Number Phi of previously drawn samples'] = p['Number Phi of previously drawn samples']
randomParams['Mean'] = old_div(E[0], (2.*(1.+nu[0])))
randomParams['Wavenumber discretization points'] = p[
'Wavenumber discretization points']
randomParams['Number Z of previously drawn samples'] = p[
'Number Z of previously drawn samples']
randomParams['Number Phi of previously drawn samples'] = p[
'Number Phi of previously drawn samples']
randomParams['Mean'] = old_div(E[0], (2. * (1. + nu[0])))
randomParams['Dispersion level'] = p['Dispersion level']
solverList['randomParams'] = randomParams
......@@ -191,10 +329,9 @@ class plate_model(object):
self.solverList = solverList
self.ensemble_size = ensemble_size
def run(self, k=1):
k = int(k)
self.slv = m.IterativeSolver(
self.pbl, k, self.solverList, 3, self.ensemble_size)
def run(self):
self.slv = m.IterativeSolver(self.pbl, self.solverList, 3,
self.ensemble_size)
self.slv.start()
f = open('timers.txt', 'w')
print(self.slv.getTimers(), file=f)
......@@ -202,44 +339,35 @@ class plate_model(object):
def main():
try:
import mpi4py.MPI as mpi
comm = mpi.COMM_WORLD
rank = comm.rank
siz = comm.size
name = mpi.Get_processor_name()
status = mpi.Status()
print("info: MPI found")
except:
comm = None
rank = 0
siz = 1
name = "noname"
print("info: MPI not found => MPI disabled")
comm, rank, size = m.utilities.import_MPI()
args = parseargs()
file_dir = os.path.dirname(__file__)
work_dir = os.getcwd()
# Units in the meshes are in mm
msh = u.fuse_meshes('plate_1.msh', 'plate_1_tmp', 'plate_2.msh',
'plate_2_tmp', 'plate_fused', file_dir, work_dir)
msh = u.fuse_meshes('plate_1.geo', 'plate_1_tmp', 'plate_2.geo',
'plate_2_tmp', 'plate_fused', file_dir + '/mesh',
work_dir, comm, rank, size)
np.random.seed(42)
N = 1
num_random_variables = 20
#randomVariable = np.random.normal(0, 1, num_random_variables*N)
#randomVariable = np.resize(randomVariable,(N,num_random_variables))
randomVariable = np.zeros((N, num_random_variables))
p = defaut_params
p = get_parameters(0, 0)
p['Write txt files'] = True
p['Write vtk files'] = True
ensemble_size = 1
pm = plate_model(ensemble_size, randomVariable,
msh, comm, file_dir, work_dir, p)
pm.run(args.k)
pm = plate_model(ensemble_size, randomVariable, msh, comm, file_dir,
work_dir, p)
nThreads = u.Initialize_Kokkos()
pm.run()
u.Finalize_Kokkos()
if __name__ == "__main__":
......
#!/bin/bash
# Submission script for Blake
#SBATCH --job-name=MC_MG
#SBATCH --time=41:00:00 # hh:mm:ss
#
#SBATCH -N 1
#SBATCH -p blake
#
#SBATCH --comment=test
#SBATCH --output=workspace/MC_MG.%j.out
. ~/.bash_profile $SLURM_SUBMIT_HOST
export MKL_DYNAMIC=TRUE
export OMP_DYNAMIC=FALSE
export OMP_NUM_THREADS=48
export KMP_PLACE_THREADS=24c,2t
export KMP_AFFINITY=compact
export MKL_NUM_THREADS=${OMP_NUM_THREADS}
python run.py -k ${OMP_NUM_THREADS} katropton/CMAME/tests/plate_MC_MG_all_cases.py
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment