View Issue Details

IDProjectCategoryView StatusLast Update
0004116OpenFOAMBugpublic2024-07-23 19:22
Reportermichael_h Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionsuspended 
Platformx86_64OSLinuxOS VersionSUSE Leap 15.6
Product Version12 
Summary0004116: Coded boundary conditions do not work together with mesh to mesh mapping
DescriptionIf the boundary condition codedFixedValue or codedMixed is used for a patch where the number of faces changes during mesh to mesh mapping then OpenFOAM crashed afterwards.

If OpenFOAM 12 is compiled with debugging enabled then the following error occurs. The regular version fails later with a floating point exception.
    
Creating patchToPatch between source patch farField and target patch farField using intersection
    patchToPatch: Calculating couplings between 28 source faces and 26 target faces
        Source min/average/max coverage = 1/1/1
        Target min/average/max coverage = 1/1/1
        Source average openness/error/depth/angle = 1.51218e-16/1.84159e-15/6.99976e-16/0
        Source max openness/error/depth/angle = 4.24329e-16/3.88393e-15/2.09133e-15/0
        104 couplings calculated in 0.016505s
Selecting motion diffusion: directional
deltaT = 4e-06
Time = 0.001504s

PIMPLE: Iteration 1
DICPCG: Solving for cellMotionUx, Initial residual = 0.00135445, Final residual = 3.02757e-09, No Iterations 26


--> FOAM FATAL ERROR:
 Field<scalar> f1(28), Field<vector> f2(28) and Field<vector> f3(26)
    for operation f1 = f2 & f3

    From function void Foam::checkFields(const Foam::UList<T>&, const Foam::UList<Key>&, const Foam::UList<Type3>&, const char*) [with Type1 = double; Type2 = Foam::Vector<double>; Type3 = Foam::Vector<double>]
    in file /home/michael/OpenFOAM/OpenFOAM-12-debug/src/OpenFOAM/lnInclude/FieldM.H at line 75.

FOAM aborting

#0 Foam::error::printStack(Foam::Ostream&) at ~/OpenFOAM/OpenFOAM-12-debug/src/OSspecific/POSIX/printStack.C:218
#1 Foam::error::abort() at ~/OpenFOAM/OpenFOAM-12-debug/src/OpenFOAM/lnInclude/error.C:206
#2 Foam::Ostream& Foam::operator<< <Foam::error>(Foam::Ostream&, Foam::errorManip<Foam::error>) at ~/OpenFOAM/OpenFOAM-12-debug/src/OpenFOAM/lnInclude/errorManip.H:85 (discriminator 4)
#3 void Foam::checkFields<double, Foam::Vector<double>, Foam::Vector<double> >(Foam::UList<double> const&, Foam::UList<Foam::Vector<double> > const&, Foam::UList<Foam::Vector<double> > const&, char const*) at ~/OpenFOAM/OpenFOAM-12-debug/src/OpenFOAM/lnInclude/FieldM.H:75
#4 void Foam::dot<Foam::Vector<double>, Foam::Vector<double> >(Foam::Field<Foam::innerProduct<Foam::Vector<double>, Foam::Vector<double> >::type>&, Foam::UList<Foam::Vector<double> > const&, Foam::UList<Foam::Vector<double> > const&) at ~/OpenFOAM/OpenFOAM-12-debug/src/OpenFOAM/lnInclude/FieldFunctions.C:775
#5 Foam::tmp<Foam::Field<Foam::innerProduct<Foam::Vector<double>, Foam::Vector<double> >::type> > Foam::operator&<Foam::Vector<double>, Foam::Vector<double> >(Foam::UList<Foam::Vector<double> > const&, Foam::UList<Foam::Vector<double> > const&) at ~/OpenFOAM/OpenFOAM-12-debug/src/OpenFOAM/lnInclude/FieldFunctions.C:775
#6 Foam::correctUphiBCs(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>&, bool) at ~/OpenFOAM/OpenFOAM-12-debug/src/finiteVolume/cfdTools/general/correctPhi/correctUphiBCs.C:66
#7 Foam::solvers::incompressibleFluid::motionCorrector() at ~/OpenFOAM/OpenFOAM-12-debug/applications/modules/incompressibleFluid/moveMesh.C:59 (discriminator 2)
#8 ? at ~/OpenFOAM/OpenFOAM-12-debug/applications/solvers/foamRun/foamRun.C:143
#9 ? in "/lib64/libc.so.6"
#10 __libc_start_main in "/lib64/libc.so.6"
#11 ? at /home/abuild/rpmbuild/BUILD/glibc-2.38/csu/../sysdeps/x86_64/start.S:117
Steps To ReproduceTake the tutorial incompressibleFluid/movingCone and change the farField dictionary in 0/U from noSlip to

    farField
    {
        type codedFixedValue;
        value uniform (0 0 0);
        name codedFarField;
        code
        #{
            operator==(vector(0, 0, 0));
        #};
    }

For convenience the complete case is also attached.
TagsNo tags attached.

Activities

michael_h

2024-07-21 18:11

reporter  

movingConeCode.tar.gz (4,595 bytes)

henry

2024-07-21 18:51

manager   ~0013318

Correct, the "coded" BCs do not provide the hooks for mesh changes, you will either need to write your BC derived directly from one of the existing BCs and provide the appropriate mesh update functions or provide funding for further development of "coded" BCs to support mesh changes.

michael_h

2024-07-23 17:48

reporter   ~0013321

I think the fix is quite simple. Patch attached.
codedMeshToMesh.diff (3,270 bytes)   
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C
index aa184512bb..2ad2b173cd 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C
@@ -184,6 +184,17 @@ Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
 }
 
 
+template<class Type>
+void Foam::codedFixedValueFvPatchField<Type>::reset(const fvPatchField<Type>& ptf)
+{
+    fvPatchField<Type>::reset(ptf);
+    if (redirectPatchFieldPtr_.valid())
+    {
+        redirectPatchFieldPtr_->reset(ptf);
+    }
+}
+
+
 template<class Type>
 void Foam::codedFixedValueFvPatchField<Type>::updateCoeffs()
 {
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H
index bef1db863b..26abf5bd64 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H
@@ -176,6 +176,9 @@ public:
         //- Get reference to the underlying patch
         const fvPatchField<Type>& redirectPatchField() const;
 
+        //- Reset the fvPatchField to the given fvPatchField
+        virtual void reset(const fvPatchField<Type>& ptf);
+
         //- Update the coefficients associated with the patch field
         virtual void updateCoeffs();
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C
index 2bb712bfe5..b765dbf718 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C
@@ -183,6 +183,17 @@ Foam::codedMixedFvPatchField<Type>::redirectPatchField() const
 }
 
 
+template<class Type>
+void Foam::codedMixedFvPatchField<Type>::reset(const fvPatchField<Type>& ptf)
+{
+    mixedFvPatchField<Type>::reset(ptf);
+    if (redirectPatchFieldPtr_.valid())
+    {
+        redirectPatchFieldPtr_->reset(ptf);
+    }
+}
+
+
 template<class Type>
 void Foam::codedMixedFvPatchField<Type>::updateCoeffs()
 {
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H
index 8d26670bbb..a59c25de53 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H
@@ -183,6 +183,9 @@ public:
         //- Get reference to the underlying patchField
         const mixedFvPatchField<Type>& redirectPatchField() const;
 
+        //- Reset the fvPatchField to the given fvPatchField
+        virtual void reset(const fvPatchField<Type>& ptf);
+
         //- Update the coefficients associated with the patch field
         virtual void updateCoeffs();
 
codedMeshToMesh.diff (3,270 bytes)   

henry

2024-07-23 19:22

manager   ~0013322

I don't think your proposed change handles the need to map data, that would require mesh-change call-backs.

henry

2024-07-23 19:22

manager   ~0013323

Pending funding.

Issue History

Date Modified Username Field Change
2024-07-21 18:11 michael_h New Issue
2024-07-21 18:11 michael_h File Added: movingConeCode.tar.gz
2024-07-21 18:51 henry Note Added: 0013318
2024-07-23 17:48 michael_h Note Added: 0013321
2024-07-23 17:48 michael_h File Added: codedMeshToMesh.diff
2024-07-23 19:22 henry Note Added: 0013322
2024-07-23 19:22 henry Assigned To => henry
2024-07-23 19:22 henry Status new => closed
2024-07-23 19:22 henry Resolution open => suspended
2024-07-23 19:22 henry Note Added: 0013323