View Issue Details

IDProjectCategoryView StatusLast Update
0002155OpenFOAMContributionpublic2018-10-20 00:18
ReporterShorty Assigned Towill  
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionduplicate 
PlatformGNU/LinuxOSUbuntuOS Version14.04
Fixed in Versiondev 
Summary0002155: Deactivating ACMI interpolation for special fields
DescriptionDear Henry,

I am trying to manipulate the ACMI BC (and the according parent classes) in a way that we would be able to unset the ACMI interpolation for special fields. At the moment the main problem is that the cellMotion_ and pointMotion_ fields that come with the fvMotionSolvers interpolate between the coupled interfaces. This should be avoided because we want to have a sliding interface, not a somehow interpolated. As I saw in the last days, it is not as trivial to implement it. Due to the fact that I do not know all classes and how they interact like you I want to ask if this could be implemented as a feature.

Why?
For example in 2-stroke-engines the channels should be connected and opened due to the piston. So we need a sliding interface ACMI but with a fvMotionSolver. The problem that occur with the fvMotionSolvers is the mesh deformation based on the interpolation between the ACMI coupled patches for the fields I mentioned above. For a better understanding, I added the case and a picture.

In the picture you see the standard ACMI behavior with fvMotionSolver (right) and some modified ACMI with the expected result on the left side. In any case the left behavior correlates to uncommented lines in the /src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch file that is at least wrong.

Thanks in advance.
If you have any hints where I should start modifying would be also nice, then I can re-programm it and if its good, you can use it and add the feature.

http://www.holzmann-cfd.de/forumCases/modifiedACMI.gif
Steps To ReproduceUntar and run moveDynamicMesh application
TagsNo tags attached.

Relationships

duplicate of 0002057 resolvedhenry ACMI incompatible with velocityComponentLaplacian 

Activities

Shorty

2016-07-20 12:36

reporter  

MattijsJ

2016-07-22 14:10

reporter   ~0006553

The cellMotion and pointMotion fields in most motionSolvers are read (or read-if-present). Hence you can set the boundary conditions yourself overriding the default (which is cyclicAMI). You'll have to use the 'patchType' specification to indicate you are overriding a constraint type and know what you're doing.

E.g. in boundaryField of cellDisplacement field:

myAMI
{
    patchType cyclicAMI;
    type zeroGradient;
}

Shorty

2016-07-25 11:17

reporter   ~0006572

Last edited: 2016-07-25 12:44

Dear Mattijs,

thanks for your replay and the hint with patchType to overwrite the stuff. In any case it is not really working for the pointMotionUx for the case I attached. The cellMotionUx field is wonderful and as expected (no interpolation after the hint you gave me). The pointMotionUx field is still interpolating even if I explicit change the patch type according to the stuff you mentioned.

The problem only occur on the moving patch. Can you give me some feedback if this is a bug or not?

I added the modified case. Finally, I do not want to ask for support (: I am just wondering why we still get a interpolation between the patches (bug?) Alternatively a codedFixedValue BC could avoid this but I had no time till now to investigate into that.

Thanks in advance.

Shorty

2016-07-25 12:44

reporter  

twoStrokeEngine2.tar.gz (993,109 bytes)

MattijsJ

2016-09-27 13:58

reporter   ~0006924

Works if I explicitly disable the interpolation inside cyclicACMIPointPatchField (attached). Now just need to figure out why it doesn't preserve the bc's on pointMotionUx...
cyclicACMIPointPatchField.C (7,659 bytes)   
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2013-2016 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 "cyclicACMIPointPatchField.H"
#include "Swap.H"
#include "transformField.H"
#include "pointFields.H"

// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

template<class Type>
Foam::cyclicACMIPointPatchField<Type>::cyclicACMIPointPatchField
(
    const pointPatch& p,
    const DimensionedField<Type, pointMesh>& iF
)
:
    coupledPointPatchField<Type>(p, iF),
    cyclicACMIPatch_(refCast<const cyclicACMIPointPatch>(p)),
    ppiPtr_(nullptr),
    nbrPpiPtr_(nullptr)
{}


template<class Type>
Foam::cyclicACMIPointPatchField<Type>::cyclicACMIPointPatchField
(
    const pointPatch& p,
    const DimensionedField<Type, pointMesh>& iF,
    const dictionary& dict
)
:
    coupledPointPatchField<Type>(p, iF, dict),
    cyclicACMIPatch_(refCast<const cyclicACMIPointPatch>(p)),
    ppiPtr_(nullptr),
    nbrPpiPtr_(nullptr)
{
    if (!isType<cyclicACMIPointPatch>(p))
    {
        FatalIOErrorInFunction
        (
            dict
        )   << "patch " << this->patch().index() << " not cyclicACMI type. "
            << "Patch type = " << p.type()
            << exit(FatalIOError);
    }
}


template<class Type>
Foam::cyclicACMIPointPatchField<Type>::cyclicACMIPointPatchField
(
    const cyclicACMIPointPatchField<Type>& ptf,
    const pointPatch& p,
    const DimensionedField<Type, pointMesh>& iF,
    const pointPatchFieldMapper& mapper
)
:
    coupledPointPatchField<Type>(ptf, p, iF, mapper),
    cyclicACMIPatch_(refCast<const cyclicACMIPointPatch>(p)),
    ppiPtr_(nullptr),
    nbrPpiPtr_(nullptr)
{
    if (!isType<cyclicACMIPointPatch>(this->patch()))
    {
        FatalErrorInFunction
            << "Field type does not correspond to patch type for patch "
            << this->patch().index() << "." << endl
            << "Field type: " << typeName << endl
            << "Patch type: " << this->patch().type()
            << exit(FatalError);
    }
}


template<class Type>
Foam::cyclicACMIPointPatchField<Type>::cyclicACMIPointPatchField
(
    const cyclicACMIPointPatchField<Type>& ptf,
    const DimensionedField<Type, pointMesh>& iF
)
:
    coupledPointPatchField<Type>(ptf, iF),
    cyclicACMIPatch_(ptf.cyclicACMIPatch_),
    ppiPtr_(nullptr),
    nbrPpiPtr_(nullptr)
{}


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

template<class Type>
void Foam::cyclicACMIPointPatchField<Type>::swapAddSeparated
(
    const Pstream::commsTypes,
    Field<Type>& pField
) const
{
//     if (cyclicACMIPatch_.cyclicACMIPatch().owner())
//     {
//         // We inplace modify pField. To prevent the other side (which gets
//         // evaluated at a later date) using already changed values we do
//         // all swaps on the side that gets evaluated first.
// 
// 
//         // Get neighbouring pointPatch
//         const cyclicACMIPointPatch& nbrPatch = cyclicACMIPatch_.neighbPatch();
// 
//         // Get neighbouring pointPatchField
//         const GeometricField<Type, pointPatchField, pointMesh>& fld =
//             refCast<const GeometricField<Type, pointPatchField, pointMesh>>
//             (
//                 this->internalField()
//             );
// 
//         const cyclicACMIPointPatchField<Type>& nbr =
//             refCast<const cyclicACMIPointPatchField<Type>>
//             (
//                 fld.boundaryField()[nbrPatch.index()]
//             );
// 
// 
//         Field<Type> ptFld(this->patchInternalField(pField));
//         Field<Type> nbrPtFld(nbr.patchInternalField(pField));
// 
//         InfoInFunction << "patch:" << cyclicACMIPatch_.name() << endl;
//         //InfoInFunction << "pointField:" << ptFld << endl;
//         forAll(cyclicACMIPatch_.localPoints(), i)
//         {
//             Pout<< "    at:" << cyclicACMIPatch_.localPoints()[i]
//                 << " pointField:" << ptFld[i] << endl;
//         }
// 
//         InfoInFunction << "nbrpatch:" << nbrPatch.name() << endl;
//         forAll(nbrPatch.localPoints(), i)
//         {
//             Pout<< "    at:" << nbrPatch.localPoints()[i]
//                 << " nbrPointField:" << nbrPtFld[i] << endl;
//         }
// 
// 
//         if (doTransform())
//         {
//             const tensor& forwardT = this->forwardT()[0];
//             const tensor& reverseT = this->reverseT()[0];
// 
//             transform(ptFld, reverseT, ptFld);
//             transform(nbrPtFld, forwardT, nbrPtFld);
//         }
// 
//         // convert point field to face field, AMI interpolate, then
//         // face back to point
//         {
//             // add neighbour side contribution to owner
//             Field<Type> nbrFcFld(nbrPpi().pointToFaceInterpolate(nbrPtFld));
// 
//             InfoInFunction << "nbrFaceField:" << nbrFcFld << endl;
// 
//             const cyclicAMIPolyPatch& cami = cyclicACMIPatch_.cyclicACMIPatch();
// 
//             // interpolate to owner
//             nbrFcFld = cami.interpolate(nbrFcFld);
// 
//             InfoInFunction << "ACMI interpolated nbrFaceField:" << nbrFcFld
//                 << endl;
//             InfoInFunction << "local contribution:"
//                 << ppi().faceToPointInterpolate(nbrFcFld)()
//                 << endl;
// 
//             // add to internal field
//             this->addToInternalField
//             (
//                 pField,
//                 ppi().faceToPointInterpolate(nbrFcFld)()
//             );
// 
//             Field<Type> newFld(this->patchInternalField(pField));
//             InfoInFunction << "After adding patch:" << cyclicACMIPatch_.name()
//                 << endl;
//             forAll(cyclicACMIPatch_.localPoints(), i)
//             {
//                 Pout<< "    at:" << cyclicACMIPatch_.localPoints()[i]
//                     << " pointField:" << newFld[i] << endl;
//             }
//         }
// 
//         {
//             // add owner side contribution to neighbour
//             Field<Type> fcFld(ppi().pointToFaceInterpolate(ptFld));
// 
//             const cyclicAMIPolyPatch& cami = cyclicACMIPatch_.cyclicACMIPatch();
// 
//             // interpolate to neighbour
//             fcFld = cami.neighbPatch().cyclicAMIPolyPatch::interpolate(fcFld);
// 
//             // add to internal field
//             nbr.addToInternalField
//             (
//                 pField,
//                 nbrPpi().faceToPointInterpolate(fcFld)()
//             );
//         }
//     }
}


// ************************************************************************* //
cyclicACMIPointPatchField.C (7,659 bytes)   

MattijsJ

2016-09-27 14:04

reporter   ~0006925

The problem is the sum of the point weights ('volPointSumWeights') inside volPointInterpolation. This still has ACMI bc so will adapt the weights across the ACMI.

Shorty

2016-09-27 14:04

reporter   ~0006926

Thanks for the update, unfortunately I have no time to investigate into that :(
If you uncomment the lines, then no field is interpolated, or do I got it wrong?

Shorty

2016-09-27 14:13

reporter   ~0006928

Reported in the same time.
Good to know. Will you make a workaround for that problem?

Shorty

2018-10-19 19:25

reporter   ~0010118

Hi all, after saw the commit of @Chris today, the problem is resolved by commit a0a88d66 too.
https://bugs.openfoam.org/view.php?id=2057#c10116

I checked the case attached and it is working (at least the mesh motion).

wyldckat

2018-10-20 00:18

updater   ~0010119

@Shorty: Many thanks for the update. And it was Will who made the commit ;)

Closing this as resolved and duplicate of issue 2057.

Issue History

Date Modified Username Field Change
2016-07-20 12:36 Shorty New Issue
2016-07-20 12:36 Shorty File Added: twoStrokeEngineMantis.tar.gz
2016-07-22 14:10 MattijsJ Note Added: 0006553
2016-07-25 11:17 Shorty Note Added: 0006572
2016-07-25 12:42 Shorty Note Edited: 0006572
2016-07-25 12:44 Shorty Note Edited: 0006572
2016-07-25 12:44 Shorty File Added: twoStrokeEngine2.tar.gz
2016-09-27 13:58 MattijsJ File Added: cyclicACMIPointPatchField.C
2016-09-27 13:58 MattijsJ Note Added: 0006924
2016-09-27 14:04 MattijsJ Note Added: 0006925
2016-09-27 14:04 Shorty Note Added: 0006926
2016-09-27 14:13 Shorty Note Added: 0006928
2018-10-19 19:25 Shorty Note Added: 0010118
2018-10-20 00:16 wyldckat Relationship added duplicate of 0002057
2018-10-20 00:18 wyldckat Assigned To => will
2018-10-20 00:18 wyldckat Status new => resolved
2018-10-20 00:18 wyldckat Resolution open => duplicate
2018-10-20 00:18 wyldckat Fixed in Version => dev
2018-10-20 00:18 wyldckat Note Added: 0010119