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

[swak4Foam] Post-processing on an empty patch using swak4foam

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 9, 2013, 10:42
Default Post-processing on an empty patch using swak4foam
  #1
Member
 
Join Date: Jan 2011
Posts: 45
Rep Power: 15
buffi is on a distinguished road
Hi,

I have a large domain consisting of multiple similar regions for which I want to calculate surface flow field quantities such as U*T*dA through a surface in order to come up with an energy balance.

I used topoSet to create cellSets (for each region) and then created smaller meshes using subsetMesh. However, the new meshes contain an empty patch (which was internal before) called oldInternalFaces. I understand why that empty patch must be there, but how can I now calculate surface field flow?

I tried swak4Foam with this function object:
Code:
  QFlow
  {
    type patchFieldFlow;
    functionObjectLibs
    (
      "libsimpleFunctionObjects.so"
    );
    verbose true;
    patches
    (
      inX
      outX
      oldInternalFaces
    );
    fields
    (
      k
    );
    factor 4185;
    outputControl timeStep;
    outputInterval 1;
  }
but unfortunately, swak4foam reports surface field flow through oldInternalFaces as zero.

Also, the field I'm interested in (T) cannot be found by swak4foam (that's why I used k in the above example). Does anybody know why and how I can fix that? The field is where it's supposed to be and I can view it in paraFoam.

When I do the same calculation in paraFoam using the calculator filter with U*T, the resulting surface field flow is non-zero. So to sum it up: How can I calculate quantities such as U*T*dA and integrate them over an empty patch? I don't want to use paraFoam as I'd like to use the results in scripts (many cases).

Regards

Christoph
buffi is offline   Reply With Quote

Old   October 9, 2013, 11:08
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by buffi View Post
Hi,

I have a large domain consisting of multiple similar regions for which I want to calculate surface flow field quantities such as U*T*dA through a surface in order to come up with an energy balance.

I used topoSet to create cellSets (for each region) and then created smaller meshes using subsetMesh. However, the new meshes contain an empty patch (which was internal before) called oldInternalFaces. I understand why that empty patch must be there, but how can I now calculate surface field flow?

I tried swak4Foam with this function object:
Code:
  QFlow
  {
    type patchFieldFlow;
    functionObjectLibs
    (
      "libsimpleFunctionObjects.so"
    );
    verbose true;
    patches
    (
      inX
      outX
      oldInternalFaces
    );
    fields
    (
      k
    );
    factor 4185;
    outputControl timeStep;
    outputInterval 1;
  }
but unfortunately, swak4foam reports surface field flow through oldInternalFaces as zero.
Check phi. I think (but please check before you take my word) that this should be zero on an empty patch. And 0*k is 0

Quote:
Originally Posted by buffi View Post
Also, the field I'm interested in (T) cannot be found by swak4foam (that's why I used k in the above example). Does anybody know why and how I can fix that? The field is where it's supposed to be and I can view it in paraFoam.
That is strange. Which solver are you using? If T is in the registry swak should find it. But there are very special cases where a second field named T exists and throws the original out of the registry (its still there. Just not registered anymore). On the other hand: then T shouldn't get written anyhow

Quote:
Originally Posted by buffi View Post
When I do the same calculation in paraFoam using the calculator filter with U*T, the resulting surface field flow is non-zero. So to sum it up: How can I calculate quantities such as U*T*dA and integrate them over an empty patch? I don't want to use paraFoam as I'd like to use the results in scripts (many cases).
That is quite possible. If paraview doesn't understand a boundary condition it uses zeroGradient. So you might get a non-zero U on the empty-boundary (and even a component "through" the empty). Maybe an expression "(U&Sf())*T" will give you your flow (not sure whether U is allowed to be non-zero on the boundary)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   October 9, 2013, 11:35
Default
  #3
Member
 
Join Date: Jan 2011
Posts: 45
Rep Power: 15
buffi is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Check phi. I think (but please check before you take my word) that this should be zero on an empty patch. And 0*k is 0
I wasn't sure how to check phi, so I just looked at the boundary in phi.gz and it just contains the "empty" patch description. However, the patch normal is aligned with the y coordinate, so I foamCalc'ed components U and the result of Uy*T is zero as well.

I'm using simpleFoam with an added equation for T. Here's the instatiation:
Code:
volScalarField T
(
  IOobject
  (
    "T",
    runTime.timeName(),
    mesh,
    IOobject::MUST_READ,
    IOobject::AUTO_WRITE
  ),
  mesh
);
Quote:
Maybe an expression "(U&Sf())*T" will give you your flow
How would the function object look like then? I tried
Code:
  QFlow1
  {
    type surfaces;
    valueType surface;
    surfaceName oldInternalFaces;
    expression "U&Sf())*T";
    accumulations (sum);
    outputControl timeStep;
    outputInterval 1;
  }
but that also gave me zero.Not sure if the function object is correct, though.

My conclusion for now is that my way of splitting the domain for post-processing is not well suited for my goal of integrating over the new surface created by the split.
buffi is offline   Reply With Quote

Old   October 9, 2013, 12:01
Default
  #4
Member
 
Join Date: Jan 2011
Posts: 45
Rep Power: 15
buffi is on a distinguished road
If that matters, here's how I execute the function:
Code:
execFlowFunctionObjects -dict funkyDoCalcDict
and the dict is in the system/.
buffi is offline   Reply With Quote

Old   October 9, 2013, 16:23
Default
  #5
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by buffi View Post
I wasn't sure how to check phi, so I just looked at the boundary in phi.gz and it just contains the "empty" patch description. However, the patch normal is aligned with the y coordinate, so I foamCalc'ed components U and the result of Uy*T is zero as well.

I'm using simpleFoam with an added equation for T. Here's the instatiation:
Code:
volScalarField T
(
  IOobject
  (
    "T",
    runTime.timeName(),
    mesh,
    IOobject::MUST_READ,
    IOobject::AUTO_WRITE
  ),
  mesh
);
How would the function object look like then? I tried
Code:
  QFlow1
  {
    type surfaces;
    valueType surface;
    surfaceName oldInternalFaces;
    expression "U&Sf())*T";
    accumulations (sum);
    outputControl timeStep;
    outputInterval 1;
  }
but that also gave me zero.Not sure if the function object is correct, though.
Looks OK to me.

And it "finds" T (you must have changed something)

Quote:
Originally Posted by buffi View Post
My conclusion for now is that my way of splitting the domain for post-processing is not well suited for my goal of integrating over the new surface created by the split.
Splitting is OK (I guess). The problem is that "empty" is not the appropriate BC for that. That BC is for "erasing" the 3rd dimension for a 2D-calculation. So it is designed to "not let anything through".
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   October 10, 2013, 03:42
Default
  #6
Member
 
Join Date: Jan 2011
Posts: 45
Rep Power: 15
buffi is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Looks OK to me.
And it "finds" T (you must have changed something)
Yes, it's a totally different function object which presumably is implemented differently. I haven't had a look at the code, though...

Quote:
Originally Posted by gschaider View Post
Splitting is OK (I guess). The problem is that "empty" is not the appropriate BC for that. That BC is for "erasing" the 3rd dimension for a 2D-calculation. So it is designed to "not let anything through".
Yes, empty is not suitable in this case. Any suggestion what I could use instead without too much hassle? I tried to turn it into a plain patch using createPatch and then remap the fields, but mapFields refused to map anything.
buffi is offline   Reply With Quote

Old   October 10, 2013, 10:57
Default
  #7
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by buffi View Post
Yes, it's a totally different function object which presumably is implemented differently. I haven't had a look at the code, though...
Both use "lookupObject" so it should be the same

Quote:
Originally Posted by buffi View Post
Yes, empty is not suitable in this case. Any suggestion what I could use instead without too much hassle? I tried to turn it into a plain patch using createPatch and then remap the fields, but mapFields refused to map anything.
I'm not sure what your "multiple regions" (original posting) are. Your setup only makes sense for a multiRegion-solver like chtFoam. If you want "control surfaces" in a single-region solver then faceZones or faceSets are more what you need
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   October 10, 2013, 11:13
Default
  #8
Member
 
Join Date: Jan 2011
Posts: 45
Rep Power: 15
buffi is on a distinguished road
Thanks for the hint, the term "region" in my first post was misleading. I'll try faceSets or faceZones. I have never used faceZones, what exactly are they? The documentation is not very verbose in that respect...
buffi is offline   Reply With Quote

Old   October 10, 2013, 13:31
Default
  #9
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by buffi View Post
Thanks for the hint, the term "region" in my first post was misleading. I'll try faceSets or faceZones. I have never used faceZones, what exactly are they? The documentation is not very verbose in that respect...
These are collections of faces. Some mesh converters generate them. Another possibility is topoSet (look through the tutorials for examples like lagrangian/reactingParcelFoam/filter/system/topoSetDict).

But that is not a swak-problem anymore
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   October 11, 2013, 04:25
Default
  #10
Member
 
Join Date: Jan 2011
Posts: 45
Rep Power: 15
buffi is on a distinguished road
I did a forum search on the difference between faceSets and faceZones, and found this thread: http://www.cfd-online.com/Forums/ope...condition.html (post #8). So what I would need here is a faceZone wherever I want to sample in the field and I could then use swak4Foam or some other post-processing tool to calculate the quantities I'm interested in and integrate them over the zone. Does that sound viable? It would still be a potential swak-problem

To make this more descriptive, here are two screenshots of the whole mesh and of the subdomain:
wholeDomain.jpg
The whole domain consists of 5 similar subdomains for which I want to calculate an energy balance. This is one of the subdomains I generated with subsetMesh, the new empty patch is on the left side:
gasketRegion.png
buffi is offline   Reply With Quote

Old   October 11, 2013, 08:28
Default
  #11
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by buffi View Post
I did a forum search on the difference between faceSets and faceZones, and found this thread: http://www.cfd-online.com/Forums/ope...condition.html (post #8). So what I would need here is a faceZone wherever I want to sample in the field and I could then use swak4Foam or some other post-processing tool to calculate the quantities I'm interested in and integrate them over the zone. Does that sound viable? It would still be a potential swak-problem

To make this more descriptive, here are two screenshots of the whole mesh and of the subdomain:
Attachment 25994
The whole domain consists of 5 similar subdomains for which I want to calculate an energy balance. This is one of the subdomains I generated with subsetMesh, the new empty patch is on the left side:
Attachment 25995
swak can do calculations on faceSets and faceZones. So if can create them you're in business. Examples for using swakExpression or similar can be found in the examples and in the presentations that are found on the Wiki-page. If you use phi you'll need the flip()-function
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   October 11, 2013, 08:46
Default
  #12
Member
 
Join Date: Jan 2011
Posts: 45
Rep Power: 15
buffi is on a distinguished road
Well, I was able to create a faceSet from the new empty patch, but not in the larger domain where these faces would be internal.

Evaluating with swak4foam didn't work as expected. This is the code I used:
Code:
functions 
(
  QFlow2
  {
    type swakExpression;
    valueType faceSet;
    setName beforeFilter;
    expression "phi*flip()*T";
    accumulations (
      sum
    );
    verbose true;
  }
);
but I got this error message:
Code:
Unknown function type swakExpression

Table of functionObjects is empty
buffi is offline   Reply With Quote

Old   October 11, 2013, 09:58
Default
  #13
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by buffi View Post
Well, I was able to create a faceSet from the new empty patch, but not in the larger domain where these faces would be internal.

Evaluating with swak4foam didn't work as expected. This is the code I used:
Code:
functions 
(
  QFlow2
  {
    type swakExpression;
    valueType faceSet;
    setName beforeFilter;
    expression "phi*flip()*T";
    accumulations (
      sum
    );
    verbose true;
  }
);
but I got this error message:
Code:
Unknown function type swakExpression

Table of functionObjects is empty
You've got to add the library with the functionObjects to the libs-list in controlDict (check the examples)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   October 11, 2013, 11:52
Default
  #14
Member
 
Join Date: Jan 2011
Posts: 45
Rep Power: 15
buffi is on a distinguished road
Thanks for the hint, will try that on monday...
buffi is offline   Reply With Quote

Old   October 14, 2013, 04:59
Default
  #15
Member
 
Join Date: Jan 2011
Posts: 45
Rep Power: 15
buffi is on a distinguished road
Adding the lib helped a bit, but didn't give me a result. For
Code:
functions 
(
  QFlow2
  {
    type swakExpression;
    valueType faceSet;
    setName intFaces;
    expression "phi*flip()*T";
    accumulations (
      sum
    );
    verbose true;
  }
);
to work, I need a faceSet named "intFaces" and a cellSet named "intFacesSlaveCells". I created those with a topoSetDict containing
Code:
actions
(
  {
    name intFaces;
    type faceSet;
    action new;
    source patchToFace;
    sourceInfo
    {
      name "oldInternalFaces";
    }
  }
  {
    name intFacesSlaveCells;
    type cellSet;
    action new;
    source faceToCell;
    sourceInfo
    {
      set intFaces;             // Name of faceSet
      option any;
    }
  }
);
However, executing
Code:
execFlowFunctionObjects -time 10011 -dict funkyDoCalcDict
returns an error stating: "field T not existing or of wrong type". The field T does exist and can viewed in paraFoam.
buffi is offline   Reply With Quote

Old   October 14, 2013, 08:31
Default
  #16
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by buffi View Post
Adding the lib helped a bit, but didn't give me a result. For
Code:
functions 
(
  QFlow2
  {
    type swakExpression;
    valueType faceSet;
    setName intFaces;
    expression "phi*flip()*T";
    accumulations (
      sum
    );
    verbose true;
  }
);
to work, I need a faceSet named "intFaces" and a cellSet named "intFacesSlaveCells". I created those with a topoSetDict containing
Code:
actions
(
  {
    name intFaces;
    type faceSet;
    action new;
    source patchToFace;
    sourceInfo
    {
      name "oldInternalFaces";
    }
  }
  {
    name intFacesSlaveCells;
    type cellSet;
    action new;
    source faceToCell;
    sourceInfo
    {
      set intFaces;             // Name of faceSet
      option any;
    }
  }
);
However, executing
Code:
execFlowFunctionObjects -time 10011 -dict funkyDoCalcDict
returns an error stating: "field T not existing or of wrong type". The field T does exist and can viewed in paraFoam.
The function objects don't search on the disc for data but only in memory. You can switch that behaviour on with the searchOnDisc-option (must be set in each FO-spec. See the incomplete reference guide). But why don't you use funkyDoCalc?
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   October 14, 2013, 08:49
Default
  #17
Member
 
Join Date: Jan 2011
Posts: 45
Rep Power: 15
buffi is on a distinguished road
I didn't use funkyDoCalc because I didn't get it working first, that's all. I didn't know about any substantial differences between the two so this was not real decision.

Removed the "functions" block surrounding the definition to make it work with funkyDoCalc, this is the resulting dict:
Code:
QFlow2
{
  type swakExpression;
  valueType faceSet;
  setName intFaces;
  searchOnDisk true;
  expression "phi*flip()*T";
  accumulations (
    sum
  );
  verbose true;
}
But unfortunately the error remains:
Code:
Could not find a field name T of type scalar (neither surfaceScalarField nor volScalarField) autoInterpolate: 0 (try setting 'autoInterpolate' to 'true')


    From function SubsetValueExpressionDriver::getFieldInternalAndInterpolate(const word &name,const Subset &sub)
    in file SubsetValueExpressionDriverI.H at line 303.
buffi is offline   Reply With Quote

Old   October 14, 2013, 10:15
Default
  #18
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by buffi View Post
I didn't use funkyDoCalc because I didn't get it working first, that's all. I didn't know about any substantial differences between the two so this was not real decision.

Removed the "functions" block surrounding the definition to make it work with funkyDoCalc, this is the resulting dict:
Code:
QFlow2
{
  type swakExpression;
  valueType faceSet;
  setName intFaces;
  searchOnDisk true;
  expression "phi*flip()*T";
  accumulations (
    sum
  );
  verbose true;
}
But unfortunately the error remains:
Code:
Could not find a field name T of type scalar (neither surfaceScalarField nor volScalarField) autoInterpolate: 0 (try setting 'autoInterpolate' to 'true')


    From function SubsetValueExpressionDriver::getFieldInternalAndInterpolate(const word &name,const Subset &sub)
    in file SubsetValueExpressionDriverI.H at line 303.
I think the error message explains quite well what the problem (you're doing calculations on faces and need a field that is only defined in the cells) is and it even suggests a fix (read the reference guide about autoInterpolate).

No matter what I write into the error messages the effect is similar to writing "There is a problem. Ask Bernhard". And when I ask nobody says "Well. I would have understood that error message if it had said ...." so I guess people think "Ups. I should have read the content of the message before asking"
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   October 14, 2013, 10:37
Default
  #19
Member
 
Join Date: Jan 2011
Posts: 45
Rep Power: 15
buffi is on a distinguished road
Quote:
Originally Posted by gschaider View Post
I think the error message explains quite well what the problem (you're doing calculations on faces and need a field that is only defined in the cells) is and it even suggests a fix (read the reference guide about autoInterpolate).
I read the error message and thought "If there is no field to be found, interpolating that not-a-field will not solve my problem". That's why I didn't even try autoInterpolate.
Quote:
No matter what I write into the error messages the effect is similar to writing "There is a problem. Ask Bernhard". And when I ask nobody says "Well. I would have understood that error message if it had said ...." so I guess people think "Ups. I should have read the content of the message before asking"
I totally understand your point here as I'm in a similar position regularly, but in a different context.

adding autoInterpolate true to the function indeed made the error disappear, I'll see if the results make any sense.

Thanks!

Christoph
buffi 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
[Other] Can't Shake Erros: patch type 'patch' not constraint type 'empty' BrendaEM OpenFOAM Meshing & Mesh Conversion 12 April 3, 2022 18:32
[Commercial meshers] Mesh conversion problem (fluent3DMeshToFoam) Aadhavan OpenFOAM Meshing & Mesh Conversion 2 March 8, 2018 01:47
Compressor Simulation using rhoPimpleDyMFoam Jetfire OpenFOAM Running, Solving & CFD 107 December 9, 2014 13:38
[GAMBIT] periodic faces not matching Aadhavan ANSYS Meshing & Geometry 6 August 31, 2013 11:25
[Commercial meshers] Fluent msh and cyclic boundary cfdengineering OpenFOAM Meshing & Mesh Conversion 48 January 25, 2013 03:28


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