CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Error In patch type 'genericPatch' not type 'directMappedPatchBase' (http://www.cfd-online.com/Forums/openfoam-programming-development/126307-error-patch-type-genericpatch-not-type-directmappedpatchbase.html)

hua1015 November 13, 2013 22:49

Error In patch type 'genericPatch' not type 'directMappedPatchBase'
 
Hi, foamers,
I want to create a 2D simulation just like the Openfoam-1.6-ext chtMultiRegionFoam using mixed coupled boundary condition.
After compiled successfully, but fail in my case.
here is the error:
--> FOAM FATAL ERROR:

patch type 'genericPatch' not type 'directMappedPatchBase'
for patch UP of field B in file "/home/junhuapan/OF_tutorials/i_c_mhd/0/fluid/B"

From function MixedBCoupledFvPatchScalarField::MixedBCoupledFvPa tchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)

in file coupledFvPatchFields/regionCoupleB/MixedBCoupledFvPatchScalarField.C at line 91.

here is my MixedBCoupledFvPatchScalar.C
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

\*---------------------------------------------------------------------------*/

#include "MixedBCoupledFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "directMappedPatchBase.H"


// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

Foam::MixedBCoupledFvPatchScalarField::
MixedBCoupledFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(p, iF),
neighbourFieldName_("undefined-neighbourFieldName")

{
this->refValue() = 0.0;
this->refGrad() = 0.0;
this->valueFraction() = 1.0;
}


Foam::MixedBCoupledFvPatchScalarField::
MixedBCoupledFvPatchScalarField
(
const MixedBCoupledFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
mixedFvPatchScalarField(ptf, p, iF, mapper),
neighbourFieldName_(ptf.neighbourFieldName_)

{}


Foam::MixedBCoupledFvPatchScalarField::
MixedBCoupledFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
mixedFvPatchScalarField(p, iF),
neighbourFieldName_(dict.lookup("neighbourFieldNam e"))

{
if (!isA<directMappedPatchBase>(this->patch().patch()))
{
FatalErrorIn
(
"MixedBCoupledFvPatchScalarField::"
"MixedBCoupledFvPatchScalarField\n"
"(\n"
" const fvPatch& p,\n"
" const DimensionedField<scalar, volMesh>& iF,\n"
" const dictionary& dict\n"
")\n"
) << "\n patch type '" << p.type()
<< "' not type '" << directMappedPatchBase::typeName << "'"
<< "\n for patch " << p.name()
<< " of field " << dimensionedInternalField().name()
<< " in file " << dimensionedInternalField().objectPath()
<< exit(FatalError);
}

fvPatchScalarField::operator=(scalarField("value", dict, p.size()));

if (dict.found("refValue"))
{
// Full restart
refValue() = scalarField("refValue", dict, p.size());
refGrad() = scalarField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
}
else
{
// Start from user entered data. Assume fixedValue.
refValue() = *this;
refGrad() = 0.0;
valueFraction() = 1.0;
}
}


Foam::MixedBCoupledFvPatchScalarField::
MixedBCoupledFvPatchScalarField
(
const MixedBCoupledFvPatchScalarField& wtcsf,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(wtcsf, iF),
neighbourFieldName_(wtcsf.neighbourFieldName_)

{}


// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //



void Foam::MixedBCoupledFvPatchScalarField::updateCoeff s()
{
if (updated())
{
return;
}

// Get the coupling information from the directMappedPatchBase
const directMappedPatchBase& mpp = refCast<const directMappedPatchBase>
(
patch().patch()
);
const polyMesh& nbrMesh = mpp.sampleMesh();
const fvPatch& nbrPatch = refCast<const fvMesh>
(
nbrMesh
).boundary()[mpp.samplePolyPatch().index()];



// Force recalculation of mapping and schedule

const mapDistribute& distMap = mpp.map();

tmp<scalarField> intFld = patchInternalField();


const MixedBCoupledFvPatchScalarField& nbrField =
refCast<const MixedBCoupledFvPatchScalarField>
(
nbrPatch.lookupPatchField<volScalarField, scalar>
(
neighbourFieldName_
)
);

// Swap to obtain full local values of neighbour internal field
scalarField nbrIntFld = nbrField.patchInternalField();
mapDistribute::distribute
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(), // what to send
distMap.constructMap(), // what to receive
nbrIntFld
);

// Swap to obtain full local values of neighbour K*delta
const dictionary& transportProperties =
nbrField.db().lookupObject<IOdictionary>("transpor tProperties");

dimensionedScalar MuZegma1(transportProperties.lookup("MuZegma"));

scalarField nbrKDelta = MuZegma1.value()*nbrPatch.deltaCoeffs();



mapDistribute::distribute
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(), // what to send
distMap.constructMap(), // what to receive
nbrKDelta
);

// const objectRegistry& db2=ownPatch.thisDb();
const dictionary& transportProperties1 =
db().lookupObject<IOdictionary>("transportProperti es");

dimensionedScalar MuZegma2(transportProperties1.lookup("MuZegma"));

tmp<scalarField> myKDelta = MuZegma2.value()*patch().deltaCoeffs();


// Both sides agree on
// - B : (myKDelta*fld + nbrKDelta*nbrFld)/(myKDelta+nbrKDelta)
// - gradient : (B-fld)*delta
// We've got a degree of freedom in how to implement this in a mixed bc.
// (what gradient, what fixedValue and mixing coefficient)
// Two reasonable choices:
// 1. specify above temperature on one side (preferentially the high side)
// and above gradient on the other. So this will switch between pure
// fixedvalue and pure fixedgradient
// 2. specify gradient and temperature such that the equations are the
// same on both sides. This leads to the choice of
// - refGradient = zero gradient
// - refValue = neighbour value
// - mixFraction = nbrKDelta / (nbrKDelta + myKDelta())


this->refValue() = nbrIntFld;

this->refGrad() = 0.0;

this->valueFraction() = nbrKDelta / (nbrKDelta + myKDelta());

mixedFvPatchScalarField::updateCoeffs();

}

here is my B in '0' of fluid domain:
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object B;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [1 0 -2 0 0 -1 0];

internalField uniform 5;

boundaryField
{
L
{
type fixedValue;
value uniform 0;
}

R
{
type fixedValue;
value uniform 0;
}

UP
{
type MixedBCoupled;
neighbourRegionName u_solid;
neighbourPatchName U_D;
neighbourFieldName B;
value $internalField;
}

D
{
type MixedBCoupled;
neighbourRegionName d_solid;
neighbourPatchName D_U;
neighbourFieldName B;
value $internalField;
}

frontAndBackPlanes
{
type empty;
}
}

Thanks for any suggestions.


All times are GMT -4. The time now is 22:04.