Skip to content

Commit

Permalink
CodeAster. Add actual control of boundary conditions (not only ENCAST…
Browse files Browse the repository at this point in the history
…RE).
  • Loading branch information
Krande committed Apr 29, 2021
1 parent 0c98553 commit ca018c3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ creates an IFC with the following hierarchy (as shown in the figure below taken
![Beam Visualized in BlenderBIM](docs/_static/figures/my_beam.png)


### Create and execute a FEM analysis in Calculix and Abaqus
### Create and execute a FEM analysis in Calculix, Code Aster and Abaqus

This example uses a function `beam_ex1` from [here](src/ada/param_models/fem_models.py) that returns an
Assembly object ready to be written to FEM.
Expand All @@ -85,6 +85,7 @@ a = beam_ex1()

a.to_fem("MyCantilever_abaqus", "abaqus", overwrite=True, execute=True, run_ext=True)
a.to_fem("MyCantilever_calculix", "calculix", overwrite=True, execute=True)
a.to_fem("MyCantilever_code_aster", "code_aster", overwrite=True, execute=True)
```

after the execution is finished you can look at the results (in Paraview or Abaqus CAE for the results from
Expand All @@ -104,9 +105,14 @@ import meshio
vtu = Settings.scratch_dir / "MyCantilever_calculix" / "MyCantilever_calculix.vtu"
mesh = meshio.read(vtu)

# Von Mises stresses and displacement at a point @ index=0
print(mesh.point_data['S'][0])
print(mesh.point_data['U'][0])
# Displacements in [X, Y, Z] at point @ index=-1
print('Calculix:',mesh.point_data['U'][-1])

rmed = Settings.scratch_dir / "MyCantilever_code_aster" / "MyCantilever_code_aster.rmed"
ca_mesh = meshio.read(rmed, 'med')

# Displacements in [X, Y, Z] at point @ index=-1
print('Code Aster:',ca_mesh.point_data['DISP[10] - 1'][-1][:3])
```

In short `beam_ex1` creates a `Beam` object which it uses to create a shell element `FEM` mesh using
Expand Down
17 changes: 14 additions & 3 deletions src/ada/fem/io/code_aster/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,21 @@ def write_boundary_condition(bc):
:rtype: str
"""
set_name = bc.fem_set.name

return f"""{bc.name}_bc = AFFE_CHAR_MECA(
MODELE=model, DDL_IMPO=_F(GROUP_NO="{set_name}", LIAISON="ENCASTRE")
bc_str = ""
for i, n in enumerate(["DX", "DY", "DZ", "DRX", "DRY", "DRZ"], start=1):
if i in bc.dofs:
bc_str += f"{n}=0, "
dofs_str = f"""dofs = dict(
GROUP_NO="{set_name}",
{bc_str}
)\n"""

return (
dofs_str
+ f"""{bc.name}_bc = AFFE_CHAR_MECA(
MODELE=model, DDL_IMPO=_F(**dofs)
)"""
)


def write_load(load):
Expand Down

0 comments on commit ca018c3

Please sign in to comment.