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

Overwrite subdictionary using a string at runtime

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 7, 2014, 07:05
Default Overwrite subdictionary using a string at runtime
  #1
Senior Member
 
Robert Sawko
Join Date: Mar 2009
Posts: 117
Rep Power: 22
AlmostSurelyRob will become famous soon enough
Hi,

I am looking for a way to insert a string into a subdictionary during runtime. This is not an elegant solution and it's part of a workaround to OpenFOAM 2.2.x port of Mesquite. I am discussing the reasons for this workaround with the creator of the port over here:

https://github.com/smenon/dynamicTopoFvMesh/issues/4

I would like to place patch information into a subdictionary. The main problem is that the patches are not an IO object and they are read from dynamicMeshDict. For separate reasons I would like to keep it like this for now. I will describe the situation in steps:

Code:
Info << fvpDict << endl;
results in
Code:
{
    GEOM                                                                                                               
    {
        type sixDoFRigidBodyDisplacement;
        centreOfMass    ( 0.5 0.83 0 );                          
        momentOfInertia ( 1 1 0.01 );                                   
        mass       0.01;                                                                                             
        rhoName     rhoInf;                                                                                           
        rhoInf          1000;                                                                                             
        report          on;
        accelerationRelaxation 0.5;
        value           uniform ( 0 0 0 );
    }                                                                                                                     
}
being printed in the log file. Now I update the patch field by

Code:
pField().updateCoeffs();
Info << pField() << endl;
pField is an autoPtr so I need (). This recalculates 6DoF so the print out says:
Code:
type            sixDoFRigidBodyDisplacement;
rhoName         rhoInf;
rhoInf          1000;
g               (0 0 0);
centreOfMass    (0.5 0.83 0);
orientation     (1 0 0 0 1 0 0 0 1);
velocity        (-0.0008491605002 -2.316277561e-20 -1.253434956e-22);
acceleration    (-16.98321 -4.632555122e-16 -2.506869911e-18);
angularMomentum (7.472962772e-24 -6.482573965e-25 -7.048032152e-06);
torque          (1.494592554e-19 -1.296514793e-20 -0.140960643);
initialCentreOfMass (0.5 0.83 0);
initialOrientation (1 0 0 0 1 0 0 0 1);
momentOfInertia (1 1 0.01);
mass            0.01;
accelerationRelaxation 0.5;
report          on;
initialPoints   nonuniform List<vector> 
168
(
(0 -0.9499999881 0.02828427125)
(0 -0.9499999881 -0.02828427125)
(-0.03436942399 -0.9363066554 -0.02828427125)
(-0.03436942399 -0.9363066554 0.02828427125)
(0.03436942026 -0.9363066554 0.02828427125)
(0.03436942026 -0.9363066554 -0.02828427125)
(0 0.9499999881 0.02828427125)
(-0.03436942399 0.9363066554 0.02828427125)
(-0.03436942399 0.9363066554 -0.02828427125)
(0 0.9499999881 -0.02828427125)
(0.03436942026 0.9363066554 -0.02828427125)
(0.03436942026 0.9363066554 0.02828427125)
(-0.05000000075 0.8550000191 0.02828427125)
(-0.05000000075 0.8550000191 -0.02828427125)
(-0.05000000075 0.8999999762 -0.02828427125)
(-0.05000000075 0.8999999762 0.02828427125)
(0.05000000075 0.8550000191 0.02828427125)
(0.05000000075 0.8999999762 0.02828427125)
(0.05000000075 0.8999999762 -0.02828427125)
(0.05000000075 0.8550000191 -0.02828427125)
(0.05000000075 -0.8550000191 0.02828427125)
(0.05000000075 -0.8550000191 -0.02828427125)
(0.05000000075 -0.8999999762 -0.02828427125)
(0.05000000075 -0.8999999762 0.02828427125)
(-0.05000000075 -0.8550000191 0.02828427125)
(-0.05000000075 -0.8999999762 0.02828427125)
(-0.05000000075 -0.8999999762 -0.02828427125)
(-0.05000000075 -0.8550000191 -0.02828427125)
(0.05000000075 -0.2849999964 0.02828427125)
(0.05000000075 -0.2849999964 -0.02828427125)
(0.05000000075 -0.3324999809 -0.02828427125)
(0.05000000075 -0.3324999809 0.02828427125)
(0.05000000075 -0.237499997 0.02828427125)
(0.05000000075 -0.237499997 -0.02828427125)
(-0.05000000075 -0.8075000048 -0.02828427125)
(-0.05000000075 -0.8075000048 0.02828427125)
(-0.05000000075 -0.7599999905 0.02828427125)
(-0.05000000075 -0.7599999905 -0.02828427125)
(0.05000000075 -0.5699999928 0.02828427125)
(0.05000000075 -0.5699999928 -0.02828427125)
(0.05000000075 -0.6174999475 -0.02828427125)
(0.05000000075 -0.6174999475 0.02828427125)
(0.05000000075 -0.6649999619 0.02828427125)
(0.05000000075 -0.6649999619 -0.02828427125)
(0.05000000075 -0.5224999785 0.02828427125)
(0.05000000075 -0.5224999785 -0.02828427125)
(0.05000000075 -0.474999994 0.02828427125)
(0.05000000075 -0.474999994 -0.02828427125)
(0.05000000075 -0.4275000095 0.02828427125)
(0.05000000075 -0.4275000095 -0.02828427125)
(0.05000000075 -0.7124999762 -0.02828427125)
(0.05000000075 -0.7124999762 0.02828427125)
(0.05000000075 -0.7599999905 0.02828427125)
(0.05000000075 -0.7599999905 -0.02828427125)
(0.05000000075 -0.8075000048 0.02828427125)
(0.05000000075 -0.8075000048 -0.02828427125)
(-0.05000000075 -0.5699999928 0.02828427125)
(-0.05000000075 -0.5699999928 -0.02828427125)
(-0.05000000075 -0.5224999785 -0.02828427125)
(-0.05000000075 -0.5224999785 0.02828427125)
(-0.05000000075 -0.474999994 0.02828427125)
(-0.05000000075 -0.474999994 -0.02828427125)
(-0.05000000075 -0.4275000095 -0.02828427125)
(-0.05000000075 -0.4275000095 0.02828427125)
(-0.05000000075 -0.6649999619 0.02828427125)
(-0.05000000075 -0.7124999762 0.02828427125)
(-0.05000000075 -0.7124999762 -0.02828427125)
(-0.05000000075 -0.6649999619 -0.02828427125)
(-0.05000000075 -0.6174999475 0.02828427125)
(-0.05000000075 -0.6174999475 -0.02828427125)
(0.05000000075 0.3799999952 0.02828427125)
(0.05000000075 0.3799999952 -0.02828427125)
(0.05000000075 0.3324999809 -0.02828427125)
(0.05000000075 0.3324999809 0.02828427125)
(0.05000000075 0.4275000095 0.02828427125)
(0.05000000075 0.4275000095 -0.02828427125)
(0.05000000075 0.474999994 0.02828427125)
(0.05000000075 0.474999994 -0.02828427125)
(-0.05000000075 0.474999994 0.02828427125)
(-0.05000000075 0.4275000095 0.02828427125)
(-0.05000000075 0.4275000095 -0.02828427125)
(-0.05000000075 0.474999994 -0.02828427125)
(-0.05000000075 0.5224999785 -0.02828427125)
(-0.05000000075 0.5224999785 0.02828427125)
(0.05000000075 0.6649999619 0.02828427125)
(0.05000000075 0.7124999762 0.02828427125)
(0.05000000075 0.7124999762 -0.02828427125)
(0.05000000075 0.6649999619 -0.02828427125)
(0.05000000075 0.8075000048 -0.02828427125)
(0.05000000075 0.8075000048 0.02828427125)
(0.05000000075 0.5224999785 0.02828427125)
(0.05000000075 0.5224999785 -0.02828427125)
(0.05000000075 0.6174999475 -0.02828427125)
(0.05000000075 0.6174999475 0.02828427125)
(0.05000000075 0.5699999928 0.02828427125)
(0.05000000075 0.5699999928 -0.02828427125)
(-0.05000000075 0.6649999619 0.02828427125)
(-0.05000000075 0.6174999475 0.02828427125)
(-0.05000000075 0.6174999475 -0.02828427125)
(-0.05000000075 0.6649999619 -0.02828427125)
(-0.05000000075 0.7124999762 -0.02828427125)
(-0.05000000075 0.7124999762 0.02828427125)
(-0.05000000075 0.8075000048 0.02828427125)
(-0.05000000075 0.8075000048 -0.02828427125)
(0.05000000075 0.2849999964 0.02828427125)
(0.05000000075 0.2849999964 -0.02828427125)
(-0.05000000075 0.2849999964 0.02828427125)
(-0.05000000075 0.237499997 0.02828427125)
(-0.05000000075 0.237499997 -0.02828427125)
(-0.05000000075 0.2849999964 -0.02828427125)
(-0.05000000075 0.3324999809 -0.02828427125)
(-0.05000000075 0.3324999809 0.02828427125)
(0.05000000075 0.09499999881 0.02828427125)
(0.05000000075 0.09499999881 -0.02828427125)
(0.05000000075 0.0474999994 -0.02828427125)
(0.05000000075 0.0474999994 0.02828427125)
(-0.05000000075 0.09499999881 0.02828427125)
(-0.05000000075 0.0474999994 0.02828427125)
(-0.05000000075 0.0474999994 -0.02828427125)
(-0.05000000075 0.09499999881 -0.02828427125)
(-0.05000000075 0.1424999982 -0.02828427125)
(-0.05000000075 0.1424999982 0.02828427125)
(0.05000000075 0.1424999982 0.02828427125)
(0.05000000075 0.1424999982 -0.02828427125)
(0.05000000075 0.1899999976 0.02828427125)
(0.05000000075 0.1899999976 -0.02828427125)
(0.05000000075 0.237499997 -0.02828427125)
(0.05000000075 0.237499997 0.02828427125)
(-0.05000000075 -0.2849999964 0.02828427125)
(-0.05000000075 -0.2849999964 -0.02828427125)
(-0.05000000075 -0.237499997 -0.02828427125)
(-0.05000000075 -0.237499997 0.02828427125)
(-0.05000000075 -0.3324999809 0.02828427125)
(-0.05000000075 -0.3324999809 -0.02828427125)
(0.05000000075 -0.09499999881 0.02828427125)
(0.05000000075 -0.09499999881 -0.02828427125)
(0.05000000075 -0.1424999982 -0.02828427125)
(0.05000000075 -0.1424999982 0.02828427125)
(-0.05000000075 -0.09499999881 0.02828427125)
(-0.05000000075 -0.1424999982 0.02828427125)
(-0.05000000075 -0.1424999982 -0.02828427125)
(-0.05000000075 -0.09499999881 -0.02828427125)
(-0.05000000075 -0.0474999994 -0.02828427125)
(-0.05000000075 -0.0474999994 0.02828427125)
(0.05000000075 -0.0474999994 0.02828427125)
(0.05000000075 -0.0474999994 -0.02828427125)
(0.05000000075 -0.1899999976 0.02828427125)
(0.05000000075 -0.1899999976 -0.02828427125)
(-0.05000000075 -0.1899999976 0.02828427125)
(-0.05000000075 -0.1899999976 -0.02828427125)
(-0.05000000075 0.1899999976 0.02828427125)
(-0.05000000075 0.1899999976 -0.02828427125)
(-0.05000000075 0.5699999928 0.02828427125)
(-0.05000000075 0.5699999928 -0.02828427125)
(0.05000000075 -0.3799999952 0.02828427125)
(0.05000000075 -0.3799999952 -0.02828427125)
(-0.05000000075 -0.3799999952 0.02828427125)
(-0.05000000075 -0.3799999952 -0.02828427125)
(-0.05000000075 0.3799999952 0.02828427125)
(-0.05000000075 0.3799999952 -0.02828427125)
(0.05000000075 0.7599999905 0.02828427125)
(0.05000000075 0.7599999905 -0.02828427125)
(-0.05000000075 0.7599999905 0.02828427125)
(-0.05000000075 0.7599999905 -0.02828427125)
(-0.05000000075 0 0.02828427125)
(-0.05000000075 0 -0.02828427125)
(0.05000000075 0 0.02828427125)
(0.05000000075 0 -0.02828427125)
)
;
value           nonuniform List<vector> 
168
(
(0 0 0)
(0 0 0)
(2.081668171e-17 0 0)
(2.081668171e-17 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(0 0 0)
(2.081668171e-17 0 0)
(2.081668171e-17 0 0)
(0 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 1.110223025e-16 0)
(-6.938893904e-18 1.110223025e-16 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(6.938893904e-18 1.110223025e-16 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 1.110223025e-16 0)
(-6.938893904e-18 5.551115123e-17 0)
(-6.938893904e-18 5.551115123e-17 0)
(-6.938893904e-18 1.110223025e-16 0)
(-6.938893904e-18 1.110223025e-16 0)
(-6.938893904e-18 8.326672685e-17 0)
(-6.938893904e-18 8.326672685e-17 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 1.110223025e-16 0)
(-6.938893904e-18 1.110223025e-16 0)
(-6.938893904e-18 -1.110223025e-16 0)
(-6.938893904e-18 -1.110223025e-16 0)
(-6.938893904e-18 -1.110223025e-16 0)
(-6.938893904e-18 -1.110223025e-16 0)
(-6.938893904e-18 5.551115123e-17 0)
(-6.938893904e-18 5.551115123e-17 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 -1.110223025e-16 0)
(6.938893904e-18 -1.110223025e-16 0)
(6.938893904e-18 5.551115123e-17 0)
(6.938893904e-18 5.551115123e-17 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 -1.110223025e-16 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 -1.110223025e-16 0)
(6.938893904e-18 1.110223025e-16 0)
(6.938893904e-18 1.110223025e-16 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(-6.938893904e-18 -5.551115123e-17 0)
(-6.938893904e-18 -5.551115123e-17 0)
(6.938893904e-18 -5.551115123e-17 0)
(6.938893904e-18 2.775557562e-17 0)
(6.938893904e-18 2.775557562e-17 0)
(6.938893904e-18 -5.551115123e-17 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(-6.938893904e-18 -1.387778781e-17 0)
(-6.938893904e-18 -1.387778781e-17 0)
(-6.938893904e-18 4.857225733e-17 0)
(-6.938893904e-18 4.857225733e-17 0)
(6.938893904e-18 -1.387778781e-17 0)
(6.938893904e-18 4.857225733e-17 0)
(6.938893904e-18 4.857225733e-17 0)
(6.938893904e-18 -1.387778781e-17 0)
(6.938893904e-18 2.775557562e-17 0)
(6.938893904e-18 2.775557562e-17 0)
(-6.938893904e-18 2.775557562e-17 0)
(-6.938893904e-18 2.775557562e-17 0)
(-6.938893904e-18 -2.775557562e-17 0)
(-6.938893904e-18 -2.775557562e-17 0)
(-6.938893904e-18 2.775557562e-17 0)
(-6.938893904e-18 2.775557562e-17 0)
(6.938893904e-18 5.551115123e-17 0)
(6.938893904e-18 5.551115123e-17 0)
(6.938893904e-18 8.326672685e-17 0)
(6.938893904e-18 8.326672685e-17 0)
(6.938893904e-18 1.110223025e-16 0)
(6.938893904e-18 1.110223025e-16 0)
(-6.938893904e-18 1.387778781e-17 0)
(-6.938893904e-18 1.387778781e-17 0)
(-6.938893904e-18 -2.775557562e-17 0)
(-6.938893904e-18 -2.775557562e-17 0)
(6.938893904e-18 1.387778781e-17 0)
(6.938893904e-18 -2.775557562e-17 0)
(6.938893904e-18 -2.775557562e-17 0)
(6.938893904e-18 1.387778781e-17 0)
(6.938893904e-18 -4.857225733e-17 0)
(6.938893904e-18 -4.857225733e-17 0)
(-6.938893904e-18 -4.857225733e-17 0)
(-6.938893904e-18 -4.857225733e-17 0)
(-6.938893904e-18 -8.326672685e-17 0)
(-6.938893904e-18 -8.326672685e-17 0)
(6.938893904e-18 -8.326672685e-17 0)
(6.938893904e-18 -8.326672685e-17 0)
(6.938893904e-18 -2.775557562e-17 0)
(6.938893904e-18 -2.775557562e-17 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(-6.938893904e-18 -5.551115123e-17 0)
(-6.938893904e-18 -5.551115123e-17 0)
(6.938893904e-18 -5.551115123e-17 0)
(6.938893904e-18 -5.551115123e-17 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
(-6.938893904e-18 0 0)
)
;
Is there any way to substitute the former with the latter in fvpDict? I've tried a number of things involving set, add and clear and only clear worked for me. Basically I would like to clear GEOM entry during runtime and put a new one which corresponds to updated pField.

Please let me know if that's possible with current implementation of dictionary object.
AlmostSurelyRob 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
runTime deji OpenFOAM 2 January 17, 2019 10:14
Problem in3D model processing mebinitap OpenFOAM 2 December 12, 2014 05:40
Creating a new field from terms of the turbulence model HaZe OpenFOAM Programming & Development 15 November 24, 2014 14:51
runTime out of scope in functionObject Sune OpenFOAM Programming & Development 2 September 26, 2012 03:11
CFX4.3 -build analysis form Chie Min CFX 5 July 13, 2001 00:19


All times are GMT -4. The time now is 07:40.