Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry
2012-09-20 15:13:57 +01:00
52 changed files with 538 additions and 310 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,7 +30,8 @@ License
template<class Type>
Foam::CompatibilityConstant<Type>::CompatibilityConstant
(
const word& entryName, const dictionary& dict
const word& entryName,
const dictionary& dict
)
:
DataEntry<Type>(entryName),
@ -69,6 +70,7 @@ Foam::CompatibilityConstant<Type>::CompatibilityConstant
dimensions_(cnst.dimensions_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>

View File

@ -27,13 +27,13 @@ Class
Description
Templated table container data entry. Items are stored in a list of
Tuple2's. First column is always stored as scalar entries. Data is read
in the form, e.g. for an entry \<entryName\> that is (scalar, vector):
in Tuple2 form, e.g. for an entry \<entryName\> that is (scalar, vector):
\verbatim
<entryName> table [0 1 0 0 0] //dimension set optional
<entryName> table
(
0.0 (1 2 3)
1.0 (4 5 6)
(0.0 (1 2 3))
(1.0 (4 5 6))
);
\endverbatim

View File

@ -0,0 +1,32 @@
Foam::word regionName;
if (args.optionReadIfPresent("region", regionName))
{
Foam::Info
<< "Create mesh " << regionName << " for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
}
else
{
regionName = Foam::fvMesh::defaultRegion;
Foam::Info
<< "Create mesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
}
autoPtr<dynamicFvMesh> meshPtr
(
dynamicFvMesh::New
(
IOobject
(
regionName,
runTime.timeName(),
runTime,
IOobject::MUST_READ
)
)
);
dynamicFvMesh& mesh = meshPtr();

View File

@ -40,8 +40,9 @@ flowRateInletVelocityFvPatchVectorField
:
fixedValueFvPatchField<vector>(p, iF),
flowRate_(),
phiName_("phi"),
rhoName_("rho")
volumetric_(false),
rhoName_("rho"),
rhoInlet_(0.0)
{}
@ -56,8 +57,9 @@ flowRateInletVelocityFvPatchVectorField
:
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
flowRate_(ptf.flowRate_().clone().ptr()),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_)
volumetric_(ptf.volumetric_),
rhoName_(ptf.rhoName_),
rhoInlet_(ptf.rhoInlet_)
{}
@ -69,11 +71,52 @@ flowRateInletVelocityFvPatchVectorField
const dictionary& dict
)
:
fixedValueFvPatchField<vector>(p, iF, dict),
flowRate_(DataEntry<scalar>::New("flowRate", dict)),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
{}
fixedValueFvPatchField<vector>(p, iF),
rhoInlet_(0.0)
{
if (dict.found("volumetricFlowRate"))
{
volumetric_ = true;
flowRate_ = DataEntry<scalar>::New("volumetricFlowRate", dict);
rhoName_ = "rho";
}
else if (dict.found("massFlowRate"))
{
volumetric_ = false;
flowRate_ = DataEntry<scalar>::New("massFlowRate", dict);
rhoName_ = word(dict.lookupOrDefault<word>("rho", "rho"));
}
else
{
FatalIOErrorIn
(
"flowRateInletVelocityFvPatchVectorField::"
"flowRateInletVelocityFvPatchVectorField"
"(const fvPatch&, const DimensionedField<vector, volMesh>&,"
" const dictionary&)",
dict
) << "Please supply either 'volumetricFlowRate' or"
<< " 'massFlowRate' and 'rho'" << exit(FatalIOError);
}
// Value field require if mass based
if (dict.found("value"))
{
fvPatchField<vector>::operator=
(
vectorField("value", dict, p.size())
);
}
else if (volumetric_)
{
evaluate(Pstream::blocking);
}
else
{
rhoInlet_ = readScalar(dict.lookup("rhoInlet"));
updateCoeffs(rhoInlet_);
}
}
Foam::flowRateInletVelocityFvPatchVectorField::
@ -84,8 +127,9 @@ flowRateInletVelocityFvPatchVectorField
:
fixedValueFvPatchField<vector>(ptf),
flowRate_(ptf.flowRate_().clone().ptr()),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_)
volumetric_(ptf.volumetric_),
rhoName_(ptf.rhoName_),
rhoInlet_(ptf.rhoInlet_)
{}
@ -98,13 +142,44 @@ flowRateInletVelocityFvPatchVectorField
:
fixedValueFvPatchField<vector>(ptf, iF),
flowRate_(ptf.flowRate_().clone().ptr()),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_)
volumetric_(ptf.volumetric_),
rhoName_(ptf.rhoName_),
rhoInlet_(ptf.rhoInlet_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs
(
const scalar uniformRho
)
{
if (updated())
{
return;
}
const scalar t = db().time().timeOutputValue();
// a simpler way of doing this would be nice
const scalar avgU = -flowRate_->value(t)/gSum(patch().magSf());
tmp<vectorField> n = patch().nf();
if (volumetric_ || rhoName_ == "none")
{
// volumetric flow-rate
operator==(n*avgU);
}
else
{
// mass flow-rate
operator==(n*avgU/uniformRho);
}
}
void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
{
if (updated())
@ -119,40 +194,18 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
tmp<vectorField> n = patch().nf();
const surfaceScalarField& phi =
db().lookupObject<surfaceScalarField>(phiName_);
if (phi.dimensions() == dimVelocity*dimArea)
if (volumetric_ || rhoName_ == "none")
{
// volumetric flow-rate
// volumetric flow-rate or density not given
operator==(n*avgU);
}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
{
if (rhoName_ == "none")
{
// volumetric flow-rate if density not given
operator==(n*avgU);
}
else
{
// mass flow-rate
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
operator==(n*avgU/rhop);
}
}
else
{
FatalErrorIn
(
"flowRateInletVelocityFvPatchVectorField::updateCoeffs()"
) << "dimensions of " << phiName_ << " are incorrect" << nl
<< " on patch " << this->patch().name()
<< " of field " << this->dimensionedInternalField().name()
<< " in file " << this->dimensionedInternalField().objectPath()
<< nl << exit(FatalError);
// mass flow-rate
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
operator==(n*avgU/rhop);
}
fixedValueFvPatchField<vector>::updateCoeffs();
@ -163,8 +216,11 @@ void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchField<vector>::write(os);
flowRate_->writeData(os);
writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
if (!volumetric_)
{
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
os.writeKeyword("rhoInlet") << rhoInlet_ << token::END_STATEMENT << nl;
}
writeEntry("value", os);
}

View File

@ -28,21 +28,25 @@ Description
Describes a volumetric/mass flow normal vector boundary condition by its
magnitude as an integral over its area.
The basis of the patch (volumetric or mass) is determined by the
dimensions of the flux, phi.
If the flux is mass-based
- the current density is used to correct the velocity
- volumetric flow rate can be applied by setting the 'rho' entry to 'none'
Either specify 'volumetricFlowRate' or 'massFlowRate' (requires additional
'rho' entry).
Example of the boundary condition specification:
\verbatim
inlet
{
type flowRateInletVelocity;
flowRate 0.2; // Volumetric/mass flow rate [m3/s or kg/s]
rho rho; // none | rho [m3/s or kg/s]
value uniform (0 0 0); // placeholder
type flowRateInletVelocity;
volumetricFlowRate 0.2; // Volumetric [m3/s]
}
\endverbatim
\verbatim
inlet
{
type flowRateInletVelocity;
volumetricFlowRate 0.2; // mass flow rate [kg/s]
rho rho; // rho [m3/s or kg/s]
value uniform (0 0 0); // placeholder
}
\endverbatim
@ -79,12 +83,15 @@ class flowRateInletVelocityFvPatchVectorField
//- Inlet integral flow rate
autoPtr<DataEntry<scalar> > flowRate_;
//- Name of the flux transporting the field
word phiName_;
//- Is volumetric?
bool volumetric_;
//- Name of the density field used to normalize the mass flux
word rhoName_;
//- Rho initialisation value (for start; if value not supplied)
scalar rhoInlet_;
public:
@ -157,6 +164,10 @@ public:
// Member functions
//- Update the coefficients associated with the patch field given
// uniform density field
void updateCoeffs(const scalar uniformRho);
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();

View File

@ -81,8 +81,14 @@ Foam::displacementSBRStressFvMotionSolver::displacementSBRStressFvMotionSolver
diffusivityPtr_
(
motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity"))
)
{}
),
solveOnPoints0_(coeffDict().lookupOrDefault("solveOnPoints0", false))
{
if (solveOnPoints0_)
{
Info<< type() << " : solving on points0" << endl;
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -123,11 +129,18 @@ void Foam::displacementSBRStressFvMotionSolver::solve()
diffusivityPtr_->correct();
pointDisplacement_.boundaryField().updateCoeffs();
pointField oldPoints;
if (solveOnPoints0_)
{
oldPoints = fvMesh_.points();
movePoints(points0());
}
surfaceScalarField Df(diffusivityPtr_->operator()());
volTensorField gradCd(fvc::grad(cellDisplacement_));
Foam::solve
tmp<fvMatrix<vector> > laplacianDf
(
fvm::laplacian
(
@ -135,7 +148,16 @@ void Foam::displacementSBRStressFvMotionSolver::solve()
cellDisplacement_,
"laplacian(diffusivity,cellDisplacement)"
)
);
// if (solveOnPoints0_)
// {
// movePoints(oldPoints);
// }
Foam::solve
(
laplacianDf
+ fvc::div
(
Df
@ -173,6 +195,12 @@ void Foam::displacementSBRStressFvMotionSolver::solve()
)
*/
);
if (solveOnPoints0_)
{
movePoints(points0());
}
}

View File

@ -53,7 +53,6 @@ class motionDiffusivity;
class displacementSBRStressFvMotionSolver
:
// public displacementFvMotionSolver
public displacementMotionSolver,
public fvMotionSolverCore
{
@ -65,6 +64,8 @@ class displacementSBRStressFvMotionSolver
//- Diffusivity used to control the motion
autoPtr<motionDiffusivity> diffusivityPtr_;
//- Solve on base mesh
Switch solveOnPoints0_;
// Private Member Functions

View File

@ -99,76 +99,6 @@ void Foam::autoLayerDriver::sumWeights
// Smooth field on moving patch
//void Foam::autoLayerDriver::smoothField
//(
// const motionSmoother& meshMover,
// const PackedBoolList& isMasterEdge,
// const labelList& meshEdges,
// const scalarField& fieldMin,
// const label nSmoothDisp,
// scalarField& field
//) const
//{
// const indirectPrimitivePatch& pp = meshMover.patch();
// const edgeList& edges = pp.edges();
// const labelList& meshPoints = pp.meshPoints();
//
// scalarField invSumWeight(pp.nPoints());
// sumWeights
// (
// isMasterEdge,
// meshEdges,
// meshPoints,
// edges,
// invSumWeight
// );
//
// // Get smoothly varying patch field.
// Info<< "shrinkMeshDistance : Smoothing field ..." << endl;
//
// for (label iter = 0; iter < nSmoothDisp; iter++)
// {
// scalarField average(pp.nPoints());
// averageNeighbours
// (
// meshMover.mesh(),
// isMasterEdge,
// meshEdges,
// meshPoints,
// pp.edges(),
// invSumWeight,
// field,
// average
// );
//
// // Transfer to field
// forAll(field, pointI)
// {
// //full smoothing neighbours + point value
// average[pointI] = 0.5*(field[pointI]+average[pointI]);
//
// // perform monotonic smoothing
// if
// (
// average[pointI] < field[pointI]
// && average[pointI] >= fieldMin[pointI]
// )
// {
// field[pointI] = average[pointI];
// }
// }
//
// // Do residual calculation every so often.
// if ((iter % 10) == 0)
// {
// Info<< " Iteration " << iter << " residual "
// << gSum(mag(field-average))
// /returnReduce(average.size(), sumOp<label>())
// << endl;
// }
// }
//}
//XXXXXXXXX
void Foam::autoLayerDriver::smoothField
(
const motionSmoother& meshMover,
@ -196,15 +126,9 @@ void Foam::autoLayerDriver::smoothField
// Get smoothly varying patch field.
Info<< "shrinkMeshDistance : Smoothing field ..." << endl;
const scalar lambda = 0.33;
const scalar mu = -0.34;
for (label iter = 0; iter < 90; iter++)
for (label iter = 0; iter < nSmoothDisp; iter++)
{
scalarField average(pp.nPoints());
// Calculate average of field
averageNeighbours
(
meshMover.mesh(),
@ -217,37 +141,23 @@ void Foam::autoLayerDriver::smoothField
average
);
forAll(field, i)
// Transfer to field
forAll(field, pointI)
{
if (field[i] >= fieldMin[i])
//full smoothing neighbours + point value
average[pointI] = 0.5*(field[pointI]+average[pointI]);
// perform monotonic smoothing
if
(
average[pointI] < field[pointI]
&& average[pointI] >= fieldMin[pointI]
)
{
field[i] = (1-lambda)*field[i]+lambda*average[i];
field[pointI] = average[pointI];
}
}
// Calculate average of field
averageNeighbours
(
meshMover.mesh(),
isMasterEdge,
meshEdges,
meshPoints,
pp.edges(),
invSumWeight,
field,
average
);
forAll(field, i)
{
if (field[i] >= fieldMin[i])
{
field[i] = (1-mu)*field[i]+mu*average[i];
}
}
// Do residual calculation every so often.
if ((iter % 10) == 0)
{
@ -259,6 +169,96 @@ void Foam::autoLayerDriver::smoothField
}
}
//XXXXXXXXX
//void Foam::autoLayerDriver::smoothField
//(
// const motionSmoother& meshMover,
// const PackedBoolList& isMasterEdge,
// const labelList& meshEdges,
// const scalarField& fieldMin,
// const label nSmoothDisp,
// scalarField& field
//) const
//{
// const indirectPrimitivePatch& pp = meshMover.patch();
// const edgeList& edges = pp.edges();
// const labelList& meshPoints = pp.meshPoints();
//
// scalarField invSumWeight(pp.nPoints());
// sumWeights
// (
// isMasterEdge,
// meshEdges,
// meshPoints,
// edges,
// invSumWeight
// );
//
// // Get smoothly varying patch field.
// Info<< "shrinkMeshDistance : (lambda-mu) Smoothing field ..." << endl;
//
//
// const scalar lambda = 0.33;
// const scalar mu = -0.34;
//
// for (label iter = 0; iter < 90; iter++)
// {
// scalarField average(pp.nPoints());
//
// // Calculate average of field
// averageNeighbours
// (
// meshMover.mesh(),
// isMasterEdge,
// meshEdges,
// meshPoints,
// pp.edges(),
// invSumWeight,
// field,
// average
// );
//
// forAll(field, i)
// {
// if (field[i] >= fieldMin[i])
// {
// field[i] = (1-lambda)*field[i]+lambda*average[i];
// }
// }
//
//
// // Calculate average of field
// averageNeighbours
// (
// meshMover.mesh(),
// isMasterEdge,
// meshEdges,
// meshPoints,
// pp.edges(),
// invSumWeight,
// field,
// average
// );
//
// forAll(field, i)
// {
// if (field[i] >= fieldMin[i])
// {
// field[i] = (1-mu)*field[i]+mu*average[i];
// }
// }
//
//
// // Do residual calculation every so often.
// if ((iter % 10) == 0)
// {
// Info<< " Iteration " << iter << " residual "
// << gSum(mag(field-average))
// /returnReduce(average.size(), sumOp<label>())
// << endl;
// }
// }
//}
//XXXXXXXXX
// Smooth normals on moving patch.
void Foam::autoLayerDriver::smoothPatchNormals

View File

@ -45,9 +45,6 @@ inline bool Foam::patchEdgeFaceRegion::update
if (w2.region_ == -2 || region_ == -2)
{
Pout<< "update : " << *this << " w2:" << w2 << " return FALSE" << endl;
// Blocked edge/face
return false;
}
@ -55,27 +52,18 @@ Pout<< "update : " << *this << " w2:" << w2 << " return FALSE" << endl;
if (!valid(td))
{
// current not yet set so use any value
label oldRegion = region_;
operator=(w2);
Pout<< "update : " << *this << " was:" << oldRegion
<< " w2:" << w2 << " return TRUE" << endl;
return true;
}
else
{
if (w2.region_ < region_)
{
label oldRegion = region_;
operator=(w2);
Pout<< "update : " << *this << " was:" << oldRegion
<< " w2:" << w2 << " return TRUE" << endl;
return true;
return true;
}
else
{
Pout<< "update : " << *this
<< " w2:" << w2 << " return FALSE" << endl;
return false;
}
}