|
[Sponsors] |
January 24, 2011, 07:48 |
Accessing Patch Objects from Solver
|
#1 |
New Member
Nils Lavesson
Join Date: Jan 2011
Posts: 4
Rep Power: 15 |
Hi,
I am using OpenFOAM to solve an electrostatic problem involving several different potentials, represented by boundaries, that need to be optimized during the solution process. I am able to write optimization routines inside each boundary condition and change their values independently, but since the problem I am working on is quite strongly coupled this is not enough. I need to optimize all the boundary conditions together. My plan is to find the pointers to all the relevant boundaries objects inside the main solver and write a routine there that handles the boundary value optimization. However, I have not been able to figure out how to do this. Is there a way of accessing all the pointers to the boundaries (patchFields) inside the main solver? Maybe extracting them from the associated volField or from the fvMatrix? Do you know any other way to do something similar? Cheers, Nils |
|
January 25, 2011, 09:29 |
|
#2 |
New Member
Misha Marie Gregersen
Join Date: Nov 2009
Posts: 7
Rep Power: 16 |
Hi Niels
I am not sure exactly how you want to access the boundary values from the main script, so maybe my suggestion is a bit off, however I give it a try: I know you can fetch the values of for instance the internal field next to a boundary patch (here number 1) as a patch field for the volScalarField T through the fvMesh using: mesh.objectRegistry::lookupObject<volScalarField>( "T").boundaryField()[1].patchInternalField() Hope it helps. ~ Misha |
|
January 25, 2011, 10:15 |
|
#3 |
Senior Member
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 17 |
Hi Nils,
it's hard to tell you what to do without knowing which kind of boundary conditions you are using. But if you want to set the gradient of a fixedGradient-BC of a volScalarField p at boundary no. 5 for example you can use Code:
fixedGradientFvPatchScalarField& pPatch = refCast<fixedGradientFvPatchScalarField>(p.boundaryField()[5]); scalarField& pGrad = pPatch.gradient(); Code:
#include "fixedGradientFvPatchFields.H" Regards, Stefan @Misha: Your method is working if you need to know the internal field from within boundary conditions, but I think Nils is going to edit boundary condition from within top level solver. |
|
January 26, 2011, 02:50 |
|
#4 |
New Member
Nils Lavesson
Join Date: Jan 2011
Posts: 4
Rep Power: 15 |
Hi Misha and Stefan,
Stefan, the code you provided is exactly along the lines I was looking for. The exact implementation is not important, what I was looking for is how to get the patch objects. The real problem contains mostly fixed value boundary conditions, which I will probably modify using access functions. Looking at the doxygen I realize how the whole thing works. p.boundaryField() gives me an object that has inherited a FieldField, which in turn has inherited a container with all the patch objects. Then I simply have to do a cast and I get what I was looking for. Misha, your code also seems to get me the same objects. If I needed to get the same information and I didn't have access to the GeometricField object containing the electric potential, this would probably be the way to go. Thanks a lot for your help. Cheers, Nils |
|
January 26, 2011, 05:33 |
|
#5 |
New Member
Misha Marie Gregersen
Join Date: Nov 2009
Posts: 7
Rep Power: 16 |
Hi Nils and Stefan
Nils, good that you figured out how to access the object you needed! Stefan, I tested my code in the top level solver, and it actually accesses the internal patch field. But of course, you can also use it within a boundary condition. Best regards, Misha |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Cyclic Boundary Condition | Luiz Eduardo Bittencourt Sampaio (Sampaio) | OpenFOAM Running, Solving & CFD | 36 | July 2, 2012 12:23 |
Quarter Burner mesh with periosic condition | SamCanuck | FLUENT | 2 | August 31, 2011 11:34 |
Working directory via command line | Luiz | CFX | 4 | March 6, 2011 20:02 |
Accessing phi from a fvPatchField at same patch | johndeas | OpenFOAM | 1 | September 13, 2010 20:23 |
mapFields : internal edges | Gearb0x | OpenFOAM Running, Solving & CFD | 3 | April 19, 2010 09:02 |