linearDisplacement_pointMeshMover.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2018-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace pointMeshMovers
34 {
36 
38  (
42  );
43 }
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 (
51  const polyMesh& mesh,
52  const dictionary& dict
53 )
54 :
56  axis_(normalised(dict.lookup<vector>("axis", dimless))),
57  xFixed_(dict.lookup<scalar>("xFixed", dimLength)),
58  xMoving_(dict.lookup<scalar>("xMoving", dimLength)),
59  displacement_
60  (
61  Function1<scalar>::New
62  (
63  "displacement",
64  mesh.time().userUnits(),
65  dimLength,
66  dict
67  )
68  )
69 {}
70 
71 
72 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
73 
75 {}
76 
77 
78 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
79 
82 {
83  tmp<pointField> tcurPoints(new pointField(points0()));
84  pointField& curPoints = tcurPoints.ref();
85 
86  const scalar displacement = displacement_->value(poly().time().value());
87 
88  forAll(curPoints, i)
89  {
90  const scalar lambda =
91  (xFixed_ - (axis_ & curPoints[i]))/(xFixed_ - xMoving_);
92 
93  if (lambda > 1)
94  {
95  curPoints[i] += axis_*displacement;
96  }
97  else if (lambda > 0)
98  {
99  curPoints[i] += axis_*lambda*displacement;
100  }
101  }
102 
103  return tcurPoints;
104 }
105 
106 
108 {
110  << "Mesh-to-mesh mapping in not implemented for displacement solvers"
111  << nl
112  << " velocity based motion solvers are preferable for cases in which"
113  " the mesh is reset periodically avoiding accumulation of error."
114  << exit(FatalError);
115 }
116 
117 
118 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
Run-time selectable general function of one variable.
Definition: Function1.H:62
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for pointMesh movers.
Abstract base class for displacement pointMesh movers.
Mesh motion solver simple linear expansion and contraction of a mesh region defined by a motion axis ...
virtual tmp< pointField > newPoints()
Return point location obtained from the current motion field.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map (not implemented)
linearDisplacement(const polyMesh &, const dictionary &)
Construct from polyMesh and dictionary.
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
dimensionedScalar lambda(viscosity->lookup("lambda"))
const dimensionSet dimless
const dimensionSet time
addToRunTimeSelectionTable(pointMeshMover, externalDisplacement, dictionary)
defineTypeNameAndDebug(externalDisplacement, 0)
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
const dimensionSet & dimLength
Definition: dimensions.C:141
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
dimensionSet normalised(const dimensionSet &)
Definition: dimensionSet.C:509
error FatalError
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
static const char nl
Definition: Ostream.H:297
dictionary dict