CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (http://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   Using mapFields if the mesh has different regions (http://www.cfd-online.com/Forums/openfoam-pre-processing/84595-using-mapfields-if-mesh-has-different-regions.html)

stevenvanharen February 3, 2011 07:31

Using mapFields if the mesh has different regions
 
Dear all,

I would like to use mapFields to map the velocity field form a simulation containing only one region to a simulation containing multiple regions. Is this possible? Does somebody know how to do it?

On of the regions in the targer folder is the same size as the region in the source folder.

Any help will be appreciated.

Kind regards,

Steven

stevenvanharen February 3, 2011 14:12

Fixed it myself, turned out it was not to hard :D

If anyone needs it let me know.

laurint March 3, 2011 02:16

I would like to hear your solution. I'm mapping from mesh with two region onto a mesh with similar regions, but nothing seems to work.

Lauri

stevenvanharen March 3, 2011 05:03

1 Attachment(s)
Just take a look at this source code.

I added the -region option to the utility and changed:

Code:

  fvMesh meshTarget
        (
            IOobject
            (
                fvMesh::defaultRegion,
                runTimeTarget.timeName(),
                runTimeTarget
            )
        );

into:

Code:

  fvMesh meshTarget
        (
            IOobject
            (
                            regionName,
                            runTimeTarget.timeName(),
                            runTimeTarget,
                            Foam::IOobject::MUST_READ
                            /* 
                fvMesh::defaultRegion,
                runTimeSource.timeName(),
                runTimeSource*/
            )
        );

However, this will only work for consistent meshes and serial cases.

laurint March 3, 2011 05:53

Thank you for the quick reply. Your solution works perfectly.

I added the region-thing also for the source, although now they have to have same names.

samiam1000 October 29, 2013 03:37

I know it's an old post, but I am having the same problems. I would like to map fields from a multiregion problem to the same multiregion one (I mean, same mesh and same regions' name and so on).

I tried to compile the archive you shared, but I get this error:

Code:

zampini@pc-zampini:~/OpenFOAM/zampini-2.2.0/applications/utilities/preProcessing/mapRegionFields$ wmake
SOURCE=mapLagrangian.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/meshTools/lnInclude -I/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude -I/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/finiteVolume/lnInclude -I/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/sampling/lnInclude -IlnInclude -I. -I/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude -I/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/mapLagrangian.o
In file included from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude/Field.H:360:0,
                from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude/scalarField.H:38,
                from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude/dimensionSet.H:46,
                from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude/dimensionedType.H:40,
                from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude/dimensionedScalar.H:38,
                from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude/dimensionedTypes.H:31,
                from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude/GeometricField.H:43,
                from MapLagrangianFields.H:37,
                from mapLagrangian.C:26:
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude/Field.C: In member function ‘void Foam::Field<Type>::operator=(const Foam::VectorSpace<Form, Cmpt, nCmpt>&)’:
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude/Field.C:680:42: warning: typedef ‘VSType’ locally defined but not used [-Wunused-local-typedefs]
    typedef VectorSpace<Form,Cmpt,nCmpt> VSType;
                                          ^
mapLagrangian.C: In function ‘void Foam::mapLagrangian(const Foam::meshToMesh&)’:
mapLagrangian.C:173:29: error: no matching function for call to ‘Foam::passiveParticle::passiveParticle(Foam::Cloud<Foam::passiveParticle>&, const Foam::Vector<double>&, const int&)’
                            )
                            ^
mapLagrangian.C:173:29: note: candidates are:
In file included from mapLagrangian.C:28:0:
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/passiveParticle.H:98:9: note: Foam::passiveParticle::passiveParticle(const Foam::passiveParticle&)
        passiveParticle(const passiveParticle& p)
        ^
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/passiveParticle.H:98:9: note:  candidate expects 1 argument, 3 provided
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/passiveParticle.H:87:9: note: Foam::passiveParticle::passiveParticle(const Foam::polyMesh&, Foam::Istream&, bool)
        passiveParticle
        ^
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/passiveParticle.H:87:9: note:  no known conversion for argument 1 from ‘Foam::Cloud<Foam::passiveParticle>’ to ‘const Foam::polyMesh&’
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/passiveParticle.H:75:9: note: Foam::passiveParticle::passiveParticle(const Foam::polyMesh&, const vector&, Foam::label, bool)
        passiveParticle
        ^
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/passiveParticle.H:75:9: note:  no known conversion for argument 1 from ‘Foam::Cloud<Foam::passiveParticle>’ to ‘const Foam::polyMesh&’
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/passiveParticle.H:61:9: note: Foam::passiveParticle::passiveParticle(const Foam::polyMesh&, const vector&, Foam::label, Foam::label, Foam::label)
        passiveParticle
        ^
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/passiveParticle.H:61:9: note:  candidate expects 5 arguments, 3 provided
mapLagrangian.C:210:60: error: no matching function for call to ‘Foam::meshSearch::meshSearch(const Foam::fvMesh&, bool)’
                meshSearch targetSearcher(meshTarget, false);
                                                            ^
mapLagrangian.C:210:60: note: candidates are:
In file included from mapLagrangian.C:29:0:
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/meshTools/lnInclude/meshSearch.H:180:9: note: Foam::meshSearch::meshSearch(const Foam::polyMesh&, const Foam::treeBoundBox&, Foam::polyMesh::cellRepresentation)
        meshSearch
        ^
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/meshTools/lnInclude/meshSearch.H:180:9: note:  no known conversion for argument 2 from ‘bool’ to ‘const Foam::treeBoundBox&’
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/meshTools/lnInclude/meshSearch.H:171:9: note: Foam::meshSearch::meshSearch(const Foam::polyMesh&, Foam::polyMesh::cellRepresentation)
        meshSearch
        ^
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/meshTools/lnInclude/meshSearch.H:171:9: note:  no known conversion for argument 2 from ‘bool’ to ‘Foam::polyMesh::cellRepresentation’
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/meshTools/lnInclude/meshSearch.H:149:9: note: Foam::meshSearch::meshSearch(const Foam::meshSearch&)
        meshSearch(const meshSearch&);
        ^
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/meshTools/lnInclude/meshSearch.H:149:9: note:  candidate expects 1 argument, 2 provided
mapLagrangian.C:242:58: error: no matching function for call to ‘Foam::IOPosition<Foam::passiveParticle>::IOPosition(Foam::Cloud<Foam::passiveParticle>&)’
                IOPosition<passiveParticle>(targetParcels).write();
                                                          ^
mapLagrangian.C:242:58: note: candidates are:
In file included from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/IOPosition.H:96:0,
                from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/CloudIO.C:28,
                from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/Cloud.C:467,
                from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/Cloud.H:342,
                from mapLagrangian.C:27:
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/IOPosition.C:31:1: note: Foam::IOPosition<ParticleType>::IOPosition(const CloudType&) [with CloudType = Foam::passiveParticle]
 Foam::IOPosition<CloudType>::IOPosition(const CloudType& c)
 ^
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/IOPosition.C:31:1: note:  no known conversion for argument 1 from ‘Foam::Cloud<Foam::passiveParticle>’ to ‘const Foam::passiveParticle&’
In file included from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/CloudIO.C:28:0,
                from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/Cloud.C:467,
                from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/Cloud.H:342,
                from mapLagrangian.C:27:
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/IOPosition.H:50:7: note: Foam::IOPosition<Foam::passiveParticle>::IOPosition(const Foam::IOPosition<Foam::passiveParticle>&)
 class IOPosition
      ^
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/IOPosition.H:50:7: note:  no known conversion for argument 1 from ‘Foam::Cloud<Foam::passiveParticle>’ to ‘const Foam::IOPosition<Foam::passiveParticle>&’
In file included from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/particle.H:562:0,
                from /home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/passiveParticle.H:38,
                from mapLagrangian.C:28:
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/particleTemplates.C: In instantiation of ‘Foam::scalar Foam::particle::trackToFace(const vector&, TrackData&) [with TrackData = double; Foam::scalar = double; Foam::vector = Foam::Vector<double>]’:
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/particleTemplates.C:193:54:  required from ‘Foam::label Foam::particle::track(const vector&, TrackData&) [with TrackData = double; Foam::label = int; Foam::vector = Foam::Vector<double>]’
mapLagrangian.C:178:77:  required from here
/home/zampini/OpenFOAM/OpenFOAM-2.2.0/src/lagrangian/basic/lnInclude/particleTemplates.C:207:43: error: ‘double’ is not a class, struct, or union type
    typedef typename TrackData::cloudType cloudType;
                                          ^
make: *** [Make/linux64GccDPOpt/mapLagrangian.o] Error 1

I am using OpenFOAM 2.2.1.

Any idea?

Thanks a lot,
Samuele

Ahmed Khattab November 5, 2013 18:31

Did you compiled this utility after modification.

stevenvanharen November 7, 2013 19:39

I think the 2.2.2 release has the options sourceRegion and targetRegion as standard in the utility mapFields, so no need to do anything yourself!

samiam1000 November 8, 2013 04:00

That is what I did, finally.

Thanks a lot,

Samuele


All times are GMT -4. The time now is 05:50.