Fixed URL for libccmio-2.6.1 (bug report #5 by Thomas Oliveira)
[foam-extend-3.2.git] / applications / solvers / solidMechanics / elasticAcpSolidFoam / createCrack.H
blob9fb081ca73c73be7440cca6c8de1941875c41ee1
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         );
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         }
136         forAll(cohesiveZone.boundaryField(), patchi)
137         {
138             forAll(cohesiveZone.boundaryField()[patchi], facei)
139             {
140                 if(cohesiveZone.boundaryField()[patchi][facei] > 0.0)
141                 {
142                     cohesiveZoneVol.boundaryField()[patchi][facei] = 1.0;
143                 }
144             }
145         }
146         Info << "Writing cohesiveZone field" << endl;
147         cohesiveZoneVol.write();
148     }
151     Switch initialiseSolution(false);
153     if
154     (
155         mesh.solutionDict().subDict("solidMechanics")
156        .found("initialiseSolution")
157     )
158     {
159         initialiseSolution =
160             Switch
161             (
162                 mesh.solutionDict().subDict("solidMechanics").lookup
163                 (
164                     "initialiseSolution"
165                 )
166             );
167     }
170     Switch breakOnlyOneFacePerTopologyChange(true);
172     if
173     (
174         mesh.solutionDict().subDict("solidMechanics")
175        .found("breakOnlyOneFacePerTopologyChange")
176     )
177     {
178         breakOnlyOneFacePerTopologyChange =
179             Switch
180             (
181                 mesh.solutionDict().subDict("solidMechanics").lookup
182                 (
183                     "breakOnlyOneFacePerTopologyChange"
184                 )
185             );
186     }
189     Switch crackPropagationFromSpecifiedPatches
190     (
191         mesh.solutionDict().subDict("solidMechanics").lookup
192         (
193             "crackPropagationFromSpecifiedPatches"
194         )
195     );
197     wordList crackPropagationPatchNames
198     (
199         mesh.solutionDict().subDict("solidMechanics").lookup
200         (
201             "crackPropagationPatches"
202         )
203     );
205     labelList crackPropagationPatches(crackPropagationPatchNames.size(), -1);
207     forAll(crackPropagationPatchNames, patchI)
208     {
209         crackPropagationPatches[patchI] =
210             mesh.boundaryMesh().findPatchID
211             (
212                 crackPropagationPatchNames[patchI]
213             );
215         if(crackPropagationPatches[patchI] == -1)
216         {
217             FatalErrorIn(args.executable())
218                 << "Can't find " << crackPropagationPatchNames[patchI]
219                 << " patch" << abort(FatalError);
220         }
221     }
223     // Internal faces next to selected crack propagation patches
224     labelList crackPropagationPatchesInternalFaces;
226 #   include "updateCrackPropagationPatchesInternalFaces.H"