|
[Sponsors] |
December 8, 2017, 19:44 |
Setting constant value in a volume
|
#1 |
New Member
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 9 |
Dear Foamers!
I'd like to define a volume in my domain where the value of a field variable (e.g. temperature) is constant. I know that setFields does this, but I need this constant value in that volume to be constant for the whole time. Can anyone have an idea how to solve this, without hard coding? Thanks for advance, Gábor |
|
December 9, 2017, 04:16 |
|
#2 |
Senior Member
|
Hi,
$FOAM_SRC/fvOptions/constraints/fixedValueConstraint. Adapting header commentary for temperature: Code:
fixedTemperature { type scalarFixedValueConstraint; active yes; selectionMode cellZone; cellZone zone-with-constant-temperature; fieldValues { T 298.15; } } |
|
December 9, 2017, 11:57 |
|
#3 |
New Member
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 9 |
Thank you Alexey. It works fine.
|
|
March 28, 2018, 12:25 |
|
#4 |
New Member
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 9 |
Dear Alexey,
I am using scalarFixedValueConstraint for setting a constant concentration in a volume, but after I define the zone and the needed value in the fvOptions file, and I also add fvOtions(c) to my solver it gives back the following warning messege. Code:
smoothSolver: Solving for Ux, Initial residual = 1, Final residual = 0.0639208, No Iterations 4 smoothSolver: Solving for Uy, Initial residual = 0, Final residual = 0, No Iterations 0 smoothSolver: Solving for Uz, Initial residual = 0, Final residual = 0, No Iterations 0 GAMG: Solving for p, Initial residual = 1, Final residual = 0.024972, No Iterations 2 time step continuity errors : sum local = 1.22917e-05, global = 2.26427e-20, cumulative = 2.26427e-20 --> FOAM Warning : From function virtual void Foam::fv::option::checkApplied() const in file cfdTools/general/fvOptions/fvOption.C at line 118 Source fixedConcentration defined for field c but never used smoothSolver: Solving for c, Initial residual = 1, Final residual = 0.0451066, No Iterations 3 smoothSolver: Solving for epsilon, Initial residual = 0.953597, Final residual = 0.0238806, No Iterations 1 smoothSolver: Solving for k, Initial residual = 1, Final residual = 0.0701502, No Iterations 1 Have you got any idea, where I could make the mistake? Thanks, Gábor |
|
March 28, 2018, 17:32 |
|
#5 |
Senior Member
|
Hi,
Could you post how do you add fvOptions to your solver? I.e. post relevant code. Otherwise thread will become rather boring game "guess what I did wrong". |
|
March 28, 2018, 17:43 |
|
#6 |
New Member
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 9 |
My scalar transport eq. in the solver looks like this:
(The -sigma(U &d) is source here, where sigma is just a constant and d is a pointer vector, but I think this part is rather irrelevant in my problem.) Code:
fvScalarMatrix cEqn ( fvm::ddt(c) +fvm::div(phi, c) -fvm::laplacian(Dt, c) == -sigma*(U & d) +fvOptions(c) ); cEqn.relax(); fvOptions.constrain(cEqn); cEqn.solve(); fvOptions.correct(c); Code:
fixedConcentration { type scalarFixedValueConstraint; active yes; scalarFixedValueConstraintCoeffs { selectionMode cellZone; cellZone pollutionSource; fieldValues { c 0; } } } Code:
-I$(LIB_SRC)/fvOptions/lnInclude \ -lfvOptions \ and my modified simplefoam solver contains the followings also Code:
#include "fvOptions.H" #include "createFvOptions.H" Code:
// --- Pressure-velocity SIMPLE corrector { #include "UEqn.H" #include "pEqn.H" #include "cEqn.H" } laminarTransport.correct(); turbulence->correct(); |
|
March 30, 2018, 13:31 |
|
#7 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,753
Rep Power: 66 |
Go into your cellZones dict and make sure you have a cellZone named pollutionSource
If serial case, you need to check constant/polyMesh/cellZones And make sure they're also present for after you decompose, e.g. in 0/constant/polyMesh/cellZones. |
|
April 15, 2018, 13:36 |
|
#8 |
New Member
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 9 |
I got the pollution source in the cellZone dict.
Any ideas? Anyone? |
|
April 21, 2018, 04:41 |
|
#9 |
Senior Member
|
Hi,
The output Code:
Source fixedConcentration defined for field c but never used checkApplied method is called (in your case): - when you do "+fvOptions(c)" - when you do "fvOptions.constrain(cEqn)" - and finally when you do "fvOptions.correct(c)" In your case fvOption(c) does nothing, since you defined only constraining. After first call to constrain method, source marked as used and checkApplied becomes happy. So, I guess, the message could be ignored. And finally, does the simulation run smoothly or values of concentration are not constrained? |
|
November 6, 2018, 04:50 |
same issue different variables p and U
|
#10 |
New Member
zeshan
Join Date: Apr 2016
Posts: 24
Rep Power: 10 |
Dear all, I want the variables in specific regions to be constant 0. How is this possible. I have a fvOptions file and headers called in my solver for fvOptions.
Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 5 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; object fvOptions; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // fixedPressureGEARDRV { type scalarFixedValueConstraint; active yes; scalarFixedValueConstraintCoeffs { selectionMode cellZone; cellZone GEARDRV; fieldValues { p 0; } } } fixedVelocityGEARDRV { type vectorFixedValueConstraint; active yes; vectorFixedValueConstraintCoeffs { selectionMode cellZone; cellZone GEARDRV; fieldValues { U (0 0 0); } } } fixedPressureGEARDVN { type scalarFixedValueConstraint; active yes; scalarFixedValueConstraintCoeffs { selectionMode cellZone; cellZone GEARDVN; fieldValues { p 0; } } } fixedVelocityGEARDVN { type vectorFixedValueConstraint; active yes; vectorFixedValueConstraintCoeffs { selectionMode cellZone; cellZone GEARDVN; fieldValues { U (0 0 0); } } } // ************************************************************************* // Any help is appreciated. |
|
November 22, 2021, 08:53 |
|
#11 |
New Member
Shengjie Lu
Join Date: Sep 2020
Location: Nanjing,China
Posts: 12
Rep Power: 6 |
Have you solved the problem? I have the same issue. The regions where I constraint to 0 by scalarFixedValueConstraint are not zero.
|
|
November 23, 2021, 04:20 |
|
#12 |
New Member
Shengjie Lu
Join Date: Sep 2020
Location: Nanjing,China
Posts: 12
Rep Power: 6 |
I think I have figured out another way, in which adding fvOtions(c) to solver is not necessary. The scalarFixedValueConstraint could be placed within functions, i.e. the function scalarTransport in controlDict file.
At least for my case, this adaptation proved to be effective. My model aims to simulate the scalar transport in open channel. The pimpleFoam solver is imposed and the variable s in some regions of computational domain needs to be set to 0. Previously, I put the scalarFixedValueConstraint in fvOptions file and it didn't work. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
decomposePar problem: Cell 0contains face labels out of range | vaina74 | OpenFOAM Pre-Processing | 37 | July 20, 2020 06:38 |
alphaEqn.H in twoPhaseEulerFoam | cheng1988sjtu | OpenFOAM Bugs | 15 | May 1, 2016 17:12 |
[snappyHexMesh] No layers in a small gap | bobburnquist | OpenFOAM Meshing & Mesh Conversion | 6 | August 26, 2015 10:38 |
On the damBreak4phaseFine cases | paean | OpenFOAM Running, Solving & CFD | 0 | November 14, 2008 22:14 |
Warning 097- | AB | Siemens | 6 | November 15, 2004 05:41 |