CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

Setting constant value in a volume

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 8, 2017, 19:44
Default Setting constant value in a volume
  #1
New Member
 
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 9
miha23 is on a distinguished road
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
miha23 is offline   Reply With Quote

Old   December 9, 2017, 04:16
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
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;
        }
    }
Though, depending on your solver, maybe fixedTemperatureConstraint could be more suitable.
amuzeshi likes this.
alexeym is offline   Reply With Quote

Old   December 9, 2017, 11:57
Default
  #3
New Member
 
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 9
miha23 is on a distinguished road
Thank you Alexey. It works fine.
miha23 is offline   Reply With Quote

Old   March 28, 2018, 12:25
Default
  #4
New Member
 
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 9
miha23 is on a distinguished road
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
It only appears once, at the beginning of the simulation.
Have you got any idea, where I could make the mistake?

Thanks,
Gábor
miha23 is offline   Reply With Quote

Old   March 28, 2018, 17:32
Default
  #5
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
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".
alexeym is offline   Reply With Quote

Old   March 28, 2018, 17:43
Default
  #6
New Member
 
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 9
miha23 is on a distinguished road
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);
And my fvOptions file is this:

Code:
fixedConcentration
{
	type 		scalarFixedValueConstraint;
	active 		yes;
	
	scalarFixedValueConstraintCoeffs
	{	
		selectionMode	cellZone;
		cellZone		pollutionSource;
		fieldValues
		{
			c		0;
		}
	}
}
Furthermore, I have checked that
Code:
	-I$(LIB_SRC)/fvOptions/lnInclude \
    -lfvOptions \
are included in the Make/options

and my modified simplefoam solver contains the followings also
Code:
#include "fvOptions.H"
    #include "createFvOptions.H"
And cEqn is called right after the pEqn:
Code:
 // --- Pressure-velocity SIMPLE corrector
        {
            #include "UEqn.H"
            #include "pEqn.H"
	    #include "cEqn.H"

        }

        laminarTransport.correct();
        turbulence->correct();
but I have tried if I put it after the turbulence -> correct(), but in that case the above mentioned warning appears also before "Solving for k" and epsilon
miha23 is offline   Reply With Quote

Old   March 30, 2018, 13:31
Default
  #7
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,753
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
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.
LuckyTran is offline   Reply With Quote

Old   April 15, 2018, 13:36
Default
  #8
New Member
 
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 9
miha23 is on a distinguished road
I got the pollution source in the cellZone dict.

Any ideas? Anyone?
miha23 is offline   Reply With Quote

Old   April 21, 2018, 04:41
Default
  #9
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

The output

Code:
Source fixedConcentration defined for field c but never used
is produced by checkApplied method (which in turn calls checkApplied method of concrete finite volume option).

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?
alexeym is offline   Reply With Quote

Old   November 6, 2018, 04:50
Default same issue different variables p and U
  #10
New Member
 
zeshan
Join Date: Apr 2016
Posts: 24
Rep Power: 10
Thecomebackkid is on a distinguished road
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);
        }
    }

}








// ************************************************************************* //
However when running my case none of those regions are zero. Also I have the issue with the checkApplied poping up for pressure not used on first iteration.


Any help is appreciated.
Thecomebackkid is offline   Reply With Quote

Old   November 22, 2021, 08:53
Default
  #11
New Member
 
Shengjie Lu
Join Date: Sep 2020
Location: Nanjing,China
Posts: 12
Rep Power: 6
hhu_lulu is on a distinguished road
Have you solved the problem? I have the same issue. The regions where I constraint to 0 by scalarFixedValueConstraint are not zero.
hhu_lulu is offline   Reply With Quote

Old   November 23, 2021, 04:20
Default
  #12
New Member
 
Shengjie Lu
Join Date: Sep 2020
Location: Nanjing,China
Posts: 12
Rep Power: 6
hhu_lulu is on a distinguished road
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.
hhu_lulu is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 06:23.