-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further refactoring of FEM Step data and move solver specific options…
… to a new subclass of "SolverOptions" per solver. Start to remove all use of metadata as a data carrier in a FEM export process.
- Loading branch information
Showing
21 changed files
with
769 additions
and
634 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from dataclasses import dataclass | ||
|
||
from ada.fem.io import FEATypes | ||
from ada.fem.steps import SolverOptions | ||
|
||
|
||
class StabilizeTypes: | ||
ENERGY = "energy" | ||
DAMPING = "damping" | ||
CONTINUE = "continue" | ||
|
||
|
||
@dataclass | ||
class Stabilize: | ||
factor: float | ||
allsdtol: float | ||
stabilize_type: StabilizeTypes = StabilizeTypes.ENERGY | ||
energy: float = None | ||
damping: float = None | ||
stabilize_continue: bool = True | ||
|
||
def to_input_str(self): | ||
st = StabilizeTypes | ||
stable_map = { | ||
st.ENERGY: f"stabilize={self.factor}, allsdtol={self.allsdtol}", | ||
st.DAMPING: f"stabilize, factor={self.factor}, allsdtol={self.allsdtol}", | ||
st.CONTINUE: "stabilize, continue=ON", | ||
} | ||
stabilize_str = stable_map.get(self.stabilize_type, None) | ||
if stabilize_str is None: | ||
raise ValueError(f'Unrecognized stabilization type "{self.stabilize_type}"') | ||
|
||
return stabilize_str | ||
|
||
|
||
@dataclass | ||
class SolverOptionsAbaqus(SolverOptions): | ||
|
||
init_accel_calc: bool = True | ||
restart_int: int = None | ||
unsymm: bool = False | ||
stabilize: Stabilize = None | ||
|
||
""" | ||
:param init_accel_calc: Calculate Initial acceleration in the beginning of the step | ||
:param restart_int: Restart interval | ||
:param unsymm: Unsymmetric Matrix storage (default=False) | ||
:param stabilize: Default=None. | ||
""" | ||
|
||
def __post_init__(self): | ||
self.solver = FEATypes.ABAQUS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from ada.fem import Load | ||
|
||
|
||
def load_str(load: Load) -> str: | ||
load_map = {Load.TYPES.GRAVITY: gravity_load_str, Load.TYPES.FORCE: force_load_str} | ||
load_str_func = load_map.get(load.type, None) | ||
|
||
if load_str_func is None: | ||
raise ValueError("Unsupported load type", load.type) | ||
|
||
return load_str_func(load) | ||
|
||
|
||
def gravity_load_str(load: Load) -> str: | ||
dof = [0, 0, 1] if load.dof is None else load.dof | ||
dof_str = ", ".join([str(x) for x in dof[:3]]) | ||
return f"""** Name: gravity Type: Gravity\n*Dload\n, GRAV, {load.magnitude}, {dof_str}""" | ||
|
||
|
||
def force_load_str(load: Load) -> str: | ||
from .writer import get_instance_name | ||
|
||
lstr = "" | ||
bc_text_f = "" | ||
bc_text_m = "" | ||
|
||
fo = 0 | ||
instance_name = get_instance_name(load.fem_set, Load) | ||
for i, f in enumerate(load.dof[:3]): | ||
if f == 0.0 or f is None: | ||
continue | ||
total_force = f * load.magnitude | ||
bc_text_f += f" {instance_name}, {i + 1}, {total_force}\n" | ||
fo += 1 | ||
|
||
mom = 0 | ||
for i, m in enumerate(load.dof[3:]): | ||
if m == 0.0 or m is None: | ||
continue | ||
mom += 1 | ||
bc_text_m += f" {instance_name}, {i + 4}, {m}\n" | ||
|
||
lstr += "\n" if "\n" not in lstr[-2:] != "" else "" | ||
follower_str = "" if load.follower_force is False else ", follower" | ||
follower_str += f", amplitude={load.amplitude}" if load.amplitude is not None else "" | ||
if fo != 0: | ||
forc_name = load.name + "_F" | ||
lstr += f"** Name: {forc_name} Type: Concentrated force\n*Cload{follower_str}\n{bc_text_f}" | ||
if mom != 0: | ||
mom_name = load.name + "_M" | ||
lstr += f"** Name: {mom_name} Type: Moment\n*Cload{follower_str}\n{bc_text_m}" | ||
return lstr.strip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.