CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Multi Region Constant Dictionaries Access

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 11, 2024, 11:43
Default Multi Region Constant Dictionaries Access
  #1
New Member
 
Maciej Marczak
Join Date: Sep 2020
Posts: 7
Rep Power: 6
MMarczak is on a distinguished road
Hello there,

1) Introduction:
I am working on multi region solver in Open FOAM 10. The solver is based on "chtMultiRegionFoam", but there is a one significant difference, that is except only separate region meshes, the solver also contains "globalMesh", it is, mesh before it was splited into regions. It is crucial to keep the structure like that because one equation is solved on this global mesh.

2) What has to done:
I am trying to implement a code that calculates new value of one of the boundary patches based on fields values. The new BC value has to be computed inside a loop that covers few PDE, so it cannot be done by only "codedFixedValue". The algorithm is divided in several componetes.

3) Problem:
Everything worked fie until I wanted to set new calculated value as a value on the boundary condition that is part of a specific region , not on the global mesh field.
The new value calulated by solver is stored in "batteryControl" dictionary that is defined for global mesh and I don't know how can I access this dictionary by my codedFixedValue. The solver simple cannot access this specific dictionary since it doesn't belong to this region, but for global mesh one.
Here is the error:
Code:
--> FOAM FATAL ERROR: 

    request for dictionary batteryControl from objectRegistry positive_electrode failed
    available objects of type dictionary are

10
(
MRFProperties
momentumTransport
electrolyteSolutionProperties
fvSchemes
fvSolution
thermophysicalTransport
data
physicalProperties
porosityProperties
electrodeProperties
)


    From function const Type& Foam::objectRegistry::lookupObject(const Foam::word&) const [with Type = Foam::IOdictionary]
    in file /home/ubuntu/OpenFOAM/OpenFOAM-10/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 211.
And here is the BC:
Code:
    positive_electrode_to_cc
    {
        type            codedFixedValue;
        name		galvanostaticControl;
        value		uniform 0;
        code
        #{
	
        	const dictionary& batteryControl = db().lookupObject<IOdictionary>("batteryControl");
        	const dictionary& galvanostatic = batteryControl.subDict("galvanostatic");
        	scalar U_cell = readScalar(galvanostatic.lookup("U_cell"));
        	const fvPatch& boundaryPatch = patch();
        	fvPatchField<scalar>& pField = *this;
        	
                forAll(pField, i)
            	{
                	pField[i] = U_cell;
            	}
        
        #};
    }
I know it might be simple issue, but I couldn't find a solution for a while, that's why I am asking for help.
Thank you in advance
MMarczak is offline   Reply With Quote

Old   July 12, 2024, 05:56
Default
  #2
New Member
 
Maciej Marczak
Join Date: Sep 2020
Posts: 7
Rep Power: 6
MMarczak is on a distinguished road
Hi again
I managed to solve it by myself. As I thought it was problem with navigation through the objectRegistry in multi-region solver.

I am leaving the code for "codedFixefdValue" here, in case anyone will encounter such issue.

Code:
    positive_electrode_to_cc
    {
        type            codedFixedValue;
        name	        	galvanostaticControl;
        value		        uniform 0;
        code
        #{
          const fvMesh& globalMesh = this->db().time().lookupObject<fvMesh>("region0");
          const dictionary& batteryControl = globalMesh.lookupObject<IOdictionary>("batteryControl"); 
        	const dictionary& galvanostatic = batteryControl.subDict("galvanostatic");
        	scalar U_cell = readScalar(galvanostatic.lookup("U_cell"));
        	const fvPatch& boundaryPatch = patch();
        	fvPatchField<scalar>& pField = *this;
        	
                forAll(pField, i)
            	{
                	pField[i] = U_cell;
            	}
        
        #};
    }
Happy foaming everyone!
MMarczak 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
Accessing dictionaries from constant folder in multi region solver F42 OpenFOAM Programming & Development 5 January 19, 2022 06:56
chtMultiRegionFoam speed up qwertz OpenFOAM Running, Solving & CFD 8 September 18, 2021 07:16
Some questions about a multi region case run in parallel zfaraday OpenFOAM Running, Solving & CFD 5 February 23, 2017 11:25
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 05:15
[Gmsh] Import gmsh msh to Foam adorean OpenFOAM Meshing & Mesh Conversion 24 April 27, 2005 09:19


All times are GMT -4. The time now is 10:42.