This isn't really a good solution. Could you explain what you want to do differently with the function and when, then we may have a better solution.
Barry On Jan 14, 2010, at 10:50 AM, (Rebecca) Xuefei YUAN wrote: > Dear Barry, > > Yes, I would like the FormFunction to do different things depending > on if it is called by SNESComputeFunction. > > I found a solution to it, but I am not sure whether it is good/easy > enough to track. > > I put up a integer "callNumber" into my user-defined contents, and > set it to be 0 at the beginning of each time iteration. > > When FormFunction is called, it is first called by > SNESComputeFunction, followed by other PETSc functions, so my if > condition is > if (callNumber==0){ > do A > }else{ > do B > } > > Before PetscFunctionReturn(0), > > callNumber + = 1; > > So far it is good, and it did what I would like to. > > Is there a better way of doing it? > > Thanks a lot! > > Rebecca > > Quoting Barry Smith <bsmith at mcs.anl.gov>: > >> >> There really isn't a mechanism to know by whom a function is called. >> >> Do you want this so you know when the function is being called >> directly vs when it is being called in computing a Jacobian >> derivative >> with finite differencing? Do you want the function to do something >> different in the two cases? >> >> Barry >> >> On Jan 14, 2010, at 9:14 AM, (Rebecca) Xuefei YUAN wrote: >> >>> Dear all, >>> >>> I would like to setup a flag for the FormFunction like: >>> >>> if (FormFunction is called by SNESComputeFunction){ >>> flag = 1; >>> }else{ >>> flag = 0; >>> } >>> >>> Is there any way I can know which function called FormFunction? I >>> can tell very clear in debug mode, but I need this information in >>> the code. >>> >>> Thanks very much! >>> >>> Rebecca >>> > > > > -- > (Rebecca) Xuefei YUAN > Department of Applied Physics and Applied Mathematics > Columbia University > Tel:917-399-8032 > www.columbia.edu/~xy2102 >