Library source files are located here: $WM_PROJECT_DIR/applications/solvers/coupled/
The bug is in the file conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialThermal/multiMaterialThermal.C
, in the function multiMaterialThermal::indicator (const label) const
to be more specific:
//- $WM_PROJECT_DIR/applications/solvers/coupled/conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialThermal/multiMaterialThermal.C Foam::tmp<Foam::volScalarField> Foam::multiMaterialThermal::indicator ( const label i ) const { const scalarField& mat = materials_.internalField(); tmp<volScalarField> tresult ( new volScalarField ( IOobject ( "indicator", mesh().time().timeName(), mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), mesh(), dimless, zeroGradientFvPatchScalarField::typeName ) ); volScalarField& result = tresult(); forAll (mat, matI) { if (mat[matI] > i - SMALL && mat[matI] < i + SMALL) { result[matI] = 1.0; } else { result[matI] = 0.0; } } result.correctBoundaryConditions(); return tresult; }
the code block if (mat[matI] > i - SMALL && mat[matI] < i + SMALL)
checks whether the matI'th cell is of the i'th material. If so, the indicator is set to one, otherwise it is zero. Everithing is fine while i<16. When i>=16 this check is always false for all cells because of round-off error (SMALL=1e-15):
mat[matI] > i - SMALL && mat[matI] < i + SMALL (16.0 > (16 - 1.e-15)) && (16.0 < (16 + 1.e-15)) (16.0 > 16.0) && (16.0 < 16.0) is false.
And the returned tresultconsists of zeros.
multiMaterialThermal::indicator(label i)is invoked in
multiMaterialThermal::k()`:
Foam::tmp<Foam::volScalarField> Foam::multiMaterialThermal::k() const { tmp<volScalarField> tresult ( new volScalarField ( IOobject ( "kTmp", mesh().time().timeName(), mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), mesh(), dimensionedScalar("zerok", dimensionSet(1, 1, -3, -1, 0), 0), calculatedFvPatchScalarField::typeName ) ); volScalarField& result = tresult(); // Accumulate data for all fields const PtrList<thermalLaw>& laws = *this; forAll (laws, lawI) { result += indicator(lawI)*laws[lawI].k(); } return tresult; }
This function returns thermal conductivity field and it is zero all the way for lawI>=16
.
The library conjugateHeatTransfer
is used, for example, in conjugateHeatSimpleFoam
solver, which blows up when thermal conductivity is zero in a cell.
To me, there is no point in defining materials_
as volScalarField
. It should be rather defined as volLabelField
. My superficial attempt to make modifications to the code wasn't successful:
+ wmake libso myConjugateHeatTransfer Making dependency list for source file thermalModel/thermalLaws/multiMaterialThermal/multiMaterialThermal.C Making dependency list for source file thermalModel/thermalLaws/multiMaterialZonesThermal/multiMaterialZonesThermal.C SOURCE=thermalModel/thermalLaws/multiMaterialThermal/multiMaterialThermal.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-200 -I/opt/foam/foam-extend-3.2/src/finiteVolume/lnInclude -I/opt/foam/foam-extend-3.2/src/thermophysicalModels/radiation/lnInclude -I/opt/foam/foam-extend-3.2/src/thermophysicalModels/basic/lnInclude -I/opt/foam/foam-extend-3.2/src/VectorN/lnInclude -IlnInclude -I. -I/opt/foam/foam-extend-3.2/src/foam/lnInclude -I/opt/foam/foam-extend-3.2/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/multiMaterialThermal.o SOURCE=thermalModel/thermalLaws/multiMaterialZonesThermal/multiMaterialZonesThermal.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-200 -I/opt/foam/foam-extend-3.2/src/finiteVolume/lnInclude -I/opt/foam/foam-extend-3.2/src/thermophysicalModels/radiation/lnInclude -I/opt/foam/foam-extend-3.2/src/thermophysicalModels/basic/lnInclude -I/opt/foam/foam-extend-3.2/src/VectorN/lnInclude -IlnInclude -I. -I/opt/foam/foam-extend-3.2/src/foam/lnInclude -I/opt/foam/foam-extend-3.2/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/multiMaterialZonesThermal.o In file included from /opt/foam/foam-extend-3.2/src/foam/lnInclude/Field.C:27:0, from /opt/foam/foam-extend-3.2/src/foam/lnInclude/Field.H:369, from /opt/foam/foam-extend-3.2/src/foam/lnInclude/DimensionedField.H:42, from /opt/foam/foam-extend-3.2/src/foam/lnInclude/GeometricField.H:44, from /opt/foam/foam-extend-3.2/src/foam/lnInclude/GeometricScalarField.H:38, from /opt/foam/foam-extend-3.2/src/foam/lnInclude/GeometricFields.H:34, from /opt/foam/foam-extend-3.2/src/finiteVolume/lnInclude/volFields.H:38, from lnInclude/thermalLaw.H:45, from lnInclude/multiMaterialThermal.H:41, from thermalModel/thermalLaws/multiMaterialZonesThermal/multiMaterialZonesThermal.H:41, from thermalModel/thermalLaws/multiMaterialZonesThermal/multiMaterialZonesThermal.C:26: /opt/foam/foam-extend-3.2/src/foam/lnInclude/FieldFunctions.C: In instantiation of ‘void Foam::cmptMultiply(Foam::Field<Type>&, const Foam::UList<T>&, const Foam::UList<T>&) [with Type = int]’: /opt/foam/foam-extend-3.2/src/foam/lnInclude/FieldFunctions.C:531:1: required from ‘Foam::tmp<Foam::Field<Type> > Foam::cmptMultiply(const Foam::UList<T>&, const Foam::tmp<Foam::Field<Type> >&) [with Type = int]’ /opt/foam/foam-extend-3.2/src/finiteVolume/lnInclude/fvPatchField.C:331:13: required from ‘void Foam::fvPatchField<Type>::patchFlux(Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh>&, const Foam::fvMatrix<Type>&) const [with Type = int]’ thermalModel/thermalLaws/multiMaterialZonesThermal/multiMaterialZonesThermal.C:93:2: required from here /opt/foam/foam-extend-3.2/src/foam/lnInclude/FieldM.H:166:61: error: call of overloaded ‘cmptMultiply(const int&, const int&)’ is ambiguous OP FUNC(List_ELEM(f2, f2P, i), List_ELEM(f3, f3P, i)); \ ^ /opt/foam/foam-extend-3.2/src/foam/lnInclude/FieldFunctionsM.C:97:5: note: in expansion of macro ‘TFOR_ALL_F_OP_FUNC_F_F’ TFOR_ALL_F_OP_FUNC_F_F \ ^ /opt/foam/foam-extend-3.2/src/foam/lnInclude/FieldFunctions.C:531:1: note: in expansion of macro ‘BINARY_FUNCTION’ BINARY_FUNCTION(Type, Type, Type, cmptMultiply) ^ /opt/foam/foam-extend-3.2/src/foam/lnInclude/FieldM.H:166:61: note: candidates are: OP FUNC(List_ELEM(f2, f2P, i), List_ELEM(f3, f3P, i)); \ ^ /opt/foam/foam-extend-3.2/src/foam/lnInclude/FieldFunctionsM.C:97:5: note: in expansion of macro ‘TFOR_ALL_F_OP_FUNC_F_F’ TFOR_ALL_F_OP_FUNC_F_F \ ^ /opt/foam/foam-extend-3.2/src/foam/lnInclude/FieldFunctions.C:531:1: note: in expansion of macro ‘BINARY_FUNCTION’ BINARY_FUNCTION(Type, Type, Type, cmptMultiply) ^