|
[Sponsors] |
May 15, 2020, 08:25 |
Time Varying BC
|
#1 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 8 |
Hi,
I would like to have a time varying inlet BC for total pressure and total temperature. It works fine with uniformTotalPressure for the total pressure. Unfortunately I havent found a time varying BC for the total temperature. The only think I have found is uniformFixedValue, but I dont want to fix the static temperature, but the total temperature. Does anyone know how to use time varying total temperature BC? Kind regards, shock77 |
|
May 15, 2020, 18:29 |
|
#2 |
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13 |
Hi,
- OF has totalTemperature BC, but I think you already know it. - If you are comfortable with modifying the source code, and using a local library, you can modify `totalTemperature` BC's `scalarField``T0_` quantity (link) to be PatchFunction1 or `TimeFunction1`, so that you can use all time-varying condition capabilities of `Function1` class, e.g. CSV file, or time-value-pair table entry. - An example of them can be found in atmBoundaryLayer boundary conditions. Hope it helps.
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki-1/Wiki-2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESI-OpenCFD-Trademark) Bugs/Features: FOAM-Extend (Wikki-FSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror |
|
May 17, 2020, 15:22 |
|
#3 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 8 |
Hello HPE,
thank you very much for your detailed answer! I have no experience with coding, but I am willing to try and to learn. I will post my solution in case I succeed. Kind regards, shock77 |
|
May 18, 2020, 12:41 |
|
#4 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 8 |
Hello HPE,
I have tried to create a new BC named uniformTotalTemperature which shall be time varying. I have created a new folder in openfoam4/src/finiteVolume/fields/fvPatchFields/derived/totalPressure and copied totalTemperatureFvPatchScalarField.H and totalTemperatureFvPatchScalarField.C into my new BC-Folder and edited them. First I have just renamed every totalTemperature to uniformTotalTemperature to make sure my new BC works on this base lvl and it did without any trouble. I have included my BC files in the openfoam4/src/finiteVolume/Make/files and hit wmake. It worked fine. Unfortunately I have some issues with the editing. I get a lot of "notes" during compiliing and the following message at the end: Code:
openfoam4/wmake/rules/General/transform:8: recipe for target '/opt/openfoam4/platforms/linux64GccDPInt32Opt/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalTemperature/uniformTotalTemperatureFvPatchScalarField.o' failed In uniformTotalTemperatureFvPatchScalarField.H I did not many changes. I have included Function1 and tried to use it with "autoPtr<Function1<scalar>> T0_" so that I can use a table and I have deleted the Member Functions, like it has been done in uniformTotalPressure: Code:
#ifndef uniformTotalTemperatureFvPatchScalarField_H #define uniformTotalTemperatureFvPatchScalarField_H #include "fixedValueFvPatchFields.H" #include "Function1.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ Class uniformTotalTemperatureFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class uniformTotalTemperatureFvPatchScalarField : public fixedValueFvPatchScalarField { // Private data //- Name of the velocity field word UName_; //- Name of the flux transporting the field word phiName_; //- Name of the compressibility field used to calculate the wave speed word psiName_; //- Heat capacity ratio scalar gamma_; //- Table of time vs total temperature autoPtr<Function1<scalar>> T0_; public: //- Runtime type information TypeName("uniformTotalTemperature"); // Constructors //- Construct from patch and internal field uniformTotalTemperatureFvPatchScalarField ( const fvPatch&, const DimensionedField<scalar, volMesh>& ); //- Construct from patch, internal field and dictionary uniformTotalTemperatureFvPatchScalarField ( const fvPatch&, const DimensionedField<scalar, volMesh>&, const dictionary& ); //- Construct by mapping given uniformTotalTemperatureFvPatchScalarField // onto a new patch uniformTotalTemperatureFvPatchScalarField ( const uniformTotalTemperatureFvPatchScalarField&, const fvPatch&, const DimensionedField<scalar, volMesh>&, const fvPatchFieldMapper& ); //- Construct as copy uniformTotalTemperatureFvPatchScalarField ( const uniformTotalTemperatureFvPatchScalarField& ); //- Construct and return a clone virtual tmp<fvPatchScalarField> clone() const { return tmp<fvPatchScalarField> ( new uniformTotalTemperatureFvPatchScalarField(*this) ); } //- Construct as copy setting internal field reference uniformTotalTemperatureFvPatchScalarField ( const uniformTotalTemperatureFvPatchScalarField&, 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 uniformTotalTemperatureFvPatchScalarField(*this, iF) ); } // Member functions // Access // 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& ); // Evaluation functions //- Update the coefficients associated with the patch field virtual void updateCoeffs(); //- Write virtual void write(Ostream&) const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif Code:
#include "uniformTotalTemperatureFvPatchScalarField.H" #include "addToRunTimeSelectionTable.H" #include "fvPatchFieldMapper.H" #include "volFields.H" #include "surfaceFields.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::uniformTotalTemperatureFvPatchScalarField::uniformTotalTemperatureFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF ) : fixedValueFvPatchScalarField(p, iF), UName_("U"), phiName_("phi"), psiName_("thermo:psi"), gamma_(0.0), T0_() {} Foam::uniformTotalTemperatureFvPatchScalarField::uniformTotalTemperatureFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const dictionary& dict ) : fixedValueFvPatchScalarField(p, iF), UName_(dict.lookupOrDefault<word>("U", "U")), phiName_(dict.lookupOrDefault<word>("phi", "phi")), psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")), gamma_(readScalar(dict.lookup("gamma"))), T0_(Function1<scalar>::New("T0", dict)) { if (dict.found("value")) { fvPatchField<scalar>::operator= ( scalarField("value", dict, p.size()) ); } else { const scalar t = this->db().time().timeOutputValue(); fvPatchScalarField::operator==(T0_->value(t)); } } Foam::uniformTotalTemperatureFvPatchScalarField::uniformTotalTemperatureFvPatchScalarField ( const uniformTotalTemperatureFvPatchScalarField& ptf, const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const fvPatchFieldMapper& mapper ) : fixedValueFvPatchScalarField(p, iF), UName_(ptf.UName_), phiName_(ptf.phiName_), psiName_(ptf.psiName_), gamma_(ptf.gamma_), T0_(ptf.T0_, false) { patchType() = ptf.patchType(); const scalar t = this->db().time().timeOutputValue(); fvPatchScalarField::operator==(T0_->value(t)); } Foam::uniformTotalTemperatureFvPatchScalarField::uniformTotalTemperatureFvPatchScalarField ( const uniformTotalTemperatureFvPatchScalarField& ptf ) : fixedValueFvPatchScalarField(ptf), UName_(ptf.UName_), phiName_(ptf.phiName_), psiName_(ptf.psiName_), gamma_(ptf.gamma_), T0_(ptf.T0_, false) {} Foam::uniformTotalTemperatureFvPatchScalarField::uniformTotalTemperatureFvPatchScalarField ( const uniformTotalTemperatureFvPatchScalarField& ptf, const DimensionedField<scalar, volMesh>& iF ) : fixedValueFvPatchScalarField(ptf, iF), UName_(ptf.UName_), phiName_(ptf.phiName_), psiName_(ptf.psiName_), gamma_(ptf.gamma_), T0_(ptf.T0_, false) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::uniformTotalTemperatureFvPatchScalarField::updateCoeffs() { if (updated()) { return; } scalar T0 = T0_->value(this->db().time().timeOutputValue()); const fvPatchVectorField& Up = patch().lookupPatchField<volVectorField, vector>(UName_); const fvsPatchField<scalar>& phip = patch().lookupPatchField<surfaceScalarField, scalar>(phiName_); const fvPatchField<scalar>& psip = patch().lookupPatchField<volScalarField, scalar>(psiName_); scalar gM1ByG = (gamma_ - 1.0)/gamma_; operator== ( T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up)) ); fixedValueFvPatchScalarField::updateCoeffs(); } void Foam::uniformTotalTemperatureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); writeEntryIfDifferent<word>(os, "U", "U", UName_); writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_); os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; T0_->writeData(os); writeEntry("value", os); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { makePatchTypeField ( fvPatchScalarField, uniformTotalTemperatureFvPatchScalarField ); } I have also attached both files in case someone likes it better that way. I hope you HPE or someone else has some advice for me! Thanks in advance, shock77 |
|
May 18, 2020, 17:39 |
|
#5 |
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13 |
Hi,
- Please use PatchFunction1 instead of Function1 (Edit: OF4 certainly does not have that, but might OF7? Certainly OF1912 has). - I can modify the code for you within two weeks when I can be a bit more free. If this does not help, I'm sorry. Otherwise, don't hesitate to poke me after two weeks if you still don't receive anything from my side. - Till then might others kindly give a hand.
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki-1/Wiki-2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESI-OpenCFD-Trademark) Bugs/Features: FOAM-Extend (Wikki-FSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror |
|
May 19, 2020, 05:21 |
|
#6 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 8 |
Hi HPE,
thank you very much for your kind offer. I will try to make it run in the time beeing and hope I it will work. I will post again in case I make some progress or finish it. In OpenFOAM 4 and OpenFOAM 7 there is only Function1. I could find PatchFunction1 only in the other openfoam version. Kind regards, shock77 |
|
May 26, 2020, 06:27 |
|
#7 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 8 |
Hi HPE,
so I finally managed to create my time varying BC for the total temperature. I have atteched both files. It seems to work well, but if you could have a look at it, I would be glad, since this is my first time creating a custom BC. Thanks again. Kind regards, shock77 |
|
May 31, 2020, 16:36 |
|
#8 |
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13 |
The code looks fine, and I think it should be considered in the official OF version. If it operates as you expect, you should have no worry. Good luck with this!
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki-1/Wiki-2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESI-OpenCFD-Trademark) Bugs/Features: FOAM-Extend (Wikki-FSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror |
|
May 31, 2020, 17:47 |
|
#9 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 8 |
Thank you very much!
I am very glad to hear that! Kind regards, shock77 |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
bash script for pseudo-parallel usage of reconstructPar | kwardle | OpenFOAM Post-Processing | 42 | May 8, 2024 00:17 |
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field | lakeat | OpenFOAM Community Contributions | 58 | December 23, 2021 03:36 |
AMI speed performance | danny123 | OpenFOAM | 21 | October 24, 2020 05:13 |
Extrusion with OpenFoam problem No. Iterations 0 | Lord Kelvin | OpenFOAM Running, Solving & CFD | 8 | March 28, 2016 12:08 |
mixerVesselAMI2D's mass is not balancing | sharonyue | OpenFOAM Running, Solving & CFD | 6 | June 10, 2013 10:34 |