OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

tractionDisplacementCorrectionFvPatchVectorField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "tractionDisplacementCorrectionFvPatchVectorField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "volFields.H"
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 
00036 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00037 
00038 tractionDisplacementCorrectionFvPatchVectorField::
00039 tractionDisplacementCorrectionFvPatchVectorField
00040 (
00041     const fvPatch& p,
00042     const DimensionedField<vector, volMesh>& iF
00043 )
00044 :
00045     fixedGradientFvPatchVectorField(p, iF),
00046     traction_(p.size(), vector::zero),
00047     pressure_(p.size(), 0.0)
00048 {
00049     fvPatchVectorField::operator=(patchInternalField());
00050     gradient() = vector::zero;
00051 }
00052 
00053 
00054 tractionDisplacementCorrectionFvPatchVectorField::
00055 tractionDisplacementCorrectionFvPatchVectorField
00056 (
00057     const tractionDisplacementCorrectionFvPatchVectorField& tdpvf,
00058     const fvPatch& p,
00059     const DimensionedField<vector, volMesh>& iF,
00060     const fvPatchFieldMapper& mapper
00061 )
00062 :
00063     fixedGradientFvPatchVectorField(tdpvf, p, iF, mapper),
00064     traction_(tdpvf.traction_, mapper),
00065     pressure_(tdpvf.pressure_, mapper)
00066 {}
00067 
00068 
00069 tractionDisplacementCorrectionFvPatchVectorField::
00070 tractionDisplacementCorrectionFvPatchVectorField
00071 (
00072     const fvPatch& p,
00073     const DimensionedField<vector, volMesh>& iF,
00074     const dictionary& dict
00075 )
00076 :
00077     fixedGradientFvPatchVectorField(p, iF),
00078     traction_("traction", dict, p.size()),
00079     pressure_("pressure", dict, p.size())
00080 {
00081     fvPatchVectorField::operator=(patchInternalField());
00082     gradient() = vector::zero;
00083 }
00084 
00085 
00086 tractionDisplacementCorrectionFvPatchVectorField::
00087 tractionDisplacementCorrectionFvPatchVectorField
00088 (
00089     const tractionDisplacementCorrectionFvPatchVectorField& tdpvf
00090 )
00091 :
00092     fixedGradientFvPatchVectorField(tdpvf),
00093     traction_(tdpvf.traction_),
00094     pressure_(tdpvf.pressure_)
00095 {}
00096 
00097 
00098 tractionDisplacementCorrectionFvPatchVectorField::
00099 tractionDisplacementCorrectionFvPatchVectorField
00100 (
00101     const tractionDisplacementCorrectionFvPatchVectorField& tdpvf,
00102     const DimensionedField<vector, volMesh>& iF
00103 )
00104 :
00105     fixedGradientFvPatchVectorField(tdpvf, iF),
00106     traction_(tdpvf.traction_),
00107     pressure_(tdpvf.pressure_)
00108 {}
00109 
00110 
00111 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00112 
00113 void tractionDisplacementCorrectionFvPatchVectorField::autoMap
00114 (
00115     const fvPatchFieldMapper& m
00116 )
00117 {
00118     fixedGradientFvPatchVectorField::autoMap(m);
00119     traction_.autoMap(m);
00120     pressure_.autoMap(m);
00121 }
00122 
00123 
00124 // Reverse-map the given fvPatchField onto this fvPatchField
00125 void tractionDisplacementCorrectionFvPatchVectorField::rmap
00126 (
00127     const fvPatchVectorField& ptf,
00128     const labelList& addr
00129 )
00130 {
00131     fixedGradientFvPatchVectorField::rmap(ptf, addr);
00132 
00133     const tractionDisplacementCorrectionFvPatchVectorField& dmptf =
00134         refCast<const tractionDisplacementCorrectionFvPatchVectorField>(ptf);
00135 
00136     traction_.rmap(dmptf.traction_, addr);
00137     pressure_.rmap(dmptf.pressure_, addr);
00138 }
00139 
00140 
00141 // Update the coefficients associated with the patch field
00142 void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
00143 {
00144     if (updated())
00145     {
00146         return;
00147     }
00148 
00149     const dictionary& mechanicalProperties = db().lookupObject<IOdictionary>
00150     (
00151         "mechanicalProperties"
00152     );
00153 
00154     dimensionedScalar rho(mechanicalProperties.lookup("rho"));
00155     dimensionedScalar rhoE(mechanicalProperties.lookup("E"));
00156     dimensionedScalar nu(mechanicalProperties.lookup("nu"));
00157 
00158     dimensionedScalar E = rhoE/rho;
00159     dimensionedScalar mu = E/(2.0*(1.0 + nu));
00160     dimensionedScalar lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu));
00161 
00162     Switch planeStress(mechanicalProperties.lookup("planeStress"));
00163 
00164     if (planeStress)
00165     {
00166         lambda = nu*E/((1.0 + nu)*(1.0 - nu));
00167     }
00168 
00169     vectorField n = patch().nf();
00170 
00171     const fvPatchField<symmTensor>& sigmaD =
00172         patch().lookupPatchField<volSymmTensorField, symmTensor>("sigmaD");
00173 
00174     const fvPatchField<tensor>& sigmaExp = 
00175         patch().lookupPatchField<volTensorField, tensor>("sigmaExp");
00176 
00177     gradient() =
00178     (
00179         (traction_ + pressure_*n)/rho.value() - (n & (sigmaD + sigmaExp))
00180     )/(2.0*mu + lambda).value();
00181 
00182     fixedGradientFvPatchVectorField::updateCoeffs();
00183 }
00184 
00185 
00186 // Write
00187 void tractionDisplacementCorrectionFvPatchVectorField::write(Ostream& os) const
00188 {
00189     fvPatchVectorField::write(os);
00190     traction_.writeEntry("traction", os);
00191     pressure_.writeEntry("pressure", os);
00192     writeEntry("value", os);
00193 }
00194 
00195 
00196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00197 
00198 makePatchTypeField
00199 (
00200     fvPatchVectorField,
00201     tractionDisplacementCorrectionFvPatchVectorField
00202 );
00203 
00204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00205 
00206 } // End namespace Foam
00207 
00208 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd