Skip to content
Snippets Groups Projects
Verified Commit c4dfd54b authored by Paul Dechamps's avatar Paul Dechamps :speech_balloon:
Browse files

(ci) Updated DART import

DART is imported from the submodule if possible or from the blaster install path under blaster/dart. Custom install path can be specified in dartCfg as dart_path.
parent b3942db5
No related branches found
No related tags found
1 merge request!1BLASTER v1.0
Pipeline #51169 passed
......@@ -15,7 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Dart interface
# Paul Dechamps
......@@ -24,6 +23,9 @@ import numpy as np
from fwk.coloring import ccolors
from blast.interfaces.blSolversInterface import SolversInterface
dartflo_import_paths = {'local module': 'modules.dartflo.dart.api.core',
'blaster install': 'blaster.dart.api.core'}
class DartInterface(SolversInterface):
"""Interface to the Dart solver.
......@@ -50,18 +52,30 @@ class DartInterface(SolversInterface):
_cfg : dict
Configuration parameters of the VII interface.
"""
try:
from modules.dartflo.dart.api.core import init_dart
self.iobj = init_dart(dartCfg, task=dartCfg['task'], viscous=True)
self.solver = self.iobj.get('sol') # Solver
self.blw = [self.iobj.get('blwb'), self.iobj.get('blww')]
if dartCfg['task'] == 'optimization':
self.adjointSolver = self.iobj.get('adj')
print('Dart successfully loaded for optimization.')
# Load DART module
if 'dart_path' in dartCfg:
# First try imposed path
try:
init_dart = __import__(dartCfg['dart_path'], fromlist=['init_dart']).init_dart
print(f'DART loaded from specified path {dartCfg["dart_path"]} for {dartCfg["task"]}.')
except ImportError:
raise ImportError(f'{ccolors.ANSI_RED}Could not load DART from specified path: {dartCfg["dart_path"]}.{ccolors.ANSI_RESET}')
else:
# Load from known paths
for name, path in dartflo_import_paths.items():
try:
init_dart = __import__(path, fromlist=['init_dart']).init_dart
print(f'DART loaded from {name} path for {dartCfg["task"]}.')
break
except ImportError:
continue
else:
print('Dart successfully loaded for analysis.')
except:
raise ImportError(ccolors.ANSI_RED, 'Could not load DART.', ccolors.ANSI_RESET)
raise ImportError(f'{ccolors.ANSI_RED}Could not load DART.{ccolors.ANSI_RESET}')
self.iobj = init_dart(dartCfg, task=dartCfg['task'], viscous=True)
self.solver = self.iobj.get('sol') # Solver
self.blw = [self.iobj.get('blwb'), self.iobj.get('blww')]
self.adjointSolver = self.iobj.get('adj')
_cfg['Format'] = dartCfg['Format']
if 'iMsh' not in _cfg:
......
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