1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Frank Bos, TU Delft. All rights reserved.
27 Dubravko Matijasevic, FSB Zagreb.
29 \*---------------------------------------------------------------------------*/
31 #include "RBFInterpolation.H"
32 #include "demandDrivenData.H"
34 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
36 const Foam::scalarSquareMatrix& Foam::RBFInterpolation::B() const
47 void Foam::RBFInterpolation::calcB() const
49 // Determine inverse of boundary connectivity matrix
57 // Fill Nb x Nb matrix
58 simpleMatrix<scalar> A(controlPoints_.size()+polySize);
60 const label nControlPoints = controlPoints_.size();
61 for (label i = 0; i < nControlPoints; i++)
63 scalarField weights = RBF_->weights(controlPoints_, controlPoints_[i]);
65 for (label col = 0; col < nControlPoints; col++)
67 A[i][col] = weights[col];
75 label row = nControlPoints;
76 row < nControlPoints + 1;
80 for (label col = 0; col < nControlPoints; col++)
87 // Fill in X components of polynomial part of matrix
90 label row = nControlPoints + 1;
91 row < nControlPoints + 2;
95 for (label col = 0; col < nControlPoints; col++)
97 A[col][row] = controlPoints_[col].x();
98 A[row][col] = controlPoints_[col].x();
102 // Fill in Y components of polynomial part of matrix
105 label row = nControlPoints + 2;
106 row < nControlPoints + 3;
110 for (label col = 0; col < nControlPoints; col++)
112 A[col][row] = controlPoints_[col].y();
113 A[row][col] = controlPoints_[col].y();
116 // Fill in Z components of polynomial part of matrix
119 label row = nControlPoints + 3;
120 row < nControlPoints + 4;
124 for (label col = 0; col < nControlPoints; col++)
126 A[col][row] = controlPoints_[col].z();
127 A[row][col] = controlPoints_[col].z();
131 // Fill 4x4 zero part of matrix
134 label row = nControlPoints;
135 row < nControlPoints + 4;
141 label col = nControlPoints;
142 col < nControlPoints + 4;
151 // HJ and FB (05 Jan 2009)
152 // Collect ALL control points from ALL CPUs
153 // Create an identical inverse for all CPUs
155 Info<< "Inverting RBF motion matrix" << endl;
157 BPtr_ = new scalarSquareMatrix(A.LUinvert());
161 void Foam::RBFInterpolation::clearOut()
163 deleteDemandDrivenData(BPtr_);
167 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
169 Foam::RBFInterpolation::RBFInterpolation
171 const dictionary& dict,
172 const vectorField& controlPoints,
173 const vectorField& allPoints
177 controlPoints_(controlPoints),
178 allPoints_(allPoints),
179 RBF_(RBFFunction::New(word(dict.lookup("RBF")), dict)),
181 focalPoint_(dict.lookup("focalPoint")),
182 innerRadius_(readScalar(dict.lookup("innerRadius"))),
183 outerRadius_(readScalar(dict.lookup("outerRadius"))),
184 polynomials_(dict.lookup("polynomials"))
188 Foam::RBFInterpolation::RBFInterpolation
190 const RBFInterpolation& rbf
194 controlPoints_(rbf.controlPoints_),
195 allPoints_(rbf.allPoints_),
196 RBF_(rbf.RBF_->clone()),
198 focalPoint_(rbf.focalPoint_),
199 innerRadius_(rbf.innerRadius_),
200 outerRadius_(rbf.outerRadius_),
201 polynomials_(rbf.polynomials_)
205 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
207 Foam::RBFInterpolation::~RBFInterpolation()
213 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
215 void Foam::RBFInterpolation::movePoints()
221 // ************************************************************************* //