From 3d434390722c221411f7943bdc040fbf0755628d Mon Sep 17 00:00:00 2001 From: graham Date: Thu, 13 May 2010 16:00:42 +0100 Subject: [PATCH 1/4] ENH: Better output formatting, directly outputting sixDoFRigidBodyDisplacement BC entries. --- .../surface/surfaceInertia/surfaceInertia.C | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/applications/utilities/surface/surfaceInertia/surfaceInertia.C b/applications/utilities/surface/surfaceInertia/surfaceInertia.C index 0819c4bbb6..c68608feda 100644 --- a/applications/utilities/surface/surfaceInertia/surfaceInertia.C +++ b/applications/utilities/surface/surfaceInertia/surfaceInertia.C @@ -591,18 +591,27 @@ int main(int argc, char *argv[]) if (showTransform) { - Info<< "Transform tensor from reference state (Q). " << nl + Info<< "Transform tensor from reference state (orientation):" << nl + << eVec.T() << nl << "Rotation tensor required to transform " "from the body reference frame to the global " "reference frame, i.e.:" << nl - << "globalVector = Q & bodyLocalVector" - << nl << eVec.T() + << "globalVector = orientation & bodyLocalVector" + << endl; + + Info<< nl + << "Entries for sixDoFRigidBodyDisplacement boundary condition:" + << nl + << " mass " << m << token::END_STATEMENT << nl + << " centreOfMass " << cM << token::END_STATEMENT << nl + << " momentOfInertia " << eVal << token::END_STATEMENT << nl + << " orientation " << eVec.T() << token::END_STATEMENT << endl; } if (calcAroundRefPt) { - Info << "Inertia tensor relative to " << refPt << ": " + Info<< nl << "Inertia tensor relative to " << refPt << ": " << nl << applyParallelAxisTheorem(m, cM, J, refPt) << endl; } From 4107c09b8a6add0a42dd1c3ae49c1cd8e111c5d9 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 14 May 2010 12:39:07 +0100 Subject: [PATCH 2/4] BUG: aded missing dt in COxidationKineticDiffusionLimitedRate model --- .../COxidationKineticDiffusionLimitedRate.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationKineticDiffusionLimitedRate/COxidationKineticDiffusionLimitedRate.C b/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationKineticDiffusionLimitedRate/COxidationKineticDiffusionLimitedRate.C index f6f7b79c9a..3fb7d18879 100644 --- a/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationKineticDiffusionLimitedRate/COxidationKineticDiffusionLimitedRate.C +++ b/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationKineticDiffusionLimitedRate/COxidationKineticDiffusionLimitedRate.C @@ -140,7 +140,7 @@ Foam::scalar Foam::COxidationKineticDiffusionLimitedRate::calculate const scalar Ap = constant::mathematical::pi*sqr(d); // Change in C mass [kg] - scalar dmC = Ap*rhoc*specie::RR*Tc*YO2/WO2_*D0*Rk/(D0 + Rk); + scalar dmC = Ap*rhoc*specie::RR*Tc*YO2/WO2_*D0*Rk/(D0 + Rk)*dt; // Limit mass transfer by availability of C dmC = min(mass*fComb, dmC); From 1638a4ac2f6fd19d5c027428be69c8536d14cbc5 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 14 May 2010 12:39:39 +0100 Subject: [PATCH 3/4] STYLE: enforcing 80 chars width --- .../COxidationDiffusionLimitedRate.C | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationDiffusionLimitedRate/COxidationDiffusionLimitedRate.C b/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationDiffusionLimitedRate/COxidationDiffusionLimitedRate.C index 67bd87f76b..71e40a0a64 100644 --- a/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationDiffusionLimitedRate/COxidationDiffusionLimitedRate.C +++ b/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationDiffusionLimitedRate/COxidationDiffusionLimitedRate.C @@ -123,7 +123,8 @@ Foam::scalar Foam::COxidationDiffusionLimitedRate::calculate const scalar YO2 = this->owner().mcCarrierThermo().Y(O2GlobalId_)[cellI]; // Change in C mass [kg] - scalar dmC = 4.0*constant::mathematical::pi*d*D_*YO2*Tc*rhoc/(Sb_*(T + Tc))*dt; + scalar dmC = + 4.0*constant::mathematical::pi*d*D_*YO2*Tc*rhoc/(Sb_*(T + Tc))*dt; // Limit mass transfer by availability of C dmC = min(mass*fComb, dmC); From 4b00c01d0c85b09da60a856feaabf08ae961aabd Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 14 May 2010 12:47:32 +0100 Subject: [PATCH 4/4] ENH: added interpolateSplineXY templated function, and updated tabulated6DoFMotion --- .../interpolateSplineXY/interpolateSplineXY.C | 126 ++++++++++++++++++ .../interpolateSplineXY/interpolateSplineXY.H | 84 ++++++++++++ .../tabulated6DoFMotion/tabulated6DoFMotion.C | 4 +- 3 files changed, 212 insertions(+), 2 deletions(-) create mode 100644 src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.C create mode 100644 src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.H diff --git a/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.C b/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.C new file mode 100644 index 0000000000..2fa74142cd --- /dev/null +++ b/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.C @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "interpolateSplineXY.H" +#include "primitiveFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +Foam::Field Foam::interpolateSplineXY +( + const scalarField& xNew, + const scalarField& xOld, + const Field& yOld +) +{ + Field yNew(xNew.size()); + + forAll(xNew, i) + { + yNew[i] = interpolateSmoothXY(xNew[i], xOld, yOld); + } + + return yNew; +} + + +template +Type Foam::interpolateSplineXY +( + const scalar x, + const scalarField& xOld, + const Field& yOld +) +{ + label n = xOld.size(); + + // early exit if out of bounds or only one value + if (n == 1 || x < xOld[0]) + { + return yOld[0]; + } + if (x > xOld[n - 1]) + { + return yOld[n - 1]; + } + + // linear interpolation if only two values + if (n == 2) + { + return (x - xOld[0])/(xOld[1] - xOld[0])*(yOld[1] - yOld[0]) + yOld[0]; + } + + // find bounding knots + label hi = 0; + while (hi < n && xOld[hi] < x) + { + hi++; + } + + label lo = hi - 1; + + const Type& y1 = yOld[lo]; + const Type& y2 = yOld[hi]; + + Type y0; + if (lo == 0) + { + y0 = 2*y1 - y2; + } + else + { + y0 = yOld[lo - 1]; + } + + Type y3; + if (hi + 1 == n) + { + y3 = 2*y2 - y1; + } + else + { + y3 = yOld[hi + 1]; + } + + // weighting + scalar mu = (x - xOld[lo])/(xOld[hi] - xOld[lo]); + + // interpolate + return + 0.5 + *( + 2*y1 + + mu + *( + -y0 + y2 + + mu*((2*y0 - 5*y1 + 4*y2 - y3) + mu*(-y0 + 3*y1 - 3*y2 + y3)) + ) + ); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.H b/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.H new file mode 100644 index 0000000000..7d06169ea8 --- /dev/null +++ b/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.H @@ -0,0 +1,84 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +InNamespace + Foam + +Description + Interpolates y values from one curve to another with a different x + distribution. + + Uses Catmull-Rom spline interpolation between points. + +SourceFiles + interpolateSplineXY.C + +\*---------------------------------------------------------------------------*/ + +#ifndef interpolateSplineXY_H +#define interpolateSplineXY_H + +#include "scalar.H" +#include "primitiveFieldsFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +Field interpolateSplineXY +( + const scalarField& xNew, + const scalarField& xOld, + const Field& yOld +); + + +template +Type interpolateSplineXY +( + const scalar x, + const scalarField& xOld, + const Field& yOld +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "interpolateSplineXY.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/tabulated6DoFMotion/tabulated6DoFMotion.C b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/tabulated6DoFMotion/tabulated6DoFMotion.C index b4d6bf06d2..38ef552948 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/tabulated6DoFMotion/tabulated6DoFMotion.C +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/tabulated6DoFMotion/tabulated6DoFMotion.C @@ -27,7 +27,7 @@ License #include "addToRunTimeSelectionTable.H" #include "Tuple2.H" #include "IFstream.H" -#include "interpolateXY.H" +#include "interpolateSplineXY.H" #include "mathematicalConstants.H" using namespace Foam::constant::mathematical; @@ -98,7 +98,7 @@ Foam::solidBodyMotionFunctions::tabulated6DoFMotion::transformation() const << exit(FatalError); } - translationRotationVectors TRV = interpolateXY + translationRotationVectors TRV = interpolateSplineXY ( t, times_,