|
[Sponsors] |
movingconeTopo with multiple patch including moving in the direction of the y-axis |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 30, 2020, 09:08 |
movingconeTopo with multiple patch including moving in the direction of the y-axis
|
#1 |
New Member
heo
Join Date: Oct 2019
Posts: 3
Rep Power: 6 |
hello
I want to modify the code to make multiple patches move. so i modified movingConeTopofvMesh.c as shown below. This code was modified to move the mesh in the y-direction. the numerical analysis carried out with pimpleDyMFoam, The curMotionValue changes according to time, but curUp and curDown does not change and in the end, the mesh does not move. My ultimate goal is want each patch to move at different cycles and Amplitude including moving in the direction of the y-axis. If you know this problem, I would appreciate it if you let me know. Code:
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-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 "YMmovingConeTopoFvMesh.H" #include "Time.H" #include "mapPolyMesh.H" #include "layerAdditionRemoval.H" #include "addToRunTimeSelectionTable.H" #include "meshTools.H" #include "OFstream.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(YMmovingConeTopoFvMesh, 0); addToRunTimeSelectionTable ( topoChangerFvMesh, YMmovingConeTopoFvMesh, IOobject ); } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::tmp<Foam::scalarField> Foam::YMmovingConeTopoFvMesh::vertexMarkup ( const pointField& p, const scalar curUp, const scalar curDown ) const { Info<< "Updating vertex markup. curUp: " << curUp << " curDown: " << curDown << endl; tmp<scalarField> tvertexMarkup(new scalarField(p.size())); scalarField& vertexMarkup = tvertexMarkup.ref(); forAll(p, pI) { if (p[pI].y() < curUp + SMALL) { vertexMarkup[pI] = -1; } else if (p[pI].y() > curDown - SMALL) { vertexMarkup[pI] = 1; } else { vertexMarkup[pI] = 0; } } return tvertexMarkup; } void Foam::YMmovingConeTopoFvMesh::addZonesAndModifiers() { // Add zones and modifiers for motion action if ( pointZones().size() || faceZones().size() || cellZones().size() || topoChanger_.size() ) { InfoInFunction << "Zones and modifiers already present. Skipping." << endl; return; } Info<< "Time = " << time().timeName() << endl << "Adding zones and modifiers to the mesh" << endl; const vectorField& fc = faceCentres(); const vectorField& fa = faceAreas(); labelList zone1(fc.size()); boolList flipZone1(fc.size(), false); label nZoneFaces1 = 0; labelList zone2(fc.size()); boolList flipZone2(fc.size(), false); label nZoneFaces2 = 0; forAll(fc, facei) { if ( fc[facei].y() > 0.0201 && fc[facei].y() < 0.01999 ) { if ((fa[facei] & vector(0, 1, 0)) < 0) { flipZone1[nZoneFaces1] = true; } zone1[nZoneFaces1] = facei; //upper Info<< "face " << facei << " for zone 1. Flip: " << flipZone1[nZoneFaces1] << endl; nZoneFaces1++; } else if ( fc[facei].y() > 0.0101 && fc[facei].y() < 0.0099 ) { zone2[nZoneFaces2] = facei; if ((fa[facei] & vector(0, 1, 0)) > 0) { flipZone2[nZoneFaces2] = true; } Info<< "face " << facei << " for zone 2. Flip: " << flipZone2[nZoneFaces2] << endl; nZoneFaces2++; } } zone1.setSize(nZoneFaces1); flipZone1.setSize(nZoneFaces1); zone2.setSize(nZoneFaces2); flipZone2.setSize(nZoneFaces2); Info<< "zone: " << zone1 << endl; Info<< "zone: " << zone2 << endl; List<pointZone*> pz(0); List<faceZone*> fz(2); List<cellZone*> cz(0); label nFz = 0; fz[nFz] = new faceZone ( "UpExtrusionFaces", zone1, flipZone1, nFz, faceZones() ); nFz++; fz[nFz] = new faceZone ( "DownExtrusionFaces", zone2, flipZone2, nFz, faceZones() ); nFz++; fz.setSize(nFz); Info<< "Adding mesh zones." << endl; addZones(pz, fz, cz); // Add layer addition/removal interfaces List<polyMeshModifier*> tm(2); label nMods = 0; tm[nMods] = new layerAdditionRemoval ( "Down", nMods, topoChanger_, "DownExtrusionFaces", readScalar ( motionDict_.subDict("Down").lookup("DownminThickness") ), readScalar ( motionDict_.subDict("Down").lookup("DownmaxThickness") ) ); nMods++; tm[nMods] = new layerAdditionRemoval ( "Up", nMods, topoChanger_, "UpExtrusionFaces", readScalar ( motionDict_.subDict("Up").lookup("UpminThickness") ), readScalar ( motionDict_.subDict("Up").lookup("UpmaxThickness") ) ); nMods++; tm.setSize(nMods); Info<< "Adding " << nMods << " mesh modifiers" << endl; topoChanger_.addTopologyModifiers(tm); write(); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct from components Foam::YMmovingConeTopoFvMesh::YMmovingConeTopoFvMesh(const IOobject& io) : topoChangerFvMesh(io), motionDict_ ( IOdictionary ( IOobject ( "dynamicMeshDict1", time().constant(), *this, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE, false ) ).subDict(typeName + "Coeffs") ), motionVelAmplitude_(motionDict_.lookup("motionVelAmplitude")), motionVelPeriod_(readScalar(motionDict_.lookup("motionVelPeriod"))), curMotionVel_ ( motionVelAmplitude_* Foam::sin(time().value()*M_PI/motionVelPeriod_) ), UpEdge_(readScalar(motionDict_.lookup("UpEdge"))), curUp_(readScalar(motionDict_.lookup("UpObstacleEdge"))), curDown_(readScalar(motionDict_.lookup("DownObstacleEdge"))) { Pout<< "Initial time:" << time().value() << " Initial curMotionVel_:" << curMotionVel_ << endl; addZonesAndModifiers(); curUp_ = average ( faceZones() [ faceZones().findZoneID("UpExtrusionFaces") ]().localPoints() ).y() + SMALL; curDown_ = average ( faceZones() [ faceZones().findZoneID("DownExtrusionFaces") ]().localPoints() ).y() -SMALL; motionMask_ = vertexMarkup ( points(), curUp_, curDown_ ); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::YMmovingConeTopoFvMesh::~YMmovingConeTopoFvMesh() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::YMmovingConeTopoFvMesh::update() { // Do mesh changes (use inflation - put new points in topoChangeMap) autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh(true); // Calculate the new point positions depending on whether the // topological change has happened or not pointField newPoints; vector curMotionVel_; curMotionVel_.y() = motionVelAmplitude_.y()* Foam::sin(time().value()*M_PI/motionVelPeriod_); Pout<< "time:" << time().value() << " curMotionVel_:" << curMotionVel_ << " curUp:" << curUp_ << " curDown:" << curDown_ << endl; if (topoChangeMap.valid()) { Info<< "Topology change. Calculating motion points" << endl; if (topoChangeMap().hasMotionPoints()) { Info<< "Topology change. Has premotion points" << endl; motionMask_ = vertexMarkup ( topoChangeMap().preMotionPoints(), curUp_, curDown_ ); // Move points inside the motionMask newPoints = topoChangeMap().preMotionPoints() + ( pos(0.5 - mag(motionMask_)) // cells above the body )*curMotionVel_*time().deltaT().value(); } else { Info<< "Topology change. Already set mesh points" << endl; motionMask_ = vertexMarkup ( points(), curUp_, curDown_ ); // Move points inside the motionMask newPoints = points() + ( pos(0.5 - mag(motionMask_)) // cells above the body )*curMotionVel_*time().deltaT().value(); } } else { Info<< "No topology change" << endl; // Set the mesh motion newPoints = points() + ( pos(0.5 - mag(motionMask_)) // cells above the body )*curMotionVel_*time().deltaT().value(); } // The mesh now contains the cells with zero volume Info << "Executing mesh motion" << endl; movePoints(newPoints); // The mesh now has got non-zero volume cells curUp_ = average ( faceZones() [ faceZones().findZoneID("UpExtrusionFaces") ]().localPoints() ).y() + SMALL; curDown_ = average ( faceZones() [ faceZones().findZoneID("DownExtrusionFaces") ]().localPoints() ).y() - SMALL; return true; } // ************************************************************************* // |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
y+ and u+ values with low-Re RANS turbulence models: utility + testcase | florian_krause | OpenFOAM | 114 | August 23, 2023 06:37 |
The CoP Does not exist: Validating Aerodynamic forces through a "line of action" | ds4719 | Main CFD Forum | 14 | February 18, 2022 19:05 |
regarding the flow direction fixed in 'x' axis. | er_ijaz | OpenFOAM Bugs | 1 | September 25, 2019 07:30 |
Cyclic Boundary Condition | Luiz Eduardo Bittencourt Sampaio (Sampaio) | OpenFOAM Running, Solving & CFD | 36 | July 2, 2012 13:23 |
Convergence moving mesh | lr103476 | OpenFOAM Running, Solving & CFD | 30 | November 19, 2007 15:09 |