diff --git a/applications/solvers/discreteMethods/dsmc/dsmcFoam/createFields.H b/applications/solvers/discreteMethods/dsmc/dsmcFoam/createFields.H deleted file mode 100644 index d024bd2017ae346c53e9adbc86a775a9ba496ba5..0000000000000000000000000000000000000000 --- a/applications/solvers/discreteMethods/dsmc/dsmcFoam/createFields.H +++ /dev/null @@ -1,162 +0,0 @@ - - Info<< nl << "Reading field boundaryT" << endl; - volScalarField boundaryT - ( - IOobject - ( - "boundaryT", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< nl << "Reading field boundaryU" << endl; - volVectorField boundaryU - ( - IOobject - ( - "boundaryU", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< nl << "Reading field rhoN (number density)" << endl; - volScalarField rhoN - ( - IOobject - ( - "rhoN", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< nl << "Reading field rhoM (mass density)" << endl; - volScalarField rhoM - ( - IOobject - ( - "rhoM", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< nl << "Reading field rhoNdsmc (dsmc particle density)" << endl; - volScalarField dsmcRhoN - ( - IOobject - ( - "dsmcRhoN", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< nl << "Reading field momentum (momentum density)" << endl; - volVectorField momentum - ( - IOobject - ( - "momentum", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< nl << "Reading field linearKE (linear kinetic energy density)" - << endl; - - volScalarField linearKE - ( - IOobject - ( - "linearKE", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< nl << "Reading field internalE (internal energy density)" << endl; - volScalarField internalE - ( - IOobject - ( - "internalE", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< nl << "Reading field iDof (internal degree of freedom density)" - << endl; - - volScalarField iDof - ( - IOobject - ( - "iDof", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< nl << "Reading field q (surface heat transfer)" << endl; - volScalarField q - ( - IOobject - ( - "q", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< nl << "Reading field fD (surface force density)" << endl; - volVectorField fD - ( - IOobject - ( - "fD", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< nl << "Constructing dsmcCloud " << endl; - - dsmcCloud dsmc("dsmc", boundaryT, boundaryU); diff --git a/applications/solvers/discreteMethods/dsmc/dsmcFoam/dsmcFoam.C b/applications/solvers/discreteMethods/dsmc/dsmcFoam/dsmcFoam.C index 84b499451f8abcdb3020741adc4b111be13a13a1..f5a57f15e81f860320485b24a4675c5d7a25d681 100644 --- a/applications/solvers/discreteMethods/dsmc/dsmcFoam/dsmcFoam.C +++ b/applications/solvers/discreteMethods/dsmc/dsmcFoam/dsmcFoam.C @@ -41,53 +41,21 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" - #include "createFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + Info<< nl << "Constructing dsmcCloud " << endl; + + dsmcCloud dsmc("dsmc", mesh); + Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; - Info<< "Time = " << runTime.timeName() << nl << endl; - // Carry out dsmcCloud timestep - dsmc.evolve(); - // Retrieve flow field data from dsmcCloud - - rhoN = dsmc.rhoN(); - rhoN.correctBoundaryConditions(); - - rhoM = dsmc.rhoM(); - rhoM.correctBoundaryConditions(); - - dsmcRhoN = dsmc.dsmcRhoN(); - dsmcRhoN.correctBoundaryConditions(); - - momentum = dsmc.momentum(); - momentum.correctBoundaryConditions(); - - linearKE = dsmc.linearKE(); - linearKE.correctBoundaryConditions(); - - internalE = dsmc.internalE(); - internalE.correctBoundaryConditions(); - - iDof = dsmc.iDof(); - iDof.correctBoundaryConditions(); - - // Retrieve surface field data from dsmcCloud - - q = dsmc.q(); - - fD = dsmc.fD(); - - // Print status of dsmcCloud - dsmc.info(); runTime.write(); diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/Make/files b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..e5f536ca09516d6be41ad0837f36e0f04c2d28e9 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/Make/files @@ -0,0 +1,5 @@ +derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C +chtMultiRegionSimpleFoam.C + +EXE = $(FOAM_APPBIN)/chtMultiRegionSimpleFoam + diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/Make/options b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..34be1995965d8beac1628c87981949e8d010ab3f --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/Make/options @@ -0,0 +1,16 @@ +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 diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.C b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.C new file mode 100644 index 0000000000000000000000000000000000000000..336f32d6714fc0ab44b8d78c268f22fb65b9eb75 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.C @@ -0,0 +1,99 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Application + chtMultiRegionSimpleFoam + +Description + Steady-state version of chtMultiRegionFoam + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "basicPsiThermo.H" +#include "turbulenceModel.H" +#include "fixedGradientFvPatchFields.H" +#include "regionProperties.H" +#include "compressibleCourantNo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + + regionProperties rp(runTime); + + #include "createFluidMeshes.H" + #include "createSolidMeshes.H" + + #include "createFluidFields.H" + #include "createSolidFields.H" + + #include "initContinuityErrs.H" + + + while (runTime.run()) + { + 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; +} + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..b1f8c3bed2f58850226ca1b1701f0afa359d8550 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C @@ -0,0 +1,168 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +\*---------------------------------------------------------------------------*/ + +#include "solidWallHeatFluxTemperatureFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::solidWallHeatFluxTemperatureFvPatchScalarField:: +solidWallHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + fixedValueFvPatchScalarField(p, iF), + q_(p.size(), 0.0), + KName_("undefined-K") +{} + + +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_) +{} + + +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")) +{} + + +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); +} + + +void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + fixedValueFvPatchScalarField::rmap(ptf, addr); + + const solidWallHeatFluxTemperatureFvPatchScalarField& hfptf = + refCast<const solidWallHeatFluxTemperatureFvPatchScalarField>(ptf); + + q_.rmap(hfptf.q_, addr); +} + + +void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + 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; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + solidWallHeatFluxTemperatureFvPatchScalarField + ); +} + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..85a1ef1cf13f46466f9451e6e1295cde8a8e0d6a --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.H @@ -0,0 +1,181 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/UEqn.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/UEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..1cbafe368aa4b6d2c4f9dddaa63fbe8db0ca1175 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/UEqn.H @@ -0,0 +1,22 @@ + // 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); diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/compressibleContinuityErrors.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/compressibleContinuityErrors.H new file mode 100644 index 0000000000000000000000000000000000000000..046ca5ec378429b496b6e4bbe47c844a1a6999de --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/compressibleContinuityErrors.H @@ -0,0 +1,21 @@ +{ + 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; +} diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddFields.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/compressibleCourantNo.C similarity index 61% rename from applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddFields.H rename to applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/compressibleCourantNo.C index 3136edd5fee3a16ee467440779a2a05540257fce..a3d68f55ca4d2f5ffdca0b4e995d69aeadddda94 100644 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/compressibleCourantNo.C @@ -22,39 +22,42 @@ 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 vtkFoamAddFields_H -#define vtkFoamAddFields_H - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "compressibleCourantNo.H" +#include "fvc.H" -template<class GeoField> -void Foam::vtkFoam::addFields +Foam::scalar Foam::compressibleCourantNo ( - vtkDataArraySelection *fieldSelection, - const IOobjectList& objects + const fvMesh& mesh, + const Time& runTime, + const volScalarField& rho, + const surfaceScalarField& phi ) { - IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName)); - - for - ( - IOobjectList::iterator iter = fieldObjects.begin(); - iter != fieldObjects.end(); - ++iter - ) + scalar CoNum = 0.0; + scalar meanCoNum = 0.0; + + //- Can have fluid domains with 0 cells so do not test. + //if (mesh.nInternalFaces()) { - fieldSelection->AddArray(iter()->name().c_str()); + surfaceScalarField SfUfbyDelta = + mesh.surfaceInterpolation::deltaCoeffs() + * mag(phi) + / fvc::interpolate(rho); + + CoNum = max(SfUfbyDelta/mesh.magSf()) + .value()*runTime.deltaT().value(); + + meanCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf())) + .value()*runTime.deltaT().value(); } -} + Info<< "Region: " << mesh.name() << " Courant Number mean: " << meanCoNum + << " max: " << CoNum << endl; -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + return CoNum; +} -#endif // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamData.cxx b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/compressibleCourantNo.H similarity index 77% rename from applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamData.cxx rename to applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/compressibleCourantNo.H index 4f89b6e25d0fddc5a8e1aff6f77b8023522ce9d6..329b8cce65ec4d8e74cd310abc463c490051aa7e 100644 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamData.cxx +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/compressibleCourantNo.H @@ -23,27 +23,27 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description + Calculates and outputs the mean and maximum Courant Numbers for the fluid + regions \*---------------------------------------------------------------------------*/ -#include <ctype.h> +#ifndef compressibleCourantNo_H +#define compressibleCourantNo_H -#include "vtkFoamData.h" -#include "vtkObjectFactory.h" +#include "fvMesh.H" -vtkCxxRevisionMacro(vtkFoamData, "$Revision: 1.20 $"); -vtkStandardNewMacro(vtkFoamData); - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -vtkFoamData::vtkFoamData() -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -vtkFoamData::~vtkFoamData() -{} +namespace Foam +{ + scalar compressibleCourantNo + ( + const fvMesh& mesh, + const Time& runTime, + const volScalarField& rho, + const surfaceScalarField& phi + ); +} +#endif // ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/compressibleMultiRegionCourantNo.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/compressibleMultiRegionCourantNo.H new file mode 100644 index 0000000000000000000000000000000000000000..3ca2f685819312306802794b946f5048e91e6e51 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/compressibleMultiRegionCourantNo.H @@ -0,0 +1,15 @@ + scalar CoNum = -GREAT; + forAll(fluidRegions, regionI) + { + CoNum = max + ( + compressibleCourantNo + ( + fluidRegions[regionI], + runTime, + rhoFluid[regionI], + phiFluid[regionI] + ), + CoNum + ); + } diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/convergenceCheck.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/convergenceCheck.H new file mode 100644 index 0000000000000000000000000000000000000000..53c00386ff6e1ad13f9d867f268dd63d29fa9ede --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/convergenceCheck.H @@ -0,0 +1,12 @@ +// check convergence +Info<< "maxResidual: " << maxResidual + << " convergence criterion: " << convergenceCriterion + << endl; + +if (maxResidual < convergenceCriterion) +{ + Info<< "reached convergence criterion: " << convergenceCriterion << endl; + runTime.writeAndEnd(); + Info<< "latestTime = " << runTime.timeName() << endl; +} + diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/createFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/createFluidFields.H new file mode 100644 index 0000000000000000000000000000000000000000..2d2ccf9a5eb4d443059ba97985a77b229407073e --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/createFluidFields.H @@ -0,0 +1,144 @@ + // Initialise fluid field pointer lists + PtrList<basicPsiThermo> thermoFluid(fluidRegions.size()); + PtrList<volScalarField> rhoFluid(fluidRegions.size()); + PtrList<volScalarField> KFluid(fluidRegions.size()); + PtrList<volVectorField> UFluid(fluidRegions.size()); + PtrList<surfaceScalarField> phiFluid(fluidRegions.size()); + PtrList<uniformDimensionedVectorField> gFluid(fluidRegions.size()); + PtrList<compressible::turbulenceModel> turbulence(fluidRegions.size()); + PtrList<volScalarField> DpDtf(fluidRegions.size()); + + List<scalar> initialMassFluid(fluidRegions.size()); + List<label> pRefCellFluid(fluidRegions.size(),0); + List<scalar> pRefValueFluid(fluidRegions.size(),0.0); + + + // Populate fluid field pointer lists + forAll(fluidRegions, i) + { + Info<< "*** Reading fluid mesh thermophysical properties for region " + << fluidRegions[i].name() << nl << endl; + + Info<< " Adding to thermoFluid\n" << endl; + + thermoFluid.set + ( + i, + basicPsiThermo::New(fluidRegions[i]).ptr() + ); + + Info<< " Adding to rhoFluid\n" << endl; + rhoFluid.set + ( + i, + new volScalarField + ( + IOobject + ( + "rho", + runTime.timeName(), + fluidRegions[i], + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + thermoFluid[i].rho() + ) + ); + + Info<< " Adding to KFluid\n" << endl; + KFluid.set + ( + i, + new volScalarField + ( + IOobject + ( + "K", + runTime.timeName(), + fluidRegions[i], + IOobject::NO_READ, + IOobject::NO_WRITE + ), + thermoFluid[i].Cp()*thermoFluid[i].alpha() + ) + ); + + Info<< " Adding to UFluid\n" << endl; + UFluid.set + ( + i, + new volVectorField + ( + IOobject + ( + "U", + runTime.timeName(), + fluidRegions[i], + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + fluidRegions[i] + ) + ); + + Info<< " Adding to phiFluid\n" << endl; + phiFluid.set + ( + i, + new surfaceScalarField + ( + IOobject + ( + "phi", + runTime.timeName(), + fluidRegions[i], + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + linearInterpolate(rhoFluid[i]*UFluid[i]) + & fluidRegions[i].Sf() + ) + ); + + Info<< " Adding to gFluid\n" << endl; + gFluid.set + ( + i, + new uniformDimensionedVectorField + ( + IOobject + ( + "g", + runTime.constant(), + fluidRegions[i], + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ) + ); + + Info<< " Adding to turbulence\n" << endl; + turbulence.set + ( + i, + compressible::turbulenceModel::New + ( + rhoFluid[i], + UFluid[i], + phiFluid[i], + thermoFluid[i] + ).ptr() + ); + + initialMassFluid[i] = fvc::domainIntegrate(rhoFluid[i]).value(); + + setRefCell + ( + thermoFluid[i].p(), + fluidRegions[i].solutionDict().subDict("SIMPLE"), + pRefCellFluid[i], + pRefValueFluid[i] + ); + } + + diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/createFluidMeshes.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/createFluidMeshes.H new file mode 100644 index 0000000000000000000000000000000000000000..30a2e1089f8875cf507ac0d4d76492830cf9647c --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/createFluidMeshes.H @@ -0,0 +1,22 @@ + PtrList<fvMesh> fluidRegions(rp.fluidRegionNames().size()); + + forAll(rp.fluidRegionNames(), i) + { + Info<< "Create fluid mesh for region " << rp.fluidRegionNames()[i] + << " for time = " << runTime.timeName() << nl << endl; + + fluidRegions.set + ( + i, + new fvMesh + ( + IOobject + ( + rp.fluidRegionNames()[i], + runTime.timeName(), + runTime, + IOobject::MUST_READ + ) + ) + ); + } diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/hEqn.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/hEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..ccd661599027a1906e90affab97d322cdd40c286 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/hEqn.H @@ -0,0 +1,21 @@ +{ + fvScalarMatrix hEqn + ( + fvm::div(phi, h) + - fvm::Sp(fvc::div(phi), h) + - fvm::laplacian(turb.alphaEff(), h) + == + fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p)) + - p*fvc::div(phi/fvc::interpolate(rho)) + ); + + hEqn.relax(); + + eqnResidual = hEqn.solve().initialResidual(); + maxResidual = max(eqnResidual, maxResidual); + + thermo.correct(); + + Info<< "Min/max T:" << min(thermo.T()).value() << ' ' + << max(thermo.T()).value() << endl; +} diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/initConvergenceCheck.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/initConvergenceCheck.H new file mode 100644 index 0000000000000000000000000000000000000000..c920b6708d044d177227d79973ed61bc7f2658fc --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/initConvergenceCheck.H @@ -0,0 +1,7 @@ + // initialize values for convergence checks + + scalar eqnResidual = 1, maxResidual = 0; + scalar convergenceCriterion = 0; + + simple.readIfPresent("convergence", convergenceCriterion); + diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/pEqn.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/pEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..6b6fe6ef5dd76b922aa1e003f97e1a86273af2d4 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/pEqn.H @@ -0,0 +1,74 @@ +{ + // From buoyantSimpleFoam + + rho = thermo.rho(); + + volScalarField rUA = 1.0/UEqn().A(); + surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA)); + + U = rUA*UEqn().H(); + UEqn.clear(); + + phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf()); + bool closedVolume = adjustPhi(phi, U, p); + + surfaceScalarField buoyancyPhi = + rhorUAf*fvc::interpolate(rho)*(g & mesh.Sf()); + phi += buoyancyPhi; + + // Solve pressure + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pEqn + ( + fvm::laplacian(rhorUAf, p) == fvc::div(phi) + ); + + pEqn.setReference(pRefCell, pRefValue); + + // retain the residual from the first iteration + if (nonOrth == 0) + { + eqnResidual = pEqn.solve().initialResidual(); + maxResidual = max(eqnResidual, maxResidual); + } + else + { + pEqn.solve(); + } + + if (nonOrth == nNonOrthCorr) + { + // For closed-volume cases adjust the pressure and density levels + // to obey overall mass continuity + if (closedVolume) + { + p += (initialMass - fvc::domainIntegrate(psi*p)) + /fvc::domainIntegrate(psi); + } + + // Calculate the conservative fluxes + phi -= pEqn.flux(); + + // Explicitly relax pressure for momentum corrector + p.relax(); + + // Correct the momentum source with the pressure gradient flux + // calculated from the relaxed pressure + U += rUA*fvc::reconstruct((buoyancyPhi - pEqn.flux())/rhorUAf); + U.correctBoundaryConditions(); + } + } + + + #include "continuityErrs.H" + + rho = thermo.rho(); + rho.relax(); + + Info<< "Min/max rho:" << min(rho).value() << ' ' + << max(rho).value() << endl; + + // Update thermal conductivity + K = thermo.Cp()*turb.alphaEff(); +} diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H new file mode 100644 index 0000000000000000000000000000000000000000..3054562d5d68076c7d36389b5479b4a41c113e9f --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H @@ -0,0 +1,25 @@ + dictionary simple = fluidRegions[i].solutionDict().subDict("SIMPLE"); + + int nNonOrthCorr = 0; + if (simple.found("nNonOrthogonalCorrectors")) + { + nNonOrthCorr = readInt(simple.lookup("nNonOrthogonalCorrectors")); + } + + bool momentumPredictor = true; + if (simple.found("momentumPredictor")) + { + momentumPredictor = Switch(simple.lookup("momentumPredictor")); + } + + bool fluxGradp = false; + if (simple.found("fluxGradp")) + { + fluxGradp = Switch(simple.lookup("fluxGradp")); + } + + bool transonic = false; + if (simple.found("transonic")) + { + transonic = Switch(simple.lookup("transonic")); + } diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H new file mode 100644 index 0000000000000000000000000000000000000000..8491056ea325e7f20258da63a16e60c9ab2130e2 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H @@ -0,0 +1,24 @@ + const fvMesh& mesh = fluidRegions[i]; + + basicPsiThermo& thermo = thermoFluid[i]; + volScalarField& rho = rhoFluid[i]; + volScalarField& K = KFluid[i]; + volVectorField& U = UFluid[i]; + surfaceScalarField& phi = phiFluid[i]; + const dimensionedVector& g = gFluid[i]; + + compressible::turbulenceModel& turb = turbulence[i]; + + volScalarField& p = thermo.p(); + const volScalarField& psi = thermo.psi(); + volScalarField& h = thermo.h(); + + const dimensionedScalar initialMass + ( + "initialMass", + dimMass, + initialMassFluid[i] + ); + + const label pRefCell = pRefCellFluid[i]; + const scalar pRefValue = pRefValueFluid[i]; diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/solveFluid.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/solveFluid.H new file mode 100644 index 0000000000000000000000000000000000000000..5198941366285201708ca870b3763390a07c5db8 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/solveFluid.H @@ -0,0 +1,11 @@ +// Pressure-velocity SIMPLE corrector + + p.storePrevIter(); + rho.storePrevIter(); + { + #include "UEqn.H" + #include "hEqn.H" + #include "pEqn.H" + } + + turb.correct(); diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/createSolidFields.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/createSolidFields.H new file mode 100644 index 0000000000000000000000000000000000000000..3361a89add381ed2f43d39b602b2b945040453cf --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/createSolidFields.H @@ -0,0 +1,91 @@ + // Initialise solid field pointer lists + PtrList<volScalarField> rhos(solidRegions.size()); + PtrList<volScalarField> cps(solidRegions.size()); + PtrList<volScalarField> rhosCps(solidRegions.size()); + PtrList<volScalarField> Ks(solidRegions.size()); + PtrList<volScalarField> Ts(solidRegions.size()); + + // Populate solid field pointer lists + forAll(solidRegions, i) + { + Info<< "*** Reading solid mesh thermophysical properties for region " + << solidRegions[i].name() << nl << endl; + + Info<< " Adding to rhos\n" << endl; + rhos.set + ( + i, + new volScalarField + ( + IOobject + ( + "rho", + runTime.timeName(), + solidRegions[i], + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + solidRegions[i] + ) + ); + + Info<< " Adding to cps\n" << endl; + cps.set + ( + i, + new volScalarField + ( + IOobject + ( + "cp", + runTime.timeName(), + solidRegions[i], + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + solidRegions[i] + ) + ); + + rhosCps.set + ( + i, + new volScalarField("rhosCps", rhos[i]*cps[i]) + ); + + Info<< " Adding to Ks\n" << endl; + Ks.set + ( + i, + new volScalarField + ( + IOobject + ( + "K", + runTime.timeName(), + solidRegions[i], + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + solidRegions[i] + ) + ); + + Info<< " Adding to Ts\n" << endl; + Ts.set + ( + i, + new volScalarField + ( + IOobject + ( + "T", + runTime.timeName(), + solidRegions[i], + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + solidRegions[i] + ) + ); + } diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/createSolidMeshes.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/createSolidMeshes.H new file mode 100644 index 0000000000000000000000000000000000000000..eb50be23808e6ffdf31c17fca398bb5366f24c7e --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/createSolidMeshes.H @@ -0,0 +1,27 @@ + PtrList<fvMesh> solidRegions(rp.solidRegionNames().size()); + + forAll(rp.solidRegionNames(), i) + { + Info<< "Create solid mesh for region " << rp.solidRegionNames()[i] + << " for time = " << runTime.timeName() << nl << endl; + + solidRegions.set + ( + i, + new fvMesh + ( + IOobject + ( + rp.solidRegionNames()[i], + runTime.timeName(), + runTime, + IOobject::MUST_READ + ) + ) + ); + + // Force calculation of geometric properties to prevent it being done + // later in e.g. some boundary evaluation + //(void)solidRegions[i].weights(); + //(void)solidRegions[i].deltaCoeffs(); + } diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/readSolidMultiRegionSIMPLEControls.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/readSolidMultiRegionSIMPLEControls.H new file mode 100644 index 0000000000000000000000000000000000000000..22e9b177f1874742fe3d8b8d24ceb2caab3f1d68 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/readSolidMultiRegionSIMPLEControls.H @@ -0,0 +1,7 @@ + dictionary simple = solidRegions[i].solutionDict().subDict("SIMPLE"); + + int nNonOrthCorr = 0; + if (simple.found("nNonOrthogonalCorrectors")) + { + nNonOrthCorr = readInt(simple.lookup("nNonOrthogonalCorrectors")); + } diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/setRegionSolidFields.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/setRegionSolidFields.H new file mode 100644 index 0000000000000000000000000000000000000000..f9e80e3d72385e7f6ae80107cc3b65921904c35f --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/setRegionSolidFields.H @@ -0,0 +1,6 @@ + fvMesh& mesh = solidRegions[i]; + + volScalarField& rho = rhos[i]; + volScalarField& cp = cps[i]; + volScalarField& K = Ks[i]; + volScalarField& T = Ts[i]; diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/solveSolid.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/solveSolid.H new file mode 100644 index 0000000000000000000000000000000000000000..7cf2cc14091336970c307730b01ffcaf2349168e --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/solid/solveSolid.H @@ -0,0 +1,16 @@ +{ + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix tEqn + ( + -fvm::laplacian(K, T) + ); + tEqn.relax(); + eqnResidual = tEqn.solve().initialResidual(); + maxResidual = max(eqnResidual, maxResidual); + + } + + Info<< "Min/max T:" << min(T).value() << ' ' + << max(T).value() << endl; +} diff --git a/applications/solvers/incompressible/pimpleDyMFoam/correctPhi.H b/applications/solvers/incompressible/pimpleDyMFoam/correctPhi.H index 023ecc6d5a7e8afa95465df9db34b9a816d860e8..394b1cbd3eb71bc019b0cb3b5b76a4256bc838b7 100644 --- a/applications/solvers/incompressible/pimpleDyMFoam/correctPhi.H +++ b/applications/solvers/incompressible/pimpleDyMFoam/correctPhi.H @@ -1,4 +1,26 @@ { + if (mesh.changing()) + { + forAll(U.boundaryField(), patchi) + { + if (U.boundaryField()[patchi].fixesValue()) + { + U.boundaryField()[patchi].initEvaluate(); + } + } + + forAll(U.boundaryField(), patchi) + { + if (U.boundaryField()[patchi].fixesValue()) + { + U.boundaryField()[patchi].evaluate(); + + phi.boundaryField()[patchi] = + U.boundaryField()[patchi] & mesh.Sf().boundaryField()[patchi]; + } + } + } + wordList pcorrTypes ( p.boundaryField().size(), diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/correctPhi.H b/applications/solvers/multiphase/compressibleInterDyMFoam/correctPhi.H index d82a03edb59a2d419420700638404e6f90b197c8..f681ba65940dd3eb12b67ad38628f19537ca2c96 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/correctPhi.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/correctPhi.H @@ -1,4 +1,26 @@ { + if (mesh.changing()) + { + forAll(U.boundaryField(), patchi) + { + if (U.boundaryField()[patchi].fixesValue()) + { + U.boundaryField()[patchi].initEvaluate(); + } + } + + forAll(U.boundaryField(), patchi) + { + if (U.boundaryField()[patchi].fixesValue()) + { + U.boundaryField()[patchi].evaluate(); + + phi.boundaryField()[patchi] = + U.boundaryField()[patchi] & mesh.Sf().boundaryField()[patchi]; + } + } + } + #include "continuityErrs.H" volScalarField pcorr diff --git a/applications/solvers/multiphase/interDyMFoam/correctPhi.H b/applications/solvers/multiphase/interDyMFoam/correctPhi.H index 0854a68b8e3ae1b941dbdad26c244017efc04d8e..43b13c2b898c35350304b203936cc0124677e21b 100644 --- a/applications/solvers/multiphase/interDyMFoam/correctPhi.H +++ b/applications/solvers/multiphase/interDyMFoam/correctPhi.H @@ -1,4 +1,26 @@ { + if (mesh.changing()) + { + forAll(U.boundaryField(), patchi) + { + if (U.boundaryField()[patchi].fixesValue()) + { + U.boundaryField()[patchi].initEvaluate(); + } + } + + forAll(U.boundaryField(), patchi) + { + if (U.boundaryField()[patchi].fixesValue()) + { + U.boundaryField()[patchi].evaluate(); + + phi.boundaryField()[patchi] = + U.boundaryField()[patchi] & mesh.Sf().boundaryField()[patchi]; + } + } + } + #include "continuityErrs.H" volScalarField pcorr diff --git a/applications/test/DimensionedField/DimensionedFieldTest.C b/applications/test/DimensionedField/DimensionedFieldTest.C deleted file mode 100644 index bc1f875dbd164756f8355fe879b1042178e2bc35..0000000000000000000000000000000000000000 --- a/applications/test/DimensionedField/DimensionedFieldTest.C +++ /dev/null @@ -1,133 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 - -\*---------------------------------------------------------------------------*/ - -#include "argList.H" -#include "Time.H" -#include "DimensionedFields.H" -#include "DimensionedSphericalTensorField.H" -#include "vector.H" -#include "tensor.H" -#include "GeoMesh.H" - -using namespace Foam; - -namespace Foam -{ - -class vMesh -{ - -public: - - vMesh() - {} - - label size() const - { - return 10; - } -}; - -}; - -template<> -const word Foam::DimensionedField<scalar, GeoMesh<vMesh> >::typeName -( - "dimenionedScalarField" -); - -template<> -const word Foam::DimensionedField<vector, GeoMesh<vMesh> >::typeName -( - "dimenionedVectorField" -); - -template<> -const word Foam::DimensionedField<tensor, GeoMesh<vMesh> >::typeName -( - "dimenionedTensorField" -); - -template<> -const word Foam::DimensionedField<sphericalTensor, GeoMesh<vMesh> >::typeName -( - "dimenionedSphericalTensorField" -); - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Main program: - -int main(int argc, char *argv[]) -{ - -# include "setRootCase.H" -# include "createTime.H" - - vMesh vm; - - DimensionedField<scalar, GeoMesh<vMesh> > dsf - ( - IOobject - ( - "dsf", - runTime.timeName(), - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE - ), - vm - ); - - Info<< dsf << endl; - dsf += dsf; - dsf -= dimensionedScalar("5", dsf.dimensions(), 5.0); - Info<< dsf << endl; - - Info<< sqr(dsf + dsf) - sqr(dsf + dsf) << endl; - - DimensionedField<vector, GeoMesh<vMesh> > dvf - ( - IOobject - ( - "dvf", - runTime.timeName(), - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE - ), - vm - ); - - Info<< (dvf ^ (dvf ^ dvf)) << endl; - - Info << "End\n" << endl; - - return 0; -} - - -// ************************************************************************* // diff --git a/applications/test/DimensionedField/Make/files b/applications/test/DimensionedField/Make/files deleted file mode 100644 index 02c479015e6823f48993ab50ddc77e0b433d2a7c..0000000000000000000000000000000000000000 --- a/applications/test/DimensionedField/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -DimensionedFieldTest.C - -EXE = $(FOAM_USER_APPBIN)/DimensionedFieldTest diff --git a/applications/test/DimensionedField/Make/options b/applications/test/DimensionedField/Make/options deleted file mode 100644 index 6a9e9810b3d5ce6684bdaf03143933480ff45e42..0000000000000000000000000000000000000000 --- a/applications/test/DimensionedField/Make/options +++ /dev/null @@ -1,2 +0,0 @@ -/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */ -/* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/test/HashTable3/hashTableTest3.C b/applications/test/HashTable3/hashTableTest3.C index 910e4f229052bc8c9305ea7b30d30a3907cbbfd0..6229e6a30438189b855022634f2fb9b38041e76c 100644 --- a/applications/test/HashTable3/hashTableTest3.C +++ b/applications/test/HashTable3/hashTableTest3.C @@ -33,7 +33,6 @@ Description #include "HashPtrTable.H" #include "Map.H" #include "StaticHashTable.H" -#include "HashTbl.H" #include "cpuTime.H" using namespace Foam; @@ -53,7 +52,7 @@ int main(int argc, char *argv[]) // Map<label> map(2 * nSize); // HashTable<label, label, Hash<label> > map(2 * nSize); // StaticHashTable<label, label, Hash<label> > map(2 * nSize); - HashTbl<label, label, Hash<label> > map(2 * nSize); + HashTable<label, label, Hash<label> > map(2 * nSize); Info<< "Constructed map of size: " << nSize << " (size " << map.size() << " capacity " << map.capacity() << ") " diff --git a/applications/test/Matrix/MatrixTest.C b/applications/test/Matrix/MatrixTest.C index 24bcc682575ca073ac911baa6a2af458fd3a7329..5576291fd50ac8c3e1661acc19a716645d7cd989 100644 --- a/applications/test/Matrix/MatrixTest.C +++ b/applications/test/Matrix/MatrixTest.C @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ -#include "Matrix.H" +#include "SquareMatrix.H" #include "vector.H" using namespace Foam; @@ -34,7 +34,7 @@ using namespace Foam; int main(int argc, char *argv[]) { - Matrix<scalar> hmm(3, 3); + SquareMatrix<scalar> hmm(3); hmm[0][0] = -3.0; hmm[0][1] = 10.0; @@ -46,27 +46,27 @@ int main(int argc, char *argv[]) hmm[2][1] = 6.0; hmm[2][2] = 1.0; - Info<< hmm << endl << hmm - 2.0*(-hmm) << endl; + //Info<< hmm << endl << hmm - 2.0*(-hmm) << endl; Info<< max(hmm) << endl; Info<< min(hmm) << endl; - Matrix<scalar> hmm2(3, 3, 1.0); + SquareMatrix<scalar> hmm2(3, 1.0); hmm = hmm2; Info<< hmm << endl; - Matrix<scalar> hmm3(Sin); + SquareMatrix<scalar> hmm3(Sin); Info<< hmm3 << endl; - Matrix<scalar> hmm4; + SquareMatrix<scalar> hmm4; hmm4 = hmm2; Info<< hmm4 << endl; - Matrix<scalar> hmm5; + SquareMatrix<scalar> hmm5; hmm4 = hmm5; Info<< hmm5 << endl; diff --git a/applications/test/ODETest/ODETest.C b/applications/test/ODETest/ODETest.C index dfc7a663bbddcf2893c2cedd0dd91c1c17d0c35a..2d8cecfa9acf58d7c7c263152477d26d18672e65 100644 --- a/applications/test/ODETest/ODETest.C +++ b/applications/test/ODETest/ODETest.C @@ -69,7 +69,7 @@ public: const scalar x, const scalarField& y, scalarField& dfdx, - Matrix<scalar>& dfdy + scalarSquareMatrix& dfdy ) const { dfdx[0] = 0.0; diff --git a/applications/test/PtrList/PtrListTest.C b/applications/test/PtrList/PtrListTest.C index 5413a662b889fed52c2c8b6bc218a3315eee3446..7fbff08d11ced6752cf4777632478b58e495b743 100644 --- a/applications/test/PtrList/PtrListTest.C +++ b/applications/test/PtrList/PtrListTest.C @@ -57,6 +57,8 @@ public: Info <<"delete Scalar: " << data_ << endl; } + autoPtr<Scalar> clone() const; + friend Ostream& operator<<(Ostream& os, const Scalar& val) { os << val.data_; diff --git a/applications/test/UIndirectListTest/UIndirectListTest.C b/applications/test/UIndirectListTest/UIndirectListTest.C index 6902f47eeab4e2ddf1c744606f5cc1a1387a78a7..67943b7d94223cf31c393fd2071c88e78b968e0d 100644 --- a/applications/test/UIndirectListTest/UIndirectListTest.C +++ b/applications/test/UIndirectListTest/UIndirectListTest.C @@ -84,11 +84,11 @@ int main(int argc, char *argv[]) // test List operations - List<double> flatList = UIndirectList<double>(completeList, addresses); - Info<< "List assigned from UIndirectList: " << flatList << endl; + List<double> flatList(UIndirectList<double>(completeList, addresses)); + Info<< "List constructed from UIndirectList: " << flatList << endl; - List<double> flatList2(UIndirectList<double>(completeList, addresses)); - Info<< "List constructed from UIndirectList: " << flatList2 << endl; + flatList = UIndirectList<double>(completeList, addresses); + Info<< "List assigned from UIndirectList: " << flatList << endl; flatList.append(UIndirectList<double>(completeList, addresses)); Info<< "List::append(UIndirectList): " << flatList << endl; diff --git a/applications/test/parallel/parallelTest.C b/applications/test/parallel/parallelTest.C index 6120de31a51670a1d2f2e71ea77004fa45613e61..caf9e6fc8d9ec2fd8147e882528cc538e40b8dff 100644 --- a/applications/test/parallel/parallelTest.C +++ b/applications/test/parallel/parallelTest.C @@ -84,7 +84,7 @@ int main(int argc, char *argv[]) // Sync how many to send labelListList allNTrans(Pstream::nProcs()); allNTrans[Pstream::myProcNo()] = nSend; - combineReduce(allNTrans, mapDistribute::listEq()); + combineReduce(allNTrans, UPstream::listEq()); // Collect items to be sent labelListList sendMap(Pstream::nProcs()); @@ -161,7 +161,7 @@ int main(int argc, char *argv[]) toMaster << data; } - Perr<< "slave receiving from master " + Perr<< "slave receiving from master " << Pstream::masterNo() << endl; IPstream fromMaster(Pstream::blocking, Pstream::masterNo()); fromMaster >> data; diff --git a/applications/test/slicedField/slicedFieldTest.C b/applications/test/slicedField/slicedFieldTest.C index a82b4ac71298032c02073b84fc4f86c6eee13b23..dd8da2522389c2507158c15e9652ad444827b590 100644 --- a/applications/test/slicedField/slicedFieldTest.C +++ b/applications/test/slicedField/slicedFieldTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - volField + slicedFieldTest Description @@ -32,16 +32,16 @@ Description #include "fvCFD.H" #include "SlicedGeometricField.H" #include "slicedFvPatchFields.H" +#include "slicedSurfaceFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { + #include "setRootCase.H" -# include "setRootCase.H" - -# include "createTime.H" -# include "createMesh.H" + #include "createTime.H" + #include "createMesh.H" Info<< "Reading field p\n" << endl; volScalarField p @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) Info<< C << endl; Info<< (C & U) << endl; - SlicedGeometricField<vector, fvPatchField, slicedFvPatchField, surfaceMesh> + SlicedGeometricField<vector, fvsPatchField, slicedFvsPatchField, surfaceMesh> Sf ( IOobject @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) mesh.faceAreas() ); - Info<< Sf << endl; + //Info<< Sf << endl; return 0; } diff --git a/applications/test/testPointEdgeWave/testPointEdgeWave.C b/applications/test/testPointEdgeWave/testPointEdgeWave.C index 3a1ff900eb8c561517579165f7c426446d831f12..124b7a921ab6d1b72688bfdcecfae95452ce24e3 100644 --- a/applications/test/testPointEdgeWave/testPointEdgeWave.C +++ b/applications/test/testPointEdgeWave/testPointEdgeWave.C @@ -48,8 +48,6 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createPolyMesh.H" - pointMesh pMesh(mesh); - const polyBoundaryMesh& patches = mesh.boundaryMesh(); // Get name of patch @@ -99,7 +97,7 @@ int main(int argc, char *argv[]) PointEdgeWave<pointEdgePoint> wallCalc ( - pMesh, + mesh, wallPoints, wallInfo, @@ -119,7 +117,7 @@ int main(int argc, char *argv[]) IOobject::NO_READ, IOobject::AUTO_WRITE ), - pMesh, + pointMesh::New(mesh), dimensionedScalar("wallDist", dimLength, 0.0) ); diff --git a/applications/test/volField/volFieldTest.C b/applications/test/volField/volFieldTest.C index 3b7dafef8e4fd17d291874d5bce44d90cc297295..f910c22544415e9974e1d74d497d3f597a6ae4e9 100644 --- a/applications/test/volField/volFieldTest.C +++ b/applications/test/volField/volFieldTest.C @@ -34,11 +34,10 @@ Application int main(int argc, char *argv[]) { + #include "setRootCase.H" -# include "setRootCase.H" - -# include "createTime.H" -# include "createMesh.H" + #include "createTime.H" + #include "createMesh.H" Info<< "Reading field p\n" << endl; volScalarField p @@ -70,12 +69,9 @@ int main(int argc, char *argv[]) mesh ); -# include "createPhi.H" - - //Info<< transform(dimensionedTensor("I", dimless, 0.1*I), U) << endl; - + #include "createPhi.H" - GeometricField<sphericalTensor, fvPatchField, volMesh> st + GeometricField<symmTensor, fvPatchField, volMesh> st ( IOobject ( @@ -86,8 +82,8 @@ int main(int argc, char *argv[]) IOobject::NO_WRITE ), mesh, - dimensioned<sphericalTensor>("st", dimless, sphericalTensor::I), - zeroGradientFvPatchSphericalTensorField::typeName + dimensioned<symmTensor>("st", dimless, symmTensor::one), + zeroGradientFvPatchSymmTensorField::typeName ); //Info<< fvc::div(st) << endl; diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/Allwmake b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/Allwmake deleted file mode 100755 index b1106aa608e77914b8c251d30e8978b6a00dcc3b..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/Allwmake +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # run from this directory -set -x - -if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] -then - case "$ParaView_VERSION" in - 2*) - wmake libso vtkFoam - ( - cd PVFoamReader - mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1 - cd Make/$WM_OPTIONS - cmake ../.. - make - ) - ;; - esac -fi - -# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/CMakeLists.txt deleted file mode 100644 index 1c88efbbfff2b768cc1cdb3938bc190d54d7e45e..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/CMakeLists.txt +++ /dev/null @@ -1,79 +0,0 @@ -# Set the project/library name here. Classes should be declared as -# "class VTK_FoamReader_EXPORT vtkFoo", where PVFoamReader is the name of the -# project set here. -PROJECT(PVFoamReader) - -# Set your list of sources here. Do not change the name of the -# PVFoamReader_SRCS variable. -SET(PVFoamReader_SRCS - vtkFoamReader.cxx - vtkFoamData.cxx -) - -# List the kits from VTK that are needed by this project. Do not -# change the name of the PVFoamReader_LIBS variable. -SET(PVFoamReader_LIBS - vtkGraphics -) - -INCLUDE_DIRECTORIES( - $ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude - $ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude - $ENV{ParaView_INST_DIR}/include - ../vtkFoam/lnInclude -) -ADD_DEFINITIONS(-DWM_$ENV{WM_PRECISION_OPTION}) - -#----------------------------------------------------------------------------- -# Most users should not need to change anything below this line. - -# Need to include class headers and the configuration header. -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}) - -# Import ParaView build settings. -FIND_PACKAGE(ParaView) -IF(NOT ParaView_FOUND) - MESSAGE(FATAL_ERROR "ParaView is required. Set ParaView_DIR.") -ENDIF(NOT ParaView_FOUND) -IF(NOT PARAVIEW_BUILD_SHARED_LIBS) - MESSAGE(FATAL_ERROR "ParaView must be built with BUILD_SHARED_LIBS ON.") -ENDIF(NOT PARAVIEW_BUILD_SHARED_LIBS) -INCLUDE(${PARAVIEW_USE_FILE}) - -# Configure output directories. -SET (LIBRARY_OUTPUT_PATH $ENV{FOAM_LIBBIN} CACHE INTERNAL - "Single output directory for building all libraries.") -SET (EXECUTABLE_OUTPUT_PATH $ENV{FOAM_APPBIN} CACHE INTERNAL - "Single output directory for building all executables.") - -# Create the configuration header. -CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReaderConfigure.h.in - ${PROJECT_BINARY_DIR}/vtk${PROJECT_NAME}Configure.h - @ONLY IMMEDIATE) - -# Must be defined before ADD_LIBRARY for cmake version 2.3.4-20060317 -LINK_DIRECTORIES($ENV{FOAM_LIBBIN}) -LINK_DIRECTORIES($ENV{FOAM_USER_LIBBIN}) - -# Create vtk client/server wrappers for the classes. -VTK_WRAP_ClientServer(${PROJECT_NAME} PVFoamReaderCS_SRCS "${PVFoamReader_SRCS}") - -# Build the package as a plugin for ParaView. -ADD_LIBRARY(${PROJECT_NAME} MODULE ${PVFoamReader_SRCS} ${PVFoamReaderCS_SRCS}) -LINK_DIRECTORIES($ENV{ParaView_INST_DIR}/lib) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} vtkClientServer) -FOREACH(c ${PVFoamReader_LIBS}) - TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${c}CS) -ENDFOREACH(c) - -# Place the package configuration file into the build tree. -CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReader.xml.in - ${PROJECT_BINARY_DIR}/../${PROJECT_NAME}.xml @ONLY IMMEDIATE) - -# Place the package configuration file into the build tree. -CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReader.pvsm.in - ${PROJECT_BINARY_DIR}/../${PROJECT_NAME}.pvsm @ONLY IMMEDIATE) - -TARGET_LINK_LIBRARIES(${PROJECT_NAME} OpenFOAM finiteVolume vtkFoam) -#----------------------------------------------------------------------------- diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/Make/PVFoamReader.pvsm b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/Make/PVFoamReader.pvsm deleted file mode 100644 index e3a097219e5bd6396d5e40f4eeac95c03be8a0f8..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/Make/PVFoamReader.pvsm +++ /dev/null @@ -1,154 +0,0 @@ -<ServerManagerConfiguration> - <ProxyGroup name="sources"> - <SourceProxy - - name="FoamReader" - class="vtkFoamReader"> - - <StringVectorProperty - name="FileName" - command="SetFileName" - number_of_elements="1"> - <StringListDomain name="files"/> - </StringVectorProperty> - - <IntVectorProperty - name="UpdateGUI" - command="SetUpdateGUI" - number_of_elements="1" - default_values="0"> - <BooleanDomain name="bool"/> - </IntVectorProperty> - - <IntVectorProperty - name="CacheMesh" - command="SetCacheMesh" - number_of_elements="1" - default_values="1"> - <BooleanDomain name="bool"/> - </IntVectorProperty> - - <IntVectorProperty - name="TimeStepRangeInfo" - command="GetTimeStepRange" - information_only="1"> - <SimpleIntInformationHelper/> - </IntVectorProperty> - <IntVectorProperty - name="TimeStep" - command="SetTimeStep" - number_of_elements="1" - animateable="1" - default_values="0"> - <IntRangeDomain name="range"> - <RequiredProperties> - <Property name="TimeStepRangeInfo" function="Range"/> - </RequiredProperties> - </IntRangeDomain> - </IntVectorProperty> - - <IntVectorProperty - name="TimeStepLimitsInfo" - command="GetTimeStepLimits" - information_only="1"> - <SimpleIntInformationHelper/> - </IntVectorProperty> - <IntVectorProperty - name="TimeStepLimits" - command="SetTimeStepLimits" - number_of_elements="2" - default_values="2 5" > - <IntRangeDomain name="range"> - <RequiredProperties> - <Property name="TimeStepLimitsInfo" function="Range"/> - </RequiredProperties> - </IntRangeDomain> - </IntVectorProperty> - - <StringVectorProperty - name="TimeArrayInfo" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="Time"/> - </StringVectorProperty> - <StringVectorProperty - name="TimeStatus" - command="SetTimeArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="TimeArrayInfo"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="TimeArrayInfo" - function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - </StringVectorProperty> - - <StringVectorProperty - name="RegionArrayInfo" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="Region"/> - </StringVectorProperty> - <StringVectorProperty - name="RegionStatus" - command="SetRegionArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="RegionArrayInfo"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="RegionArrayInfo" - function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - </StringVectorProperty> - - <StringVectorProperty - name="VolFieldArrayInfo" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="VolField"/> - </StringVectorProperty> - <StringVectorProperty - name="VolFieldStatus" - command="SetVolFieldArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="VolFieldArrayInfo"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="VolFieldArrayInfo" - function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - </StringVectorProperty> - - <StringVectorProperty - name="PointFieldArrayInfo" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="PointField"/> - </StringVectorProperty> - <StringVectorProperty - name="PointFieldStatus" - command="SetPointFieldArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="PointFieldArrayInfo"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="PointFieldArrayInfo" - function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - </StringVectorProperty> - - </SourceProxy> - </ProxyGroup> -</ServerManagerConfiguration> diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/Make/PVFoamReader.xml b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/Make/PVFoamReader.xml deleted file mode 100644 index 91e00b78d68150cdae95e6221506415d09d4638a..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/Make/PVFoamReader.xml +++ /dev/null @@ -1,71 +0,0 @@ -<ModuleInterfaces> - <Library name="PVFoamReader"/> - <ServerManagerFile name="PVFoamReader.pvsm"/> - - <Module name="FoamReader" - class="vtkPVAdvancedReaderModule" - root_name="Foam" - output="vtkDataSet" - module_type="Reader" - extensions=".foam" - file_description="Foam case"> - - <Source class="vtkFoamReader"/> - - <LabeledToggle - label="Update GUI" - trace_name="UpdateGUI" - property="UpdateGUI" - help="To update GUI without execution toggle this Accept and Reset."/> - - <LabeledToggle - label="Cache Mesh" - trace_name="CacheMesh" - property="CacheMesh" - help="Cache the FOAM mesh between GUI selection changes."/> - - <Scale - property="TimeStep" - trace_name="TimeStep" - label="Time step" - display_entry="0" - display_value="1" - entry_and_label_on_top="0" - help="Select a time step." - keeps_timesteps="1" - range_source="TimeStepRange"/> - - <VectorEntry - property="TimeStepLimits" - type="int" - trace_name="TimeStepLimits" - length="2" - label="Lower and Upper Times" - help="Maximum lower and upper number of time steps displayed in the selection list."/> - - <ArraySelection - label_text="Time" - property="TimeStatus" - trace_name="TimeArrays"/> - - <ArraySelection - label_text="Region" - property="RegionStatus" - trace_name="RegionArrays"/> - - <ArraySelection - label_text="Vol Field" - property="VolFieldStatus" - trace_name="CellArrays"/> - - <ArraySelection - label_text="Point Field" - property="PointFieldStatus" - trace_name="PointArrays"/> - - <Documentation> - ParaView Foam reader module - </Documentation> - </Module> - -</ModuleInterfaces> diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReader.pvsm.in b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReader.pvsm.in deleted file mode 100644 index e3a097219e5bd6396d5e40f4eeac95c03be8a0f8..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReader.pvsm.in +++ /dev/null @@ -1,154 +0,0 @@ -<ServerManagerConfiguration> - <ProxyGroup name="sources"> - <SourceProxy - - name="FoamReader" - class="vtkFoamReader"> - - <StringVectorProperty - name="FileName" - command="SetFileName" - number_of_elements="1"> - <StringListDomain name="files"/> - </StringVectorProperty> - - <IntVectorProperty - name="UpdateGUI" - command="SetUpdateGUI" - number_of_elements="1" - default_values="0"> - <BooleanDomain name="bool"/> - </IntVectorProperty> - - <IntVectorProperty - name="CacheMesh" - command="SetCacheMesh" - number_of_elements="1" - default_values="1"> - <BooleanDomain name="bool"/> - </IntVectorProperty> - - <IntVectorProperty - name="TimeStepRangeInfo" - command="GetTimeStepRange" - information_only="1"> - <SimpleIntInformationHelper/> - </IntVectorProperty> - <IntVectorProperty - name="TimeStep" - command="SetTimeStep" - number_of_elements="1" - animateable="1" - default_values="0"> - <IntRangeDomain name="range"> - <RequiredProperties> - <Property name="TimeStepRangeInfo" function="Range"/> - </RequiredProperties> - </IntRangeDomain> - </IntVectorProperty> - - <IntVectorProperty - name="TimeStepLimitsInfo" - command="GetTimeStepLimits" - information_only="1"> - <SimpleIntInformationHelper/> - </IntVectorProperty> - <IntVectorProperty - name="TimeStepLimits" - command="SetTimeStepLimits" - number_of_elements="2" - default_values="2 5" > - <IntRangeDomain name="range"> - <RequiredProperties> - <Property name="TimeStepLimitsInfo" function="Range"/> - </RequiredProperties> - </IntRangeDomain> - </IntVectorProperty> - - <StringVectorProperty - name="TimeArrayInfo" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="Time"/> - </StringVectorProperty> - <StringVectorProperty - name="TimeStatus" - command="SetTimeArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="TimeArrayInfo"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="TimeArrayInfo" - function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - </StringVectorProperty> - - <StringVectorProperty - name="RegionArrayInfo" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="Region"/> - </StringVectorProperty> - <StringVectorProperty - name="RegionStatus" - command="SetRegionArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="RegionArrayInfo"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="RegionArrayInfo" - function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - </StringVectorProperty> - - <StringVectorProperty - name="VolFieldArrayInfo" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="VolField"/> - </StringVectorProperty> - <StringVectorProperty - name="VolFieldStatus" - command="SetVolFieldArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="VolFieldArrayInfo"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="VolFieldArrayInfo" - function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - </StringVectorProperty> - - <StringVectorProperty - name="PointFieldArrayInfo" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="PointField"/> - </StringVectorProperty> - <StringVectorProperty - name="PointFieldStatus" - command="SetPointFieldArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="PointFieldArrayInfo"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="PointFieldArrayInfo" - function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - </StringVectorProperty> - - </SourceProxy> - </ProxyGroup> -</ServerManagerConfiguration> diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReader.xml.in b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReader.xml.in deleted file mode 100644 index 5eb2a4a8e8a4f674474ac098450dfbb2748ff391..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReader.xml.in +++ /dev/null @@ -1,71 +0,0 @@ -<ModuleInterfaces> - <Library name="@PROJECT_NAME@"/> - <ServerManagerFile name="@PROJECT_NAME@.pvsm"/> - - <Module name="FoamReader" - class="vtkPVAdvancedReaderModule" - root_name="Foam" - output="vtkDataSet" - module_type="Reader" - extensions=".foam" - file_description="Foam case"> - - <Source class="vtkFoamReader"/> - - <LabeledToggle - label="Update GUI" - trace_name="UpdateGUI" - property="UpdateGUI" - help="To update GUI without execution toggle this Accept and Reset."/> - - <LabeledToggle - label="Cache Mesh" - trace_name="CacheMesh" - property="CacheMesh" - help="Cache the FOAM mesh between GUI selection changes."/> - - <Scale - property="TimeStep" - trace_name="TimeStep" - label="Time step" - display_entry="0" - display_value="1" - entry_and_label_on_top="0" - help="Select a time step." - keeps_timesteps="1" - range_source="TimeStepRange"/> - - <VectorEntry - property="TimeStepLimits" - type="int" - trace_name="TimeStepLimits" - length="2" - label="Lower and Upper Times" - help="Maximum lower and upper number of time steps displayed in the selection list."/> - - <ArraySelection - label_text="Time" - property="TimeStatus" - trace_name="TimeArrays"/> - - <ArraySelection - label_text="Region" - property="RegionStatus" - trace_name="RegionArrays"/> - - <ArraySelection - label_text="Vol Field" - property="VolFieldStatus" - trace_name="CellArrays"/> - - <ArraySelection - label_text="Point Field" - property="PointFieldStatus" - trace_name="PointArrays"/> - - <Documentation> - ParaView Foam reader module - </Documentation> - </Module> - -</ModuleInterfaces> diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReaderConfigure.h.in b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReaderConfigure.h.in deleted file mode 100644 index aae4a079a2faf8d11545d4048049e4f0a4a258ed..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReaderConfigure.h.in +++ /dev/null @@ -1,18 +0,0 @@ -/*========================================================================= -This source has no copyright. It is intended to be copied by users -wishing to create their own ParaView plugin classes locally. -=========================================================================*/ -#ifndef __vtk@PROJECT_NAME@_h -#define __vtk@PROJECT_NAME@_h - -#if defined(_WIN32) -# if defined(@PROJECT_NAME@_EXPORTS) -# define VTK_@PROJECT_NAME@_EXPORT __declspec(dllexport) -# else -# define VTK_@PROJECT_NAME@_EXPORT __declspec(dllimport) -# endif -#else -# define VTK_@PROJECT_NAME@_EXPORT -#endif - -#endif diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamReader.cxx b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamReader.cxx deleted file mode 100644 index d977104ce28e26993b12342c86d4847a141a12ba..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamReader.cxx +++ /dev/null @@ -1,411 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 - -Description - -\*---------------------------------------------------------------------------*/ - -#include <ctype.h> - -#include "vtkFoamReader.h" - -#include "vtkCallbackCommand.h" -#include "vtkDataArraySelection.h" -#include "vtkDataArrayCollection.h" -#include "vtkObjectFactory.h" -#include "vtkDataSet.h" -#include "vtkErrorCode.h" -#include "vtkUnstructuredGrid.h" - -#include "vtkFoam.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -vtkCxxRevisionMacro(vtkFoamReader, "$Revision: 1.20 $"); -vtkStandardNewMacro(vtkFoamReader); - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -vtkFoamReader::vtkFoamReader() -{ - StoredOutputs = NULL; - - FileName = NULL; - foamData_ = NULL; - - CacheMesh = 0; - - UpdateGUI = 1; - UpdateGUIOld = 1; - TimeStep = 0; - TimeStepRange[0] = 0; - TimeStepRange[1] = 0; - - TimeStepLimits[0] = 2; - TimeStepLimits[1] = 5; - - TimeSelection = vtkDataArraySelection::New(); - RegionSelection = vtkDataArraySelection::New(); - VolFieldSelection = vtkDataArraySelection::New(); - PointFieldSelection = vtkDataArraySelection::New(); - - // Setup the selection callback to modify this object when an array - // selection is changed. - SelectionObserver = vtkCallbackCommand::New(); - SelectionObserver->SetCallback(&vtkFoamReader::SelectionModifiedCallback); - SelectionObserver->SetClientData(this); - - TimeSelection->AddObserver - ( - vtkCommand::ModifiedEvent, - this->SelectionObserver - ); - RegionSelection->AddObserver - ( - vtkCommand::ModifiedEvent, - this->SelectionObserver - ); - VolFieldSelection->AddObserver - ( - vtkCommand::ModifiedEvent, - this->SelectionObserver - ); - PointFieldSelection->AddObserver - ( - vtkCommand::ModifiedEvent, - this->SelectionObserver - ); - - // This is needed by ParaView 2.?.? - this->SetNumberOfOutputPorts(0); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -vtkFoamReader::~vtkFoamReader() -{ - if (foamData_) - { - delete foamData_; - } - - if (StoredOutputs) - { - StoredOutputs->Delete(); - } - - if (FileName) - { - delete [] FileName; - } - - TimeSelection->RemoveObserver(this->SelectionObserver); - RegionSelection->RemoveObserver(this->SelectionObserver); - VolFieldSelection->RemoveObserver(this->SelectionObserver); - PointFieldSelection->RemoveObserver(this->SelectionObserver); - SelectionObserver->Delete(); - - TimeSelection->Delete(); - RegionSelection->Delete(); - VolFieldSelection->Delete(); - PointFieldSelection->Delete(); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void vtkFoamReader::ExecuteInformation() -{ - if (!foamData_) - { - vtkDebugMacro( << "Reading Foam case" << FileName); - foamData_ = new Foam::vtkFoam(FileName, this); - } - else - { - foamData_->UpdateInformation(); - } - - vtkDebugMacro( << "end of ExecuteInformation\n"); -} - - -void vtkFoamReader::Execute() -{ - if (!StoredOutputs) - { - foamData_->Update(); - - StoredOutputs = vtkFoamData::New(); - - for (int i = 0; i < GetNumberOfOutputs(); i++) - { - vtkDataObject* tmp = GetOutput(i); - vtkDataObject* output = tmp->NewInstance(); - output->ShallowCopy(tmp); - StoredOutputs->SetNthOutput(i, output); - output->Delete(); - } - } - else - { - for (int i = 0; i < GetNumberOfOutputs(); i++) - { - vtkDataObject* output = GetOutput(i); - int tempExtent[6]; - output->GetUpdateExtent(tempExtent); - output->ShallowCopy(StoredOutputs->GetOutput(i)); - output->SetUpdateExtent(tempExtent); - } - - if (UpdateGUIOld == GetUpdateGUI()) - { - foamData_->Update(); - - for (int i = 0; i < GetNumberOfOutputs(); i++) - { - vtkDataObject* tmp = GetOutput(i); - vtkDataObject* output = tmp->NewInstance(); - output->ShallowCopy(tmp); - StoredOutputs->SetNthOutput(i, output); - output->Delete(); - } - } - } - - UpdateGUIOld = GetUpdateGUI(); -} - - -void vtkFoamReader::SetFileName(const char *name) -{ - if (name && !FileName || (FileName && !strcmp(FileName,name))) - { - if (!FileName) - { - FileName = new char[strlen(name) + 1]; - strcpy(FileName, name); - } - } - else - { - vtkErrorMacro("Changing case is not currently supported.\nPlease delete reader and create a new one for the new case."); - return; - } - - /* - if ( FileName && name && (!strcmp(FileName,name))) - { - return; - } - - if (!name && !FileName) - { - return; - } - - if (FileName) - { - delete [] FileName; - } - - FileName = new char[strlen(name) + 1]; - strcpy(FileName, name); - - if (foamData_) - { - delete foamData_; - foamData_ = NULL; - - if (StoredOutputs) - { - StoredOutputs->Delete(); - StoredOutputs = NULL; - } - } - - Modified(); - */ -} - - -void vtkFoamReader::PrintSelf(ostream& os, vtkIndent indent) -{ - Superclass::PrintSelf(os,indent); - - os << indent << "File Name: " - << (FileName ? FileName : "(none)") << "\n"; -} - - -vtkDataArraySelection* vtkFoamReader::GetTimeSelection() -{ - return TimeSelection; -} - -int vtkFoamReader::GetNumberOfTimeArrays() -{ - return TimeSelection->GetNumberOfArrays(); -} - -const char* vtkFoamReader::GetTimeArrayName(int index) -{ - return TimeSelection->GetArrayName(index); -} - -int vtkFoamReader::GetTimeArrayStatus(const char* name) -{ - return TimeSelection->ArrayIsEnabled(name); -} - -void vtkFoamReader::SetTimeArrayStatus(const char* name, int status) -{ - if(status) - { - TimeSelection->EnableArray(name); - } - else - { - TimeSelection->DisableArray(name); - } -} - -vtkDataArraySelection* vtkFoamReader::GetRegionSelection() -{ - return RegionSelection; -} - -int vtkFoamReader::GetNumberOfRegionArrays() -{ - return RegionSelection->GetNumberOfArrays(); -} - -const char* vtkFoamReader::GetRegionArrayName(int index) -{ - return RegionSelection->GetArrayName(index); -} - -int vtkFoamReader::GetRegionArrayStatus(const char* name) -{ - return RegionSelection->ArrayIsEnabled(name); -} - -void vtkFoamReader::SetRegionArrayStatus(const char* name, int status) -{ - if(status) - { - RegionSelection->EnableArray(name); - } - else - { - RegionSelection->DisableArray(name); - } -} - - -vtkDataArraySelection* vtkFoamReader::GetVolFieldSelection() -{ - return VolFieldSelection; -} - -int vtkFoamReader::GetNumberOfVolFieldArrays() -{ - return VolFieldSelection->GetNumberOfArrays(); -} - -const char* vtkFoamReader::GetVolFieldArrayName(int index) -{ - return VolFieldSelection->GetArrayName(index); -} - -int vtkFoamReader::GetVolFieldArrayStatus(const char* name) -{ - return VolFieldSelection->ArrayIsEnabled(name); -} - -void vtkFoamReader::SetVolFieldArrayStatus(const char* name, int status) -{ - if(status) - { - VolFieldSelection->EnableArray(name); - } - else - { - VolFieldSelection->DisableArray(name); - } -} - - -vtkDataArraySelection* vtkFoamReader::GetPointFieldSelection() -{ - return PointFieldSelection; -} - -int vtkFoamReader::GetNumberOfPointFieldArrays() -{ - return PointFieldSelection->GetNumberOfArrays(); -} - -const char* vtkFoamReader::GetPointFieldArrayName(int index) -{ - return PointFieldSelection->GetArrayName(index); -} - -int vtkFoamReader::GetPointFieldArrayStatus(const char* name) -{ - return PointFieldSelection->ArrayIsEnabled(name); -} - -void vtkFoamReader::SetPointFieldArrayStatus(const char* name, int status) -{ - if(status) - { - PointFieldSelection->EnableArray(name); - } - else - { - PointFieldSelection->DisableArray(name); - } -} - - -void vtkFoamReader::SelectionModifiedCallback -( - vtkObject*, - unsigned long, - void* clientdata, - void* -) -{ - static_cast<vtkFoamReader*>(clientdata)->SelectionModified(); -} - -void vtkFoamReader::SelectionModified() -{ - Modified(); -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamReader.h b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamReader.h deleted file mode 100644 index 023c064086ba8a8c691143dc27a65c18795f1a97..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamReader.h +++ /dev/null @@ -1,200 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 - vtkFoamReader - -Description - -SourceFiles - vtkFoamReader.cxx - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkFoamReader_h -#define vtkFoamReader_h - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "vtkDataSetSource.h" -#include "vtkFoamData.h" - -// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // - -namespace Foam -{ - class vtkFoam; -} - -class vtkPoints; -class vtkDataArraySelection; -class vtkDataArrayCollection; -class vtkCallbackCommand; - -/*---------------------------------------------------------------------------*\ - Class vtkFoamReader Declaration -\*---------------------------------------------------------------------------*/ - -class VTK_IO_EXPORT vtkFoamReader -: - public vtkDataSetSource -{ - -public: - - //- Standard VTK class creation function - static vtkFoamReader *New(); - - //- Standard VTK class type and revision declaration macro - vtkTypeRevisionMacro(vtkFoamReader,vtkDataSetSource); - - //- Standard VTK class print function - void PrintSelf(ostream& os, vtkIndent indent); - - // File name of FOAM datafile to read - void SetFileName(const char *); - //vtkSetStringMacro(FileName); - vtkGetStringMacro(FileName); - - // GUI update control - vtkSetMacro(UpdateGUI, int); - vtkGetMacro(UpdateGUI, int); - - // FOAM mesh caching control - vtkSetMacro(CacheMesh, int); - vtkGetMacro(CacheMesh, int); - - // Time-step slider control - vtkSetMacro(TimeStep, int); - vtkGetMacro(TimeStep, int); - vtkSetVector2Macro(TimeStepRange, int); - vtkGetVector2Macro(TimeStepRange, int); - - // Control of the upper and lower limits on the number of times - // displayed in the selection list - vtkSetVector2Macro(TimeStepLimits, int); - vtkGetVector2Macro(TimeStepLimits, int); - - // Time selection list control - vtkDataArraySelection* GetTimeSelection(); - int GetNumberOfTimeArrays(); - const char* GetTimeArrayName(int index); - int GetTimeArrayStatus(const char* name); - void SetTimeArrayStatus(const char* name, int status); - - // Region selection list control - vtkDataArraySelection* GetRegionSelection(); - int GetNumberOfRegionArrays(); - const char* GetRegionArrayName(int index); - int GetRegionArrayStatus(const char* name); - void SetRegionArrayStatus(const char* name, int status); - - // volField selection list control - vtkDataArraySelection* GetVolFieldSelection(); - int GetNumberOfVolFieldArrays(); - const char* GetVolFieldArrayName(int index); - int GetVolFieldArrayStatus(const char* name); - void SetVolFieldArrayStatus(const char* name, int status); - - // pointField selection list control - vtkDataArraySelection* GetPointFieldSelection(); - int GetNumberOfPointFieldArrays(); - const char* GetPointFieldArrayName(int index); - int GetPointFieldArrayStatus(const char* name); - void SetPointFieldArrayStatus(const char* name, int status); - - // SetNthOutput provided so that vtkFoam can access it - void SetNthOutput(int num, vtkDataObject *output) - { - vtkDataSetSource::SetNthOutput(num, output); - } - - // Standard VTK ExecuteInformation function overriding the base-class. - // Called by ParaView before GUI is displayed. - virtual void ExecuteInformation(); - - // Callback registered with the SelectionObserver - // for all the selection lists - static void SelectionModifiedCallback - ( - vtkObject* caller, - unsigned long eid, - void* clientdata, - void* calldata - ); - - void SelectionModified(); - - -protected: - - vtkFoamReader(); - ~vtkFoamReader(); - - // Standard VTK execute function overriding the base-class. - // Called by ParaView when Accept is pressed. - void Execute(); - - // Cache for the outputs. These are stored before the end of Execute() - // and re-instated at the beginning because the Outputs would disappear - // otherwise. - vtkFoamData* StoredOutputs; - - // FOAM file name (*.foam) - char *FileName; - - //BTX - Foam::vtkFoam* foamData_; - //ETX - - int CacheMesh; - - int UpdateGUI; - int UpdateGUIOld; - int TimeStep; - int TimeStepRange[2]; - - int TimeStepLimits[2]; - - vtkDataArraySelection* TimeSelection; - vtkDataArraySelection* RegionSelection; - vtkDataArraySelection* VolFieldSelection; - vtkDataArraySelection* PointFieldSelection; - - // The observer to modify this object when the array selections are modified - vtkCallbackCommand* SelectionObserver; - - -private: - - vtkFoamReader(const vtkFoamReader&); // Not implemented. - void operator=(const vtkFoamReader&); // Not implemented. -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.cxx b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.cxx deleted file mode 100644 index fd948578da81a6a9df0553c6f80c6ef841baece3..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.cxx +++ /dev/null @@ -1,531 +0,0 @@ -/*========================================================================= - - Program: ParaView - Module: $RCSfile: vtkPVFoamSelectTimeSet.cxx,v $ - - Copyright (c) Kitware, Inc. - All rights reserved. - See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -#include "vtkPVFoamSelectTimeSet.h" - -#include "vtkDataArrayCollection.h" -#include "vtkFloatArray.h" -#include "vtkKWFrame.h" -#include "vtkKWLabel.h" -#include "vtkKWLabeledFrame.h" -#include "vtkKWMenu.h" -#include "vtkObjectFactory.h" -#include "vtkPVAnimationInterfaceEntry.h" -#include "vtkPVApplication.h" -#include "vtkPVProcessModule.h" -#include "vtkPVScalarListWidgetProperty.h" -#include "vtkPVSource.h" -#include "vtkPVXMLElement.h" - -#include <vtkstd/string> - -//----------------------------------------------------------------------------- -vtkStandardNewMacro(vtkPVFoamSelectTimeSet); -vtkCxxRevisionMacro(vtkPVFoamSelectTimeSet, "$Revision: 1.39 $"); - -//----------------------------------------------------------------------------- -int vtkDataArrayCollectionCommand(ClientData cd, Tcl_Interp *interp, - int argc, char *argv[]); - -//----------------------------------------------------------------------------- -vtkPVFoamSelectTimeSet::vtkPVFoamSelectTimeSet() -{ - this->LabeledFrame = vtkKWLabeledFrame::New(); - this->LabeledFrame->SetParent(this); - - this->TimeLabel = vtkKWLabel::New(); - this->TimeLabel->SetParent(this->LabeledFrame->GetFrame()); - - this->TreeFrame = vtkKWWidget::New(); - this->TreeFrame->SetParent(this->LabeledFrame->GetFrame()); - - this->Tree = vtkKWWidget::New(); - this->Tree->SetParent(this->TreeFrame); - - this->TimeValue = 0.0; - - this->FrameLabel = 0; - - this->TimeSets = vtkDataArrayCollection::New(); - - this->Property = 0; - - this->SetCommand = 0; - this->ServerSideID.ID = 0; -} - -//----------------------------------------------------------------------------- -vtkPVFoamSelectTimeSet::~vtkPVFoamSelectTimeSet() -{ - this->LabeledFrame->Delete(); - this->Tree->Delete(); - this->TreeFrame->Delete(); - this->TimeLabel->Delete(); - this->SetFrameLabel(0); - this->TimeSets->Delete(); - this->SetSetCommand(0); - if(this->ServerSideID.ID) - { - vtkPVProcessModule* pm = this->GetPVApplication()->GetProcessModule(); - pm->DeleteStreamObject(this->ServerSideID); - pm->SendStream(vtkProcessModule::DATA_SERVER); - } -} - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::SetLabel(const char* label) -{ - this->SetFrameLabel(label); - if (this->GetApplication()) - { - this->LabeledFrame->SetLabel(label); - } -} - -//----------------------------------------------------------------------------- -const char* vtkPVFoamSelectTimeSet::GetLabel() -{ - return this->GetFrameLabel(); -} - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::Create(vtkKWApplication *pvApp) -{ - // Call the superclass to create the widget and set the appropriate flags - - if (!this->vtkKWWidget::Create(pvApp, "frame", "-bd 2 -relief flat")) - { - vtkErrorMacro("Failed creating widget " << this->GetClassName()); - return; - } - - // For getting the widget in a script. - if ((this->TraceNameState == vtkPVWidget::Uninitialized || - this->TraceNameState == vtkPVWidget::Default) ) - { - this->SetTraceName("FoamSelectTimeSet"); - this->SetTraceNameState(vtkPVWidget::SelfInitialized); - } - - this->LabeledFrame->Create(this->GetApplication(), 0); - if (this->FrameLabel) - { - this->LabeledFrame->SetLabel(this->FrameLabel); - } - this->TimeLabel->Create(this->GetApplication(), ""); - - char label[32]; - sprintf(label, "Time value: %12.5e", 0.0); - this->TimeLabel->SetLabel(label); - this->Script("pack %s", this->TimeLabel->GetWidgetName()); - - this->TreeFrame->Create(this->GetApplication(), "ScrolledWindow", - "-relief sunken -bd 2"); - - this->Tree->Create(this->GetApplication(), "Tree", - "-background white -bd 0 -width 15 -padx 2 " - "-redraw 1 -relief flat -selectbackground red"); - this->Script("%s bindText <ButtonPress-1> {%s SetTimeValueCallback}", - this->Tree->GetWidgetName(), this->GetTclName()); - this->Script("%s setwidget %s", this->TreeFrame->GetWidgetName(), - this->Tree->GetWidgetName()); - - this->Script("pack %s -expand t -fill x", this->TreeFrame->GetWidgetName()); - - this->Script("pack %s -side top -expand t -fill x", - this->LabeledFrame->GetWidgetName()); - -} - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::SetTimeValue(float time) -{ - if (this->TimeValue != time || - !this->TimeLabel->GetLabel() || - !strcmp(this->TimeLabel->GetLabel(), "No timesets available.")) - { - this->TimeValue = time; - - char label[32]; - sprintf(label, "Time value: %12.5e", time); - this->TimeLabel->SetLabel(label); - this->Modified(); - } -} - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::SetTimeValueCallback(const char* item) -{ - if (this->TimeSets->GetNumberOfItems() == 0) - { - return; - } - - if ( strncmp(item, "timeset", strlen("timeset")) == 0 ) - { - this->Script("if [%s itemcget %s -open] " - "{%s closetree %s} else {%s opentree %s}", - this->Tree->GetWidgetName(), item, - this->Tree->GetWidgetName(), item, - this->Tree->GetWidgetName(), item); - return; - } - - this->Script("%s selection set %s", this->Tree->GetWidgetName(), - item); - this->Script("%s itemcget %s -data", this->Tree->GetWidgetName(), - item); - const char* result = this->GetApplication()->GetMainInterp()->result; - if (result[0] == '\0') - { - return; - } - - int index[2]; - sscanf(result, "%d %d", &(index[0]), &(index[1])); - - this->SetTimeSetsFromReader(); - this->SetTimeValue(this->TimeSets->GetItem(index[0])->GetTuple1(index[1])); - this->ModifiedCallback(); -} - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::AddRootNode(const char* name, const char* text) -{ - if (!this->GetApplication()) - { - return; - } - this->Script("%s insert end root %s -text {%s}", this->Tree->GetWidgetName(), - name, text); -} - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::AddChildNode(const char* parent, const char* name, - const char* text, const char* data) -{ - if (!this->GetApplication()) - { - return; - } - this->Script("%s insert end %s %s -text {%s} -data %s", - this->Tree->GetWidgetName(), parent, name, text, data); -} - - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::SaveInBatchScript(ofstream *file) -{ - *file << " [$pvTemp" << this->PVSource->GetVTKSourceID(0) - << " GetProperty " << this->SetCommand << "] SetElements1 " - << this->Property->GetScalar(0) << endl; -} - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::AcceptInternal(vtkClientServerID sourceID) -{ - if (this->ModifiedFlag) - { - this->Script("%s selection get", this->Tree->GetWidgetName()); - this->AddTraceEntry("$kw(%s) SetTimeValueCallback {%s}", - this->GetTclName(), - this->GetApplication()->GetMainInterp()->result); - } - - this->Property->SetVTKSourceID(sourceID); - this->Property->SetScalars(1, &this->TimeValue); - this->Property->AcceptInternal(); - - this->ModifiedFlag = 0; -} - -//--------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::Trace(ofstream *file) -{ - if ( ! this->InitializeTrace(file)) - { - return; - } - - this->Script("%s selection get", this->Tree->GetWidgetName()); - *file << "$kw(" << this->GetTclName() << ") SetTimeValueCallback {" - << this->GetApplication()->GetMainInterp()->result << "}" << endl; -} - - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::ResetInternal() -{ - if ( ! this->ModifiedFlag) - { - return; - } - - // Command to update the UI. - if (!this->Tree) - { - return; - } - - this->Script("%s delete [%s nodes root]", this->Tree->GetWidgetName(), - this->Tree->GetWidgetName()); - - this->SetTimeSetsFromReader(); - - int timeSetId=0; - char timeSetName[32]; - char timeSetText[32]; - - char timeValueName[32]; - char timeValueText[32]; - char indices[32]; - - float actualTimeValue = this->Property->GetScalar(0); - int matchFound = 0; - - this->ModifiedFlag = 0; - - if (this->TimeSets->GetNumberOfItems() == 0) - { - this->Script("pack forget %s", this->TreeFrame->GetWidgetName()); - this->TimeLabel->SetLabel("No timesets available."); - return; - } - else - { - this->SetTimeValue(actualTimeValue); - this->Script("pack %s -expand t -fill x", this->TreeFrame->GetWidgetName()); - } - - this->TimeSets->InitTraversal(); - vtkDataArray* da; - while( (da=this->TimeSets->GetNextItem()) ) - { - timeSetId++; - sprintf(timeSetName,"timeset%d", timeSetId); - sprintf(timeSetText,"Time Set %d", timeSetId); - this->AddRootNode(timeSetName, timeSetText); - - vtkIdType tuple; - for(tuple=0; tuple<da->GetNumberOfTuples(); tuple++) - { - float timeValue = da->GetTuple1(tuple); - sprintf(timeValueName, "time%d_%-12.5e", timeSetId, timeValue); - sprintf(timeValueText, "%-12.5e", timeValue); - ostrstream str; - str << "{" << timeSetId-1 << " " << tuple << "}" << ends; - sprintf(indices, "%s", str.str()); - str.rdbuf()->freeze(0); - this->AddChildNode(timeSetName, timeValueName, timeValueText, indices); - if (actualTimeValue == timeValue && !matchFound) - { - matchFound=1; - this->Script("%s selection set %s", this->Tree->GetWidgetName(), - timeValueName); - } - } - if (timeSetId == 1) - { - this->Script("%s opentree %s", this->Tree->GetWidgetName(), - timeSetName); - } - } - - this->SetTimeValue(actualTimeValue); -} - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::AddAnimationScriptsToMenu(vtkKWMenu *menu, - vtkPVAnimationInterfaceEntry *ai) -{ - char methodAndArgs[500]; - - sprintf(methodAndArgs, "AnimationMenuCallback %s", ai->GetTclName()); - // I do not under stand why the trace name is used for the - // menu entry, but Berk must know. - menu->AddCommand(this->GetTraceName(), this, methodAndArgs, 0, ""); -} - - -//----------------------------------------------------------------------------- -// What a pain. I need this method for tracing. -// Maybe the animation should call PVwidget methods and not vtk object methods. -void vtkPVFoamSelectTimeSet::AnimationMenuCallback(vtkPVAnimationInterfaceEntry *ai) -{ - if (ai->InitializeTrace(NULL)) - { - this->AddTraceEntry("$kw(%s) AnimationMenuCallback $kw(%s)", - this->GetTclName(), ai->GetTclName()); - } - - // I do not under stand why the trace name is used for the - // menu entry, but Berk must know. - ai->SetLabelAndScript(this->GetTraceName(), NULL, this->GetTraceName()); - ai->SetCurrentProperty(this->Property); - ai->Update(); -} - - - -//----------------------------------------------------------------------------- -vtkPVFoamSelectTimeSet* vtkPVFoamSelectTimeSet::ClonePrototype(vtkPVSource* pvSource, - vtkArrayMap<vtkPVWidget*, vtkPVWidget*>* map) -{ - vtkPVWidget* clone = this->ClonePrototypeInternal(pvSource, map); - return vtkPVFoamSelectTimeSet::SafeDownCast(clone); -} - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::CopyProperties(vtkPVWidget* clone, - vtkPVSource* pvSource, - vtkArrayMap<vtkPVWidget*, vtkPVWidget*>* map) -{ - this->Superclass::CopyProperties(clone, pvSource, map); - vtkPVFoamSelectTimeSet* pvts = vtkPVFoamSelectTimeSet::SafeDownCast(clone); - if (pvts) - { - pvts->SetLabel(this->FrameLabel); - pvts->SetSetCommand(this->SetCommand); - } - else - { - vtkErrorMacro( - "Internal error. Could not downcast clone to PVFoamSelectTimeSet."); - } -} - -//----------------------------------------------------------------------------- -int vtkPVFoamSelectTimeSet::ReadXMLAttributes(vtkPVXMLElement* element, - vtkPVXMLPackageParser* parser) -{ - if(!this->Superclass::ReadXMLAttributes(element, parser)) { return 0; } - - // Setup the Label. - const char* label = element->GetAttribute("label"); - if(label) - { - this->SetLabel(label); - } - - this->SetSetCommand(element->GetAttribute("set_command")); - - return 1; -} - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::SetTimeSetsFromReader() -{ - vtkPVProcessModule* pm = this->GetPVApplication()->GetProcessModule(); - this->TimeSets->RemoveAllItems(); - - // Create the server-side helper if necessary. - if(!this->ServerSideID.ID) - { - this->ServerSideID = pm->NewStreamObject("vtkPVFoamServerSelectTimeSet"); - pm->SendStream(vtkProcessModule::DATA_SERVER); - } - - // Get the time sets from the reader on the server. - // Reader -> VTKSourceID (0). We assume that there is 1 VTKSource. - pm->GetStream() << vtkClientServerStream::Invoke - << this->ServerSideID << "GetTimeSets" - << this->PVSource->GetVTKSourceID(0) - << vtkClientServerStream::End; - pm->SendStream(vtkProcessModule::DATA_SERVER_ROOT); - vtkClientServerStream timeSets; - if(!pm->GetLastServerResult().GetArgument(0, 0, &timeSets)) - { - vtkErrorMacro("Error getting time sets from server."); - return; - } - - // There is one time set per message. - for(int m=0; m < timeSets.GetNumberOfMessages(); ++m) - { - // Each argument in the message is a time set entry. - vtkFloatArray* timeSet = vtkFloatArray::New(); - int n = timeSets.GetNumberOfArguments(m); - timeSet->SetNumberOfTuples(n); - for(int i=0; i < n; ++i) - { - float value; - if(!timeSets.GetArgument(m, i, &value)) - { - vtkErrorMacro("Error reading time set value."); - timeSet->Delete(); - return; - } - timeSet->SetTuple1(i, value); - } - this->TimeSets->AddItem(timeSet); - timeSet->Delete(); - } - - if (this->Property->GetNumberOfScalars() == 0 && - this->TimeSets->GetNumberOfItems() > 0) - { - vtkFloatArray *ts = - vtkFloatArray::SafeDownCast(this->TimeSets->GetItem(0)); - this->Property->SetScalars(1, ts->GetPointer(0)); - } -} - -//---------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::SaveInBatchScriptForPart(ofstream *file, - vtkClientServerID sourceID) -{ - if (sourceID.ID == 0) - { - vtkErrorMacro(<< this->GetClassName() - << " must not have SaveInBatchScript method."); - return; - } - - *file << "\t" << "pvTemp" << sourceID - << " SetTimeValue " << this->GetTimeValue() - << endl;; -} - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::SetProperty(vtkPVWidgetProperty *prop) -{ - this->Property = vtkPVScalarListWidgetProperty::SafeDownCast(prop); - if (this->Property) - { - int numScalars = 1; - this->Property->SetVTKCommands(1, &this->SetCommand, &numScalars); - } -} - -//----------------------------------------------------------------------------- -vtkPVWidgetProperty* vtkPVFoamSelectTimeSet::GetProperty() -{ - return this->Property; -} - -//----------------------------------------------------------------------------- -vtkPVWidgetProperty* vtkPVFoamSelectTimeSet::CreateAppropriateProperty() -{ - return vtkPVScalarListWidgetProperty::New(); -} - -//----------------------------------------------------------------------------- -void vtkPVFoamSelectTimeSet::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - os << indent << "TimeValue: " << this->TimeValue << endl; - os << indent << "LabeledFrame: " << this->LabeledFrame << endl; - os << indent << "SetCommand: " - << (this->SetCommand ? this->SetCommand : "(none)") << endl; -} diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.h b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.h deleted file mode 100644 index 70ab8cc97fb2393529cc2424cefb7f36fa1206ec..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.h +++ /dev/null @@ -1,164 +0,0 @@ -/*========================================================================= - - Program: ParaView - Module: $RCSfile: vtkPVFoamSelectTimeSet.h,v $ - - Copyright (c) Kitware, Inc. - All rights reserved. - See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -// .NAME vtkPVFoamSelectTimeSet - Special time selection widget used by PVFoamReaderModule -// .SECTION Description -// This is a PVWidget specially designed to be used with PVFoamReaderModule. -// It provides support for multiple sets. The time value selected by -// the user is passed to the Foam reader with a SetTimeValue() call. - -#ifndef __vtkPVFoamSelectTimeSet_h -#define __vtkPVFoamSelectTimeSet_h - -#include "vtkPVWidget.h" - -class vtkKWLabel; -class vtkKWMenu; -class vtkKWLabeledFrame; -class vtkDataArrayCollection; -class vtkPVScalarListWidgetProperty; - -class VTK_EXPORT vtkPVFoamSelectTimeSet : public vtkPVWidget -{ -public: - static vtkPVFoamSelectTimeSet* New(); - vtkTypeRevisionMacro(vtkPVFoamSelectTimeSet, vtkPVWidget); - void PrintSelf(ostream& os, vtkIndent indent); - - virtual void Create(vtkKWApplication *pvApp); - - //BTX - // Description: - // Called when accept button is pushed. - // Sets objects variable to the widgets value. - // Adds a trace entry. Side effect is to turn modified flag off. - virtual void AcceptInternal(vtkClientServerID); - //ETX - - // Description: - // Called when the reset button is pushed. - // Sets widget's value to the object-variable's value. - // Side effect is to turn the modified flag off. - virtual void ResetInternal(); - - // Description: - // Adds a script to the menu of the animation interface. - virtual void AddAnimationScriptsToMenu(vtkKWMenu *menu, - vtkPVAnimationInterfaceEntry *ai); - - // Description: - // Called whenthe animation method menu item is selected. - // Needed for proper tracing. - // It would be nice if the menu and cascade menus would trace - // invokation of items (?relying of enumeration of menu items or label?) - void AnimationMenuCallback(vtkPVAnimationInterfaceEntry *ai); - - // Description: - // This is the labeled frame around the timeset tree. - vtkGetObjectMacro(LabeledFrame, vtkKWLabeledFrame); - - // Description: - // Label displayed on the labeled frame. - void SetLabel(const char* label); - const char* GetLabel(); - - // Description: - // Updates the time value label and the time ivar. - void SetTimeValue(float time); - vtkGetMacro(TimeValue, float); - - // Description: - // Calls this->SetTimeValue () and Reader->SetTimeValue() - // with currently selected time value. - void SetTimeValueCallback(const char* item); - -//BTX - // Description: - // Creates and returns a copy of this widget. It will create - // a new instance of the same type as the current object - // using NewInstance() and then copy some necessary state - // parameters. - vtkPVFoamSelectTimeSet* ClonePrototype(vtkPVSource* pvSource, - vtkArrayMap<vtkPVWidget*, vtkPVWidget*>* map); -//ETX - - // Description: - // This serves a dual purpose. For tracing and for saving state. - virtual void Trace(ofstream *file); - - // Description: - // Set/get the property to use with this widget. - virtual void SetProperty(vtkPVWidgetProperty *prop); - virtual vtkPVWidgetProperty* GetProperty(); - - // Description: - // Create the right property for use with this widget. - virtual vtkPVWidgetProperty* CreateAppropriateProperty(); - - // Description: - // Set/get the command to pass the value to VTK. - vtkSetStringMacro(SetCommand); - vtkGetStringMacro(SetCommand); - - // Description: - // Save this widget to a file. - virtual void SaveInBatchScript(ofstream *file); - -protected: - vtkPVFoamSelectTimeSet(); - ~vtkPVFoamSelectTimeSet(); - - vtkPVFoamSelectTimeSet(const vtkPVFoamSelectTimeSet&); // Not implemented - void operator=(const vtkPVFoamSelectTimeSet&); // Not implemented - - vtkPVScalarListWidgetProperty *Property; - - char *SetCommand; - - vtkSetStringMacro(FrameLabel); - vtkGetStringMacro(FrameLabel); - - vtkKWWidget* Tree; - vtkKWWidget* TreeFrame; - vtkKWLabel* TimeLabel; - vtkKWLabeledFrame* LabeledFrame; - - void AddRootNode(const char* name, const char* text); - void AddChildNode(const char* parent, const char* name, - const char* text, const char* data); - - float TimeValue; - char* FrameLabel; - - vtkDataArrayCollection* TimeSets; - vtkClientServerID ServerSideID; - - // Fill the TimeSets collection with that from the actual reader. - void SetTimeSetsFromReader(); - -//BTX - virtual void CopyProperties(vtkPVWidget* clone, vtkPVSource* pvSource, - vtkArrayMap<vtkPVWidget*, vtkPVWidget*>* map); -//ETX - - int ReadXMLAttributes(vtkPVXMLElement* element, - vtkPVXMLPackageParser* parser); - - // Description: - // An interface for saving a widget into a script. - virtual void SaveInBatchScriptForPart(ofstream *file, vtkClientServerID); - -}; - -#endif diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.cxx b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.cxx deleted file mode 100644 index acfce9bab2bbb6587c5a7303c703f0120bfd23fc..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.cxx +++ /dev/null @@ -1,85 +0,0 @@ -/*========================================================================= - - Program: ParaView - Module: $RCSfile: vtkPVFoamServerSelectTimeSet.cxx,v $ - - Copyright (c) Kitware, Inc. - All rights reserved. - See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -#include "vtkPVFoamServerSelectTimeSet.h" - -#include "vtkClientServerInterpreter.h" -#include "vtkObjectFactory.h" -#include "vtkPVProcessModule.h" -#include "vtkFoamReader.h" -#include "vtkDataArrayCollection.h" -#include "vtkDataArrayCollectionIterator.h" -#include "vtkClientServerStream.h" - -#include <vtkstd/string> - -//---------------------------------------------------------------------------- -vtkStandardNewMacro(vtkPVFoamServerSelectTimeSet); -vtkCxxRevisionMacro(vtkPVFoamServerSelectTimeSet, "$Revision: 1.4 $"); - -//---------------------------------------------------------------------------- -class vtkPVFoamServerSelectTimeSetInternals -{ -public: - vtkClientServerStream Result; -}; - -//---------------------------------------------------------------------------- -vtkPVFoamServerSelectTimeSet::vtkPVFoamServerSelectTimeSet() -{ - this->Internal = new vtkPVFoamServerSelectTimeSetInternals; -} - -//---------------------------------------------------------------------------- -vtkPVFoamServerSelectTimeSet::~vtkPVFoamServerSelectTimeSet() -{ - delete this->Internal; -} - -//---------------------------------------------------------------------------- -void vtkPVFoamServerSelectTimeSet::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); -} - -//---------------------------------------------------------------------------- -const vtkClientServerStream& -vtkPVFoamServerSelectTimeSet::GetTimeSets(vtkFoamReader* reader) -{ - // Reset the stream for a new list of time sets. - this->Internal->Result.Reset(); - - // Get the time sets from the reader. - vtkDataArrayCollection* timeSets = reader->GetTimeSets(); - - // Iterate through the time sets. - vtkDataArrayCollectionIterator* iter = vtkDataArrayCollectionIterator::New(); - iter->SetCollection(timeSets); - for(iter->GoToFirstItem(); !iter->IsDoneWithTraversal(); - iter->GoToNextItem()) - { - // Each time set is stored in one message. - this->Internal->Result << vtkClientServerStream::Reply; - vtkDataArray* da = iter->GetDataArray(); - for(int i=0; i < da->GetNumberOfTuples(); ++i) - { - this->Internal->Result << da->GetTuple1(i); - } - this->Internal->Result << vtkClientServerStream::End; - } - iter->Delete(); - - // Return the stream. - return this->Internal->Result; -} diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.h b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.h deleted file mode 100644 index 99f755c9f39651decfd8be7cf684bbd6bc3d89e4..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.h +++ /dev/null @@ -1,49 +0,0 @@ -/*========================================================================= - - Program: ParaView - Module: $RCSfile: vtkPVFoamServerSelectTimeSet.h,v $ - - Copyright (c) Kitware, Inc. - All rights reserved. - See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -// .NAME vtkPVFoamServerSelectTimeSet - Server-side helper for vtkPVFoamSelectTimeSet. -// .SECTION Description - -#ifndef __vtkPVFoamServerSelectTimeSet_h -#define __vtkPVFoamServerSelectTimeSet_h - -#include "vtkPVServerObject.h" - -class vtkClientServerStream; -class vtkPVFoamServerSelectTimeSetInternals; -class vtkFoamReader; - -class VTK_EXPORT vtkPVFoamServerSelectTimeSet : public vtkPVServerObject -{ -public: - static vtkPVFoamServerSelectTimeSet* New(); - vtkTypeRevisionMacro(vtkPVFoamServerSelectTimeSet, vtkPVServerObject); - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // Get a list the time sets provided by the given reader. - const vtkClientServerStream& GetTimeSets(vtkFoamReader*); - -protected: - vtkPVFoamServerSelectTimeSet(); - ~vtkPVFoamServerSelectTimeSet(); - - // Internal implementation details. - vtkPVFoamServerSelectTimeSetInternals* Internal; -private: - vtkPVFoamServerSelectTimeSet(const vtkPVFoamServerSelectTimeSet&); // Not implemented - void operator=(const vtkPVFoamServerSelectTimeSet&); // Not implemented -}; - -#endif diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/Make/files b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/Make/files deleted file mode 100644 index f5a5526caa156bc2135854331db70929d286caf8..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/Make/files +++ /dev/null @@ -1,5 +0,0 @@ -vtkFoam.C -vtkFoamAddInternalMesh.C -vtkFoamAddPatch.C - -LIB = $(FOAM_LIBBIN)/libvtkFoam diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/Make/options b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/Make/options deleted file mode 100644 index 7dd2c76c8b3f0e89a1192f4cdf48e988b7b66e35..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/Make/options +++ /dev/null @@ -1,9 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(ParaView_INST_DIR)/include \ - -I../PVFoamReader - -LIB_LIBS = \ - -lfiniteVolume \ - -lgenericPatchFields \ - $(GLIBS) diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkDataArrayTemplateImplicit.txx b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkDataArrayTemplateImplicit.txx deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoam.C b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoam.C deleted file mode 100644 index 6a1830b5d14dd60a851496247830f9a6942c983c..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoam.C +++ /dev/null @@ -1,665 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 - -\*---------------------------------------------------------------------------*/ - -#include "vtkFoam.H" - -#include "argList.H" -#include "Time.H" -#include "polyBoundaryMeshEntries.H" -#include "IOobjectList.H" -#include "wordList.H" -#include "fvMesh.H" -#include "volFields.H" -#include "pointMesh.H" -#include "volPointInterpolation.H" - -#include "vtkFoamReader.h" -#include "vtkDataArraySelection.h" -#include "vtkUnstructuredGrid.h" -#include "vtkPointData.h" -#include "vtkCellData.h" -#include "vtkFloatArray.h" -#include "vtkCharArray.h" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -defineTypeNameAndDebug(Foam::vtkFoam, 0); - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -#include "vtkFoamConvertFields.H" - -void Foam::vtkFoam::SetName -( - vtkUnstructuredGrid* vtkMesh, - const char* name -) -{ - vtkCharArray* nmArray = vtkCharArray::New(); - nmArray->SetName("Name"); - size_t len = strlen(name); - nmArray->SetNumberOfTuples(static_cast<vtkIdType>(len)+1); - char* copy = nmArray->GetPointer(0); - memcpy(copy, name, len); - copy[len] = '\0'; - vtkMesh->GetFieldData()->AddArray(nmArray); - nmArray->Delete(); -} - - -Foam::string Foam::vtkFoam::padTimeString(const string& ts) -{ - return ts + string(" ", max(label(12 - ts.size()), 0)); -} - - -// Pad the patch name string in order to account for dynamic changes -// in patch names during topological changes -Foam::string Foam::vtkFoam::padPatchString(const string& ps) -{ - label n = max(label(50 - ps.size()), 0); - return ps + string(" ", n); -} - - -void Foam::vtkFoam::setSelectedTime -( - Time& runTime, - vtkFoamReader* reader -) -{ - // Get times list - instantList Times = runTime.times(); - int timeIndex = min(max(reader->GetTimeStep() + 1, 0), Times.size()-1); - - // If this is the first call timeIndex will be 0 ("constant") - // so reset to the first time step if one exists and deselect every - // element of the selection array - if (timeIndex == 0) - { - timeIndex = min(1, Times.size()-1); - reader->GetTimeSelection()->DisableAllArrays(); - } - - label selectedTimeIndex = -1; - label nSelectedTimes = reader->GetTimeSelection()->GetNumberOfArrays(); - - for (label i=nSelectedTimes-1; i>=0; i--) - { - if(reader->GetTimeSelection()->GetArraySetting(i)) - { - word timeName = string::validate<word> - ( - reader->GetTimeSelection()->GetArrayName(i) - ); - - forAll(Times, j) - { - if (Times[j].name() == timeName) - { - selectedTimeIndex = j; - break; - } - } - break; - } - } - - if (selectedTimeIndex != -1) - { - timeIndex = min(selectedTimeIndex, Times.size()-1); - } - - if (debug) - { - Info<< "Selecting time " << Times[timeIndex].name() << endl; - } - - runTime.setTime(Times[timeIndex], timeIndex); - - Times = runTime.times(); - - reader->SetTimeStepRange(0, max(Times.size()-2, 0)); - - // reset the time steps ... - reader->GetTimeSelection()->RemoveAllArrays(); - - int* TimeStepLimits = reader->GetTimeStepLimits(); - label maxStartTimes = min(Times.size(), TimeStepLimits[0]); - label maxNTimes = min(Times.size() - maxStartTimes, TimeStepLimits[1]); - - for (label i=0; i<maxStartTimes; i++) - { - reader->GetTimeSelection() - ->AddArray(padTimeString(Times[i].name()).c_str()); - } - - if (Times.size() > TimeStepLimits[0] + TimeStepLimits[1]) - { - reader->GetTimeSelection()->AddArray(padTimeString("...").c_str()); - } - - for (label i=Times.size() - maxNTimes; i<Times.size(); i++) - { - reader->GetTimeSelection() - ->AddArray(padTimeString(Times[i].name()).c_str()); - } - - // Disable all the time selections (which are all selected by default) ... - reader->GetTimeSelection()->DisableAllArrays(); - - // But maintain the selections made previously - if (selectedTimeIndex != -1 && selectedTimeIndex < Times.size()) - { - reader->GetTimeSelection()->EnableArray - (padTimeString(Times[selectedTimeIndex].name()).c_str()); - } -} - - -void Foam::vtkFoam::updateSelectedRegions() -{ - if (debug) - { - Info<< "Foam::vtkFoam::updateSelectedRegions()" << endl; - } - - label nRegions = reader_->GetRegionSelection()->GetNumberOfArrays(); - - selectedRegions_.setSize(nRegions); - - // Read the selected patches and add to the region list - for (int i=0; i<nRegions; i++) - { - selectedRegions_[i] = - reader_->GetRegionSelection()->GetArraySetting(i); - } -} - - -void Foam::vtkFoam::convertMesh() -{ - if (debug) - { - Info<< "Foam::vtkFoam::convertMesh()" << endl; - } - - const fvMesh& mesh = *meshPtr_; - - // Read the internal mesh as region 0 if selected - if (reader_->GetRegionSelection()->GetArraySetting(0)) - { - selectedRegions_[0] = true; - addInternalMesh - ( - mesh, - vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0)) - ); - } - else - { - selectedRegions_[0] = false; - - vtkUnstructuredGrid *vtkMesh = - vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0)); - - vtkMesh->Initialize(); - SetName(vtkMesh, "(Internal Mesh)"); - } - - - // Read the selected patches and add to the region list - - polyBoundaryMeshEntries patchEntries - ( - IOobject - ( - "boundary", - dbPtr_().findInstance(polyMesh::meshSubDir, "boundary"), - polyMesh::meshSubDir, - dbPtr_(), - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); - - label regioni = 0; - label regioniLast = 0; - - // Read in the number Outputs (patch regions) currently being used - label currNOutputs = reader_->GetNumberOfOutputs(); - - // Cycle through all the patches in the boundary file for the relevant - // time step - forAll(patchEntries, entryi) - { - // Number of faces in the current patch (Used to detect dummy patches - // of size zero) - label nFaces(readLabel(patchEntries[entryi].dict().lookup("nFaces"))); - - // Check to see if the patch is currently a part of the displayed list - if - ( - reader_->GetRegionSelection()->ArrayExists - ( - padPatchString(patchEntries[entryi].keyword()).c_str() - ) - ) - { - if (!nFaces) - { - // Remove patch if it is only a dummy patch in the current - // time step with zero faces - reader_->GetRegionSelection()->RemoveArrayByName - ( - padPatchString(patchEntries[entryi].keyword()).c_str() - ); - } - else - { - // A patch already existent in the list and which - // continues to exist found - regioni++; - } - } - else - { - // A new patch so far not yet included into the list has been found - if (nFaces) - { - regioni++; - - // Add a new entry to the list of regions - reader_->GetRegionSelection()->AddArray - ( - padPatchString(patchEntries[entryi].keyword()).c_str() - ); - - // AddArray automatically enables a new array... disable - // it manually - reader_->GetRegionSelection()->DisableArray - ( - padPatchString(patchEntries[entryi].keyword()).c_str() - ); - } - } - - // Avoid Initialization of the same Output twice - if (regioni != regioniLast) - { - // Only setup an Output if it has not been setup before - if(regioni >= currNOutputs) - { - vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New(); - reader_->SetNthOutput(regioni,ugrid); - ugrid->Delete(); - } - // Initialize -> Delete memory used, and reset to zero state - reader_->GetOutput(regioni)->Initialize(); - regioniLast = regioni; - } - } - - // Initialize (reset to zero and free) any outputs which are not used - // anymore - if (regioni < currNOutputs) - { - for(label i = (regioni+1); i < currNOutputs;i++) - { - reader_->GetOutput(i)->Initialize(); - } - } - - selectedRegions_.setSize(regioni + 1); - - regioni = 0; - - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - forAll (patches, patchi) - { - if (patches[patchi].size()) - { - regioni++; - - if (reader_->GetRegionSelection()->GetArraySetting(regioni)) - { - selectedRegions_[regioni] = true; - addPatch - ( - patches[patchi], - vtkUnstructuredGrid::SafeDownCast - ( - reader_->GetOutput(regioni) - ) - ); - } - else - { - selectedRegions_[regioni] = false; - - vtkUnstructuredGrid *vtkMesh = - vtkUnstructuredGrid::SafeDownCast - ( - reader_->GetOutput(regioni) - ); - - vtkMesh->Initialize(); - SetName - ( - vtkMesh, - ('(' + padPatchString(patches[patchi].name()) + ')').c_str() - ); - } - } - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::vtkFoam::vtkFoam(const char* const FileName, vtkFoamReader* reader) -: - reader_(reader), - argsPtr_(NULL), - dbPtr_(NULL), - meshPtr_(NULL) -{ - fileName fullCasePath(fileName(FileName).path()); - - if (!isDir(fullCasePath)) - { - return; - } - - char* argvStrings[3]; - argvStrings[0] = new char[9]; - strcpy(argvStrings[0], "/vtkFoam"); - argvStrings[1] = new char[6]; - strcpy(argvStrings[1], "-case"); - argvStrings[2] = new char[fullCasePath.size()+1]; - strcpy(argvStrings[2], fullCasePath.c_str()); - - int argc = 3; - char** argv = &argvStrings[0]; - argsPtr_.reset(new argList(argc, argv)); - - for(int i = 0; i < argc; i++) - { - delete[] argvStrings[i]; - } - - dbPtr_.reset - ( - new Time - ( - Time::controlDictName, - argsPtr_().rootPath(), - argsPtr_().caseName() - ) - ); - dbPtr_().functionObjects().off(); - setSelectedTime(dbPtr_(), reader_); - - if (debug) - { - Info<< "vtkFoam::ExecuteInformation: Initialising outputs" << endl; - } - - reader_->GetRegionSelection()->AddArray("Internal Mesh"); - - vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New(); - reader_->SetNthOutput(0, ugrid); - ugrid->Delete(); - reader_->GetOutput(0)->Initialize(); - - polyBoundaryMeshEntries patchEntries - ( - IOobject - ( - "boundary", - dbPtr_().findInstance(polyMesh::meshSubDir, "boundary"), - polyMesh::meshSubDir, - dbPtr_(), - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); - - label regioni = 0; - forAll(patchEntries, entryi) - { - label nFaces(readLabel(patchEntries[entryi].dict().lookup("nFaces"))); - - if (nFaces) - { - regioni++; - - reader_->GetRegionSelection()->AddArray - ( - padPatchString(patchEntries[entryi].keyword()).c_str() - ); - - vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New(); - reader_->SetNthOutput(regioni, ugrid); - ugrid->Delete(); - reader_->GetOutput(regioni)->Initialize(); - } - } - - selectedRegions_.setSize(regioni + 1); - selectedRegions_ = true; - - UpdateInformation(); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::vtkFoam::~vtkFoam() -{ - // Do NOT delete meshPtr_ since still referenced somehow. -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -#include "vtkFoamAddFields.H" - -void Foam::vtkFoam::UpdateInformation() -{ - if (debug) - { - Info<< "TimeStep = " << reader_->GetTimeStep() << endl; - } - - setSelectedTime(dbPtr_(), reader_); - - // Search for list of objects for this time - IOobjectList objects(dbPtr_(), dbPtr_().timeName()); - - addFields<volScalarField>(reader_->GetVolFieldSelection(), objects); - addFields<volVectorField>(reader_->GetVolFieldSelection(), objects); - addFields<volSphericalTensorField>(reader_->GetVolFieldSelection(), objects); - addFields<volSymmTensorField>(reader_->GetVolFieldSelection(), objects); - addFields<volTensorField>(reader_->GetVolFieldSelection(), objects); - - addFields<pointScalarField>(reader_->GetPointFieldSelection(), objects); - addFields<pointVectorField>(reader_->GetPointFieldSelection(), objects); - addFields<pointSphericalTensorField>(reader_->GetPointFieldSelection(), objects); - addFields<pointSymmTensorField>(reader_->GetPointFieldSelection(), objects); - addFields<pointTensorField>(reader_->GetPointFieldSelection(), objects); -} - - -void Foam::vtkFoam::Update() -{ - if - ( - !reader_->GetCacheMesh() - || reader_->GetTimeSelection()->GetArraySetting(0) - ) - { - meshPtr_= NULL; - } - - // Clear the current set of selected fields - - for (label i=0; i<reader_->GetNumberOfOutputs(); i++) - { - vtkUnstructuredGrid *vtkMesh = - vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(i)); - - vtkCellData* cellData = vtkMesh->GetCellData(); - int numberOfCellArrays = cellData->GetNumberOfArrays(); - - wordList cellFieldNames(numberOfCellArrays); - for (int j=0; j<numberOfCellArrays; j++) - { - cellFieldNames[j] = cellData->GetArrayName(j); - } - - for (int j=0; j<numberOfCellArrays; j++) - { - cellData->RemoveArray(cellFieldNames[j].c_str()); - } - - vtkPointData* pointData = vtkMesh->GetPointData(); - int numberOfPointArrays = pointData->GetNumberOfArrays(); - - wordList pointFieldNames(numberOfPointArrays); - for (int j=0; j<numberOfPointArrays; j++) - { - pointFieldNames[j] = pointData->GetArrayName(j); - } - - for (int j=0; j<numberOfPointArrays; j++) - { - pointData->RemoveArray(pointFieldNames[j].c_str()); - } - } - - // Check to see if the mesh has been created - - if (!meshPtr_) - { - if (debug) - { - Info<< "Reading Mesh" << endl; - } - meshPtr_ = - new fvMesh - ( - IOobject - ( - fvMesh::defaultRegion, - dbPtr_().timeName(), - dbPtr_() - ) - ); - convertMesh(); - } - else - { - boolList oldSelectedRegions = selectedRegions_; - updateSelectedRegions(); - if - ( - meshPtr_->readUpdate() != fvMesh::UNCHANGED - || oldSelectedRegions != selectedRegions_ - ) - { - convertMesh(); - } - } - - if (debug) - { - Info<< "converting fields" << endl; - } - - const fvMesh& mesh = *meshPtr_; - - // Construct interpolation on the raw mesh - Foam::pointMesh pMesh(mesh); - - Foam::volPointInterpolation pInterp(mesh, pMesh); - - // Search for list of objects for this time - Foam::IOobjectList objects(mesh, dbPtr_().timeName()); - - convertVolFields<Foam::scalar> - ( - mesh, pInterp, objects, reader_->GetVolFieldSelection() - ); - convertVolFields<Foam::vector> - ( - mesh, pInterp, objects, reader_->GetVolFieldSelection() - ); - convertVolFields<Foam::sphericalTensor> - ( - mesh, pInterp, objects, reader_->GetVolFieldSelection() - ); - convertVolFields<Foam::symmTensor> - ( - mesh, pInterp, objects, reader_->GetVolFieldSelection() - ); - convertVolFields<Foam::tensor> - ( - mesh, pInterp, objects, reader_->GetVolFieldSelection() - ); - - convertPointFields<Foam::scalar> - ( - mesh, objects, reader_->GetPointFieldSelection() - ); - convertPointFields<Foam::vector> - ( - mesh, objects, reader_->GetPointFieldSelection() - ); - convertPointFields<Foam::sphericalTensor> - ( - mesh, objects, reader_->GetPointFieldSelection() - ); - convertPointFields<Foam::symmTensor> - ( - mesh, objects, reader_->GetPointFieldSelection() - ); - convertPointFields<Foam::tensor> - ( - mesh, objects, reader_->GetPointFieldSelection() - ); - - if (debug) - { - Info<< "done" << endl; - } -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoam.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoam.H deleted file mode 100644 index baca6a38637d2e7172a025eb842796b97985297d..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoam.H +++ /dev/null @@ -1,256 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 - Foam::vtkFoam - -Description - -SourceFiles - vtkFoam.C - vtkFoamInsertNextPoint.H - vtkFoamAddFields.H - vtkFoamAddInternalMesh.H - vtkFoamConvertFields.H - vtkFoamConvertVolField.H - vtkFoamConvertPatchFaceField.H - vtkFoamConvertPointField.H - vtkFoamConvertPatchPointField.H - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkFoam_H -#define vtkFoam_H - -#include "className.H" -#include "fileName.H" -#include "volPointInterpolation.H" - -// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // - -// VTK class forward declarations -class vtkFoamReader; -class vtkUnstructuredGrid; -class vtkPoints; -class vtkDataArraySelection; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// Foam class forward declarations -class argList; -class Time; -class fvMesh; -class IOobjectList; -class polyPatch; - - -/*---------------------------------------------------------------------------*\ - Class vtkFoam Declaration -\*---------------------------------------------------------------------------*/ - -class vtkFoam -{ - // Private data - - //- Access to the controlling vtkFoamReader - vtkFoamReader *reader_; - - autoPtr<argList> argsPtr_; - autoPtr<Time> dbPtr_; - fvMesh* meshPtr_; - - //- Selected regions, [0] = internal mesh, [1-nPatches] = patches - boolList selectedRegions_; - - //- Lables of cell-centres used as additional points when decomposing - // polyhedra - labelList addPointCellLabels_; - - //- Label of original cell the decomposed cells are split from - labelList superCells_; - - - // Private Member Functions - - //- Pad-out the time name to avoid bug in the GUI redraw - static string padTimeString(const string&); - - //- Pad-out the patch name - static string padPatchString(const string&); - - //- Find and set the selected time from all the methods of selection - static void setSelectedTime - ( - Time& runTime, - vtkFoamReader* reader - ); - - //- Update the selected regions - void updateSelectedRegions(); - - //- Convert the mesh according to the list of selected regions - void convertMesh(); - - //- Add the internal mesh to the set of Outputs if selected - void addInternalMesh(const fvMesh&, vtkUnstructuredGrid*); - - //- Add the internal patch to the set of Outputs if selected - void addPatch(const polyPatch&, vtkUnstructuredGrid*); - - //- Add the fields in th selested time directory to the selection lists - template<class GeoField> - void addFields - ( - vtkDataArraySelection *fieldSelection, - const IOobjectList& objects - ); - - //- Convert the selected volFields - template<class Type> - void convertVolFields - ( - const fvMesh& mesh, - const volPointInterpolation& pInterp, - const IOobjectList& objects, - vtkDataArraySelection *fieldSelection - ); - - template<class Type> - void convertVolField - ( - const GeometricField<Type, fvPatchField, volMesh>& tf - ); - - template<class Type> - void convertPatchFaceField - ( - const word& name, - const Field<Type>& tf, - const label regioni - ); - - //- Convert the selected pointFields - template<class Type> - void convertPointFields - ( - const fvMesh& mesh, - const IOobjectList& objects, - vtkDataArraySelection *fieldSelection - ); - - template<class Type> - void convertPointField - ( - const GeometricField<Type, pointPatchField, pointMesh>& ptf, - const GeometricField<Type, fvPatchField, volMesh>& tf - ); - - template<class Type> - void convertPatchPointField - ( - const word& name, - const Field<Type>& tf, - const label regioni - ); - - //- Set the name of the Output vtkUnstructuredGrid - void SetName(vtkUnstructuredGrid *vtkMesh, const char* name); - - - //- Disallow default bitwise copy construct - vtkFoam(const vtkFoam&); - - //- Disallow default bitwise assignment - void operator=(const vtkFoam&); - - -public: - - // Static data members - - ClassName("vtkFoam"); - - - // Constructors - - //- Construct from components - vtkFoam(const char* const FileName, vtkFoamReader* reader); - - - // Destructor - - ~vtkFoam(); - - - // Member Functions - - void UpdateInformation(); - void Update(); -}; - - -// * * * * * * * * * * * * * Template Specialisations * * * * * * * * * * * // - -template<> -void vtkFoam::convertVolField -( - const GeometricField<scalar, fvPatchField, volMesh>& sf -); - -template<> -void vtkFoam::convertPatchFaceField -( - const word& name, - const Field<scalar>& sf, - const label regioni -); - -template<> -void vtkFoam::convertPointField -( - const GeometricField<scalar, pointPatchField, pointMesh>& psf, - const GeometricField<scalar, fvPatchField, volMesh>& sf -); - -template<> -void vtkFoam::convertPatchPointField -( - const word& name, - const Field<scalar>& sf, - const label regioni -); - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddInternalMesh.C b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddInternalMesh.C deleted file mode 100644 index aa818bb82796b7d62cd56d891332b8cacd72bdb9..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddInternalMesh.C +++ /dev/null @@ -1,299 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 - -Description - -\*---------------------------------------------------------------------------*/ - -#include "vtkFoam.H" -#include "fvMesh.H" -#include "cellModeller.H" - -#include "vtkUnstructuredGrid.h" -#include "vtkCellArray.h" - -#include "vtkFoamInsertNextPoint.H" - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::vtkFoam::addInternalMesh -( - const fvMesh& mesh, - vtkUnstructuredGrid* vtkMesh -) -{ - SetName(vtkMesh, "Internal Mesh"); - - // Number of additional points needed by the decomposition of polyhedra - label nAddPoints = 0; - - // Number of additional cells generated by the decomposition of polyhedra - label nAddCells = 0; - - const cellModel& tet = *(cellModeller::lookup("tet")); - const cellModel& pyr = *(cellModeller::lookup("pyr")); - const cellModel& prism = *(cellModeller::lookup("prism")); - const cellModel& wedge = *(cellModeller::lookup("wedge")); - const cellModel& tetWedge = *(cellModeller::lookup("tetWedge")); - const cellModel& hex = *(cellModeller::lookup("hex")); - - // Scan for cells which need to be decomposed and count additional points - // and cells - if (debug) - { - Info<< "building cell-shapes" << endl; - } - const cellShapeList& cellShapes = mesh.cellShapes(); - - if (debug) - { - Info<< "scanning" << endl; - } - - forAll(cellShapes, cellI) - { - const cellModel& model = cellShapes[cellI].model(); - - if - ( - model != hex - && model != wedge - && model != prism - && model != pyr - && model != tet - && model != tetWedge - ) - { - const cell& cFaces = mesh.cells()[cellI]; - - forAll(cFaces, cFaceI) - { - const face& f = mesh.faces()[cFaces[cFaceI]]; - - label nFacePoints = f.size(); - - label nQuads = (nFacePoints - 2)/2; - label nTris = (nFacePoints - 2)%2; - nAddCells += nQuads + nTris; - } - - nAddCells--; - nAddPoints++; - } - } - - // Set size of additional point addressing array - // (from added point to original cell) - addPointCellLabels_.setSize(nAddPoints); - - // Set size of additional cells mapping array - // (from added cell to original cell) - superCells_.setSize(mesh.nCells() + nAddCells); - - if (debug) - { - Info<< "converting points" << endl; - } - - // Convert Foam mesh vertices to VTK - vtkPoints *vtkpoints = vtkPoints::New(); - vtkpoints->Allocate(mesh.nPoints() + nAddPoints); - - const Foam::pointField& points = mesh.points(); - - forAll(points, i) - { - vtkFoamInsertNextPoint(vtkpoints, points[i]); - } - - if (debug) - { - Info<< "converting cells" << endl; - } - - vtkMesh->Allocate(mesh.nCells() + nAddCells); - - // Set counters for additional points and additional cells - label api = 0, aci = 0; - - forAll(cellShapes, celli) - { - const cellShape& cellShape = cellShapes[celli]; - const cellModel& cellModel = cellShape.model(); - - superCells_[aci++] = celli; - - if (cellModel == tet) - { - vtkMesh->InsertNextCell - ( - VTK_TETRA, - 4, - const_cast<int*>(cellShape.begin()) - ); - } - else if (cellModel == pyr) - { - vtkMesh->InsertNextCell - ( - VTK_PYRAMID, - 5, - const_cast<int*>(cellShape.begin()) - ); - } - else if (cellModel == prism) - { - vtkMesh->InsertNextCell - ( - VTK_WEDGE, - 6, - const_cast<int*>(cellShape.begin()) - ); - } - else if (cellModel == tetWedge) - { - // Treat as squeezed prism - - int vtkVerts[6]; - vtkVerts[0] = cellShape[0]; - vtkVerts[1] = cellShape[2]; - vtkVerts[2] = cellShape[1]; - vtkVerts[3] = cellShape[3]; - vtkVerts[4] = cellShape[4]; - vtkVerts[5] = cellShape[4]; - - vtkMesh->InsertNextCell(VTK_WEDGE, 6, vtkVerts); - } - else if (cellModel == wedge) - { - // Treat as squeezed hex - - int vtkVerts[8]; - vtkVerts[0] = cellShape[0]; - vtkVerts[1] = cellShape[1]; - vtkVerts[2] = cellShape[2]; - vtkVerts[3] = cellShape[2]; - vtkVerts[4] = cellShape[3]; - vtkVerts[5] = cellShape[4]; - vtkVerts[6] = cellShape[5]; - vtkVerts[7] = cellShape[6]; - - vtkMesh->InsertNextCell(VTK_HEXAHEDRON, 8, vtkVerts); - } - else if (cellModel == hex) - { - vtkMesh->InsertNextCell - ( - VTK_HEXAHEDRON, - 8, - const_cast<int*>(cellShape.begin()) - ); - } - else - { - // Polyhedral cell. Decompose into tets + prisms. - - // Mapping from additional point to cell - addPointCellLabels_[api] = celli; - - // Insert the new vertex from the cell-centre - label newVertexLabel = mesh.nPoints() + api; - vtkFoamInsertNextPoint(vtkpoints, mesh.C()[celli]); - - // Whether to insert cell in place of original or not. - bool substituteCell = true; - - const labelList& cFaces = mesh.cells()[celli]; - - forAll(cFaces, cFaceI) - { - const face& f = mesh.faces()[cFaces[cFaceI]]; - - label nFacePoints = f.size(); - - label nQuads = (nFacePoints - 2)/2; - label nTris = (nFacePoints - 2)%2; - - label qpi = 0; - - for (label quadi=0; quadi<nQuads; quadi++) - { - label thisCellI = -1; - - if (substituteCell) - { - thisCellI = celli; - substituteCell = false; - } - else - { - thisCellI = mesh.nCells() + aci; - superCells_[aci++] = celli; - } - - int addVtkVerts[5]; - addVtkVerts[0] = f[0]; - addVtkVerts[1] = f[qpi + 1]; - addVtkVerts[2] = f[qpi + 2]; - addVtkVerts[3] = f[qpi + 3]; - addVtkVerts[4] = newVertexLabel; - vtkMesh->InsertNextCell(VTK_PYRAMID, 5, addVtkVerts); - - qpi += 2; - } - - if (nTris) - { - label thisCellI = -1; - - if (substituteCell) - { - thisCellI = celli; - substituteCell = false; - } - else - { - thisCellI = mesh.nCells() + aci; - superCells_[aci++] = celli; - } - - int addVtkVerts[4]; - addVtkVerts[0] = f[0]; - addVtkVerts[1] = f[qpi + 1]; - addVtkVerts[2] = f[qpi + 2]; - addVtkVerts[3] = newVertexLabel; - vtkMesh->InsertNextCell(VTK_TETRA, 4, addVtkVerts); - } - } - - api++; - } - } - - vtkMesh->SetPoints(vtkpoints); - vtkpoints->Delete(); -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddPatch.C b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddPatch.C deleted file mode 100644 index 5db4f79555b30c5e3fd76b7802003ab3e09c674a..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddPatch.C +++ /dev/null @@ -1,115 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 - -Description - -\*---------------------------------------------------------------------------*/ - -#include "vtkFoam.H" -#include "polyPatch.H" - -#include "vtkUnstructuredGrid.h" -#include "vtkCellArray.h" - -#include "vtkFoamInsertNextPoint.H" - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::vtkFoam::addPatch -( - const polyPatch& p, - vtkUnstructuredGrid *vtkPatch -) -{ - if (debug) - { - Info<< "Adding patch " << p.name() << endl; - } - - SetName(vtkPatch, p.name().c_str()); - - if (debug) - { - Info<< "converting points" << endl; - } - - const Foam::pointField& points = p.localPoints(); - - // Convert Foam mesh vertices to VTK - vtkPoints *vtkpoints = vtkPoints::New(); - vtkpoints->Allocate(points.size()); - - forAll(points, i) - { - vtkFoamInsertNextPoint(vtkpoints, points[i]); - } - - if (debug) - { - Info<< "converting faces" << endl; - } - - const faceList& faces = p.localFaces(); - - vtkPatch->Allocate(faces.size()); - - forAll(faces, facei) - { - const face& f = faces[facei]; - - if (f.size() == 3) - { - vtkPatch->InsertNextCell - ( - VTK_TRIANGLE, - 3, - const_cast<int*>(f.begin()) - ); - } - else if (f.size() == 4) - { - vtkPatch->InsertNextCell - ( - VTK_QUAD, - 4, - const_cast<int*>(f.begin()) - ); - } - else - { - vtkPatch->InsertNextCell - ( - VTK_POLYGON, - f.size(), - const_cast<int*>(f.begin()) - ); - } - } - - vtkPatch->SetPoints(vtkpoints); - vtkpoints->Delete(); -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertFields.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertFields.H deleted file mode 100644 index 6ba4435d1afe6cf7191937bae428951c2bd90049..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertFields.H +++ /dev/null @@ -1,235 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 - -InClass - Foam::vtkFoam - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkFoamConvertFields_H -#define vtkFoamConvertFields_H - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "vtkFoamConvertVolField.H" -#include "vtkFoamConvertPointField.H" - -#include "vtkFoamConvertPatchFaceField.H" -#include "vtkFoamConvertPatchPointField.H" - -#include "emptyFvPatchField.H" - -template<class Type> -void Foam::vtkFoam::convertVolFields -( - const fvMesh& mesh, - const volPointInterpolation& pInterp, - const IOobjectList& objects, - vtkDataArraySelection *fieldSelection -) -{ - IOobjectList fieldObjects - ( - objects.lookupClass - ( - GeometricField<Type, fvPatchField, volMesh>::typeName - ) - ); - - label nSelectedFields = fieldSelection->GetNumberOfArrays(); - - for (label i=0; i<nSelectedFields; i++) - { - if(fieldSelection->GetArraySetting(i)) - { - word fieldName = fieldSelection->GetArrayName(i); - - if (fieldObjects.found(fieldName)) - { - GeometricField<Type, fvPatchField, volMesh> tf - ( - IOobject - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ - ), - mesh - ); - - tmp<GeometricField<Type, pointPatchField, pointMesh> > tptf - ( - pInterp.interpolate(tf) - ); - - if (selectedRegions_[0]) - { - convertVolField(tf); - convertPointField(tptf(), tf); - } - - label regioni = 0; - forAll (mesh.boundaryMesh(), patchi) - { - if (mesh.boundaryMesh()[patchi].size()) - { - regioni++; - - if (selectedRegions_[regioni]) - { - const fvPatchField<Type>& ptf - ( - tf.boundaryField()[patchi] - ); - - if (!isType<emptyFvPatchField<Type> >(ptf)) - { - convertPatchFaceField - ( - tf.name(), - ptf, - regioni - ); - - convertPatchPointField - ( - tptf().name(), - tptf().boundaryField()[patchi] - .patchInternalField()(), - regioni - ); - } - else - { - fvPatch p - ( - ptf.patch().patch(), - tf.mesh().boundary() - ); - - convertPatchFaceField - ( - tf.name(), - fvPatchField<Type>(p, tf) - .patchInternalField()(), - regioni - ); - - convertPatchPointField - ( - tptf().name(), - tptf().boundaryField()[patchi] - .patchInternalField()(), - regioni - ); - } - } - } - } - } - } - } -} - - -template<class Type> -void Foam::vtkFoam::convertPointFields -( - const fvMesh& mesh, - const IOobjectList& objects, - vtkDataArraySelection *fieldSelection -) -{ - IOobjectList fieldObjects - ( - objects.lookupClass - ( - GeometricField<Type, pointPatchField, pointMesh>::typeName - ) - ); - - label nSelectedFields = fieldSelection->GetNumberOfArrays(); - - for (label i=0; i<nSelectedFields; i++) - { - if(fieldSelection->GetArraySetting(i)) - { - word fieldName = fieldSelection->GetArrayName(i); - - if (fieldObjects.found(fieldName)) - { - pointMesh pMesh(mesh); - - GeometricField<Type, pointPatchField, pointMesh> ptf - ( - IOobject - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ - ), - pMesh - ); - - if (selectedRegions_[0]) - { - convertPointField - ( - ptf, - GeometricField<Type, fvPatchField, volMesh>::null() - ); - } - - label regioni = 0; - forAll (mesh.boundaryMesh(), patchi) - { - if (mesh.boundaryMesh()[patchi].size()) - { - regioni++; - - if (selectedRegions_[regioni]) - { - convertPatchPointField - ( - ptf.name(), - ptf.boundaryField()[patchi] - .patchInternalField()(), - regioni - ); - } - } - } - } - } - } -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPatchFaceField.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPatchFaceField.H deleted file mode 100644 index 9b5fd9353f600b13f45a8be895c38db68c86da94..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPatchFaceField.H +++ /dev/null @@ -1,106 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 - -InClass - Foam::vtkFoam - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkFoamConvertPatchFaceField_H -#define vtkFoamConvertPatchFaceField_H - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<class Type> -void Foam::vtkFoam::convertPatchFaceField -( - const word& name, - const Field<Type>& ptf, - const label regioni -) -{ - vtkUnstructuredGrid *vtkMesh = - vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni)); - - vtkFloatArray *cellTypes = vtkFloatArray::New(); - cellTypes->SetNumberOfTuples(ptf.size()); - cellTypes->SetNumberOfComponents(Type::nComponents); - cellTypes->Allocate(Type::nComponents*ptf.size()); - cellTypes->SetName(name.c_str()); - - float vec[Type::nComponents]; - - forAll(ptf, i) - { - const Type& t = ptf[i]; - for (direction d=0; d<Type::nComponents; d++) - { - vec[d] = t[d]; - } - - cellTypes->InsertTuple(i, vec); - } - - vtkMesh->GetCellData()->AddArray(cellTypes); - cellTypes->Delete(); -} - - -template<> -void Foam::vtkFoam::convertPatchFaceField -( - const word& name, - const Field<scalar>& psf, - const label regioni -) -{ - vtkUnstructuredGrid *vtkMesh = - vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni)); - - vtkFloatArray *cellScalars = vtkFloatArray::New(); - cellScalars->SetNumberOfTuples(psf.size()); - cellScalars->SetNumberOfComponents(1); - cellScalars->Allocate(psf.size()); - cellScalars->SetName(name.c_str()); - - forAll(psf, i) - { - cellScalars->InsertComponent(i, 0, psf[i]); - } - - vtkMesh->GetCellData()->AddArray(cellScalars); - if (!vtkMesh->GetCellData()->GetScalars()) - { - vtkMesh->GetCellData()->SetScalars(cellScalars); - } - - cellScalars->Delete(); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPatchPointField.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPatchPointField.H deleted file mode 100644 index 911ec08d714caeed843bd295d27976d6cba84970..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPatchPointField.H +++ /dev/null @@ -1,105 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 - -InClass - Foam::vtkFoam - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkFoamConvertPatchPointField_H -#define vtkFoamConvertPatchPointField_H - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<class Type> -void Foam::vtkFoam::convertPatchPointField -( - const word& name, - const Field<Type>& pptf, - const label regioni -) -{ - vtkUnstructuredGrid *vtkMesh = - vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni)); - - vtkFloatArray *pointTypes = vtkFloatArray::New(); - pointTypes->SetNumberOfTuples(pptf.size()); - pointTypes->SetNumberOfComponents(Type::nComponents); - pointTypes->Allocate(Type::nComponents*pptf.size()); - pointTypes->SetName(name.c_str()); - - float vec[Type::nComponents]; - - forAll(pptf, i) - { - for (direction d=0; d<Type::nComponents; d++) - { - vec[d] = pptf[i][d]; - } - - pointTypes->InsertTuple(i, vec); - } - - vtkMesh->GetPointData()->AddArray(pointTypes); - pointTypes->Delete(); -} - - -template<> -void Foam::vtkFoam::convertPatchPointField -( - const word& name, - const Field<scalar>& ppsf, - const label regioni -) -{ - vtkUnstructuredGrid *vtkMesh = - vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni)); - - vtkFloatArray *pointScalars = vtkFloatArray::New(); - pointScalars->SetNumberOfTuples(ppsf.size()); - pointScalars->SetNumberOfComponents(1); - pointScalars->Allocate(ppsf.size()); - pointScalars->SetName(name.c_str()); - - for (int i=0; i<ppsf.size(); i++) - { - pointScalars->InsertComponent(i, 0, ppsf[i]); - } - - vtkMesh->GetPointData()->AddArray(pointScalars); - if (!vtkMesh->GetPointData()->GetScalars()) - { - vtkMesh->GetPointData()->SetScalars(pointScalars); - } - - pointScalars->Delete(); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPointField.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPointField.H deleted file mode 100644 index d09d9da23eb5d134b0b7359490612e4ecbc0090a..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPointField.H +++ /dev/null @@ -1,163 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 - -InClass - Foam::vtkFoam - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkFoamConvertPointField_H -#define vtkFoamConvertPointField_H - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "interpolatePointToCell.H" - -template<class Type> -void Foam::vtkFoam::convertPointField -( - const GeometricField<Type, pointPatchField, pointMesh>& ptf, - const GeometricField<Type, fvPatchField, volMesh>& tf -) -{ - vtkUnstructuredGrid *vtkMesh = - vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0)); - - vtkFloatArray *pointTypes = vtkFloatArray::New(); - pointTypes->SetNumberOfTuples(ptf.size() + addPointCellLabels_.size()); - pointTypes->SetNumberOfComponents(Type::nComponents); - pointTypes->Allocate(Type::nComponents*ptf.size()); - pointTypes->SetName(ptf.name().c_str()); - - float vec[Type::nComponents]; - - forAll(ptf, i) - { - for (direction d=0; d<Type::nComponents; d++) - { - vec[d] = ptf[i][d]; - } - - pointTypes->InsertTuple(i, vec); - } - - label i = ptf.size(); - - if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null()) - { - forAll(addPointCellLabels_, api) - { - Type t = tf[addPointCellLabels_[api]]; - - for (direction d=0; d<Type::nComponents; d++) - { - vec[d] = t[d]; - } - - pointTypes->InsertTuple(i++, vec); - } - } - else - { - forAll(addPointCellLabels_, api) - { - Type t = interpolatePointToCell(ptf, addPointCellLabels_[api]); - - for (direction d=0; d<Type::nComponents; d++) - { - vec[d] = t[d]; - } - - pointTypes->InsertTuple(i++, vec); - } - } - - vtkMesh->GetPointData()->AddArray(pointTypes); - pointTypes->Delete(); -} - - -template<> -void Foam::vtkFoam::convertPointField -( - const GeometricField<scalar, pointPatchField, pointMesh>& psf, - const GeometricField<scalar, fvPatchField, volMesh>& sf -) -{ - vtkUnstructuredGrid *vtkMesh = - vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0)); - - vtkFloatArray *pointScalars = vtkFloatArray::New(); - pointScalars->SetNumberOfTuples(psf.size() + addPointCellLabels_.size()); - pointScalars->SetNumberOfComponents(1); - pointScalars->Allocate(psf.size()); - pointScalars->SetName(psf.name().c_str()); - - for (int i=0; i<psf.size(); i++) - { - pointScalars->InsertComponent(i, 0, psf[i]); - } - - label i = psf.size(); - - if (&sf != &GeometricField<scalar, fvPatchField, volMesh>::null()) - { - forAll(addPointCellLabels_, api) - { - pointScalars->InsertComponent - ( - i++, - 0, - sf[addPointCellLabels_[api]] - ); - } - } - else - { - forAll(addPointCellLabels_, api) - { - pointScalars->InsertComponent - ( - i++, - 0, - interpolatePointToCell(psf, addPointCellLabels_[api]) - ); - } - } - - vtkMesh->GetPointData()->AddArray(pointScalars); - if (!vtkMesh->GetPointData()->GetScalars()) - { - vtkMesh->GetPointData()->SetScalars(pointScalars); - } - - pointScalars->Delete(); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertVolField.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertVolField.H deleted file mode 100644 index 7762e906d17f2d49fdfecfc7fff96ffabd78941c..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertVolField.H +++ /dev/null @@ -1,102 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 - -InClass - Foam::vtkFoam - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkFoamConvertVolField_H -#define vtkFoamConvertVolField_H - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<class Type> -void Foam::vtkFoam::convertVolField -( - const GeometricField<Type, fvPatchField, volMesh>& tf -) -{ - vtkUnstructuredGrid *vtkMesh = - vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0)); - - 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]; - - forAll(superCells_, sci) - { - const Type& t = tf[superCells_[sci]]; - for (direction d=0; d<Type::nComponents; d++) - { - vec[d] = t[d]; - } - - cellTypes->InsertTuple(sci, vec); - } - - vtkMesh->GetCellData()->AddArray(cellTypes); - cellTypes->Delete(); -} - - -template<> -void Foam::vtkFoam::convertVolField -( - const GeometricField<scalar, fvPatchField, volMesh>& sf -) -{ - vtkUnstructuredGrid *vtkMesh = - vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0)); - - vtkFloatArray *cellScalars = vtkFloatArray::New(); - cellScalars->SetNumberOfTuples(superCells_.size()); - cellScalars->SetNumberOfComponents(1); - cellScalars->Allocate(sf.size()); - cellScalars->SetName(sf.name().c_str()); - - forAll(superCells_, sci) - { - cellScalars->InsertComponent(sci, 0, sf[superCells_[sci]]); - } - - vtkMesh->GetCellData()->AddArray(cellScalars); - if (!vtkMesh->GetCellData()->GetScalars()) - { - vtkMesh->GetCellData()->SetScalars(cellScalars); - } - - cellScalars->Delete(); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamInsertNextPoint.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamInsertNextPoint.H deleted file mode 100644 index 70f18986845348aeb011c3731ced173bcfc6ddbc..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamInsertNextPoint.H +++ /dev/null @@ -1,49 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 - -InClass - Foam::vtkFoam - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkFoamInsertNextPoint_H -#define vtkFoamInsertNextPoint_H - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -inline void vtkFoamInsertNextPoint -( - vtkPoints *points, - const Foam::point& p -) -{ - points->InsertNextPoint(p.x(), p.y(), p.z()); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C index 95077df225fbae93d2ac8db5d3584c81dbe68a60..34f231850f02f73187a37175779a932d62864b0f 100644 --- a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C +++ b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C @@ -113,7 +113,16 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) return; } - wordList extensiveVVFNames(IStringStream ("(momentumMean)")()); + wordList extensiveVVFNames + ( + IStringStream + ( + "( \ + momentumMean \ + fDMean \ + )" + )() + ); PtrList<volVectorField> extensiveVVFs(extensiveVVFNames.size()); diff --git a/applications/utilities/preProcessing/dsmcInitialise/dsmcInitialise.C b/applications/utilities/preProcessing/dsmcInitialise/dsmcInitialise.C index f8b831001df83cdafbfb6998a79312ed03176049..9e7725ec23e622691de9ef44f942e3be8fb5533f 100644 --- a/applications/utilities/preProcessing/dsmcInitialise/dsmcInitialise.C +++ b/applications/utilities/preProcessing/dsmcInitialise/dsmcInitialise.C @@ -44,9 +44,21 @@ int main(int argc, char *argv[]) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + IOdictionary dsmcInitialiseDict + ( + IOobject + ( + "dsmcInitialiseDict", + mesh.time().system(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + Info<< "Initialising dsmc for Time = " << runTime.timeName() << nl << endl; - dsmcCloud dsmc("dsmc", mesh); + dsmcCloud dsmc("dsmc", mesh, dsmcInitialiseDict); label totalMolecules = dsmc.size(); diff --git a/etc/controlDict b/etc/controlDict index 97af349e7aa8360fde8a91954d9570215a8797db..ef72407eaff16a67b7c055a3379da97a0cb5f82e 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -377,6 +377,7 @@ DebugSwitches displacementLaplacian 0; displacementSBRStress 0; distanceSurface 0; + distribution 0; downwind 0; dragModel 0; duplicatePoints 0; diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C index d63921f95bac5638f029190f1a5a7077bdbdf2f6..4701c8020de7180bb9907516c290837a7c0260fb 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C @@ -105,7 +105,7 @@ template<class Key, class Hash> void Foam::HashSet<Key, Hash>::operator&=(const HashSet<Key, Hash>& rhs) { // Remove elements not also found in rhs - for (iterator iter = this->cbegin(); iter != this->cend(); ++iter) + for (iterator iter = this->begin(); iter != this->end(); ++iter) { if (!rhs.found(iter.key())) { @@ -145,8 +145,6 @@ void Foam::HashSet<Key, Hash>::operator-=(const HashSet<Key, Hash>& rhs) } -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - /* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */ template<class Key, class Hash> diff --git a/src/OpenFOAM/matrices/Matrix/Matrix.C b/src/OpenFOAM/matrices/Matrix/Matrix.C index 7f91a5f36c81eba94c32410da02d3c1b83d66266..0062d897a431b8a33466541181e5a9db1e732598 100644 --- a/src/OpenFOAM/matrices/Matrix/Matrix.C +++ b/src/OpenFOAM/matrices/Matrix/Matrix.C @@ -235,12 +235,12 @@ void Foam::Matrix<Form, Type>::operator=(const Matrix<Form, Type>& a) template<class Form, class Type> const Type& Foam::max(const Matrix<Form, Type>& a) { - label nm = a.n_*a.m_; + label nm = a.n()*a.m(); if (nm) { label curMaxI = 0; - const Type* v = a.v_[0]; + const Type* v = a[0]; for (register label i=1; i<nm; i++) { @@ -267,12 +267,12 @@ const Type& Foam::max(const Matrix<Form, Type>& a) template<class Form, class Type> const Type& Foam::min(const Matrix<Form, Type>& a) { - label nm = a.n_*a.m_; + label nm = a.n()*a.m(); if (nm) { label curMinI = 0; - const Type* v = a.v_[0]; + const Type* v = a[0]; for (register label i=1; i<nm; i++) { @@ -301,14 +301,14 @@ const Type& Foam::min(const Matrix<Form, Type>& a) template<class Form, class Type> Form Foam::operator-(const Matrix<Form, Type>& a) { - Form na(a.n_, a.m_); + Form na(a.n(), a.m()); - if (a.n_ && a.m_) + if (a.n() && a.m()) { - Type* nav = na.v_[0]; - const Type* av = a.v_[0]; + Type* nav = na[0]; + const Type* av = a[0]; - label nm = a.n_*a.m_; + label nm = a.n()*a.m(); for (register label i=0; i<nm; i++) { nav[i] = -av[i]; @@ -322,33 +322,33 @@ Form Foam::operator-(const Matrix<Form, Type>& a) template<class Form, class Type> Form Foam::operator+(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b) { - if (a.n_ != b.n_) + if (a.n() != b.n()) { FatalErrorIn ( "Matrix<Form, Type>::operator+(const Matrix<Form, Type>&, const Matrix<Form, Type>&)" ) << "attempted add matrices with different number of rows: " - << a.n_ << ", " << b.n_ + << a.n() << ", " << b.n() << abort(FatalError); } - if (a.m_ != b.m_) + if (a.m() != b.m()) { FatalErrorIn ( "Matrix<Form, Type>::operator+(const Matrix<Form, Type>&, const Matrix<Form, Type>&)" ) << "attempted add matrices with different number of columns: " - << a.m_ << ", " << b.m_ + << a.m() << ", " << b.m() << abort(FatalError); } - Form ab(a.n_, a.m_); + Form ab(a.n(), a.m()); - Type* abv = ab.v_[0]; - const Type* av = a.v_[0]; - const Type* bv = b.v_[0]; + Type* abv = ab[0]; + const Type* av = a[0]; + const Type* bv = b[0]; - label nm = a.n_*a.m_; + label nm = a.n()*a.m(); for (register label i=0; i<nm; i++) { abv[i] = av[i] + bv[i]; @@ -361,33 +361,33 @@ Form Foam::operator+(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b) template<class Form, class Type> Form Foam::operator-(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b) { - if (a.n_ != b.n_) + if (a.n() != b.n()) { FatalErrorIn ( "Matrix<Form, Type>::operator-(const Matrix<Form, Type>&, const Matrix<Form, Type>&)" ) << "attempted add matrices with different number of rows: " - << a.n_ << ", " << b.n_ + << a.n() << ", " << b.n() << abort(FatalError); } - if (a.m_ != b.m_) + if (a.m() != b.m()) { FatalErrorIn ( "Matrix<Form, Type>::operator-(const Matrix<Form, Type>&, const Matrix<Form, Type>&)" ) << "attempted add matrices with different number of columns: " - << a.m_ << ", " << b.m_ + << a.m() << ", " << b.m() << abort(FatalError); } - Form ab(a.n_, a.m_); + Form ab(a.n(), a.m()); - Type* abv = ab.v_[0]; - const Type* av = a.v_[0]; - const Type* bv = b.v_[0]; + Type* abv = ab[0]; + const Type* av = a[0]; + const Type* bv = b[0]; - label nm = a.n_*a.m_; + label nm = a.n()*a.m(); for (register label i=0; i<nm; i++) { abv[i] = av[i] - bv[i]; @@ -400,14 +400,14 @@ Form Foam::operator-(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b) template<class Form, class Type> Form Foam::operator*(const scalar s, const Matrix<Form, Type>& a) { - Form sa(a.n_, a.m_); + Form sa(a.n(), a.m()); - if (a.n_ && a.m_) + if (a.n() && a.m()) { - Type* sav = sa.v_[0]; - const Type* av = a.v_[0]; + Type* sav = sa[0]; + const Type* av = a[0]; - label nm = a.n_*a.m_; + label nm = a.n()*a.m(); for (register label i=0; i<nm; i++) { sav[i] = s*av[i]; diff --git a/src/OpenFOAM/matrices/Matrix/Matrix.H b/src/OpenFOAM/matrices/Matrix/Matrix.H index fd623fdb206dc0746c78aaebadbd6e10ff9567a9..b674956e2f2f1e9d8fc2b3fb36ccd01f5c0e3ef2 100644 --- a/src/OpenFOAM/matrices/Matrix/Matrix.H +++ b/src/OpenFOAM/matrices/Matrix/Matrix.H @@ -161,10 +161,10 @@ public: // Member operators - //- Return subscript-checked element of Matrix. + //- Return subscript-checked row of Matrix. inline Type* operator[](const label); - //- Return subscript-checked element of constant Matrix. + //- Return subscript-checked row of constant Matrix. inline const Type* operator[](const label) const; //- Assignment operator. Takes linear time. diff --git a/src/Pstream/mpi/UPstream.C b/src/Pstream/mpi/UPstream.C index 3623f5da58c3cb503e68db555df58a6bdaca32da..d05fe2ad9a7f4b72a8ca47d9fb9b96c986e1ed07 100644 --- a/src/Pstream/mpi/UPstream.C +++ b/src/Pstream/mpi/UPstream.C @@ -177,7 +177,7 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) { if (Pstream::debug) { - Pout<< "UPstream::reduce : value:" << Value << endl; + Pout<< "Foam::reduce : value:" << Value << endl; } if (!UPstream::parRun()) @@ -452,7 +452,7 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) if (Pstream::debug) { - Pout<< "UPstream::reduce : reduced value:" << Value << endl; + Pout<< "Foam::reduce : reduced value:" << Value << endl; } } diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 5fe44b935751f8c95bdc23e7e561c1b40ac7b359..94c83312d35b49b48f4019411eab97c1ba1dfcee 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -122,6 +122,7 @@ $(derivedFvPatchFields)/inletOutletTotalTemperature/inletOutletTotalTemperatureF $(derivedFvPatchFields)/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/movingWallVelocity/movingWallVelocityFvPatchVectorField.C $(derivedFvPatchFields)/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C +$(derivedFvPatchFields)/translatingWallVelocity/translatingWallVelocityFvPatchVectorField.C $(derivedFvPatchFields)/oscillatingFixedValue/oscillatingFixedValueFvPatchFields.C $(derivedFvPatchFields)/outletInlet/outletInletFvPatchFields.C $(derivedFvPatchFields)/partialSlip/partialSlipFvPatchFields.C diff --git a/src/lagrangian/dsmc/Make/files b/src/lagrangian/dsmc/Make/files index 9f6d33d209edf23f3a65deb06139746c0bb873ae..983de123ab3dd948fc347e2321285f87154ecb4e 100644 --- a/src/lagrangian/dsmc/Make/files +++ b/src/lagrangian/dsmc/Make/files @@ -4,9 +4,6 @@ parcels/derived/dsmcParcel/dsmcParcel.C /* Cloud base classes */ clouds/baseClasses/DsmcBaseCloud/DsmcBaseCloud.C -/* Clouds */ -clouds/derived/dsmcCloud/dsmcCloud.C - /* submodels */ parcels/derived/dsmcParcel/defineDsmcParcel.C parcels/derived/dsmcParcel/makeDsmcParcelBinaryCollisionModels.C diff --git a/src/lagrangian/dsmc/Make/options b/src/lagrangian/dsmc/Make/options index 15874b7b55afc2cfae55d9550fd48451604ee3d4..55865dfabcd9146aa4fe204e71d664b62e535b95 100644 --- a/src/lagrangian/dsmc/Make/options +++ b/src/lagrangian/dsmc/Make/options @@ -1,7 +1,9 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/lagrangian/basic/lnInclude + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude LIB_LIBS = \ -llagrangian \ - -lfiniteVolume + -lfiniteVolume \ + -lmeshTools diff --git a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C index 5ac29101e59c71199ceacdd9c7c8585a97a280df..f7aaaa724d2a9f4606d4785fc59e7b29fd089163 100644 --- a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C +++ b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C @@ -297,7 +297,7 @@ void Foam::DsmcCloud<ParcelType>::collisions() // Temporary storage for subCells List<DynamicList<label> > subCells(8); - scalar deltaT = cachedDeltaT(); + scalar deltaT = mesh().time().deltaTValue(); label collisionCandidates = 0; @@ -473,21 +473,92 @@ void Foam::DsmcCloud<ParcelType>::collisions() template<class ParcelType> -void Foam::DsmcCloud<ParcelType>::resetSurfaceDataFields() +void Foam::DsmcCloud<ParcelType>::resetFields() { - volScalarField::GeometricBoundaryField& qBF(q_.boundaryField()); + q_ = dimensionedScalar("zero", dimensionSet(1, 0, -3, 0, 0), 0.0); + + fD_ = dimensionedVector + ( + "zero", + dimensionSet(1, -1, -2, 0, 0), + vector::zero + ); + + rhoN_ = dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL); + + rhoM_ = dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0), VSMALL); + + dsmcRhoN_ = dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), 0.0); + + linearKE_ = dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0); + + internalE_ = dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0); + + iDof_ = dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL); + + momentum_ = dimensionedVector + ( + "zero", + dimensionSet(1, -2, -1, 0, 0), + vector::zero + ); +} - forAll(qBF, p) - { - qBF[p] = 0.0; - } - volVectorField::GeometricBoundaryField& fDBF(fD_.boundaryField()); +template<class ParcelType> +void Foam::DsmcCloud<ParcelType>::calculateFields() +{ + scalarField& rhoN = rhoN_.internalField(); + + scalarField& rhoM = rhoM_.internalField(); + + scalarField& dsmcRhoN = dsmcRhoN_.internalField(); + + scalarField& linearKE = linearKE_.internalField(); + + scalarField& internalE = internalE_.internalField(); + + scalarField& iDof = iDof_.internalField(); + + vectorField& momentum = momentum_.internalField(); - forAll(fDBF, p) + forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) { - fDBF[p] = vector::zero; + const ParcelType& p = iter(); + const label cellI = p.cell(); + + rhoN[cellI]++; + + rhoM[cellI] += constProps(p.typeId()).mass(); + + dsmcRhoN[cellI]++; + + linearKE[cellI] += 0.5*constProps(p.typeId()).mass()*(p.U() & p.U()); + + internalE[cellI] += p.Ei(); + + iDof[cellI] += constProps(p.typeId()).internalDegreesOfFreedom(); + + momentum[cellI] += constProps(p.typeId()).mass()*p.U(); } + + rhoN *= nParticle_/mesh().cellVolumes(); + rhoN_.correctBoundaryConditions(); + + rhoM *= nParticle_/mesh().cellVolumes(); + rhoM_.correctBoundaryConditions(); + + linearKE *= nParticle_/mesh().cellVolumes(); + linearKE_.correctBoundaryConditions(); + + internalE *= nParticle_/mesh().cellVolumes(); + internalE_.correctBoundaryConditions(); + + iDof *= nParticle_/mesh().cellVolumes(); + iDof_.correctBoundaryConditions(); + + momentum *= nParticle_/mesh().cellVolumes(); + momentum_.correctBoundaryConditions(); } @@ -523,15 +594,14 @@ template<class ParcelType> Foam::DsmcCloud<ParcelType>::DsmcCloud ( const word& cloudName, - const volScalarField& T, - const volVectorField& U, + const fvMesh& mesh, bool readFields ) : - Cloud<ParcelType>(T.mesh(), cloudName, false), + Cloud<ParcelType>(mesh, cloudName, false), DsmcBaseCloud(), cloudName_(cloudName), - mesh_(T.mesh()), + mesh_(mesh), particleProperties_ ( IOobject @@ -563,37 +633,142 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud ( IOobject ( - this->name() + "q_", + "q", mesh_.time().timeName(), mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::MUST_READ, + IOobject::AUTO_WRITE ), - mesh_, - dimensionedScalar("zero", dimensionSet(1, 0, -3, 0, 0), 0.0) + mesh_ ), fD_ ( IOobject ( - this->name() + "fD_", + "fD", mesh_.time().timeName(), mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::MUST_READ, + IOobject::AUTO_WRITE ), - mesh_, - dimensionedVector + mesh_ + ), + rhoN_ + ( + IOobject ( - "zero", - dimensionSet(1, -1, -2, 0, 0), - vector::zero - ) + "rhoN", + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + rhoM_ + ( + IOobject + ( + "rhoM", + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + dsmcRhoN_ + ( + IOobject + ( + "dsmcRhoN", + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + linearKE_ + ( + IOobject + ( + "linearKE", + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + internalE_ + ( + IOobject + ( + "internalE", + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + iDof_ + ( + IOobject + ( + "iDof", + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + momentum_ + ( + IOobject + ( + "momentum", + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ ), constProps_(), rndGen_(label(149382906) + 7183*Pstream::myProcNo()), - T_(T), - U_(U), + boundaryT_ + ( + volScalarField + ( + IOobject + ( + "boundaryT", + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) + ), + boundaryU_ + ( + volVectorField + ( + IOobject + ( + "boundaryU", + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) + ), binaryCollisionModel_ ( BinaryCollisionModel<DsmcCloud<ParcelType> >::New @@ -641,7 +816,8 @@ template<class ParcelType> Foam::DsmcCloud<ParcelType>::DsmcCloud ( const word& cloudName, - const fvMesh& mesh + const fvMesh& mesh, + const IOdictionary& dsmcInitialiseDict ) : Cloud<ParcelType>(mesh, cloudName, false), @@ -707,15 +883,111 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud vector::zero ) ), + rhoN_ + ( + IOobject + ( + this->name() + "rhoN_", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL) + ), + rhoM_ + ( + IOobject + ( + this->name() + "rhoM_", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0), VSMALL) + ), + dsmcRhoN_ + ( + IOobject + ( + this->name() + "dsmcRhoN_", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), 0.0) + ), + linearKE_ + ( + IOobject + ( + this->name() + "linearKE_", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0) + ), + internalE_ + ( + IOobject + ( + this->name() + "internalE_", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0) + ), + iDof_ + ( + IOobject + ( + this->name() + "iDof_", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL) + ), + momentum_ + ( + IOobject + ( + this->name() + "momentum_", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedVector + ( + "zero", + dimensionSet(1, -2, -1, 0, 0), + vector::zero + ) + ), constProps_(), rndGen_(label(971501) + 1526*Pstream::myProcNo()), - T_ + boundaryT_ ( volScalarField ( IOobject ( - "T", + "boundaryT", mesh_.time().timeName(), mesh_, IOobject::NO_READ, @@ -725,13 +997,13 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud dimensionedScalar("zero", dimensionSet(0, 0, 0, 1, 0), 0.0) ) ), - U_ + boundaryU_ ( volVectorField ( IOobject ( - "U", + "boundaryU", mesh_.time().timeName(), mesh_, IOobject::NO_READ, @@ -754,18 +1026,6 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud buildConstProps(); - IOdictionary dsmcInitialiseDict - ( - IOobject - ( - "dsmcInitialiseDict", - mesh_.time().system(), - mesh_, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ); - initialise(dsmcInitialiseDict); } @@ -782,13 +1042,10 @@ Foam::DsmcCloud<ParcelType>::~DsmcCloud() template<class ParcelType> void Foam::DsmcCloud<ParcelType>::evolve() { - // cache the value of deltaT for this timestep - storeDeltaT(); - typename ParcelType::trackData td(*this); - // Reset the surface data collection fields - resetSurfaceDataFields(); + // Reset the data collection fields + resetFields(); if (debug) { @@ -803,6 +1060,9 @@ void Foam::DsmcCloud<ParcelType>::evolve() // Calculate new velocities via stochastic collisions collisions(); + + // Calculate the volume field data + calculateFields(); } diff --git a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.H b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.H index c3765ba0dfccd08eed048633f144451aed099f9a..5b2f382eb62f4b2699ec3a48caae5d1b71579385 100644 --- a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.H +++ b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.H @@ -110,24 +110,41 @@ class DsmcCloud //- Force density at surface field volVectorField fD_; + //- number density field + volScalarField rhoN_; + + //- Mass density field + volScalarField rhoM_; + + //- dsmc particle density field + volScalarField dsmcRhoN_; + + //- linear kinetic energy density field + volScalarField linearKE_; + + //- Internal energy density field + volScalarField internalE_; + + // Internal degree of freedom density field + volScalarField iDof_; + + //- Momentum density field + volVectorField momentum_; + //- Parcel constant properties - one for each type List<typename ParcelType::constantProperties> constProps_; //- Random number generator Random rndGen_; - //- In-cloud cache of deltaT, lookup in submodels and parcel is - // expensive - scalar cachedDeltaT_; + // boundary value fields - // References to the macroscopic fields + //- boundary temperature + volScalarField boundaryT_; - //- Temperature - const volScalarField& T_; - - //- Velocity - const volVectorField& U_; + //- boundary velocity + volVectorField boundaryU_; // References to the cloud sub-models @@ -159,8 +176,11 @@ class DsmcCloud //- Calculate collisions between molecules void collisions(); - //- Reset the surface data accumulation field values - void resetSurfaceDataFields(); + //- Reset the data accumulation field values to zero + void resetFields(); + + //- Calculate the volume field data + void calculateFields(); //- Disallow default bitwise copy construct DsmcCloud(const DsmcCloud&); @@ -173,20 +193,21 @@ public: // Constructors - //- Construct given name and mesh, will read Parcels from file + //- Construct given name and mesh, will read Parcels and fields from + // file DsmcCloud ( const word& cloudName, - const volScalarField& T, - const volVectorField& U, + const fvMesh& mesh, bool readFields = true ); - //- Construct given name and mesh. Used to initialise. + //- Construct given name, mesh and initialisation dictionary. DsmcCloud ( const word& cloudName, - const fvMesh& mesh + const fvMesh& mesh, + const IOdictionary& dsmcInitialiseDict ); @@ -242,35 +263,72 @@ public: //- Return refernce to the random object inline Random& rndGen(); - //- Store (cache) the current value of deltaT - inline void storeDeltaT(); - //- Return the cached value of deltaT - inline scalar cachedDeltaT() const; + // References to the boundary fields for surface data collection + //- Return non-const heat flux boundary field reference + inline volScalarField::GeometricBoundaryField& qBF(); - // References to the surface data collection fields + //- Return non-const force density at boundary field reference + inline volVectorField::GeometricBoundaryField& fDBF(); - //- Return heat flux at surface field - inline const volScalarField& q() const; + //- Return non-const number density boundary field reference + inline volScalarField::GeometricBoundaryField& rhoNBF(); - //- Return non-const heat flux at surface field - inline volScalarField& q(); + //- Return non-const mass density boundary field reference + inline volScalarField::GeometricBoundaryField& rhoMBF(); - //- Return force density at surface field - inline const volVectorField& fD() const; + //- Return non-const linear kinetic energy density boundary + // field reference + inline volScalarField::GeometricBoundaryField& linearKEBF(); - //- Return non-const force density at surface field - inline volVectorField& fD(); + //- Return non-const internal energy density boundary field + // reference + inline volScalarField::GeometricBoundaryField& internalEBF(); + + //- Return non-const internal degree of freedom density boundary + // field reference + inline volScalarField::GeometricBoundaryField& iDofBF(); + + //- Return non-const momentum density boundary field reference + inline volVectorField::GeometricBoundaryField& momentumBF(); // References to the macroscopic fields //- Return macroscopic temperature - inline const volScalarField& T() const; + inline const volScalarField& boundaryT() const; //- Return macroscopic velocity - inline const volVectorField& U() const; + inline const volVectorField& boundaryU() const; + + //- Return heat flux at surface field + inline const volScalarField& q() const; + + //- Return force density at surface field + inline const volVectorField& fD() const; + + //- Return the real particle number density field + inline const volScalarField& rhoN() const; + + //- Return the particle mass density field + inline const volScalarField& rhoM() const; + + //- Return the field of number of DSMC particles + inline const volScalarField& dsmcRhoN() const; + + //- Return the total linear kinetic energy (translational and + // thermal density field + inline const volScalarField& linearKE() const; + + //- Return the internal energy density field + inline const volScalarField& internalE() const; + + //- Return the average internal degrees of freedom field + inline const volScalarField& iDof() const; + + //- Return the momentum density field + inline const volVectorField& momentum() const; // Kinetic theory helper functions @@ -385,29 +443,6 @@ public: void dumpParticlePositions() const; - // Fields - - //- Return the real particle number density field - inline const tmp<volScalarField> rhoN() const; - - //- Return the particle mass density field - inline const tmp<volScalarField> rhoM() const; - - //- Return the field of number of DSMC particles - inline const tmp<volScalarField> dsmcRhoN() const; - - //- Return the momentum density field - inline const tmp<volVectorField> momentum() const; - - //- Return the total linear kinetic energy (translational and - // thermal density field - inline const tmp<volScalarField> linearKE() const; - - //- Return the internal energy density field - inline const tmp<volScalarField> internalE() const; - - //- Return the average internal degrees of freedom field - inline const tmp<volScalarField> iDof() const; // Cloud evolution functions diff --git a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloudI.H b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloudI.H index 9b65d776594a0c2e29c0e3bd0b8c85d61926115d..beaacb2276683d7251396dec9a49806e33e0ef79 100644 --- a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloudI.H +++ b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloudI.H @@ -126,58 +126,82 @@ inline Foam::Random& Foam::DsmcCloud<ParcelType>::rndGen() template<class ParcelType> -inline void Foam::DsmcCloud<ParcelType>::storeDeltaT() +inline Foam::volScalarField::GeometricBoundaryField& +Foam::DsmcCloud<ParcelType>::qBF() { - cachedDeltaT_ = mesh().time().deltaTValue(); + return q_.boundaryField(); } template<class ParcelType> -inline Foam::scalar Foam::DsmcCloud<ParcelType>::cachedDeltaT() const +inline Foam::volVectorField::GeometricBoundaryField& +Foam::DsmcCloud<ParcelType>::fDBF() { - return cachedDeltaT_; + return fD_.boundaryField(); } template<class ParcelType> -inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::q() const +inline Foam::volScalarField::GeometricBoundaryField& +Foam::DsmcCloud<ParcelType>::rhoNBF() { - return q_; + return rhoN_.boundaryField(); } template<class ParcelType> -inline Foam::volScalarField& Foam::DsmcCloud<ParcelType>::q() +inline Foam::volScalarField::GeometricBoundaryField& +Foam::DsmcCloud<ParcelType>::rhoMBF() { - return q_; + return rhoM_.boundaryField(); } template<class ParcelType> -inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::fD() const +inline Foam::volScalarField::GeometricBoundaryField& +Foam::DsmcCloud<ParcelType>::linearKEBF() { - return fD_; + return linearKE_.boundaryField(); } template<class ParcelType> -inline Foam::volVectorField& Foam::DsmcCloud<ParcelType>::fD() +inline Foam::volScalarField::GeometricBoundaryField& +Foam::DsmcCloud<ParcelType>::internalEBF() { - return fD_; + return internalE_.boundaryField(); +} + + +template<class ParcelType> +inline Foam::volScalarField::GeometricBoundaryField& +Foam::DsmcCloud<ParcelType>::iDofBF() +{ + return iDof_.boundaryField(); } template<class ParcelType> -inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::T() const +inline Foam::volVectorField::GeometricBoundaryField& +Foam::DsmcCloud<ParcelType>::momentumBF() { - return T_; + return momentum_.boundaryField(); } template<class ParcelType> -inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::U() const +inline const Foam::volScalarField& +Foam::DsmcCloud<ParcelType>::boundaryT() const { - return U_; + return boundaryT_; +} + + +template<class ParcelType> +inline const Foam::volVectorField& +Foam::DsmcCloud<ParcelType>::boundaryU() const +{ + return boundaryU_; } @@ -381,265 +405,70 @@ Foam::DsmcCloud<ParcelType>::maxwellianMostProbableSpeed template<class ParcelType> -inline const Foam::tmp<Foam::volScalarField> -Foam::DsmcCloud<ParcelType>::rhoN() const +inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::q() const { - tmp<volScalarField> trhoN - ( - new volScalarField - ( - IOobject - ( - this->name() + "rhoN", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - mesh_, - dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL) - ) - ); - - scalarField& rhoN = trhoN().internalField(); - forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) - { - const ParcelType& p = iter(); - const label cellI = p.cell(); - - rhoN[cellI]++; - } - - rhoN *= nParticle_/mesh().cellVolumes(); - - return trhoN; + return q_; } template<class ParcelType> -inline const Foam::tmp<Foam::volScalarField> -Foam::DsmcCloud<ParcelType>::rhoM() const +inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::fD() const { - tmp<volScalarField> trhoM - ( - new volScalarField - ( - IOobject - ( - this->name() + "rhoM", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - mesh_, - dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0), VSMALL) - ) - ); - - scalarField& rhoM = trhoM().internalField(); - forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) - { - const ParcelType& p = iter(); - const label cellI = p.cell(); - - rhoM[cellI] += constProps(p.typeId()).mass(); - } - - rhoM *= nParticle_/mesh().cellVolumes(); - - return trhoM; + return fD_; } template<class ParcelType> -inline const Foam::tmp<Foam::volScalarField> -Foam::DsmcCloud<ParcelType>::dsmcRhoN() const +inline const Foam::volScalarField& +Foam::DsmcCloud<ParcelType>::rhoN() const { - tmp<volScalarField> tdsmcRhoN - ( - new volScalarField - ( - IOobject - ( - this->name() + "dsmcRhoN", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - mesh_, - dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), 0.0) - ) - ); - - scalarField& dsmcRhoN = tdsmcRhoN().internalField(); - forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) - { - const ParcelType& p = iter(); - const label cellI = p.cell(); - - dsmcRhoN[cellI]++; - } - - return tdsmcRhoN; + return rhoN_; } template<class ParcelType> -inline const Foam::tmp<Foam::volVectorField> -Foam::DsmcCloud<ParcelType>::momentum() const +inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::rhoM() const { - tmp<volVectorField> tmomentum - ( - new volVectorField - ( - IOobject - ( - this->name() + "momentum", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - mesh_, - dimensionedVector - ( - "zero", - dimensionSet(1, -2, -1, 0, 0), - vector::zero - ) - ) - ); - - vectorField& momentum = tmomentum().internalField(); - forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) - { - const ParcelType& p = iter(); - const label cellI = p.cell(); - - momentum[cellI] += constProps(p.typeId()).mass()*p.U(); - } + return rhoM_; +} - momentum *= nParticle_/mesh().cellVolumes(); - return tmomentum; +template<class ParcelType> +inline const Foam::volScalarField& +Foam::DsmcCloud<ParcelType>::dsmcRhoN() const +{ + return dsmcRhoN_; } template<class ParcelType> -inline const Foam::tmp<Foam::volScalarField> +inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::linearKE() const { - tmp<volScalarField> tlinearKE - ( - new volScalarField - ( - IOobject - ( - this->name() + "linearKE", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - mesh_, - dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0) - ) - ); - - scalarField& linearKE = tlinearKE().internalField(); - forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) - { - const ParcelType& p = iter(); - const label cellI = p.cell(); - - linearKE[cellI] += 0.5*constProps(p.typeId()).mass()*(p.U() & p.U()); - } - - linearKE *= nParticle_/mesh().cellVolumes(); - - return tlinearKE; + return linearKE_; } template<class ParcelType> -inline const Foam::tmp<Foam::volScalarField> +inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::internalE() const { - tmp<volScalarField> tinternalE - ( - new volScalarField - ( - IOobject - ( - this->name() + "internalE", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - mesh_, - dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0) - ) - ); - - scalarField& internalE = tinternalE().internalField(); - forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) - { - const ParcelType& p = iter(); - const label cellI = p.cell(); - - internalE[cellI] += p.Ei(); - } - - internalE *= nParticle_/mesh().cellVolumes(); - - return tinternalE; + return internalE_; } template<class ParcelType> -inline const Foam::tmp<Foam::volScalarField> +inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::iDof() const { - tmp<volScalarField> tiDof - ( - new volScalarField - ( - IOobject - ( - this->name() + "iDof", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - mesh_, - dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL) - ) - ); - - scalarField& iDof = tiDof().internalField(); - - forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) - { - const ParcelType& p = iter(); - const label cellI = p.cell(); - - iDof[cellI] += constProps(p.typeId()).internalDegreesOfFreedom(); - } + return iDof_; +} - iDof *= nParticle_/mesh().cellVolumes(); - return tiDof; +template<class ParcelType> +inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::momentum() const +{ + return momentum_; } diff --git a/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.C b/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.C deleted file mode 100644 index 7f94f3e73958af10eb1e1bae07a61ba3945978eb..0000000000000000000000000000000000000000 --- a/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.C +++ /dev/null @@ -1,66 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2009-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 - -\*---------------------------------------------------------------------------*/ - -#include "dsmcCloud.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(dsmcCloud, 0); -}; - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::dsmcCloud::dsmcCloud -( - const word& cloudName, - const volScalarField& T, - const volVectorField& U -) -: - DsmcCloud<dsmcParcel>(cloudName, T, U) -{} - - -Foam::dsmcCloud::dsmcCloud -( - const word& cloudName, - const fvMesh& mesh -) -: - DsmcCloud<dsmcParcel>(cloudName, mesh) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::dsmcCloud::~dsmcCloud() -{} - - -// ************************************************************************* // diff --git a/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.H b/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.H index 99343c2b3ec74faf763a08b43562dd2aac9d3086..c0c17336e6b2488ba4b349503ff742d450cdc3c1 100644 --- a/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.H +++ b/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.H @@ -43,54 +43,8 @@ SourceFiles namespace Foam { - -/*---------------------------------------------------------------------------*\ - Class dsmcCloud Declaration -\*---------------------------------------------------------------------------*/ - -class dsmcCloud -: - public DsmcCloud<dsmcParcel> -{ - // Private member functions - - //- Disallow default bitwise copy construct - dsmcCloud(const dsmcCloud&); - - //- Disallow default bitwise assignment - void operator=(const dsmcCloud&); - - -public: - - //- Runtime type information - TypeName("dsmcCloud"); - - - // Constructors - - //- Construct from components - dsmcCloud - ( - const word& cloudName, - const volScalarField& T, - const volVectorField& U - ); - - //- Construct from name and mesh, used to initialise. - dsmcCloud - ( - const word& cloudName, - const fvMesh& mesh - ); - - //- Destructor - ~dsmcCloud(); -}; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam + typedef DsmcCloud<dsmcParcel> dsmcCloud; +} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C index 521559b72ccdfdfea6effaeb2b1350efae6999d3..3d752aa98dcb97b7b2a4e2be465e13c11a4e99e3 100644 --- a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C +++ b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C @@ -25,6 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "DsmcParcel.H" +#include "meshTools.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -43,16 +44,31 @@ bool Foam::DsmcParcel<ParcelType>::move const polyMesh& mesh = td.cloud().pMesh(); const polyBoundaryMesh& pbMesh = mesh.boundaryMesh(); - const scalar deltaT = td.cloud().cachedDeltaT(); + const scalar deltaT = mesh.time().deltaTValue(); scalar tEnd = (1.0 - p.stepFraction())*deltaT; const scalar dtMax = tEnd; + // For reduced-D cases, the velocity used to track needs to be + // constrained, but the actual U_ of the parcel must not be + // altered or used, as it is altered by patch interactions an + // needs to retain its 3D value for collision purposes. + vector Utracking = U_; + while (td.keepParticle && !td.switchProcessor && tEnd > ROOTVSMALL) { + // Apply correction to position for reduced-D cases + meshTools::constrainToMeshCentre(mesh, p.position()); + + Utracking = U_; + + // Apply correction to velocity to constrain tracking for + // reduced-D cases + meshTools::constrainDirection(mesh, mesh.solutionD(), Utracking); + // Set the Lagrangian time-step scalar dt = min(dtMax, tEnd); - dt *= p.trackToFace(p.position() + dt*U_, td); + dt *= p.trackToFace(p.position() + dt*Utracking, td); tEnd -= dt; @@ -113,10 +129,41 @@ void Foam::DsmcParcel<ParcelType>::hitWallPatch TrackData& td ) { + label wppIndex = wpp.index(); + + label wppLocalFace = wpp.whichFace(this->face()); + + const scalar fA = mag(wpp.faceAreas()[wppLocalFace]); + + const scalar deltaT = td.cloud().pMesh().time().deltaTValue(); + const constantProperties& constProps(td.cloud().constProps(typeId_)); scalar m = constProps.mass(); + vector nw = wpp.faceAreas()[wppLocalFace]; + nw /= mag(nw); + + scalar U_dot_nw = U_ & nw; + + vector Ut = U_ - U_dot_nw*nw; + + scalar invMagUnfA = 1/max(mag(U_dot_nw)*fA, VSMALL); + + td.cloud().rhoNBF()[wppIndex][wppLocalFace] += invMagUnfA; + + td.cloud().rhoMBF()[wppIndex][wppLocalFace] += m*invMagUnfA; + + td.cloud().linearKEBF()[wppIndex][wppLocalFace] += + 0.5*m*(U_ & U_)*invMagUnfA; + + td.cloud().internalEBF()[wppIndex][wppLocalFace] += Ei_*invMagUnfA; + + td.cloud().iDofBF()[wppIndex][wppLocalFace] += + constProps.internalDegreesOfFreedom()*invMagUnfA; + + td.cloud().momentumBF()[wppIndex][wppLocalFace] += m*Ut*invMagUnfA; + // pre-interaction energy scalar preIE = 0.5*m*(U_ & U_) + Ei_; @@ -132,27 +179,40 @@ void Foam::DsmcParcel<ParcelType>::hitWallPatch typeId_ ); - // post-interaction energy - scalar postIE = 0.5*m*(U_ & U_) + Ei_; + U_dot_nw = U_ & nw; - // post-interaction momentum - vector postIMom = m*U_; + Ut = U_ - U_dot_nw*nw; - label wppIndex = wpp.index(); + invMagUnfA = 1/max(mag(U_dot_nw)*fA, VSMALL); - label wppLocalFace = wpp.whichFace(this->face()); + td.cloud().rhoNBF()[wppIndex][wppLocalFace] += invMagUnfA; - const scalar fA = mag(wpp.faceAreas()[wppLocalFace]); + td.cloud().rhoMBF()[wppIndex][wppLocalFace] += m*invMagUnfA; + + td.cloud().linearKEBF()[wppIndex][wppLocalFace] += + 0.5*m*(U_ & U_)*invMagUnfA; + + td.cloud().internalEBF()[wppIndex][wppLocalFace] += Ei_*invMagUnfA; - const scalar deltaT = td.cloud().cachedDeltaT(); + td.cloud().iDofBF()[wppIndex][wppLocalFace] += + constProps.internalDegreesOfFreedom()*invMagUnfA; + + td.cloud().momentumBF()[wppIndex][wppLocalFace] += m*Ut*invMagUnfA; + + // post-interaction energy + scalar postIE = 0.5*m*(U_ & U_) + Ei_; + + // post-interaction momentum + vector postIMom = m*U_; scalar deltaQ = td.cloud().nParticle()*(preIE - postIE)/(deltaT*fA); vector deltaFD = td.cloud().nParticle()*(preIMom - postIMom)/(deltaT*fA); - td.cloud().q().boundaryField()[wppIndex][wppLocalFace] += deltaQ; + td.cloud().qBF()[wppIndex][wppLocalFace] += deltaQ; + + td.cloud().fDBF()[wppIndex][wppLocalFace] += deltaFD; - td.cloud().fD().boundaryField()[wppIndex][wppLocalFace] += deltaFD; } @@ -212,4 +272,3 @@ void Foam::DsmcParcel<ParcelType>::transformProperties #include "DsmcParcelIO.C" // ************************************************************************* // - diff --git a/src/lagrangian/dsmc/parcels/derived/dsmcParcel/makeDsmcParcelWallInteractionModels.C b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/makeDsmcParcelWallInteractionModels.C index f15d0bdadd6090c6a39f4403abb97d69015ce91e..b67f66ec8590f1b0adf8e378117e28bb005aca7f 100644 --- a/src/lagrangian/dsmc/parcels/derived/dsmcParcel/makeDsmcParcelWallInteractionModels.C +++ b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/makeDsmcParcelWallInteractionModels.C @@ -28,6 +28,7 @@ License #include "DsmcCloud.H" #include "MaxwellianThermal.H" #include "SpecularReflection.H" +#include "MixedDiffuseSpecular.H" namespace Foam { @@ -46,6 +47,12 @@ namespace Foam DsmcCloud, dsmcParcel ); + makeWallInteractionModelType + ( + MixedDiffuseSpecular, + DsmcCloud, + dsmcParcel + ); }; diff --git a/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.C b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.C index 03fc89d032ce48bdd93b61763c67cd7781e0a374..1df22c68d5a34f04bdcd01bbdd9fe06b402536ad 100644 --- a/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.C +++ b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.C @@ -129,7 +129,7 @@ void Foam::FreeStream<CloudType>::inflow() const polyMesh& mesh(cloud.mesh()); - const scalar deltaT = cloud.cachedDeltaT(); + const scalar deltaT = mesh.time().deltaTValue(); Random& rndGen(cloud.rndGen()); @@ -139,12 +139,12 @@ void Foam::FreeStream<CloudType>::inflow() const volScalarField::GeometricBoundaryField& boundaryT ( - cloud.T().boundaryField() + cloud.boundaryT().boundaryField() ); const volVectorField::GeometricBoundaryField& boundaryU ( - cloud.U().boundaryField() + cloud.boundaryU().boundaryField() ); forAll(patches_, p) @@ -168,7 +168,8 @@ void Foam::FreeStream<CloudType>::inflow() if (min(boundaryT[patchI]) < SMALL) { FatalErrorIn ("Foam::FreeStream<CloudType>::inflow()") - << "Zero boundary temperature detected, check boundaryT condition." << nl + << "Zero boundary temperature detected, check boundaryT " + << "condition." << nl << nl << abort(FatalError); } diff --git a/src/lagrangian/dsmc/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.C b/src/lagrangian/dsmc/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.C index 569e9b21e625ea0a327be582c8e8bfdfa4ca7978..38890400c87be761831ea6924ae67038435ba0d5 100644 --- a/src/lagrangian/dsmc/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.C +++ b/src/lagrangian/dsmc/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.C @@ -71,10 +71,10 @@ void Foam::MaxwellianThermal<CloudType>::correct nw /= mag(nw); // Normal velocity magnitude - scalar magUn = U & nw; + scalar U_dot_nw = U & nw; // Wall tangential velocity (flow direction) - vector Ut = U - magUn*nw; + vector Ut = U - U_dot_nw*nw; CloudType& cloud(this->owner()); @@ -93,9 +93,9 @@ void Foam::MaxwellianThermal<CloudType>::correct U.z()*(0.8 + 0.2*rndGen.scalar01()) ); - magUn = U & nw; + U_dot_nw = U & nw; - Ut = U - magUn*nw; + Ut = U - U_dot_nw*nw; } // Wall tangential unit vector @@ -104,7 +104,7 @@ void Foam::MaxwellianThermal<CloudType>::correct // Other tangential unit vector vector tw2 = nw^tw1; - scalar T = cloud.T().boundaryField()[wppIndex][wppLocalFace]; + scalar T = cloud.boundaryT().boundaryField()[wppIndex][wppLocalFace]; scalar mass = cloud.constProps(typeId).mass(); @@ -118,7 +118,7 @@ void Foam::MaxwellianThermal<CloudType>::correct - sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw ); - U += cloud.U().boundaryField()[wppIndex][wppLocalFace]; + U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace]; Ei = cloud.equipartitionInternalEnergy(T, iDof); } diff --git a/src/lagrangian/dsmc/submodels/WallInteractionModel/MixedDiffuseSpecular/MixedDiffuseSpecular.C b/src/lagrangian/dsmc/submodels/WallInteractionModel/MixedDiffuseSpecular/MixedDiffuseSpecular.C new file mode 100644 index 0000000000000000000000000000000000000000..9f2f5fdc3b304364bed9344a845f7bba38eb537b --- /dev/null +++ b/src/lagrangian/dsmc/submodels/WallInteractionModel/MixedDiffuseSpecular/MixedDiffuseSpecular.C @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-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 + +\*---------------------------------------------------------------------------*/ + +#include "MixedDiffuseSpecular.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::MixedDiffuseSpecular<CloudType>::MixedDiffuseSpecular +( + const dictionary& dict, + CloudType& cloud +) +: + WallInteractionModel<CloudType>(dict, cloud, typeName), + diffuseFraction_(readScalar(this->coeffDict().lookup("diffuseFraction"))) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::MixedDiffuseSpecular<CloudType>::~MixedDiffuseSpecular() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template <class CloudType> +void Foam::MixedDiffuseSpecular<CloudType>::correct +( + const wallPolyPatch& wpp, + const label faceId, + vector& U, + scalar& Ei, + label typeId +) +{ + label wppIndex = wpp.index(); + + label wppLocalFace = wpp.whichFace(faceId); + + vector nw = wpp.faceAreas()[wppLocalFace]; + + // Normal unit vector + nw /= mag(nw); + + // Normal velocity magnitude + scalar U_dot_nw = U & nw; + + CloudType& cloud(this->owner()); + + Random& rndGen(cloud.rndGen()); + + if (diffuseFraction_ > rndGen.scalar01()) + { + // Diffuse reflection + + // Wall tangential velocity (flow direction) + vector Ut = U - U_dot_nw*nw; + + while (mag(Ut) < SMALL) + { + // If the incident velocity is parallel to the face normal, no + // tangential direction can be chosen. Add a perturbation to the + // incoming velocity and recalculate. + + U = vector + ( + U.x()*(0.8 + 0.2*rndGen.scalar01()), + U.y()*(0.8 + 0.2*rndGen.scalar01()), + U.z()*(0.8 + 0.2*rndGen.scalar01()) + ); + + U_dot_nw = U & nw; + + Ut = U - U_dot_nw*nw; + } + + // Wall tangential unit vector + vector tw1 = Ut/mag(Ut); + + // Other tangential unit vector + vector tw2 = nw^tw1; + + scalar T = cloud.boundaryT().boundaryField()[wppIndex][wppLocalFace]; + + scalar mass = cloud.constProps(typeId).mass(); + + scalar iDof = cloud.constProps(typeId).internalDegreesOfFreedom(); + + U = + sqrt(physicoChemical::k.value()*T/mass) + *( + rndGen.GaussNormal()*tw1 + + rndGen.GaussNormal()*tw2 + - sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw + ); + + U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace]; + + Ei = cloud.equipartitionInternalEnergy(T, iDof); + } + else + { + // Specular reflection + + if (U_dot_nw > 0.0) + { + U -= 2.0*U_dot_nw*nw; + } + } + +} + + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamData.h b/src/lagrangian/dsmc/submodels/WallInteractionModel/MixedDiffuseSpecular/MixedDiffuseSpecular.H similarity index 52% rename from applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamData.h rename to src/lagrangian/dsmc/submodels/WallInteractionModel/MixedDiffuseSpecular/MixedDiffuseSpecular.H index ebb0a7ad810dd03a74ecbbfde812ebad3eafdeff..b84f43d8f6ef0ba8e35d874deb2411de2061d2b2 100644 --- a/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamData.h +++ b/src/lagrangian/dsmc/submodels/WallInteractionModel/MixedDiffuseSpecular/MixedDiffuseSpecular.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,46 +23,82 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - vtkFoamData + Foam::MixedDiffuseSpecular Description - -SourceFiles - vtkFoamData.cxx + Wall interaction setting microscopic velocity to a random one drawn from a + Maxwellian distribution corresponding to a specified temperature \*---------------------------------------------------------------------------*/ -#ifndef vtkFoamData_h -#define vtkFoamData_h +#ifndef MixedDiffuseSpecular_H +#define MixedDiffuseSpecular_H -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "WallInteractionModel.H" -#include "vtkDataSetSource.h" +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ /*---------------------------------------------------------------------------*\ - Class vtkFoamData Declaration + Class MixedDiffuseSpecular Declaration \*---------------------------------------------------------------------------*/ -class VTK_IO_EXPORT vtkFoamData -: - public vtkDataSetSource +template<class CloudType> +class MixedDiffuseSpecular +: + public WallInteractionModel<CloudType> { + // Private data + + //- Fraction of wall interactions that are diffuse + scalar diffuseFraction_; + public: - static vtkFoamData *New(); - vtkTypeRevisionMacro(vtkFoamData,vtkDataSetSource); + //- Runtime type information + TypeName("MixedDiffuseSpecular"); + + + // Constructors + + //- Construct from dictionary + MixedDiffuseSpecular + ( + const dictionary& dict, + CloudType& cloud + ); + - vtkFoamData(); - ~vtkFoamData(); + // Destructor + virtual ~MixedDiffuseSpecular(); - void SetNthOutput(int num, vtkDataObject *output) - { - vtkDataSetSource::SetNthOutput(num, output); - } + + // Member Functions + + //- Apply wall correction + virtual void correct + ( + const wallPolyPatch& wpp, + const label faceId, + vector& U, + scalar& Ei, + label typeId + ); }; +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "MixedDiffuseSpecular.C" +#endif + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/lagrangian/dsmc/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.C b/src/lagrangian/dsmc/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.C index 1fb5ab3208404f235f264a54035c27263edac463..bed84b8c68151ae86a8c8f250e27289499a73966 100644 --- a/src/lagrangian/dsmc/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.C +++ b/src/lagrangian/dsmc/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.C @@ -63,11 +63,11 @@ void Foam::SpecularReflection<CloudType>::correct vector nw = wpp.faceAreas()[wpp.whichFace(faceId)]; nw /= mag(nw); - scalar magUn = U & nw; + scalar U_dot_nw = U & nw; - if (magUn > 0.0) + if (U_dot_nw > 0.0) { - U -= 2.0*magUn*nw; + U -= 2.0*U_dot_nw*nw; } } diff --git a/src/lagrangian/molecularDynamics/molecularMeasurements/distribution/distribution.C b/src/lagrangian/molecularDynamics/molecularMeasurements/distribution/distribution.C index 439ed64bdf06229f8b13fd6424a9336f14f43187..7cc9e70c0ef6413a086dc1f33c8aefdaaa242840 100644 --- a/src/lagrangian/molecularDynamics/molecularMeasurements/distribution/distribution.C +++ b/src/lagrangian/molecularDynamics/molecularMeasurements/distribution/distribution.C @@ -25,27 +25,49 @@ License \*----------------------------------------------------------------------------*/ #include "distribution.H" +#include "OFstream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { + defineTypeNameAndDebug(distribution, 0); +} + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +void Foam::distribution::write +( + const fileName& file, + const List<Pair<scalar> >& pairs +) +{ + OFstream os(file); + + forAll(pairs, i) + { + os << pairs[i].first() << ' ' << pairs[i].second() << nl; + } +} + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -distribution::distribution() +Foam::distribution::distribution() : Map<label>(), binWidth_(1) {} -distribution::distribution(const scalar binWidth) +Foam::distribution::distribution(const scalar binWidth) : Map<label>(), binWidth_(binWidth) {} -distribution::distribution(const distribution& d) +Foam::distribution::distribution(const distribution& d) : Map<label>(static_cast< Map<label> >(d)), binWidth_(d.binWidth()) @@ -54,13 +76,13 @@ distribution::distribution(const distribution& d) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -distribution::~distribution() +Foam::distribution::~distribution() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -label distribution::totalEntries() const +Foam::label Foam::distribution::totalEntries() const { label sumOfEntries = 0; @@ -88,7 +110,7 @@ label distribution::totalEntries() const } -scalar distribution::approxTotalEntries() const +Foam::scalar Foam::distribution::approxTotalEntries() const { scalar sumOfEntries = 0; @@ -101,7 +123,7 @@ scalar distribution::approxTotalEntries() const } -scalar distribution::mean() const +Foam::scalar Foam::distribution::mean() const { scalar runningSum = 0; @@ -124,7 +146,7 @@ scalar distribution::mean() const } -scalar distribution::median() +Foam::scalar Foam::distribution::median() { // From: // http://mathworld.wolfram.com/StatisticalMedian.html @@ -188,7 +210,7 @@ scalar distribution::median() } -void distribution::add(const scalar valueToAdd) +void Foam::distribution::add(const scalar valueToAdd) { iterator iter(this->begin()); @@ -218,13 +240,13 @@ void distribution::add(const scalar valueToAdd) } -void distribution::add(const label valueToAdd) +void Foam::distribution::add(const label valueToAdd) { add(scalar(valueToAdd)); } -void distribution::insertMissingKeys() +void Foam::distribution::insertMissingKeys() { iterator iter(this->begin()); @@ -247,7 +269,7 @@ void distribution::insertMissingKeys() } -List< Pair<scalar> > distribution::normalised() +Foam::List<Foam::Pair<Foam::scalar> > Foam::distribution::normalised() { scalar totEnt = approxTotalEntries(); @@ -268,17 +290,25 @@ List< Pair<scalar> > distribution::normalised() normDist[k].second() = scalar((*this)[key])/totEnt/binWidth_; } + if (debug) + { + Info<< "totEnt: " << totEnt << endl; + } + return normDist; } -List< Pair<scalar> > distribution::normalisedMinusMean() +Foam::List<Foam::Pair<Foam::scalar> > Foam::distribution::normalisedMinusMean() { return normalisedShifted(mean()); } -List< Pair<scalar> > distribution::normalisedShifted(const scalar shiftValue) +Foam::List<Foam::Pair<Foam::scalar> > Foam::distribution::normalisedShifted +( + scalar shiftValue +) { List<Pair<scalar> > oldDist(normalised()); @@ -301,20 +331,23 @@ List< Pair<scalar> > distribution::normalisedShifted(const scalar shiftValue) label newKey = lowestNewKey; -// Info << shiftValue -// << nl << lowestOldBin -// << nl << lowestNewKey -// << nl << interpolationStartDirection -// << endl; + if (debug) + { + Info<< shiftValue + << nl << lowestOldBin + << nl << lowestNewKey + << nl << interpolationStartDirection + << endl; -// scalar checkNormalisation = 0; + scalar checkNormalisation = 0; -// forAll (oldDist, oD) -// { -// checkNormalisation += oldDist[oD].second()*binWidth_; -// } + forAll (oldDist, oD) + { + checkNormalisation += oldDist[oD].second()*binWidth_; + } -// Info << "Initial normalisation = " << checkNormalisation << endl; + Info<< "Initial normalisation = " << checkNormalisation << endl; + } forAll(oldDist,u) { @@ -368,20 +401,23 @@ List< Pair<scalar> > distribution::normalisedShifted(const scalar shiftValue) newKey++; } -// checkNormalisation = 0; + if (debug) + { + scalar checkNormalisation = 0; -// forAll (newDist, nD) -// { -// checkNormalisation += newDist[nD].second()*binWidth_; -// } + forAll (newDist, nD) + { + checkNormalisation += newDist[nD].second()*binWidth_; + } -// Info << "Shifted normalisation = " << checkNormalisation << endl; + Info<< "Shifted normalisation = " << checkNormalisation << endl; + } return newDist; } -List<Pair<scalar> > distribution::raw() +Foam::List<Foam::Pair<Foam::scalar> > Foam::distribution::raw() { insertMissingKeys(); @@ -406,7 +442,7 @@ List<Pair<scalar> > distribution::raw() // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -void distribution::operator=(const distribution& rhs) +void Foam::distribution::operator=(const distribution& rhs) { // Check for assignment to self if (this == &rhs) @@ -424,7 +460,7 @@ void distribution::operator=(const distribution& rhs) // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // -Ostream& operator<<(Ostream& os, const distribution& d) +Foam::Ostream& Foam::operator<<(Ostream& os, const distribution& d) { os << d.binWidth_ << static_cast<const Map<label>&>(d); @@ -440,8 +476,4 @@ Ostream& operator<<(Ostream& os, const distribution& d) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/lagrangian/molecularDynamics/molecularMeasurements/distribution/distribution.H b/src/lagrangian/molecularDynamics/molecularMeasurements/distribution/distribution.H index da1ce973bc7d3fa9dceabbcf4dd2e5f2b39a1b87..d86ae83934966791471978c1e657d1ce6a7f346c 100644 --- a/src/lagrangian/molecularDynamics/molecularMeasurements/distribution/distribution.H +++ b/src/lagrangian/molecularDynamics/molecularMeasurements/distribution/distribution.H @@ -26,6 +26,8 @@ Class Foam::distribution Description + Accumulating histogram of values. Specified bin resolution + automatic generation of bins. SourceFiles distributionI.H @@ -59,6 +61,21 @@ class distribution public: + //- Runtime type information + + TypeName("distribution"); + + // Static functions + + //- write to file + + static void write + ( + const fileName& file, + const List<Pair<scalar> >& pairs + ); + + // Constructors //- Construct null @@ -73,7 +90,7 @@ public: // Destructor - ~distribution(); + virtual ~distribution(); // Member Functions @@ -97,7 +114,7 @@ public: List<Pair<scalar> > normalisedMinusMean(); - List<Pair<scalar> > normalisedShifted(const scalar shiftValue); + List<Pair<scalar> > normalisedShifted(scalar shiftValue); List<Pair<scalar> > raw(); diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C index eac6499043d5036b7beef61b43baf64e3d34e00b..4544afdc459e53f955710bf11c770f2381cb682a 100644 --- a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C +++ b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C @@ -110,6 +110,7 @@ void Foam::dsmcFields::write() word linearKEMeanName = "linearKEMean"; word internalEMeanName = "internalEMean"; word iDofMeanName = "iDofMean"; + word fDMeanName = "fDMean"; const volScalarField& rhoNMean = obr_.lookupObject<volScalarField> ( @@ -141,6 +142,11 @@ void Foam::dsmcFields::write() iDofMeanName ); + volVectorField fDMean = obr_.lookupObject<volVectorField> + ( + fDMeanName + ); + if (min(mag(rhoNMean)).value() > VSMALL) { Info<< "Calculating dsmcFields." << endl; @@ -168,8 +174,9 @@ void Foam::dsmcFields::write() obr_, IOobject::NO_READ ), + 2.0/(3.0*physicoChemical::k.value()*rhoNMean) - *(linearKEMean - 0.5*rhoMMean*(UMean & UMean)) + *(linearKEMean - 0.5*rhoMMean*(UMean & UMean)) ); Info<< " Calculating internalT field." << endl; @@ -182,7 +189,7 @@ void Foam::dsmcFields::write() obr_, IOobject::NO_READ ), - 2.0/(physicoChemical::k.value()*iDofMean)*internalEMean + (2.0/physicoChemical::k.value())*(internalEMean/iDofMean) ); Info<< " Calculating overallT field." << endl; @@ -196,9 +203,36 @@ void Foam::dsmcFields::write() IOobject::NO_READ ), 2.0/(physicoChemical::k.value()*(3.0*rhoNMean + iDofMean)) - *(linearKEMean - 0.5*rhoMMean*(UMean & UMean) + internalEMean) + *(linearKEMean - 0.5*rhoMMean*(UMean & UMean) + internalEMean) + ); + + Info<< " Calculating pressure field." << endl; + volScalarField p + ( + IOobject + ( + "p", + obr_.time().timeName(), + obr_, + IOobject::NO_READ + ), + physicoChemical::k.value()*rhoNMean*translationalT ); + const fvMesh& mesh = fDMean.mesh(); + + forAll(mesh.boundaryMesh(), i) + { + const polyPatch& patch = mesh.boundaryMesh()[i]; + + if (isA<wallPolyPatch>(patch)) + { + p.boundaryField()[i] = + fDMean.boundaryField()[i] + & (patch.faceAreas()/mag(patch.faceAreas())); + } + } + Info<< " mag(UMean) max/min : " << max(mag(UMean)).value() << " " << min(mag(UMean)).value() << endl; @@ -215,6 +249,10 @@ void Foam::dsmcFields::write() << max(overallT).value() << " " << min(overallT).value() << endl; + Info<< " p max/min : " + << max(p).value() << " " + << min(p).value() << endl; + UMean.write(); translationalT.write(); @@ -223,6 +261,8 @@ void Foam::dsmcFields::write() overallT.write(); + p.write(); + Info<< "dsmcFields written." << nl << endl; } else diff --git a/src/turbulenceModels/compressible/RAS/Make/files b/src/turbulenceModels/compressible/RAS/Make/files index 6fa7d7e9634651106073bad239bcbd4b14e086ca..def806534ab52e722648072d881ea925b7fcb51b 100644 --- a/src/turbulenceModels/compressible/RAS/Make/files +++ b/src/turbulenceModels/compressible/RAS/Make/files @@ -38,8 +38,8 @@ derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFv derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C derivedFvPatchFields/turbulentTemperatureCoupledBaffle/turbulentTemperatureCoupledBaffleFvPatchScalarField.C +derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C derivedFvPatchFields/turbulentTemperatureCoupledBaffle/regionProperties.C - backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C LIB = $(FOAM_LIBBIN)/libcompressibleRASModels diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffle/turbulentTemperatureCoupledBaffleFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffle/turbulentTemperatureCoupledBaffleFvPatchScalarField.C index 52a358f53207abe4be4db19a38d70155ae314a4a..bc3c56c2f052d8ed69bec67a0e02b60789d333d2 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffle/turbulentTemperatureCoupledBaffleFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffle/turbulentTemperatureCoupledBaffleFvPatchScalarField.C @@ -33,16 +33,9 @@ License #include "basicThermo.H" #include "RASModel.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace compressible -{ - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -bool turbulentTemperatureCoupledBaffleFvPatchScalarField::interfaceOwner +bool Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField::interfaceOwner ( const polyMesh& nbrRegion, const polyPatch& nbrPatch @@ -103,6 +96,7 @@ bool turbulentTemperatureCoupledBaffleFvPatchScalarField::interfaceOwner } nbrIndex = props.fluidRegionNames().size() + i; } + return myIndex < nbrIndex; } } @@ -110,25 +104,20 @@ bool turbulentTemperatureCoupledBaffleFvPatchScalarField::interfaceOwner // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -turbulentTemperatureCoupledBaffleFvPatchScalarField:: +Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField:: turbulentTemperatureCoupledBaffleFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF ) : - mixedFvPatchScalarField(p, iF), + fixedValueFvPatchScalarField(p, iF), neighbourFieldName_("undefined-neighbourFieldName"), KName_("undefined-K") -{ - this->refValue() = 0.0; - this->refGrad() = 0.0; - this->valueFraction() = 1.0; - this->fixesValue_ = true; -} +{} -turbulentTemperatureCoupledBaffleFvPatchScalarField:: +Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField:: turbulentTemperatureCoupledBaffleFvPatchScalarField ( const turbulentTemperatureCoupledBaffleFvPatchScalarField& ptf, @@ -137,14 +126,13 @@ turbulentTemperatureCoupledBaffleFvPatchScalarField const fvPatchFieldMapper& mapper ) : - mixedFvPatchScalarField(ptf, p, iF, mapper), + fixedValueFvPatchScalarField(ptf, p, iF, mapper), neighbourFieldName_(ptf.neighbourFieldName_), - KName_(ptf.KName_), - fixesValue_(ptf.fixesValue_) + KName_(ptf.KName_) {} -turbulentTemperatureCoupledBaffleFvPatchScalarField:: +Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField:: turbulentTemperatureCoupledBaffleFvPatchScalarField ( const fvPatch& p, @@ -152,7 +140,7 @@ turbulentTemperatureCoupledBaffleFvPatchScalarField const dictionary& dict ) : - mixedFvPatchScalarField(p, iF), + fixedValueFvPatchScalarField(p, iF, dict), neighbourFieldName_(dict.lookup("neighbourFieldName")), KName_(dict.lookup("K")) { @@ -174,46 +162,26 @@ turbulentTemperatureCoupledBaffleFvPatchScalarField << " 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()); - fixesValue_ = readBool(dict.lookup("fixesValue")); - } - else - { - // Start from user entered data. Assume fixedValue. - refValue() = *this; - refGrad() = 0.0; - valueFraction() = 1.0; - fixesValue_ = true; - } } -turbulentTemperatureCoupledBaffleFvPatchScalarField:: +Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField:: turbulentTemperatureCoupledBaffleFvPatchScalarField ( const turbulentTemperatureCoupledBaffleFvPatchScalarField& wtcsf, const DimensionedField<scalar, volMesh>& iF ) : - mixedFvPatchScalarField(wtcsf, iF), + fixedValueFvPatchScalarField(wtcsf, iF), neighbourFieldName_(wtcsf.neighbourFieldName_), - KName_(wtcsf.KName_), - fixesValue_(wtcsf.fixesValue_) + KName_(wtcsf.KName_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -tmp<scalarField> -turbulentTemperatureCoupledBaffleFvPatchScalarField::K() const +Foam::tmp<Foam::scalarField> +Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField::K() const { const fvMesh& mesh = patch().boundaryMesh().mesh(); @@ -260,7 +228,7 @@ turbulentTemperatureCoupledBaffleFvPatchScalarField::K() const } -void turbulentTemperatureCoupledBaffleFvPatchScalarField::updateCoeffs() +void Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField::updateCoeffs() { if (updated()) { @@ -353,18 +321,13 @@ void turbulentTemperatureCoupledBaffleFvPatchScalarField::updateCoeffs() ).fvPatchScalarField::operator=(Twall); } - - // Switch between fixed value (of harmonic avg) or gradient - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - label nFixed = 0; - - // Like snGrad but bypass switching on refValue/refGrad. - tmp<scalarField> normalGradient = (*this-intFld())*patch().deltaCoeffs(); - if (debug) { - scalar Q = gSum(K()*patch().magSf()*normalGradient()); + //tmp<scalarField> normalGradient = + // (*this-intFld()) + // * patch().deltaCoeffs(); + + scalar Q = gSum(K()*patch().magSf()*snGrad()); Info<< patch().boundaryMesh().mesh().name() << ':' << patch().name() << ':' @@ -380,74 +343,33 @@ void turbulentTemperatureCoupledBaffleFvPatchScalarField::updateCoeffs() << endl; } - forAll(*this, i) - { - // if outgoing flux use fixed value. - if (normalGradient()[i] < 0.0) - { - this->refValue()[i] = operator[](i); - this->refGrad()[i] = 0.0; // not used - this->valueFraction()[i] = 1.0; - nFixed++; - } - else - { - this->refValue()[i] = 0.0; // not used - this->refGrad()[i] = normalGradient()[i]; - this->valueFraction()[i] = 0.0; - } - } - - reduce(nFixed, sumOp<label>()); - - fixesValue_ = (nFixed > 0); - - if (debug) - { - label nTotSize = returnReduce(this->size(), sumOp<label>()); - - Info<< patch().boundaryMesh().mesh().name() << ':' - << patch().name() << ':' - << this->dimensionedInternalField().name() << " -> " - << nbrMesh.name() << ':' - << nbrPatch.name() << ':' - << this->dimensionedInternalField().name() << " :" - << " patch:" << patch().name() - << " out of:" << nTotSize - << " fixedBC:" << nFixed - << " gradient:" << nTotSize-nFixed << endl; - } - - mixedFvPatchScalarField::updateCoeffs(); + fixedValueFvPatchScalarField::updateCoeffs(); } -void turbulentTemperatureCoupledBaffleFvPatchScalarField::write +void Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField::write ( Ostream& os ) const { - mixedFvPatchScalarField::write(os); + fixedValueFvPatchScalarField::write(os); os.writeKeyword("neighbourFieldName")<< neighbourFieldName_ << token::END_STATEMENT << nl; os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; - os.writeKeyword("fixesValue") << fixesValue_ << token::END_STATEMENT << nl; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ + makePatchTypeField ( fvPatchScalarField, turbulentTemperatureCoupledBaffleFvPatchScalarField ); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace compressible } // End namespace Foam - // ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffle/turbulentTemperatureCoupledBaffleFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffle/turbulentTemperatureCoupledBaffleFvPatchScalarField.H index 9e13167a62743756c5eba979e544c4ddffa026e7..717f6b1e7cbe3c4dce283e6e405628bf9e6fa6c3 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffle/turbulentTemperatureCoupledBaffleFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffle/turbulentTemperatureCoupledBaffleFvPatchScalarField.H @@ -23,16 +23,15 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::compressible::turbulentTemperatureCoupledBaffleFvPatchScalarField + turbulentTemperatureCoupledBaffleFvPatchScalarField Description - Mixed boundary condition for temperature, to be used for heat-transfer - on back-to-back baffles. + Harmonic fixed value boundary condition for temperature, to be used + for heat-transfer on back-to-back baffles. - If my temperature is T1, neighbour is T2: + If my temperature is T1, heat conductivity K1 and neighbour is T2,K2 - T1 > T2: my side becomes fixedValue T2 bc, other side becomes fixedGradient. - + both sides get fixedValue (K1/dx1*T1 + K2/dx2*T2)/(K1/dx1+K2/dx2) Example usage: myInterfacePatchName @@ -65,16 +64,12 @@ SourceFiles #ifndef turbulentTemperatureCoupledBaffleFvPatchScalarField_H #define turbulentTemperatureCoupledBaffleFvPatchScalarField_H -//#include "fvPatchFields.H" -#include "mixedFvPatchFields.H" -//#include "fvPatch.H" +#include "fixedValueFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -namespace compressible -{ /*---------------------------------------------------------------------------*\ Class turbulentTemperatureCoupledBaffleFvPatchScalarField Declaration @@ -82,7 +77,7 @@ namespace compressible class turbulentTemperatureCoupledBaffleFvPatchScalarField : - public mixedFvPatchScalarField + public fixedValueFvPatchScalarField { // Private data @@ -92,8 +87,6 @@ class turbulentTemperatureCoupledBaffleFvPatchScalarField //- Name of thermal conductivity field const word KName_; - bool fixesValue_; - // Private Member Functions @@ -104,7 +97,7 @@ class turbulentTemperatureCoupledBaffleFvPatchScalarField public: //- Runtime type information - TypeName("compressible::turbulentTemperatureCoupledBaffle"); + TypeName("turbulentTemperatureCoupledBaffle"); // Constructors @@ -172,14 +165,6 @@ public: //- Get corresponding K field tmp<scalarField> K() const; - //- Return true if this patch field fixes a value. - // Needed to check if a level has to be specified while solving - // Poissons equations. - virtual bool fixesValue() const - { - return fixesValue_; - } - //- Update the coefficients associated with the patch field virtual void updateCoeffs(); @@ -190,7 +175,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace compressible } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..c44ec7656c15571ac5e23b0d07cb5578c19c6a5e --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C @@ -0,0 +1,458 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +\*---------------------------------------------------------------------------*/ + +#include "turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "directMappedPatchBase.H" +#include "regionProperties.H" +#include "basicThermo.H" +#include "RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::interfaceOwner +( + const polyMesh& nbrRegion, + const polyPatch& nbrPatch +) const +{ + const fvMesh& myRegion = patch().boundaryMesh().mesh(); + + if (nbrRegion.name() == myRegion.name()) + { + return patch().index() < nbrPatch.index(); + } + else + { + const regionProperties& props = + myRegion.objectRegistry::parent().lookupObject<regionProperties> + ( + "regionProperties" + ); + + label myIndex = findIndex(props.fluidRegionNames(), myRegion.name()); + if (myIndex == -1) + { + label i = findIndex(props.solidRegionNames(), myRegion.name()); + + if (i == -1) + { + FatalErrorIn + ( + "turbulentTemperatureCoupledBaffleMixedFvPatchScalarField" + "::interfaceOwner(const polyMesh&" + ", const polyPatch&)const" + ) << "Cannot find region " << myRegion.name() + << " neither in fluids " << props.fluidRegionNames() + << " nor in solids " << props.solidRegionNames() + << exit(FatalError); + } + myIndex = props.fluidRegionNames().size() + i; + } + label nbrIndex = findIndex + ( + props.fluidRegionNames(), + nbrRegion.name() + ); + if (nbrIndex == -1) + { + label i = findIndex(props.solidRegionNames(), nbrRegion.name()); + + if (i == -1) + { + FatalErrorIn + ( + "coupleManager::interfaceOwner" + "(const polyMesh&, const polyPatch&) const" + ) << "Cannot find region " << nbrRegion.name() + << " neither in fluids " << props.fluidRegionNames() + << " nor in solids " << props.solidRegionNames() + << exit(FatalError); + } + nbrIndex = props.fluidRegionNames().size() + i; + } + return myIndex < nbrIndex; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField:: +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchScalarField(p, iF), + neighbourFieldName_("undefined-neighbourFieldName"), + KName_("undefined-K") +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 1.0; + this->fixesValue_ = true; +} + + +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField:: +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField +( + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + neighbourFieldName_(ptf.neighbourFieldName_), + KName_(ptf.KName_), + fixesValue_(ptf.fixesValue_) +{} + + +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField:: +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + neighbourFieldName_(dict.lookup("neighbourFieldName")), + KName_(dict.lookup("K")) +{ + if (!isA<directMappedPatchBase>(this->patch().patch())) + { + FatalErrorIn + ( + "turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::" + "turbulentTemperatureCoupledBaffleMixedFvPatchScalarField\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()); + fixesValue_ = readBool(dict.lookup("fixesValue")); + } + else + { + // Start from user entered data. Assume fixedValue. + refValue() = *this; + refGrad() = 0.0; + valueFraction() = 1.0; + fixesValue_ = true; + } +} + + +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField:: +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField +( + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField& wtcsf, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchScalarField(wtcsf, iF), + neighbourFieldName_(wtcsf.neighbourFieldName_), + KName_(wtcsf.KName_), + fixesValue_(wtcsf.fixesValue_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp<scalarField> +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::K() const +{ + const fvMesh& mesh = patch().boundaryMesh().mesh(); + + if (KName_ == "none") + { + const compressible::RASModel& model = + db().lookupObject<compressible::RASModel>("RASProperties"); + + tmp<volScalarField> talpha = model.alphaEff(); + + const basicThermo& thermo = + db().lookupObject<basicThermo>("thermophysicalProperties"); + + return + talpha().boundaryField()[patch().index()] + *thermo.Cp()().boundaryField()[patch().index()]; + } + else 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 + ( + "turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::K()" + " const" + ) << "Did not find field " << KName_ + << " on mesh " << mesh.name() << " patch " << patch().name() + << endl + << "Please set 'K' to 'none', a valid volScalarField" + << " or a valid volSymmTensorField." << exit(FatalError); + + return scalarField(0); + } +} + + +void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs() +{ + 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(); + (void)distMap.schedule(); + + tmp<scalarField> intFld = patchInternalField(); + + if (interfaceOwner(nbrMesh, nbrPatch.patch())) + { + // Note: other side information could be cached - it only needs + // to be updated the first time round the iteration (i.e. when + // switching regions) but unfortunately we don't have this information. + + + // Calculate the temperature by harmonic averaging + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField& + nbrField = + refCast + < + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField + > + ( + 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 + scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs(); + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + distMap.constructSize(), + distMap.subMap(), // what to send + distMap.constructMap(), // what to receive + nbrKDelta + ); + + tmp<scalarField> myKDelta = K()*patch().deltaCoeffs(); + + // Calculate common wall temperature. Reuse *this to store common value. + scalarField Twall + ( + (myKDelta()*intFld() + nbrKDelta*nbrIntFld) + / (myKDelta() + nbrKDelta) + ); + // Assign to me + fvPatchScalarField::operator=(Twall); + // Distribute back and assign to neighbour + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + nbrField.size(), + distMap.constructMap(), // reverse : what to send + distMap.subMap(), + Twall + ); + const_cast<turbulentTemperatureCoupledBaffleMixedFvPatchScalarField&> + ( + nbrField + ).fvPatchScalarField::operator=(Twall); + } + + + // Switch between fixed value (of harmonic avg) or gradient + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + label nFixed = 0; + + // Like snGrad but bypass switching on refValue/refGrad. + tmp<scalarField> normalGradient = (*this-intFld())*patch().deltaCoeffs(); + + if (debug) + { + scalar Q = gSum(K()*patch().magSf()*normalGradient()); + + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << this->dimensionedInternalField().name() << " -> " + << nbrMesh.name() << ':' + << nbrPatch.name() << ':' + << this->dimensionedInternalField().name() << " :" + << " heatFlux:" << Q + << " walltemperature " + << " min:" << gMin(*this) + << " max:" << gMax(*this) + << " avg:" << gAverage(*this) + << endl; + } + + forAll(*this, i) + { + // if outgoing flux use fixed value. + if (normalGradient()[i] < 0.0) + { + this->refValue()[i] = operator[](i); + this->refGrad()[i] = 0.0; // not used + this->valueFraction()[i] = 1.0; + nFixed++; + } + else + { + this->refValue()[i] = 0.0; // not used + this->refGrad()[i] = normalGradient()[i]; + this->valueFraction()[i] = 0.0; + } + } + + reduce(nFixed, sumOp<label>()); + + fixesValue_ = (nFixed > 0); + + if (debug) + { + label nTotSize = returnReduce(this->size(), sumOp<label>()); + + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << this->dimensionedInternalField().name() << " -> " + << nbrMesh.name() << ':' + << nbrPatch.name() << ':' + << this->dimensionedInternalField().name() << " :" + << " patch:" << patch().name() + << " out of:" << nTotSize + << " fixedBC:" << nFixed + << " gradient:" << nTotSize-nFixed << endl; + } + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::write +( + Ostream& os +) const +{ + mixedFvPatchScalarField::write(os); + os.writeKeyword("neighbourFieldName")<< neighbourFieldName_ + << token::END_STATEMENT << nl; + os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; + os.writeKeyword("fixesValue") << fixesValue_ << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..d4fe1d06fd16c09b74405c288fe42871cf61eaa8 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H @@ -0,0 +1,204 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + Foam::compressible::turbulentTemperatureCoupledBaffleMixedFvPatchScalarField + +Description + Mixed boundary condition for temperature, to be used for heat-transfer + on back-to-back baffles. + + If my temperature is T1, neighbour is T2: + + T1 > T2: my side becomes fixedValue T2 bc, other side becomes fixedGradient. + + + Example usage: + myInterfacePatchName + { + type turbulentTemperatureCoupledBaffleMixed; + neighbourFieldName T; + K K; // or none + value uniform 300; + } + + Needs to be on underlying directMapped(Wall)FvPatch. + + Note: if K is "none" looks up RASModel and basicThermo, otherwise expects + the solver to calculate a 'K' field. + + Note: runs in parallel with arbitrary decomposition. Uses directMapped + functionality to calculate exchange. + + Note: lags interface data so both sides use same data. + - problem: schedule to calculate average would interfere + with standard processor swaps. + - so: updateCoeffs sets both to same Twall. Only need to do + this for last outer iteration but don't have access to this. + +SourceFiles + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef turbulentTemperatureCoupledBaffleMixedFvPatchScalarField_H +#define turbulentTemperatureCoupledBaffleMixedFvPatchScalarField_H + +//#include "fvPatchFields.H" +#include "mixedFvPatchFields.H" +//#include "fvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +/*---------------------------------------------------------------------------*\ + Class turbulentTemperatureCoupledBaffleMixedFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class turbulentTemperatureCoupledBaffleMixedFvPatchScalarField +: + public mixedFvPatchScalarField +{ + // Private data + + //- Name of field on the neighbour region + const word neighbourFieldName_; + + //- Name of thermal conductivity field + const word KName_; + + bool fixesValue_; + + + // Private Member Functions + + //- Am I or neighbour owner of interface + bool interfaceOwner(const polyMesh&, const polyPatch&) const; + + +public: + + //- Runtime type information + TypeName("compressible::turbulentTemperatureCoupledBaffleMixed"); + + + // Constructors + + //- Construct from patch and internal field + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // turbulentTemperatureCoupledBaffleMixedFvPatchScalarField onto a + // new patch + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField + ( + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new turbulentTemperatureCoupledBaffleMixedFvPatchScalarField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField + ( + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField&, + 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 turbulentTemperatureCoupledBaffleMixedFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + //- Get corresponding K field + tmp<scalarField> K() const; + + //- Return true if this patch field fixes a value. + // Needed to check if a level has to be specified while solving + // Poissons equations. + virtual bool fixesValue() const + { + return fixesValue_; + } + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/iDof b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/iDof index 4f081fa179a0422cd94a93f612b19642f8a65a30..1e13af9370f63157d67336a43f8506b935b100bd 100644 --- a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/iDof +++ b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/iDof @@ -32,7 +32,8 @@ boundaryField walls { - type zeroGradient; + type calculated; + value uniform 0; } } diff --git a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/internalE b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/internalE index 8bf198ceaef2722f8ffc0ec035134eacb1b811fe..976ec30e748377cdf28804e7eafffd9678af758d 100644 --- a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/internalE +++ b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/internalE @@ -32,7 +32,8 @@ boundaryField walls { - type zeroGradient; + type calculated; + value uniform 0; } } diff --git a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/linearKE b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/linearKE index f05be3b1c8420ccf544949ddcfa974b65d97bda9..b26e99313c337f33fdd5fb3a6014ddfc4be6bf1f 100644 --- a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/linearKE +++ b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/linearKE @@ -32,7 +32,8 @@ boundaryField walls { - type zeroGradient; + type calculated; + value uniform 0; } } diff --git a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/momentum b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/momentum index 244901de0c415b351cdeebe51ea07045411219a6..05d234bd2a9faeea9e3be9f3704f6c70332adf85 100644 --- a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/momentum +++ b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/momentum @@ -32,7 +32,8 @@ boundaryField walls { - type zeroGradient; + type calculated; + value uniform (0 0 0); } } diff --git a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/rhoM b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/rhoM index fa4dec993be1da096d12025ec261540e90be66dc..7ec6f3368f6ffb0e880a51f0cf7caf0d5fe7dd08 100644 --- a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/rhoM +++ b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/rhoM @@ -32,7 +32,8 @@ boundaryField walls { - type zeroGradient; + type calculated; + value uniform 0; } } diff --git a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/rhoN b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/rhoN index cd16296be931f3e54ad743e68165113548372821..f847c22cd09bcd571c103f2dd0ccb8512cf97fbc 100644 --- a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/rhoN +++ b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/0/rhoN @@ -32,7 +32,8 @@ boundaryField walls { - type zeroGradient; + type calculated; + value uniform 0; } } diff --git a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/iDof b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/iDof index 3e8f63f7c3bcea350c645b1f3100243a2cd32d67..b31b782ef050c24772f71c89a2de1167f746c923 100644 --- a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/iDof +++ b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/iDof @@ -27,7 +27,8 @@ boundaryField obstacle { - type zeroGradient; + type calculated; + value uniform 0; } periodic diff --git a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/internalE b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/internalE index 4cb241119786cd855db3ef548cb70bbad5853d58..61e30470b9791854b94c86ca60de0db6ebf9d7c4 100644 --- a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/internalE +++ b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/internalE @@ -27,7 +27,8 @@ boundaryField obstacle { - type zeroGradient; + type calculated; + value uniform 0; } periodic diff --git a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/linearKE b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/linearKE index 72f2c152c5c29dbc7ddeddbc33b4fa50ff626203..b3f5a50d70da3a3fa0ef3389bfffced201ce155c 100644 --- a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/linearKE +++ b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/linearKE @@ -27,7 +27,8 @@ boundaryField obstacle { - type zeroGradient; + type calculated; + value uniform 0; } periodic diff --git a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/momentum b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/momentum index f0e6facaef53db8cd1aeba1bc2cb3b5c232ce68b..424e0310cc4070392cd1708231e7ab87e4360d2f 100644 --- a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/momentum +++ b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/momentum @@ -27,7 +27,8 @@ boundaryField obstacle { - type zeroGradient; + type calculated; + value uniform (0 0 0); } periodic diff --git a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/rhoM b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/rhoM index 9a84df6fa04f1055614e23361c93d23080fd87a8..224aae627a1e17ebdbc52bce9e1220805b83b23b 100644 --- a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/rhoM +++ b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/rhoM @@ -27,7 +27,8 @@ boundaryField obstacle { - type zeroGradient; + type calculated; + value uniform 0; } periodic diff --git a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/rhoN b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/rhoN index 4f948784aef625e893f24c88fc72321bbf760da6..275417c99567a6157034da5570056d96538eb489 100644 --- a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/rhoN +++ b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/0/rhoN @@ -27,7 +27,8 @@ boundaryField obstacle { - type zeroGradient; + type calculated; + value uniform 0; } periodic diff --git a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/constant/dynamicMeshDict b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/constant/dynamicMeshDict index d7570faf2d4d8ccdba5dd26614745c8f804fedf3..9249808c58d190e2272d768484beb5005c191676 100644 --- a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/constant/dynamicMeshDict +++ b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/constant/dynamicMeshDict @@ -19,14 +19,23 @@ dynamicFvMesh dynamicRefineFvMesh; dynamicRefineFvMeshCoeffs { + // How often to refine refineInterval 1; + // Field to be refinement on field alpha1; + // Refine field inbetween lower..upper lowerRefineLevel 0.001; upperRefineLevel 0.999; + // If value < unrefineLevel unrefine unrefineLevel 10; + // Have slower than 2:1 refinement nBufferLayers 1; + // Refine cells only up to maxRefinement levels maxRefinement 2; + // Stop refinement if maxCells reached maxCells 200000; + // Flux field and corresponding velocity field. Fluxes on changed + // faces get recalculated by interpolating the velocity. correctFluxes ( ( @@ -34,6 +43,7 @@ dynamicRefineFvMeshCoeffs U ) ); + // Write the refinement level as a volScalarField dumpLevel true; }