From 8a2e272af97a2b44b0bdadbc7e4d36eb4cf0385e Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Wed, 10 Apr 2013 17:22:22 +0100 Subject: [PATCH] Minor-clean-up --- .../RBFInterpolation/RBFInterpolation.C | 6 ++-- .../RBFInterpolation/RBFInterpolation.H | 36 ++++++++++--------- .../RBFInterpolationTemplates.C | 18 +++++----- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/OpenFOAM/interpolations/RBFInterpolation/RBFInterpolation.C b/src/OpenFOAM/interpolations/RBFInterpolation/RBFInterpolation.C index e066fab1b..f5a5e7c76 100644 --- a/src/OpenFOAM/interpolations/RBFInterpolation/RBFInterpolation.C +++ b/src/OpenFOAM/interpolations/RBFInterpolation/RBFInterpolation.C @@ -170,11 +170,11 @@ Foam::RBFInterpolation::RBFInterpolation ( const dictionary& dict, const vectorField& controlPoints, - const vectorField& allPoints + const vectorField& dataPoints ) : controlPoints_(controlPoints), - allPoints_(allPoints), + dataPoints_(dataPoints), RBF_(RBFFunction::New(word(dict.lookup("RBF")), dict)), BPtr_(NULL), focalPoint_(dict.lookup("focalPoint")), @@ -190,7 +190,7 @@ Foam::RBFInterpolation::RBFInterpolation ) : controlPoints_(rbf.controlPoints_), - allPoints_(rbf.allPoints_), + dataPoints_(rbf.dataPoints_), RBF_(rbf.RBF_->clone()), BPtr_(NULL), focalPoint_(rbf.focalPoint_), diff --git a/src/OpenFOAM/interpolations/RBFInterpolation/RBFInterpolation.H b/src/OpenFOAM/interpolations/RBFInterpolation/RBFInterpolation.H index 592a9a769..16e3f1579 100644 --- a/src/OpenFOAM/interpolations/RBFInterpolation/RBFInterpolation.H +++ b/src/OpenFOAM/interpolations/RBFInterpolation/RBFInterpolation.H @@ -29,8 +29,8 @@ Description Radial basis function interpolation class Description - Interpolation class which uses Radial Basis Functions to interpolate the - fluid displacements for given boundary displacements. + Interpolation class which uses Radial Basis Functions to interpolate + field from given data points to arbitrary set of points. The coefficient vectors, alpha and beta are determined by solving the system: @@ -38,25 +38,17 @@ Description | db | = | Mbb Pb | | alpha | | 0 | | Pb 0 | | beta | - where db are the given boundary displacements, + where db are the given field values at data carrier points. Mbb the boundary RBF correlation matrix (NbxNb), containing RBF evaluations at the boundary nodes, and Pb some linear polynomial matrix (Nbx4). - Those coefficients are calculated every timestep, with the current - boundary displacements db, with the inverse of Mbb. Using those - coefficients, the RBF is evaluated at all fluid points every - timestep. - - The efficiency of this method is increased by: - 1) using control points which is a subset of the moving - boundary points. Those control points are selected by - a coarsening function. - 2) The outer boundary points are neglected since a cutoff function - is used toward the outer boundaries. + In cases where far field data is not of interest, a cutoff function + is used to eliminate unnecessary data points in the far field Author Frank Bos, TU Delft. All rights reserved. Dubravko Matijasevic, FSB Zagreb. + Reorganisation by Hrvoje Jasak, Wikki Ltd. SourceFiles RBFInterpolation.C @@ -90,7 +82,7 @@ class RBFInterpolation const vectorField& controlPoints_; //- Reference to all points - const vectorField& allPoints_; + const vectorField& dataPoints_; //- RBF function autoPtr RBF_; @@ -136,7 +128,7 @@ public: ( const dictionary& dict, const vectorField& controlPoints, - const vectorField& allPoints + const vectorField& dataPoints ); //- Construct as copy @@ -150,6 +142,18 @@ public: // Member Functions + //- Return reference to control points + const vectorField& controlPoints() const + { + return controlPoints_; + } + + //- Reference to all points + const vectorField& dataPoints() const + { + return dataPoints_; + } + //- Interpolate template tmp > interpolate(const Field& ctrlField) const; diff --git a/src/OpenFOAM/interpolations/RBFInterpolation/RBFInterpolationTemplates.C b/src/OpenFOAM/interpolations/RBFInterpolation/RBFInterpolationTemplates.C index f37264fb2..1757a61d1 100644 --- a/src/OpenFOAM/interpolations/RBFInterpolation/RBFInterpolationTemplates.C +++ b/src/OpenFOAM/interpolations/RBFInterpolation/RBFInterpolationTemplates.C @@ -43,7 +43,7 @@ Foam::tmp > Foam::RBFInterpolation::interpolate { // HJ and FB (05 Jan 2009) // Collect the values from ALL control points to all CPUs - // Then, each CPU will do interpolation only on local allPoints_ + // Then, each CPU will do interpolation only on local dataPoints_ if (ctrlField.size() != controlPoints_.size()) { @@ -60,7 +60,7 @@ Foam::tmp > Foam::RBFInterpolation::interpolate tmp > tresult ( - new Field(allPoints_.size(), pTraits::zero) + new Field(dataPoints_.size(), pTraits::zero) ); Field& result = tresult(); @@ -107,10 +107,10 @@ Foam::tmp > Foam::RBFInterpolation::interpolate // Algorithmic improvement, Matteo Lombardi. 21/Mar/2011 - forAll (allPoints_, flPoint) + forAll (dataPoints_, flPoint) { // Cut-off function to justify neglecting outer boundary points - t = (Foam::mag(allPoints_[flPoint] - focalPoint_) - innerRadius_)/ + t = (Foam::mag(dataPoints_[flPoint] - focalPoint_) - innerRadius_)/ (outerRadius_ - innerRadius_); if (t >= 1) @@ -122,7 +122,7 @@ Foam::tmp > Foam::RBFInterpolation::interpolate { // Full calculation of weights scalarField weights = - RBF_->weights(controlPoints_, allPoints_[flPoint]); + RBF_->weights(controlPoints_, dataPoints_[flPoint]); forAll (controlPoints_, i) { @@ -133,9 +133,9 @@ Foam::tmp > Foam::RBFInterpolation::interpolate { result[flPoint] += beta[0] - + beta[1]*allPoints_[flPoint].x() - + beta[2]*allPoints_[flPoint].y() - + beta[3]*allPoints_[flPoint].z(); + + beta[1]*dataPoints_[flPoint].x() + + beta[2]*dataPoints_[flPoint].y() + + beta[3]*dataPoints_[flPoint].z(); } scalar w; @@ -146,7 +146,7 @@ Foam::tmp > Foam::RBFInterpolation::interpolate } else { - w = 1 - sqr(t)*(3-2*t); + w = 1 - sqr(t)*(3 - 2*t); } result[flPoint] = w*result[flPoint];