|
[Sponsors] |
creating functionObject for uTau - compilation i.O. - application error |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 13, 2014, 11:29 |
creating functionObject for uTau - compilation i.O. - application error
|
#1 | |
Senior Member
Join Date: Nov 2012
Location: Bavaria
Posts: 145
Rep Power: 14 |
Hi Foamers,
I've tried to adapt a functionObject to finally get uTau during simulation. Following error comes up once I've start the case with the 'new' FO activated: Quote:
Code:
\*---------------------------------------------------------------------------*/ #ifndef uTau_H #define uTau_H #include "functionObjectFile.H" #include "volFieldsFwd.H" #include "Switch.H" #include "OFstream.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { // Forward declaration of classes class objectRegistry; class dictionary; class polyMesh; class mapPolyMesh; class fvMesh; /*---------------------------------------------------------------------------*\ Class uTau Declaration \*---------------------------------------------------------------------------*/ class uTau : public functionObjectFile { protected: // Protected data //- Name of this set of uTau object word name_; const objectRegistry& obr_; //- on/off switch bool active_; //- Switch to send output to Info as well as to file Switch log_; //- Optional list of patches to process labelHashSet patchSet_; // Protected Member Functions //- File header information virtual void writeFileHeader(const label i); //- Calculate the shear stress void calcuTau ( const fvMesh& mesh, volScalarField& uTau, const volVectorField& U, volScalarField nuLam ); //- Disallow default bitwise copy construct uTau(const uTau&); //- Disallow default bitwise assignment void operator=(const uTau&); public: //- Runtime type information TypeName("uTau"); // Constructors //- Construct for given objectRegistry and dictionary. // Allow the possibility to load fields from files uTau ( const word& name, const objectRegistry&, const dictionary&, const bool loadFromFiles = false ); //- Destructor virtual ~uTau(); // Member Functions //- Return name of the set of uTau virtual const word& name() const { return name_; } //- Read the uTau data virtual void read(const dictionary&); //- Execute, currently does nothing virtual void execute(); //- Execute at the final time-loop, currently does nothing virtual void end(); //- Called when time was set at the end of the Time::operator++ virtual void timeSet(); //- Calculate the uTau and write virtual void write(); //- Update for changes of mesh virtual void updateMesh(const mapPolyMesh&) {} //- Update for changes of mesh virtual void movePoints(const polyMesh&) {} }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* // Code:
\*---------------------------------------------------------------------------*/ #include "uTau.H" #include "volFields.H" #include "surfaceFields.H" #include "incompressible/turbulenceModel/turbulenceModel.H" #include "compressible/turbulenceModel/turbulenceModel.H" #include "wallPolyPatch.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(uTau, 0); } // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // void Foam::uTau::writeFileHeader(const label i) { // Add headers to output data writeHeader(file(), "uTau"); writeCommented(file(), "Time"); writeTabbed(file(), "patch"); writeTabbed(file(), "min"); writeTabbed(file(), "max"); } void Foam::uTau::calcuTau ( const fvMesh& mesh, volScalarField& uTauField, const volVectorField& U, volScalarField nuLam ) { forAllConstIter(labelHashSet, patchSet_, iter) { label patchI = iter.key(); const polyPatch& pp = mesh.boundaryMesh()[patchI]; scalarField& uTau_p = uTauField.boundaryField()[patchI]; uTau_p = sqrt ( nuLam.boundaryField()[patchI] *mag(U.boundaryField()[patchI].snGrad()) ); scalar minUTau = gMin(uTau_p); scalar maxUTau = gMax(uTau_p); if (Pstream::master()) { file() << mesh.time().value() << token::TAB << pp.name() << token::TAB << minUTau << token::TAB << maxUTau << endl; } Info(log_)<< " min/max(" << pp.name() << ") = " << minUTau << ", " << maxUTau << endl; } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::uTau::uTau ( const word& name, const objectRegistry& obr, const dictionary& dict, const bool loadFromFiles ) : functionObjectFile(obr, name, typeName), name_(name), obr_(obr), active_(true), log_(true), patchSet_() { // Check if the available mesh is an fvMesh, otherwise deactivate if (!isA<fvMesh>(obr_)) { active_ = false; WarningIn ( "uTau::uTau" "(" "const word&, " "const objectRegistry&, " "const dictionary&, " "const bool" ")" ) << "No fvMesh available, deactivating " << name_ << nl << endl; } if (active_) { const fvMesh& mesh = refCast<const fvMesh>(obr_); volScalarField* uTauPtr ( new volScalarField ( IOobject ( type(), mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensionedScalar ( "0", dimless, //sqr(dimLength)/sqr(dimTime), 0 ) ) ); mesh.objectRegistry::store(uTauPtr); } read(dict); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::uTau::~uTau() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::uTau::read(const dictionary& dict) { if (active_) { log_ = dict.lookupOrDefault<Switch>("log", true); const fvMesh& mesh = refCast<const fvMesh>(obr_); const polyBoundaryMesh& pbm = mesh.boundaryMesh(); patchSet_ = mesh.boundaryMesh().patchSet ( wordReList(dict.lookupOrDefault("patches", wordReList())) ); Info<< type() << " " << name_ << ":" << nl; if (patchSet_.empty()) { forAll(pbm, patchI) { if (isA<wallPolyPatch>(pbm[patchI])) { patchSet_.insert(patchI); } } Info<< " processing all wall patches" << nl << endl; } else { Info<< " processing wall patches: " << nl; labelHashSet filteredPatchSet; forAllConstIter(labelHashSet, patchSet_, iter) { label patchI = iter.key(); if (isA<wallPolyPatch>(pbm[patchI])) { filteredPatchSet.insert(patchI); Info<< " " << pbm[patchI].name() << endl; } else { WarningIn("void uTau::read(const dictionary&)") << "Requested uTau on non-wall boundary " << "type patch: " << pbm[patchI].name() << endl; } } Info<< endl; patchSet_ = filteredPatchSet; } } } void Foam::uTau::execute() { //typedef compressible::turbulenceModel cmpModel; typedef incompressible::turbulenceModel icoModel; if (active_) { functionObjectFile::write(); const fvMesh& mesh = refCast<const fvMesh>(obr_); volScalarField& uTau = const_cast<volScalarField&> ( mesh.lookupObject<volScalarField>(type()) ); Info(log_)<< type() << " " << name_ << " output:" << nl; //neu const volVectorField& U = obr_.lookupObject<volVectorField>("U"); tmp<volScalarField> nuLam; if (mesh.foundObject<icoModel>("turbulenceModel")) { const icoModel& model = mesh.lookupObject<icoModel>("turbulenceModel"); nuLam = model.nu(); } else { FatalErrorIn("void Foam::uTau::write()") << "Unable to find turbulence model in the " << "database" << exit(FatalError); } calcuTau(mesh, uTau, U, nuLam); } } void Foam::uTau::end() { if (active_) { execute(); } } void Foam::uTau::timeSet() { // Do nothing } void Foam::uTau::write() { if (active_) { functionObjectFile::write(); const volVectorField& uTau = obr_.lookupObject<volVectorField>(type()); Info(log_)<< type() << " " << name_ << " output:" << nl << " writing field " << uTau.name() << nl << endl; uTau.write(); } } // ************************************************************************* // Thanks! Ayla |
||
September 18, 2014, 21:04 |
|
#2 |
New Member
Janaína de Andrade Silva
Join Date: Mar 2014
Posts: 8
Rep Power: 12 |
How could you do this ?
|
|
April 29, 2018, 15:50 |
|
#3 | |
Senior Member
Guilherme
Join Date: Apr 2017
Posts: 245
Rep Power: 10 |
Quote:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
error compiling modified applications | yvyan | OpenFOAM Programming & Development | 21 | March 1, 2016 05:53 |
Mesquite - Adaptive mesh refinement / coarsening? | philippose | OpenFOAM Running, Solving & CFD | 94 | January 27, 2016 10:40 |
OpenFOAM without MPI | kokizzu | OpenFOAM Installation | 4 | May 26, 2014 10:17 |
Compiling dynamicTopoFvMesh for OpenFOAM 2.1.x | Saxwax | OpenFOAM Installation | 25 | November 29, 2013 06:34 |
Problem with compile the setParabolicInlet | ivanyao | OpenFOAM Running, Solving & CFD | 6 | September 5, 2008 21:50 |