Move: structures to anisotropy, salompl is standalone module now

This commit is contained in:
L-Nafaryus 2021-07-27 14:56:51 +05:00
parent 39db5447c9
commit cae96521b0
6 changed files with 35 additions and 37 deletions

View File

@ -1,4 +1,12 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#from anisotropy import Anisotropy from anisotropy.anisotropy import (
Anisotropy,
logger
)
from anisotropy.simple import simple
from anisotropy.bodyCentered import bodyCentered
from anisotropy.faceCentered import faceCentered

View File

@ -225,8 +225,8 @@ class Anisotropy(object):
def getParams(structure, direction, theta): def getParams(structure, direction, theta):
for entry in self.params: for entry in self.params:
if entry["name"] == structure and if entry["name"] == structure and \
entry["geometry"]["direction"] == direction and entry["geometry"]["direction"] == direction and \
entry["geometry"]["theta"] == theta: entry["geometry"]["theta"] == theta:
return entry return entry
@ -294,11 +294,11 @@ class Anisotropy(object):
self.params = sorted(self.params, key = lambda entry: f"{ entry['name'] } { entry['geometry']['direction'] } { entry['geometry']['theta'] }") self.params = sorted(self.params, key = lambda entry: f"{ entry['name'] } { entry['geometry']['direction'] } { entry['geometry']['theta'] }")
@timer @timer
def computeMesh(self): def computeMesh(self, name, direction, theta):
scriptpath = os.path.join(env["ROOT"], "salomepl/genmesh.py") scriptpath = os.path.join(self.env["ROOT"], "anisotropy/genmesh.py")
port = 2900 port = 2900
out, err, returncode = salomepl.runSalome(port, scriptpath, env["ROOT"], case) out, err, returncode = salomepl.runSalome(port, scriptpath, env["ROOT"], name, direction, theta)
def computeFlow(self): def computeFlow(self):
pass pass

View File

@ -5,9 +5,9 @@
## ##
import os, sys import os, sys
import math import math
import logging
import salome import salome
import click
@click.command() @click.command()
@click.argument("root") @click.argument("root")
@ -29,18 +29,21 @@ def genmesh(root, name, direction, theta):
os.path.join(root, "env/lib/python3.9/site-packages") os.path.join(root, "env/lib/python3.9/site-packages")
]) ])
import logging from anisotropy import (
import click Anisotropy,
logger,
from anisotropy import Anisotropy simple,
bodyCentered,
from salomepl.simple import simple faceCentered
from salomepl.faceCentered import faceCentered )
from salomepl.bodyCentered import bodyCentered
from salomepl.geometry import getGeom from salomepl.geometry import getGeom
from salomepl.mesh import Mesh, Fineness, ExtrusionMethod, defaultParameters from salomepl.mesh import (
Mesh,
Fineness,
ExtrusionMethod,
defaultParameters
)
### ###
# Model # Model
@ -51,22 +54,6 @@ def genmesh(root, name, direction, theta):
p = model.getParams(name, direction, theta) p = model.getParams(name, direction, theta)
###
# Logger
##
logging.basicConfig(
level = logging.INFO,
format = model.env["logger"]["format"],
handlers = [
logging.StreamHandler(),
logging.FileHandler(
os.path.join(model.env["LOG"], model.env["logger"]["name"])
)
]
)
logger = logging.getLogger(model.env["logger"]["name"])
### ###
# Entry # Entry
## ##
@ -141,6 +128,7 @@ def genmesh(root, name, direction, theta):
mesh.Triangle(subshape, **smp) mesh.Triangle(subshape, **smp)
model.updateDB()
returncode, errors = mesh.compute() returncode, errors = mesh.compute()
if not returncode: if not returncode:

View File

@ -1,9 +1,9 @@
#import salome #import salome
#salome.salome_init() #salome.salome_init()
import GEOM #import GEOM
from salome.geom import geomBuilder #from salome.geom import geomBuilder
geompy = geomBuilder.New() #geompy = geomBuilder.New()
from math import pi, sqrt from math import pi, sqrt
@ -284,6 +284,8 @@ def simpleHexagonalPrism(theta = 0.01, fillet = False, direction = [1, 1, 1]):
def simple(theta, fillet, direction): def simple(theta, fillet, direction):
#from salomepl import getGeom
if direction in [[1, 0, 0], [0, 0, 1]]: if direction in [[1, 0, 0], [0, 0, 1]]:
return simpleCubic(theta, fillet, direction) return simpleCubic(theta, fillet, direction)