tractionDisplacementFvPatchVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v4
5 
6  This file is modified from OpenFOAM's source code
7  applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/
8  tractionDisplacementFvPatchVectorField.C
9 
10  OpenFOAM: The Open Source CFD Toolbox
11 
12  Copyright (C): 2011-2016 OpenFOAM Foundation
13 
14  OpenFOAM License:
15 
16  OpenFOAM is free software: you can redistribute it and/or modify it
17  under the terms of the GNU General Public License as published by
18  the Free Software Foundation, either version 3 of the License, or
19  (at your option) any later version.
20 
21  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
22  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  for more details.
25 
26  You should have received a copy of the GNU General Public License
27  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 
29 \*---------------------------------------------------------------------------*/
30 
32 #include "addToRunTimeSelectionTable.H"
33 #include "volFields.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
44  const fvPatch& p,
45  const DimensionedField<vector, volMesh>& iF)
46  : fixedGradientFvPatchVectorField(p, iF)
47 {
48 }
49 
53  const fvPatch& p,
54  const DimensionedField<vector, volMesh>& iF,
55  const fvPatchFieldMapper& mapper)
56  : fixedGradientFvPatchVectorField(tdpvf, p, iF, mapper)
57 {
58 }
59 
62  const fvPatch& p,
63  const DimensionedField<vector, volMesh>& iF,
64  const dictionary& dict)
65  : fixedGradientFvPatchVectorField(p, iF),
66  traction_("traction", dict, p.size()),
67  pressure_("pressure", dict, p.size())
68 {
69  fvPatchVectorField::operator=(patchInternalField());
70  gradient() = Zero;
71 }
72 
76  : fixedGradientFvPatchVectorField(tdpvf)
77 {
78 }
79 
83  const DimensionedField<vector, volMesh>& iF)
84  : fixedGradientFvPatchVectorField(tdpvf, iF)
85 {
86 }
87 
88 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90 {
91  if (updated())
92  {
93  return;
94  }
95 
96  const fvPatchField<scalar>& rho =
97  patch().lookupPatchField<volScalarField, scalar>("solid:rho");
98 
99  const fvPatchField<scalar>& lambda =
100  patch().lookupPatchField<volScalarField, scalar>("solid:lambda");
101 
102  const fvPatchField<scalar>& mu =
103  patch().lookupPatchField<volScalarField, scalar>("solid:mu");
104 
105  const fvPatchField<tensor>& gradD =
106  patch().lookupPatchField<volTensorField, tensor>("gradD");
107 
108  // here we use the BC implementation from:
109  // Tang, Tian: Implementation of solid body stress analysis in OpenFOAM, 2013
110  vectorField n(patch().nf());
111  gradient() = ((traction_ - pressure_ * n) / rho
112  - (n & (mu * gradD.T() - (mu + lambda) * gradD))
113  - n * tr(gradD) * lambda)
114  / (2.0 * mu + lambda);
115 
116  fixedGradientFvPatchVectorField::updateCoeffs();
117 }
118 
120 {
121  fvPatchVectorField::write(os);
122  traction_.writeEntry("traction", os);
123  pressure_.writeEntry("pressure", os);
124  writeEntry("value", os);
125 }
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
130  fvPatchVectorField,
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 } // End namespace Foam
136 
137 // ************************************************************************* //
mu
volScalarField & mu
Definition: createRefsSolidDisplacement.H:6
Foam::tractionDisplacementFvPatchVectorField::tractionDisplacementFvPatchVectorField
tractionDisplacementFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Definition: tractionDisplacementFvPatchVectorField.C:43
p
volScalarField & p
Definition: createRefsPimpleDyM.H:6
Foam::tractionDisplacementFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Definition: tractionDisplacementFvPatchVectorField.C:89
Foam
Definition: checkGeometry.C:32
Foam::tractionDisplacementFvPatchVectorField
Definition: tractionDisplacementFvPatchVectorField.H:50
Foam::tractionDisplacementFvPatchVectorField::write
virtual void write(Ostream &) const
Definition: tractionDisplacementFvPatchVectorField.C:119
rho
volScalarField & rho
Definition: createRefsRhoPimple.H:8
gradD
volTensorField & gradD
Definition: createRefsSolidDisplacement.H:9
tractionDisplacementFvPatchVectorField.H
lambda
volScalarField & lambda
Definition: createRefsSolidDisplacement.H:7
Foam::makePatchTypeField
makePatchTypeField(fvPatchScalarField, fixedWallHeatFluxFvPatchScalarField)