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 #include "displacementFvMotionSolver.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <OpenFOAM/mapPolyMesh.H>
00029
00030
00031
00032 namespace Foam
00033 {
00034 defineTypeNameAndDebug(displacementFvMotionSolver, 0);
00035 }
00036
00037
00038
00039
00040 Foam::displacementFvMotionSolver::displacementFvMotionSolver
00041 (
00042 const polyMesh& mesh,
00043 Istream&
00044 )
00045 :
00046 fvMotionSolver(mesh),
00047 points0_
00048 (
00049 pointIOField
00050 (
00051 IOobject
00052 (
00053 "points",
00054 mesh.time().constant(),
00055 polyMesh::meshSubDir,
00056 mesh,
00057 IOobject::MUST_READ,
00058 IOobject::NO_WRITE,
00059 false
00060 )
00061 )
00062 )
00063 {
00064 if (points0_.size() != mesh.nPoints())
00065 {
00066 FatalErrorIn
00067 (
00068 "displacementFvMotionSolver::displacementFvMotionSolver\n"
00069 "(\n"
00070 " const polyMesh&,\n"
00071 " Istream&\n"
00072 ")"
00073 ) << "Number of points in mesh " << mesh.nPoints()
00074 << " differs from number of points " << points0_.size()
00075 << " read from file "
00076 <<
00077 IOobject
00078 (
00079 "points",
00080 mesh.time().constant(),
00081 polyMesh::meshSubDir,
00082 mesh,
00083 IOobject::MUST_READ,
00084 IOobject::NO_WRITE,
00085 false
00086 ).filePath()
00087 << exit(FatalError);
00088 }
00089 }
00090
00091
00092
00093
00094 Foam::displacementFvMotionSolver::~displacementFvMotionSolver()
00095 {}
00096
00097
00098
00099
00100 void Foam::displacementFvMotionSolver::updateMesh(const mapPolyMesh& mpm)
00101 {
00102 fvMotionSolver::updateMesh(mpm);
00103
00104
00105
00106
00107
00108
00109 const pointField& points =
00110 (
00111 mpm.hasMotionPoints()
00112 ? mpm.preMotionPoints()
00113 : fvMesh_.points()
00114 );
00115
00116
00117 const vector span0 = boundBox(points0_).span();
00118 const vector span = boundBox(points).span();
00119
00120 vector scaleFactors(cmptDivide(span0, span));
00121
00122 pointField newPoints0(mpm.pointMap().size());
00123
00124 forAll(newPoints0, pointI)
00125 {
00126 label oldPointI = mpm.pointMap()[pointI];
00127
00128 if (oldPointI >= 0)
00129 {
00130 label masterPointI = mpm.reversePointMap()[oldPointI];
00131
00132 if (masterPointI == pointI)
00133 {
00134 newPoints0[pointI] = points0_[oldPointI];
00135 }
00136 else
00137 {
00138
00139 newPoints0[pointI] = points0_[oldPointI] + cmptMultiply
00140 (
00141 scaleFactors,
00142 points[pointI]-points[masterPointI]
00143 );
00144 }
00145 }
00146 else
00147 {
00148 FatalErrorIn
00149 (
00150 "displacementLaplacianFvMotionSolver::updateMesh"
00151 "(const mapPolyMesh& mpm)"
00152 ) << "Cannot work out coordinates of introduced vertices."
00153 << " New vertex " << pointI << " at coordinate "
00154 << points[pointI] << exit(FatalError);
00155 }
00156 }
00157 points0_.transfer(newPoints0);
00158 }
00159
00160
00161