- **OpenFOAM Pre-Processing**
(*http://www.cfd-online.com/Forums/openfoam-pre-processing/*)

- - **mapFields between inconsistent meshes**
(*http://www.cfd-online.com/Forums/openfoam-pre-processing/65353-mapfields-between-inconsistent-meshes.html*)

mapFields between inconsistent meshes1 Attachment(s)
Hello,
I have two meshes with inconsistent geometries which I would like to map fields in between, but I can not understand how to use e.g. mapFields. For the from mesh I've calculated the coordinates which corresponds to the coordinates in the to mesh, i.e. P(S,r,\theta) = (x,y,z). Now I would like to use these coordinates together with an interpolation routine (if different amount of cells) to map fields. The two meshes have patches which correspond to each other. I've attached a fig. that shows a simple example of meshes. Will mapFields perform this mapping? If so could anyone please give an example/hint of how the mapFieldsDict file would look like or is there a better way of performing this mapping? All the Best /NW |

Or, could anyone explain how to load two meshes, please. Thinking of trying to use the meshToMesh class.
/NW |

Writing since I still need some help or proposals of how to map fields between two meshes with different geometries.
I would like to map fields between the two meshes according to a coordinate system derived for my source mesh corresponding to the cartesian coordinate system for the target mesh. The new coordinate system is saved as a volVectorField. (createMesh.H is rewritten to be able to load two meshes, source and target mesh) a) Is it possible to replace the cartesian coordinate system in my source mesh with the derived coordinate system with e.g. the coordinateSystem class? How? (Would allow me to directly find corresponding cell values for a direct mapping) b) Is there a class that performs a map between meshes and desirably performs an interpolation too? I've tried to understand how the meshToMesh class can be used for my case but without success. Sincerely /NW |

If you have a function that maps a point in the 'from' geometry onto the corresponding point in the 'to' geometry you can just go through meshToMesh and add this transformation to all accesses of any 'from' geometry. Look for mesh.cellCentres(), faceCentres(), mesh.C(), mesh.Cf() etc. This will make sure that the correspondence (addressing and weights) between the meshes is found correctly. You'll then need to apply your coordinate system transformation when mapping (vector and tensor)fields.
a) above coordinate transformation function can be coded as a 'coordinateSystem'. Use toLocal and toGlobal to convert coordinates. However this is not the hard bit; the hard bit is finding the coordinate transformation function. |

Dear Mattijs,
Thanks for your reply, unfortunately I still have problems understanding how to perform the mapping and would need a more detailed explanation, please. The function you refer to I assume is my calculated coordinate variables in the 'from' mesh corresponding to the cartesian coordinates in the 'to' mesh? Then, how should I do to, "go through meshToMesh and add this transformation to all accesses of any 'from' geometry"? mesh.C(), .Cf() etc. returns cellcentres, faceCentres etc. but how can I use this info together with meshToMesh? Thanks /NW |

Say you have a function F (your coordinate system) which takes a coordinate in the 'fromMesh' and produces the equivalent coordinate in the 'toMesh'. Go through all of meshToMesh files (in sampling/meshToMeshInterpolation/meshToMesh/) and replace all usage of coordinates of the fromMesh with its transformed equivalence.
E.g. const vectorField& centresFrom = fromMesh.cellCentres(); .. scalar distSqr = magSqr(p - centresFrom[curCell]); becomes const vectorField& centresFrom = fromMesh.cellCentres(); .. scalar distSqr = magSqr(p - F(centresFrom[curCell])); I can't explain it any clearer. |

Thank You! Now I start to understand mapFields and meshToMesh etc.
Just one thing, I would need to obtain a pointField from a volVectorField, but I can not find any example or syntax as from my understanding in the doxygen manual or in the forum. Could you give me a hint, please? |

To finish this thread! The fields between the two meshes can be mapped as consistent after a coordinate transformation which can be done as,
pointMesh pMesh(meshSource); volPointInterpolation newCoordInt(meshSource, pMesh); pointVectorField pNewCoord(newCoordInt.interpolate(newCoord)); meshSource.movePoints(pNewCoord); where newCoord is a volVectorField. Regards /NW |

All times are GMT -4. The time now is 17:37. |