You could separate your geometry definition and CFD analysis from the objective and constraint functions. Put them in a separate function, which takes a design vector x as an argument. Your objective and constraint functions can then call this function when necessary
Each time NLopt calls one of your objective or constraint functions with a design vector x as an argument, check whether x has changed since the last time you ran a CFD analysis (you'll need to store the past value of x somewhere). If x hasn't changed, then you only need to post-process the existing CFD results, which you have stored either in memory or on disk. If x has changed since the last time, then you need to rebuild the geometry and rerun the analysis Even better (depending on problem size, CFD analysis time, etc.), you could record the values of all your functions for all encountered values of x, preventing any duplicate geometry definitions and CFD runs. On Thu, May 10, 2012 at 10:14 AM, Ricardo Puente <[email protected]>wrote: > Hi, > > I am trying to use the NLOPT library with a shape optimization problem. > Browsing through this mailing list I see that other people have done > something > similar, but I have some problems with the objective and constraint > functions. > > What I do is build a geometry through some parametrized CAD code, analyze > it > with a cfd code, and the objectives and constraints are computed by > postprocessing the cfd solution and retrieving some geometrical data > nonlinearly > related with the design variables. > > I see that the NLOPT interface requires separate functions for the > objective and > constraints. My problem is that to comply with those requirements would > make me > build geometry and analyze for each different objective and constraint, > which is > very time consuming. > > Is there an obvious workaround, or would I need to code interfaces for > common > calculations within nlopt_optimize_()? > > Thanks, > > > _______________________________________________ > NLopt-discuss mailing list > [email protected] > http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss >
_______________________________________________ NLopt-discuss mailing list [email protected] http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss
