PyXMake Developer Guide: D:/03_Workspaces/01_Eclipse/pyx_core/PyXMake/VTL/abaqus.py Source File

| PyXMake Developer Guide 1.0 PyXMake

D:/03_Workspaces/01_Eclipse/pyx_core/PyXMake/VTL/abaqus.py
1 # -*- coding: utf-8 -*-
2 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 # % PyXMake - Build environment for PyXMake %
4 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 """
6 Triple-use minimum working example for PyXMake. This script can be
7 executed in three different ways in varying levels of accessibility
8
9 @note: Compile MCODAC for ABAQUS Standard & Explicit
10 on Windows. Can be combined with self-written code alike.
11 Created on 25.06.2018
12
13 @version: 1.0
14 ----------------------------------------------------------------------------------------------
15 @requires:
16 - PyXMake
17
18 @change:
19 -
20
21 @author: garb_ma [DLR-FA,STM Braunschweig]
22 ----------------------------------------------------------------------------------------------
23 """
24 import os, sys
25 import argparse
26
27 try:
28 import PyXMake as _
29 except ImportError:
30 # Script is executed as a plug-in
31 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
32 finally:
33 from PyXMake.Build import Make as pyx #@UnresolvedImport
34 from PyXMake.Tools import Utility #@UnresolvedImport
35 from PyXMake import VTL #@UnresolvedImport
36
37 # Predefined script local variables
38 __arch = "x64"
39
40 # Select a installation of ABAQUS. Always use latest found.
41 os.environ["pyx_abaqus"] = "abaqus"
42
43 try:
44 # Import PyCODAC to build library locally during setup.
45 from PyCODAC.Tools.Utility import GetPyCODACPath
46 # Import and set local path to PyCODAC
47 __mcd_core_path = os.path.join(GetPyCODACPath(),"Core")
48 except ImportError:
49 # This script is not executed as plug-in
50 __mcd_core_path = ""
51 except:
52 # Something else went wrong.
53 from PyXMake.Tools import ErrorHandling
54 ErrorHandling.InputError(20)
55
56 def main(
57 BuildID,
58 # Build MCODAC for ABAQUS Standard by default
59 files="mcd_astandard",
60 command = VTL.GetBuildCommand(6),
61 libs = 'mcd_corex64',
62 # Resource paths
63 source=os.path.join(__mcd_core_path,"solver"),
64 include=list(Utility.ArbitraryFlattening([[os.path.join(__mcd_core_path,"include",Utility.GetPlatform(),__arch)],
65 [os.path.join(__mcd_core_path,"include",Utility.GetPlatform(),__arch, x) for x in VTL.GetIncludeDirectory(__mcd_core_path, 0, 4, __arch)]])),
66 dependency=os.path.join(__mcd_core_path,"lib",Utility.GetPlatform(),__arch),
67 output=os.path.join(__mcd_core_path,"bin",Utility.GetPlatform(),__arch),
68 # Verbose and scratch directory
69 scratch=VTL.Scratch, verbosity=1):
70 """
71 Main function to execute the script.
72 """
73 # Build a shared library for Abaqus using the Intel Fortran Compiler
74 ABQBuild = pyx.Custom(BuildID, files, scratch=scratch, msvsc="vs2015", arch=__arch, verbose=verbosity)
75 ABQBuild.SourcePath(source)
76 ABQBuild.AddIncludePath(include)
77 ABQBuild.AddDependencyPath(dependency)
78 ABQBuild.OutputPath(output, files=["standardU.dll","explicitU-D.dll"])
79 ABQBuild.Preprocessing('fpp -P -e', inend='.f', outend='.for')
80 ABQBuild.UseLibraries(libs)
81 ABQBuild.Build(command)
82 ABQBuild.create()
83
84 if __name__ == "__main__":
85 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 # % Access command line inputs %
87 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 parser = argparse.ArgumentParser(description="Build a static Fortran library remotely on the institute cluster")
89 parser.add_argument("source_path", metavar="source", nargs=1, help="Directory containing all source files")
90 parser.add_argument("feature_path", metavar="feature", nargs=1, help="Directory containing the feature source file \
91 (in dependence of requested feature: ABAQUS, ANSYS, NASTRAN.")
92
93 try:
94 _ = sys.argv[1]
95 args, _ = parser.parse_known_args()
96 # Extract command line option to identify the requested make operation
97 make_opt = args.make[0]
98 except:
99 # This is the default build option
100 make_opt = -1
101 # Build all supported features
102 if make_opt == -1:
103 # Temporary ID during the build process.
104 BuildID = 'mcd_abaqus'
105 main(BuildID,"mcd_astandard"); main(BuildID,"mcd_aexplicit")
106 else:
107 # This is not implemented yet
108 raise NotImplementedError
109
110 # Finish
111 print('==================================')
112 print('Finished build for ABAQUS')
113 print('==================================')
114 sys.exit()
PyXMake.Tools
Module containing basic functionalities defined for convenience.
Definition: __init__.py:1
PyXMake.Build
Module containing all relevant modules and scripts associated with the building process.
Definition: __init__.py:1
PyXMake.VTL.abaqus.main
def main(BuildID, files="mcd_astandard", command=VTL.GetBuildCommand(6), libs='mcd_corex64', source=os.path.join(__mcd_core_path,"solver"), include=list(Utility.ArbitraryFlattening([[os.path.join(__mcd_core_path,"include", Utility.GetPlatform(), __arch)], [os.path.join(__mcd_core_path,"include", Utility.GetPlatform(), __arch, x) for x in VTL.GetIncludeDirectory(__mcd_core_path, 0, 4, __arch)]])), dependency=os.path.join(__mcd_core_path,"lib", Utility.GetPlatform(), __arch), output=os.path.join(__mcd_core_path,"bin", Utility.GetPlatform(), __arch), scratch=VTL.Scratch, verbosity=1)
Definition: abaqus.py:69