View Issue Details

IDProjectCategoryView StatusLast Update
0000638OpenFOAMBugpublic2013-03-20 14:28
Reporteruser331Assigned Touser4 
PriorityhighSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
PlatformLinuxOSOpenSUSEOS Version11.4
Summary0000638: polyMesh::updateMesh(const mapPolyMesh&) fails to update pointFields
DescriptionI was testing the combination of motionSolvers and refinement and found that that the pointFields in the object registry aren't updated as they should be.
Steps To Reproduce1. Unpack and compile solver sprayDyMFoam
2. Unpack and compile library dynamicMotionSolverRefineFvMesh
3. Unpack and run sprayDyMFoam on aachenBombMoveRefine

You will notice that pointMotionUy is not mapped when updateMesh is called.
Additional InformationI tried to manually map the fields inside the dynamicMotionSolverRefineFvMesh::refine and ::unrefine functions by:

pointMesh motionUpdate(*this);
motionUpdate(map);

where map is the mapPolyMesh returned after the refinement (but it could be any topology change). Now the mapping is attempted, but fails with:

Not mapping point<Type>Field fieldName since originating mesh differs from that of mapper.

As pointed out in the following thread, this may be an issue with pointer inconsistency:

http://www.cfd-online.com/Forums/openfoam-programming-development/106469-mapping-pointfields-topology-changes.html
TagsNo tags attached.

Activities

user331

2012-08-29 23:00

 

user331

2012-08-29 23:01

 

sprayDyMFoam.tar.gz (4,138 bytes)

user331

2012-08-29 23:01

 

user4

2012-08-30 09:09

  ~0001645

Can you try e.g. refineHexMesh? This should read and map pointScalarFields and pointVectorFields. Just create a blockMesh, create a cellSet and put a pointScalarField in the 0 directory.

     refineHexMesh <cellSet>

user4

2012-08-30 18:13

  ~0001653

Just tried and refineHexMesh has the same problem. The pointMesh gets deleted before mapping occurs.

user331

2012-08-30 18:43

  ~0001655

Last edited: 2012-08-30 19:33

I was just about to post this but you beat my to it. Early morning meeting. Let me know if there are any other tests I can run to help with this.

I don't know if this will help, but when trying to use setFields on a pointScalarField, I get that the field is not supported. Exact error message is:

--> FOAM Warning :
    From function setCellField::iNew::operator()(Istream& is)
    in file setFields.C at line 156
    field type pointScalarFieldValue not currently supported
--> FOAM Warning :
    From function setCellField::iNew::operator()(Istream& is)
    in file setFields.C at line 156
    field type pointMotionUy not currently supported

I don't know if this is simply a syntax error in the setFieldsDict, I've uploaded it and the topoSetDict I used to create the cellSet

user331

2012-08-30 19:32

 

setFieldsDict (1,238 bytes)   
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.1.x                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      setFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

defaultFieldValues
(
    //volScalarFieldValue C7H16 0
    //pointScalarFieldValue pointMotionUy uniform 0
);

regions
(
    // Set cell values
    // (does zerogradient on boundaries)
    boxToCell
    {
        box (-0.005 0.045 -0.005) (0.005 0.055 0.005);

        fieldValues
        (
            volScalarFieldValue C7H16 0.75
	    pointScalarFieldValue pointMotionUy 0.5
        );
    }

);

// ************************************************************************* //
setFieldsDict (1,238 bytes)   

user331

2012-08-30 19:32

 

topoSetDict (10,146 bytes)   
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.1.x                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// List of actions. Each action is a dictionary with e.g.
//     // name of set
//     name    c0;
//
//     // type: pointSet/faceSet/cellSet/faceZoneSet/cellZoneSet
//     type    cellSet;
//
//     // action to perform on set. Two types:
//     // - require no source : clear/invert/remove
//     //       clear  : clears set or zone
//     //       invert : select all currently non-selected elements
//     //       remove : removes set or zone
//     // - require source    : new/add/delete/subset
//     //       new    : create new set or zone from source
//     //       add    : add source to contents
//     //       delete : deletes source from contents
//     //       subset : keeps elements both in contents and source
//     action  new;
//
// The source entry varies according to the type of set:
//
// cellSet
// ~~~~~~~
//
//    // Select by explicitly providing cell labels
//    source labelToCell;
//    sourceInfo
//    {
//        value (12 13 56);   // labels of cells
//    }
//
//    // Copy elements from cellSet
//    source cellToCell;
//    sourceInfo
//    {
//        set c1;
//    }
//
//    // Cells in cell zone
//    source zoneToCell;
//    sourceInfo
//    {
//        name ".*Zone";      // Name of cellZone, regular expressions allowed
//    }
//
//    // Cells on master or slave side of faceZone
//    source faceZoneToCell;
//    sourceInfo
//    {
//        name ".*Zone";      // Name of faceZone, regular expressions allowed
//        option master;      // master/slave
//    }
//
//    // Select based on faceSet
//    source faceToCell;
//    sourceInfo
//    {
//        set f0;             // Name of faceSet
//
//        //option neighbour; // cell with neighbour in faceSet
//        //option owner;     //  ,,       owner
//        option any;         // cell with any face in faceSet
//        //option all;       // cell with all faces in faceSet
//    }
//
//    // Select based on pointSet
//    source pointToCell;
//    sourceInfo
//    {
//        set p0;
//        option any;         // cell with any point in pointSet
//        //option all;       // cell with all points in pointSet
//    }
//
//    // Select based on cellShape
//    source shapeToCell;
//    sourceInfo
//    {
//        type hex;           // hex/wedge/prism/pyr/tet/tetWedge/splitHex
//    }
//
//    // Cells with cell centre within box
//    source boxToCell;
//    sourceInfo
//    {
//       box   (0 0 0) (1 1 1);
//    }
//
//    // Cells with cell centre within box
//    // Is skewed, rotated box. Given as origin and three spanning vectors.
//    source rotatedBoxToCell;
//    sourceInfo
//    {
//       origin   (0.2 0.2 -10);
//       i        (0.2 0.2 0);
//       j        (-0.2 0.2 0);
//       k        (10 10 10);
//    }
//
//    // Cells with centre within cylinder
//    source cylinderToCell;
//    sourceInfo
//    {
//       p1       (0.2 0.2 -10); // start point on cylinder axis
//       p2       (0.2 0.2 0);   // end point on cylinder axis
//       radius   5.0;
//    }
//
//    // Cells with centre within sphere
//    source sphereToCell;
//    sourceInfo
//    {
//       centre   (0.2 0.2 -10);
//       radius   5.0;
//    }
//
//    // Cells with cellCentre nearest to coordinates
//    source nearestToCell;
//    sourceInfo
//    {
//       points ((0 0 0) (1 1 1)(2 2 2));
//    }
//
//    // Select based on surface
//    source surfaceToCell;
//    sourceInfo
//    {
//        file            "www.avl.com-geometry.stl";
//        outsidePoints   ((-99 -99 -59));    // definition of outside
//        includeCut      false;              // cells cut by surface
//        includeInside   false;              // cells not on outside of surf
//        includeOutside  false;              // cells on outside of surf
//        nearDistance    -1;                 // cells with centre near surf
//                                            // (set to -1 if not used)
//        curvature       0.9;                // cells within nearDistance
//                                            // and near surf curvature
//                                            // (set to -100 if not used)
//    }
//
//    // values of field within certain range
//    source fieldToCell;
//    sourceInfo
//    {
//        fieldName   U;      // Note: uses mag(U) since volVectorField
//        min         0.1;
//        max         0.5;
//    }
//
//    // Mesh region (non-face connected part of (subset of)mesh)
//    source regionToCell;
//    sourceInfo
//    {
//        set         c0;         // name of cellSet giving mesh subset
//        insidePoint (1 2 3);    // point inside region to select
//    }
//
//    // Cells underneath plane such that volume is reached. Can be used
//    // in setFields.
//    source targetVolumeToCell;
//    sourceInfo
//    {
//        volume  2e-05;
//        normal  (1 1 1);
//        //set     mask;       // optional cellSet to delimit search
//    }
//
//
//
// faceSet
// ~~~~~~~
//
//    // Copy elements from faceSet
//    source faceToFace;
//    sourceInfo
//    {
//        set f1;
//    }
//
//    // Select based on cellSet
//    source cellToFace;
//    sourceInfo
//    {
//        set c0;
//        option all;         // All faces of cells
//        //option both;      // Only faces whose owner&neighbour are in cellSet
//    }
//
//    // Select based on pointSet
//    source pointToFace;
//    sourceInfo
//    {
//        set p0;
//        option any;         // Faces using any point in pointSet
//        //option all        // Faces with all points in pointSet
//    }
//
//    //  Select by explicitly providing face labels
//    source labelToFace;
//    sourceInfo
//    {
//        value (12 13 56);   // labels of faces
//    }
//
//    // All faces of patch
//    source patchToFace;
//    sourceInfo
//    {
//        name ".*Wall";      // Name of patch, regular expressions allowed
//    }
//
//    // All faces of faceZone
//    source zoneToFace;
//    sourceInfo
//    {
//        name ".*Zone1";     // Name of faceZone, regular expressions allowed
//    }
//
//    // Faces with face centre within box
//    source boxToFace;
//    sourceInfo
//    {
//        box  (0 0 0) (1 1 1);
//    }
//
//    // Faces with normal to within certain angle aligned with vector.
//    source normalToFace;
//    sourceInfo
//    {
//        normal (0 0 1);     // Vector
//        cos     0.01;       // Tolerance (max cos of angle)
//    }
//
//    // Walk on faces in faceSet, starting from face nearest given position
//    source  regionToFace;
//    sourceInfo
//    {
//        set         f0;
//        nearPoint   (0.1 0.1 0.005);
//    }
//
//
//
// pointSet
// ~~~~~~~
//
//    // Copy elements from pointSet
//    source pointToPoint;
//    sourceInfo
//    {
//        set p1;
//    }
//
//    // Select based on cellSet
//    source cellToPoint;
//    sourceInfo
//    {
//        set c0;
//        option all;         // all points of cell
//    }
//
//    // Select based on faceSet
//    source faceToPoint;
//    sourceInfo
//    {
//        set f0;             // name of faceSet
//        option all;         // all points of face
//    }
//
//    // Select by explicitly providing point labels
//    source labelToPoint;
//    sourceInfo
//    {
//        value (12 13 56);   // labels of points
//    }
//
//    // All points in pointzone
//    source zoneToPoint;
//    sourceInfo
//    {
//        name ".*Zone";      // name of pointZone, regular expressions allowed
//    }
//
//    // Points nearest to coordinates
//    source nearestToPoint;
//    sourceInfo
//    {
//       points ((0 0 0) (1 1 1));
//    }
//
//    // Points with coordinate within box
//    source boxToPoint;
//    sourceInfo
//    {
//       box   (0 0 0) (1 1 1);
//    }
//
//    // Select based on surface
//    source surfaceToPoint;
//    sourceInfo
//    {
//        file            "www.avl.com-geometry.stl";
//        nearDistance    0.1;    // points near to surface
//        includeInside   false;  // points on inside of surface
//                                // (requires closed surface with consistent
//                                //  normals)
//        includeOutside  false;  //   ,,    outside  ,,
//    }
//
//
//
//
// cellZoneSet
// ~~~~~~~~~~~
// (mirrors operations on a cellSet into a cellZone)
//
//    // Select based on cellSet
//    source setToCellZone;
//    sourceInfo
//    {
//        set c0;           // name of cellSet
//    }
//
//
//
// faceZoneSet
// ~~~~~~~~~~~
//    // Select based on faceSet without orientation
//    source setToFaceZone;
//    sourceInfo
//    {
//        faceSet f0;       // name of faceSet
//    }
//
//    // Select based on faceSet, using cellSet to determine orientation
//    source setsToFaceZone;
//    sourceInfo
//    {
//        faceSet f0;       // name of faceSet
//        cellSet c0;       // name of cellSet of slave side
//    }
//

actions
(
    // Example:pick up internal faces on outside of cellSet
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    // Load initial cellSet
    {
        name    c0;
        type    cellSet;
        action  new;
        source boxToCell;
        sourceInfo
        {
	  box (-0.005 0.045 -0.005) (0.005 0.055 0.005);
        }
    }
);

// ************************************************************************* //
topoSetDict (10,146 bytes)   

user4

2012-08-31 11:48

  ~0001656

In polyMeshClear.C can you try moving the pointMesh::Delete(*this) out of clearGeom() and clearAddressing() and into clearOut()? This will keep the pointMesh around during geometry and topology changes. It solves the refineHexMesh test but needs a bit more testing before I commit it.

2) correct, setFields does not support pointFields. Probably not hard to add. Do you see any use for it?

user331

2012-08-31 19:37

  ~0001667

Last edited: 2012-08-31 19:40

Thanks, moving the call makes the mapping happen and the pointFields are mapped. The solver proceeeds for quite a few timesteps until the refinement engine performs an unrefinement, which leads to an error similar to the first time around:

--> FOAM FATAL ERROR:
Incompatible size before mapping. Field size: 42841 map size: 42917

    From function void MapInternalField<Type, MeshMapper, pointMesh>::operator()
(
    Field<Type>& field,
    const MeshMapper& mapper
) const
    in file lnInclude/MapPointField.H at line 79.

I think this may have to do with trying to do two consecutive topology change operations, as the refinement mapping alone seems to have no problems; I checked the created meshes and pointFields are created as they should be.

I don't know if this is still a problem with the polyMesh mapping or if it has to do with the way the dynamicRefine portions of the code do unrefinement. I've attached a complete log of the run.

user331

2012-08-31 19:37

 

log.sprayDyMFoam (86,957 bytes)

user4

2012-09-04 16:03

  ~0001670

I've pushed 91aaca36bd39bef47bc74803961d07db1160d99c which in addition to that pointMesh deletion moved to clearOut also uses pointMesh::New to construct a pointMesh. Your sprayDyMFoam now runs past unrefinement - it only maps pointMotionUy once (attached log).

user4

2012-09-04 16:04

 

log.sprayDyMFoam.gz (523,859 bytes)

user331

2012-09-04 18:34

  ~0001671

Last edited: 2012-09-04 19:18

Thanks Mattijs. The mapping is working now. Interesting about the temperature dropping; even though I have some custom libraries that handle that, I wonder if this is related to the timestep shrinking issue; I know that with smaller mesh size with refinement and movement I'll get a smaller timestep, but down to 1e-20 or so seems a bit excessive. Some more tests, when I find anything conclusive I'll report back.

user331

2012-09-06 20:19

  ~0001676

This issue can now be closed; it turns out the refinement operation should be carried out before the movement operation to keep the time step from plummetting. Somehow refining after movement causes the velocity field to increase by a ridiculous amount.

I'm now going to learn how to play with my shiny new toy...thanks for the responsiveness!

Issue History

Date Modified Username Field Change
2012-08-29 23:00 user331 New Issue
2012-08-29 23:00 user331 File Added: aachenBombMoveRefine.tar.gz
2012-08-29 23:01 user331 File Added: sprayDyMFoam.tar.gz
2012-08-29 23:01 user331 File Added: dynamicMotionSolverRefineFvMesh.tar.gz
2012-08-30 09:09 user4 Note Added: 0001645
2012-08-30 18:13 user4 Note Added: 0001653
2012-08-30 18:43 user331 Note Added: 0001655
2012-08-30 19:31 user331 Note Edited: 0001655
2012-08-30 19:32 user331 File Added: setFieldsDict
2012-08-30 19:32 user331 File Added: topoSetDict
2012-08-30 19:33 user331 Note Edited: 0001655
2012-08-31 11:48 user4 Note Added: 0001656
2012-08-31 19:37 user331 Note Added: 0001667
2012-08-31 19:37 user331 File Added: log.sprayDyMFoam
2012-08-31 19:40 user331 Note Edited: 0001667
2012-09-04 16:03 user4 Note Added: 0001670
2012-09-04 16:04 user4 File Added: log.sprayDyMFoam.gz
2012-09-04 18:34 user331 Note Added: 0001671
2012-09-04 19:10 user331 Note Edited: 0001671
2012-09-04 19:18 user331 Note Edited: 0001671
2012-09-06 20:19 user331 Note Added: 0001676
2012-10-08 09:23 user2 Status new => resolved
2012-10-08 09:23 user2 Resolution open => fixed
2012-10-08 09:23 user2 Assigned To => user4