Remove trailing whitespace systematically
[foam-extend-3.2.git] / applications / solvers / solidMechanics / elasticOrthoAcpSolidFoam / createCrack.H
blobaa796b3b322c27500317a4863845da462944a80b
1     label cohesivePatchID = -1;
3    solidCohesiveFvPatchVectorField* cohesivePatchUPtr = NULL;
4    solidCohesiveFixedModeMixFvPatchVectorField* cohesivePatchUFixedModePtr = NULL;
6     forAll (U.boundaryField(), patchI)
7     {
8       if (isA<solidCohesiveFvPatchVectorField>(U.boundaryField()[patchI]))
9         {
10           cohesivePatchID = patchI;
11           cohesivePatchUPtr =
12             &refCast<solidCohesiveFvPatchVectorField>
13             (
14              U.boundaryField()[cohesivePatchID]
15              );
16           break;
17         }
18       else if (isA<solidCohesiveFixedModeMixFvPatchVectorField>(U.boundaryField()[patchI]))
19         {
20           cohesivePatchID = patchI;
21           cohesivePatchUFixedModePtr =
22             &refCast<solidCohesiveFixedModeMixFvPatchVectorField>
23             (
24              U.boundaryField()[cohesivePatchID]
25              );
26           break;
27         }
28     }
30     if(cohesivePatchID == -1)
31     {
32         FatalErrorIn(args.executable())
33             << "Can't find cohesiveLawFvPatch" << nl
34             << "One of the boundary patches in " << U.name() << ".boundaryField() "
35             << "should be of type " << solidCohesiveFvPatchVectorField::typeName
36             << "or " << solidCohesiveFixedModeMixFvPatchVectorField::typeName
37             << abort(FatalError);
38     }
40     // solidCohesiveFvPatchVectorField& cohesivePatchU =
41     //  refCast<solidCohesiveFvPatchVectorField>
42     //  (
43     //   U.boundaryField()[cohesivePatchID]
44     //     );
46    // philipc: I have moved cohesive stuff to constitutiveModel
47    // cohesiveZone is an index field
48    // which allows the user to limit the crack to certain areas at runtime
49    // 1 for faces within cohesiveZone
50    // 0 for faces outside cohesiveZone
51     surfaceScalarField cohesiveZone
52     (
53         IOobject
54         (
55             "cohesiveZone",
56             runTime.timeName(),
57             mesh,
58             IOobject::READ_IF_PRESENT,
59             IOobject::AUTO_WRITE
60         ),
61         mesh,
62         dimensionedScalar("zero", dimless, 0.0)
63      );
65     // limit crack to specified boxes
66     {
67       const dictionary& stressControl =
68         mesh.solutionDict().subDict("solidMechanics");
70       List<boundBox> userBoxes(stressControl.lookup("crackLimitingBoxes"));
71       const surfaceVectorField& Cf = mesh.Cf();
72       forAll(cohesiveZone.internalField(), faceI)
73         {
74           bool faceInsideBox = false;
76           forAll(userBoxes, boxi)
77             {
78               if(userBoxes[boxi].contains(Cf.internalField()[faceI])) faceInsideBox = true;
79             }
81           if(faceInsideBox)
82             {
83               cohesiveZone.internalField()[faceI] = 1.0;
84             }
85         }
87       forAll(cohesiveZone.boundaryField(), patchI)
88         {
89           // cracks may go along proc boundaries
90           if(mesh.boundaryMesh()[patchI].type() == processorPolyPatch::typeName)
91             {
92               forAll(cohesiveZone.boundaryField()[patchI], faceI)
93                 {
94                   bool faceInsideBox = false;
96                   forAll(userBoxes, boxi)
97                     {
98                       if(userBoxes[boxi].contains(Cf.boundaryField()[patchI][faceI])) faceInsideBox = true;
99                     }
101                   if(faceInsideBox)
102                     {
103                       cohesiveZone.boundaryField()[patchI][faceI] = 1.0;
104                     }
105                 }
106             }
107         }
109       Info << "\nThere are " << gSum(cohesiveZone.internalField()) << " potential internal crack faces" << nl << endl;
110       Info << "\nThere are " << gSum(cohesiveZone.boundaryField())/2 << " potential coupled boundary crack faces" << nl << endl;
112       // write field for visualisation
113       volScalarField cohesiveZoneVol
114         (
115          IOobject
116          (
117           "cohesiveZoneVol",
118           runTime.timeName(),
119           mesh,
120           IOobject::NO_READ,
121           IOobject::AUTO_WRITE
122           ),
123          mesh,
124          dimensionedScalar("zero", dimless, 0.0)
125          );
126       forAll(cohesiveZone.internalField(), facei)
127         {
128           if(cohesiveZone.internalField()[facei])
129             {
130               cohesiveZoneVol.internalField()[mesh.owner()[facei]] = 1.0;
131               cohesiveZoneVol.internalField()[mesh.neighbour()[facei]] = 1.0;
132             }
133         }
134       forAll(cohesiveZone.boundaryField(), patchi)
135         {
136           forAll(cohesiveZone.boundaryField()[patchi], facei)
137             {
138               if(cohesiveZone.boundaryField()[patchi][facei] > 0.0)
139                 {
140                   cohesiveZoneVol.boundaryField()[patchi][facei] = 1.0;
141                 }
142             }
143         }
144       Info << "Writing cohesiveZone field" << endl;
145       cohesiveZoneVol.write();
146     }
149     Switch initialiseSolution(false);
151     if
152     (
153         mesh.solutionDict().subDict("solidMechanics")
154        .found("initialiseSolution")
155     )
156     {
157         initialiseSolution =
158             Switch
159             (
160                 mesh.solutionDict().subDict("solidMechanics").lookup
161                 (
162                     "initialiseSolution"
163                 )
164             );
165     }
168     Switch breakOnlyOneFacePerTopologyChange(true);
170     if
171     (
172         mesh.solutionDict().subDict("solidMechanics")
173        .found("breakOnlyOneFacePerTopologyChange")
174     )
175     {
176         breakOnlyOneFacePerTopologyChange =
177             Switch
178             (
179                 mesh.solutionDict().subDict("solidMechanics").lookup
180                 (
181                     "breakOnlyOneFacePerTopologyChange"
182                 )
183             );
184     }
187     Switch crackPropagationFromSpecifiedPatches
188     (
189         mesh.solutionDict().subDict("solidMechanics").lookup
190         (
191             "crackPropagationFromSpecifiedPatches"
192         )
193     );
195     wordList crackPropagationPatchNames
196     (
197         mesh.solutionDict().subDict("solidMechanics").lookup
198         (
199             "crackPropagationPatches"
200         )
201     );
203     labelList crackPropagationPatches(crackPropagationPatchNames.size(), -1);
205     forAll(crackPropagationPatchNames, patchI)
206     {
207         crackPropagationPatches[patchI] =
208             mesh.boundaryMesh().findPatchID
209             (
210                 crackPropagationPatchNames[patchI]
211             );
213         if(crackPropagationPatches[patchI] == -1)
214         {
215             FatalErrorIn(args.executable())
216                 << "Can't find " << crackPropagationPatchNames[patchI]
217                 << " patch" << abort(FatalError);
218         }
219     }
221     // Internal faces next to selected crack propagation patches
222     labelList crackPropagationPatchesInternalFaces;
224 #   include "updateCrackPropagationPatchesInternalFaces.H"