|
[Sponsors] |
July 11, 2024, 11:43 |
Multi Region Constant Dictionaries Access
|
#1 |
New Member
Maciej Marczak
Join Date: Sep 2020
Posts: 7
Rep Power: 6 |
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. 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; } #}; } Thank you in advance |
|
July 12, 2024, 05:56 |
|
#2 |
New Member
Maciej Marczak
Join Date: Sep 2020
Posts: 7
Rep Power: 6 |
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; } #}; } |
|
|
|
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 |