|
[Sponsors] |
Boundary Conditions: How is temperature modified in constHTemperatureRadiationFvPatch |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 28, 2015, 10:08 |
Boundary Conditions: How is temperature modified in constHTemperatureRadiationFvPatch
|
#1 |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Hi Foames,
Can anybody help me understand how temperature is being modified here? This is a part of code being implemented for modifying temperature at a pacth. Code:
void Foam::constHTemperatureRadiationFvPatchScalarField::updateCoeffs() { if (this->updated()) { return; } // const scalarField K_ = patch().lookupPatchField<volScalarField, scalar>("K"); const scalar sigma = constant::physicoChemical::sigma.value(); forAll(*this, i) { const scalar T = operator[](i); // positive heat flux heats solid, negative cools solid // convection const scalar qConv = h_[i]*(Tinf_[i] - T); // radiation const scalar absorptivity = emissivity_[i]; const scalar emissivitySurroundings = emissivity_[i]; const scalar qRadIncident = emissivitySurroundings*sigma*pow4(Tinf_[i]); const scalar qRadAbsorbed = + absorptivity *qRadIncident; const scalar qRadEmission = - emissivity_[i]*sigma*pow4(T); const scalar qRad = + qRadAbsorbed + qRadEmission; const scalar qTotal = qRad + qConv; this->refValue()[i] = Tinf_[i]; // not used this->refGrad()[i] = qTotal; this->valueFraction()[i] = 0.0; } mixedFvPatchField<scalar>::updateCoeffs(); } Code:
this->refValue()[i] = Tinf_[i]; // not used this->refGrad()[i] = qTotal; this->valueFraction()[i] = 0.0; |
|
April 28, 2015, 12:32 |
|
#2 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
The gradient of the temperature field at the boundary is set to the heat flux. OpenFOAM uses this heat flux to determine the temperature in the simulation (it is not set to a fixed value.)
|
|
April 28, 2015, 12:44 |
|
#3 | |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Quote:
However, I did not understand well. Are you saying that grad(T)/dz = qRad in this case? What will happen if I use valueFraction = 1? I am trying to implement a boundary condition with given function: T_s = T_0 + 1/Cp(Qr/phi - Hv) I can get all the values (constant and field variables) at the patch. How should I update the temperature in the code? Thanks |
||
April 28, 2015, 12:57 |
|
#4 | |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
Quote:
|
||
April 28, 2015, 13:25 |
|
#5 | |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Quote:
Thanks for a nice explanation. But as in the code valueFarction = 0 then Value = refGrad (qRad) as shown in the code...... is this grad(T)/dz? if I use valueFraction =1 then Value = refValue (Tref) as shown in the code.....is this T? Does it change the value also based on valueFraction? for valueFraction =0 it calculates temperature gradient and for valueFraction =1, it calculates fix temperature value? |
||
April 28, 2015, 14:09 |
|
#6 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
I guess your code is from fireFoam.
As you can see at https://github.com/fireFoam-dev/fire...larField.H#L53 the class constHTemperatureRadiationFvPatchScalarField is derived from the mixedFvPatchField class. The value at the boundary is calculated then at https://github.com/OpenFOAM/OpenFOAM...chField.C#L168 where you can see the effect of the valueFraction variable. So if it's 0 only the gradient is considered, if it's 1 only the value (and interpolated for values in between). |
|
April 28, 2015, 14:11 |
|
#7 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
If you look at the code, you will see that the superclass method updateCoeffs is called (for mixedFvPatchField). If you look at the code there, you can see how the BCs are applied. I've found the best way to implement BCs is to write it out mathematically and see what you need to set your gradient and value references to get what you want.
|
|
April 29, 2015, 05:44 |
|
#8 |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Hi Marco and Joachim,
Thank you very much for a nice explanation. I am very new to OpenFOAM and try to modify BC for my case. It clears many doubts that I had. I will try to implement and come back soon if there is any update. Also, if there is any thread that can help me regarding implementing new BC please share. Thanks in advance.. |
|
April 29, 2015, 09:16 |
|
#9 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
||
April 30, 2015, 06:17 |
|
#10 | |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Hi,
Thanks Joachim for your references. I tried to implement my boundary condition and successfully compiled it as well but while running the solver I am getting errors. I think there is something wrong with Cp, the way it is being accessed from the solver. But I am not sure what to do. I tried many things playing with this terms looking at other boundary conditions but could not get away of it. Please help. Code:
void Foam::customHTemperatureFvPatchScalarField::updateCoeffs() { if (this->updated()) { return; } const label patchI = patch().index(); const basicThermo& thermo = db().lookupObject<basicThermo>("thermophysicalProperties"); const fvsPatchField<scalar>& phip = patch().lookupPatchField<surfaceScalarField, scalar>(phiName_); const fvsPatchField<scalar>& Qrp = patch().lookupPatchField<surfaceScalarField, scalar>(QrName_); // const scalarField alphap = // turbulence.alphaEff()().boundaryField()[patchI]; // const fvmesh& mesh = patch().boundaryMesh().mesh(); const scalarField Cp_ = thermo.Cp(); // thermo.Cp().boundaryField()[patchI]; // mesh.lookupObject<volScalarField>(thermo.cp()); scalar T0=300; scalar Hv=8500; refValue() = Tinf_; refGrad() = 0.0; valueFraction() = 1.0 + 1.0/(T0*Cp_)*((Qrp/phip)-Hv); //1.0/(1.0 + K_/max(h_,SMALL)*patch().deltaCoeffs()); mixedFvPatchField<scalar>::updateCoeffs(); } Quote:
Please suggest what should I do? Thanks in advance.... |
||
April 30, 2015, 12:21 |
|
#11 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
Using the code search feature of github in the OpenFOAM/OpenFOAM-2.3.x repository I found the following code at
https://github.com/OpenFOAM/OpenFOAM...arField.C#L256 Code:
Qr = patch().lookupPatchField<volScalarField, scalar>(QrName_); Where is your Qrp defined, cell of face? |
|
April 30, 2015, 12:48 |
|
#12 | |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Quote:
Code:
void Foam::customHTemperatureFvPatchScalarField::updateCoeffs() { if (this->updated()) { return; } const label patchI = patch().index(); const basicThermo& thermo = db().lookupObject<basicThermo>("thermophysicalProperties"); const fvsPatchField<scalar>& phip = patch().lookupPatchField<surfaceScalarField, scalar>(phiName_); const fvPatchField<scalar>& Qrp = patch().lookupPatchField<volScalarField, scalar>(QrName_); // const scalarField alphap = // turbulence.alphaEff()().boundaryField()[patchI]; // const fvmesh& mesh = patch().boundaryMesh().mesh(); const scalarField Cp_ = thermo.Cp(); // thermo.Cp().boundaryField()[patchI]; // mesh.lookupObject<volScalarField>(thermo.cp()); scalar T0=300; scalar Hv=8500; refValue() = Tinf_; refGrad() = 0.0; valueFraction() = 1.0 + 1.0/(T0*Cp_)*((Qrp/phip)-Hv); //1.0/(1.0 + K_/max(h_,SMALL)*patch().deltaCoeffs()); mixedFvPatchField<scalar>::updateCoeffs(); } Looking at the errors is it also possible that he problem also comes from phip not from Qr? Thanks |
||
April 30, 2015, 19:46 |
|
#13 | |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
Quote:
|
||
May 1, 2015, 06:12 |
|
#14 | |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Hi Joachim,
I am sorry for editing the post many times. But I have done something and posting the current status. I have attached my files for your reference. Just want to tell you that what I have done actually. I have taken another boundary condition which was working to update temperature and modify that. The error is similar but it is looking for volScalarField now, not surfaceScalarField as before. Since I am new I may do some silly mistakes and here we discuss on a different track. It is a great help from you. Please share if you found the problem and I will try to modify that part. objectRegistryTemplates.C customEnthalpyFluxTemperatureFvPatchScalarField.C customEnthalpyFluxTemperatureFvPatchScalarField.H Code:
template<class Type> const Type& Foam::objectRegistry::lookupObject(const word& name) const { const_iterator iter = find(name); if (iter != end()) { const Type* vpsiPtr_ = dynamic_cast<const Type*>(iter()); if (vpsiPtr_) { return *vpsiPtr_; } FatalErrorIn ( "objectRegistry::lookupObject<Type>(const word&) const" ) << nl << " lookup of " << name << " from objectRegistry " << this->name() << " successful\n but it is not a " << Type::typeName << ", it is a " << iter()->type() << abort(FatalError); } else { if (this->parentNotTime()) { return parent_.lookupObject<Type>(name); } FatalErrorIn ( "objectRegistry::lookupObject<Type>(const word&) const" ) << nl //line 164 << " request for " << Type::typeName << " " << name << " from objectRegistry " << this->name() << " failed\n available objects of type " << Type::typeName << " are" << nl << names<Type>() << abort(FatalError); } return *reinterpret_cast< const Type* >(0); } The error looks like: Quote:
Thanks in advance Last edited by mehtab; May 1, 2015 at 07:43. |
||
May 1, 2015, 12:26 |
|
#15 | |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Hi,
any body knows how radField is being declared here? https://github.com/fireFoam-dev/fire...arField.C#L225 In this boundary condition implementation radiative heat flux is being accessed on a boundary patch. I am trying to do the same but getting errors. Also in the current implementation nbrPatch.lookupObjectField has been used. I am using patch.lookupObjectField instead because in my case there is only one region and no interface. Quote:
Thanks in advance |
||
May 1, 2015, 12:51 |
|
#17 | |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Hi,
I tried to mdify my boundary condition and compiled it. I have edited "fixedEnthalpyFluxTemperatureFvPatchScalarFiel d" and also taken some part of the code from "turbulentTemperatureRadiationQinCoupledMixed" for accessing radiation flux Qr. Code:
void Foam::customEnthalpyFluxTemperatureFvPatchScalarField::updateCoeffs() { if (this->updated()) { return; } const label patchI = patch().index(); const basicThermo& thermo = db().lookupObject<basicThermo>("thermophysicalProperties"); const scalarField Cp_ = thermo.Cp(); const fvsPatchField<scalar>& phip = patch().lookupPatchField<surfaceScalarField, scalar>(phiName_); //add radiation part to read Qr scalarList radField(patch().size(),0.0); radField = patch().lookupPatchField<volScalarField, scalar> ( FieldRadiativeName_ ); // mpp().distribute(radField); const fvMesh& mesh = patch().boundaryMesh().mesh(); const radiation::radiationModel& radiation = mesh.lookupObject<radiation::radiationModel> ( "radiationProperties" ); scalarField temissivity ( radiation.absorptionEmission().e()().boundaryField() [ //nbrPatch.index() patch().index() ] ); scalar Qr = gSum(radField*patch().magSf()); const compressible::LESModel& turbulence = db().lookupObject<compressible::LESModel> ( "LESProperties" ); const scalarField alphap = turbulence.alphaEff()().boundaryField()[patchI]; scalar T0=300; scalar Hv=8500; refValue() = Tinf_; refGrad() = 0.0; valueFraction() = 1.0 + 1.0/(T0*Cp_)*((Qr/phip)-Hv); //Info << valueFraction() << endl; //Info << refValue() << endl; // } mixedFvPatchField<scalar>::updateCoeffs(); } While running tutorial it show following errors: Quote:
Please help.... Thanks Last edited by mehtab; May 5, 2015 at 10:00. |
||
May 5, 2015, 09:50 |
|
#18 |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
CGNS Boundary conditions using SU2 | denzell | SU2 | 3 | July 9, 2018 05:58 |
several fields modified by single boundary condition | schröder | OpenFOAM Programming & Development | 3 | April 21, 2015 05:09 |
Overflow Error in Multiphase Modelling with Two Continuous Fluids | ashtonJ | CFX | 6 | August 11, 2014 14:32 |
Radiation interface | hinca | CFX | 15 | January 26, 2014 17:11 |
An error has occurred in cfx5solve: | volo87 | CFX | 5 | June 14, 2013 17:44 |