View Issue Details

IDProjectCategoryView StatusLast Update
0001694OpenFOAMBugpublic2015-05-24 19:07
ReporterDanielJ Assigned Tohenry  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSUbuntuOS Version14.04
Summary0001694: Particles cannot correctly interact with AMI patches
DescriptionWhenever a particle hits an AMI patch fatal error is reported:

"
--> FOAM FATAL ERROR:
Particle lost across cyclicAMI patches bottom and top at position (0.5 0.05219193 0.04739402)

    From function template<class TrackData>void Foam::particle::hitCyclicAMIPatch(const cyclicAMIPolyPatch&, TrackData&, const vector&)
    in file /opt/OpenFOAM/OpenFOAM-2.3.1/src/lagrangian/basic/lnInclude/particleTemplates.C at line 1072.

"
Steps To ReproduceError occures always when a particle hits AMI patch with transformation.
Additional InformationPull request with correction is on GitHub.
TagsNo tags attached.

Activities

henry

2015-05-16 20:13

manager   ~0004749

Thanks for the bug-report and for developing a fix.

Could you provide a small test-case which reproduces the problem and demonstrates the patch you have developed?

Have you tested your correction for coincident, separated, parallel and non-parallel AMIs?

Also it would help if you could provide the changed files and/or patches here so that we can keep all bug-related information in one place.

DanielJ

2015-05-16 20:23

reporter  

rot_cyclic.zip (47,626 bytes)

DanielJ

2015-05-16 20:32

reporter   ~0004750

I attached a simple case that reproduces the bug.
The patch was tested on rotated AMI patches so it should work on a simpler configurations :)
I attached the patch.

DanielJ

2015-05-16 20:33

reporter  

particle-AMI.patch (4,622 bytes)   
From c3e5510325bfe3f71442874c1273d1ad12247f36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Jasi=C5=84ski?= <daniel.jasinski@gmail.com>
Date: Sat, 16 May 2015 20:24:40 +0200
Subject: [PATCH] particle::hitCyclicAMIPatch - corrected bug

---
 src/lagrangian/basic/particle/particleTemplates.C  |  3 -
 .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.C        | 85 ++++++++++++++++++++--
 .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.H        | 14 ++++
 3 files changed, 93 insertions(+), 9 deletions(-)

diff --git a/src/lagrangian/basic/particle/particleTemplates.C b/src/lagrangian/basic/particle/particleTemplates.C
index 280165d..b6f9e72 100644
--- a/src/lagrangian/basic/particle/particleTemplates.C
+++ b/src/lagrangian/basic/particle/particleTemplates.C
@@ -1086,9 +1086,6 @@ void Foam::particle::hitCyclicAMIPatch
 
     // Now the particle is on the receiving side
 
-    // Have patch transform the position
-    receiveCpp.transformPosition(position_, patchFaceI);
-
     // Transform the properties
     if (!receiveCpp.parallel())
     {
diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
index 9d33b27..82da2fb 100644
--- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
+++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
@@ -922,6 +922,64 @@ void Foam::cyclicAMIPolyPatch::transformPosition
 }
 
 
+void Foam::cyclicAMIPolyPatch::reverseTransformPosition
+(
+    point& l,
+    const label faceI
+) const
+{
+    if (!parallel())
+    {
+        const tensor& T =
+        (
+            reverseT().size() == 1
+          ? reverseT()[0]
+          : reverseT()[faceI]
+        );
+
+        if (transform() == ROTATIONAL)
+        {
+            l = Foam::transform(T, l - rotationCentre_) + rotationCentre_;
+        }
+        else
+        {
+            l = Foam::transform(T, l);
+        }
+    }
+    else if (separated())
+    {
+        const vector& s =
+        (
+            separation().size() == 1
+          ? separation()[0]
+          : separation()[faceI]
+        );
+
+        l += s;
+    }
+}
+
+
+void Foam::cyclicAMIPolyPatch::reverseTransformDirection
+(
+    vector& d,
+    const label faceI
+) const
+{
+    if (!parallel())
+    {
+        const tensor& T =
+        (
+            reverseT().size() == 1
+          ? reverseT()[0]
+          : reverseT()[faceI]
+        );
+
+        d = Foam::transform(T, d);
+    }
+}
+
+
 void Foam::cyclicAMIPolyPatch::calcGeometry
 (
     const primitivePatch& referPatch,
@@ -978,28 +1036,43 @@ Foam::label Foam::cyclicAMIPolyPatch::pointFace
     point& p
 ) const
 {
+    point prt(p);
+    vector nrt(n);
+
+    label nbrFaceI = -1;
+
+    reverseTransformPosition(prt,faceI);
+    reverseTransformDirection(nrt,faceI);
+
     if (owner())
     {
-        return AMI().tgtPointFace
+        nbrFaceI = AMI().tgtPointFace
         (
             *this,
             neighbPatch(),
-            n,
+            nrt,
             faceI,
-            p
+            prt
         );
     }
     else
     {
-        return neighbPatch().AMI().srcPointFace
+        nbrFaceI = neighbPatch().AMI().srcPointFace
         (
             neighbPatch(),
             *this,
-            n,
+            nrt,
             faceI,
-            p
+            prt
         );
     }
+
+    if (nbrFaceI >= 0)
+    {
+        p = prt;
+    }
+
+    return nbrFaceI;
 }
 
 
diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H
index 40cfc95..ff0d3d8 100644
--- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H
+++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H
@@ -329,6 +329,20 @@ public:
                     const label faceI
                 ) const;
 
+                //- Transform a patch-based position from this side to nbr side
+                virtual void reverseTransformPosition
+                (
+                    point& l,
+                    const label faceI
+                ) const;
+
+                //- Transform a patch-based direction from this side to nbr side
+                virtual void reverseTransformDirection
+                (
+                    vector& d,
+                    const label faceI
+                ) const;
+
 
             // Interpolations
 
particle-AMI.patch (4,622 bytes)   

henry

2015-05-16 21:23

manager   ~0004751

Excellent, thanks. If you could provide a short description of the changes necessary that would be useful.

henry

2015-05-16 21:56

manager   ~0004752

I just ran the test-case you provided in OpenFOAM-2.3.x without your patch and without any problems. Does it run correctly for you in OpenFOAM-2.3.x?

DanielJ

2015-05-16 22:47

reporter   ~0004753

OpenFOAM-2.3.x shows this error on simulation time 0.0028. This is the time when particles reach one of the AMI patches.

In method cyclicAMIPolyPatch::pointFace, before looking for neighbour patch face it is necessary to transform location and vector, to be local to the neighbour patch. Additionally in method particle::hitCyclicAMIPatch there is an unnecessary call to the cyclicAMIPolyPatch::transformPosition, since it was already done in the pointFace method.

henry

2015-05-16 22:58

manager   ~0004754

When I run the case you supplied in OpenFOAM-2.3.x it completes without any error. Do you have the same problem in OpenFOAM-2.3.1 and 2.3.x?

DanielJ

2015-05-16 23:07

reporter   ~0004755

The problem occures for me on both 2.3.1 and current 2.3.x when running sprayFoam.
In the simulation did the particles reach the cyclic patch and crossed it correctly?

henry

2015-05-16 23:36

manager   ~0004756

I ran sprayFoam on the case you provided; no warnings, no errors, it completed without issues and yes particles reach the cyclic patch. However, during post-processing with ParaFoam an error is generated:

--> FOAM FATAL ERROR:
    cell, tetFace and tetPt search failure at position (-0.4990717 -1.049392 -0.0003441443)
    for requested cell 405
    If this is a restart or reconstruction/decomposition etc. it is likely that the write precision is not sufficient.
    Either increase 'writePrecision' or set 'writeFormat' to 'binary'

    From function void Foam::particle::initCellFacePt()
    in file /home/dm2/henry/OpenFOAM/OpenFOAM-2.3.x/src/lagrangian/basic/lnInclude/particleI.H at line 758.

DanielJ

2015-05-17 09:15

reporter   ~0004762

This error is very strange since domain bounding box is (-0.5 -0.5 -0.5) (0.5 0.5 0.5).

henry

2015-05-17 15:40

manager   ~0004769

The case runs and post-processes correctly with your patch. I am running a few more tests now.

henry

2015-05-24 19:07

manager   ~0004791

Thanks for the bug-report and patch.

Resolved in OpenFOAM-2.3.x by
commit bd11d30c854688cc42635eb53bc86e7a7ac5c830

Issue History

Date Modified Username Field Change
2015-05-16 20:05 DanielJ New Issue
2015-05-16 20:13 henry Note Added: 0004749
2015-05-16 20:23 DanielJ File Added: rot_cyclic.zip
2015-05-16 20:32 DanielJ Note Added: 0004750
2015-05-16 20:33 DanielJ File Added: particle-AMI.patch
2015-05-16 21:23 henry Note Added: 0004751
2015-05-16 21:56 henry Note Added: 0004752
2015-05-16 22:47 DanielJ Note Added: 0004753
2015-05-16 22:58 henry Note Added: 0004754
2015-05-16 23:07 DanielJ Note Added: 0004755
2015-05-16 23:36 henry Note Added: 0004756
2015-05-17 09:15 DanielJ Note Added: 0004762
2015-05-17 15:40 henry Note Added: 0004769
2015-05-24 19:07 henry Note Added: 0004791
2015-05-24 19:07 henry Status new => resolved
2015-05-24 19:07 henry Resolution open => fixed
2015-05-24 19:07 henry Assigned To => henry