|
[Sponsors] |
Setting normal gradient of each face of patch |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 16, 2019, 10:36 |
Setting normal gradient of each face of patch
|
#1 |
New Member
Join Date: Dec 2016
Posts: 24
Rep Power: 9 |
Hi all,
In my simulation, I have to reset the fixed gradient of a scalar field "s" as a BC on a patch each time step. Now, I am aware that if all faces of a patch get the same value, you can use Code:
label BCID = mesh.boundaryMesh().findPatchID("part0"); if(s.boundaryField()[BCID].type() == fixedGradientFvPatchScalarField::typeName) { fixedGradientFvPatchScalarField& spatch = refCast<fixedGradientFvPatchScalarField>(s.boundaryFieldRef()[BCID]); spatch.gradient() = dp; } This will set the normal gradient of scalar "s" on all faces of patch "part0" to value "dp". Which works perfectly. But what if I want to give each face a different value? Say something like this: Code:
label BCID = mesh.boundaryMesh().findPatchID("part0"); if(s.boundaryField()[BCID].type() == fixedGradientFvPatchScalarField::typeName) { fixedGradientFvPatchScalarField& spatch = refCast<fixedGradientFvPatchScalarField>(s.boundaryFieldRef()[BCID]); forAll (spatch, faceI) { spatch[faceI].gradient() = dp[faceI]; } } Code:
sBC.H:32:18: error: request for member ‘gradient’ in ‘(& spatch)->Foam::fixedGradientFvPatchField<double>:: <anonymous>.Foam::fvPatchField<double>::<anonymous>.Foam::Field<double>:: <anonymous>.Foam::List<double>::<anonymous>.Foam::UList<double>::operator[](faceI)’, which is of non-class type ‘double’ spatch[faceI].gradient() = dp[faceI]; Thanks in advance, |
|
July 16, 2019, 11:00 |
|
#2 | |
Member
Hosein
Join Date: Nov 2011
Location: Germany
Posts: 94
Rep Power: 14 |
Quote:
have you tried it this way: spatch.gradient()[faceI] = dp[faceI] |
||
July 16, 2019, 11:08 |
|
#3 |
New Member
Join Date: Dec 2016
Posts: 24
Rep Power: 9 |
Oh my... Not my brightest moment. Thanks a lot for the superfast reply!
|
|
Tags |
boudary condition, patch gradient |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
steadyUniversalMRFFoam Tutorial fails in MixingPlane | HenrikJohansson | OpenFOAM Bugs | 0 | February 14, 2019 05:48 |
[mesh manipulation] Importing Multiple Meshes | thomasnwalshiii | OpenFOAM Meshing & Mesh Conversion | 18 | December 19, 2015 19:57 |
NACA0012 geometry/design software needed | Franny | Main CFD Forum | 13 | July 7, 2007 16:57 |
[Gmsh] Import gmsh msh to Foam | adorean | OpenFOAM Meshing & Mesh Conversion | 24 | April 27, 2005 09:19 |
Multicomponent fluid | Andrea | CFX | 2 | October 11, 2004 06:12 |