Commit 5f8f1059 authored by Mark Olesen's avatar Mark Olesen
Browse files

Merge remote branch 'OpenCFD/master' into olesenm

parents 74b68856 300ac484
......@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
Info<< "\nStarting time loop\n" << endl;
for (runTime++; !runTime.end(); runTime++)
while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;
......
......@@ -124,6 +124,41 @@ void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::rmap
}
Foam::tmp<Foam::scalarField>
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::K() const
{
const fvMesh& mesh = patch().boundaryMesh().mesh();
if (mesh.objectRegistry::foundObject<volScalarField>(KName_))
{
return patch().lookupPatchField<volScalarField, scalar>(KName_);
}
else if (mesh.objectRegistry::foundObject<volSymmTensorField>(KName_))
{
const symmTensorField& KWall =
patch().lookupPatchField<volSymmTensorField, scalar>(KName_);
vectorField n = patch().nf();
return n & KWall & n;
}
else
{
FatalErrorIn
(
"solidWallHeatFluxTemperatureFvPatchScalarField::K()"
" const"
) << "Did not find field " << KName_
<< " on mesh " << mesh.name() << " patch " << patch().name()
<< endl
<< "Please set 'K' to a valid volScalarField"
<< " or a valid volSymmTensorField." << exit(FatalError);
return scalarField(0);
}
}
void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
{
if (updated())
......@@ -131,12 +166,7 @@ void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
return;
}
const scalarField& Kw = patch().lookupPatchField<volScalarField, scalar>
(
KName_
);
gradient() = q_/Kw;
gradient() = q_/K();
fixedGradientFvPatchScalarField::updateCoeffs();
}
......
......@@ -31,9 +31,10 @@ Description
myWallPatch
{
type solidWallHeatFluxTemperature;
K K; // Name of K field
q uniform 1000; // Heat flux / [W/m2]
value 300.0; // Initial temperature / [K]
K K; // Name of K field
q uniform 1000; // Heat flux / [W/m2]
value uniform 300.0; // Initial temperature / [K]
gradient uniform 0.0; // Initial gradient / [K/m]
}
......@@ -140,6 +141,11 @@ public:
// Member functions
// Helper
//- Get K field on this patch
tmp<scalarField> K() const;
// Evaluation functions
//- Update the coefficients associated with the patch field
......
......@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
Info<< "\nStarting time loop\n" << endl;
for (runTime++; !runTime.end(); runTime++)
while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;
......
......@@ -508,19 +508,11 @@ bool Foam::Time::run() const
}
}
return running;
}
bool Foam::Time::loop()
{
bool running = run();
if (running)
{
if (!subCycling_)
{
readModifiedObjects();
const_cast<Time&>(*this).readModifiedObjects();
if (timeIndex_ == startTimeIndex_)
{
......@@ -532,14 +524,22 @@ bool Foam::Time::loop()
}
}
// Check update the "running" status following the "++" operation
// to take into account possible side-effects from functionObjects
running = run();
// Update the "running" status following the
// possible side-effects from functionObjects
running = value() < (endTime_ - 0.5*deltaT_);
}
if (running)
{
operator++();
}
return running;
}
bool Foam::Time::loop()
{
bool running = run();
if (running)
{
operator++();
}
return running;
......
......@@ -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()
);
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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> >