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

Copy mesh instance and save it to another place...

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 22, 2020, 08:15
Default Copy mesh instance and save it to another place...
  #1
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Augsburg
Posts: 2,383
Blog Entries: 6
Rep Power: 41
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi everybody, today I am playing around with the mesh object and actually I just want to do simple things. Right now, I am working on a new dynamic mesh library. Right at the beginning, I am checking if the mesh optional mesh was already created, if yes, I want to load this one (not a big deal), otherwise I want to save the current available mesh into a new location (this makes trouble). Actually I expect this not be a big deal. However, I am facing some problems. E.g., if I create a new instance of the mesh with the new folder, it (obviously) tries to search for the polyMesh files such as points and so on but actually this folder does not exist right now. In the code below, I create the actual mesh named meshPtr and copy it. Now, I want to save the copy to a new folder. The IOobject however does not allow one to change the path and if I create a new instance of the mesh using the IOobject including the correct path, it tries to search for mesh files which does not exist.

Code:
                                                                                            
        // Generate the actual mesh                                                                          
        autoPtr<dynamicFvMesh> meshPtr                                                                   
        (                                                                                                
            dynamicFvMesh::New                                                                           
            (                                                                                            
                IOobject                                                                                 
                (                                                                                        
                    dynamicFvMesh::defaultRegion,                                                        
                    time().timeName(),                                                                   
                    time(),                                                                              
                    IOobject::MUST_READ                                                                  
                )                                                                                        
            )                                                                                            
        );                                                                                               
                                                                                                 
         dynamicFvMesh& dynmesh = meshPtr();                                                              
        

        // Copy of the dynamic mesh                                                                                   
        Foam::fvMesh mesh = dynmesh;                                                                     


        // Change the save location ... ? IOobject does not allow this
        mesh.newPath("constant/polyMesh2");
        mesh.write();
Any hint related to the c++ objects are welcomed. I believe there is a simple function that can handle that.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   May 22, 2020, 11:01
Default
  #2
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Augsburg
Posts: 2,383
Blog Entries: 6
Rep Power: 41
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi all, an extension.


Can one tell me why the mesh (object) is not written? I first create a new object that stores the mesh constant/polyMesh. Then, I remove the constant/polyMesh folder and want to write the new mesh, which should actually create the polyMesh folder and the mesh files, shouldn't it? However, even if the write() functions return »true« no files are written.



Code:
        // Create static mesh                                                   
        word location = "";                                                     
        Foam::fvMesh backgroundMesh                                             
        (                                                                       
            Foam::IOobject                                                      
            (                                                                   
                Foam::fvMesh::defaultRegion,                                    
                time().timeName(),                                              
                time(),                                                         
                Foam::IOobject::MUST_READ                                       
            )                                                                   
        );                                                                      
                                                                                
        rmDir ("constant/polyMesh");                                            
                                                                                
        //backgroundMesh = *this;                                               
        backgroundMesh.write();
__________________
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
[Other] dynamicTopoFVMesh and pointDisplacement RandomUser OpenFOAM Meshing & Mesh Conversion 6 April 26, 2018 07:30
Mesh connectivity requirements maero21 SU2 4 July 25, 2016 11:34


All times are GMT -4. The time now is 08:16.