35#include "surfaceInterpolate.H"
61Foam::surfaceAlignedSBRStressFvMotionSolver::
62surfaceAlignedSBRStressFvMotionSolver
69 surfaceNames_(coeffDict().
lookup(
"surfaces")),
70 surfaceMesh_(surfaceNames_.size()),
84 maxAng_(coeffDict().getOrDefault<scalar>(
"maxAng", 80)),
85 minAng_(coeffDict().getOrDefault<scalar>(
"minAng", 20)),
86 accFactor_(coeffDict().getOrDefault<scalar>(
"accFactor", 1)),
87 smoothFactor_(coeffDict().getOrDefault<scalar>(
"smoothFactor", 0.9)),
88 nNonOrthogonalCorr_(coeffDict().get<label>(
"nNonOrthogonalCorr")),
89 pointDisplacement_(pointDisplacement()),
103 minSigmaDiff_(coeffDict().getOrDefault<scalar>(
"minSigmaDiff", 1
e-4))
115 mesh.time().constant(),
137void Foam::surfaceAlignedSBRStressFvMotionSolver::calculateCellRot()
139 cellRot_.primitiveFieldRef() =
Zero;
140 pointDisplacement_.primitiveFieldRef() =
Zero;
149 for (label faceI = 0; faceI < fvMesh_.nInternalFaces(); faceI++)
151 start[faceI] = Cc[fvMesh_.faceOwner()[faceI]];
152 end[faceI] = Cc[fvMesh_.faceNeighbour()[faceI]];
157 forAll(surfaceMesh_, surfi)
160 surfaceMesh_[surfi].findLineAny(start, end, hit);
164 const vectorField& nf = surfaceMesh_[surfi].faceNormals();
174 if (hit[facei].hit())
177 const vector& hitPoint = hit[facei].point();
179 if (fvMesh_.isInternalFace(facei))
181 const point& ownCc = Cc[fvMesh_.faceOwner()[facei]];
182 const point& nbrCc = Cc[fvMesh_.faceNeighbour()[facei]];
184 if (hitPoint.distSqr(ownCc) < hitPoint.distSqr(nbrCc))
186 rotCellId = fvMesh_.faceOwner()[facei];
190 rotCellId = fvMesh_.faceNeighbour()[facei];
198 const point& ownCc = Cc[fvMesh_.faceOwner()[facei]];
200 const vector cCentreOne = ownCc - hitPoint;
204 .neighbFaceCellCentres()[facei];
206 const vector cCentreTwo = nbrCc - hitPoint;
208 if (cCentreOne < cCentreTwo)
210 rotCellId = fvMesh_.faceOwner()[facei];
223 const labelList& cFaces = fvMesh_.cells()[rotCellId];
225 scalar cosMax(-GREAT);
230 mag(nf[hit[facei].index()] & nSfMesh[cFaces[
k]]);
249 cellRot_[rotCellId] =
250 nSfMesh[
faceId]^nf[hit[facei].index()];
252 const scalar magRot =
mag(cellRot_[rotCellId]);
256 const scalar theta =
::asin(magRot);
257 quaternion q(cellRot_[rotCellId]/magRot, theta);
260 fvMesh_.cellPoints(rotCellId);
264 const label pointId = cPoints[j];
266 pointsCount[pointId]++;
269 fvMesh_.points()[pointId];
271 pointDisplacement_[pointId] +=
272 (
R & (pointPos - hitPoint))
273 - (pointPos - hitPoint);
281 vectorField& pd = pointDisplacement_.primitiveFieldRef();
285 point /= pointsCount[pointi];
295 this->movePoints(fvMesh_.points());
299 diffusivity().correct();
310 cellMotionBoundaryTypes<vector>
312 pointDisplacement().boundaryField()
315 auto& Ud = tUd.ref();
321 Ud[i] = pointInter.interpolate(pointDisplacement_);
346 auto&
mu = tmu.ref();
349 mu.primitiveFieldRef() = (1.0/
V);
360 const scalar diffSigmaD =
361 gSum(
mag(sigmaD_.oldTime().primitiveField()))
362 -
gSum(
mag(magNewSigmaD.primitiveField()));
364 if (
mag(diffSigmaD) > minSigmaDiff_)
366 sigmaD_ = magNewSigmaD;
373 pointDisplacement_.boundaryFieldRef().updateCoeffs();
379 for (
int nonOrth=0; nonOrth<=nNonOrthogonalCorr_; nonOrth++)
387 "laplacian(diffusivity,cellDisplacement)"
407 DEqn.solveSegregatedOrCoupled();
#define R(A, B, C, D, E, F, K, M)
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
const polyBoundaryMesh & pbm
Graphite solid properties.
C() noexcept
Default construct.
label size() const noexcept
The number of elements in list.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
static tmp< GeometricField< vector, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< vector >::calculatedType())
tmp< GeometricField< Type, PatchField, GeoMesh > > T() const
Return transpose (only if it is a tensor field).
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const Time & time() const noexcept
Return Time associated with the objectRegistry.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
pointVectorField & pointDisplacement() noexcept
Return reference to the point motion displacement field.
Mesh motion solver for an fvMesh. Based on solving the cell-centre solid-body rotation stress equatio...
motionDiffusivity & diffusivity()
Return diffusivity.
volVectorField & cellDisplacement()
Return reference to the cell motion displacement field.
SolverPerformance< Type > solveSegregatedOrCoupled(const dictionary &)
Solve segregated or coupled returning the solution statistics.
const fvMesh & fvMesh_
The fvMesh to be moved.
wordList cellMotionBoundaryTypes(const typename GeometricField< Type, pointPatchField, pointMesh >::Boundary &pmUbf) const
Create the corresponding patch types for cellMotion from those.
const fvMesh & mesh() const
Return reference to the fvMesh to be moved.
void correct(GeometricField< Type, PatchField, GeoMesh > &field)
Apply correction to field.
void constrain(fvMatrix< Type > &eqn)
Apply constraints to equation.
Finite-volume options, which is an IOdictionary of values and a fv::optionList.
static options & New(const fvMesh &mesh)
Construct fvOptions and register to database if not present otherwise lookup and return.
Virtual base class for mesh motion solver.
const dictionary & coeffDict() const
Const access to the coefficients dictionary.
Container to calculate weights for interpolating directly from vertices of cell using Mean Value Coor...
Type interpolate(const GeometricField< Type, pointPatchField, pointMesh > &psip) const
Interpolate field.
virtual void movePoints(const pointField &)
Update local data for geometry changes.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
Mesh consisting of general polyhedral cells.
Quaternion class used to perform rotations in 3D space.
Lookup type of boundary radiation properties.
Mesh motion solver for an fvMesh. Based on solving the cell-centre solid-body rotation stress equatio...
~surfaceAlignedSBRStressFvMotionSolver()
Destructor.
virtual void solve()
Solve for motion.
A class for managing temporary objects.
IOoject and searching on triSurface.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Calculate the divergence of the given field.
Provides functions smooth spread and sweep which use the FaceCellWave algorithm to smooth and redistr...
Calculate the matrix for the laplacian of the field.
const expr V(m.psi().mesh().V())
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
void smooth(volScalarField &field, const scalar coeff)
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
const dimensionSet dimViscosity
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
dimensionedScalar asin(const dimensionedScalar &ds)
Type gSum(const FieldField< Field, Type > &f)
GeometricField< vector, fvPatchField, volMesh > volVectorField
const dimensionSet dimless
Dimensionless.
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
List< label > labelList
A List of labels.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
static const Identity< scalar > I
List< vector > vectorList
List of vector.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
dimensioned< symmTensor > dimensionedSymmTensor
Dimensioned tensor obtained from generic dimensioned type.
constexpr scalar degToRad() noexcept
Multiplication factor for degrees to radians conversion.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
fvMatrix< vector > fvVectorMatrix
Field< vector > vectorField
Specialisation of Field<T> for vector.
Field< label > labelField
Specialisation of Field<T> for label.
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
vectorField pointField
pointField is a vectorField.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
List< scalar > scalarList
List of scalar.
dimensionedScalar cos(const dimensionedScalar &ds)
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
#define forAll(list, i)
Loop across all elements in list.
Unit conversion functions.