Commit fabbd8bb authored by graham's avatar graham
Browse files

Merge branch 'master' into dsmc

parents 35f0c0ab 8ce765e3
derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C
chtMultiRegionSimpleFoam.C
EXE = $(FOAM_APPBIN)/chtMultiRegionSimpleFoam
EXE_INC = \
/* -DFULLDEBUG -O0 -g */ \
-Ifluid \
-Isolid \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lbasicThermophysicalModels \
-lspecie \
-lcompressibleRASModels
......@@ -22,49 +22,78 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
vtkFoamData
Application
chtMultiRegionSimpleFoam
Description
SourceFiles
vtkFoamData.cxx
Steady-state version of chtMultiRegionFoam
\*---------------------------------------------------------------------------*/
#ifndef vtkFoamData_h
#define vtkFoamData_h
#include "fvCFD.H"
#include "basicPsiThermo.H"
#include "turbulenceModel.H"
#include "fixedGradientFvPatchFields.H"
#include "regionProperties.H"
#include "compressibleCourantNo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "vtkDataSetSource.h"
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
/*---------------------------------------------------------------------------*\
Class vtkFoamData Declaration
\*---------------------------------------------------------------------------*/
regionProperties rp(runTime);
class VTK_IO_EXPORT vtkFoamData
:
public vtkDataSetSource
{
#include "createFluidMeshes.H"
#include "createSolidMeshes.H"
public:
#include "createFluidFields.H"
#include "createSolidFields.H"
static vtkFoamData *New();
vtkTypeRevisionMacro(vtkFoamData,vtkDataSetSource);
#include "initContinuityErrs.H"
vtkFoamData();
~vtkFoamData();
void SetNthOutput(int num, vtkDataObject *output)
while (runTime.run())
{
vtkDataSetSource::SetNthOutput(num, output);
Info<< "Time = " << runTime.timeName() << nl << endl;
forAll(fluidRegions, i)
{
Info<< "\nSolving for fluid region "
<< fluidRegions[i].name() << endl;
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionSIMPLEControls.H"
#include "initConvergenceCheck.H"
#include "solveFluid.H"
#include "convergenceCheck.H"
}
forAll(solidRegions, i)
{
Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl;
#include "setRegionSolidFields.H"
#include "readSolidMultiRegionSIMPLEControls.H"
#include "initConvergenceCheck.H"
#include "solveSolid.H"
#include "convergenceCheck.H"
}
runTime++;
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
};
Info<< "End\n" << endl;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
return 0;
}
#endif
// ************************************************************************* //
......@@ -22,81 +22,147 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
Foam::vtkFoam
\*---------------------------------------------------------------------------*/
#ifndef vtkFoamConvertVolField_H
#define vtkFoamConvertVolField_H
#include "solidWallHeatFluxTemperatureFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkFoam::convertVolField
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const GeometricField<Type, fvPatchField, volMesh>& tf
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
{
vtkUnstructuredGrid *vtkMesh =
vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0));
:
fixedValueFvPatchScalarField(p, iF),
q_(p.size(), 0.0),
KName_("undefined-K")
{}
vtkFloatArray *cellTypes = vtkFloatArray::New();
cellTypes->SetNumberOfTuples(superCells_.size());
cellTypes->SetNumberOfComponents(Type::nComponents);
cellTypes->Allocate(Type::nComponents*tf.size());
cellTypes->SetName(tf.name().c_str());
float vec[Type::nComponents];
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
q_(ptf.q_, mapper),
KName_(ptf.KName_)
{}
forAll(superCells_, sci)
{
const Type& t = tf[superCells_[sci]];
for (direction d=0; d<Type::nComponents; d++)
{
vec[d] = t[d];
}
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict),
q_("q", dict, p.size()),
KName_(dict.lookup("K"))
{}
cellTypes->InsertTuple(sci, vec);
}
vtkMesh->GetCellData()->AddArray(cellTypes);
cellTypes->Delete();
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField& tppsf
)
:
fixedValueFvPatchScalarField(tppsf),
q_(tppsf.q_),
KName_(tppsf.KName_)
{}
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField& tppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(tppsf, iF),
q_(tppsf.q_),
KName_(tppsf.KName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
{
fixedValueFvPatchScalarField::autoMap(m);
q_.autoMap(m);
}
template<>
void Foam::vtkFoam::convertVolField
void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::rmap
(
const GeometricField<scalar, fvPatchField, volMesh>& sf
const fvPatchScalarField& ptf,
const labelList& addr
)
{
vtkUnstructuredGrid *vtkMesh =
vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0));
fixedValueFvPatchScalarField::rmap(ptf, addr);
vtkFloatArray *cellScalars = vtkFloatArray::New();
cellScalars->SetNumberOfTuples(superCells_.size());
cellScalars->SetNumberOfComponents(1);
cellScalars->Allocate(sf.size());
cellScalars->SetName(sf.name().c_str());
const solidWallHeatFluxTemperatureFvPatchScalarField& hfptf =
refCast<const solidWallHeatFluxTemperatureFvPatchScalarField>(ptf);
q_.rmap(hfptf.q_, addr);
}
forAll(superCells_, sci)
{
cellScalars->InsertComponent(sci, 0, sf[superCells_[sci]]);
}
vtkMesh->GetCellData()->AddArray(cellScalars);
if (!vtkMesh->GetCellData()->GetScalars())
void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
{
if (updated())
{
vtkMesh->GetCellData()->SetScalars(cellScalars);
return;
}
cellScalars->Delete();
const scalarField& Kw =
patch().lookupPatchField<volScalarField, scalar>(KName_);
const fvPatchScalarField& Tw = *this;
operator==(q_/(patch().deltaCoeffs()*Kw) + Tw.patchInternalField());
fixedValueFvPatchScalarField::updateCoeffs();
}
void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::write
(
Ostream& os
) const
{
fixedValueFvPatchScalarField::write(os);
q_.writeEntry("q", os);
os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
solidWallHeatFluxTemperatureFvPatchScalarField
);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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
Class
solidWallHeatFluxTemperatureFvPatchScalarField
Description
Heat flux boundary condition for temperature on solid region
Example usage:
myWallPatch
{
type solidWallHeatFluxTemperature;
K K; // Name of K field
q uniform 1000; // Heat flux / [W/m2]
value 300.0; // Initial temperature / [K]
}
SourceFiles
solidWallHeatFluxTemperatureFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef solidWallHeatFluxTemperatureFvPatchScalarField_H
#define solidWallHeatFluxTemperatureFvPatchScalarField_H
#include "fixedValueFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class solidWallHeatFluxTemperatureFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class solidWallHeatFluxTemperatureFvPatchScalarField
:
public fixedValueFvPatchScalarField
{
// Private data
//- Heat flux / [W/m2]
scalarField q_;
//- Name of thermal conductivity field
word KName_;
public:
//- Runtime type information
TypeName("solidWallHeatFluxTemperature");
// Constructors
//- Construct from patch and internal field
solidWallHeatFluxTemperatureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
solidWallHeatFluxTemperatureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// solidWallHeatFluxTemperatureFvPatchScalarField
// onto a new patch
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new solidWallHeatFluxTemperatureFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new solidWallHeatFluxTemperatureFvPatchScalarField(*this, iF)
);
}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchScalarField&,
const labelList&
);
// I-O
//- Write
void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
// Solve the Momentum equation
tmp<fvVectorMatrix> UEqn
(
fvm::div(phi, U)
- fvm::Sp(fvc::div(phi), U)
+ turb.divDevRhoReff(U)
);
UEqn().relax();
eqnResidual = solve
(
UEqn()
==
fvc::reconstruct
(
fvc::interpolate(rho)*(g & mesh.Sf())
- fvc::snGrad(p)*mesh.magSf()
)
).initialResidual();
maxResidual = max(eqnResidual, maxResidual);
{
dimensionedScalar totalMass = fvc::domainIntegrate(rho);
scalar sumLocalContErr =
(
fvc::domainIntegrate(mag(rho - thermo.rho()))/totalMass
).value();
scalar globalContErr =
(
fvc::domainIntegrate(rho - thermo.rho())/totalMass
).value();
cumulativeContErr[i] += globalContErr;
Info<< "time step continuity errors (" << mesh.name() << ")"
<< ": sum local = " << sumLocalContErr
<< ", global = " << globalContErr
<< ", cumulative = " << cumulativeContErr[i]
<< endl;
}