|
[Sponsors] |
runTime mapFields from fineMesh to coarseMesh |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 25, 2015, 08:56 |
runTime mapFields from fineMesh to coarseMesh
|
#1 |
Member
Join Date: Jul 2012
Posts: 67
Rep Power: 14 |
Hi Foamers,
I have recently successfully combined two solvers which solve different fields on two separate meshes(one fine and one coarse). Now I need to couple the fields of these two meshes every timestep. How can I achieve this? I read from this thread http://www.cfd-online.com/Forums/ope...-parallel.html #15 that I need to use a portion of the mapFields code. However, I have two questions, where do I put this code in my solver (eg.interFoam.C)? The second question is how can I read Code:
HashTable<word> patchMap; myDict.lookup("patchMap") >> patchMap; wordList cuttingPatches; myDict.lookup("cuttingPatches") >> cuttingPatches; Also, my two meshes are of the same geometry, do you think the method I mentioned above is appropriate? Thank you in advance Carlen |
|
April 27, 2015, 04:45 |
|
#2 | |
Member
Join Date: Jul 2012
Posts: 67
Rep Power: 14 |
Quote:
Code:
IOdictionary carlenMapFieldsDict ( IOobject ( "carlenMapFieldsDict", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ); volVectorField U_L(U, mesh); volVectorField U_E(U_P, Primary); volScalarField p_L(p, mesh); volScalarField p_E(p_P, Primary); volScalarField T_L(T, mesh); volScalarField T_E(T_P, Primary); HashTable<word> patchMap; wordList cuttingPatches; carlenMapFieldsDict.lookup("patchMap") >> patchMap; carlenMapFieldsDict.lookup("cuttingPatches") >> cuttingPatches; //set up an interpolation method meshToMesh::interpolationMethod mapMethod = meshToMesh::imCellVolumeWeight; // create the meshtomesh interpolator object Info << "Interpolating U,p,T Fields" << endl; meshToMesh InterpolatorObj ( mesh, Primary, mapMethod, patchMap, addProcessorPatches(Primary, cuttingPatches) ); //do the interpolation between U of the source mesh and Utgt of the target mesh InterpolatorObj.mapSrcToTgt ( U, eqOp<vector>(), U_P ); InterpolatorObj.mapSrcToTgt ( p, eqOp<scalar>(), p_P ); InterpolatorObj.mapSrcToTgt ( T, eqOp<scalar>(), T_P ); Info << "Mapping complete" << endl; Thank you very much carlen |
||
April 28, 2015, 16:21 |
|
#3 |
New Member
Marcel Vonlanthen
Join Date: Nov 2012
Location: Zurich, Switzerland
Posts: 28
Rep Power: 14 |
What do you mean by "the fields are not mapped between two grid"? The solver crashes or the interpolation is wrong/incomplete?
Sylv |
|
April 28, 2015, 20:23 |
|
#4 |
Member
Join Date: Jul 2012
Posts: 67
Rep Power: 14 |
||
April 29, 2015, 05:36 |
|
#5 |
New Member
Marcel Vonlanthen
Join Date: Nov 2012
Location: Zurich, Switzerland
Posts: 28
Rep Power: 14 |
So the solver just go through the interpolation without crashing and the target field remained unchanged, right? Are the mesh identical? Is one grid coarser? If yes, which one (target or source)?
Be more detailed in your answers. It is tough to understand the problem with just "not carried out" or "doesn't work".... Sylv |
|
April 29, 2015, 21:28 |
|
#6 | |
Member
Join Date: Jul 2012
Posts: 67
Rep Power: 14 |
Quote:
I managed to make the interpolation work from a fine mesh (mesh) to a coarse (Secondary) mesh (they are of the same geometry) using code below: Code:
IOdictionary carlenMapFieldsDict ( IOobject ( "carlenMapFieldsDict", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ); HashTable<word> patchMap; wordList cuttingPatches; carlenMapFieldsDict.lookup("patchMap") >> patchMap; carlenMapFieldsDict.lookup("cuttingPatches") >> cuttingPatches; //set up an interpolation method meshToMesh::interpolationMethod mapMethod = meshToMesh::imCellVolumeWeight; // create the meshtomesh interpolator IOobject Utarget ( "U", Secondary.time().timeName(), Secondary, IOobject::MUST_READ ); volVectorField Utgt(Utarget, Secondary); meshToMesh Interp ( mesh, Secondary, mapMethod, patchMap, addProcessorPatches(Secondary, cuttingPatches) ); Info << "Interpolating U Field" << endl; Interp.mapSrcToTgt ( U, eqOp<vector>(), Utgt ); Utgt.write(); Info << "Mapping complete" << endl; Carlen |
||
May 1, 2015, 04:32 |
|
#7 |
Member
Join Date: Jul 2012
Posts: 67
Rep Power: 14 |
Anyone please help me with this problem. I am stuck.
carlen |
|
May 10, 2015, 16:20 |
|
#8 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Carlen,
I have this thread of yours on my to-do list, but I won't be able to look into this any time soon Nonetheless, please provide a test case and the code ready to be used/tested, so that it takes less time for someone to step in and help. In addition, you might want to take a look into the source code for this library/toolkit: https://github.com/smenon/dynamicTopoFvMesh - it has the ability to re-mesh the whole domain on-the-fly, although last I saw, it could only handle tetrahedral meshes. This issue also reminds me of a similar topic: http://www.cfd-online.com/Forums/ope...pdate-fsi.html - you might be able to find some additional helpful ideas on that thread!! Best regards, Bruno
__________________
|
|
May 15, 2015, 08:10 |
|
#9 |
Member
Join Date: Jul 2012
Posts: 67
Rep Power: 14 |
Thank you bruno,
I solved the problem by applying the same initial boundary condition for both the fine and coarse meshes. Now the interpolations is working as intended. |
|
February 2, 2017, 10:07 |
|
#10 |
New Member
Join Date: Mar 2012
Posts: 20
Rep Power: 14 |
Hi Carlen,
I have been trying to implement mapField during runTime, in a similar way to the one you used (thank you for the useful posts btw). I stumbled upon the same problem you had: the mapped field is smeared exactly as you posted. You wrote that you solved the problem by applying the same initial boundary condition. It doesn't seem to work for me. Could you be more specific? |
|
February 5, 2017, 12:09 |
|
#11 |
New Member
Join Date: Mar 2012
Posts: 20
Rep Power: 14 |
I solved my problem by replacing
Code:
eqOp<vector>() Code:
plusEqOp<vector>() |
|
February 10, 2017, 04:58 |
|
#12 | |
New Member
Ebrahim
Join Date: Mar 2010
Posts: 28
Rep Power: 16 |
Quote:
I have the same issue as yours and I solved it by replacing eqOp<vector>() with plusEqOp<vector>() as well. Did you find the reason? Actually, I do not know what is changed by this replacement! /Ebrahim |
||
February 23, 2017, 09:30 |
|
#13 |
New Member
Join Date: Mar 2012
Posts: 20
Rep Power: 14 |
Does anyone know how to save the meshToMesh addressing, so that it doesn't need to calculate it at every restart?
With some meshes it's a very time consuming process. I found that with meshToMesh debug set to 1, it saves the srcToTgtCellAddr_, but I would need a way to write the whole result of Code:
meshToMesh Interp ( mesh, Secondary, mapMethod, patchMap, addProcessorPatches(Secondary, cuttingPatches) ); I guess I would need to write my own meshToMesh.C. Any idea? |
|
April 5, 2017, 13:25 |
|
#14 | |
New Member
Ehimen
Join Date: Jun 2016
Posts: 12
Rep Power: 10 |
Quote:
I had the same problem of the cell addressing recalculating at every timestep when I used meshToMesh.H. I now use meshToMesh0.H and the interpolation between two regions is much faster, although, I am clueless on how to get it to work for parallel cases. By the way, it seems that meshToMesh0.H is only available for the third and fourth versions of OpenFOAM. |
||
April 5, 2017, 13:33 |
|
#15 | |
New Member
Ehimen
Join Date: Jun 2016
Posts: 12
Rep Power: 10 |
Quote:
The difference may depend on which of the mesh to mesh libraries that you use. Cheers |
||
November 14, 2022, 22:39 |
|
#16 |
New Member
Xiaobo YAO
Join Date: Oct 2020
Posts: 9
Rep Power: 6 |
Hi Carlen,
I am also trying to implement mapFields into a solver. (chtMultiRegionFoam) May I ask where do you put your mapFields code in your solver.c? Best, Yao |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Issues with mapFields | BlackBoatNavArch | OpenFOAM Pre-Processing | 38 | May 28, 2021 17:29 |
Problem in3D model processing | mebinitap | OpenFOAM | 2 | December 12, 2014 05:40 |
Strange random behaviour of mapFields | blaise | OpenFOAM Pre-Processing | 0 | November 3, 2014 10:37 |
The -parallel parameter of mapFields utility in OpenFOAM v2.3.0 | shuoxue | OpenFOAM Pre-Processing | 1 | April 28, 2014 06:59 |
transientSimpleDyMFoam, mapFields and decomposePar | pad | OpenFOAM Running, Solving & CFD | 0 | December 3, 2010 06:22 |