BUGFIX: Uninitialised member variables
[foam-extend-3.2.git] / applications / solvers / solidMechanics / elasticAcpSolidFoam / createCrack.H
blob2bbfe17eb33b3a863ca774a40af2af506febeebd
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     //     );
45     
46    // philipc: I have moved cohesive stuff to constitutiveModel
48    // cohesiveZone is an index field
49    // which allows the user to limit the crack to certain areas at runtime
50    // 1 for faces within cohesiveZone
51    // 0 for faces outside cohesiveZone
52     surfaceScalarField cohesiveZone
53     (
54         IOobject
55         (
56             "cohesiveZone",
57             runTime.timeName(),
58             mesh,
59             IOobject::READ_IF_PRESENT,
60             IOobject::AUTO_WRITE
61         ),
62         mesh,
63         dimensionedScalar("zero", dimless, 0.0)
64      );
66     // limit crack to specified boxes
67     {
68       const dictionary& stressControl =
69         mesh.solutionDict().subDict("solidMechanics");
70       
71       List<boundBox> userBoxes(stressControl.lookup("crackLimitingBoxes"));
72       const surfaceVectorField& Cf = mesh.Cf();
73       forAll(cohesiveZone.internalField(), faceI)
74         {
75           bool faceInsideBox = false;
76           
77           forAll(userBoxes, boxi)
78             {
79               if(userBoxes[boxi].contains(Cf.internalField()[faceI])) faceInsideBox = true;
80             }
81           
82           if(faceInsideBox)
83             {
84               cohesiveZone.internalField()[faceI] = 1.0;
85             }
86         }
88       forAll(cohesiveZone.boundaryField(), patchI)
89         {
90           // cracks may go along proc boundaries
91           if(mesh.boundaryMesh()[patchI].type() == processorPolyPatch::typeName)
92             {
93               forAll(cohesiveZone.boundaryField()[patchI], faceI)
94                 {
95                   bool faceInsideBox = false;
96                   
97                   forAll(userBoxes, boxi)
98                     {
99                       if(userBoxes[boxi].contains(Cf.boundaryField()[patchI][faceI])) faceInsideBox = true;
100                     }
101                   
102                   if(faceInsideBox)
103                     {
104                       cohesiveZone.boundaryField()[patchI][faceI] = 1.0;
105                     }
106                 }
107             }
108         }
110       Info << "\nThere are " << gSum(cohesiveZone.internalField()) << " potential internal crack faces" << nl << endl;
111       Info << "\nThere are " << gSum(cohesiveZone.boundaryField())/2 << " potential coupled boundary crack faces" << nl << endl;
113       // write field for visualisation
114       volScalarField cohesiveZoneVol
115         (
116          IOobject
117          (
118           "cohesiveZoneVol",
119           runTime.timeName(),
120           mesh,
121           IOobject::NO_READ,
122           IOobject::AUTO_WRITE
123           ),
124          mesh,
125          dimensionedScalar("zero", dimless, 0.0)
126          );
127       forAll(cohesiveZone.internalField(), facei)
128         {
129           if(cohesiveZone.internalField()[facei])
130             {
131               cohesiveZoneVol.internalField()[mesh.owner()[facei]] = 1.0;
132               cohesiveZoneVol.internalField()[mesh.neighbour()[facei]] = 1.0;
133             }
134         }
135       forAll(cohesiveZone.boundaryField(), patchi)
136         {
137           forAll(cohesiveZone.boundaryField()[patchi], facei)
138             {
139               if(cohesiveZone.boundaryField()[patchi][facei] > 0.0)
140                 {
141                   cohesiveZoneVol.boundaryField()[patchi][facei] = 1.0;
142                 }
143             }
144         }
145       Info << "Writing cohesiveZone field" << endl;
146       cohesiveZoneVol.write();
147     }
150     Switch initialiseSolution(false);
152     if 
153     (
154         mesh.solutionDict().subDict("solidMechanics")
155        .found("initialiseSolution")
156     )
157     {
158         initialiseSolution =
159             Switch
160             (
161                 mesh.solutionDict().subDict("solidMechanics").lookup
162                 (
163                     "initialiseSolution"
164                 )
165             );
166     }
169     Switch breakOnlyOneFacePerTopologyChange(true);
171     if 
172     (
173         mesh.solutionDict().subDict("solidMechanics")
174        .found("breakOnlyOneFacePerTopologyChange")
175     )
176     {
177         breakOnlyOneFacePerTopologyChange =
178             Switch
179             (
180                 mesh.solutionDict().subDict("solidMechanics").lookup
181                 (
182                     "breakOnlyOneFacePerTopologyChange"
183                 )
184             );
185     }
188     Switch crackPropagationFromSpecifiedPatches
189     (
190         mesh.solutionDict().subDict("solidMechanics").lookup
191         (
192             "crackPropagationFromSpecifiedPatches"
193         )
194     );
196     wordList crackPropagationPatchNames
197     (
198         mesh.solutionDict().subDict("solidMechanics").lookup
199         (
200             "crackPropagationPatches"
201         )
202     );
204     labelList crackPropagationPatches(crackPropagationPatchNames.size(), -1);
206     forAll(crackPropagationPatchNames, patchI)
207     {
208         crackPropagationPatches[patchI] =
209             mesh.boundaryMesh().findPatchID
210             (
211                 crackPropagationPatchNames[patchI]
212             );
214         if(crackPropagationPatches[patchI] == -1)
215         {
216             FatalErrorIn(args.executable())
217                 << "Can't find " << crackPropagationPatchNames[patchI]
218                 << " patch" << abort(FatalError);
219         }
220     }
222     // Internal faces next to selected crack propagation patches
223     labelList crackPropagationPatchesInternalFaces;
225 #   include "updateCrackPropagationPatchesInternalFaces.H"