[overture] Re: user defined forcing problem

  • From: Shi Qiu <shiq@xxxxxxx>
  • To: overture@xxxxxxxxxxxxx
  • Date: Sun, 1 Sep 2013 21:17:10 -0700

Hi Bill,

Thanks a lot. Now the forcing function works fine now.

But I am still confused about how to set parameters like pressure or
temperature in user defined forcing function. Can I make the parameter
which I want times 2.5 to make the final output result right. (say I want
ug(i1,i2,i3,tc)=10, so I set this in the used defined forcing as
ug(i1,i2,i3,tc)=25) .

Best,

Stone


On Sun, Sep 1, 2013 at 2:46 PM, Bill Henshaw <henshaw@xxxxxxxx> wrote:

>  Hi Stone,
>
>   I had to make a few fixes to get the forcing working again.
> Once you make the fixes below you should double check the results since
> we haven't used forcing with cgcns very much before.
>
> Regards,
>   Bill
>
>
> ***Fix 1: File cg/cns/src/cns.C : move a block of code around line 3518
>
>  
> --------------------------------------------------------------------------------------------
>
>   if( debug() & 8 )
>   {
>     fprintf(pDebugFile," ====== addForcingCNS t=%9.3e TZ=%i
> pdeVariation=%i ===== \n",t0,
>         (int)parameters.dbase.get<bool
> >("twilightZoneFlow"),(int)pdeVariation);
>   }
>
>
>   Index I1,I2,I3;
>   realArray & ut = dvdt;
>   OV_GET_SERIAL_ARRAY(real,ut,utLocal);
>
>   // --- Add on any user defined forcing ---
>
>
>   if( parameters.dbase.get<bool >("turnOnBodyForcing") )
>   {
>
>     // The body forcing will have already been computed.
>     if( false )
>       printF("Cgcns::addForcing:turnOnBodyForcing=%i\n",(int)
> parameters.dbase.get<bool >("turnOnBodyForcing"));
>
>
>     assert( parameters.dbase.get<realCompositeGridFunction*
> >("bodyForce")!=NULL );
>     realCompositeGridFunction & bodyForce =
> *(parameters.dbase.get<realCompositeGridFunction* >("bodyForce"));
>
>     //     // Compute the user defined forcing:
>     //     userDefinedForcing( userDefinedForce[grid], u, iparam, rparam );
>
>     // Add the user defined force onto dvdt:
>     OV_GET_SERIAL_ARRAY(real,bodyForce[grid],bodyForceLocal);
>
>     // printF("addForcing: add body force:
> (min,max)=(%g,%g)\n",min(bodyForceLocal),max(bodyForceLocal));
>
>     getIndex(mg.gridIndexRange(),I1,I2,I3);
>     bool ok = ParallelUtility::getLocalArrayBounds(ut,utLocal,I1,I2,I3);
>
>     const Range & Rt = parameters.dbase.get<Range >("Rt");       // time
> dependent components
>
>     if( false )
>       printF("cns:getForcing: grid=%i, utLocal=[%i,%i][%i,%i],
> bodyForceLocal=[%i,%i][%i,%i]\n",grid,
>          utLocal.getBase(0),utLocal.getBound(0),
>          utLocal.getBase(1),utLocal.getBound(1),
>          bodyForceLocal.getBase(0),bodyForceLocal.getBound(0),
>          bodyForceLocal.getBase(1),bodyForceLocal.getBound(1));
>
>     utLocal(I1,I2,I3,Rt) += bodyForceLocal(I1,I2,I3,Rt);
>
>   }
>
>   // *wdh* 2013/08/31 -- put this after assigning the bodyForce
>   // THIS NEXT BLOCK WAS MOVED FROM ABOVE
>   if( !parameters.dbase.get<bool >("twilightZoneFlow") ||
>       conservativeGodunovMethod==CnsParameters::multiComponentVersion ||
>       (pde==CnsParameters::compressibleNavierStokes &&
>        pdeVariation==CnsParameters::conservativeGodunov) )
>   {
>
> parameters.dbase.get<RealArray>("timing")(parameters.dbase.get<int>("timeForForcing"))+=getCPU()-cpu0;
>     return;
>   }
>
>
>   const int & rc = parameters.dbase.get<int >("rc");
>   const int & uc = parameters.dbase.get<int >("uc");
>   const int & vc = parameters.dbase.get<int >("vc");
>   const int & wc = parameters.dbase.get<int >("wc");
>
>
>
> -------------------------------------------------------------------------------------------------
>
>
> *** Fix 2:  cg/common/src/addGrids.bC : add some lines around line 969
>
> ------------------------------------------------------------------------------------------------
>
>   // updateToMatchNewGrid(cgNew,changes,gf0);
>   updateWorkSpace(gf0);
>
>   gf0.u.getOperators()->updateToMatchGrid(gf0.cg);
>
>   gf0.u.setOperators(*gf0.u.getOperators()); // need to assign all
> components
>
>   //  update the body forcing *wdh* 2013/08/31
>   // START CHANGE
>
>   if( parameters.dbase.get<bool >("turnOnBodyForcing") )
>   {
>     realCompositeGridFunction *&bodyForce =
> parameters.dbase.get<realCompositeGridFunction* >("bodyForce");
>     (*bodyForce).updateToMatchGrid(gf0.cg);
>   }
>   // END CHANGE
>
>   // *wdh* 070706 -- put this here instead of the routines that call this
> function
>   real time2=getCPU();
>   gf0.cg.rcData->interpolant->updateToMatchGrid( gf0.cg );
>   time2=getCPU()-time2;
>   time0+=time2; // do not include the time for updating the interpolant
>
> parameters.dbase.get<RealArray>("timing")(parameters.dbase.get<int>("timeForUpdateInterpolant"))+=time2;
>
>
> ----------------------------------------------------------------------------------------------------------
>
> *** Fix 3: cg/common/src/userDefinedForcing.C : make a change around line
> 77
>
> ----------------------------------------------------------------------------------------------------------
>
>   CompositeGrid & cg = gf.cg;
>   realCompositeGridFunction & u = gf.u;
>
>   const real t0 = gf.t;     // ** here is the current time ***
>
>   // There is no forcing to compute if none was specified or if the
> forcing is not time dependent and t>0
>   // For moving or AMR we always evaluate the forcing (for time independet
> forcing and AMR, we really
>   //    only to to re-eval when the grids change.) *wdh* 2013/08/31
>   // START CHANGE
>   if( option==noForcing || ( !userDefinedForcingIsTimeDependent && t0>0.
>                  && !parameters.isAdaptiveGridProblem()
>                              && !parameters.isMovingGridProblem()) )
>     return 0;
>
>   // END CHANGE
>
>   const int & numberOfComponents=parameters.dbase.get<int
> >("numberOfComponents");
>   const int & numberOfDimensions=parameters.dbase.get<int
> >("numberOfDimensions");
>
>
> --------------------------------------------------------------------------------------------------------
>
>
>
>
>
> On 08/31/2013 09:58 AM, Shi Qiu wrote:
>
>  Hi Bill,
>
>  Sorry to bother you again,
>
>  After I applied the fix file, overture can run now, but it seems that the
> user defined forcing is ignored by overture. There is no forcing included
> in the calculation.(I have tried constant forcing and guassion forcing in a
> uniform flow, there is no change during each time step.)
>
>  Thanks a lot.
>
>  Best,
>
>  Stone
>
>
>
> On Fri, Aug 30, 2013 at 8:01 PM, Bill Henshaw <henshaw@xxxxxxxx> wrote:
>
>>  Hi Stone,
>>   Thanks for the files showing the bug.
>> The  fix to your problem is hopefully given below (it worked for me with
>> my
>> current version but it is possible I have changed something else too).
>>
>> The body forcing is applied to the equations in conservation form
>> so that even though the variable appears a "tc" the forcing is really
>> added to the total energy equation.
>>
>> Regards,
>>   Bill
>>
>>
>> //
>> -------------------------------------------------------------------------------
>> // ------   fix to cg/common/src/update.C around line 71 ---
>>
>>     for( i=0; i<numberOfExtraFunctionsToUse; i++ )
>>     {
>>       fn[i].updateToMatchGrid(cg);
>>       fn[i]=0.;  // *wdh* 040316 - to avoid UMR's
>>     }
>>
>>     //  START FIX  ***** update the body forcing *******
>>     if( parameters.dbase.get<bool >("turnOnBodyForcing") )
>>     {
>>       realCompositeGridFunction *&bodyForce =
>> parameters.dbase.get<realCompositeGridFunction* >("bodyForce");
>>       (*bodyForce).updateToMatchGrid(cg);
>>     }
>>     // **END FIX**
>>
>>
>>   }
>>
>> On 08/30/2013 01:24 PM, Shi Qiu wrote:
>>
>>    Hi Bill,
>>
>>  Attached is the cmd file I used for testing forcing function. I also
>> attach a grid file for this cmd.
>>
>>  Also I have another problem. In the version v24 user defined forcing
>> file, whenever I want to set a certain temperature or a certain pressure in
>> the file (for example, I set ug(I1,I2,I3,tc)=10 ) , but the actual result
>> is always the number I set divided by 2.5 (10/2.5=4).
>>
>>  Thanks a lot.
>>
>>  Best.
>>
>>  Stone
>>
>>
>>
>>
>>
>>
>> On Fri, Aug 30, 2013 at 12:39 PM, Bill Henshaw <henshaw@xxxxxxxx> wrote:
>>
>>>  Hi Stone,
>>>
>>>   Can you send the commands you running (you will need to rename .cmd
>>> files to e.g. .cmdx in the eamil). There were numerous changes to the
>>> forcings in v25.
>>> Sorry for the problems.
>>>
>>> ...Bill
>>>
>>>
>>> On 08/30/2013 11:19 AM, Shi Qiu wrote:
>>>
>>>  Hi All,
>>>
>>>  I am trying to user defined forcing (which is gaussianForcing). It
>>> works fine in the version cg.v24 and overture.v24. But when I use *exactly
>>> the same* cmd file to run it in version v25. It always gives me the
>>> same error as listed. And I also tried constant forcing and I got the same
>>> error in version v25. If anyone can give me an example cmd file which uses
>>> user defined forcing in version v25 will be very helpful to me.
>>>
>>> Here is the error,
>>>
>>> adaptGrids (end) step=0: number of array ID's has increased to 2028
>>>
>>> ListOfDoubleMappedGridFunction: List Index Out of Range!
>>>
>>> trying to reference a list with index=10
>>>
>>>  but the list only has indicies in the range: [0,9]
>>>
>>>  length of List = 10
>>>
>>> ListOfDoubleMappedGridFunction: List Index Out of Range!
>>>
>>>  Thanks a lot.
>>>
>>>  Best,
>>>
>>>  Stone
>>>
>>>
>>>
>>>
>>>
>>
>>
>
>

Other related posts: