mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' into dsmc
This commit is contained in:
@ -0,0 +1,5 @@
|
|||||||
|
derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C
|
||||||
|
chtMultiRegionSimpleFoam.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/chtMultiRegionSimpleFoam
|
||||||
|
|
||||||
@ -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
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -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);
|
||||||
@ -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;
|
||||||
|
}
|
||||||
@ -22,39 +22,42 @@ License
|
|||||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
InClass
|
|
||||||
Foam::vtkFoam
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef vtkFoamAddFields_H
|
#include "compressibleCourantNo.H"
|
||||||
#define vtkFoamAddFields_H
|
#include "fvc.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
Foam::scalar Foam::compressibleCourantNo
|
||||||
|
|
||||||
template<class GeoField>
|
|
||||||
void Foam::vtkFoam::addFields
|
|
||||||
(
|
(
|
||||||
vtkDataArraySelection *fieldSelection,
|
const fvMesh& mesh,
|
||||||
const IOobjectList& objects
|
const Time& runTime,
|
||||||
|
const volScalarField& rho,
|
||||||
|
const surfaceScalarField& phi
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
|
scalar CoNum = 0.0;
|
||||||
|
scalar meanCoNum = 0.0;
|
||||||
|
|
||||||
for
|
//- Can have fluid domains with 0 cells so do not test.
|
||||||
(
|
//if (mesh.nInternalFaces())
|
||||||
IOobjectList::iterator iter = fieldObjects.begin();
|
|
||||||
iter != fieldObjects.end();
|
|
||||||
++iter
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
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
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -22,28 +22,28 @@ License
|
|||||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
InClass
|
Description
|
||||||
Foam::vtkFoam
|
Calculates and outputs the mean and maximum Courant Numbers for the fluid
|
||||||
|
regions
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef vtkFoamInsertNextPoint_H
|
#ifndef compressibleCourantNo_H
|
||||||
#define vtkFoamInsertNextPoint_H
|
#define compressibleCourantNo_H
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
#include "fvMesh.H"
|
||||||
|
|
||||||
inline void vtkFoamInsertNextPoint
|
namespace Foam
|
||||||
(
|
|
||||||
vtkPoints *points,
|
|
||||||
const Foam::point& p
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
points->InsertNextPoint(p.x(), p.y(), p.z());
|
scalar compressibleCourantNo
|
||||||
|
(
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const Time& runTime,
|
||||||
|
const volScalarField& rho,
|
||||||
|
const surfaceScalarField& phi
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
scalar CoNum = -GREAT;
|
||||||
|
forAll(fluidRegions, regionI)
|
||||||
|
{
|
||||||
|
CoNum = max
|
||||||
|
(
|
||||||
|
compressibleCourantNo
|
||||||
|
(
|
||||||
|
fluidRegions[regionI],
|
||||||
|
runTime,
|
||||||
|
rhoFluid[regionI],
|
||||||
|
phiFluid[regionI]
|
||||||
|
),
|
||||||
|
CoNum
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
@ -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]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -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
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
// initialize values for convergence checks
|
||||||
|
|
||||||
|
scalar eqnResidual = 1, maxResidual = 0;
|
||||||
|
scalar convergenceCriterion = 0;
|
||||||
|
|
||||||
|
simple.readIfPresent("convergence", convergenceCriterion);
|
||||||
|
|
||||||
@ -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();
|
||||||
|
}
|
||||||
@ -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"));
|
||||||
|
}
|
||||||
@ -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];
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
// Pressure-velocity SIMPLE corrector
|
||||||
|
|
||||||
|
p.storePrevIter();
|
||||||
|
rho.storePrevIter();
|
||||||
|
{
|
||||||
|
#include "UEqn.H"
|
||||||
|
#include "hEqn.H"
|
||||||
|
#include "pEqn.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
turb.correct();
|
||||||
@ -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]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -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();
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
dictionary simple = solidRegions[i].solutionDict().subDict("SIMPLE");
|
||||||
|
|
||||||
|
int nNonOrthCorr = 0;
|
||||||
|
if (simple.found("nNonOrthogonalCorrectors"))
|
||||||
|
{
|
||||||
|
nNonOrthCorr = readInt(simple.lookup("nNonOrthogonalCorrectors"));
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
fvMesh& mesh = solidRegions[i];
|
||||||
|
|
||||||
|
volScalarField& rho = rhos[i];
|
||||||
|
volScalarField& cp = cps[i];
|
||||||
|
volScalarField& K = Ks[i];
|
||||||
|
volScalarField& T = Ts[i];
|
||||||
@ -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;
|
||||||
|
}
|
||||||
@ -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
|
wordList pcorrTypes
|
||||||
(
|
(
|
||||||
p.boundaryField().size(),
|
p.boundaryField().size(),
|
||||||
|
|||||||
@ -90,7 +90,6 @@ int main(int argc, char *argv[])
|
|||||||
// --- PISO loop
|
// --- PISO loop
|
||||||
for (int corr=0; corr<nCorr; corr++)
|
for (int corr=0; corr<nCorr; corr++)
|
||||||
{
|
{
|
||||||
surfaceScalarField hf = fvc::interpolate(h);
|
|
||||||
volScalarField rUA = 1.0/hUEqn.A();
|
volScalarField rUA = 1.0/hUEqn.A();
|
||||||
surfaceScalarField ghrUAf = magg*fvc::interpolate(h*rUA);
|
surfaceScalarField ghrUAf = magg*fvc::interpolate(h*rUA);
|
||||||
|
|
||||||
|
|||||||
@ -1,20 +1,5 @@
|
|||||||
dictionary additional = mesh.solutionDict().subDict("additional");
|
dictionary additional = mesh.solutionDict().subDict("additional");
|
||||||
|
|
||||||
bool dpdt = true;
|
bool dpdt = additional.lookupOrDefault("dpdt", true);
|
||||||
if (additional.found("dpdt"))
|
bool eWork = additional.lookupOrDefault("eWork", true);
|
||||||
{
|
bool hWork = additional.lookupOrDefault("hWork", true);
|
||||||
additional.lookup("dpdt") >> dpdt;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool eWork = true;
|
|
||||||
if (additional.found("eWork"))
|
|
||||||
{
|
|
||||||
additional.lookup("eWork") >> eWork;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hWork = true;
|
|
||||||
if (additional.found("hWork"))
|
|
||||||
{
|
|
||||||
additional.lookup("hWork") >> hWork;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@ -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"
|
#include "continuityErrs.H"
|
||||||
|
|
||||||
volScalarField pcorr
|
volScalarField pcorr
|
||||||
|
|||||||
@ -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"
|
#include "continuityErrs.H"
|
||||||
|
|
||||||
volScalarField pcorr
|
volScalarField pcorr
|
||||||
|
|||||||
@ -57,7 +57,7 @@ int main(int argc, char *argv[])
|
|||||||
//Info<< ck.specieThermo() << endl;
|
//Info<< ck.specieThermo() << endl;
|
||||||
//Info<< ck.reactions() << endl;
|
//Info<< ck.reactions() << endl;
|
||||||
|
|
||||||
PtrList<chemkinReader::reaction> reactions = ck.reactions();
|
const SLPtrList<gasReaction>& reactions = ck.reactions();
|
||||||
|
|
||||||
{
|
{
|
||||||
OFstream reactionStream("reactions");
|
OFstream reactionStream("reactions");
|
||||||
@ -70,17 +70,17 @@ int main(int argc, char *argv[])
|
|||||||
label nReactions(readLabel(reactionStream));
|
label nReactions(readLabel(reactionStream));
|
||||||
reactionStream.readBeginList(args.executable().c_str());
|
reactionStream.readBeginList(args.executable().c_str());
|
||||||
|
|
||||||
PtrList<chemkinReader::reaction> testReactions(nReactions);
|
PtrList<gasReaction> testReactions(nReactions);
|
||||||
|
|
||||||
forAll (testReactions, i)
|
forAll (testReactions, i)
|
||||||
{
|
{
|
||||||
testReactions.set
|
testReactions.set
|
||||||
(
|
(
|
||||||
i,
|
i,
|
||||||
chemkinReader::reaction::New
|
gasReaction::New
|
||||||
(
|
(
|
||||||
ck.species(),
|
ck.species(),
|
||||||
ck.specieThermo(),
|
ck.speciesThermo(),
|
||||||
reactionStream
|
reactionStream
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -39,6 +39,8 @@ Description
|
|||||||
\* ------------------------------------------------------------------------- */
|
\* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
// For EOF only
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
#include "scalar.H"
|
#include "scalar.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
|
|||||||
@ -41,6 +41,9 @@ Description
|
|||||||
#include "scalarList.H"
|
#include "scalarList.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
|
|
||||||
|
// For EOF only
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
#include "argList.H"
|
#include "argList.H"
|
||||||
|
|||||||
@ -428,7 +428,43 @@ void Foam::ensightMesh::writePrimsBinary
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::ensightMesh::writePolys
|
void Foam::ensightMesh::writePolysNFaces
|
||||||
|
(
|
||||||
|
const labelList& polys,
|
||||||
|
const cellList& cellFaces,
|
||||||
|
OFstream& ensightGeometryFile
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
forAll(polys, i)
|
||||||
|
{
|
||||||
|
ensightGeometryFile
|
||||||
|
<< setw(10) << cellFaces[polys[i]].size() << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::ensightMesh::writePolysNPointsPerFace
|
||||||
|
(
|
||||||
|
const labelList& polys,
|
||||||
|
const cellList& cellFaces,
|
||||||
|
const faceList& faces,
|
||||||
|
OFstream& ensightGeometryFile
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
forAll(polys, i)
|
||||||
|
{
|
||||||
|
const labelList& cf = cellFaces[polys[i]];
|
||||||
|
|
||||||
|
forAll(cf, faceI)
|
||||||
|
{
|
||||||
|
ensightGeometryFile
|
||||||
|
<< setw(10) << faces[cf[faceI]].size() << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::ensightMesh::writePolysPoints
|
||||||
(
|
(
|
||||||
const labelList& polys,
|
const labelList& polys,
|
||||||
const cellList& cellFaces,
|
const cellList& cellFaces,
|
||||||
@ -437,50 +473,190 @@ void Foam::ensightMesh::writePolys
|
|||||||
OFstream& ensightGeometryFile
|
OFstream& ensightGeometryFile
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (polys.size())
|
label po = pointOffset + 1;
|
||||||
|
|
||||||
|
forAll(polys, i)
|
||||||
{
|
{
|
||||||
ensightGeometryFile
|
const labelList& cf = cellFaces[polys[i]];
|
||||||
<< "nfaced" << nl << setw(10) << polys.size() << nl;
|
|
||||||
|
|
||||||
label po = pointOffset + 1;
|
forAll(cf, faceI)
|
||||||
|
|
||||||
forAll(polys, i)
|
|
||||||
{
|
{
|
||||||
ensightGeometryFile
|
const face& f = faces[cf[faceI]];
|
||||||
<< setw(10) << cellFaces[polys[i]].size() << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
forAll(polys, i)
|
forAll(f, pointI)
|
||||||
{
|
|
||||||
const labelList& cf = cellFaces[polys[i]];
|
|
||||||
|
|
||||||
forAll(cf, faceI)
|
|
||||||
{
|
{
|
||||||
ensightGeometryFile
|
ensightGeometryFile << setw(10) << f[pointI] + po;
|
||||||
<< setw(10) << faces[cf[faceI]].size() << nl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
forAll(polys, i)
|
|
||||||
{
|
|
||||||
const labelList& cf = cellFaces[polys[i]];
|
|
||||||
|
|
||||||
forAll(cf, faceI)
|
|
||||||
{
|
|
||||||
const face& f = faces[cf[faceI]];
|
|
||||||
|
|
||||||
forAll(f, pointI)
|
|
||||||
{
|
|
||||||
ensightGeometryFile << setw(10) << f[pointI] + po;
|
|
||||||
}
|
|
||||||
ensightGeometryFile << nl;
|
|
||||||
}
|
}
|
||||||
|
ensightGeometryFile << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::ensightMesh::writePolysBinary
|
void Foam::ensightMesh::writeAllPolys
|
||||||
|
(
|
||||||
|
const labelList& pointOffsets,
|
||||||
|
OFstream& ensightGeometryFile
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (meshCellSets_.nPolys)
|
||||||
|
{
|
||||||
|
const cellList& cellFaces = mesh_.cells();
|
||||||
|
const faceList& faces = mesh_.faces();
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
ensightGeometryFile
|
||||||
|
<< "nfaced" << nl << setw(10) << meshCellSets_.nPolys << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Number of faces for each poly cell
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
// Master
|
||||||
|
writePolysNFaces
|
||||||
|
(
|
||||||
|
meshCellSets_.polys,
|
||||||
|
cellFaces,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
// Slaves
|
||||||
|
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||||
|
{
|
||||||
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
|
labelList polys(fromSlave);
|
||||||
|
cellList cellFaces(fromSlave);
|
||||||
|
|
||||||
|
writePolysNFaces
|
||||||
|
(
|
||||||
|
polys,
|
||||||
|
cellFaces,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
|
toMaster<< meshCellSets_.polys << cellFaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Number of points for each face of the above list
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
// Master
|
||||||
|
writePolysNPointsPerFace
|
||||||
|
(
|
||||||
|
meshCellSets_.polys,
|
||||||
|
cellFaces,
|
||||||
|
faces,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
// Slaves
|
||||||
|
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||||
|
{
|
||||||
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
|
labelList polys(fromSlave);
|
||||||
|
cellList cellFaces(fromSlave);
|
||||||
|
faceList faces(fromSlave);
|
||||||
|
|
||||||
|
writePolysNPointsPerFace
|
||||||
|
(
|
||||||
|
polys,
|
||||||
|
cellFaces,
|
||||||
|
faces,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
|
toMaster<< meshCellSets_.polys << cellFaces << faces;
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of points id for each face of the above list
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
// Master
|
||||||
|
writePolysPoints
|
||||||
|
(
|
||||||
|
meshCellSets_.polys,
|
||||||
|
cellFaces,
|
||||||
|
faces,
|
||||||
|
0,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
// Slaves
|
||||||
|
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||||
|
{
|
||||||
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
|
labelList polys(fromSlave);
|
||||||
|
cellList cellFaces(fromSlave);
|
||||||
|
faceList faces(fromSlave);
|
||||||
|
|
||||||
|
writePolysPoints
|
||||||
|
(
|
||||||
|
polys,
|
||||||
|
cellFaces,
|
||||||
|
faces,
|
||||||
|
pointOffsets[slave-1],
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
|
toMaster<< meshCellSets_.polys << cellFaces << faces;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::ensightMesh::writePolysNFacesBinary
|
||||||
|
(
|
||||||
|
const labelList& polys,
|
||||||
|
const cellList& cellFaces,
|
||||||
|
std::ofstream& ensightGeometryFile
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
forAll(polys, i)
|
||||||
|
{
|
||||||
|
writeEnsDataBinary
|
||||||
|
(
|
||||||
|
cellFaces[polys[i]].size(),
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::ensightMesh::writePolysNPointsPerFaceBinary
|
||||||
|
(
|
||||||
|
const labelList& polys,
|
||||||
|
const cellList& cellFaces,
|
||||||
|
const faceList& faces,
|
||||||
|
std::ofstream& ensightGeometryFile
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
forAll(polys, i)
|
||||||
|
{
|
||||||
|
const labelList& cf = cellFaces[polys[i]];
|
||||||
|
|
||||||
|
forAll(cf, faceI)
|
||||||
|
{
|
||||||
|
writeEnsDataBinary
|
||||||
|
(
|
||||||
|
faces[cf[faceI]].size(),
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::ensightMesh::writePolysPointsBinary
|
||||||
(
|
(
|
||||||
const labelList& polys,
|
const labelList& polys,
|
||||||
const cellList& cellFaces,
|
const cellList& cellFaces,
|
||||||
@ -489,51 +665,142 @@ void Foam::ensightMesh::writePolysBinary
|
|||||||
std::ofstream& ensightGeometryFile
|
std::ofstream& ensightGeometryFile
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (polys.size())
|
label po = pointOffset + 1;
|
||||||
|
|
||||||
|
forAll(polys, i)
|
||||||
{
|
{
|
||||||
writeEnsDataBinary("nfaced",ensightGeometryFile);
|
const labelList& cf = cellFaces[polys[i]];
|
||||||
writeEnsDataBinary(polys.size(),ensightGeometryFile);
|
|
||||||
|
|
||||||
label po = pointOffset + 1;
|
forAll(cf, faceI)
|
||||||
|
|
||||||
//TODO No buffer at the moment. To be done for speed purposes!
|
|
||||||
forAll(polys, i)
|
|
||||||
{
|
{
|
||||||
writeEnsDataBinary
|
const face& f = faces[cf[faceI]];
|
||||||
(
|
|
||||||
cellFaces[polys[i]].size(),
|
forAll(f, pointI)
|
||||||
ensightGeometryFile
|
{
|
||||||
);
|
writeEnsDataBinary(f[pointI] + po,ensightGeometryFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::ensightMesh::writeAllPolysBinary
|
||||||
|
(
|
||||||
|
const labelList& pointOffsets,
|
||||||
|
std::ofstream& ensightGeometryFile
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (meshCellSets_.nPolys)
|
||||||
|
{
|
||||||
|
const cellList& cellFaces = mesh_.cells();
|
||||||
|
const faceList& faces = mesh_.faces();
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
writeEnsDataBinary("nfaced",ensightGeometryFile);
|
||||||
|
writeEnsDataBinary(meshCellSets_.nPolys,ensightGeometryFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(polys, i)
|
// Number of faces for each poly cell
|
||||||
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
const labelList& cf = cellFaces[polys[i]];
|
// Master
|
||||||
|
writePolysNFacesBinary
|
||||||
forAll(cf, faceI)
|
(
|
||||||
|
meshCellSets_.polys,
|
||||||
|
cellFaces,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
// Slaves
|
||||||
|
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||||
{
|
{
|
||||||
writeEnsDataBinary
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
|
labelList polys(fromSlave);
|
||||||
|
cellList cellFaces(fromSlave);
|
||||||
|
|
||||||
|
writePolysNFacesBinary
|
||||||
(
|
(
|
||||||
faces[cf[faceI]].size(),
|
polys,
|
||||||
|
cellFaces,
|
||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
forAll(polys, i)
|
|
||||||
{
|
{
|
||||||
const labelList& cf = cellFaces[polys[i]];
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
|
toMaster<< meshCellSets_.polys << cellFaces;
|
||||||
|
}
|
||||||
|
|
||||||
forAll(cf, faceI)
|
// Number of points for each face of the above list
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
// Master
|
||||||
|
writePolysNPointsPerFaceBinary
|
||||||
|
(
|
||||||
|
meshCellSets_.polys,
|
||||||
|
cellFaces,
|
||||||
|
faces,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
// Slaves
|
||||||
|
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||||
{
|
{
|
||||||
const face& f = faces[cf[faceI]];
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
|
labelList polys(fromSlave);
|
||||||
|
cellList cellFaces(fromSlave);
|
||||||
|
faceList faces(fromSlave);
|
||||||
|
|
||||||
forAll(f, pointI)
|
writePolysNPointsPerFaceBinary
|
||||||
{
|
(
|
||||||
writeEnsDataBinary(f[pointI] + po,ensightGeometryFile);
|
polys,
|
||||||
}
|
cellFaces,
|
||||||
|
faces,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
|
toMaster<< meshCellSets_.polys << cellFaces << faces;
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of points id for each face of the above list
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
// Master
|
||||||
|
writePolysPointsBinary
|
||||||
|
(
|
||||||
|
meshCellSets_.polys,
|
||||||
|
cellFaces,
|
||||||
|
faces,
|
||||||
|
0,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
// Slaves
|
||||||
|
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||||
|
{
|
||||||
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
|
labelList polys(fromSlave);
|
||||||
|
cellList cellFaces(fromSlave);
|
||||||
|
faceList faces(fromSlave);
|
||||||
|
|
||||||
|
writePolysPointsBinary
|
||||||
|
(
|
||||||
|
polys,
|
||||||
|
cellFaces,
|
||||||
|
faces,
|
||||||
|
pointOffsets[slave-1],
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
|
toMaster<< meshCellSets_.polys << cellFaces << faces;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,7 +886,6 @@ void Foam::ensightMesh::writeAllPrimsBinary
|
|||||||
|
|
||||||
void Foam::ensightMesh::writeFacePrims
|
void Foam::ensightMesh::writeFacePrims
|
||||||
(
|
(
|
||||||
const char* key,
|
|
||||||
const faceList& patchFaces,
|
const faceList& patchFaces,
|
||||||
const label pointOffset,
|
const label pointOffset,
|
||||||
OFstream& ensightGeometryFile
|
OFstream& ensightGeometryFile
|
||||||
@ -627,18 +893,6 @@ void Foam::ensightMesh::writeFacePrims
|
|||||||
{
|
{
|
||||||
if (patchFaces.size())
|
if (patchFaces.size())
|
||||||
{
|
{
|
||||||
if (word(key) == "nsided")
|
|
||||||
{
|
|
||||||
ensightGeometryFile
|
|
||||||
<< key << nl << setw(10) << patchFaces.size() << nl;
|
|
||||||
|
|
||||||
forAll(patchFaces, i)
|
|
||||||
{
|
|
||||||
ensightGeometryFile
|
|
||||||
<< setw(10) << patchFaces[i].size() << nl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
label po = pointOffset + 1;
|
label po = pointOffset + 1;
|
||||||
|
|
||||||
forAll(patchFaces, i)
|
forAll(patchFaces, i)
|
||||||
@ -657,7 +911,6 @@ void Foam::ensightMesh::writeFacePrims
|
|||||||
|
|
||||||
void Foam::ensightMesh::writeFacePrimsBinary
|
void Foam::ensightMesh::writeFacePrimsBinary
|
||||||
(
|
(
|
||||||
const char* key,
|
|
||||||
const faceList& patchFaces,
|
const faceList& patchFaces,
|
||||||
const label pointOffset,
|
const label pointOffset,
|
||||||
std::ofstream& ensightGeometryFile
|
std::ofstream& ensightGeometryFile
|
||||||
@ -665,22 +918,6 @@ void Foam::ensightMesh::writeFacePrimsBinary
|
|||||||
{
|
{
|
||||||
if (patchFaces.size())
|
if (patchFaces.size())
|
||||||
{
|
{
|
||||||
//TODO No buffer at the moment. To be done for speed purposes!
|
|
||||||
if (word(key) == "nsided")
|
|
||||||
{
|
|
||||||
writeEnsDataBinary(key,ensightGeometryFile);
|
|
||||||
writeEnsDataBinary(patchFaces.size(),ensightGeometryFile);
|
|
||||||
|
|
||||||
forAll(patchFaces, i)
|
|
||||||
{
|
|
||||||
writeEnsDataBinary
|
|
||||||
(
|
|
||||||
patchFaces[i].size(),
|
|
||||||
ensightGeometryFile
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
label po = pointOffset + 1;
|
label po = pointOffset + 1;
|
||||||
|
|
||||||
forAll(patchFaces, i)
|
forAll(patchFaces, i)
|
||||||
@ -732,16 +969,12 @@ void Foam::ensightMesh::writeAllFacePrims
|
|||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
if (word(key) != "nsided")
|
ensightGeometryFile << key << nl << setw(10) << nPrims << nl;
|
||||||
{
|
|
||||||
ensightGeometryFile << key << nl << setw(10) << nPrims << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (&prims != NULL)
|
if (&prims != NULL)
|
||||||
{
|
{
|
||||||
writeFacePrims
|
writeFacePrims
|
||||||
(
|
(
|
||||||
key,
|
|
||||||
map(patchFaces, prims),
|
map(patchFaces, prims),
|
||||||
0,
|
0,
|
||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
@ -758,7 +991,251 @@ void Foam::ensightMesh::writeAllFacePrims
|
|||||||
|
|
||||||
writeFacePrims
|
writeFacePrims
|
||||||
(
|
(
|
||||||
key,
|
patchFaces,
|
||||||
|
pointOffsets[i],
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (&prims != NULL)
|
||||||
|
{
|
||||||
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
|
toMaster<< map(patchFaces, prims);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::ensightMesh::writeNSidedNPointsPerFace
|
||||||
|
(
|
||||||
|
const faceList& patchFaces,
|
||||||
|
OFstream& ensightGeometryFile
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
forAll(patchFaces, i)
|
||||||
|
{
|
||||||
|
ensightGeometryFile
|
||||||
|
<< setw(10) << patchFaces[i].size() << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::ensightMesh::writeNSidedPoints
|
||||||
|
(
|
||||||
|
const faceList& patchFaces,
|
||||||
|
const label pointOffset,
|
||||||
|
OFstream& ensightGeometryFile
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
writeFacePrims
|
||||||
|
(
|
||||||
|
patchFaces,
|
||||||
|
pointOffset,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::ensightMesh::writeAllNSided
|
||||||
|
(
|
||||||
|
const labelList& prims,
|
||||||
|
const label nPrims,
|
||||||
|
const faceList& patchFaces,
|
||||||
|
const labelList& pointOffsets,
|
||||||
|
const labelList& patchProcessors,
|
||||||
|
OFstream& ensightGeometryFile
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (nPrims)
|
||||||
|
{
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
ensightGeometryFile
|
||||||
|
<< "nsided" << nl << setw(10) << nPrims << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Number of points for each face
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
if (&prims != NULL)
|
||||||
|
{
|
||||||
|
writeNSidedNPointsPerFace
|
||||||
|
(
|
||||||
|
map(patchFaces, prims),
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll (patchProcessors, i)
|
||||||
|
{
|
||||||
|
if (patchProcessors[i] != 0)
|
||||||
|
{
|
||||||
|
label slave = patchProcessors[i];
|
||||||
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
|
faceList patchFaces(fromSlave);
|
||||||
|
|
||||||
|
writeNSidedNPointsPerFace
|
||||||
|
(
|
||||||
|
patchFaces,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (&prims != NULL)
|
||||||
|
{
|
||||||
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
|
toMaster<< map(patchFaces, prims);
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of points id for each face
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
if (&prims != NULL)
|
||||||
|
{
|
||||||
|
writeNSidedPoints
|
||||||
|
(
|
||||||
|
map(patchFaces, prims),
|
||||||
|
0,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll (patchProcessors, i)
|
||||||
|
{
|
||||||
|
if (patchProcessors[i] != 0)
|
||||||
|
{
|
||||||
|
label slave = patchProcessors[i];
|
||||||
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
|
faceList patchFaces(fromSlave);
|
||||||
|
|
||||||
|
writeNSidedPoints
|
||||||
|
(
|
||||||
|
patchFaces,
|
||||||
|
pointOffsets[i],
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (&prims != NULL)
|
||||||
|
{
|
||||||
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
|
toMaster<< map(patchFaces, prims);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::ensightMesh::writeNSidedPointsBinary
|
||||||
|
(
|
||||||
|
const faceList& patchFaces,
|
||||||
|
const label pointOffset,
|
||||||
|
std::ofstream& ensightGeometryFile
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
writeFacePrimsBinary
|
||||||
|
(
|
||||||
|
patchFaces,
|
||||||
|
pointOffset,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::ensightMesh::writeNSidedNPointsPerFaceBinary
|
||||||
|
(
|
||||||
|
const faceList& patchFaces,
|
||||||
|
std::ofstream& ensightGeometryFile
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
forAll(patchFaces, i)
|
||||||
|
{
|
||||||
|
writeEnsDataBinary
|
||||||
|
(
|
||||||
|
patchFaces[i].size(),
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::ensightMesh::writeAllNSidedBinary
|
||||||
|
(
|
||||||
|
const labelList& prims,
|
||||||
|
const label nPrims,
|
||||||
|
const faceList& patchFaces,
|
||||||
|
const labelList& pointOffsets,
|
||||||
|
const labelList& patchProcessors,
|
||||||
|
std::ofstream& ensightGeometryFile
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (nPrims)
|
||||||
|
{
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
writeEnsDataBinary("nsided",ensightGeometryFile);
|
||||||
|
writeEnsDataBinary(nPrims,ensightGeometryFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Number of points for each face
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
if (&prims != NULL)
|
||||||
|
{
|
||||||
|
writeNSidedNPointsPerFaceBinary
|
||||||
|
(
|
||||||
|
map(patchFaces, prims),
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll (patchProcessors, i)
|
||||||
|
{
|
||||||
|
if (patchProcessors[i] != 0)
|
||||||
|
{
|
||||||
|
label slave = patchProcessors[i];
|
||||||
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
|
faceList patchFaces(fromSlave);
|
||||||
|
|
||||||
|
writeNSidedNPointsPerFaceBinary
|
||||||
|
(
|
||||||
|
patchFaces,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (&prims != NULL)
|
||||||
|
{
|
||||||
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
|
toMaster<< map(patchFaces, prims);
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of points id for each face
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
if (&prims != NULL)
|
||||||
|
{
|
||||||
|
writeNSidedPointsBinary
|
||||||
|
(
|
||||||
|
map(patchFaces, prims),
|
||||||
|
0,
|
||||||
|
ensightGeometryFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll (patchProcessors, i)
|
||||||
|
{
|
||||||
|
if (patchProcessors[i] != 0)
|
||||||
|
{
|
||||||
|
label slave = patchProcessors[i];
|
||||||
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
|
faceList patchFaces(fromSlave);
|
||||||
|
|
||||||
|
writeNSidedPointsBinary
|
||||||
|
(
|
||||||
patchFaces,
|
patchFaces,
|
||||||
pointOffsets[i],
|
pointOffsets[i],
|
||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
@ -790,17 +1267,13 @@ void Foam::ensightMesh::writeAllFacePrimsBinary
|
|||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
if (word(key) != "nsided")
|
writeEnsDataBinary(key,ensightGeometryFile);
|
||||||
{
|
writeEnsDataBinary(nPrims,ensightGeometryFile);
|
||||||
writeEnsDataBinary(key,ensightGeometryFile);
|
|
||||||
writeEnsDataBinary(nPrims,ensightGeometryFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (&prims != NULL)
|
if (&prims != NULL)
|
||||||
{
|
{
|
||||||
writeFacePrimsBinary
|
writeFacePrimsBinary
|
||||||
(
|
(
|
||||||
key,
|
|
||||||
map(patchFaces, prims),
|
map(patchFaces, prims),
|
||||||
0,
|
0,
|
||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
@ -817,7 +1290,6 @@ void Foam::ensightMesh::writeAllFacePrimsBinary
|
|||||||
|
|
||||||
writeFacePrimsBinary
|
writeFacePrimsBinary
|
||||||
(
|
(
|
||||||
key,
|
|
||||||
patchFaces,
|
patchFaces,
|
||||||
pointOffsets[i],
|
pointOffsets[i],
|
||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
@ -863,8 +1335,6 @@ void Foam::ensightMesh::writeAscii
|
|||||||
{
|
{
|
||||||
const Time& runTime = mesh_.time();
|
const Time& runTime = mesh_.time();
|
||||||
const pointField& points = mesh_.points();
|
const pointField& points = mesh_.points();
|
||||||
const cellList& cellFaces = mesh_.cells();
|
|
||||||
const faceList& faces = mesh_.faces();
|
|
||||||
const cellShapeList& cellShapes = mesh_.cellShapes();
|
const cellShapeList& cellShapes = mesh_.cellShapes();
|
||||||
|
|
||||||
word timeFile = prepend;
|
word timeFile = prepend;
|
||||||
@ -990,48 +1460,11 @@ void Foam::ensightMesh::writeAscii
|
|||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
);
|
);
|
||||||
|
|
||||||
|
writeAllPolys
|
||||||
if (meshCellSets_.nPolys)
|
(
|
||||||
{
|
pointOffsets,
|
||||||
if (Pstream::master())
|
ensightGeometryFile
|
||||||
{
|
);
|
||||||
/*
|
|
||||||
ensightGeometryFile
|
|
||||||
<< "nfaced" << nl
|
|
||||||
<< setw(10) << meshCellSets_.nPolys << nl;
|
|
||||||
*/
|
|
||||||
writePolys
|
|
||||||
(
|
|
||||||
meshCellSets_.polys,
|
|
||||||
cellFaces,
|
|
||||||
faces,
|
|
||||||
0,
|
|
||||||
ensightGeometryFile
|
|
||||||
);
|
|
||||||
|
|
||||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
|
||||||
{
|
|
||||||
IPstream fromSlave(Pstream::scheduled, slave);
|
|
||||||
labelList polys(fromSlave);
|
|
||||||
cellList cellFaces(fromSlave);
|
|
||||||
faceList faces(fromSlave);
|
|
||||||
|
|
||||||
writePolys
|
|
||||||
(
|
|
||||||
polys,
|
|
||||||
cellFaces,
|
|
||||||
faces,
|
|
||||||
pointOffsets[slave-1],
|
|
||||||
ensightGeometryFile
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
|
||||||
toMaster<< meshCellSets_.polys << cellFaces << faces;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1166,9 +1599,8 @@ void Foam::ensightMesh::writeAscii
|
|||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
);
|
);
|
||||||
|
|
||||||
writeAllFacePrims
|
writeAllNSided
|
||||||
(
|
(
|
||||||
"nsided",
|
|
||||||
polys,
|
polys,
|
||||||
nfp.nPolys,
|
nfp.nPolys,
|
||||||
patchFaces,
|
patchFaces,
|
||||||
@ -1197,8 +1629,6 @@ void Foam::ensightMesh::writeBinary
|
|||||||
{
|
{
|
||||||
//const Time& runTime = mesh.time();
|
//const Time& runTime = mesh.time();
|
||||||
const pointField& points = mesh_.points();
|
const pointField& points = mesh_.points();
|
||||||
const cellList& cellFaces = mesh_.cells();
|
|
||||||
const faceList& faces = mesh_.faces();
|
|
||||||
const cellShapeList& cellShapes = mesh_.cellShapes();
|
const cellShapeList& cellShapes = mesh_.cellShapes();
|
||||||
|
|
||||||
word timeFile = prepend;
|
word timeFile = prepend;
|
||||||
@ -1316,47 +1746,11 @@ void Foam::ensightMesh::writeBinary
|
|||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
);
|
);
|
||||||
|
|
||||||
if (meshCellSets_.nPolys)
|
writeAllPolysBinary
|
||||||
{
|
(
|
||||||
if (Pstream::master())
|
pointOffsets,
|
||||||
{
|
ensightGeometryFile
|
||||||
/*
|
);
|
||||||
ensightGeometryFile
|
|
||||||
<< "nfaced" << nl
|
|
||||||
<< setw(10) << meshCellSets_.nPolys << nl;
|
|
||||||
*/
|
|
||||||
writePolysBinary
|
|
||||||
(
|
|
||||||
meshCellSets_.polys,
|
|
||||||
cellFaces,
|
|
||||||
faces,
|
|
||||||
0,
|
|
||||||
ensightGeometryFile
|
|
||||||
);
|
|
||||||
|
|
||||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
|
||||||
{
|
|
||||||
IPstream fromSlave(Pstream::scheduled, slave);
|
|
||||||
labelList polys(fromSlave);
|
|
||||||
cellList cellFaces(fromSlave);
|
|
||||||
faceList faces(fromSlave);
|
|
||||||
|
|
||||||
writePolysBinary
|
|
||||||
(
|
|
||||||
polys,
|
|
||||||
cellFaces,
|
|
||||||
faces,
|
|
||||||
pointOffsets[slave-1],
|
|
||||||
ensightGeometryFile
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
|
||||||
toMaster<< meshCellSets_.polys << cellFaces << faces;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1495,9 +1889,8 @@ void Foam::ensightMesh::writeBinary
|
|||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
);
|
);
|
||||||
|
|
||||||
writeAllFacePrimsBinary
|
writeAllNSidedBinary
|
||||||
(
|
(
|
||||||
"nsided",
|
|
||||||
polys,
|
polys,
|
||||||
nfp.nPolys,
|
nfp.nPolys,
|
||||||
patchFaces,
|
patchFaces,
|
||||||
@ -1516,4 +1909,5 @@ void Foam::ensightMesh::writeBinary
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -134,7 +134,22 @@ class ensightMesh
|
|||||||
OFstream& ensightGeometryFile
|
OFstream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writePolys
|
void writePolysNFaces
|
||||||
|
(
|
||||||
|
const labelList& polys,
|
||||||
|
const cellList& cellFaces,
|
||||||
|
OFstream& ensightGeometryFile
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void writePolysNPointsPerFace
|
||||||
|
(
|
||||||
|
const labelList& polys,
|
||||||
|
const cellList& cellFaces,
|
||||||
|
const faceList& faces,
|
||||||
|
OFstream& ensightGeometryFile
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void writePolysPoints
|
||||||
(
|
(
|
||||||
const labelList& polys,
|
const labelList& polys,
|
||||||
const cellList& cellFaces,
|
const cellList& cellFaces,
|
||||||
@ -143,6 +158,12 @@ class ensightMesh
|
|||||||
OFstream& ensightGeometryFile
|
OFstream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
void writeAllPolys
|
||||||
|
(
|
||||||
|
const labelList& pointOffsets,
|
||||||
|
OFstream& ensightGeometryFile
|
||||||
|
) const;
|
||||||
|
|
||||||
void writeAllPrims
|
void writeAllPrims
|
||||||
(
|
(
|
||||||
const char* key,
|
const char* key,
|
||||||
@ -154,7 +175,6 @@ class ensightMesh
|
|||||||
|
|
||||||
void writeFacePrims
|
void writeFacePrims
|
||||||
(
|
(
|
||||||
const char* key,
|
|
||||||
const faceList& patchFaces,
|
const faceList& patchFaces,
|
||||||
const label pointOffset,
|
const label pointOffset,
|
||||||
OFstream& ensightGeometryFile
|
OFstream& ensightGeometryFile
|
||||||
@ -177,6 +197,29 @@ class ensightMesh
|
|||||||
OFstream& ensightGeometryFile
|
OFstream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
void writeNSidedNPointsPerFace
|
||||||
|
(
|
||||||
|
const faceList& patchFaces,
|
||||||
|
OFstream& ensightGeometryFile
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void writeNSidedPoints
|
||||||
|
(
|
||||||
|
const faceList& patchFaces,
|
||||||
|
const label pointOffset,
|
||||||
|
OFstream& ensightGeometryFile
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void writeAllNSided
|
||||||
|
(
|
||||||
|
const labelList& prims,
|
||||||
|
const label nPrims,
|
||||||
|
const faceList& patchFaces,
|
||||||
|
const labelList& pointOffsets,
|
||||||
|
const labelList& patchProcessors,
|
||||||
|
OFstream& ensightGeometryFile
|
||||||
|
) const;
|
||||||
|
|
||||||
void writeAscii
|
void writeAscii
|
||||||
(
|
(
|
||||||
const fileName& postProcPath,
|
const fileName& postProcPath,
|
||||||
@ -209,7 +252,22 @@ class ensightMesh
|
|||||||
std::ofstream& ensightGeometryFile
|
std::ofstream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writePolysBinary
|
void writePolysNFacesBinary
|
||||||
|
(
|
||||||
|
const labelList& polys,
|
||||||
|
const cellList& cellFaces,
|
||||||
|
std::ofstream& ensightGeometryFile
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void writePolysNPointsPerFaceBinary
|
||||||
|
(
|
||||||
|
const labelList& polys,
|
||||||
|
const cellList& cellFaces,
|
||||||
|
const faceList& faces,
|
||||||
|
std::ofstream& ensightGeometryFile
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void writePolysPointsBinary
|
||||||
(
|
(
|
||||||
const labelList& polys,
|
const labelList& polys,
|
||||||
const cellList& cellFaces,
|
const cellList& cellFaces,
|
||||||
@ -218,6 +276,12 @@ class ensightMesh
|
|||||||
std::ofstream& ensightGeometryFile
|
std::ofstream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
void writeAllPolysBinary
|
||||||
|
(
|
||||||
|
const labelList& pointOffsets,
|
||||||
|
std::ofstream& ensightGeometryFile
|
||||||
|
) const;
|
||||||
|
|
||||||
void writeAllFacePrimsBinary
|
void writeAllFacePrimsBinary
|
||||||
(
|
(
|
||||||
const char* key,
|
const char* key,
|
||||||
@ -231,12 +295,33 @@ class ensightMesh
|
|||||||
|
|
||||||
void writeFacePrimsBinary
|
void writeFacePrimsBinary
|
||||||
(
|
(
|
||||||
const char* key,
|
|
||||||
const faceList& patchFaces,
|
const faceList& patchFaces,
|
||||||
const label pointOffset,
|
const label pointOffset,
|
||||||
std::ofstream& ensightGeometryFile
|
std::ofstream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
void writeNSidedPointsBinary
|
||||||
|
(
|
||||||
|
const faceList& patchFaces,
|
||||||
|
const label pointOffset,
|
||||||
|
std::ofstream& ensightGeometryFile
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void writeNSidedNPointsPerFaceBinary
|
||||||
|
(
|
||||||
|
const faceList& patchFaces,
|
||||||
|
std::ofstream& ensightGeometryFile
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void writeAllNSidedBinary
|
||||||
|
(
|
||||||
|
const labelList& prims,
|
||||||
|
const label nPrims,
|
||||||
|
const faceList& patchFaces,
|
||||||
|
const labelList& pointOffsets,
|
||||||
|
const labelList& patchProcessors,
|
||||||
|
std::ofstream& ensightGeometryFile
|
||||||
|
) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@ -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
|
|
||||||
@ -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)
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
@ -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>
|
|
||||||
@ -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>
|
|
||||||
@ -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>
|
|
||||||
@ -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>
|
|
||||||
@ -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
|
|
||||||
@ -1,70 +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
|
|
||||||
vtkFoamData
|
|
||||||
|
|
||||||
Description
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
vtkFoamData.cxx
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef vtkFoamData_h
|
|
||||||
#define vtkFoamData_h
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#include "vtkDataSetSource.h"
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class vtkFoamData Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
class VTK_IO_EXPORT vtkFoamData
|
|
||||||
:
|
|
||||||
public vtkDataSetSource
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
static vtkFoamData *New();
|
|
||||||
vtkTypeRevisionMacro(vtkFoamData,vtkDataSetSource);
|
|
||||||
|
|
||||||
vtkFoamData();
|
|
||||||
~vtkFoamData();
|
|
||||||
|
|
||||||
void SetNthOutput(int num, vtkDataObject *output)
|
|
||||||
{
|
|
||||||
vtkDataSetSource::SetNthOutput(num, output);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -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
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -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;
|
|
||||||
}
|
|
||||||
@ -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
|
|
||||||
@ -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;
|
|
||||||
}
|
|
||||||
@ -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
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
vtkFoam.C
|
|
||||||
vtkFoamAddInternalMesh.C
|
|
||||||
vtkFoamAddPatch.C
|
|
||||||
|
|
||||||
LIB = $(FOAM_LIBBIN)/libvtkFoam
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
EXE_INC = \
|
|
||||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
|
||||||
-I$(ParaView_INST_DIR)/include \
|
|
||||||
-I../PVFoamReader
|
|
||||||
|
|
||||||
LIB_LIBS = \
|
|
||||||
-lfiniteVolume \
|
|
||||||
-lgenericPatchFields \
|
|
||||||
$(GLIBS)
|
|
||||||
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -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
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -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
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -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
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -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
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -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
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -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
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -35,6 +35,7 @@ InClass
|
|||||||
#include "vtkFloatArray.h"
|
#include "vtkFloatArray.h"
|
||||||
#include "vtkMultiBlockDataSet.h"
|
#include "vtkMultiBlockDataSet.h"
|
||||||
#include "vtkPolyData.h"
|
#include "vtkPolyData.h"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
@ -53,11 +54,11 @@ void Foam::vtkPV3Foam::convertFaceField
|
|||||||
const labelList& faceOwner = mesh.faceOwner();
|
const labelList& faceOwner = mesh.faceOwner();
|
||||||
const labelList& faceNeigh = mesh.faceNeighbour();
|
const labelList& faceNeigh = mesh.faceNeighbour();
|
||||||
|
|
||||||
vtkFloatArray *cellData = vtkFloatArray::New();
|
vtkFloatArray* cellData = vtkFloatArray::New();
|
||||||
cellData->SetNumberOfTuples( faceLabels.size() );
|
cellData->SetNumberOfTuples(faceLabels.size());
|
||||||
cellData->SetNumberOfComponents( nComp );
|
cellData->SetNumberOfComponents(nComp);
|
||||||
cellData->Allocate( nComp*faceLabels.size() );
|
cellData->Allocate(nComp*faceLabels.size());
|
||||||
cellData->SetName( tf.name().c_str() );
|
cellData->SetName(tf.name().c_str());
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -123,11 +124,11 @@ void Foam::vtkPV3Foam::convertFaceField
|
|||||||
const labelList& faceOwner = mesh.faceOwner();
|
const labelList& faceOwner = mesh.faceOwner();
|
||||||
const labelList& faceNeigh = mesh.faceNeighbour();
|
const labelList& faceNeigh = mesh.faceNeighbour();
|
||||||
|
|
||||||
vtkFloatArray *cellData = vtkFloatArray::New();
|
vtkFloatArray* cellData = vtkFloatArray::New();
|
||||||
cellData->SetNumberOfTuples( fSet.size() );
|
cellData->SetNumberOfTuples(fSet.size());
|
||||||
cellData->SetNumberOfComponents( nComp );
|
cellData->SetNumberOfComponents(nComp);
|
||||||
cellData->Allocate( nComp*fSet.size() );
|
cellData->Allocate(nComp*fSet.size());
|
||||||
cellData->SetName( tf.name().c_str() );
|
cellData->SetName(tf.name().c_str());
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -80,8 +80,8 @@ vtkPolyData* Foam::vtkPV3Foam::lagrangianVTKMesh
|
|||||||
vtkPoints* vtkpoints = vtkPoints::New();
|
vtkPoints* vtkpoints = vtkPoints::New();
|
||||||
vtkCellArray* vtkcells = vtkCellArray::New();
|
vtkCellArray* vtkcells = vtkCellArray::New();
|
||||||
|
|
||||||
vtkpoints->Allocate( parcels.size() );
|
vtkpoints->Allocate(parcels.size());
|
||||||
vtkcells->Allocate( parcels.size() );
|
vtkcells->Allocate(parcels.size());
|
||||||
|
|
||||||
vtkIdType particleId = 0;
|
vtkIdType particleId = 0;
|
||||||
forAllConstIter(Cloud<passiveParticle>, parcels, iter)
|
forAllConstIter(Cloud<passiveParticle>, parcels, iter)
|
||||||
|
|||||||
@ -22,8 +22,6 @@ License
|
|||||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Description
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "vtkPV3Foam.H"
|
#include "vtkPV3Foam.H"
|
||||||
@ -40,10 +38,7 @@ Description
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh
|
vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh(const polyPatch& p)
|
||||||
(
|
|
||||||
const polyPatch& p
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||||
|
|
||||||
@ -56,8 +51,8 @@ vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh
|
|||||||
// Convert Foam mesh vertices to VTK
|
// Convert Foam mesh vertices to VTK
|
||||||
const Foam::pointField& points = p.localPoints();
|
const Foam::pointField& points = p.localPoints();
|
||||||
|
|
||||||
vtkPoints *vtkpoints = vtkPoints::New();
|
vtkPoints* vtkpoints = vtkPoints::New();
|
||||||
vtkpoints->Allocate( points.size() );
|
vtkpoints->Allocate(points.size());
|
||||||
forAll(points, i)
|
forAll(points, i)
|
||||||
{
|
{
|
||||||
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
|
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
|
||||||
@ -71,7 +66,7 @@ vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh
|
|||||||
const faceList& faces = p.localFaces();
|
const faceList& faces = p.localFaces();
|
||||||
|
|
||||||
vtkCellArray* vtkcells = vtkCellArray::New();
|
vtkCellArray* vtkcells = vtkCellArray::New();
|
||||||
vtkcells->Allocate( faces.size() );
|
vtkcells->Allocate(faces.size());
|
||||||
forAll(faces, faceI)
|
forAll(faces, faceI)
|
||||||
{
|
{
|
||||||
const face& f = faces[faceI];
|
const face& f = faces[faceI];
|
||||||
|
|||||||
@ -22,8 +22,6 @@ License
|
|||||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Description
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "vtkPV3Foam.H"
|
#include "vtkPV3Foam.H"
|
||||||
@ -71,8 +69,8 @@ vtkPolyData* Foam::vtkPV3Foam::faceSetVTKMesh
|
|||||||
// Convert Foam mesh vertices to VTK
|
// Convert Foam mesh vertices to VTK
|
||||||
const pointField& points = p.localPoints();
|
const pointField& points = p.localPoints();
|
||||||
|
|
||||||
vtkPoints *vtkpoints = vtkPoints::New();
|
vtkPoints* vtkpoints = vtkPoints::New();
|
||||||
vtkpoints->Allocate( points.size() );
|
vtkpoints->Allocate(points.size());
|
||||||
forAll(points, i)
|
forAll(points, i)
|
||||||
{
|
{
|
||||||
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
|
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
|
||||||
@ -84,7 +82,7 @@ vtkPolyData* Foam::vtkPV3Foam::faceSetVTKMesh
|
|||||||
const faceList& faces = p.localFaces();
|
const faceList& faces = p.localFaces();
|
||||||
|
|
||||||
vtkCellArray* vtkcells = vtkCellArray::New();
|
vtkCellArray* vtkcells = vtkCellArray::New();
|
||||||
vtkcells->Allocate( faces.size() );
|
vtkcells->Allocate(faces.size());
|
||||||
|
|
||||||
forAll(faces, faceI)
|
forAll(faces, faceI)
|
||||||
{
|
{
|
||||||
@ -127,8 +125,8 @@ vtkPolyData* Foam::vtkPV3Foam::pointSetVTKMesh
|
|||||||
|
|
||||||
const pointField& meshPoints = mesh.points();
|
const pointField& meshPoints = mesh.points();
|
||||||
|
|
||||||
vtkPoints *vtkpoints = vtkPoints::New();
|
vtkPoints* vtkpoints = vtkPoints::New();
|
||||||
vtkpoints->Allocate( pSet.size() );
|
vtkpoints->Allocate(pSet.size());
|
||||||
|
|
||||||
forAllConstIter(pointSet, pSet, iter)
|
forAllConstIter(pointSet, pSet, iter)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -22,8 +22,6 @@ License
|
|||||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Description
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "vtkPV3Foam.H"
|
#include "vtkPV3Foam.H"
|
||||||
@ -136,8 +134,8 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert Foam mesh vertices to VTK
|
// Convert Foam mesh vertices to VTK
|
||||||
vtkPoints *vtkpoints = vtkPoints::New();
|
vtkPoints* vtkpoints = vtkPoints::New();
|
||||||
vtkpoints->Allocate( mesh.nPoints() + nAddPoints );
|
vtkpoints->Allocate(mesh.nPoints() + nAddPoints);
|
||||||
|
|
||||||
const Foam::pointField& points = mesh.points();
|
const Foam::pointField& points = mesh.points();
|
||||||
|
|
||||||
@ -152,7 +150,7 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh
|
|||||||
Info<< "... converting cells" << endl;
|
Info<< "... converting cells" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkmesh->Allocate( mesh.nCells() + nAddCells );
|
vtkmesh->Allocate(mesh.nCells() + nAddCells);
|
||||||
|
|
||||||
// Set counters for additional points and additional cells
|
// Set counters for additional points and additional cells
|
||||||
label addPointI = 0, addCellI = 0;
|
label addPointI = 0, addCellI = 0;
|
||||||
|
|||||||
@ -22,8 +22,6 @@ License
|
|||||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Description
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "vtkPV3Foam.H"
|
#include "vtkPV3Foam.H"
|
||||||
@ -69,7 +67,7 @@ vtkPolyData* Foam::vtkPV3Foam::faceZoneVTKMesh
|
|||||||
const pointField& points = p.localPoints();
|
const pointField& points = p.localPoints();
|
||||||
|
|
||||||
vtkPoints* vtkpoints = vtkPoints::New();
|
vtkPoints* vtkpoints = vtkPoints::New();
|
||||||
vtkpoints->Allocate( points.size() );
|
vtkpoints->Allocate(points.size());
|
||||||
forAll(points, i)
|
forAll(points, i)
|
||||||
{
|
{
|
||||||
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
|
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
|
||||||
@ -83,7 +81,7 @@ vtkPolyData* Foam::vtkPV3Foam::faceZoneVTKMesh
|
|||||||
const faceList& faces = p.localFaces();
|
const faceList& faces = p.localFaces();
|
||||||
|
|
||||||
vtkCellArray* vtkcells = vtkCellArray::New();
|
vtkCellArray* vtkcells = vtkCellArray::New();
|
||||||
vtkcells->Allocate( faces.size() );
|
vtkcells->Allocate(faces.size());
|
||||||
|
|
||||||
forAll(faces, faceI)
|
forAll(faces, faceI)
|
||||||
{
|
{
|
||||||
@ -126,8 +124,8 @@ vtkPolyData* Foam::vtkPV3Foam::pointZoneVTKMesh
|
|||||||
|
|
||||||
const pointField& meshPoints = mesh.points();
|
const pointField& meshPoints = mesh.points();
|
||||||
|
|
||||||
vtkPoints *vtkpoints = vtkPoints::New();
|
vtkPoints* vtkpoints = vtkPoints::New();
|
||||||
vtkpoints->Allocate( pointLabels.size() );
|
vtkpoints->Allocate(pointLabels.size());
|
||||||
|
|
||||||
forAll(pointLabels, pointI)
|
forAll(pointLabels, pointI)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -52,10 +52,10 @@ void Foam::vtkPV3Foam::convertPatchField
|
|||||||
const label nComp = pTraits<Type>::nComponents;
|
const label nComp = pTraits<Type>::nComponents;
|
||||||
|
|
||||||
vtkFloatArray* cellData = vtkFloatArray::New();
|
vtkFloatArray* cellData = vtkFloatArray::New();
|
||||||
cellData->SetNumberOfTuples( ptf.size() );
|
cellData->SetNumberOfTuples(ptf.size());
|
||||||
cellData->SetNumberOfComponents( nComp );
|
cellData->SetNumberOfComponents(nComp);
|
||||||
cellData->Allocate( nComp*ptf.size() );
|
cellData->Allocate(nComp*ptf.size());
|
||||||
cellData->SetName( name.c_str() );
|
cellData->SetName(name.c_str());
|
||||||
|
|
||||||
float vec[nComp];
|
float vec[nComp];
|
||||||
forAll(ptf, i)
|
forAll(ptf, i)
|
||||||
@ -91,11 +91,11 @@ void Foam::vtkPV3Foam::convertPatchPointField
|
|||||||
{
|
{
|
||||||
const label nComp = pTraits<Type>::nComponents;
|
const label nComp = pTraits<Type>::nComponents;
|
||||||
|
|
||||||
vtkFloatArray *pointData = vtkFloatArray::New();
|
vtkFloatArray* pointData = vtkFloatArray::New();
|
||||||
pointData->SetNumberOfTuples( pptf.size() );
|
pointData->SetNumberOfTuples(pptf.size());
|
||||||
pointData->SetNumberOfComponents( nComp );
|
pointData->SetNumberOfComponents(nComp);
|
||||||
pointData->Allocate( nComp*pptf.size() );
|
pointData->Allocate(nComp*pptf.size());
|
||||||
pointData->SetName( name.c_str() );
|
pointData->SetName(name.c_str());
|
||||||
|
|
||||||
float vec[nComp];
|
float vec[nComp];
|
||||||
forAll(pptf, i)
|
forAll(pptf, i)
|
||||||
|
|||||||
@ -110,9 +110,9 @@ void Foam::vtkPV3Foam::convertPointFields
|
|||||||
++partId
|
++partId
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const word patchName = getPartName(partId);
|
const word patchName = getPartName(partId);
|
||||||
const label datasetNo = partDataset_[partId];
|
const label datasetNo = partDataset_[partId];
|
||||||
const label patchId = patches.findPatchID(patchName);
|
const label patchId = patches.findPatchID(patchName);
|
||||||
|
|
||||||
if (!partStatus_[partId] || datasetNo < 0 || patchId < 0)
|
if (!partStatus_[partId] || datasetNo < 0 || patchId < 0)
|
||||||
{
|
{
|
||||||
@ -187,7 +187,7 @@ void Foam::vtkPV3Foam::convertPointField
|
|||||||
nPoints = ptf.size();
|
nPoints = ptf.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkFloatArray *pointData = vtkFloatArray::New();
|
vtkFloatArray* pointData = vtkFloatArray::New();
|
||||||
pointData->SetNumberOfTuples(nPoints + addPointCellLabels.size());
|
pointData->SetNumberOfTuples(nPoints + addPointCellLabels.size());
|
||||||
pointData->SetNumberOfComponents(nComp);
|
pointData->SetNumberOfComponents(nComp);
|
||||||
pointData->Allocate(nComp*(nPoints + addPointCellLabels.size()));
|
pointData->Allocate(nComp*(nPoints + addPointCellLabels.size()));
|
||||||
|
|||||||
@ -140,7 +140,6 @@ void Foam::vtkPV3Foam::updateInfoInternalMesh()
|
|||||||
|
|
||||||
Info<< "<end> Foam::vtkPV3Foam::updateInfoInternalMesh" << endl;
|
Info<< "<end> Foam::vtkPV3Foam::updateInfoInternalMesh" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -440,14 +439,13 @@ void Foam::vtkPV3Foam::updateInfoLagrangianFields()
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkDataArraySelection *fieldSelection =
|
vtkDataArraySelection* fieldSelection =
|
||||||
reader_->GetLagrangianFieldSelection();
|
reader_->GetLagrangianFieldSelection();
|
||||||
|
|
||||||
// preserve the enabled selections
|
// preserve the enabled selections
|
||||||
stringList enabledEntries = getSelectedArrayEntries(fieldSelection);
|
stringList enabledEntries = getSelectedArrayEntries(fieldSelection);
|
||||||
fieldSelection->RemoveAllArrays();
|
fieldSelection->RemoveAllArrays();
|
||||||
|
|
||||||
//
|
|
||||||
// TODO - currently only get fields from ONE cloud
|
// TODO - currently only get fields from ONE cloud
|
||||||
// have to decide if the second set of fields get mixed in
|
// have to decide if the second set of fields get mixed in
|
||||||
// or dealt with separately
|
// or dealt with separately
|
||||||
|
|||||||
@ -35,7 +35,7 @@ InClass
|
|||||||
template<template<class> class patchType, class meshType>
|
template<template<class> class patchType, class meshType>
|
||||||
void Foam::vtkPV3Foam::updateInfoFields
|
void Foam::vtkPV3Foam::updateInfoFields
|
||||||
(
|
(
|
||||||
vtkDataArraySelection *select
|
vtkDataArraySelection* select
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -112,4 +112,5 @@ void Foam::vtkPV3Foam::updateInfoFields
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -69,6 +69,7 @@ namespace Foam
|
|||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::vtkPV3Foam::AddToBlock
|
void Foam::vtkPV3Foam::AddToBlock
|
||||||
|
|||||||
@ -62,7 +62,7 @@ void writeProcStats
|
|||||||
// Determine surface bounding boxes, faces, points
|
// Determine surface bounding boxes, faces, points
|
||||||
List<treeBoundBox> surfBb(Pstream::nProcs());
|
List<treeBoundBox> surfBb(Pstream::nProcs());
|
||||||
{
|
{
|
||||||
surfBb[Pstream::myProcNo()] = boundBox(s.points(), false);
|
surfBb[Pstream::myProcNo()] = treeBoundBox(s.points());
|
||||||
Pstream::gatherList(surfBb);
|
Pstream::gatherList(surfBb);
|
||||||
Pstream::scatterList(surfBb);
|
Pstream::scatterList(surfBb);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,8 +82,8 @@ export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
|
|||||||
: ${WM_OSTYPE:=POSIX}; export WM_OSTYPE
|
: ${WM_OSTYPE:=POSIX}; export WM_OSTYPE
|
||||||
|
|
||||||
|
|
||||||
# Compiler: set to Gcc, Gcc43 or Icc (for Intel's icc)
|
# Compiler: set to Gcc, Gcc43, Gcc44, or Icc (for Intel's icc)
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
: ${WM_COMPILER:=Gcc}; export WM_COMPILER
|
: ${WM_COMPILER:=Gcc}; export WM_COMPILER
|
||||||
|
|
||||||
export WM_COMPILER_ARCH=
|
export WM_COMPILER_ARCH=
|
||||||
|
|||||||
@ -76,8 +76,8 @@ setenv WM_THIRD_PARTY_DIR $WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
|
|||||||
if ( ! $?WM_OSTYPE ) setenv WM_OSTYPE POSIX
|
if ( ! $?WM_OSTYPE ) setenv WM_OSTYPE POSIX
|
||||||
|
|
||||||
|
|
||||||
# Compiler: set to Gcc, Gcc43 or Icc (for Intel's icc)
|
# Compiler: set to Gcc, Gcc43, Gcc44 or Icc (for Intel's icc)
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
if ( ! $?WM_COMPILER ) setenv WM_COMPILER Gcc
|
if ( ! $?WM_COMPILER ) setenv WM_COMPILER Gcc
|
||||||
|
|
||||||
setenv WM_COMPILER_ARCH
|
setenv WM_COMPILER_ARCH
|
||||||
|
|||||||
@ -87,12 +87,12 @@ switch ("$compilerInstall")
|
|||||||
case OpenFOAM:
|
case OpenFOAM:
|
||||||
switch ("$WM_COMPILER")
|
switch ("$WM_COMPILER")
|
||||||
case Gcc:
|
case Gcc:
|
||||||
setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.3.3/platforms/$WM_ARCH$WM_COMPILER_ARCH
|
setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.4.2/platforms/$WM_ARCH$WM_COMPILER_ARCH
|
||||||
_foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
_foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
||||||
_foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
_foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
||||||
breaksw
|
breaksw
|
||||||
case Gcc44:
|
case Gcc44:
|
||||||
setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH
|
setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.4.2/platforms/$WM_ARCH$WM_COMPILER_ARCH
|
||||||
_foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
_foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
||||||
_foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
_foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
||||||
breaksw
|
breaksw
|
||||||
|
|||||||
@ -111,12 +111,12 @@ case "${compilerInstall:-OpenFOAM}" in
|
|||||||
OpenFOAM)
|
OpenFOAM)
|
||||||
case "$WM_COMPILER" in
|
case "$WM_COMPILER" in
|
||||||
Gcc)
|
Gcc)
|
||||||
export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.3/platforms/$WM_ARCH$WM_COMPILER_ARCH
|
export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.4.2/platforms/$WM_ARCH$WM_COMPILER_ARCH
|
||||||
_foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
_foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
||||||
_foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
_foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
||||||
;;
|
;;
|
||||||
Gcc44)
|
Gcc44)
|
||||||
export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH
|
export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.4.2/platforms/$WM_ARCH$WM_COMPILER_ARCH
|
||||||
_foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
_foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
||||||
_foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
_foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
|
||||||
;;
|
;;
|
||||||
|
|||||||
@ -61,8 +61,16 @@ namespace Foam
|
|||||||
|
|
||||||
template<class T, class Container> class CompactListList;
|
template<class T, class Container> class CompactListList;
|
||||||
|
|
||||||
template<class T, class Container> Istream& operator>>(Istream&, CompactListList<T, Container>&);
|
template<class T, class Container> Istream& operator>>
|
||||||
template<class T, class Container> Ostream& operator<<(Ostream&, const CompactListList<T, Container>&);
|
(
|
||||||
|
Istream&,
|
||||||
|
CompactListList<T, Container>&
|
||||||
|
);
|
||||||
|
template<class T, class Container> Ostream& operator<<
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const CompactListList<T, Container>&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
|
|||||||
@ -52,20 +52,11 @@ Foam::tmp
|
|||||||
typename Foam::GeometricField<Type, PatchField, GeoMesh>::
|
typename Foam::GeometricField<Type, PatchField, GeoMesh>::
|
||||||
GeometricBoundaryField
|
GeometricBoundaryField
|
||||||
>
|
>
|
||||||
Foam::GeometricField<Type, PatchField, GeoMesh>::readField(Istream& is)
|
Foam::GeometricField<Type, PatchField, GeoMesh>::readField
|
||||||
|
(
|
||||||
|
const dictionary& fieldDict
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (is.version() < 2.0)
|
|
||||||
{
|
|
||||||
FatalIOErrorIn
|
|
||||||
(
|
|
||||||
"GeometricField<Type, PatchField, GeoMesh>::readField(Istream&)",
|
|
||||||
is
|
|
||||||
) << "IO versions < 2.0 are not supported."
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
dictionary fieldDict(is);
|
|
||||||
|
|
||||||
DimensionedField<Type, GeoMesh>::readField(fieldDict, "internalField");
|
DimensionedField<Type, GeoMesh>::readField(fieldDict, "internalField");
|
||||||
|
|
||||||
tmp<GeometricBoundaryField> tboundaryField
|
tmp<GeometricBoundaryField> tboundaryField
|
||||||
@ -96,6 +87,28 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::readField(Istream& is)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
Foam::tmp
|
||||||
|
<
|
||||||
|
typename Foam::GeometricField<Type, PatchField, GeoMesh>::
|
||||||
|
GeometricBoundaryField
|
||||||
|
>
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::readField(Istream& is)
|
||||||
|
{
|
||||||
|
if (is.version() < 2.0)
|
||||||
|
{
|
||||||
|
FatalIOErrorIn
|
||||||
|
(
|
||||||
|
"GeometricField<Type, PatchField, GeoMesh>::readField(Istream&)",
|
||||||
|
is
|
||||||
|
) << "IO versions < 2.0 are not supported."
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return readField(dictionary(is));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
bool Foam::GeometricField<Type, PatchField, GeoMesh>::readIfPresent()
|
bool Foam::GeometricField<Type, PatchField, GeoMesh>::readIfPresent()
|
||||||
{
|
{
|
||||||
@ -404,6 +417,44 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
DimensionedField<Type, GeoMesh>(io, mesh, dimless),
|
||||||
|
timeIndex_(this->time().timeIndex()),
|
||||||
|
field0Ptr_(NULL),
|
||||||
|
fieldPrevIterPtr_(NULL),
|
||||||
|
boundaryField_(*this, readField(dict))
|
||||||
|
{
|
||||||
|
// Check compatibility between field and mesh
|
||||||
|
|
||||||
|
if (this->size() != GeoMesh::size(this->mesh()))
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"GeometricField<Type, PatchField, GeoMesh>::GeometricField"
|
||||||
|
"(const IOobject&, const Mesh&, const dictionary&)"
|
||||||
|
) << " number of field elements = " << this->size()
|
||||||
|
<< " number of mesh elements = " << GeoMesh::size(this->mesh())
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
readOldTimeIfPresent();
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "Finishing dictionary-construct of "
|
||||||
|
"GeometricField<Type, PatchField, GeoMesh>"
|
||||||
|
<< endl << this->info() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// construct as copy
|
// construct as copy
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
||||||
|
|||||||
@ -240,6 +240,9 @@ private:
|
|||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
|
|
||||||
|
//- Read the field from the dictionary
|
||||||
|
tmp<GeometricBoundaryField> readField(const dictionary&);
|
||||||
|
|
||||||
//- Read the field from the given stream
|
//- Read the field from the given stream
|
||||||
tmp<GeometricBoundaryField> readField(Istream& is);
|
tmp<GeometricBoundaryField> readField(Istream& is);
|
||||||
|
|
||||||
@ -327,6 +330,14 @@ public:
|
|||||||
Istream&
|
Istream&
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
GeometricField
|
||||||
|
(
|
||||||
|
const IOobject&,
|
||||||
|
const Mesh&,
|
||||||
|
const dictionary&
|
||||||
|
);
|
||||||
|
|
||||||
//- Construct as copy
|
//- Construct as copy
|
||||||
GeometricField
|
GeometricField
|
||||||
(
|
(
|
||||||
|
|||||||
@ -66,6 +66,14 @@ Foam::UIPstream::UIPstream
|
|||||||
|
|
||||||
label wantedSize = externalBuf_.capacity();
|
label wantedSize = externalBuf_.capacity();
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UIPstream::UIPstream : read from:" << fromProcNo
|
||||||
|
<< " tag:" << tag << " wanted size:" << wantedSize
|
||||||
|
<< Foam::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// If the buffer size is not specified, probe the incomming message
|
// If the buffer size is not specified, probe the incomming message
|
||||||
// and set it
|
// and set it
|
||||||
if (!wantedSize)
|
if (!wantedSize)
|
||||||
@ -75,6 +83,12 @@ Foam::UIPstream::UIPstream
|
|||||||
|
|
||||||
externalBuf_.setCapacity(messageSize_);
|
externalBuf_.setCapacity(messageSize_);
|
||||||
wantedSize = messageSize_;
|
wantedSize = messageSize_;
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UIPstream::UIPstream : probed size:" << wantedSize
|
||||||
|
<< Foam::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
messageSize_ = UIPstream::read
|
messageSize_ = UIPstream::read
|
||||||
@ -127,6 +141,7 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
|
|||||||
if (commsType() == UPstream::nonBlocking)
|
if (commsType() == UPstream::nonBlocking)
|
||||||
{
|
{
|
||||||
// Message is already received into externalBuf
|
// Message is already received into externalBuf
|
||||||
|
messageSize_ = buffers.recvBuf_[fromProcNo].size();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -134,6 +149,14 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
|
|||||||
|
|
||||||
label wantedSize = externalBuf_.capacity();
|
label wantedSize = externalBuf_.capacity();
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UIPstream::UIPstream PstreamBuffers :"
|
||||||
|
<< " read from:" << fromProcNo
|
||||||
|
<< " tag:" << tag_ << " wanted size:" << wantedSize
|
||||||
|
<< Foam::endl;
|
||||||
|
}
|
||||||
|
|
||||||
// If the buffer size is not specified, probe the incomming message
|
// If the buffer size is not specified, probe the incomming message
|
||||||
// and set it
|
// and set it
|
||||||
if (!wantedSize)
|
if (!wantedSize)
|
||||||
@ -143,6 +166,12 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
|
|||||||
|
|
||||||
externalBuf_.setCapacity(messageSize_);
|
externalBuf_.setCapacity(messageSize_);
|
||||||
wantedSize = messageSize_;
|
wantedSize = messageSize_;
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UIPstream::UIPstream PstreamBuffers : probed size:"
|
||||||
|
<< wantedSize << Foam::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
messageSize_ = UIPstream::read
|
messageSize_ = UIPstream::read
|
||||||
@ -180,6 +209,14 @@ Foam::label Foam::UIPstream::read
|
|||||||
const int tag
|
const int tag
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UIPstream::read : starting read from:" << fromProcNo
|
||||||
|
<< " tag:" << tag << " wanted size:" << label(bufSize)
|
||||||
|
<< " commsType:" << UPstream::commsTypeNames[commsType]
|
||||||
|
<< Foam::endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (commsType == blocking || commsType == scheduled)
|
if (commsType == blocking || commsType == scheduled)
|
||||||
{
|
{
|
||||||
MPI_Status status;
|
MPI_Status status;
|
||||||
@ -214,6 +251,14 @@ Foam::label Foam::UIPstream::read
|
|||||||
label messageSize;
|
label messageSize;
|
||||||
MPI_Get_count(&status, MPI_BYTE, &messageSize);
|
MPI_Get_count(&status, MPI_BYTE, &messageSize);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UIPstream::read : finished read from:" << fromProcNo
|
||||||
|
<< " tag:" << tag << " read size:" << label(bufSize)
|
||||||
|
<< " commsType:" << UPstream::commsTypeNames[commsType]
|
||||||
|
<< Foam::endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (messageSize > bufSize)
|
if (messageSize > bufSize)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
@ -256,6 +301,15 @@ Foam::label Foam::UIPstream::read
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UIPstream::read : started read from:" << fromProcNo
|
||||||
|
<< " tag:" << tag << " read size:" << label(bufSize)
|
||||||
|
<< " commsType:" << UPstream::commsTypeNames[commsType]
|
||||||
|
<< " request:" << PstreamGlobals::outstandingRequests_.size()
|
||||||
|
<< Foam::endl;
|
||||||
|
}
|
||||||
|
|
||||||
PstreamGlobals::outstandingRequests_.append(request);
|
PstreamGlobals::outstandingRequests_.append(request);
|
||||||
|
|
||||||
// Assume the message is completely received.
|
// Assume the message is completely received.
|
||||||
@ -267,7 +321,8 @@ Foam::label Foam::UIPstream::read
|
|||||||
(
|
(
|
||||||
"UIPstream::read"
|
"UIPstream::read"
|
||||||
"(const int fromProcNo, char* buf, std::streamsize bufSize)"
|
"(const int fromProcNo, char* buf, std::streamsize bufSize)"
|
||||||
) << "Unsupported communications type " << commsType
|
) << "Unsupported communications type "
|
||||||
|
<< commsType
|
||||||
<< Foam::abort(FatalError);
|
<< Foam::abort(FatalError);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -43,6 +43,14 @@ bool Foam::UOPstream::write
|
|||||||
const int tag
|
const int tag
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UIPstream::write : starting write to:" << toProcNo
|
||||||
|
<< " tag:" << tag << " size:" << label(bufSize)
|
||||||
|
<< " commsType:" << UPstream::commsTypeNames[commsType]
|
||||||
|
<< Foam::endl;
|
||||||
|
}
|
||||||
|
|
||||||
bool transferFailed = true;
|
bool transferFailed = true;
|
||||||
|
|
||||||
if (commsType == blocking)
|
if (commsType == blocking)
|
||||||
@ -56,6 +64,14 @@ bool Foam::UOPstream::write
|
|||||||
tag,
|
tag,
|
||||||
MPI_COMM_WORLD
|
MPI_COMM_WORLD
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UIPstream::write : finished write to:" << toProcNo
|
||||||
|
<< " tag:" << tag << " size:" << label(bufSize)
|
||||||
|
<< " commsType:" << UPstream::commsTypeNames[commsType]
|
||||||
|
<< Foam::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (commsType == scheduled)
|
else if (commsType == scheduled)
|
||||||
{
|
{
|
||||||
@ -68,6 +84,14 @@ bool Foam::UOPstream::write
|
|||||||
tag,
|
tag,
|
||||||
MPI_COMM_WORLD
|
MPI_COMM_WORLD
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UIPstream::write : finished write to:" << toProcNo
|
||||||
|
<< " tag:" << tag << " size:" << label(bufSize)
|
||||||
|
<< " commsType:" << UPstream::commsTypeNames[commsType]
|
||||||
|
<< Foam::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (commsType == nonBlocking)
|
else if (commsType == nonBlocking)
|
||||||
{
|
{
|
||||||
@ -84,6 +108,15 @@ bool Foam::UOPstream::write
|
|||||||
&request
|
&request
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UIPstream::write : started write to:" << toProcNo
|
||||||
|
<< " tag:" << tag << " size:" << label(bufSize)
|
||||||
|
<< " commsType:" << UPstream::commsTypeNames[commsType]
|
||||||
|
<< " request:" << PstreamGlobals::outstandingRequests_.size()
|
||||||
|
<< Foam::endl;
|
||||||
|
}
|
||||||
|
|
||||||
PstreamGlobals::outstandingRequests_.append(request);
|
PstreamGlobals::outstandingRequests_.append(request);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -93,7 +126,8 @@ bool Foam::UOPstream::write
|
|||||||
"UOPstream::write"
|
"UOPstream::write"
|
||||||
"(const int fromProcNo, char* buf, std::streamsize bufSize"
|
"(const int fromProcNo, char* buf, std::streamsize bufSize"
|
||||||
", const int)"
|
", const int)"
|
||||||
) << "Unsupported communications type " << commsType
|
) << "Unsupported communications type "
|
||||||
|
<< UPstream::commsTypeNames[commsType]
|
||||||
<< Foam::abort(FatalError);
|
<< Foam::abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,6 +70,12 @@ bool Foam::UPstream::init(int& argc, char**& argv)
|
|||||||
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
|
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
|
||||||
MPI_Comm_rank(MPI_COMM_WORLD, &myProcNo_);
|
MPI_Comm_rank(MPI_COMM_WORLD, &myProcNo_);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UPstream::init : initialised with numProcs:" << numprocs
|
||||||
|
<< " myProcNo:" << myProcNo_ << endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (numprocs <= 1)
|
if (numprocs <= 1)
|
||||||
{
|
{
|
||||||
FatalErrorIn("UPstream::init(int& argc, char**& argv)")
|
FatalErrorIn("UPstream::init(int& argc, char**& argv)")
|
||||||
@ -124,6 +130,11 @@ bool Foam::UPstream::init(int& argc, char**& argv)
|
|||||||
|
|
||||||
void Foam::UPstream::exit(int errnum)
|
void Foam::UPstream::exit(int errnum)
|
||||||
{
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UPstream::exit." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
# ifndef SGIMPI
|
# ifndef SGIMPI
|
||||||
int size;
|
int size;
|
||||||
char* buff;
|
char* buff;
|
||||||
@ -164,6 +175,11 @@ void Foam::UPstream::abort()
|
|||||||
|
|
||||||
void Foam::reduce(scalar& Value, const sumOp<scalar>& bop)
|
void Foam::reduce(scalar& Value, const sumOp<scalar>& bop)
|
||||||
{
|
{
|
||||||
|
if (Pstream::debug)
|
||||||
|
{
|
||||||
|
Pout<< "Foam::reduce : value:" << Value << endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (!UPstream::parRun())
|
if (!UPstream::parRun())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -433,11 +449,23 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Pstream::debug)
|
||||||
|
{
|
||||||
|
Pout<< "Foam::reduce : reduced value:" << Value << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::UPstream::waitRequests()
|
void Foam::UPstream::waitRequests()
|
||||||
{
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UPstream::waitRequests : starting wait for "
|
||||||
|
<< PstreamGlobals::outstandingRequests_.size()
|
||||||
|
<< " outstanding requests." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (PstreamGlobals::outstandingRequests_.size())
|
if (PstreamGlobals::outstandingRequests_.size())
|
||||||
{
|
{
|
||||||
if
|
if
|
||||||
@ -458,11 +486,22 @@ void Foam::UPstream::waitRequests()
|
|||||||
|
|
||||||
PstreamGlobals::outstandingRequests_.clear();
|
PstreamGlobals::outstandingRequests_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UPstream::waitRequests : finished wait." << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::UPstream::finishedRequest(const label i)
|
bool Foam::UPstream::finishedRequest(const label i)
|
||||||
{
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UPstream::waitRequests : starting wait for request:" << i
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (i >= PstreamGlobals::outstandingRequests_.size())
|
if (i >= PstreamGlobals::outstandingRequests_.size())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
@ -483,6 +522,12 @@ bool Foam::UPstream::finishedRequest(const label i)
|
|||||||
MPI_STATUS_IGNORE
|
MPI_STATUS_IGNORE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "UPstream::waitRequests : finished wait for request:" << i
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
return flag != 0;
|
return flag != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,6 @@ perfectInterface/perfectInterface.C
|
|||||||
|
|
||||||
boundaryMesh/boundaryMesh.C
|
boundaryMesh/boundaryMesh.C
|
||||||
boundaryPatch/boundaryPatch.C
|
boundaryPatch/boundaryPatch.C
|
||||||
boundaryMesh/octreeDataFaceList.C
|
|
||||||
setUpdater/setUpdater.C
|
setUpdater/setUpdater.C
|
||||||
|
|
||||||
meshModifiers = meshCut/meshModifiers
|
meshModifiers = meshCut/meshModifiers
|
||||||
|
|||||||
@ -29,11 +29,12 @@ License
|
|||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
#include "repatchPolyTopoChanger.H"
|
#include "repatchPolyTopoChanger.H"
|
||||||
#include "faceList.H"
|
#include "faceList.H"
|
||||||
#include "octree.H"
|
#include "indexedOctree.H"
|
||||||
#include "octreeDataFaceList.H"
|
#include "treeDataPrimitivePatch.H"
|
||||||
#include "triSurface.H"
|
#include "triSurface.H"
|
||||||
#include "SortableList.H"
|
#include "SortableList.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
|
#include "uindirectPrimitivePatch.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -892,6 +893,17 @@ Foam::labelList Foam::boundaryMesh::getNearest
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uindirectPrimitivePatch leftPatch
|
||||||
|
(
|
||||||
|
UIndirectList<face>(mesh(), leftFaces),
|
||||||
|
mesh().points()
|
||||||
|
);
|
||||||
|
uindirectPrimitivePatch rightPatch
|
||||||
|
(
|
||||||
|
UIndirectList<face>(mesh(), rightFaces),
|
||||||
|
mesh().points()
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Overall bb
|
// Overall bb
|
||||||
treeBoundBox overallBb(mesh().localPoints());
|
treeBoundBox overallBb(mesh().localPoints());
|
||||||
@ -911,29 +923,35 @@ Foam::labelList Foam::boundaryMesh::getNearest
|
|||||||
bbMax.z() += 2*tol;
|
bbMax.z() += 2*tol;
|
||||||
|
|
||||||
// Create the octrees
|
// Create the octrees
|
||||||
octree<octreeDataFaceList> leftTree
|
indexedOctree
|
||||||
|
<
|
||||||
|
treeDataPrimitivePatch<face, UIndirectList, const pointField&>
|
||||||
|
> leftTree
|
||||||
(
|
(
|
||||||
overallBb,
|
treeDataPrimitivePatch<face, UIndirectList, const pointField&>
|
||||||
octreeDataFaceList
|
|
||||||
(
|
(
|
||||||
mesh(),
|
false, // cacheBb
|
||||||
leftFaces
|
leftPatch
|
||||||
),
|
),
|
||||||
1,
|
overallBb,
|
||||||
20,
|
10, // maxLevel
|
||||||
10
|
10, // leafSize
|
||||||
|
3.0 // duplicity
|
||||||
);
|
);
|
||||||
octree<octreeDataFaceList> rightTree
|
indexedOctree
|
||||||
|
<
|
||||||
|
treeDataPrimitivePatch<face, UIndirectList, const pointField&>
|
||||||
|
> rightTree
|
||||||
(
|
(
|
||||||
overallBb,
|
treeDataPrimitivePatch<face, UIndirectList, const pointField&>
|
||||||
octreeDataFaceList
|
|
||||||
(
|
(
|
||||||
mesh(),
|
false, // cacheBb
|
||||||
rightFaces
|
rightPatch
|
||||||
),
|
),
|
||||||
1,
|
overallBb,
|
||||||
20,
|
10, // maxLevel
|
||||||
10
|
10, // leafSize
|
||||||
|
3.0 // duplicity
|
||||||
);
|
);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -953,7 +971,7 @@ Foam::labelList Foam::boundaryMesh::getNearest
|
|||||||
|
|
||||||
treeBoundBox tightest;
|
treeBoundBox tightest;
|
||||||
|
|
||||||
const scalar searchDim = mag(searchSpan);
|
const scalar searchDimSqr = magSqr(searchSpan);
|
||||||
|
|
||||||
forAll(nearestBFaceI, patchFaceI)
|
forAll(nearestBFaceI, patchFaceI)
|
||||||
{
|
{
|
||||||
@ -982,50 +1000,25 @@ Foam::labelList Foam::boundaryMesh::getNearest
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Search right tree
|
// Search right tree
|
||||||
tightest.min() = ctr - searchSpan;
|
pointIndexHit rightInfo = rightTree.findNearest(ctr, searchDimSqr);
|
||||||
tightest.max() = ctr + searchSpan;
|
|
||||||
scalar rightDist = searchDim;
|
|
||||||
label rightI = rightTree.findNearest(ctr, tightest, rightDist);
|
|
||||||
|
|
||||||
|
|
||||||
// Search left tree. Note: could start from rightDist bounding box
|
// Search left tree. Note: could start from rightDist bounding box
|
||||||
// instead of starting from top.
|
// instead of starting from top.
|
||||||
tightest.min() = ctr - searchSpan;
|
pointIndexHit leftInfo = leftTree.findNearest(ctr, searchDimSqr);
|
||||||
tightest.max() = ctr + searchSpan;
|
|
||||||
scalar leftDist = searchDim;
|
|
||||||
label leftI = leftTree.findNearest(ctr, tightest, leftDist);
|
|
||||||
|
|
||||||
|
if (rightInfo.hit())
|
||||||
if (rightI == -1)
|
|
||||||
{
|
{
|
||||||
// No face found in right tree.
|
if (leftInfo.hit())
|
||||||
|
|
||||||
if (leftI == -1)
|
|
||||||
{
|
|
||||||
// No face found in left tree.
|
|
||||||
nearestBFaceI[patchFaceI] = -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Found in left but not in right. Choose left regardless if
|
|
||||||
// correct sign. Note: do we want this?
|
|
||||||
nearestBFaceI[patchFaceI] = leftFaces[leftI];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (leftI == -1)
|
|
||||||
{
|
|
||||||
// Found in right but not in left. Choose right regardless if
|
|
||||||
// correct sign. Note: do we want this?
|
|
||||||
nearestBFaceI[patchFaceI] = rightFaces[rightI];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Found in both trees. Compare normals.
|
// Found in both trees. Compare normals.
|
||||||
|
label rightFaceI = rightFaces[rightInfo.index()];
|
||||||
|
label leftFaceI = leftFaces[leftInfo.index()];
|
||||||
|
|
||||||
scalar rightSign = n & ns[rightFaces[rightI]];
|
label rightDist = mag(rightInfo.hitPoint()-ctr);
|
||||||
scalar leftSign = n & ns[leftFaces[leftI]];
|
label leftDist = mag(leftInfo.hitPoint()-ctr);
|
||||||
|
|
||||||
|
scalar rightSign = n & ns[rightFaceI];
|
||||||
|
scalar leftSign = n & ns[leftFaceI];
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -1036,11 +1029,11 @@ Foam::labelList Foam::boundaryMesh::getNearest
|
|||||||
// Both same sign. Choose nearest.
|
// Both same sign. Choose nearest.
|
||||||
if (rightDist < leftDist)
|
if (rightDist < leftDist)
|
||||||
{
|
{
|
||||||
nearestBFaceI[patchFaceI] = rightFaces[rightI];
|
nearestBFaceI[patchFaceI] = rightFaceI;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nearestBFaceI[patchFaceI] = leftFaces[leftI];
|
nearestBFaceI[patchFaceI] = leftFaceI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1059,11 +1052,11 @@ Foam::labelList Foam::boundaryMesh::getNearest
|
|||||||
// Different sign and nearby. Choosing matching normal
|
// Different sign and nearby. Choosing matching normal
|
||||||
if (rightSign > 0)
|
if (rightSign > 0)
|
||||||
{
|
{
|
||||||
nearestBFaceI[patchFaceI] = rightFaces[rightI];
|
nearestBFaceI[patchFaceI] = rightFaceI;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nearestBFaceI[patchFaceI] = leftFaces[leftI];
|
nearestBFaceI[patchFaceI] = leftFaceI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1071,15 +1064,38 @@ Foam::labelList Foam::boundaryMesh::getNearest
|
|||||||
// Different sign but faraway. Choosing nearest.
|
// Different sign but faraway. Choosing nearest.
|
||||||
if (rightDist < leftDist)
|
if (rightDist < leftDist)
|
||||||
{
|
{
|
||||||
nearestBFaceI[patchFaceI] = rightFaces[rightI];
|
nearestBFaceI[patchFaceI] = rightFaceI;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nearestBFaceI[patchFaceI] = leftFaces[leftI];
|
nearestBFaceI[patchFaceI] = leftFaceI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Found in right but not in left. Choose right regardless if
|
||||||
|
// correct sign. Note: do we want this?
|
||||||
|
label rightFaceI = rightFaces[rightInfo.index()];
|
||||||
|
nearestBFaceI[patchFaceI] = rightFaceI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No face found in right tree.
|
||||||
|
|
||||||
|
if (leftInfo.hit())
|
||||||
|
{
|
||||||
|
// Found in left but not in right. Choose left regardless if
|
||||||
|
// correct sign. Note: do we want this?
|
||||||
|
nearestBFaceI[patchFaceI] = leftFaces[leftInfo.index()];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No face found in left tree.
|
||||||
|
nearestBFaceI[patchFaceI] = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,573 +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 "octreeDataFaceList.H"
|
|
||||||
#include "octree.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
defineTypeNameAndDebug(Foam::octreeDataFaceList, 0);
|
|
||||||
|
|
||||||
Foam::scalar Foam::octreeDataFaceList::tol = 1E-6;
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void Foam::octreeDataFaceList::calcBb()
|
|
||||||
{
|
|
||||||
allBb_.setSize(faceLabels_.size());
|
|
||||||
allBb_ = treeBoundBox
|
|
||||||
(
|
|
||||||
vector(GREAT, GREAT, GREAT),
|
|
||||||
vector(-GREAT, -GREAT, -GREAT)
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll (faceLabels_, faceLabelI)
|
|
||||||
{
|
|
||||||
label faceI = faceLabels_[faceLabelI];
|
|
||||||
|
|
||||||
// Update bb of face
|
|
||||||
treeBoundBox& myBb = allBb_[faceLabelI];
|
|
||||||
|
|
||||||
const face& f = mesh_.localFaces()[faceI];
|
|
||||||
|
|
||||||
forAll(f, fp)
|
|
||||||
{
|
|
||||||
const point& coord = mesh_.localPoints()[f[fp]];
|
|
||||||
|
|
||||||
myBb.min() = min(myBb.min(), coord);
|
|
||||||
myBb.max() = max(myBb.max(), coord);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
// Construct from all faces in bMesh
|
|
||||||
Foam::octreeDataFaceList::octreeDataFaceList(const bMesh& mesh)
|
|
||||||
:
|
|
||||||
mesh_(mesh),
|
|
||||||
faceLabels_(mesh_.size()),
|
|
||||||
allBb_(mesh_.size())
|
|
||||||
{
|
|
||||||
forAll(faceLabels_, faceI)
|
|
||||||
{
|
|
||||||
faceLabels_[faceI] = faceI;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate tight fitting bounding box
|
|
||||||
calcBb();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Construct from selected faces in bMesh
|
|
||||||
Foam::octreeDataFaceList::octreeDataFaceList
|
|
||||||
(
|
|
||||||
const bMesh& mesh,
|
|
||||||
const labelList& faceLabels
|
|
||||||
)
|
|
||||||
:
|
|
||||||
mesh_(mesh),
|
|
||||||
faceLabels_(faceLabels),
|
|
||||||
allBb_(faceLabels.size())
|
|
||||||
{
|
|
||||||
// Generate tight fitting bounding box
|
|
||||||
calcBb();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Construct as copy
|
|
||||||
Foam::octreeDataFaceList::octreeDataFaceList(const octreeDataFaceList& shapes)
|
|
||||||
:
|
|
||||||
mesh_(shapes.mesh()),
|
|
||||||
faceLabels_(shapes.faceLabels()),
|
|
||||||
allBb_(shapes.allBb())
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::octreeDataFaceList::~octreeDataFaceList()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::octreeDataFaceList::getSampleType
|
|
||||||
(
|
|
||||||
const octree<octreeDataFaceList>& oc,
|
|
||||||
const point& sample
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
// Need to determine whether sample is 'inside' or 'outside'
|
|
||||||
// Done by finding nearest face. This gives back a face which is
|
|
||||||
// guaranteed to contain nearest point. This point can be
|
|
||||||
// - in interior of face: compare to face normal
|
|
||||||
// - on edge of face: compare to edge normal
|
|
||||||
// - on point of face: compare to point normal
|
|
||||||
// Unfortunately the octree does not give us back the intersection point
|
|
||||||
// or where on the face it has hit so we have to recreate all that
|
|
||||||
// information.
|
|
||||||
|
|
||||||
|
|
||||||
// Find nearest face to sample
|
|
||||||
treeBoundBox tightest(treeBoundBox::greatBox);
|
|
||||||
|
|
||||||
scalar tightestDist = GREAT;
|
|
||||||
|
|
||||||
label index = oc.findNearest(sample, tightest, tightestDist);
|
|
||||||
|
|
||||||
if (index == -1)
|
|
||||||
{
|
|
||||||
FatalErrorIn
|
|
||||||
(
|
|
||||||
"octreeDataFaceList::getSampleType"
|
|
||||||
"(octree<octreeDataFaceList>&, const point&)"
|
|
||||||
) << "Could not find " << sample << " in octree."
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
label faceI = faceLabels_[index];
|
|
||||||
|
|
||||||
// Get actual intersection point on face
|
|
||||||
|
|
||||||
if (debug & 2)
|
|
||||||
{
|
|
||||||
Pout<< "getSampleType : sample:" << sample
|
|
||||||
<< " nearest face:" << faceI;
|
|
||||||
}
|
|
||||||
|
|
||||||
const face& f = mesh_.localFaces()[faceI];
|
|
||||||
|
|
||||||
const pointField& points = mesh_.localPoints();
|
|
||||||
|
|
||||||
pointHit curHit = f.nearestPoint(sample, points);
|
|
||||||
|
|
||||||
//
|
|
||||||
// 1] Check whether sample is above face
|
|
||||||
//
|
|
||||||
|
|
||||||
if (curHit.hit())
|
|
||||||
{
|
|
||||||
// Simple case. Compare to face normal.
|
|
||||||
|
|
||||||
if (debug & 2)
|
|
||||||
{
|
|
||||||
Pout<< " -> face hit:" << curHit.hitPoint()
|
|
||||||
<< " comparing to face normal " << mesh_.faceNormals()[faceI]
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
return octree<octreeDataFaceList>::getVolType
|
|
||||||
(
|
|
||||||
mesh_.faceNormals()[faceI],
|
|
||||||
sample - curHit.hitPoint()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debug & 2)
|
|
||||||
{
|
|
||||||
Pout<< " -> face miss:" << curHit.missPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// 2] Check whether intersection is on one of the face vertices or
|
|
||||||
// face centre
|
|
||||||
//
|
|
||||||
|
|
||||||
// typical dimension as sqrt of face area.
|
|
||||||
scalar typDim = sqrt(mag(f.normal(points))) + VSMALL;
|
|
||||||
|
|
||||||
forAll(f, fp)
|
|
||||||
{
|
|
||||||
if ((mag(points[f[fp]] - curHit.missPoint())/typDim) < tol)
|
|
||||||
{
|
|
||||||
// Face intersection point equals face vertex fp
|
|
||||||
|
|
||||||
if (debug & 2)
|
|
||||||
{
|
|
||||||
Pout<< " -> face point hit :" << points[f[fp]]
|
|
||||||
<< " point normal:" << mesh_.pointNormals()[f[fp]]
|
|
||||||
<< " distance:"
|
|
||||||
<< mag(points[f[fp]] - curHit.missPoint())/typDim
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
return octree<octreeDataFaceList>::getVolType
|
|
||||||
(
|
|
||||||
mesh_.pointNormals()[f[fp]],
|
|
||||||
sample - curHit.missPoint()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get face centre
|
|
||||||
point ctr(f.centre(points));
|
|
||||||
|
|
||||||
if ((mag(ctr - curHit.missPoint())/typDim) < tol)
|
|
||||||
{
|
|
||||||
// Face intersection point equals face centre. Normal at face centre
|
|
||||||
// is already average of face normals
|
|
||||||
|
|
||||||
if (debug & 2)
|
|
||||||
{
|
|
||||||
Pout<< " -> centre hit:" << ctr
|
|
||||||
<< " distance:"
|
|
||||||
<< mag(ctr - curHit.missPoint())/typDim
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return octree<octreeDataFaceList>::getVolType
|
|
||||||
(
|
|
||||||
mesh_.faceNormals()[faceI],
|
|
||||||
sample - curHit.missPoint()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// 3] Get the 'real' edge the face intersection is on
|
|
||||||
//
|
|
||||||
|
|
||||||
const labelList& myEdges = mesh_.faceEdges()[faceI];
|
|
||||||
|
|
||||||
forAll(myEdges, myEdgeI)
|
|
||||||
{
|
|
||||||
const edge& e = mesh_.edges()[myEdges[myEdgeI]];
|
|
||||||
|
|
||||||
pointHit edgeHit =
|
|
||||||
line<point, const point&>
|
|
||||||
(
|
|
||||||
points[e.start()],
|
|
||||||
points[e.end()]
|
|
||||||
).nearestDist(sample);
|
|
||||||
|
|
||||||
point edgePoint;
|
|
||||||
if (edgeHit.hit())
|
|
||||||
{
|
|
||||||
edgePoint = edgeHit.hitPoint();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
edgePoint = edgeHit.missPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ((mag(edgePoint - curHit.missPoint())/typDim) < tol)
|
|
||||||
{
|
|
||||||
// Face intersection point lies on edge e
|
|
||||||
|
|
||||||
// Calculate edge normal (wrong: uses face normals instead of
|
|
||||||
// triangle normals)
|
|
||||||
const labelList& myFaces = mesh_.edgeFaces()[myEdges[myEdgeI]];
|
|
||||||
|
|
||||||
vector edgeNormal(vector::zero);
|
|
||||||
|
|
||||||
forAll(myFaces, myFaceI)
|
|
||||||
{
|
|
||||||
edgeNormal += mesh_.faceNormals()[myFaces[myFaceI]];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debug & 2)
|
|
||||||
{
|
|
||||||
Pout<< " -> real edge hit point:" << edgePoint
|
|
||||||
<< " comparing to edge normal:" << edgeNormal
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Found face intersection point on this edge. Compare to edge
|
|
||||||
// normal
|
|
||||||
return octree<octreeDataFaceList>::getVolType
|
|
||||||
(
|
|
||||||
edgeNormal,
|
|
||||||
sample - curHit.missPoint()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// 4] Get the internal edge (vertex - faceCentre) the face intersection
|
|
||||||
// is on
|
|
||||||
//
|
|
||||||
|
|
||||||
forAll(f, fp)
|
|
||||||
{
|
|
||||||
pointHit edgeHit =
|
|
||||||
line<point, const point&>
|
|
||||||
(
|
|
||||||
points[f[fp]],
|
|
||||||
ctr
|
|
||||||
).nearestDist(sample);
|
|
||||||
|
|
||||||
point edgePoint;
|
|
||||||
if (edgeHit.hit())
|
|
||||||
{
|
|
||||||
edgePoint = edgeHit.hitPoint();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
edgePoint = edgeHit.missPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((mag(edgePoint - curHit.missPoint())/typDim) < tol)
|
|
||||||
{
|
|
||||||
// Face intersection point lies on edge between two face triangles
|
|
||||||
|
|
||||||
// Calculate edge normal as average of the two triangle normals
|
|
||||||
label fpPrev = f.rcIndex(fp);
|
|
||||||
label fpNext = f.fcIndex(fp);
|
|
||||||
|
|
||||||
vector e = points[f[fp]] - ctr;
|
|
||||||
vector ePrev = points[f[fpPrev]] - ctr;
|
|
||||||
vector eNext = points[f[fpNext]] - ctr;
|
|
||||||
|
|
||||||
vector nLeft = ePrev ^ e;
|
|
||||||
nLeft /= mag(nLeft) + VSMALL;
|
|
||||||
|
|
||||||
vector nRight = e ^ eNext;
|
|
||||||
nRight /= mag(nRight) + VSMALL;
|
|
||||||
|
|
||||||
if (debug & 2)
|
|
||||||
{
|
|
||||||
Pout<< " -> internal edge hit point:" << edgePoint
|
|
||||||
<< " comparing to edge normal "
|
|
||||||
<< 0.5*(nLeft + nRight)
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Found face intersection point on this edge. Compare to edge
|
|
||||||
// normal
|
|
||||||
return octree<octreeDataFaceList>::getVolType
|
|
||||||
(
|
|
||||||
0.5*(nLeft + nRight),
|
|
||||||
sample - curHit.missPoint()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debug & 2)
|
|
||||||
{
|
|
||||||
Pout<< "Did not find sample " << sample
|
|
||||||
<< " anywhere related to nearest face " << faceI << endl
|
|
||||||
<< "Face:";
|
|
||||||
|
|
||||||
forAll(f, fp)
|
|
||||||
{
|
|
||||||
Pout<< " vertex:" << f[fp] << " coord:" << points[f[fp]]
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can't determine status of sample with respect to nearest face.
|
|
||||||
// Either
|
|
||||||
// - tolerances are wrong. (if e.g. face has zero area)
|
|
||||||
// - or (more likely) surface is not closed.
|
|
||||||
|
|
||||||
return octree<octreeDataFaceList>::UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::octreeDataFaceList::overlaps
|
|
||||||
(
|
|
||||||
const label index,
|
|
||||||
const treeBoundBox& sampleBb
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return sampleBb.overlaps(allBb_[index]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::octreeDataFaceList::contains
|
|
||||||
(
|
|
||||||
const label,
|
|
||||||
const point&
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
notImplemented
|
|
||||||
(
|
|
||||||
"octreeDataFaceList::contains(const label, const point&)"
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::octreeDataFaceList::intersects
|
|
||||||
(
|
|
||||||
const label index,
|
|
||||||
const point& start,
|
|
||||||
const point& end,
|
|
||||||
point& intersectionPoint
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
label faceI = faceLabels_[index];
|
|
||||||
|
|
||||||
const face& f = mesh_.localFaces()[faceI];
|
|
||||||
|
|
||||||
const vector dir(end - start);
|
|
||||||
|
|
||||||
// Disable picking up intersections behind us.
|
|
||||||
scalar oldTol = intersection::setPlanarTol(0.0);
|
|
||||||
|
|
||||||
pointHit inter =
|
|
||||||
f.ray
|
|
||||||
(
|
|
||||||
start,
|
|
||||||
dir,
|
|
||||||
mesh_.localPoints(),
|
|
||||||
intersection::HALF_RAY,
|
|
||||||
intersection::VECTOR
|
|
||||||
);
|
|
||||||
|
|
||||||
intersection::setPlanarTol(oldTol);
|
|
||||||
|
|
||||||
if (inter.hit() && inter.distance() <= mag(dir))
|
|
||||||
{
|
|
||||||
intersectionPoint = inter.hitPoint();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::octreeDataFaceList::findTightest
|
|
||||||
(
|
|
||||||
const label index,
|
|
||||||
const point& sample,
|
|
||||||
treeBoundBox& tightest
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
// Get nearest and furthest away vertex
|
|
||||||
point myNear, myFar;
|
|
||||||
allBb_[index].calcExtremities(sample, myNear, myFar);
|
|
||||||
|
|
||||||
const point dist = myFar - sample;
|
|
||||||
scalar myFarDist = mag(dist);
|
|
||||||
|
|
||||||
point tightestNear, tightestFar;
|
|
||||||
tightest.calcExtremities(sample, tightestNear, tightestFar);
|
|
||||||
|
|
||||||
scalar tightestFarDist = mag(tightestFar - sample);
|
|
||||||
|
|
||||||
if (tightestFarDist < myFarDist)
|
|
||||||
{
|
|
||||||
// Keep current tightest.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Construct bb around sample and myFar
|
|
||||||
const point dist2(fabs(dist.x()), fabs(dist.y()), fabs(dist.z()));
|
|
||||||
|
|
||||||
tightest.min() = sample - dist2;
|
|
||||||
tightest.max() = sample + dist2;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Determine numerical value of sign of sample compared to shape at index
|
|
||||||
Foam::scalar Foam::octreeDataFaceList::calcSign
|
|
||||||
(
|
|
||||||
const label index,
|
|
||||||
const point& sample,
|
|
||||||
vector&
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
label faceI = faceLabels_[index];
|
|
||||||
|
|
||||||
const face& f = mesh_.localFaces()[faceI];
|
|
||||||
|
|
||||||
point ctr = f.centre(mesh_.localPoints());
|
|
||||||
|
|
||||||
vector vec = sample - ctr;
|
|
||||||
|
|
||||||
vec /= mag(vec) + VSMALL;
|
|
||||||
|
|
||||||
return mesh_.faceNormals()[faceI] & vec;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Calculate nearest point on/in shapei
|
|
||||||
Foam::scalar Foam::octreeDataFaceList::calcNearest
|
|
||||||
(
|
|
||||||
const label index,
|
|
||||||
const point& sample,
|
|
||||||
point& nearest
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
label faceI = faceLabels_[index];
|
|
||||||
|
|
||||||
const face& f = mesh_.localFaces()[faceI];
|
|
||||||
|
|
||||||
pointHit nearHit = f.nearestPoint(sample, mesh_.localPoints());
|
|
||||||
|
|
||||||
if (nearHit.hit())
|
|
||||||
{
|
|
||||||
nearest = nearHit.hitPoint();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nearest = nearHit.missPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debug & 1)
|
|
||||||
{
|
|
||||||
point ctr = f.centre(mesh_.localPoints());
|
|
||||||
|
|
||||||
scalar sign = mesh_.faceNormals()[faceI] & (sample - nearest);
|
|
||||||
|
|
||||||
Pout<< "octreeDataFaceList::calcNearest : "
|
|
||||||
<< "sample:" << sample
|
|
||||||
<< " faceI:" << faceI
|
|
||||||
<< " ctr:" << ctr
|
|
||||||
<< " sign:" << sign
|
|
||||||
<< " nearest point:" << nearest
|
|
||||||
<< " distance to face:" << nearHit.distance()
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
return nearHit.distance();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::octreeDataFaceList::write
|
|
||||||
(
|
|
||||||
Ostream& os,
|
|
||||||
const label index
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
os << faceLabels_[index] << " " << allBb_[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,220 +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::octreeDataFaceList
|
|
||||||
|
|
||||||
Description
|
|
||||||
Holds data for octree to work on list of faces on a bMesh
|
|
||||||
(= PrimitivePatch which holds faces, not references them)
|
|
||||||
Same as octreeDataFace except for that.
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
octreeDataFaceList.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef octreeDataFaceList_H
|
|
||||||
#define octreeDataFaceList_H
|
|
||||||
|
|
||||||
#include "treeBoundBoxList.H"
|
|
||||||
#include "faceList.H"
|
|
||||||
#include "point.H"
|
|
||||||
#include "className.H"
|
|
||||||
#include "bMesh.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// Forward declaration of classes
|
|
||||||
template<class Type> class octree;
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class octreeDataFaceList Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
class octreeDataFaceList
|
|
||||||
{
|
|
||||||
// Static data
|
|
||||||
|
|
||||||
//- tolerance on linear dimensions
|
|
||||||
static scalar tol;
|
|
||||||
|
|
||||||
|
|
||||||
// Static function
|
|
||||||
|
|
||||||
static inline label nexti(label max, label i)
|
|
||||||
{
|
|
||||||
return (i + 1) % max;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Private data
|
|
||||||
|
|
||||||
//- the mesh
|
|
||||||
const bMesh& mesh_;
|
|
||||||
|
|
||||||
//- labels (in mesh indexing) of faces
|
|
||||||
labelList faceLabels_;
|
|
||||||
|
|
||||||
//- bbs for all above faces
|
|
||||||
treeBoundBoxList allBb_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- Set allBb to tight fitting bounding box
|
|
||||||
void calcBb();
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Declare name of the class and its debug switch
|
|
||||||
ClassName("octreeDataFaceList");
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
//- Construct from all faces in bMesh.
|
|
||||||
octreeDataFaceList(const bMesh& mesh);
|
|
||||||
|
|
||||||
//- Construct from selected faces in bMesh.
|
|
||||||
octreeDataFaceList(const bMesh& mesh, const labelList& faceLabels);
|
|
||||||
|
|
||||||
//- Construct as copy
|
|
||||||
octreeDataFaceList(const octreeDataFaceList&);
|
|
||||||
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
|
|
||||||
~octreeDataFaceList();
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
|
||||||
|
|
||||||
// Access
|
|
||||||
|
|
||||||
const bMesh& mesh() const
|
|
||||||
{
|
|
||||||
return mesh_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const labelList& faceLabels() const
|
|
||||||
{
|
|
||||||
return faceLabels_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const treeBoundBoxList& allBb() const
|
|
||||||
{
|
|
||||||
return allBb_;
|
|
||||||
}
|
|
||||||
|
|
||||||
label size() const
|
|
||||||
{
|
|
||||||
return allBb_.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search
|
|
||||||
|
|
||||||
//- Get type of sample
|
|
||||||
label getSampleType
|
|
||||||
(
|
|
||||||
const octree<octreeDataFaceList>&,
|
|
||||||
const point&
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Does (bb of) shape at index overlap bb
|
|
||||||
bool overlaps
|
|
||||||
(
|
|
||||||
const label index,
|
|
||||||
const treeBoundBox& sampleBb
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Does shape at index contain sample
|
|
||||||
bool contains
|
|
||||||
(
|
|
||||||
const label index,
|
|
||||||
const point& sample
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Segment (from start to end) intersection with shape
|
|
||||||
// at index. If intersects returns true and sets intersectionPoint
|
|
||||||
bool intersects
|
|
||||||
(
|
|
||||||
const label index,
|
|
||||||
const point& start,
|
|
||||||
const point& end,
|
|
||||||
point& intersectionPoint
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Sets newTightest to bounding box (and returns true) if
|
|
||||||
// nearer to sample than tightest bounding box. Otherwise
|
|
||||||
// returns false.
|
|
||||||
bool findTightest
|
|
||||||
(
|
|
||||||
const label index,
|
|
||||||
const point& sample,
|
|
||||||
treeBoundBox& tightest
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Given index get unit normal and calculate (numerical) sign
|
|
||||||
// of sample.
|
|
||||||
// Used to determine accuracy of calcNearest or inside/outside.
|
|
||||||
scalar calcSign
|
|
||||||
(
|
|
||||||
const label index,
|
|
||||||
const point& sample,
|
|
||||||
vector& n
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Calculates nearest (to sample) point in shape.
|
|
||||||
// Returns point and mag(nearest - sample). Returns GREAT if
|
|
||||||
// sample does not project onto (triangle decomposition) of face.
|
|
||||||
scalar calcNearest
|
|
||||||
(
|
|
||||||
const label index,
|
|
||||||
const point& sample,
|
|
||||||
point& nearest
|
|
||||||
) const;
|
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
|
||||||
|
|
||||||
// Write
|
|
||||||
|
|
||||||
//- Write shape at index
|
|
||||||
void write(Ostream& os, const label index) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -330,8 +330,6 @@ void Foam::fvMeshAdder::MapVolFields
|
|||||||
|
|
||||||
if (fieldsToAdd.found(fld.name()))
|
if (fieldsToAdd.found(fld.name()))
|
||||||
{
|
{
|
||||||
Pout<< "Mapping field " << fld.name() << endl;
|
|
||||||
|
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& fldToAdd =
|
const GeometricField<Type, fvPatchField, volMesh>& fldToAdd =
|
||||||
*fieldsToAdd[fld.name()];
|
*fieldsToAdd[fld.name()];
|
||||||
|
|
||||||
@ -339,7 +337,7 @@ void Foam::fvMeshAdder::MapVolFields
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WarningIn("fvMeshAdder::MapVolFields")
|
WarningIn("fvMeshAdder::MapVolFields(..)")
|
||||||
<< "Not mapping field " << fld.name()
|
<< "Not mapping field " << fld.name()
|
||||||
<< " since not present on mesh to add"
|
<< " since not present on mesh to add"
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -642,15 +640,13 @@ void Foam::fvMeshAdder::MapSurfaceFields
|
|||||||
|
|
||||||
if (fieldsToAdd.found(fld.name()))
|
if (fieldsToAdd.found(fld.name()))
|
||||||
{
|
{
|
||||||
Pout<< "Mapping field " << fld.name() << endl;
|
|
||||||
|
|
||||||
const fldType& fldToAdd = *fieldsToAdd[fld.name()];
|
const fldType& fldToAdd = *fieldsToAdd[fld.name()];
|
||||||
|
|
||||||
MapSurfaceField<Type>(meshMap, fld, fldToAdd);
|
MapSurfaceField<Type>(meshMap, fld, fldToAdd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WarningIn("fvMeshAdder::MapSurfaceFields")
|
WarningIn("fvMeshAdder::MapSurfaceFields(..)")
|
||||||
<< "Not mapping field " << fld.name()
|
<< "Not mapping field " << fld.name()
|
||||||
<< " since not present on mesh to add"
|
<< " since not present on mesh to add"
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|||||||
@ -25,8 +25,6 @@ License
|
|||||||
\*----------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "fvMeshDistribute.H"
|
#include "fvMeshDistribute.H"
|
||||||
#include "ProcessorTopology.H"
|
|
||||||
#include "commSchedule.H"
|
|
||||||
#include "PstreamCombineReduceOps.H"
|
#include "PstreamCombineReduceOps.H"
|
||||||
#include "fvMeshAdder.H"
|
#include "fvMeshAdder.H"
|
||||||
#include "faceCoupleInfo.H"
|
#include "faceCoupleInfo.H"
|
||||||
@ -39,6 +37,8 @@ License
|
|||||||
#include "mergePoints.H"
|
#include "mergePoints.H"
|
||||||
#include "mapDistributePolyMesh.H"
|
#include "mapDistributePolyMesh.H"
|
||||||
#include "surfaceFields.H"
|
#include "surfaceFields.H"
|
||||||
|
#include "syncTools.H"
|
||||||
|
#include "CompactListList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -47,71 +47,6 @@ defineTypeNameAndDebug(Foam::fvMeshDistribute, 0);
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
//Foam::List<Foam::labelPair> Foam::fvMeshDistribute::getSchedule
|
|
||||||
//(
|
|
||||||
// const labelList& distribution
|
|
||||||
//)
|
|
||||||
//{
|
|
||||||
// labelList nCellsPerProc(countCells(distribution));
|
|
||||||
//
|
|
||||||
// if (debug)
|
|
||||||
// {
|
|
||||||
// Pout<< "getSchedule : Wanted distribution:" << nCellsPerProc << endl;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Processors I need to send data to
|
|
||||||
// labelListList mySendProcs(Pstream::nProcs());
|
|
||||||
//
|
|
||||||
// // Count
|
|
||||||
// label nSendProcs = 0;
|
|
||||||
// forAll(nCellsPerProc, sendProcI)
|
|
||||||
// {
|
|
||||||
// if (sendProcI != Pstream::myProcNo() && nCellsPerProc[sendProcI] > 0)
|
|
||||||
// {
|
|
||||||
// nSendProcs++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Fill
|
|
||||||
// mySendProcs[Pstream::myProcNo()].setSize(nSendProcs);
|
|
||||||
// nSendProcs = 0;
|
|
||||||
// forAll(nCellsPerProc, sendProcI)
|
|
||||||
// {
|
|
||||||
// if (sendProcI != Pstream::myProcNo() && nCellsPerProc[sendProcI] > 0)
|
|
||||||
// {
|
|
||||||
// mySendProcs[Pstream::myProcNo()][nSendProcs++] = sendProcI;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Synchronise
|
|
||||||
// Pstream::gatherList(mySendProcs);
|
|
||||||
// Pstream::scatterList(mySendProcs);
|
|
||||||
//
|
|
||||||
// // Combine into list (same on all procs) giving sending and receiving
|
|
||||||
// // processor
|
|
||||||
// label nComms = 0;
|
|
||||||
// forAll(mySendProcs, procI)
|
|
||||||
// {
|
|
||||||
// nComms += mySendProcs[procI].size();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// List<labelPair> schedule(nComms);
|
|
||||||
// nComms = 0;
|
|
||||||
//
|
|
||||||
// forAll(mySendProcs, procI)
|
|
||||||
// {
|
|
||||||
// const labelList& sendProcs = mySendProcs[procI];
|
|
||||||
//
|
|
||||||
// forAll(sendProcs, i)
|
|
||||||
// {
|
|
||||||
// schedule[nComms++] = labelPair(procI, sendProcs[i]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return schedule;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::labelList Foam::fvMeshDistribute::select
|
Foam::labelList Foam::fvMeshDistribute::select
|
||||||
(
|
(
|
||||||
const bool selectEqual,
|
const bool selectEqual,
|
||||||
@ -144,14 +79,29 @@ Foam::labelList Foam::fvMeshDistribute::select
|
|||||||
|
|
||||||
|
|
||||||
// Check all procs have same names and in exactly same order.
|
// Check all procs have same names and in exactly same order.
|
||||||
void Foam::fvMeshDistribute::checkEqualWordList(const wordList& lst)
|
void Foam::fvMeshDistribute::checkEqualWordList
|
||||||
|
(
|
||||||
|
const string& msg,
|
||||||
|
const wordList& lst
|
||||||
|
)
|
||||||
{
|
{
|
||||||
wordList myObjects(lst);
|
List<wordList> allNames(Pstream::nProcs());
|
||||||
|
allNames[Pstream::myProcNo()] = lst;
|
||||||
|
Pstream::gatherList(allNames);
|
||||||
|
Pstream::scatterList(allNames);
|
||||||
|
|
||||||
// Check that all meshes have same objects
|
for (label procI = 1; procI < Pstream::nProcs(); procI++)
|
||||||
Pstream::listCombineGather(myObjects, checkEqualType());
|
{
|
||||||
// Below scatter only needed to balance sends and receives.
|
if (allNames[procI] != allNames[0])
|
||||||
Pstream::listCombineScatter(myObjects);
|
{
|
||||||
|
FatalErrorIn("fvMeshDistribute::checkEqualWordList(..)")
|
||||||
|
<< "When checking for equal " << msg.c_str() << " :" << endl
|
||||||
|
<< "processor0 has:" << allNames[0] << endl
|
||||||
|
<< "processor" << procI << " has:" << allNames[procI] << endl
|
||||||
|
<< msg.c_str() << " need to be synchronised on all processors."
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -664,21 +614,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshDistribute::mergeSharedPoints
|
|||||||
<< " newPointI:" << newPointI << abort(FatalError);
|
<< " newPointI:" << newPointI << abort(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//- old: use pointToMaster map.
|
|
||||||
//forAll(constructMap, i)
|
|
||||||
//{
|
|
||||||
// label oldPointI = constructMap[i];
|
|
||||||
//
|
|
||||||
// // See if merged into other point
|
|
||||||
// Map<label>::const_iterator iter = pointToMaster.find(oldPointI);
|
|
||||||
//
|
|
||||||
// if (iter != pointToMaster.end())
|
|
||||||
// {
|
|
||||||
// oldPointI = iter();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// constructMap[i] = map().reversePointMap()[oldPointI];
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -693,46 +628,49 @@ void Foam::fvMeshDistribute::getNeighbourData
|
|||||||
labelList& sourceNewProc
|
labelList& sourceNewProc
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
sourceFace.setSize(mesh_.nFaces() - mesh_.nInternalFaces());
|
label nBnd = mesh_.nFaces() - mesh_.nInternalFaces();
|
||||||
sourceProc.setSize(sourceFace.size());
|
sourceFace.setSize(nBnd);
|
||||||
sourceNewProc.setSize(sourceFace.size());
|
sourceProc.setSize(nBnd);
|
||||||
|
sourceNewProc.setSize(nBnd);
|
||||||
|
|
||||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
|
|
||||||
// Send meshFace labels of processor patches and destination processor.
|
// Get neighbouring meshFace labels and new processor of coupled boundaries.
|
||||||
|
labelList nbrFaces(nBnd, -1);
|
||||||
|
labelList nbrNewProc(nBnd, -1);
|
||||||
|
|
||||||
forAll(patches, patchI)
|
forAll(patches, patchI)
|
||||||
{
|
{
|
||||||
const polyPatch& pp = patches[patchI];
|
const polyPatch& pp = patches[patchI];
|
||||||
|
|
||||||
if (isA<processorPolyPatch>(pp))
|
if (isA<processorPolyPatch>(pp))
|
||||||
{
|
{
|
||||||
const processorPolyPatch& procPatch =
|
label offset = pp.start() - mesh_.nInternalFaces();
|
||||||
refCast<const processorPolyPatch>(pp);
|
|
||||||
|
|
||||||
// Labels of faces on this side
|
// Mesh labels of faces on this side
|
||||||
labelList meshFaceLabels(pp.size());
|
forAll(pp, i)
|
||||||
forAll(meshFaceLabels, i)
|
|
||||||
{
|
{
|
||||||
meshFaceLabels[i] = pp.start()+i;
|
label bndI = offset + i;
|
||||||
|
nbrFaces[bndI] = pp.start()+i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Which processor they will end up on
|
// Which processor they will end up on
|
||||||
const labelList newProc
|
SubList<label>(nbrNewProc, pp.size(), offset).assign
|
||||||
(
|
(
|
||||||
UIndirectList<label>(distribution, pp.faceCells())
|
UIndirectList<label>(distribution, pp.faceCells())()
|
||||||
);
|
);
|
||||||
|
|
||||||
OPstream toNeighbour(Pstream::blocking, procPatch.neighbProcNo());
|
|
||||||
|
|
||||||
toNeighbour << meshFaceLabels << newProc;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive meshFace labels and destination processors of processor faces.
|
|
||||||
|
// Exchange the boundary data
|
||||||
|
syncTools::swapBoundaryFaceList(mesh_, nbrFaces, false);
|
||||||
|
syncTools::swapBoundaryFaceList(mesh_, nbrNewProc, false);
|
||||||
|
|
||||||
|
|
||||||
forAll(patches, patchI)
|
forAll(patches, patchI)
|
||||||
{
|
{
|
||||||
const polyPatch& pp = patches[patchI];
|
const polyPatch& pp = patches[patchI];
|
||||||
|
|
||||||
label offset = pp.start() - mesh_.nInternalFaces();
|
label offset = pp.start() - mesh_.nInternalFaces();
|
||||||
|
|
||||||
if (isA<processorPolyPatch>(pp))
|
if (isA<processorPolyPatch>(pp))
|
||||||
@ -740,11 +678,6 @@ void Foam::fvMeshDistribute::getNeighbourData
|
|||||||
const processorPolyPatch& procPatch =
|
const processorPolyPatch& procPatch =
|
||||||
refCast<const processorPolyPatch>(pp);
|
refCast<const processorPolyPatch>(pp);
|
||||||
|
|
||||||
// Receive the data
|
|
||||||
IPstream fromNeighbour(Pstream::blocking, procPatch.neighbProcNo());
|
|
||||||
labelList nbrFaces(fromNeighbour);
|
|
||||||
labelList nbrNewProc(fromNeighbour);
|
|
||||||
|
|
||||||
// Check which of the two faces we store.
|
// Check which of the two faces we store.
|
||||||
|
|
||||||
if (Pstream::myProcNo() < procPatch.neighbProcNo())
|
if (Pstream::myProcNo() < procPatch.neighbProcNo())
|
||||||
@ -752,9 +685,10 @@ void Foam::fvMeshDistribute::getNeighbourData
|
|||||||
// Use my local face labels
|
// Use my local face labels
|
||||||
forAll(pp, i)
|
forAll(pp, i)
|
||||||
{
|
{
|
||||||
sourceFace[offset + i] = pp.start()+i;
|
label bndI = offset + i;
|
||||||
sourceProc[offset + i] = Pstream::myProcNo();
|
sourceFace[bndI] = pp.start()+i;
|
||||||
sourceNewProc[offset + i] = nbrNewProc[i];
|
sourceProc[bndI] = Pstream::myProcNo();
|
||||||
|
sourceNewProc[bndI] = nbrNewProc[bndI];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -762,9 +696,10 @@ void Foam::fvMeshDistribute::getNeighbourData
|
|||||||
// Use my neighbours face labels
|
// Use my neighbours face labels
|
||||||
forAll(pp, i)
|
forAll(pp, i)
|
||||||
{
|
{
|
||||||
sourceFace[offset + i] = nbrFaces[i];
|
label bndI = offset + i;
|
||||||
sourceProc[offset + i] = procPatch.neighbProcNo();
|
sourceFace[bndI] = nbrFaces[bndI];
|
||||||
sourceNewProc[offset + i] = nbrNewProc[i];
|
sourceProc[bndI] = procPatch.neighbProcNo();
|
||||||
|
sourceNewProc[bndI] = nbrNewProc[bndI];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -773,9 +708,10 @@ void Foam::fvMeshDistribute::getNeighbourData
|
|||||||
// Normal (physical) boundary
|
// Normal (physical) boundary
|
||||||
forAll(pp, i)
|
forAll(pp, i)
|
||||||
{
|
{
|
||||||
sourceFace[offset + i] = patchI;
|
label bndI = offset + i;
|
||||||
sourceProc[offset + i] = -1;
|
sourceFace[bndI] = patchI;
|
||||||
sourceNewProc[offset + i] = -1;
|
sourceProc[bndI] = -1;
|
||||||
|
sourceNewProc[bndI] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1120,7 +1056,8 @@ void Foam::fvMeshDistribute::sendMesh
|
|||||||
|
|
||||||
const labelList& sourceFace,
|
const labelList& sourceFace,
|
||||||
const labelList& sourceProc,
|
const labelList& sourceProc,
|
||||||
const labelList& sourceNewProc
|
const labelList& sourceNewProc,
|
||||||
|
UOPstream& toDomain
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -1133,52 +1070,95 @@ void Foam::fvMeshDistribute::sendMesh
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assume sparse point zones. Get contents in merged-zone indices.
|
// Assume sparse, possibly overlapping point zones. Get contents
|
||||||
labelListList zonePoints(pointZoneNames.size());
|
// in merged-zone indices.
|
||||||
|
CompactListList<label> zonePoints;
|
||||||
{
|
{
|
||||||
const pointZoneMesh& pointZones = mesh.pointZones();
|
const pointZoneMesh& pointZones = mesh.pointZones();
|
||||||
|
|
||||||
|
labelList rowSizes(pointZoneNames.size(), 0);
|
||||||
|
|
||||||
forAll(pointZoneNames, nameI)
|
forAll(pointZoneNames, nameI)
|
||||||
{
|
{
|
||||||
label myZoneID = pointZones.findZoneID(pointZoneNames[nameI]);
|
label myZoneID = pointZones.findZoneID(pointZoneNames[nameI]);
|
||||||
|
|
||||||
if (myZoneID != -1)
|
if (myZoneID != -1)
|
||||||
{
|
{
|
||||||
zonePoints[nameI] = pointZones[myZoneID];
|
rowSizes[nameI] = pointZones[myZoneID].size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zonePoints.setSize(rowSizes);
|
||||||
|
|
||||||
|
forAll(pointZoneNames, nameI)
|
||||||
|
{
|
||||||
|
label myZoneID = pointZones.findZoneID(pointZoneNames[nameI]);
|
||||||
|
|
||||||
|
if (myZoneID != -1)
|
||||||
|
{
|
||||||
|
zonePoints[nameI].assign(pointZones[myZoneID]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assume sparse face zones
|
// Assume sparse, possibly overlapping face zones
|
||||||
labelListList zoneFaces(faceZoneNames.size());
|
CompactListList<label> zoneFaces;
|
||||||
boolListList zoneFaceFlip(faceZoneNames.size());
|
CompactListList<bool> zoneFaceFlip;
|
||||||
{
|
{
|
||||||
const faceZoneMesh& faceZones = mesh.faceZones();
|
const faceZoneMesh& faceZones = mesh.faceZones();
|
||||||
|
|
||||||
|
labelList rowSizes(faceZoneNames.size(), 0);
|
||||||
|
|
||||||
forAll(faceZoneNames, nameI)
|
forAll(faceZoneNames, nameI)
|
||||||
{
|
{
|
||||||
label myZoneID = faceZones.findZoneID(faceZoneNames[nameI]);
|
label myZoneID = faceZones.findZoneID(faceZoneNames[nameI]);
|
||||||
|
|
||||||
if (myZoneID != -1)
|
if (myZoneID != -1)
|
||||||
{
|
{
|
||||||
zoneFaces[nameI] = faceZones[myZoneID];
|
rowSizes[nameI] = faceZones[myZoneID].size();
|
||||||
zoneFaceFlip[nameI] = faceZones[myZoneID].flipMap();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zoneFaces.setSize(rowSizes);
|
||||||
|
zoneFaceFlip.setSize(rowSizes);
|
||||||
|
|
||||||
|
forAll(faceZoneNames, nameI)
|
||||||
|
{
|
||||||
|
label myZoneID = faceZones.findZoneID(faceZoneNames[nameI]);
|
||||||
|
|
||||||
|
if (myZoneID != -1)
|
||||||
|
{
|
||||||
|
zoneFaces[nameI].assign(faceZones[myZoneID]);
|
||||||
|
zoneFaceFlip[nameI].assign(faceZones[myZoneID].flipMap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assume sparse cell zones
|
// Assume sparse, possibly overlapping cell zones
|
||||||
labelListList zoneCells(cellZoneNames.size());
|
CompactListList<label> zoneCells;
|
||||||
{
|
{
|
||||||
const cellZoneMesh& cellZones = mesh.cellZones();
|
const cellZoneMesh& cellZones = mesh.cellZones();
|
||||||
|
|
||||||
|
labelList rowSizes(pointZoneNames.size(), 0);
|
||||||
|
|
||||||
forAll(cellZoneNames, nameI)
|
forAll(cellZoneNames, nameI)
|
||||||
{
|
{
|
||||||
label myZoneID = cellZones.findZoneID(cellZoneNames[nameI]);
|
label myZoneID = cellZones.findZoneID(cellZoneNames[nameI]);
|
||||||
|
|
||||||
if (myZoneID != -1)
|
if (myZoneID != -1)
|
||||||
{
|
{
|
||||||
zoneCells[nameI] = cellZones[myZoneID];
|
rowSizes[nameI] = cellZones[myZoneID].size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zoneCells.setSize(rowSizes);
|
||||||
|
|
||||||
|
forAll(cellZoneNames, nameI)
|
||||||
|
{
|
||||||
|
label myZoneID = cellZones.findZoneID(cellZoneNames[nameI]);
|
||||||
|
|
||||||
|
if (myZoneID != -1)
|
||||||
|
{
|
||||||
|
zoneCells[nameI].assign(cellZones[myZoneID]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1198,10 +1178,9 @@ void Foam::fvMeshDistribute::sendMesh
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
// Send
|
// Send
|
||||||
OPstream toDomain(Pstream::blocking, domain);
|
|
||||||
toDomain
|
toDomain
|
||||||
<< mesh.points()
|
<< mesh.points()
|
||||||
<< mesh.faces()
|
<< CompactListList<label, face>(mesh.faces())
|
||||||
<< mesh.faceOwner()
|
<< mesh.faceOwner()
|
||||||
<< mesh.faceNeighbour()
|
<< mesh.faceNeighbour()
|
||||||
<< mesh.boundaryMesh()
|
<< mesh.boundaryMesh()
|
||||||
@ -1214,6 +1193,13 @@ void Foam::fvMeshDistribute::sendMesh
|
|||||||
<< sourceFace
|
<< sourceFace
|
||||||
<< sourceProc
|
<< sourceProc
|
||||||
<< sourceNewProc;
|
<< sourceNewProc;
|
||||||
|
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "Started sending mesh to domain " << domain
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1227,21 +1213,20 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshDistribute::receiveMesh
|
|||||||
const Time& runTime,
|
const Time& runTime,
|
||||||
labelList& domainSourceFace,
|
labelList& domainSourceFace,
|
||||||
labelList& domainSourceProc,
|
labelList& domainSourceProc,
|
||||||
labelList& domainSourceNewProc
|
labelList& domainSourceNewProc,
|
||||||
|
UIPstream& fromNbr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
IPstream fromNbr(Pstream::blocking, domain);
|
|
||||||
|
|
||||||
pointField domainPoints(fromNbr);
|
pointField domainPoints(fromNbr);
|
||||||
faceList domainFaces(fromNbr);
|
faceList domainFaces = CompactListList<label, face>(fromNbr)();
|
||||||
labelList domainAllOwner(fromNbr);
|
labelList domainAllOwner(fromNbr);
|
||||||
labelList domainAllNeighbour(fromNbr);
|
labelList domainAllNeighbour(fromNbr);
|
||||||
PtrList<entry> patchEntries(fromNbr);
|
PtrList<entry> patchEntries(fromNbr);
|
||||||
|
|
||||||
labelListList zonePoints(fromNbr);
|
CompactListList<label> zonePoints(fromNbr);
|
||||||
labelListList zoneFaces(fromNbr);
|
CompactListList<label> zoneFaces(fromNbr);
|
||||||
boolListList zoneFaceFlip(fromNbr);
|
CompactListList<bool> zoneFaceFlip(fromNbr);
|
||||||
labelListList zoneCells(fromNbr);
|
CompactListList<label> zoneCells(fromNbr);
|
||||||
|
|
||||||
fromNbr
|
fromNbr
|
||||||
>> domainSourceFace
|
>> domainSourceFace
|
||||||
@ -1442,6 +1427,7 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
|
|||||||
const wordList cellZoneNames(mergeWordList(mesh_.cellZones().names()));
|
const wordList cellZoneNames(mergeWordList(mesh_.cellZones().names()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Local environment of all boundary faces
|
// Local environment of all boundary faces
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@ -1481,36 +1467,39 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
|
|||||||
mesh_.clearOut();
|
mesh_.clearOut();
|
||||||
mesh_.resetMotion();
|
mesh_.resetMotion();
|
||||||
|
|
||||||
|
// Get data to send. Make sure is synchronised
|
||||||
const wordList volScalars(mesh_.names(volScalarField::typeName));
|
const wordList volScalars(mesh_.names(volScalarField::typeName));
|
||||||
checkEqualWordList(volScalars);
|
checkEqualWordList("volScalarFields", volScalars);
|
||||||
const wordList volVectors(mesh_.names(volVectorField::typeName));
|
const wordList volVectors(mesh_.names(volVectorField::typeName));
|
||||||
checkEqualWordList(volVectors);
|
checkEqualWordList("volVectorFields", volVectors);
|
||||||
const wordList volSphereTensors
|
const wordList volSphereTensors
|
||||||
(
|
(
|
||||||
mesh_.names(volSphericalTensorField::typeName)
|
mesh_.names(volSphericalTensorField::typeName)
|
||||||
);
|
);
|
||||||
checkEqualWordList(volSphereTensors);
|
checkEqualWordList("volSphericalTensorFields", volSphereTensors);
|
||||||
const wordList volSymmTensors(mesh_.names(volSymmTensorField::typeName));
|
const wordList volSymmTensors(mesh_.names(volSymmTensorField::typeName));
|
||||||
checkEqualWordList(volSymmTensors);
|
checkEqualWordList("volSymmTensorFields", volSymmTensors);
|
||||||
const wordList volTensors(mesh_.names(volTensorField::typeName));
|
const wordList volTensors(mesh_.names(volTensorField::typeName));
|
||||||
checkEqualWordList(volTensors);
|
checkEqualWordList("volTensorField", volTensors);
|
||||||
|
|
||||||
const wordList surfScalars(mesh_.names(surfaceScalarField::typeName));
|
const wordList surfScalars(mesh_.names(surfaceScalarField::typeName));
|
||||||
checkEqualWordList(surfScalars);
|
checkEqualWordList("surfaceScalarFields", surfScalars);
|
||||||
const wordList surfVectors(mesh_.names(surfaceVectorField::typeName));
|
const wordList surfVectors(mesh_.names(surfaceVectorField::typeName));
|
||||||
checkEqualWordList(surfVectors);
|
checkEqualWordList("surfaceVectorFields", surfVectors);
|
||||||
const wordList surfSphereTensors
|
const wordList surfSphereTensors
|
||||||
(
|
(
|
||||||
mesh_.names(surfaceSphericalTensorField::typeName)
|
mesh_.names(surfaceSphericalTensorField::typeName)
|
||||||
);
|
);
|
||||||
checkEqualWordList(surfSphereTensors);
|
checkEqualWordList("surfaceSphericalTensorFields", surfSphereTensors);
|
||||||
const wordList surfSymmTensors
|
const wordList surfSymmTensors
|
||||||
(
|
(
|
||||||
mesh_.names(surfaceSymmTensorField::typeName)
|
mesh_.names(surfaceSymmTensorField::typeName)
|
||||||
);
|
);
|
||||||
checkEqualWordList(surfSymmTensors);
|
checkEqualWordList("surfaceSymmTensorFields", surfSymmTensors);
|
||||||
const wordList surfTensors(mesh_.names(surfaceTensorField::typeName));
|
const wordList surfTensors(mesh_.names(surfaceTensorField::typeName));
|
||||||
checkEqualWordList(surfTensors);
|
checkEqualWordList("surfaceTensorFields", surfTensors);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Find patch to temporarily put exposed and processor faces into.
|
// Find patch to temporarily put exposed and processor faces into.
|
||||||
@ -1589,6 +1578,9 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
|
|||||||
Pstream::scatterList(nSendCells);
|
Pstream::scatterList(nSendCells);
|
||||||
|
|
||||||
|
|
||||||
|
// Allocate buffers
|
||||||
|
PstreamBuffers pBufs(Pstream::nonBlocking);
|
||||||
|
|
||||||
|
|
||||||
// What to send to neighbouring domains
|
// What to send to neighbouring domains
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -1612,6 +1604,10 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
|
|||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pstream for sending mesh and fields
|
||||||
|
//OPstream str(Pstream::blocking, recvProc);
|
||||||
|
UOPstream str(recvProc, pBufs);
|
||||||
|
|
||||||
// Mesh subsetting engine
|
// Mesh subsetting engine
|
||||||
fvMeshSubset subsetter(mesh_);
|
fvMeshSubset subsetter(mesh_);
|
||||||
|
|
||||||
@ -1659,6 +1655,8 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
|
|||||||
procSourceNewProc
|
procSourceNewProc
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Send to neighbour
|
// Send to neighbour
|
||||||
sendMesh
|
sendMesh
|
||||||
(
|
(
|
||||||
@ -1671,43 +1669,69 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
|
|||||||
|
|
||||||
procSourceFace,
|
procSourceFace,
|
||||||
procSourceProc,
|
procSourceProc,
|
||||||
procSourceNewProc
|
procSourceNewProc,
|
||||||
|
str
|
||||||
);
|
);
|
||||||
sendFields<volScalarField>(recvProc, volScalars, subsetter);
|
sendFields<volScalarField>(recvProc, volScalars, subsetter, str);
|
||||||
sendFields<volVectorField>(recvProc, volVectors, subsetter);
|
sendFields<volVectorField>(recvProc, volVectors, subsetter, str);
|
||||||
sendFields<volSphericalTensorField>
|
sendFields<volSphericalTensorField>
|
||||||
(
|
(
|
||||||
recvProc,
|
recvProc,
|
||||||
volSphereTensors,
|
volSphereTensors,
|
||||||
subsetter
|
subsetter,
|
||||||
|
str
|
||||||
);
|
);
|
||||||
sendFields<volSymmTensorField>
|
sendFields<volSymmTensorField>
|
||||||
(
|
(
|
||||||
recvProc,
|
recvProc,
|
||||||
volSymmTensors,
|
volSymmTensors,
|
||||||
subsetter
|
subsetter,
|
||||||
|
str
|
||||||
);
|
);
|
||||||
sendFields<volTensorField>(recvProc, volTensors, subsetter);
|
sendFields<volTensorField>(recvProc, volTensors, subsetter, str);
|
||||||
|
|
||||||
sendFields<surfaceScalarField>(recvProc, surfScalars, subsetter);
|
sendFields<surfaceScalarField>
|
||||||
sendFields<surfaceVectorField>(recvProc, surfVectors, subsetter);
|
(
|
||||||
|
recvProc,
|
||||||
|
surfScalars,
|
||||||
|
subsetter,
|
||||||
|
str
|
||||||
|
);
|
||||||
|
sendFields<surfaceVectorField>
|
||||||
|
(
|
||||||
|
recvProc,
|
||||||
|
surfVectors,
|
||||||
|
subsetter,
|
||||||
|
str
|
||||||
|
);
|
||||||
sendFields<surfaceSphericalTensorField>
|
sendFields<surfaceSphericalTensorField>
|
||||||
(
|
(
|
||||||
recvProc,
|
recvProc,
|
||||||
surfSphereTensors,
|
surfSphereTensors,
|
||||||
subsetter
|
subsetter,
|
||||||
|
str
|
||||||
);
|
);
|
||||||
sendFields<surfaceSymmTensorField>
|
sendFields<surfaceSymmTensorField>
|
||||||
(
|
(
|
||||||
recvProc,
|
recvProc,
|
||||||
surfSymmTensors,
|
surfSymmTensors,
|
||||||
subsetter
|
subsetter,
|
||||||
|
str
|
||||||
|
);
|
||||||
|
sendFields<surfaceTensorField>
|
||||||
|
(
|
||||||
|
recvProc,
|
||||||
|
surfTensors,
|
||||||
|
subsetter,
|
||||||
|
str
|
||||||
);
|
);
|
||||||
sendFields<surfaceTensorField>(recvProc, surfTensors, subsetter);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Start sending&receiving from buffers
|
||||||
|
pBufs.finishedSends();
|
||||||
|
|
||||||
|
|
||||||
// Subset the part that stays
|
// Subset the part that stays
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -1817,109 +1841,132 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
|
|||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Pstream for receiving mesh and fields
|
||||||
|
UIPstream str(sendProc, pBufs);
|
||||||
|
|
||||||
|
|
||||||
// Receive from sendProc
|
// Receive from sendProc
|
||||||
labelList domainSourceFace;
|
labelList domainSourceFace;
|
||||||
labelList domainSourceProc;
|
labelList domainSourceProc;
|
||||||
labelList domainSourceNewProc;
|
labelList domainSourceNewProc;
|
||||||
|
|
||||||
// Opposite of sendMesh
|
autoPtr<fvMesh> domainMeshPtr;
|
||||||
autoPtr<fvMesh> domainMeshPtr = receiveMesh
|
|
||||||
(
|
|
||||||
sendProc,
|
|
||||||
pointZoneNames,
|
|
||||||
faceZoneNames,
|
|
||||||
cellZoneNames,
|
|
||||||
|
|
||||||
const_cast<Time&>(mesh_.time()),
|
|
||||||
domainSourceFace,
|
|
||||||
domainSourceProc,
|
|
||||||
domainSourceNewProc
|
|
||||||
);
|
|
||||||
fvMesh& domainMesh = domainMeshPtr();
|
|
||||||
|
|
||||||
// Receive fields
|
|
||||||
PtrList<volScalarField> vsf;
|
PtrList<volScalarField> vsf;
|
||||||
receiveFields<volScalarField>
|
|
||||||
(
|
|
||||||
sendProc,
|
|
||||||
volScalars,
|
|
||||||
domainMesh,
|
|
||||||
vsf
|
|
||||||
);
|
|
||||||
|
|
||||||
PtrList<volVectorField> vvf;
|
PtrList<volVectorField> vvf;
|
||||||
receiveFields<volVectorField>
|
|
||||||
(
|
|
||||||
sendProc,
|
|
||||||
volVectors,
|
|
||||||
domainMesh,
|
|
||||||
vvf
|
|
||||||
);
|
|
||||||
PtrList<volSphericalTensorField> vsptf;
|
PtrList<volSphericalTensorField> vsptf;
|
||||||
receiveFields<volSphericalTensorField>
|
|
||||||
(
|
|
||||||
sendProc,
|
|
||||||
volSphereTensors,
|
|
||||||
domainMesh,
|
|
||||||
vsptf
|
|
||||||
);
|
|
||||||
PtrList<volSymmTensorField> vsytf;
|
PtrList<volSymmTensorField> vsytf;
|
||||||
receiveFields<volSymmTensorField>
|
|
||||||
(
|
|
||||||
sendProc,
|
|
||||||
volSymmTensors,
|
|
||||||
domainMesh,
|
|
||||||
vsytf
|
|
||||||
);
|
|
||||||
PtrList<volTensorField> vtf;
|
PtrList<volTensorField> vtf;
|
||||||
receiveFields<volTensorField>
|
|
||||||
(
|
|
||||||
sendProc,
|
|
||||||
volTensors,
|
|
||||||
domainMesh,
|
|
||||||
vtf
|
|
||||||
);
|
|
||||||
|
|
||||||
PtrList<surfaceScalarField> ssf;
|
PtrList<surfaceScalarField> ssf;
|
||||||
receiveFields<surfaceScalarField>
|
|
||||||
(
|
|
||||||
sendProc,
|
|
||||||
surfScalars,
|
|
||||||
domainMesh,
|
|
||||||
ssf
|
|
||||||
);
|
|
||||||
PtrList<surfaceVectorField> svf;
|
PtrList<surfaceVectorField> svf;
|
||||||
receiveFields<surfaceVectorField>
|
|
||||||
(
|
|
||||||
sendProc,
|
|
||||||
surfVectors,
|
|
||||||
domainMesh,
|
|
||||||
svf
|
|
||||||
);
|
|
||||||
PtrList<surfaceSphericalTensorField> ssptf;
|
PtrList<surfaceSphericalTensorField> ssptf;
|
||||||
receiveFields<surfaceSphericalTensorField>
|
|
||||||
(
|
|
||||||
sendProc,
|
|
||||||
surfSphereTensors,
|
|
||||||
domainMesh,
|
|
||||||
ssptf
|
|
||||||
);
|
|
||||||
PtrList<surfaceSymmTensorField> ssytf;
|
PtrList<surfaceSymmTensorField> ssytf;
|
||||||
receiveFields<surfaceSymmTensorField>
|
|
||||||
(
|
|
||||||
sendProc,
|
|
||||||
surfSymmTensors,
|
|
||||||
domainMesh,
|
|
||||||
ssytf
|
|
||||||
);
|
|
||||||
PtrList<surfaceTensorField> stf;
|
PtrList<surfaceTensorField> stf;
|
||||||
receiveFields<surfaceTensorField>
|
|
||||||
(
|
// Opposite of sendMesh
|
||||||
sendProc,
|
{
|
||||||
surfTensors,
|
domainMeshPtr = receiveMesh
|
||||||
domainMesh,
|
(
|
||||||
stf
|
sendProc,
|
||||||
);
|
pointZoneNames,
|
||||||
|
faceZoneNames,
|
||||||
|
cellZoneNames,
|
||||||
|
|
||||||
|
const_cast<Time&>(mesh_.time()),
|
||||||
|
domainSourceFace,
|
||||||
|
domainSourceProc,
|
||||||
|
domainSourceNewProc,
|
||||||
|
str
|
||||||
|
);
|
||||||
|
fvMesh& domainMesh = domainMeshPtr();
|
||||||
|
|
||||||
|
// Receive fields. Read as single dictionary because
|
||||||
|
// of problems reading consecutive fields from single stream.
|
||||||
|
dictionary fieldDicts(str);
|
||||||
|
|
||||||
|
receiveFields<volScalarField>
|
||||||
|
(
|
||||||
|
sendProc,
|
||||||
|
volScalars,
|
||||||
|
domainMesh,
|
||||||
|
vsf,
|
||||||
|
fieldDicts.subDict(volScalarField::typeName)
|
||||||
|
);
|
||||||
|
receiveFields<volVectorField>
|
||||||
|
(
|
||||||
|
sendProc,
|
||||||
|
volVectors,
|
||||||
|
domainMesh,
|
||||||
|
vvf,
|
||||||
|
fieldDicts.subDict(volVectorField::typeName)
|
||||||
|
);
|
||||||
|
receiveFields<volSphericalTensorField>
|
||||||
|
(
|
||||||
|
sendProc,
|
||||||
|
volSphereTensors,
|
||||||
|
domainMesh,
|
||||||
|
vsptf,
|
||||||
|
fieldDicts.subDict(volSphericalTensorField::typeName)
|
||||||
|
);
|
||||||
|
receiveFields<volSymmTensorField>
|
||||||
|
(
|
||||||
|
sendProc,
|
||||||
|
volSymmTensors,
|
||||||
|
domainMesh,
|
||||||
|
vsytf,
|
||||||
|
fieldDicts.subDict(volSymmTensorField::typeName)
|
||||||
|
);
|
||||||
|
receiveFields<volTensorField>
|
||||||
|
(
|
||||||
|
sendProc,
|
||||||
|
volTensors,
|
||||||
|
domainMesh,
|
||||||
|
vtf,
|
||||||
|
fieldDicts.subDict(volTensorField::typeName)
|
||||||
|
);
|
||||||
|
|
||||||
|
receiveFields<surfaceScalarField>
|
||||||
|
(
|
||||||
|
sendProc,
|
||||||
|
surfScalars,
|
||||||
|
domainMesh,
|
||||||
|
ssf,
|
||||||
|
fieldDicts.subDict(surfaceScalarField::typeName)
|
||||||
|
);
|
||||||
|
receiveFields<surfaceVectorField>
|
||||||
|
(
|
||||||
|
sendProc,
|
||||||
|
surfVectors,
|
||||||
|
domainMesh,
|
||||||
|
svf,
|
||||||
|
fieldDicts.subDict(surfaceVectorField::typeName)
|
||||||
|
);
|
||||||
|
receiveFields<surfaceSphericalTensorField>
|
||||||
|
(
|
||||||
|
sendProc,
|
||||||
|
surfSphereTensors,
|
||||||
|
domainMesh,
|
||||||
|
ssptf,
|
||||||
|
fieldDicts.subDict(surfaceSphericalTensorField::typeName)
|
||||||
|
);
|
||||||
|
receiveFields<surfaceSymmTensorField>
|
||||||
|
(
|
||||||
|
sendProc,
|
||||||
|
surfSymmTensors,
|
||||||
|
domainMesh,
|
||||||
|
ssytf,
|
||||||
|
fieldDicts.subDict(surfaceSymmTensorField::typeName)
|
||||||
|
);
|
||||||
|
receiveFields<surfaceTensorField>
|
||||||
|
(
|
||||||
|
sendProc,
|
||||||
|
surfTensors,
|
||||||
|
domainMesh,
|
||||||
|
stf,
|
||||||
|
fieldDicts.subDict(surfaceTensorField::typeName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const fvMesh& domainMesh = domainMeshPtr();
|
||||||
|
|
||||||
|
|
||||||
constructCellMap[sendProc] = identity(domainMesh.nCells());
|
constructCellMap[sendProc] = identity(domainMesh.nCells());
|
||||||
|
|||||||
@ -82,38 +82,8 @@ class fvMeshDistribute
|
|||||||
const scalar mergeTol_;
|
const scalar mergeTol_;
|
||||||
|
|
||||||
|
|
||||||
// Private classes
|
|
||||||
|
|
||||||
//- Check words are the same. Used in patch type checking of similarly
|
|
||||||
// named patches.
|
|
||||||
class checkEqualType
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
void operator()(word& x, const word& y) const
|
|
||||||
{
|
|
||||||
if (x != y)
|
|
||||||
{
|
|
||||||
FatalErrorIn("checkEqualType()(word&, const word&) const")
|
|
||||||
<< "Patch type " << x << " possibly on processor "
|
|
||||||
<< Pstream::myProcNo()
|
|
||||||
<< " does not equal patch type " << y
|
|
||||||
<< " on some other processor." << nl
|
|
||||||
<< "Please check similarly named patches for"
|
|
||||||
<< " having exactly the same type."
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Given distribution work out a communication schedule. Is list
|
|
||||||
// of pairs. First element of pair is send processor, second is
|
|
||||||
// receive processor.
|
|
||||||
//static List<labelPair> getSchedule(const labelList&);
|
|
||||||
|
|
||||||
//- Find indices with value
|
//- Find indices with value
|
||||||
static labelList select
|
static labelList select
|
||||||
(
|
(
|
||||||
@ -123,7 +93,7 @@ class fvMeshDistribute
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Check all procs have same names and in exactly same order.
|
//- Check all procs have same names and in exactly same order.
|
||||||
static void checkEqualWordList(const wordList&);
|
static void checkEqualWordList(const string&, const wordList&);
|
||||||
|
|
||||||
//- Merge wordlists over all processors
|
//- Merge wordlists over all processors
|
||||||
static wordList mergeWordList(const wordList&);
|
static wordList mergeWordList(const wordList&);
|
||||||
@ -288,7 +258,8 @@ class fvMeshDistribute
|
|||||||
const wordList& cellZoneNames,
|
const wordList& cellZoneNames,
|
||||||
const labelList& sourceFace,
|
const labelList& sourceFace,
|
||||||
const labelList& sourceProc,
|
const labelList& sourceProc,
|
||||||
const labelList& sourceNewProc
|
const labelList& sourceNewProc,
|
||||||
|
UOPstream& toDomain
|
||||||
);
|
);
|
||||||
//- Send subset of fields
|
//- Send subset of fields
|
||||||
template<class GeoField>
|
template<class GeoField>
|
||||||
@ -296,7 +267,8 @@ class fvMeshDistribute
|
|||||||
(
|
(
|
||||||
const label domain,
|
const label domain,
|
||||||
const wordList& fieldNames,
|
const wordList& fieldNames,
|
||||||
const fvMeshSubset&
|
const fvMeshSubset&,
|
||||||
|
UOPstream& toNbr
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Receive mesh. Opposite of sendMesh
|
//- Receive mesh. Opposite of sendMesh
|
||||||
@ -309,7 +281,8 @@ class fvMeshDistribute
|
|||||||
const Time& runTime,
|
const Time& runTime,
|
||||||
labelList& domainSourceFace,
|
labelList& domainSourceFace,
|
||||||
labelList& domainSourceProc,
|
labelList& domainSourceProc,
|
||||||
labelList& domainSourceNewProc
|
labelList& domainSourceNewProc,
|
||||||
|
UIPstream& fromNbr
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Receive fields. Opposite of sendFields
|
//- Receive fields. Opposite of sendFields
|
||||||
@ -319,7 +292,8 @@ class fvMeshDistribute
|
|||||||
const label domain,
|
const label domain,
|
||||||
const wordList& fieldNames,
|
const wordList& fieldNames,
|
||||||
fvMesh&,
|
fvMesh&,
|
||||||
PtrList<GeoField>&
|
PtrList<GeoField>&,
|
||||||
|
const dictionary& fieldDicts
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
|
|||||||
@ -184,7 +184,7 @@ void Foam::fvMeshDistribute::mapBoundaryFields
|
|||||||
|
|
||||||
if (flds.size() != oldBflds.size())
|
if (flds.size() != oldBflds.size())
|
||||||
{
|
{
|
||||||
FatalErrorIn("fvMeshDistribute::mapBoundaryFields") << "problem"
|
FatalErrorIn("fvMeshDistribute::mapBoundaryFields(..)") << "problem"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,19 +273,40 @@ void Foam::fvMeshDistribute::initPatchFields
|
|||||||
|
|
||||||
|
|
||||||
// Send fields. Note order supplied so we can receive in exactly the same order.
|
// Send fields. Note order supplied so we can receive in exactly the same order.
|
||||||
|
// Note that field gets written as entry in dictionary so we
|
||||||
|
// can construct from subdictionary.
|
||||||
|
// (since otherwise the reading as-a-dictionary mixes up entries from
|
||||||
|
// consecutive fields)
|
||||||
|
// The dictionary constructed is:
|
||||||
|
// volScalarField
|
||||||
|
// {
|
||||||
|
// p {internalField ..; boundaryField ..;}
|
||||||
|
// k {internalField ..; boundaryField ..;}
|
||||||
|
// }
|
||||||
|
// volVectorField
|
||||||
|
// {
|
||||||
|
// U {internalField ... }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// volVectorField {U {internalField ..; boundaryField ..;}}
|
||||||
|
//
|
||||||
template<class GeoField>
|
template<class GeoField>
|
||||||
void Foam::fvMeshDistribute::sendFields
|
void Foam::fvMeshDistribute::sendFields
|
||||||
(
|
(
|
||||||
const label domain,
|
const label domain,
|
||||||
const wordList& fieldNames,
|
const wordList& fieldNames,
|
||||||
const fvMeshSubset& subsetter
|
const fvMeshSubset& subsetter,
|
||||||
|
UOPstream& toNbr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
toNbr << GeoField::typeName << token::NL << token::BEGIN_BLOCK << token::NL;
|
||||||
forAll(fieldNames, i)
|
forAll(fieldNames, i)
|
||||||
{
|
{
|
||||||
//Pout<< "Subsetting field " << fieldNames[i]
|
if (debug)
|
||||||
// << " for domain:" << domain
|
{
|
||||||
// << endl;
|
Pout<< "Subsetting field " << fieldNames[i]
|
||||||
|
<< " for domain:" << domain << endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Send all fieldNames. This has to be exactly the same set as is
|
// Send all fieldNames. This has to be exactly the same set as is
|
||||||
// being received!
|
// being received!
|
||||||
@ -294,10 +315,12 @@ void Foam::fvMeshDistribute::sendFields
|
|||||||
|
|
||||||
tmp<GeoField> tsubfld = subsetter.interpolate(fld);
|
tmp<GeoField> tsubfld = subsetter.interpolate(fld);
|
||||||
|
|
||||||
// Send
|
toNbr
|
||||||
OPstream toNbr(Pstream::blocking, domain);
|
<< fieldNames[i] << token::NL << token::BEGIN_BLOCK
|
||||||
toNbr << tsubfld();
|
<< tsubfld
|
||||||
|
<< token::NL << token::END_BLOCK << token::NL;
|
||||||
}
|
}
|
||||||
|
toNbr << token::END_BLOCK << token::NL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -308,18 +331,25 @@ void Foam::fvMeshDistribute::receiveFields
|
|||||||
const label domain,
|
const label domain,
|
||||||
const wordList& fieldNames,
|
const wordList& fieldNames,
|
||||||
fvMesh& mesh,
|
fvMesh& mesh,
|
||||||
PtrList<GeoField>& fields
|
PtrList<GeoField>& fields,
|
||||||
|
const dictionary& fieldDicts
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "Receiving fields " << fieldNames
|
||||||
|
<< " from domain:" << domain << endl;
|
||||||
|
}
|
||||||
|
|
||||||
fields.setSize(fieldNames.size());
|
fields.setSize(fieldNames.size());
|
||||||
|
|
||||||
forAll(fieldNames, i)
|
forAll(fieldNames, i)
|
||||||
{
|
{
|
||||||
//Pout<< "Receiving field " << fieldNames[i]
|
if (debug)
|
||||||
// << " from domain:" << domain
|
{
|
||||||
// << endl;
|
Pout<< "Constructing field " << fieldNames[i]
|
||||||
|
<< " from domain:" << domain << endl;
|
||||||
IPstream fromNbr(Pstream::blocking, domain);
|
}
|
||||||
|
|
||||||
fields.set
|
fields.set
|
||||||
(
|
(
|
||||||
@ -335,7 +365,7 @@ void Foam::fvMeshDistribute::receiveFields
|
|||||||
IOobject::AUTO_WRITE
|
IOobject::AUTO_WRITE
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
fromNbr
|
fieldDicts.subDict(fieldNames[i])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -122,6 +122,7 @@ $(derivedFvPatchFields)/inletOutletTotalTemperature/inletOutletTotalTemperatureF
|
|||||||
$(derivedFvPatchFields)/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C
|
$(derivedFvPatchFields)/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C
|
||||||
$(derivedFvPatchFields)/movingWallVelocity/movingWallVelocityFvPatchVectorField.C
|
$(derivedFvPatchFields)/movingWallVelocity/movingWallVelocityFvPatchVectorField.C
|
||||||
$(derivedFvPatchFields)/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C
|
$(derivedFvPatchFields)/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C
|
||||||
|
$(derivedFvPatchFields)/translatingWallVelocity/translatingWallVelocityFvPatchVectorField.C
|
||||||
$(derivedFvPatchFields)/oscillatingFixedValue/oscillatingFixedValueFvPatchFields.C
|
$(derivedFvPatchFields)/oscillatingFixedValue/oscillatingFixedValueFvPatchFields.C
|
||||||
$(derivedFvPatchFields)/outletInlet/outletInletFvPatchFields.C
|
$(derivedFvPatchFields)/outletInlet/outletInletFvPatchFields.C
|
||||||
$(derivedFvPatchFields)/partialSlip/partialSlipFvPatchFields.C
|
$(derivedFvPatchFields)/partialSlip/partialSlipFvPatchFields.C
|
||||||
|
|||||||
@ -154,7 +154,7 @@ void jumpCyclicFvPatchField<Type>::updateInterfaceMatrix
|
|||||||
label sizeby2 = this->size()/2;
|
label sizeby2 = this->size()/2;
|
||||||
const unallocLabelList& faceCells = this->cyclicPatch().faceCells();
|
const unallocLabelList& faceCells = this->cyclicPatch().faceCells();
|
||||||
|
|
||||||
if (long(&psiInternal) == long(&this->internalField()))
|
if (&psiInternal == &this->internalField())
|
||||||
{
|
{
|
||||||
tmp<Field<scalar> > tjf = jump();
|
tmp<Field<scalar> > tjf = jump();
|
||||||
const Field<scalar>& jf = tjf();
|
const Field<scalar>& jf = tjf();
|
||||||
|
|||||||
@ -0,0 +1,142 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "translatingWallVelocityFvPatchVectorField.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "surfaceFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
translatingWallVelocityFvPatchVectorField::
|
||||||
|
translatingWallVelocityFvPatchVectorField
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<vector, volMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchField<vector>(p, iF),
|
||||||
|
U_(vector::zero)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
translatingWallVelocityFvPatchVectorField::
|
||||||
|
translatingWallVelocityFvPatchVectorField
|
||||||
|
(
|
||||||
|
const translatingWallVelocityFvPatchVectorField& ptf,
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<vector, volMesh>& iF,
|
||||||
|
const fvPatchFieldMapper& mapper
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
|
||||||
|
U_(ptf.U_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
translatingWallVelocityFvPatchVectorField::
|
||||||
|
translatingWallVelocityFvPatchVectorField
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<vector, volMesh>& iF,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchField<vector>(p, iF),
|
||||||
|
U_(dict.lookup("U"))
|
||||||
|
{
|
||||||
|
// Evaluate the wall velocity
|
||||||
|
updateCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
translatingWallVelocityFvPatchVectorField::
|
||||||
|
translatingWallVelocityFvPatchVectorField
|
||||||
|
(
|
||||||
|
const translatingWallVelocityFvPatchVectorField& twvpvf
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchField<vector>(twvpvf),
|
||||||
|
U_(twvpvf.U_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
translatingWallVelocityFvPatchVectorField::
|
||||||
|
translatingWallVelocityFvPatchVectorField
|
||||||
|
(
|
||||||
|
const translatingWallVelocityFvPatchVectorField& twvpvf,
|
||||||
|
const DimensionedField<vector, volMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchField<vector>(twvpvf, iF),
|
||||||
|
U_(twvpvf.U_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void translatingWallVelocityFvPatchVectorField::updateCoeffs()
|
||||||
|
{
|
||||||
|
if (updated())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the component of U normal to the wall in case the wall is not flat
|
||||||
|
vectorField n = patch().nf();
|
||||||
|
vectorField::operator=(U_ - n*(n & U_));
|
||||||
|
|
||||||
|
fixedValueFvPatchVectorField::updateCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void translatingWallVelocityFvPatchVectorField::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
fvPatchVectorField::write(os);
|
||||||
|
os.writeKeyword("U") << U_ << token::END_STATEMENT << nl;
|
||||||
|
writeEntry("value", os);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
makePatchTypeField
|
||||||
|
(
|
||||||
|
fvPatchVectorField,
|
||||||
|
translatingWallVelocityFvPatchVectorField
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,155 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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::translatingWallVelocityFvPatchVectorField
|
||||||
|
|
||||||
|
Description
|
||||||
|
Foam::translatingWallVelocityFvPatchVectorField
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
translatingWallVelocityFvPatchVectorField.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef translatingWallVelocityFvPatchVectorField_H
|
||||||
|
#define translatingWallVelocityFvPatchVectorField_H
|
||||||
|
|
||||||
|
#include "fixedValueFvPatchFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class translatingWallVelocityFvPatchField Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class translatingWallVelocityFvPatchVectorField
|
||||||
|
:
|
||||||
|
public fixedValueFvPatchVectorField
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Origin of the rotation
|
||||||
|
vector U_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("translatingWallVelocity");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from patch and internal field
|
||||||
|
translatingWallVelocityFvPatchVectorField
|
||||||
|
(
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<vector, volMesh>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from patch, internal field and dictionary
|
||||||
|
translatingWallVelocityFvPatchVectorField
|
||||||
|
(
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<vector, volMesh>&,
|
||||||
|
const dictionary&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct by mapping given a
|
||||||
|
// translatingWallVelocityFvPatchVectorField onto a new patch
|
||||||
|
translatingWallVelocityFvPatchVectorField
|
||||||
|
(
|
||||||
|
const translatingWallVelocityFvPatchVectorField&,
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<vector, volMesh>&,
|
||||||
|
const fvPatchFieldMapper&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct as copy
|
||||||
|
translatingWallVelocityFvPatchVectorField
|
||||||
|
(
|
||||||
|
const translatingWallVelocityFvPatchVectorField&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct and return a clone
|
||||||
|
virtual tmp<fvPatchVectorField> clone() const
|
||||||
|
{
|
||||||
|
return tmp<fvPatchVectorField>
|
||||||
|
(
|
||||||
|
new translatingWallVelocityFvPatchVectorField(*this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Construct as copy setting internal field reference
|
||||||
|
translatingWallVelocityFvPatchVectorField
|
||||||
|
(
|
||||||
|
const translatingWallVelocityFvPatchVectorField&,
|
||||||
|
const DimensionedField<vector, volMesh>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct and return a clone setting internal field reference
|
||||||
|
virtual tmp<fvPatchVectorField> clone
|
||||||
|
(
|
||||||
|
const DimensionedField<vector, volMesh>& iF
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return tmp<fvPatchVectorField>
|
||||||
|
(
|
||||||
|
new translatingWallVelocityFvPatchVectorField(*this, iF)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Member functions
|
||||||
|
|
||||||
|
// Access functions
|
||||||
|
|
||||||
|
//- Return the velocity
|
||||||
|
const vector& U() const
|
||||||
|
{
|
||||||
|
return U_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Update the coefficients associated with the patch field
|
||||||
|
virtual void updateCoeffs();
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
virtual void write(Ostream&) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -146,6 +146,10 @@ void Foam::singleCellFvMesh::agglomerateMesh
|
|||||||
// From new patch face back to agglomeration
|
// From new patch face back to agglomeration
|
||||||
patchFaceMap_.setSize(oldPatches.size());
|
patchFaceMap_.setSize(oldPatches.size());
|
||||||
|
|
||||||
|
// From fine face to coarse face (or -1)
|
||||||
|
reverseFaceMap_.setSize(mesh.nFaces());
|
||||||
|
reverseFaceMap_.labelList::operator=(-1);
|
||||||
|
|
||||||
// Face counter
|
// Face counter
|
||||||
coarseI = 0;
|
coarseI = 0;
|
||||||
|
|
||||||
|
|||||||
@ -329,7 +329,7 @@ surfaceDisplacementPointPatchVectorField
|
|||||||
surfacesDict_(dict.subDict("geometry")),
|
surfacesDict_(dict.subDict("geometry")),
|
||||||
projectMode_(projectModeNames_.read(dict.lookup("projectMode"))),
|
projectMode_(projectModeNames_.read(dict.lookup("projectMode"))),
|
||||||
projectDir_(dict.lookup("projectDirection")),
|
projectDir_(dict.lookup("projectDirection")),
|
||||||
wedgePlane_(dict.lookupOrDefault(dict.lookup("wedgePlane"), -1)),
|
wedgePlane_(dict.lookupOrDefault("wedgePlane", -1)),
|
||||||
frozenPointsZone_(dict.lookupOrDefault("frozenPointsZone", word::null))
|
frozenPointsZone_(dict.lookupOrDefault("frozenPointsZone", word::null))
|
||||||
{
|
{
|
||||||
if (velocity_.x() < 0 || velocity_.y() < 0 || velocity_.z() < 0)
|
if (velocity_.x() < 0 || velocity_.y() < 0 || velocity_.z() < 0)
|
||||||
|
|||||||
@ -1858,7 +1858,7 @@ void Foam::meshRefinement::distribute(const mapDistributePolyMesh& map)
|
|||||||
// Get local mesh bounding box. Single box for now.
|
// Get local mesh bounding box. Single box for now.
|
||||||
List<treeBoundBox> meshBb(1);
|
List<treeBoundBox> meshBb(1);
|
||||||
treeBoundBox& bb = meshBb[0];
|
treeBoundBox& bb = meshBb[0];
|
||||||
bb = boundBox(mesh_.points(), false);
|
bb = treeBoundBox(mesh_.points());
|
||||||
bb = bb.extend(rndGen, 1E-4);
|
bb = bb.extend(rndGen, 1E-4);
|
||||||
|
|
||||||
// Distribute all geometry (so refinementSurfaces and shellSurfaces)
|
// Distribute all geometry (so refinementSurfaces and shellSurfaces)
|
||||||
|
|||||||
@ -50,6 +50,7 @@ indexedOctree/treeDataCell.C
|
|||||||
indexedOctree/treeDataEdge.C
|
indexedOctree/treeDataEdge.C
|
||||||
indexedOctree/treeDataFace.C
|
indexedOctree/treeDataFace.C
|
||||||
indexedOctree/treeDataPoint.C
|
indexedOctree/treeDataPoint.C
|
||||||
|
indexedOctree/treeDataPrimitivePatchName.C
|
||||||
indexedOctree/treeDataTriSurface.C
|
indexedOctree/treeDataTriSurface.C
|
||||||
|
|
||||||
searchableSurface = searchableSurface
|
searchableSurface = searchableSurface
|
||||||
|
|||||||
567
src/meshTools/indexedOctree/treeDataPrimitivePatch.C
Normal file
567
src/meshTools/indexedOctree/treeDataPrimitivePatch.C
Normal file
@ -0,0 +1,567 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "treeDataPrimitivePatch.H"
|
||||||
|
#include "indexedOctree.H"
|
||||||
|
#include "triangleFuncs.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
Foam::scalar
|
||||||
|
Foam::treeDataPrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||||
|
tolSqr = sqr(1E-6);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
Foam::treeBoundBox
|
||||||
|
Foam::treeDataPrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||||
|
calcBb
|
||||||
|
(
|
||||||
|
const pointField& points,
|
||||||
|
const face& f
|
||||||
|
)
|
||||||
|
{
|
||||||
|
treeBoundBox bb(points[f[0]], points[f[0]]);
|
||||||
|
|
||||||
|
for (label fp = 1; fp < f.size(); fp++)
|
||||||
|
{
|
||||||
|
const point& p = points[f[fp]];
|
||||||
|
|
||||||
|
bb.min() = min(bb.min(), p);
|
||||||
|
bb.max() = max(bb.max(), p);
|
||||||
|
}
|
||||||
|
return bb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
void Foam::treeDataPrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||||
|
update()
|
||||||
|
{
|
||||||
|
if (cacheBb_)
|
||||||
|
{
|
||||||
|
bbs_.setSize(patch_.size());
|
||||||
|
|
||||||
|
forAll(patch_, i)
|
||||||
|
{
|
||||||
|
bbs_[i] = calcBb(patch_.points(), patch_[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
Foam::treeDataPrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||||
|
treeDataPrimitivePatch
|
||||||
|
(
|
||||||
|
const bool cacheBb,
|
||||||
|
const PrimitivePatch<Face, FaceList, PointField, PointType>& patch
|
||||||
|
)
|
||||||
|
:
|
||||||
|
patch_(patch),
|
||||||
|
cacheBb_(cacheBb)
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
Foam::pointField
|
||||||
|
Foam::treeDataPrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||||
|
points() const
|
||||||
|
{
|
||||||
|
pointField cc(patch_.size());
|
||||||
|
|
||||||
|
forAll(patch_, i)
|
||||||
|
{
|
||||||
|
cc[i] = patch_[i].centre(patch_.points());
|
||||||
|
}
|
||||||
|
|
||||||
|
return cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
|
||||||
|
// Only makes sense for closed surfaces.
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
Foam::label
|
||||||
|
Foam::treeDataPrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||||
|
getVolumeType
|
||||||
|
(
|
||||||
|
const indexedOctree
|
||||||
|
<
|
||||||
|
treeDataPrimitivePatch
|
||||||
|
<
|
||||||
|
Face,
|
||||||
|
FaceList,
|
||||||
|
PointField,
|
||||||
|
PointType
|
||||||
|
>
|
||||||
|
>& oc,
|
||||||
|
const point& sample
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Need to determine whether sample is 'inside' or 'outside'
|
||||||
|
// Done by finding nearest face. This gives back a face which is
|
||||||
|
// guaranteed to contain nearest point. This point can be
|
||||||
|
// - in interior of face: compare to face normal
|
||||||
|
// - on edge of face: compare to edge normal
|
||||||
|
// - on point of face: compare to point normal
|
||||||
|
// Unfortunately the octree does not give us back the intersection point
|
||||||
|
// or where on the face it has hit so we have to recreate all that
|
||||||
|
// information.
|
||||||
|
|
||||||
|
|
||||||
|
// Find nearest face to sample
|
||||||
|
pointIndexHit info = oc.findNearest(sample, sqr(GREAT));
|
||||||
|
|
||||||
|
if (info.index() == -1)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"treeDataPrimitivePatch::getSampleType"
|
||||||
|
"(indexedOctree<treeDataPrimitivePatch>&, const point&)"
|
||||||
|
) << "Could not find " << sample << " in octree."
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get actual intersection point on face
|
||||||
|
label faceI = info.index();
|
||||||
|
|
||||||
|
if (debug & 2)
|
||||||
|
{
|
||||||
|
Pout<< "getSampleType : sample:" << sample
|
||||||
|
<< " nearest face:" << faceI;
|
||||||
|
}
|
||||||
|
|
||||||
|
const pointField& points = patch_.localPoints();
|
||||||
|
const face& f = patch_.localFaces()[faceI];
|
||||||
|
|
||||||
|
// Retest to classify where on face info is. Note: could be improved. We
|
||||||
|
// already have point.
|
||||||
|
|
||||||
|
pointHit curHit = f.nearestPoint(sample, points);
|
||||||
|
const vector area = f.normal(points);
|
||||||
|
const point& curPt = curHit.rawPoint();
|
||||||
|
|
||||||
|
//
|
||||||
|
// 1] Check whether sample is above face
|
||||||
|
//
|
||||||
|
|
||||||
|
if (curHit.hit())
|
||||||
|
{
|
||||||
|
// Nearest point inside face. Compare to face normal.
|
||||||
|
|
||||||
|
if (debug & 2)
|
||||||
|
{
|
||||||
|
Pout<< " -> face hit:" << curPt
|
||||||
|
<< " comparing to face normal " << area << endl;
|
||||||
|
}
|
||||||
|
return indexedOctree<treeDataPrimitivePatch>::getSide
|
||||||
|
(
|
||||||
|
area,
|
||||||
|
sample - curPt
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug & 2)
|
||||||
|
{
|
||||||
|
Pout<< " -> face miss:" << curPt;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 2] Check whether intersection is on one of the face vertices or
|
||||||
|
// face centre
|
||||||
|
//
|
||||||
|
|
||||||
|
const scalar typDimSqr = mag(area) + VSMALL;
|
||||||
|
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
if ((magSqr(points[f[fp]] - curPt)/typDimSqr) < tolSqr)
|
||||||
|
{
|
||||||
|
// Face intersection point equals face vertex fp
|
||||||
|
|
||||||
|
// Calculate point normal (wrong: uses face normals instead of
|
||||||
|
// triangle normals)
|
||||||
|
|
||||||
|
return indexedOctree<treeDataPrimitivePatch>::getSide
|
||||||
|
(
|
||||||
|
patch_.pointNormals()[f[fp]],
|
||||||
|
sample - curPt
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const point fc(f.centre(points));
|
||||||
|
|
||||||
|
if ((magSqr(fc - curPt)/typDimSqr) < tolSqr)
|
||||||
|
{
|
||||||
|
// Face intersection point equals face centre. Normal at face centre
|
||||||
|
// is already average of face normals
|
||||||
|
|
||||||
|
if (debug & 2)
|
||||||
|
{
|
||||||
|
Pout<< " -> centre hit:" << fc
|
||||||
|
<< " distance:" << magSqr(fc - curPt)/typDimSqr << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return indexedOctree<treeDataPrimitivePatch>::getSide
|
||||||
|
(
|
||||||
|
area,
|
||||||
|
sample - curPt
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 3] Get the 'real' edge the face intersection is on
|
||||||
|
//
|
||||||
|
|
||||||
|
const labelList& fEdges = patch_.faceEdges()[faceI];
|
||||||
|
|
||||||
|
forAll(fEdges, fEdgeI)
|
||||||
|
{
|
||||||
|
label edgeI = fEdges[fEdgeI];
|
||||||
|
const edge& e = patch_.edges()[edgeI];
|
||||||
|
|
||||||
|
pointHit edgeHit = e.line(points).nearestDist(sample);
|
||||||
|
|
||||||
|
if ((magSqr(edgeHit.rawPoint() - curPt)/typDimSqr) < tolSqr)
|
||||||
|
{
|
||||||
|
// Face intersection point lies on edge e
|
||||||
|
|
||||||
|
// Calculate edge normal (wrong: uses face normals instead of
|
||||||
|
// triangle normals)
|
||||||
|
const labelList& eFaces = patch_.edgeFaces()[edgeI];
|
||||||
|
|
||||||
|
vector edgeNormal(vector::zero);
|
||||||
|
|
||||||
|
forAll(eFaces, i)
|
||||||
|
{
|
||||||
|
edgeNormal += patch_.faceNormal()[eFaces[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug & 2)
|
||||||
|
{
|
||||||
|
Pout<< " -> real edge hit point:" << edgeHit.rawPoint()
|
||||||
|
<< " comparing to edge normal:" << edgeNormal
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Found face intersection point on this edge. Compare to edge
|
||||||
|
// normal
|
||||||
|
return indexedOctree<treeDataPrimitivePatch>::getSide
|
||||||
|
(
|
||||||
|
edgeNormal,
|
||||||
|
sample - curPt
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 4] Get the internal edge the face intersection is on
|
||||||
|
//
|
||||||
|
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
pointHit edgeHit = linePointRef
|
||||||
|
(
|
||||||
|
points[f[fp]],
|
||||||
|
fc
|
||||||
|
).nearestDist(sample);
|
||||||
|
|
||||||
|
if ((magSqr(edgeHit.rawPoint() - curPt)/typDimSqr) < tolSqr)
|
||||||
|
{
|
||||||
|
// Face intersection point lies on edge between two face triangles
|
||||||
|
|
||||||
|
// Calculate edge normal as average of the two triangle normals
|
||||||
|
vector e = points[f[fp]] - fc;
|
||||||
|
vector ePrev = points[f[f.rcIndex(fp)]] - fc;
|
||||||
|
vector eNext = points[f[f.fcIndex(fp)]] - fc;
|
||||||
|
|
||||||
|
vector nLeft = ePrev ^ e;
|
||||||
|
nLeft /= mag(nLeft) + VSMALL;
|
||||||
|
|
||||||
|
vector nRight = e ^ eNext;
|
||||||
|
nRight /= mag(nRight) + VSMALL;
|
||||||
|
|
||||||
|
if (debug & 2)
|
||||||
|
{
|
||||||
|
Pout<< " -> internal edge hit point:" << edgeHit.rawPoint()
|
||||||
|
<< " comparing to edge normal "
|
||||||
|
<< 0.5*(nLeft + nRight)
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Found face intersection point on this edge. Compare to edge
|
||||||
|
// normal
|
||||||
|
return indexedOctree<treeDataPrimitivePatch>::getSide
|
||||||
|
(
|
||||||
|
0.5*(nLeft + nRight),
|
||||||
|
sample - curPt
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug & 2)
|
||||||
|
{
|
||||||
|
Pout<< "Did not find sample " << sample
|
||||||
|
<< " anywhere related to nearest face " << faceI << endl
|
||||||
|
<< "Face:";
|
||||||
|
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
Pout<< " vertex:" << f[fp] << " coord:" << points[f[fp]]
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can't determine status of sample with respect to nearest face.
|
||||||
|
// Either
|
||||||
|
// - tolerances are wrong. (if e.g. face has zero area)
|
||||||
|
// - or (more likely) surface is not closed.
|
||||||
|
|
||||||
|
return indexedOctree<treeDataPrimitivePatch>::UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Check if any point on shape is inside cubeBb.
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
bool
|
||||||
|
Foam::treeDataPrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||||
|
overlaps
|
||||||
|
(
|
||||||
|
const label index,
|
||||||
|
const treeBoundBox& cubeBb
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// 1. Quick rejection: bb does not intersect face bb at all
|
||||||
|
if (cacheBb_)
|
||||||
|
{
|
||||||
|
if (!cubeBb.overlaps(bbs_[index]))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!cubeBb.overlaps(calcBb(patch_.points(), patch_[index])))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 2. Check if one or more face points inside
|
||||||
|
|
||||||
|
const pointField& points = patch_.points();
|
||||||
|
const face& f = patch_[index];
|
||||||
|
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
if (cubeBb.contains(points[f[fp]]))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Difficult case: all points are outside but connecting edges might
|
||||||
|
// go through cube. Use triangle-bounding box intersection.
|
||||||
|
const point fc = f.centre(points);
|
||||||
|
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
bool triIntersects = triangleFuncs::intersectBb
|
||||||
|
(
|
||||||
|
points[f[fp]],
|
||||||
|
points[f[f.fcIndex(fp)]],
|
||||||
|
fc,
|
||||||
|
cubeBb
|
||||||
|
);
|
||||||
|
|
||||||
|
if (triIntersects)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Calculate nearest point to sample. Updates (if any) nearestDistSqr, minIndex,
|
||||||
|
// nearestPoint.
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
void
|
||||||
|
Foam::treeDataPrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||||
|
findNearest
|
||||||
|
(
|
||||||
|
const labelList& indices,
|
||||||
|
const point& sample,
|
||||||
|
|
||||||
|
scalar& nearestDistSqr,
|
||||||
|
label& minIndex,
|
||||||
|
point& nearestPoint
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const pointField& points = patch_.points();
|
||||||
|
|
||||||
|
forAll(indices, i)
|
||||||
|
{
|
||||||
|
label index = indices[i];
|
||||||
|
|
||||||
|
const face& f = patch_[index];
|
||||||
|
|
||||||
|
pointHit nearHit = f.nearestPoint(sample, points);
|
||||||
|
scalar distSqr = sqr(nearHit.distance());
|
||||||
|
|
||||||
|
if (distSqr < nearestDistSqr)
|
||||||
|
{
|
||||||
|
nearestDistSqr = distSqr;
|
||||||
|
minIndex = index;
|
||||||
|
nearestPoint = nearHit.rawPoint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
bool
|
||||||
|
Foam::treeDataPrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||||
|
intersects
|
||||||
|
(
|
||||||
|
const label index,
|
||||||
|
const point& start,
|
||||||
|
const point& end,
|
||||||
|
point& intersectionPoint
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Do quick rejection test
|
||||||
|
if (cacheBb_)
|
||||||
|
{
|
||||||
|
const treeBoundBox& faceBb = bbs_[index];
|
||||||
|
|
||||||
|
if ((faceBb.posBits(start) & faceBb.posBits(end)) != 0)
|
||||||
|
{
|
||||||
|
// start and end in same block outside of faceBb.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const pointField& points = patch_.points();
|
||||||
|
const face& f = patch_[index];
|
||||||
|
const point fc = f.centre(points);
|
||||||
|
const vector dir(end - start);
|
||||||
|
|
||||||
|
pointHit inter = patch_[index].intersection
|
||||||
|
(
|
||||||
|
start,
|
||||||
|
dir,
|
||||||
|
fc,
|
||||||
|
points,
|
||||||
|
intersection::HALF_RAY
|
||||||
|
);
|
||||||
|
|
||||||
|
if (inter.hit() && inter.distance() <= 1)
|
||||||
|
{
|
||||||
|
// Note: no extra test on whether intersection is in front of us
|
||||||
|
// since using half_ray
|
||||||
|
intersectionPoint = inter.hitPoint();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
210
src/meshTools/indexedOctree/treeDataPrimitivePatch.H
Normal file
210
src/meshTools/indexedOctree/treeDataPrimitivePatch.H
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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::treeDataPrimitivePatch
|
||||||
|
|
||||||
|
Description
|
||||||
|
Encapsulation of data needed to search on PrimitivePatches
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
treeDataPrimitivePatch.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef treeDataPrimitivePatch_H
|
||||||
|
#define treeDataPrimitivePatch_H
|
||||||
|
|
||||||
|
#include "PrimitivePatch.H"
|
||||||
|
//#include "indexedOctree.H"
|
||||||
|
#include "treeBoundBoxList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declaration of classes
|
||||||
|
template<class Type> class indexedOctree;
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class treeDataPrimitivePatchName Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
TemplateName(treeDataPrimitivePatch);
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class treeDataPrimitivePatch Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType=point
|
||||||
|
>
|
||||||
|
class treeDataPrimitivePatch
|
||||||
|
:
|
||||||
|
public treeDataPrimitivePatchName
|
||||||
|
{
|
||||||
|
// Static data
|
||||||
|
|
||||||
|
//- tolerance on linear dimensions
|
||||||
|
static scalar tolSqr;
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Underlying geometry
|
||||||
|
const PrimitivePatch<Face, FaceList, PointField, PointType>& patch_;
|
||||||
|
|
||||||
|
//- Whether to precalculate and store face bounding box
|
||||||
|
const bool cacheBb_;
|
||||||
|
|
||||||
|
//- face bounding boxes (valid only if cacheBb_)
|
||||||
|
treeBoundBoxList bbs_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Calculate face bounding box
|
||||||
|
static treeBoundBox calcBb(const pointField&, const face&);
|
||||||
|
|
||||||
|
//- Initialise all member data
|
||||||
|
void update();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from patch.
|
||||||
|
treeDataPrimitivePatch
|
||||||
|
(
|
||||||
|
const bool cacheBb,
|
||||||
|
const PrimitivePatch<Face, FaceList, PointField, PointType>&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
label size() const
|
||||||
|
{
|
||||||
|
return patch_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Get representative point cloud for all shapes inside
|
||||||
|
// (one point per shape)
|
||||||
|
pointField points() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Search
|
||||||
|
|
||||||
|
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
|
||||||
|
// Only makes sense for closed surfaces.
|
||||||
|
label getVolumeType
|
||||||
|
(
|
||||||
|
const indexedOctree
|
||||||
|
<
|
||||||
|
treeDataPrimitivePatch
|
||||||
|
<
|
||||||
|
Face,
|
||||||
|
FaceList,
|
||||||
|
PointField,
|
||||||
|
PointType
|
||||||
|
>
|
||||||
|
>&,
|
||||||
|
const point&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Does (bb of) shape at index overlap bb
|
||||||
|
bool overlaps
|
||||||
|
(
|
||||||
|
const label index,
|
||||||
|
const treeBoundBox& sampleBb
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Calculates nearest (to sample) point in shape.
|
||||||
|
// Returns actual point and distance (squared)
|
||||||
|
void findNearest
|
||||||
|
(
|
||||||
|
const labelList& indices,
|
||||||
|
const point& sample,
|
||||||
|
|
||||||
|
scalar& nearestDistSqr,
|
||||||
|
label& nearestIndex,
|
||||||
|
point& nearestPoint
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Calculates nearest (to line) point in shape.
|
||||||
|
// Returns point and distance (squared)
|
||||||
|
void findNearest
|
||||||
|
(
|
||||||
|
const labelList& indices,
|
||||||
|
const linePointRef& ln,
|
||||||
|
|
||||||
|
treeBoundBox& tightest,
|
||||||
|
label& minIndex,
|
||||||
|
point& linePoint,
|
||||||
|
point& nearestPoint
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
notImplemented
|
||||||
|
(
|
||||||
|
"treeDataPrimitivePatch::findNearest"
|
||||||
|
"(const labelList&, const linePointRef&, ..)"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Calculate intersection of shape with ray. Sets result
|
||||||
|
// accordingly
|
||||||
|
bool intersects
|
||||||
|
(
|
||||||
|
const label index,
|
||||||
|
const point& start,
|
||||||
|
const point& end,
|
||||||
|
point& result
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "treeDataPrimitivePatch.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user