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

Access to field which is evaluated at the moment

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 1 Post By Tobi
  • 1 Post By Tobi
  • 1 Post By Tobi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 12, 2017, 18:51
Default Access to field which is evaluated at the moment
  #1
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Augsburg
Posts: 2,336
Blog Entries: 6
Rep Power: 39
Tobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hey everybody,

after a lot of suggestions from Philip Cardiff, I implement non-orthogonal corrections to the symmetry patches. In foam-extend it is straight forward and it is already implemented. However in FOAM-4.x it was not as straight forward than in extend or maybe I did it in an complex way. However, I build my own solidSymmetric boundary condition. Based on the fact that the class is a template one, I have to make some checks:
  • Displacement field -> do non-ortho corrections
  • Temperature field -> don't do non-ortho corrections (or differently)
Example given. The surface normal gradient function is given as:
Code:
template<class Type>                                                            
Foam::tmp<Foam::Field<Type>>                                                    
Foam::solidSymmetryFvPatchField<Type>::snGrad() const                           
{                                                                                                                                  
    const vectorField nHat(this->patch().nf());                                 
                                                                                
    Field<Type> iF(this->patchInternalField());                                 
                                                                                
    //- Non-orthogonal correctors     

    if ("Displacement field")
    {                                         
        vectorField delta(this->patch().delta());                                   
        vectorField k = delta - nHat * (nHat & delta);                              
                                                                                
        const fvPatchTensorField& gradD =                                           
        this->patch().template lookupPatchField<volTensorField, tensor>         
        (                                                                       
            "grad(D)"                                                           
        );   



        //- Correct iF
        iF ...                                                                   
    }                           
                                                                                
    return                                                                      
        (transform(I - 2.0*sqr(nHat), iF) - iF)                                 
       *(this->patch().deltaCoeffs()/2.0);                                      
}
As you can see, I need some check if the actual field is the displacement field but I could not figure out how I can check the field name from the patch here. I went through Doxygen to figure out which class could have access to the field name (T, D, ...) but could not find anything till now. Does anyone does know how to get access which volField is calling the function at the moment?


Any feedback would be warmly welcomed and I hope I pointed out what I want to do.
Lisandro Maders likes this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   April 12, 2017, 19:07
Default
  #2
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Augsburg
Posts: 2,336
Blog Entries: 6
Rep Power: 39
Tobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Okay solved in an easy way. I added a boolean for switching on and off the nonOrthoCorrection in the boundary of each field (default = false). So the solution is:
Code:
    //- Non-orthogonal correctors                                               
    if (nonOrthoCorrection_)                                                    
    {                                                                           
        vectorField delta(this->patch().delta());                               
        vectorField k = delta - nHat * (nHat & delta);                          
                                                                                
        const fvPatchTensorField& gradD =                                       
            this->patch().template lookupPatchField<volTensorField, tensor>     
            (                                                                   
                "gradD"                                                         
            );                                                                  
                                                                                
        const vectorField corrector = (k & gradD.patchInternalField());         
         
        //- PROBLEM                                                                       
        iF += corrector;                                                        
    }
However, the last problem is to cast the corrector into a <Type> form. The corrector loop is always done for a vector loop but based on the template I have to cast it somehow. Any idea, - tomorrow I will hopefully figure it out (maybe with some input of you).

Good night.
Lisandro Maders likes this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   April 13, 2017, 07:59
Default
  #3
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Augsburg
Posts: 2,336
Blog Entries: 6
Rep Power: 39
Tobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hey all,

solved in the way that I derived a new class without using a template. Finally, now it is like in foam-extend but you have to take a bit more care (things are not 100% similar, as we would expect). Everything is working now
Lisandro Maders likes this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   April 19, 2017, 04:16
Default
  #4
Senior Member
 
Join Date: Oct 2013
Posts: 393
Rep Power: 14
chriss85 will become famous soon enough
Have you done any tests to check for the influence of this correction at the boundary?
chriss85 is offline   Reply With Quote

Old   April 19, 2017, 04:33
Default
  #5
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Augsburg
Posts: 2,336
Blog Entries: 6
Rep Power: 39
Tobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Of course...


Sent from my HTC One mini using CFD Online Forum mobile app
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   April 19, 2017, 05:15
Default
  #6
Senior Member
 
Join Date: Oct 2013
Posts: 393
Rep Power: 14
chriss85 will become famous soon enough
So, are there any relevant differences or is this a minor effect? I'm wondering if it's important to consider this when nonorthogonal meshes with symmetries are used.
chriss85 is offline   Reply With Quote

Old   April 19, 2017, 14:09
Default
  #7
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Augsburg
Posts: 2,336
Blog Entries: 6
Rep Power: 39
Tobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
To keep everything clear. I consider only solid stress calculation. And yes it accelerates the convergence. In fluid dynamics I would say, that you can not see the difference but I did not checked that.

Sent from my HTC One mini using CFD Online Forum mobile app
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Access field from different region in chtMultiRegionFoam JoeFriend OpenFOAM Programming & Development 0 March 21, 2017 11:35
[SOWFA] NREL SOWFA ABLTerrainSolver tutorial problem cico0815 OpenFOAM Community Contributions 18 February 1, 2016 19:16
How to access the field of weighting factor of interpolations fumiya OpenFOAM 2 November 16, 2012 08:33
Access to field data sepp OpenFOAM 2 February 10, 2011 12:45


All times are GMT -4. The time now is 17:34.