|
[Sponsors] |
Issue with Implementing Custom Boundary Condition using codedMixed in OpenFOAM |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 2, 2023, 10:19 |
Issue with Implementing Custom Boundary Condition using codedMixed in OpenFOAM
|
#1 |
Member
Al
Join Date: May 2019
Posts: 37
Rep Power: 7 |
Hello everyone,
I am currently trying to implement the following custom boundary condition in OpenFOAM: The boundary condition relates the gradient of a scalar field (phi) at a certain boundary (y=0) with the gradient of temperature. I have decided to use codedMixed for this purpose in the boundary field of phi. Below is the code I've written, which seems to work up to a point: Code:
fluid_to_solid { type codedMixed; value uniform 5e-2; name phitFlux; refValue uniform 5e-2; refGradient uniform 0; valueFraction uniform 0; //1 - Dirictlect ; 0 - Neumann codeInclude #{ #include "fvCFD.H" #}; codeOptions #{ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude #}; codeLibs #{ -lmeshTools \ -lfiniteVolume #}; code #{ // Get current patchi const label patchi = patch().index(); // Accessing the temperature field of the current patch const volScalarField& TS=db().lookupObject<volScalarField>("T"); // I am facing issues while trying to compute snGrad for the temperature field // When I use snGrad(), I encounter an error. However, removing .snGrad() (like shown below) lets it run without any problem. const scalarField& TG = TS.boundaryField()[patchi]; // How can I add .snGrad() here? // This is the phi of the current patch, which is not utilized in the code right now const scalarField& phip(*this); // Constants of the equation const scalar C1 = 1; const scalar C2 = 2; // Here, this->refGrad() represents the left side of the equation concerning phi. this->refGrad() = C1*C2*TG; } #}; } Could someone kindly provide insights or corrections on how I can successfully calculate the snGrad for the temperature field in the above context? Thank you in advance! |
|
November 3, 2023, 11:36 |
|
#2 |
Member
Al
Join Date: May 2019
Posts: 37
Rep Power: 7 |
I managed to add snGrad using the following code
Code:
// Access the entire temperature field const volScalarField& T = db().lookupObject<volScalarField>("T"); // Calculate the surface-normal gradient for the entire temperature field const surfaceScalarField gradT = fvc::snGrad(T); // Extract the values at the boundary of interest const scalarField& gradT_boundary = gradT.boundaryField()[patchi]; // Here, this->refGrad() represents the left side of the equation concerning phi. this->refGrad() = C1*C2*gradT_boundary; But there is a problem still when i am running the code, after the first iteration, it gives me core dumped error Code:
#0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::sigFpe::sigHandler(int) at ??:? #2 ? in /lib/x86_64-linux-gnu/libpthread.so.0 #3 ? in /lib/x86_64-linux-gnu/libm.so.6 #4 Foam::log(Foam::Field<double>&, Foam::UList<double> const&) at ??:? #5 void Foam::log<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:? #6 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::log<Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&) at ??:? #7 Foam::surfaceTensionModels::temperatureDependent::sigma() const at ??:? #8 Foam::phaseSystem::surfaceTensionCoeff(Foam::phasePairKey const&) const at ??:? #9 Foam::phaseSystem::surfaceTensionForce() const at ??:? #10 ? in ~/OpenFOAM/ubuntu-v2006/platforms/linux64GccDPInt32Opt/bin/icoReactingMultiphaseInterFoamPhi2BrounNew2 #11 __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6 #12 ? in ~/OpenFOAM/ubuntu-v2006/platforms/linux64GccDPInt32Opt/bin/icoReactingMultiphaseInterFoamPhi2BrounNew2 Floating point exception (core dumped) |
|
November 3, 2023, 12:02 |
|
#3 | |
Member
Lorenzo
Join Date: Apr 2020
Location: Italy
Posts: 46
Rep Power: 6 |
Hi aliyah,
It seems that something could be wrong with the surface tension rather than the BC. Could you please provide the phaseProperties dict of your test case? I guessed the error is due the surface tension force because of the following lines: Quote:
Regards, Lorenzo |
||
November 5, 2023, 06:51 |
|
#4 | |
Member
Al
Join Date: May 2019
Posts: 37
Rep Power: 7 |
Quote:
Thanks for your tip. You were right. I was using a custom surface tension model and this custom surface tension model had logarithmic terms causing issues. When I used the abovementioned boundary condition, it resulted in negative values for the logarithm. I've now addressed this and things are working better. Appreciate your help. Best, |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wind turbine simulation | Saturn | CFX | 60 | July 17, 2024 06:45 |
Custom boundary condition in OpenFOAM | saurcerer | OpenFOAM | 0 | May 5, 2023 14:24 |
Question about different kinds of Boundaries and Boundary Conditions | granzer | Main CFD Forum | 17 | April 12, 2022 18:27 |
My radial inflow turbine | Abo Anas | CFX | 27 | May 11, 2018 02:44 |
Wrong flow in ratating domain problem | Sanyo | CFX | 17 | August 15, 2015 07:20 |