|
[Sponsors] |
[mesh manipulation] createBaffles and time varying from wall to empty internal patches |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 16, 2020, 12:42 |
createBaffles and time varying from wall to empty internal patches
|
#1 |
New Member
Giovanni Farina
Join Date: Nov 2019
Location: Trieste, Italy
Posts: 11
Rep Power: 7 |
Hi Foamers,
I have three inlets/outlets internal to my mesh, I would like to create internal patches which should periodically shift between type empty (open) and type wall (closed). I thought this was an easy task but apparently it's not. To start I tried just creating some baffles and apply type wall. I used patchPairs and not patchField, specifying the boundary conditions in the various files in the 0 folder (I don't think it makes some difference, does it?). I'm using a modified interFoam (in openfoam6) and the solver runs for a while, the new internal walls don't seem to work, the timestep goes to zero in order to keep limited the phi and the interface Courant number (which are probably getting higher and higher). Looking in paraview it seems that the walls make some difference but a not clear one, the executed time is too short to tell, but they are not proper walls for sure. My guess is that there is something wrong with the numerical schemes and I have no idea how to fix this. Maybe I shouldn't treat the patches as regular boundaries in the 0 folder files? Then I would like to change the wall type and implementing the periodical boundary condition: is there any way I can change the type of the boundary periodically? If not, how do I tell the solver to ignore the wall and basically implement the empty boundary condition (maybe with cyclic? but then how to implement the wall part for other times?)? I really hope to get some reply, it would be much appreciated. This how my createBaffles look like: Code:
internalFacesOnly true; baffles { inlet1faceZone // and same for 2 and 3 { type faceZone; zoneName inlet1faceZone; patchPairs { type wall; } } } I know this is a quite specific question but even general suggestions could bring me a little bit closer to the solution. Giovanni |
|
November 26, 2020, 11:37 |
|
#2 | |
New Member
Giovanni Farina
Join Date: Nov 2019
Location: Trieste, Italy
Posts: 11
Rep Power: 7 |
So... I tried different solutions, but I'll keep it simple: if I use groovyBC for opening and closing inlets over time I get the inlets always closed. This could be linked to this warning when I run createBaffles -overwrite:
Code:
--> FOAM Warning : From function int main(int, char**) in file createBaffles.C at line 854 Setting field on boundary faces to zero. You might have to edit these fields. Could you check my createBaffesDict? I'm not sure if I need to specify boundary condition also there but you can see them in the file. Also see attached a screen of what happens to U when I set it at 0.1 instead of interpolating U, you can see like a wall behaviour from one side (I see no effect on concentration). I think there is some issues on how the two sides are handled. Also the interface Courant number is pretty high. I tried also changing the inlet type to empty: still a wall behaviour. Using checkMesh I found this message: Quote:
Last edited by the_ichthyologist; November 28, 2020 at 12:23. |
||
November 28, 2020, 12:21 |
|
#3 |
New Member
Giovanni Farina
Join Date: Nov 2019
Location: Trieste, Italy
Posts: 11
Rep Power: 7 |
So.. I realized that it's necessary to differentiate between the paired patches and to implement some kind of cyclic condition to connect the mesh parts at the inlets; what I would ideally want is to turn on and off over time between a cyclic and a wall condition. Unfotunately this is not possible with groovyBC. This is probably the most useful thread on this topic:
groovyBC for coupling of patches It should be possible to map fields inside groovyBC (defining variables from other patches ) when patches have the same structure, but this does not work for some reason (it just averages and then everything crashes because of discontinuity). I could try again, maybe. I also tried combining type mapped and type groovyBC but again it doesn't work, I should turn on and off the mapped as well, but this is not possible. Then I tried just with a cyclic and at least this works, even if this is not what I want, so the way I create baflles is correct, I still get the high interface Courant number (and the later crash), and this could be more mesh-dependent (I'm using a "toy" mesh). Now I'll try going back to codedFixedValue and implement this cyclic/wall over time condition for the various fields. |
|
November 28, 2020, 15:13 |
|
#4 |
Senior Member
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 151
Rep Power: 10 |
Without knowing your model details, I can only guess.
First, I don't believe one can change patch type during a run. So changing from open to close should not involve a patch type change (e.g. not possible from cyclic to wall). Using cyclic boundary, something like activeBaffleVelocity, might be a way to go though I haven't seen a patch that have feature of turning on / off a valve. So, you might need to program. There are quite a few patches for selection in folder /opt/openfoam7/src/finiteVolume/fields/fvPatchFields/derived/. About the multi-region message, when you use wall type patch, the fluid domain is split into two by the wall. That's why there sent a warning message on multiple-region because solver is designed to address one region fluid flow for most cases.
__________________
Charles L. |
|
December 2, 2020, 15:03 |
|
#5 | |
New Member
Giovanni Farina
Join Date: Nov 2019
Location: Trieste, Italy
Posts: 11
Rep Power: 7 |
Hi Charles! Thank you a lot for your reply and for your suggestion!
Unfortunately, no boundary condition seems to fit my requirements, and I'm really struggling to make it work... I tried again with groovyBC but even if the fields have the same structured, even setting the patch as mapped, as said in the swak4foam guide: Quote:
I tried implementing this cyclic/wall condition with codedFixedValue, this is the velocity bc for an inlet side patch: Code:
inlet1faceZone_lagoon { type codedFixedValue; value uniform (0 0 0); redirectType combo1_lagoon; codeOptions #{ -I$(FOAM_CASE)/incl \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude #}; codeLibs #{ -lmeshTools \ -lfiniteVolume #}; codeInclude #{ #include "fvCFD.H" #include <cmath> #include <iostream> #include <stdio.h> #include <stdlib.h> #}; code #{ //const fvMesh& mymesh=mesh(); const fvPatch& boundaryPatch = patch(); // get patch ID on opposite side word oPatchName = "inlet1faceZone_sea"; label oPatchID = this->patch().boundaryMesh().findPatchID(oPatchName); const vectorField& Cf = boundaryPatch.Cf(); vectorField& fieldU = *this; volVectorField U = this->db().lookupObject<volVectorField>("U"); const Foam::fvPatchField<Foam::Vector<double> > Usea = U.boundaryField()[oPatchID]; const scalar omega = 0.0418879; // T=150 s (0 in 37.5 out 112.5 ...) scalar t = db().time().value(); if(cos(omega*t)/mag(cos(omega*t))>=0) // when open { forAll(Cf, faceI) { label cellI = boundaryPatch.faceCells()[faceI]; if (Usea[faceI].component(0)>0) // inflow coming in > copy from sea patch { fieldU[faceI] = Usea[faceI]; //fieldU[cellI] = 0.5*(fieldU[cellI]+Usea[faceI]); //not sure about this } if (Usea[faceI].component(0)<0) // outflow > take from internal field { fieldU[faceI] = fieldU[cellI]; } } } else // when closed { forAll(Cf, faceI) { fieldU[faceI] = vector(0,0,0); // wall behaviour } } #}; } For clarification my mesh is composed by a 'sea' basin and a 'lagoon' basin connected through three inlets and I want to open and close theinlets at different times in combination. See screenshot attached. Solver is interFoam. I really don't know why it does not work (it's compiled correctly but soon it blows up). And I'm really not sure if I'm doing this correctly for the other fields, alpha.water (indicator function) and the pressure, as this condition maybe should be applied differently. |
||
December 3, 2020, 13:38 |
|
#6 |
New Member
Giovanni Farina
Join Date: Nov 2019
Location: Trieste, Italy
Posts: 11
Rep Power: 7 |
Quick update: I went back to groovyBC, according to this thread:
groovyBC and access to alpha field of other patch it should be possible to map fields between coupled patches. However, if I try to do it OpenFOAM complains during the run that it can't find the region of the patch in the object registry. This happens because createBaffles splits the mesh in two regions, groovyBC is aware of this but can't find them since these regions are not defined originally in the mesh, and it's not possible to define internal faces. I'm very demotivated at this point but I guess that a way to go is to define the mesh, split it without createBaffles and somehow manage to define the patches separately, then apply groovyBC and maybe it could work... |
|
December 3, 2020, 15:41 |
|
#7 | |
Senior Member
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 151
Rep Power: 10 |
Thanks for the updating. You may need to create a new patch type (i.e. coding) based on patch type activeBaffleVelocity. The description is quite similar to what you want.
Quote:
__________________
Charles L. |
||
December 8, 2020, 13:46 |
|
#8 |
New Member
Giovanni Farina
Join Date: Nov 2019
Location: Trieste, Italy
Posts: 11
Rep Power: 7 |
Thank you a lot for your simple yet important suggestion! Source code can be daunting but creating a new boundary condition resulted as the most simple and effective solution.
You can find a simple guide here: http://openfoamwiki.net/index.php/Ho...dary_condition The main issue was in activeBaffleVelocity itself, I reproduced the same error as in here: activeBaffleVelocity boundary condition ? I applied your workaround method and got sensible results. However, I have issues decomposing the mesh and making the whole thing work in parallel. I haven't still gone in full detail about this and I'll post some updates tomorrowish. |
|
December 13, 2020, 19:37 |
|
#9 |
Senior Member
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 151
Rep Power: 10 |
Hi Giovanni
Have you resolved the problem? If not, can you share you model so I can take a deep look into it and fix the problem?
__________________
Charles L. |
|
December 14, 2020, 12:11 |
|
#10 |
New Member
Giovanni Farina
Join Date: Nov 2019
Location: Trieste, Italy
Posts: 11
Rep Power: 7 |
Hi Charles, I'm happy to tell you that everything works, to do the trick in parallel one needs to do the same for every processor* folder, basically:
As for the initial error about the interface phi Courant number the error was in the meshing, I needed to have a smoother and gradual meshing towards and away from baffles. Thank you again Charles for your suggestion and encouragement, it's good to receive an answer when you are starting to feel hopeless |
|
Tags |
boundary conditions, createbaffles, internal patches, patch, periodic |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem with createBaffles - want to make master and slave internal patches | artymk4 | OpenFOAM | 1 | May 22, 2021 06:45 |
[mesh manipulation] CreateBaffles generates distorted mesh | Andrea_85 | OpenFOAM Meshing & Mesh Conversion | 0 | May 24, 2019 05:36 |
[Gmsh] Creating 2 baffles in geometry | caja94 | OpenFOAM Meshing & Mesh Conversion | 1 | October 7, 2018 05:05 |