Commit 36e845a7 authored by mattijs's avatar mattijs
Browse files

ENH: Allow derivation of constraint types (for pointFields only). Allow usage of

non constraint patchFields on constraint patch types (all fields)
parent 93a0172f
......@@ -72,7 +72,8 @@ GeometricBoundaryField
(
const BoundaryMesh& bmesh,
const DimensionedField<Type, GeoMesh>& field,
const wordList& patchFieldTypes
const wordList& patchFieldTypes,
const wordList& constraintTypes
)
:
FieldField<PatchField, Type>(bmesh.size()),
......@@ -83,18 +84,22 @@ GeometricBoundaryField
Info<< "GeometricField<Type, PatchField, GeoMesh>::"
"GeometricBoundaryField::"
"GeometricBoundaryField(const BoundaryMesh&, "
"const Field<Type>&, const wordList&)"
"const Field<Type>&, const wordList&, const wordList&)"
<< endl;
}
if (patchFieldTypes.size() != this->size())
if
(
patchFieldTypes.size() != this->size()
|| (constraintTypes.size() && (constraintTypes.size() != this->size()))
)
{
FatalErrorIn
(
"GeometricField<Type, PatchField, GeoMesh>::"
"GeometricBoundaryField::"
"GeometricBoundaryField(const BoundaryMesh&, "
"const Field<Type>&, const wordList&)"
"const Field<Type>&, const wordList&, const wordList&)"
) << "Incorrect number of patch type specifications given" << nl
<< " Number of patches in mesh = " << bmesh.size()
<< " number of patch type specifications = "
......@@ -102,18 +107,38 @@ GeometricBoundaryField
<< abort(FatalError);
}
forAll(bmesh_, patchi)
if (constraintTypes.size())
{
set
(
patchi,
PatchField<Type>::New
forAll(bmesh_, patchi)
{
set
(
patchFieldTypes[patchi],
bmesh_[patchi],
field
)
);
patchi,
PatchField<Type>::New
(
patchFieldTypes[patchi],
constraintTypes[patchi],
bmesh_[patchi],
field
)
);
}
}
else
{
forAll(bmesh_, patchi)
{
set
(
patchi,
PatchField<Type>::New
(
patchFieldTypes[patchi],
bmesh_[patchi],
field
)
);
}
}
}
......
......@@ -231,14 +231,15 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const IOobject& io,
const Mesh& mesh,
const dimensionSet& ds,
const wordList& patchFieldTypes
const wordList& patchFieldTypes,
const wordList& actualPatchTypes
)
:
DimensionedField<Type, GeoMesh>(io, mesh, ds),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
boundaryField_(mesh.boundary(), *this, patchFieldTypes)
boundaryField_(mesh.boundary(), *this, patchFieldTypes, actualPatchTypes)
{
if (debug)
{
......@@ -287,14 +288,15 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const IOobject& io,
const Mesh& mesh,
const dimensioned<Type>& dt,
const wordList& patchFieldTypes
const wordList& patchFieldTypes,
const wordList& actualPatchTypes
)
:
DimensionedField<Type, GeoMesh>(io, mesh, dt),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
boundaryField_(mesh.boundary(), *this, patchFieldTypes)
boundaryField_(mesh.boundary(), *this, patchFieldTypes, actualPatchTypes)
{
if (debug)
{
......@@ -653,14 +655,22 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
(
const IOobject& io,
const GeometricField<Type, PatchField, GeoMesh>& gf,
const wordList& patchFieldTypes
const wordList& patchFieldTypes,
const wordList& actualPatchTypes
)
:
DimensionedField<Type, GeoMesh>(io, gf),
timeIndex_(gf.timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
boundaryField_(this->mesh().boundary(), *this, patchFieldTypes)
boundaryField_
(
this->mesh().boundary(),
*this,
patchFieldTypes,
actualPatchTypes
)
{
if (debug)
{
......
......@@ -128,12 +128,14 @@ public:
//- Construct from a BoundaryMesh,
// reference to the internal field
// and a wordList of patch types
// and a wordList of patch types and optional the actual patch
// types (to override constraint patches)
GeometricBoundaryField
(
const BoundaryMesh&,
const DimensionedInternalField&,
const wordList&
const wordList& wantedPatchTypes,
const wordList& actualPatchTypes = wordList()
);
//- Construct from a BoundaryMesh,
......@@ -283,7 +285,8 @@ public:
const IOobject&,
const Mesh&,
const dimensionSet&,
const wordList& patchFieldTypes
const wordList& wantedPatchTypes,
const wordList& actualPatchTypes = wordList()
);
//- Constructor given IOobject, mesh, dimensioned<Type> and patch type.
......@@ -301,7 +304,8 @@ public:
const IOobject&,
const Mesh&,
const dimensioned<Type>&,
const wordList& patchFieldTypes
const wordList& wantedPatchTypes,
const wordList& actualPatchTypes = wordList()
);
//- Constructor from components
......@@ -387,7 +391,8 @@ public:
(
const IOobject&,
const GeometricField<Type, PatchField, GeoMesh>&,
const wordList& patchFieldTypes
const wordList& patchFieldTypes,
const wordList& actualPatchTypes = wordList()
);
......
......@@ -29,6 +29,7 @@ template<class Type>
Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
(
const word& patchFieldType,
const word& actualPatchType,
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF
)
......@@ -36,7 +37,8 @@ Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
if (debug)
{
Info<< "PointPatchField<Type>::"
"New(const word&, const pointPatch&, const Field<Type>&) : "
"New(const word&, const word&"
", const pointPatch&, const Field<Type>&) : "
"constructing pointPatchField<Type>"
<< endl;
}
......@@ -49,7 +51,7 @@ Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
FatalErrorIn
(
"PointPatchField<Type>::New"
"(const word&, const pointPatch&, const Field<Type>&)"
"(const word&, const word&, const pointPatch&, const Field<Type>&)"
) << "Unknown patchFieldType type "
<< patchFieldType
<< endl << endl
......@@ -60,31 +62,48 @@ Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
autoPtr<pointPatchField<Type> > pfPtr(cstrIter()(p, iF));
if (pfPtr().constraintType() == p.constraintType())
{
// Compatible (constraint-wise) with the patch type
return pfPtr;
}
else
if
(
actualPatchType == word::null
|| actualPatchType != p.type()
)
{
// Use default constraint type
typename pointPatchConstructorTable::iterator patchTypeCstrIter =
pointPatchConstructorTablePtr_->find(p.type());
if (patchTypeCstrIter == pointPatchConstructorTablePtr_->end())
if (pfPtr().constraintType() != p.constraintType())
{
FatalErrorIn
(
"PointPatchField<Type>::New"
"(const word&, const pointPatch&, const Field<Type>&)"
) << "inconsistent patch and patchField types for \n"
<< " patch type " << p.type()
<< " and patchField type " << patchFieldType
<< exit(FatalError);
}
// Use default constraint type
typename pointPatchConstructorTable::iterator patchTypeCstrIter =
pointPatchConstructorTablePtr_->find(p.type());
if (patchTypeCstrIter == pointPatchConstructorTablePtr_->end())
{
FatalErrorIn
(
"PointPatchField<Type>::New"
"(const word&, const word&"
", const pointPatch&, const Field<Type>&)"
) << "inconsistent patch and patchField types for \n"
<< " patch type " << p.type()
<< " and patchField type " << patchFieldType
<< exit(FatalError);
}
return patchTypeCstrIter()(p, iF);
return patchTypeCstrIter()(p, iF);
}
}
return pfPtr;
}
template<class Type>
Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
(
const word& patchFieldType,
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF
)
{
return New(patchFieldType, word::null, p, iF);
}
......
......@@ -35,7 +35,7 @@ Description
SourceFiles
pointPatchField.C
newpointPatchField.C
newPointPatchField.C
\*---------------------------------------------------------------------------*/
......@@ -199,6 +199,18 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a pointer to a new patchField created on freestore given
// patch and internal field
// (does not set the patch field values).
// Allows override of constraint type
static autoPtr<pointPatchField<Type> > New
(
const word&,
const word& actualPatchType,
const pointPatch&,
const DimensionedField<Type, pointMesh>&
);
//- Return a pointer to a new patchField created on freestore from
// a given pointPatchField mapped onto a new patch
static autoPtr<pointPatchField<Type> > New
......
......@@ -226,6 +226,18 @@ public:
const DimensionedField<Type, volMesh>&
);
//- Return a pointer to a new patchField created on freestore given
// patch and internal field
// (does not set the patch field values).
// Allows override of constraint type
static tmp<fvPatchField<Type> > New
(
const word&,
const word& actualPatchType,
const fvPatch&,
const DimensionedField<Type, volMesh>&
);
//- Return a pointer to a new patchField created on freestore from
// a given fvPatchField mapped onto a new patch
static tmp<fvPatchField<Type> > New
......
......@@ -29,14 +29,16 @@ template<class Type>
Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
(
const word& patchFieldType,
const word& actualPatchType,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF
)
{
if (debug)
{
Info<< "fvPatchField<Type>::New(const word&, const fvPatch&, "
"const DimensionedField<Type, volMesh>&) : patchFieldType="
Info<< "fvPatchField<Type>::New(const word&, const word&, "
"const fvPatch&, const DimensionedField<Type, volMesh>&) :"
" patchFieldType="
<< patchFieldType
<< endl;
}
......@@ -48,7 +50,7 @@ Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
{
FatalErrorIn
(
"fvPatchField<Type>::New(const word&, const fvPatch&, "
"fvPatchField<Type>::New(const word&, const word&, const fvPatch&, "
"const DimensionedField<Type, volMesh>&)"
) << "Unknown patchTypefield type " << patchFieldType
<< endl << endl
......@@ -57,12 +59,23 @@ Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
<< exit(FatalError);
}
typename patchConstructorTable::iterator patchTypeCstrIter =
patchConstructorTablePtr_->find(p.type());
if (patchTypeCstrIter != patchConstructorTablePtr_->end())
if
(
actualPatchType == word::null
|| actualPatchType != p.type()
)
{
return patchTypeCstrIter()(p, iF);
typename patchConstructorTable::iterator patchTypeCstrIter =
patchConstructorTablePtr_->find(p.type());
if (patchTypeCstrIter != patchConstructorTablePtr_->end())
{
return patchTypeCstrIter()(p, iF);
}
else
{
return cstrIter()(p, iF);
}
}
else
{
......@@ -71,6 +84,18 @@ Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
}
template<class Type>
Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
(
const word& patchFieldType,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF
)
{
return New(patchFieldType, word::null, p, iF);
}
template<class Type>
Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
(
......
......@@ -216,6 +216,18 @@ public:
const DimensionedField<Type, surfaceMesh>&
);
//- Return a pointer to a new patchField created on freestore given
// patch and internal field
// (does not set the patch field values)
// Allows override of constraint type
static tmp<fvsPatchField<Type> > New
(
const word&,
const word& actualPatchType,
const fvPatch&,
const DimensionedField<Type, surfaceMesh>&
);
//- Return a pointer to a new patchField created on freestore from
// a given fvsPatchField mapped onto a new patch
static tmp<fvsPatchField<Type> > New
......
......@@ -34,14 +34,15 @@ template<class Type>
tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
(
const word& patchFieldType,
const word& actualPatchType,
const fvPatch& p,
const DimensionedField<Type, surfaceMesh>& iF
)
{
if (debug)
{
Info<< "fvsPatchField<Type>::New(const word&, const fvPatch&, "
"const Field<Type>&) : "
Info<< "fvsPatchField<Type>::New(const word&, const word&"
", const fvPatch&, const Field<Type>&) : "
"constructing fvsPatchField<Type>"
<< endl;
}
......@@ -53,8 +54,8 @@ tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
{
FatalErrorIn
(
"fvsPatchField<Type>::New(const word&, const fvPatch&, "
"const Field<Type>&)"
"fvsPatchField<Type>::New(const word&, const word&, const fvPatch&"
", const Field<Type>&)"
) << "Unknown patchTypefield type " << patchFieldType
<< endl << endl
<< "Valid patchField types are :" << endl
......@@ -62,12 +63,23 @@ tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
<< exit(FatalError);
}
typename patchConstructorTable::iterator patchTypeCstrIter =
patchConstructorTablePtr_->find(p.type());
if (patchTypeCstrIter != patchConstructorTablePtr_->end())
if
(
actualPatchType == word::null
|| actualPatchType != p.type()
)
{
return patchTypeCstrIter()(p, iF);
typename patchConstructorTable::iterator patchTypeCstrIter =
patchConstructorTablePtr_->find(p.type());
if (patchTypeCstrIter != patchConstructorTablePtr_->end())
{
return patchTypeCstrIter()(p, iF);
}
else
{
return cstrIter()(p, iF);
}
}
else
{
......@@ -76,6 +88,18 @@ tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
}
template<class Type>
tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
(
const word& patchFieldType,
const fvPatch& p,
const DimensionedField<Type, surfaceMesh>& iF
)
{
return New(patchFieldType, word::null, p, iF);
}
template<class Type>
tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment