Skip to content

Commit

Permalink
adding multi US mesh option (#290)
Browse files Browse the repository at this point in the history
* adding multi US mesh option

* adding options to mphys_adflow file for multi US mesh

* minor changes to add dictionary for multiUSmesh

* more descriptive message for mesh_type

* minor fixes

---------

Co-authored-by: Alasdair Gray <[email protected]>
  • Loading branch information
ArshSaja and A-CGray authored Jul 14, 2023
1 parent 7fac40d commit c246e06
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions adflow/mphys/mphys_adflow.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from pprint import pprint as pp

import numpy as np
from idwarp import USMesh
from adflow import ADFLOW
from idwarp import USMesh, MultiUSMesh
from mphys.builder import Builder
from openmdao.api import AnalysisError, ExplicitComponent, Group, ImplicitComponent

from adflow import ADFLOW

from .om_utils import get_dvs_and_cons

Expand Down Expand Up @@ -1132,6 +1131,7 @@ def __init__(
options, # adflow options
mesh_options=None, # idwarp options
scenario="aerodynamic", # scenario type to configure the groups
mesh_type="USMesh", # mesh type option. USMesh or MultiUSMesh
restart_failed_analysis=False, # retry after failed analysis
err_on_convergence_fail=False, # raise an analysis error if the solver stalls
balance_group=None,
Expand Down Expand Up @@ -1165,6 +1165,28 @@ def __init__(
else:
self.mesh_options = mesh_options

if mesh_type == "USMesh":
self.multi_us_mesh = False

if "multi_us_mesh_components" in self.mesh_options.keys():
raise TypeError(
"'multi_us_mesh_components' is only for 'MultiUSMesh' mesh_type . Please don't provide any multi_us_mesh_components dictionary for 'USMesh' mesh_type."
)

elif mesh_type == "MultiUSMesh":
if "multi_us_mesh_components" not in self.mesh_options.keys():
raise TypeError(
"The 'multi_us_mesh_components' keyword argument is *NOT* "
"optional. A multi_us_mesh_components dictionary must be passed for 'MultiUSMesh' mesh_type. "
)

self.multi_us_mesh = True

else:
raise ValueError(
"Available options for mesh_type: 'USMesh' and 'MultiUSMesh'. By default, 'USMesh' is used. Choose 'MultiUSMesh' When several mesh components are considered for independent deformation of multiple overset component meshes."
)

# defaults:

# flag to determine if the mesh warping component is added
Expand Down Expand Up @@ -1227,7 +1249,10 @@ def initialize(self, comm):
for key, val in self.user_family_groups.items():
self.solver.addFamilyGroup(key, val)

mesh = USMesh(options=self.mesh_options, comm=comm)
if self.multi_us_mesh:
mesh = MultiUSMesh(self.mesh_options["gridFile"], self.mesh_options["multi_us_mesh_components"], comm=comm)
else:
mesh = USMesh(options=self.mesh_options, comm=comm)

self.solver.setMesh(mesh)

Expand Down

0 comments on commit c246e06

Please sign in to comment.