File size: 7,039 Bytes
985c397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# ***************************************************************************
# *   Copyright (c) 2021 Bernd Hahnebach <bernd@bimstatik.org>              *
# *                                                                         *
# *   This file is part of the FreeCAD CAx development system.              *
# *                                                                         *
# *   This program is free software; you can redistribute it and/or modify  *
# *   it under the terms of the GNU Lesser General Public License (LGPL)    *
# *   as published by the Free Software Foundation; either version 2 of     *
# *   the License, or (at your option) any later version.                   *
# *   for detail see the LICENCE text file.                                 *
# *                                                                         *
# *   This program is distributed in the hope that it will be useful,       *
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
# *   GNU Library General Public License for more details.                  *
# *                                                                         *
# *   You should have received a copy of the GNU Library General Public     *
# *   License along with this program; if not, write to the Free Software   *
# *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
# *   USA                                                                   *
# *                                                                         *
# ***************************************************************************

__title__ = "FreeCAD FEM calculix write inpfile step output"
__author__ = "Bernd Hahnebach"
__url__ = "https://www.freecad.org"


def write_step_output(f, ccxwriter):

    f.write("\n{}\n".format(59 * "*"))
    f.write("** Outputs --> frd file\n")
    if (
        ccxwriter.member.geos_beamsection
        or ccxwriter.member.geos_shellthickness
        or ccxwriter.member.geos_fluidsection
    ):
        if ccxwriter.solver_obj.BeamShellResultOutput3D is False:
            f.write("*NODE FILE, OUTPUT=2d\n")
        else:
            f.write("*NODE FILE, OUTPUT=3d\n")
    else:
        f.write("*NODE FILE\n")
    # MPH write out nodal temperatures if thermomechanical
    if ccxwriter.analysis_type == "thermomech":
        if not ccxwriter.member.geos_fluidsection:
            f.write("U, NT\n")
        else:
            f.write("MF, PS\n")
    elif ccxwriter.analysis_type == "electromagnetic":
        f.write("NT\n")
    else:
        f.write("U\n")
    if not ccxwriter.member.geos_fluidsection:
        f.write("*EL FILE\n")
        variables = "S, E"
        if ccxwriter.analysis_type == "thermomech":
            variables += ", HFL"
        if ccxwriter.solver_obj.MaterialNonlinearity == "nonlinear":
            variables += ", PEEQ"
        if ccxwriter.analysis_type == "electromagnetic":
            variables = "HFL"

        f.write(variables + "\n")

        # dat file
        if ccxwriter.member.cons_fixed or ccxwriter.member.cons_displacement:
            f.write("** outputs --> dat file\n")
        if ccxwriter.member.cons_fixed:
            # reaction forces for all Constraint fixed
            f.write("** reaction forces for Constraint fixed\n")
            for femobj in ccxwriter.member.cons_fixed:
                # femobj --> dict, FreeCAD document object is femobj["Object"]
                f.write("*NODE PRINT, NSET={}, TOTALS=ONLY\n".format(femobj["Object"].Name))
                f.write("RF\n")
        if ccxwriter.member.cons_displacement:
            # reaction forces for Constraint displacement constraining translation
            f.write("** reaction forces for Constraint displacement constraining translation\n")
            for femobj in ccxwriter.member.cons_displacement:
                # femobj --> dict, FreeCAD document object is femobj["Object"]
                if (
                    not femobj["Object"].xFree
                    or not femobj["Object"].yFree
                    or not femobj["Object"].zFree
                ):
                    f.write("*NODE PRINT, NSET={}, TOTALS=ONLY\n".format(femobj["Object"].Name))
                    f.write("RF\n")
        if ccxwriter.member.cons_rigidbody:
            # displacements and reaction forces/moments for Constraint rigid body
            f.write("** displacements and reaction forces/moments for Constraint rigid body\n")
            for femobj in ccxwriter.member.cons_rigidbody:
                # femobj --> dict, FreeCAD document object is femobj["Object"]
                f.write("*NODE PRINT, NSET={}_RefNode\n".format(femobj["Object"].Name))
                f.write("U\n")
                f.write("*NODE PRINT, NSET={}_RotNode\n".format(femobj["Object"].Name))
                f.write("U\n")
                if (
                    femobj["Object"].TranslationalModeX != "Free"
                    or femobj["Object"].TranslationalModeY != "Free"
                    or femobj["Object"].TranslationalModeZ != "Free"
                ):
                    f.write(
                        "*NODE PRINT, NSET={}_RefNode, TOTALS=ONLY\n".format(femobj["Object"].Name)
                    )
                    f.write("RF\n")
                if (
                    femobj["Object"].RotationalModeX != "Free"
                    or femobj["Object"].RotationalModeY != "Free"
                    or femobj["Object"].RotationalModeZ != "Free"
                ):
                    f.write(
                        "*NODE PRINT, NSET={}_RotNode, TOTALS=ONLY\n".format(femobj["Object"].Name)
                    )
                    f.write("RF\n")
        if ccxwriter.member.cons_contact:
            # contact forces for all Constraint contact (only available for face-to-face penalty contact)
            f.write("** contact forces for Constraint contact\n")
            for femobj in ccxwriter.member.cons_contact:
                # femobj --> dict, FreeCAD document object is femobj["Object"]
                f.write(
                    "*CONTACT PRINT, MASTER={}, SLAVE={}\n".format(
                        "IND" + femobj["Object"].Name, "DEP" + femobj["Object"].Name
                    )
                )
                f.write("CF, CFN, CFS\n")
        if any(
            vars(ccxwriter.member).get(f"cons_{key}")
            for key in ["fixed", "displacement", "rigidbody", "contact"]
        ):
            f.write("\n")
        f.write(f"*OUTPUT, FREQUENCY={ccxwriter.solver_obj.OutputFrequency}")

        # there is no need to write all integration point results
        # as long as there is no reader for them
        # see https://forum.freecad.org/viewtopic.php?f=18&t=29060
        # f.write("*NODE PRINT , NSET=" + ccxwriter.ccx_nall + "\n")
        # f.write("U \n")
        # f.write("*EL PRINT , ELSET=" + ccxwriter.ccx_eall + "\n")
        # f.write("S \n")