Commit 1444b6f6 authored by mattijs's avatar mattijs
Browse files

ENH: motionSolver: refactor into displacement v.s. velocity

parent c1ef233e
......@@ -85,7 +85,11 @@ motionSmoother/motionSmoother.C
motionSmoother/motionSmootherCheck.C
motionSmoother/polyMeshGeometry/polyMeshGeometry.C
motionSolver/motionSolver.C
motionSolver/motionSolver/motionSolver.C
motionSolver/displacement/displacementMotionSolver.C
motionSolver/componentDisplacement/componentDisplacementMotionSolver.C
motionSolver/velocity/velocityMotionSolver.C
motionSolver/componentVelocity/componentVelocityMotionSolver.C
createShellMesh/createShellMesh.C
......
......@@ -2445,32 +2445,69 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
// parallel comms. After this points and edges should again be consistent.
mergeSharedPoints(constructPointMap);
// // Bit of hack: processorFvPatchField does not get reset since created
// // from nothing so explicitly reset.
// initPatchFields<volScalarField, processorFvPatchField<scalar> >
// (
// pTraits<scalar>::zero
// );
// initPatchFields<volVectorField, processorFvPatchField<vector> >
// (
// pTraits<vector>::zero
// );
// initPatchFields
// <
// volSphericalTensorField,
// processorFvPatchField<sphericalTensor>
// >
// (
// pTraits<sphericalTensor>::zero
// );
// initPatchFields<volSymmTensorField, processorFvPatchField<symmTensor> >
// (
// pTraits<symmTensor>::zero
// );
// initPatchFields<volTensorField, processorFvPatchField<tensor> >
// (
// pTraits<tensor>::zero
// );
// initPatchFields<surfaceScalarField, processorFvsPatchField<scalar> >
// (
// pTraits<scalar>::zero
// );
// initPatchFields<surfaceVectorField, processorFvsPatchField<vector> >
// (
// pTraits<vector>::zero
// );
// initPatchFields
// <
// surfaceSphericalTensorField,
// processorFvsPatchField<sphericalTensor>
// >
// (
// pTraits<sphericalTensor>::zero
// );
// initPatchFields
// <
// surfaceSymmTensorField,
// processorFvsPatchField<symmTensor>
// >
// (
// pTraits<symmTensor>::zero
// );
// initPatchFields<surfaceTensorField, processorFvsPatchField<tensor> >
// (
// pTraits<tensor>::zero
// );
//XXXXX
// Bit of hack: processorFvPatchField does not get reset since created
// from nothing so explicitly reset.
initPatchFields<volScalarField, processorFvPatchField<scalar> >
(
pTraits<scalar>::zero
);
initPatchFields<volVectorField, processorFvPatchField<vector> >
(
pTraits<vector>::zero
);
initPatchFields
<
volSphericalTensorField,
processorFvPatchField<sphericalTensor>
>
(
pTraits<sphericalTensor>::zero
);
initPatchFields<volSymmTensorField, processorFvPatchField<symmTensor> >
(
pTraits<symmTensor>::zero
);
initPatchFields<volTensorField, processorFvPatchField<tensor> >
(
pTraits<tensor>::zero
);
correctBoundaryConditions<volScalarField>();
correctBoundaryConditions<volVectorField>();
correctBoundaryConditions<volSphericalTensorField>();
correctBoundaryConditions<volSymmTensorField>();
correctBoundaryConditions<volTensorField>();
initPatchFields<surfaceScalarField, processorFvsPatchField<scalar> >
(
pTraits<scalar>::zero
......@@ -2499,7 +2536,7 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
(
pTraits<tensor>::zero
);
//XXXXX
mesh_.setInstance(mesh_.time().timeName());
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -138,6 +138,10 @@ class fvMeshDistribute
const typename GeoField::value_type& initVal
);
//- Call correctBoundaryConditions on fields
template<class GeoField>
void correctBoundaryConditions();
//- Delete all processor patches. Move any processor faces into
// patchI.
autoPtr<mapPolyMesh> deleteProcPatches(const label patchI);
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -241,6 +241,24 @@ void Foam::fvMeshDistribute::initPatchFields
}
// correctBoundaryConditions patch fields of certain type
template<class GeoField>
void Foam::fvMeshDistribute::correctBoundaryConditions()
{
HashTable<const GeoField*> flds
(
mesh_.objectRegistry::lookupClass<GeoField>()
);
forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
{
const GeoField& fld = *iter();
const_cast<GeoField&>(fld).correctBoundaryConditions();
}
}
// Send fields. Note order supplied so we can receive in exactly the same order.
// Note that field gets written as entry in dictionary so we
// can construct from subdictionary.
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "componentDisplacementMotionSolver.H"
#include "mapPolyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(componentDisplacementMotionSolver, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::direction Foam::componentDisplacementMotionSolver::cmpt
(
const word& cmptName
) const
{
if (cmptName == "x")
{
return vector::X;
}
else if (cmptName == "y")
{
return vector::Y;
}
else if (cmptName == "z")
{
return vector::Z;
}
else
{
FatalErrorIn
(
"componentDisplacementMotionSolver::"
"componentDisplacementMotionSolver"
"(const polyMesh& mesh, const IOdictionary&)"
) << "Given component name " << cmptName << " should be x, y or z"
<< exit(FatalError);
return 0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::componentDisplacementMotionSolver::componentDisplacementMotionSolver
(
const polyMesh& mesh,
const IOdictionary& dict,
const word& type
)
:
motionSolver(mesh, dict, type),
cmptName_(coeffDict().lookup("component")),
cmpt_(cmpt(cmptName_)),
points0_
(
pointIOField
(
IOobject
(
"points",
time().constant(),
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
).component(cmpt_)
),
pointDisplacement_
(
IOobject
(
"pointDisplacement" + cmptName_,
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
pointMesh::New(mesh)
)
{
if (points0_.size() != mesh.nPoints())
{
FatalErrorIn
(
"componentDisplacementMotionSolver::"
"componentDisplacementMotionSolver\n"
"(\n"
" const polyMesh&,\n"
" const IOdictionary&\n"
")"
) << "Number of points in mesh " << mesh.nPoints()
<< " differs from number of points " << points0_.size()
<< " read from file "
<<
IOobject
(
"points",
mesh.time().constant(),
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
).filePath()
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::componentDisplacementMotionSolver::~componentDisplacementMotionSolver()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::componentDisplacementMotionSolver::movePoints(const pointField& p)
{
// No local data to update
}
void Foam::componentDisplacementMotionSolver::updateMesh(const mapPolyMesh& mpm)
{
// pointMesh already updates pointFields.
motionSolver::updateMesh(mpm);
// Map points0_. Bit special since we somehow have to come up with
// a sensible points0 position for introduced points.
// Find out scaling between points0 and current points
// Get the new points either from the map or the mesh
const scalarField points
(
mpm.hasMotionPoints()
? mpm.preMotionPoints().component(cmpt_)
: mesh().points().component(cmpt_)
);
// Get extents of points0 and points and determine scale
const scalar scale =
(gMax(points0_)-gMin(points0_))
/(gMax(points)-gMin(points));
scalarField newPoints0(mpm.pointMap().size());
forAll(newPoints0, pointI)
{
label oldPointI = mpm.pointMap()[pointI];
if (oldPointI >= 0)
{
label masterPointI = mpm.reversePointMap()[oldPointI];
if (masterPointI == pointI)
{
newPoints0[pointI] = points0_[oldPointI];
}
else
{
// New point. Assume motion is scaling.
newPoints0[pointI] =
points0_[oldPointI]
+ scale*(points[pointI]-points[masterPointI]);
}
}
else
{
FatalErrorIn
(
"displacementLaplacianFvMotionSolver::updateMesh"
"(const mapPolyMesh& mpm)"
) << "Cannot work out coordinates of introduced vertices."
<< " New vertex " << pointI << " at coordinate "
<< points[pointI] << exit(FatalError);
}
}
points0_.transfer(newPoints0);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::componentDisplacementMotionSolver
Description
Virtual base class for displacement motion solver
The boundary displacement is set as a boundary condition
on the pointDisplacementX pointScalarField.
SourceFiles
componentDisplacementMotionSolver.C
\*---------------------------------------------------------------------------*/
#ifndef componentDisplacementMotionSolver_H
#define componentDisplacementMotionSolver_H
#include "motionSolver.H"
#include "pointFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class componentDisplacementMotionSolver Declaration
\*---------------------------------------------------------------------------*/
class componentDisplacementMotionSolver
:
public motionSolver
{
protected:
// Protected data
//- The component name to solve for
word cmptName_;
//- The component to solve for
direction cmpt_;
//- Reference point field for this component
scalarField points0_;
//- Point motion field
mutable pointScalarField pointDisplacement_;
private:
// Private Member Functions
//- Return the component corresponding to the given component name
direction cmpt(const word& cmptName) const;
//- Disallow default bitwise copy construct
componentDisplacementMotionSolver
(
const componentDisplacementMotionSolver&
);
//- Disallow default bitwise assignment
void operator=(const componentDisplacementMotionSolver&);
public:
//- Runtime type information
TypeName("componentDisplacementMotionSolver");
// Constructors
//- Construct from polyMesh and dictionary and type
componentDisplacementMotionSolver
(
const polyMesh&,
const IOdictionary&,
const word& type
);
//- Destructor
virtual ~componentDisplacementMotionSolver();
// Member Functions
//- Return reference to the reference field
scalarField& points0()
{
return points0_;
}
//- Return reference to the reference field
const scalarField& points0() const
{
return points0_;
}
//- Update local data for geometry changes
virtual void movePoints(const pointField&);
//- Update local data for topology changes
virtual void updateMesh(const mapPolyMesh&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "componentVelocityMotionSolver.H"
#include "mapPolyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(componentVelocityMotionSolver, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::direction Foam::componentVelocityMotionSolver::cmpt
(
const word& cmptName
) const
{
if (cmptName == "x")
{
return vector::X;
}
else if (cmptName == "y")
{
return vector::Y;
}
else if (cmptName == "z")
{
return vector::Z;
}
else