CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How to Map Fields in openFOAM using the utility (https://www.cfd-online.com/Forums/openfoam-solving/119231-how-map-fields-openfoam-using-utility.html)

Chanterz February 4, 2016 23:22

Hi guys, I am trying to do something very similar to what you are trying to do. I will post what I have discovered so far relating to my problem and hopefully it can help yours. I am sick of mapFields problems - I just want to solve this!

So far I have:
  • A target mesh that has an STL file meshed with SHM
  • A source mesh that is the same but without the meshed STL file inside

The target mesh is thus 'finer' than the source file. I.e. it has more cells, points and faces.

System architecture:
  • I have a 0,constant,system, 3962 folder (left empty), and 'blah' folder... these are ALL inside my target folder
  • 'blah' folder has a 0,constant and system folder of a pre-solved case of 3692. This is my 'source' case.
  • controlDict in target directory has been changed with a startTime of 3692
The Source and Target cases have the same boundary conditions apart from my desired cutting patch of 'heliostat', which is my meshed STL file.



What I do:
  • blockMesh and SHM the target case (see other threads about how to do this)
  • call <mapFields blah -sourceTime latestTime>
This is my mapFields:
*Note: heliostat is the STL file/object I have added into the farfield.


Code:

patchMap       
(
inlet inlet
outlet outlet
sides sides
top top
ground ground
 );

cuttingPatches 
(
heliostat
);

And this is the output:


Code:

Source: "." "blah"
Target: "/mnt/worimi/jade/Final_System" "simple_atm_smallerlayers_z0ofZero_withHeliostat"

Create databases as time

Source time: 3692
Target time: 3692
Create meshes

Source mesh size: 2534400    Target mesh size: 2860432


Mapping fields for time 3692


End

When I check 3692 folder in target directory there is nothing there.


This method has worked for me when I leave mapFields blank, but of course, but only when I go from a fine to a coarse mesh. In this case, it mapped everything from Source to Target 3692 as nonuniform lists, to which I could add my extra BC for 'heliostat' at the end. (supplementary question: can I do this?)


I have tried messing around with mapFields, by leaving out parts of cuttingPatches and patchMap, but it hasn't worked (I get the above output where it accepts the command but doesn't do anything).



I WAS using 2.3x but if you get this error:


Code:

Source: ".." "frac1" Target: "/home/ripuvm/OpenFOAM/ripuvm-2.3.x/multiFrac/cases/Consecutive1Well" "frac2"  Create databases as time Case  : ../frac1 nProcs : 1  Source time: 133 Target time: 54  Create meshes  Source mesh size: 68670    Target mesh size: 83482  Creating and mapping fields for time 133  Creating mesh-to-mesh addressing for region0 and region0 regions using cellVolumeWeight  --> FOAM FATAL ERROR:  Plane normal defined with zero length Bad points:(15.24 -114.3 -22.86) (15.24 -106.68 -22.86) (15.24 -99.06 -22.86)      From function void plane::calcPntAndVec (    const point&,    const point&,    const point& )      in file meshes/primitiveShapes/plane/plane.C at line 116.  FOAM aborting  #0  Foam::error::printStack(Foam::Ostream&) in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/lib/libOpenFOAM.so" #1  Foam::error::abort() in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/lib/libOpenFOAM.so" #2  Foam::plane::calcPntAndVec(Foam::Vector<double> const&, Foam::Vector<double> const&, Foam::Vector<double> const&) in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/lib/libOpenFOAM.so" #3  Foam::tetOverlapVolume::tetTetOverlapVol(Foam::tetPoints const&, Foam::tetPoints const&) const in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/lib/libmeshTools.so" #4  Foam::tetOverlapVolume::cellCellOverlapVolumeMinDecomp(Foam::primitiveMesh const&, int, Foam::primitiveMesh const&, int, Foam::treeBoundBox const&) const in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/lib/libmeshTools.so" #5  Foam::meshToMeshMethod::interVol(int, int) const in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/lib/libsampling.so" #6  Foam::cellVolumeWeightMethod::calculateAddressing(Foam::List<Foam::List<int> >&, Foam::List<Foam::List<double> >&, Foam::List<Foam::List<int> >&, Foam::List<Foam::List<double> >&, int, int, Foam::List<int> const&, Foam::List<bool>&, int&) in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/lib/libsampling.so" #7  Foam::cellVolumeWeightMethod::calculate(Foam::List<Foam::List<int> >&, Foam::List<Foam::List<double> >&, Foam::List<Foam::List<int> >&, Foam::List<Foam::List<double> >&) in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/lib/libsampling.so" #8  Foam::meshToMesh::calcAddressing(Foam::polyMesh const&, Foam::polyMesh const&) in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/lib/libsampling.so" #9  Foam::meshToMesh::calculate() in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/lib/libsampling.so" #10  Foam::meshToMesh::meshToMesh(Foam::polyMesh const&, Foam::polyMesh const&, Foam::meshToMesh::interpolationMethod const&, Foam::HashTable<Foam::word, Foam::word, Foam::string::hash> const&, Foam::List<Foam::word> const&) in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/lib/libsampling.so" #11    in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/bin/mapFields" #12    in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/bin/mapFields" #13  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #14    in "/opt/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64GccDPOpt/bin/mapFields"  Program received signal SIGABRT, Aborted. 0x00007ffff4260425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(taken from ripudaman in this thread: http://www.cfd-online.com/Forums/openfoam-pre-processing/81780-issues-mapfields.html)



... then I have been led to believe this is a problem with mapFields in 2.3.

OpenFoam 2.2 is supposed to work, but the creators have noticed this and have reverted back to 2.2 functionality in 3.0x.



So I downloaded 3.0x and now in stead of getting this error with cuttingPatches it accepts it, but doesn't do anything. I feel like there is an issue with how it is reading the points or something - or the way the files are set up?



If I have any development on the matter I will post, but at the moment I am quite stuck. Any help would be much appreciated by myself and, I'm guessing, MANY OF users.



Kind regards, Jade

Chanterz February 5, 2016 00:25

Wow found a possible solution:
 
3 Attachment(s)
Back again!

Ok, so I managed to successfully mapFields with everying, including my cuttingPatch of heliostat, filled out above.

What is also great, is that the cuttingPatch BC's are also mapped into the list of field numbers of the mapped solution files from source.

Here's what I did:

  • copied the 0 files from target case (of the boundary conditions I want of the patches INCLUDING heliostat boundary) into the-previously-blank 3692 file (where the source files 'were' to be uploaded).
  • When I employ mapFields as above, it seems that the mapFields function overwrites the target boundary files and fills it with the list of numbers that have matching boundary conditions between the target and source cases (outlined in patchMap) and leaves the 'heliostat' cutting patch alone.

The number of faces indicating that the coarse source mesh has been mapped onto the fine target mesh is also indicated at the top of these new files.

I have to wait until Monday to run it. I will let you know how it goes.

sisetrun April 27, 2016 02:19

Hello everybody,

I found this thread while I was searching for mapping methods.
In my case, I want to map a fully developed flow profile to a different inlet.
Situation:
Run a simulation of a tube (l=1m), sample at 0.9m and use this "cut" as inlet BC for a different case 2. Meshes are not the same...
I tried meshFields, but I can only map an overlapping volume.
Is there a way to map a cutting plane to the inlet of case 2?

Thanks a lot for your info

Regards

Elham June 24, 2016 02:40

Dear sisetrun,

Could you find any solution for this problem? Please let me know since I have the same issue.

Thanks.

Elham

sisetrun June 24, 2016 02:52

Hey Elham.,

I managed it by sampling a fully developed flow from a pipe. Use "foamFile" as output in the sampleDict.

Then you can have a look at incompressible/simpleFoam/pitzDailyExptinlet.
In your constant directory, create a folder boundaryData and in this folder another one with the name of your inlet patch. Within this inlet-folder, your copy your points from sampleDict and a third folder "0" where you put your "U" file. make sure, that you add the OpenFoam header:

Quote:

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class vectorField; (points) // vectorAverageField for U
object points; or values for U
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
As BC for your patch, use
Quote:

inlet
{
type timeVaryingMappedFixedValue;
offset (0 0 0);
setAverage off;
}
offset is a dummy here, the actual data is taken from your "U" file in the constant/boundaryData... folder.

Regards

Elham June 24, 2016 03:58

Dear sisetrun,

Thanks for prompt reply. I have followed your instruction and sampled my inlet patch. Now I have points, U and P of inlet. But I don't know where should I assign BC for patch, since I have U and P ?

Thanks.

Elham

Elham June 24, 2016 04:01

And another question:

Should I execute mapFields now?

sisetrun June 24, 2016 04:52

Hey Alham,

there is no need for mapFields.

Set the BC in your case/0 as shown above.
In the constant/boundaryData/inlet/0/U is just the list of values for your points located in constant/boundaryData/inlet/points. This "plane" or "
Circle" is taken as inlet BC for your geometry. For p it is a scalar and for U a vector...
If you want to simulate a tube, just use U and set the p BC in case/0 to zeroGradient as usual. With this settings, you have a zeroGradient pressure at the inlet and for U you get the desired U profile

Elham June 27, 2016 03:59

Dear sisetrun,

Thanks. It took a day to manipulate and run the case succesfuly but you gave me the right points.

Cheers,

Elham

Esther Jin July 4, 2016 10:14

Hello Sisetrun,

I have quite same problem with your case.

I still not clear about how to map the inlet data onto another case.

After creating the BoundaryData folder and setting inlet BC as timevaryingMappedFixedValue as you described in your case, what do I need to do in next step so that the inlet data can be mapped? Or is it already mapped and I can run the solvers directly?

Looking forward to your reply.
Thank you in advance.


Best regards,
Esther

sisetrun July 5, 2016 01:42

Hey Esther,

the setup shut be fine...just run your case and with timevaryingMappedFixedValue as BC and the profile is mapped.

Quote:

This boundary conditions interpolates the values from a set of supplied points in space and
time. Supplied data should be specifi ed in constant/boundaryData/ < patchname > where:
- points : pointField with locations
- ddd : supplied values at time ddd
The points should be more or less on a plane since they get triangulated in 2-D.
Best regards

Esther Jin July 7, 2016 04:42

Dear Sisetrun,

According to the points you gave me I found out reason of the problem, now it works. Thank you for your help.

cheers
Esther

amin_jalalian August 14, 2016 06:14

lagrangian mapField
 
I want to separate some boundaries to some walls which had been merged into one wall.
They are some walls of a combustion chamber. particles come into chamber to combust.
I mapField them by mapFieldDict, but O.F only maps lagrangian datas.
What can I do?

sisetrun August 15, 2016 04:44

Hey amin_jalalian,
I do completely get your problem.
Can you please add a picture or try to be more precise?

amin_jalalian August 18, 2016 09:31

mapField Euler-Lagrange field with new wall.
 
2 Attachment(s)
Quote:

Originally Posted by sisetrun (Post 614048)
Hey amin_jalalian,
I do completely get your problem.
Can you please add a picture or try to be more precise?

I draw one quarter of IFRF No.1 combustion chamber and mesh in gambit. Pic has been attached. I put all walls in one boundary by name "walls". After some weeks I dedicate that separate inlet and outlet pipes walls and front and back walls from that boundary which now has top and side walls. Because it is better to put them adiabatic instead of fixed temperature. I named it "other_walls". Thus I have to wall boundary one "walls" which has top and side walls, the other "other_walls" which has inlet & outlet pipes walls and front & back walls.
I want to mapField from previous results. What can I do now?
When I adjust mapFieldsDict in target folder to this:

Code:

patchMap  (  );

cuttingPatches  (other_walls);


O.F only maps lagrangian results.
Excuse because of poor english.

sisetrun August 19, 2016 03:29

Hey,

with mapFields, as far as I know, you can do the following things:
-map fields from one case to a different case, so you can map the whole field from the old case to your new one. If the geometry is the same, use mapFields -consistant
-map patches from old one to knew one by the name of each pactch
-you can use transformPoints -translate to translate one of your meshes. Then you can map the overlapping part

I have just maped U,p,k... fields. Though I do not have any experiences with lagrangian so far.

amin_jalalian August 19, 2016 05:41

Quote:

Originally Posted by sisetrun (Post 614644)
Hey,

with mapFields, as far as I know, you can do the following things:
-map fields from one case to a different case, so you can map the whole field from the old case to your new one. If the geometry is the same, use mapFields -consistant
-map patches from old one to knew one by the name of each pactch
-you can use transformPoints -translate to translate one of your meshes. Then you can map the overlapping part

I have just maped U,p,k... fields. Though I do not have any experiences with lagrangian so far.


Thanks
What does "transformPoints -translate" command do briefly?

sisetrun August 19, 2016 06:11

use transformPoints -translate '(x y z)' in the terminal to translate the Mesh of your current working directory.

FYI:
with surfaceTransformPoints -translate (or -scale) input.stl output.stl you can manipulate your stl geometry

himanshu28 October 12, 2016 18:24

1 Attachment(s)
Quote:

Originally Posted by Chanterz (Post 583791)
Back again!

Ok, so I managed to successfully mapFields with everying, including my cuttingPatch of heliostat, filled out above.

What is also great, is that the cuttingPatch BC's are also mapped into the list of field numbers of the mapped solution files from source.

Here's what I did:

  • copied the 0 files from target case (of the boundary conditions I want of the patches INCLUDING heliostat boundary) into the-previously-blank 3692 file (where the source files 'were' to be uploaded).
  • When I employ mapFields as above, it seems that the mapFields function overwrites the target boundary files and fills it with the list of numbers that have matching boundary conditions between the target and source cases (outlined in patchMap) and leaves the 'heliostat' cutting patch alone.

The number of faces indicating that the coarse source mesh has been mapped onto the fine target mesh is also indicated at the top of these new files.

I have to wait until Monday to run it. I will let you know how it goes.

Hi All,

I am trying something similar and I tried the approach presented above but no luck till now.

I have two geometries with different mesh size and one different patches. Attached the images of source and target geo.

I am trying to use the mapFieldDict for the cases and following is the what mapFieldDict looks like.

Code:

// List of pairs of source/target patches for mapping
patchMap
(
inlet inlet
outlet outlet
wall.ceiling wall.ceiling
);

// List of target patches cutting the source domain (these need to be
// handled specially e.g. interpolated from internal values)
cuttingPatches
(
wall.floor
wall.human
wall.hot
wall.left
emptyZ
);

// ********************************************** //

After running mapFields I am getting a following error.

Code:

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Source: "../source_case" ""
Target: "/media/meisu/Storage/OpenFOAM/meisu-2.4.0/Project_SensorPlacement/Maptest" "target_case"

Create databases as time
Case  : ../source_case
nProcs : 1

Source time: 0
Target time: 0

Create meshes

Source mesh size: 11140        Target mesh size: 9462


Creating and mapping fields for time 0

Creating mesh-to-mesh addressing for region0 and region0 regions using cellVolumeWeight
    Overlap volume: 2.635
Creating AMI between source patch outlet and target patch outlet using faceAreaWeightAMI
    AMI: Creating addressing and weights between 10 source faces and 12 target faces
    AMI: Patch source sum(weights) min/max/average = 1, 1, 1
    AMI: Patch target sum(weights) min/max/average = 0.333333, 0.333333, 0.333333
Creating AMI between source patch inlet and target patch inlet using faceAreaWeightAMI
    AMI: Creating addressing and weights between 4 source faces and 5 target faces
    AMI: Patch source sum(weights) min/max/average = 1, 1, 1
    AMI: Patch target sum(weights) min/max/average = 0.333333, 0.333333, 0.333333
Creating AMI between source patch wall.ceiling and target patch wall.ceiling using faceAreaWeightAMI
    AMI: Creating addressing and weights between 190 source faces and 166 target faces
    AMI: Patch source sum(weights) min/max/average = 1, 1, 1
    AMI: Patch target sum(weights) min/max/average = 0.333333, 0.333333, 0.333333
    interpolating U
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigSegv::sigHandler(int) at ??:?
#2  ? in "/lib/x86_64-linux-gnu/libc.so.6"
#3  ? at ??:?
#4  ? at ??:?
#5  ? at ??:?
#6  ? at ??:?
#7  ? at ??:?
#8  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#9  ? at ??:?
Segmentation fault

I don't know what could be the reason for this.
Is mapField capable of doing what I am trying to do.??

Thanks in advance.

sisetrun October 17, 2016 11:42

Hey,
sorry for the late reply, I have been on holiday :)!
I did not try such a geometry yet, but I think that the problem is in the bottom of your geometry.
In the source, you have the gap in the x-axis. This gap is not present in the target.
The gap also leads to different front and back geometries...
Is it possible to map the inlet, outlet and the top?
Cheers


All times are GMT -4. The time now is 01:08.