Source code for vasp.automatedPostprocessing.predeform_mesh
# File under GNU GPL (v3) licence, see LICENSE file for details.
# This software is distributed WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.
"""
This script is used to predeform the mesh for an FSI simulation. It assumes
that the simulation has already been executed, and the displacement information
is available in the 'displacement.h5' file. By applying the reverse of the
displacement to the original mesh, this script generates a predeformed mesh for
subsequent simulation steps.
"""
import argparse
import h5py
from pathlib import Path
[docs]
def parse_arguments() -> argparse.Namespace:
"""
Parse command line arguments.
Returns:
argparse.Namespace: Parsed command-line arguments.
"""
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('--folder', type=str, required=True, help="Path to simulation results")
parser.add_argument('--mesh-path', type=str, default=None,
help="Path to the mesh file (default: <folder_path>/Mesh/mesh.h5)")
parser.add_argument('--scale-factor', type=float, default=-1,
help="Scale factor for mesh deformation (default: -1)")
return parser.parse_args()
[docs]
def main() -> None:
"""
Main function for parsing arguments and predeforming the mesh.
Returns:
None
"""
args = parse_arguments()
folder_path = Path(args.folder)
if args.mesh_path is None:
mesh_path = folder_path / "Mesh" / "mesh.h5"
else:
mesh_path = Path(args.mesh_path)
predeform_mesh(folder_path, Path(mesh_path), args.scale_factor)
if __name__ == '__main__':
main()