volPointInterpolation.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "volPointInterpolation.H"
00028 #include "fvMesh.H"
00029 #include "volFields.H"
00030 #include "pointFields.H"
00031 #include "demandDrivenData.H"
00032 #include "coupledPointPatchFields.H"
00033 #include "pointConstraint.H"
00034
00035
00036
00037 namespace Foam
00038 {
00039
00040
00041
00042 defineTypeNameAndDebug(volPointInterpolation, 0);
00043
00044
00045
00046
00047 void volPointInterpolation::makeWeights()
00048 {
00049 if (debug)
00050 {
00051 Info<< "volPointInterpolation::makeWeights() : "
00052 << "constructing weighting factors"
00053 << endl;
00054 }
00055
00056 const pointField& points = mesh().points();
00057 const labelListList& pointCells = mesh().pointCells();
00058 const vectorField& cellCentres = mesh().cellCentres();
00059
00060
00061 pointWeights_.clear();
00062 pointWeights_.setSize(points.size());
00063
00064 forAll(pointWeights_, pointi)
00065 {
00066 pointWeights_[pointi].setSize(pointCells[pointi].size());
00067 }
00068
00069 pointScalarField sumWeights
00070 (
00071 IOobject
00072 (
00073 "volPointSumWeights",
00074 mesh().polyMesh::instance(),
00075 mesh()
00076 ),
00077 pointMesh::New(mesh()),
00078 dimensionedScalar("zero", dimless, 0)
00079 );
00080
00081
00082
00083 forAll(points, pointi)
00084 {
00085 scalarList& pw = pointWeights_[pointi];
00086 const labelList& pcp = pointCells[pointi];
00087
00088 forAll(pcp, pointCelli)
00089 {
00090 pw[pointCelli] =
00091 1.0/mag(points[pointi] - cellCentres[pcp[pointCelli]]);
00092
00093 sumWeights[pointi] += pw[pointCelli];
00094 }
00095 }
00096
00097 forAll(sumWeights.boundaryField(), patchi)
00098 {
00099 if (sumWeights.boundaryField()[patchi].coupled())
00100 {
00101 refCast<coupledPointPatchScalarField>
00102 (sumWeights.boundaryField()[patchi]).initSwapAdd
00103 (
00104 sumWeights.internalField()
00105 );
00106 }
00107 }
00108
00109 forAll(sumWeights.boundaryField(), patchi)
00110 {
00111 if (sumWeights.boundaryField()[patchi].coupled())
00112 {
00113 refCast<coupledPointPatchScalarField>
00114 (sumWeights.boundaryField()[patchi]).swapAdd
00115 (
00116 sumWeights.internalField()
00117 );
00118 }
00119 }
00120
00121 forAll(points, pointi)
00122 {
00123 scalarList& pw = pointWeights_[pointi];
00124
00125 forAll(pw, pointCelli)
00126 {
00127 pw[pointCelli] /= sumWeights[pointi];
00128 }
00129 }
00130
00131 if (debug)
00132 {
00133 Info<< "volPointInterpolation::makeWeights() : "
00134 << "finished constructing weighting factors"
00135 << endl;
00136 }
00137 }
00138
00139
00140
00141
00142 volPointInterpolation::volPointInterpolation(const fvMesh& vm)
00143 :
00144 MeshObject<fvMesh, volPointInterpolation>(vm),
00145 boundaryInterpolator_(vm)
00146 {
00147 updateMesh();
00148 }
00149
00150
00151
00152
00153 volPointInterpolation::~volPointInterpolation()
00154 {}
00155
00156
00157
00158
00159 void volPointInterpolation::updateMesh()
00160 {
00161 makeWeights();
00162 boundaryInterpolator_.updateMesh();
00163 }
00164
00165
00166 bool volPointInterpolation::movePoints()
00167 {
00168 makeWeights();
00169 boundaryInterpolator_.movePoints();
00170
00171 return true;
00172 }
00173
00174
00175
00176
00177 }
00178
00179
Copyright © 2000-2009 OpenCFD Ltd