OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::opti Namespace Reference

All optimization code is contained in this namespace. More...

Namespaces

namespace  projection
 

Classes

class  AdjointLbSolver
 Base class for solvers that solve both primal and dual problems. More...
 
class  BlockDdifferenceObjectiveDf3D
 functor to compute 0.5*(f-f_wanted)^2 on a lattice More...
 
class  BlockDrelativeDifferenceObjectiveComponentDf3D
 functor to compute 0.5*(f[extractDim]-f_wanted[0])^2/f_wanted^2 on a lattice More...
 
class  BlockDrelativeDifferenceObjectiveDf3D
 functor to compute 0.5(f-f_wanted)^2/f_wanted^2 on a lattice More...
 
class  BlockLatticeDphysDissipationDf
 functor to get the pointwise dual dissipation density on local lattices, if globIC is not on the local processor, the returned vector is empty More...
 
class  BlockLatticeDphysVelocityDf3D
 functor to get pointwise dual velocity density on local lattices, if globIC is not on the local processor, the returned vector is empty More...
 
class  BlockLatticeSerialDataF
 
class  Controller
 
struct  DCDALPHA
 Collision operator derivative regarding optimization controls. More...
 
class  DdifferenceObjectiveDf3D
 functor to compute 0.5*(f-f_wanted)^2 on a lattice More...
 
class  DifferenceObjective3D
 functor to compute 0.5*L2Norm(f-f_wanted)^2 on a lattice More...
 
class  DistributedObjective
 Objective in optimization with adjoint LBM. More...
 
struct  DJDALPHA
 Objective functional derivative regarding optimization controls. More...
 
struct  DJDF
 Derivative of Objective functional regarding populations. More...
 
struct  DPROJECTIONDALPHA
 Derivative of control projection regarding control variable. More...
 
class  DrelativeDifferenceObjectiveComponentDf3D
 functor to compute 0.5*(f[extractDim]-f_wanted[0])^2/f_wanted^2 on a lattice More...
 
class  DrelativeDifferenceObjectiveDf3D
 functor to compute 0.5(f-f_wanted)^2/f_wanted^2 on a lattice More...
 
class  DualController
 
class  DualForcedMRTdynamics
 Implementation of the dual MRT collision step with external force. More...
 
struct  dualLbHelpers
 This structure forwards the calls to the appropriate helper class. More...
 
struct  dualLbMomentaHelpers
 
struct  F
 Stores populations of the primal problems for adjoint simulations. More...
 
class  GenericObjective
 Objective in optimization with adjoint LBM. More...
 
class  GeometrySerializer
 This class serializes the cells inside the geometry. More...
 
struct  J
 Objective functional results, always scalar. More...
 
class  OptiCase
 Abstract base class for optimization tasks. More...
 
class  OptiCaseAD
 Derivatives are computed with automatic differentiation. More...
 
class  OptiCaseAdForSolver
 Interface for OptiCaseAD that performs Lattice-Boltzmann-Solver construction itself (from xml file) More...
 
class  OptiCaseAnalytical
 Gradient is just passed as a function (and not computed by an own routine) More...
 
class  OptiCaseCDQ
 Gradient computation with central difference quotients. More...
 
class  OptiCaseDQ
 
class  OptiCaseDual
 This class implements the evaluation of the goal functional and its derivatives by using adjoint LBM. More...
 
class  OptiCaseFDQ
 Gradient computation with forward difference quotients. More...
 
class  Optimizer
 Interface for the use of various optimization algorithms. More...
 
class  OptimizerBarzilaiBorwein
 Optimization algorithm: BarzilaiBorwein. More...
 
class  OptimizerLBFGS
 Optimization algorithm: LBFGS. More...
 
class  OptimizerLineSearch
 Optimization algorithm: LineSearch. More...
 
class  OptimizerSteepestDescent
 Optimization algorithm: SteepestDescent. More...
 
class  RelativeDifferenceObjective3D
 functor to compute 0.5*L2Norm(f-f_wanted)^2/L2Norm(f_wanted)^2 on a lattice More...
 
struct  SENSITIVITY
 Total derivative of the objective functional regarding controls. More...
 
class  SimpleGeometrySerializer
 This class serializes the cells inside the geometry. More...
 
class  SparseGeometrySerializer
 This class serializes the cells which are marked by indicator. More...
 
class  SuperLatticeDphysDissipationDf
 functor to get pointwise dual dissipation density on local lattices, if globIC is not on the local processor, the returned vector is empty More...
 
class  SuperLatticeDphysVelocityDf3D
 functor to get pointwise dual velocity density on local lattices, if globIC is not on the local processor, the returned vector is empty More...
 
class  SuperLatticeSerialDataF
 A data field whose values are managed by a controller. More...
 

Enumerations

enum  OptimizerLogType {
  control , derivative , value , error ,
  norm_derivative
}
 
enum  StartValueType { Control , ProjectedControl , Porosity , Permeability }
 
enum class  SolverMode : int { Reference , Primal , Dual }
 Tags different simulation modes: compute either reference simulation or perform primal or dual (adjoint) simulation. More...
 

Functions

template<typename S , typename C >
 OptiCaseAnalytical (std::function< S(const C &)>, std::function< void(const C &, C &)>) -> OptiCaseAnalytical< S, C >
 
template<typename S , typename C >
 OptiCaseAnalytical (std::function< S(const C &)>, std::function< void(const C &, C &)>, std::function< void(void)>) -> OptiCaseAnalytical< S, C >
 
template<typename S , typename C >
 OptiCaseFDQ (std::function< S(const C &)>, std::function< void(void)>) -> OptiCaseFDQ< S, C >
 
template<typename S , typename C >
 OptiCaseFDQ (std::function< S(const C &)>, S, std::function< void(void)>) -> OptiCaseFDQ< S, C >
 
template<typename S , typename C >
 OptiCaseFDQ (std::function< S(const C &, unsigned)>, std::function< void(void)>) -> OptiCaseFDQ< S, C >
 
template<typename S , typename C >
 OptiCaseFDQ (std::function< S(const C &, unsigned)>, S, std::function< void(void)>) -> OptiCaseFDQ< S, C >
 
template<typename S , typename C >
 OptiCaseFDQ (std::function< S(const C &)>) -> OptiCaseFDQ< S, C >
 
template<typename S , typename C >
 OptiCaseFDQ (std::function< S(const C &)>, S) -> OptiCaseFDQ< S, C >
 
template<typename S , typename C >
 OptiCaseFDQ (std::function< S(const C &, unsigned)>) -> OptiCaseFDQ< S, C >
 
template<typename S , typename C >
 OptiCaseFDQ (std::function< S(const C &, unsigned)>, S) -> OptiCaseFDQ< S, C >
 
template<typename S , typename C >
 OptiCaseCDQ (std::function< S(const C &)>, std::function< void(void)>) -> OptiCaseCDQ< S, C >
 
template<typename S , typename C >
 OptiCaseCDQ (std::function< S(const C &)>, S, std::function< void(void)>) -> OptiCaseCDQ< S, C >
 
template<typename S , typename C >
 OptiCaseCDQ (std::function< S(const C &, unsigned)>, std::function< void(void)>) -> OptiCaseCDQ< S, C >
 
template<typename S , typename C >
 OptiCaseCDQ (std::function< S(const C &, unsigned)>, S, std::function< void(void)>) -> OptiCaseCDQ< S, C >
 
template<typename S , typename C >
 OptiCaseCDQ (std::function< S(const C &)>) -> OptiCaseCDQ< S, C >
 
template<typename S , typename C >
 OptiCaseCDQ (std::function< S(const C &)>, S) -> OptiCaseCDQ< S, C >
 
template<typename S , typename C >
 OptiCaseCDQ (std::function< S(const C &, unsigned)>) -> OptiCaseCDQ< S, C >
 
template<typename S , typename C >
 OptiCaseCDQ (std::function< S(const C &, unsigned)>, S) -> OptiCaseCDQ< S, C >
 
template<typename S , typename T , template< typename > typename SOLVER>
 OptiCaseAdForSolver (std::shared_ptr< SOLVER< S > >, std::shared_ptr< SOLVER< T > >) -> OptiCaseAdForSolver< S, T::dim, SOLVER, util::StdVector >
 
void getGnuplotTagsFromString (std::string gplotAnalysisString, std::vector< OptimizerLogType > &gplotAnalysis)
 the gplotAnalysisString is gained from the xml file and the function than separates and prepares it to be used in the constructor
 
template<typename S , typename C = std::vector<S>>
OptimizerBarzilaiBorwein< S, C > * createOptimizerBarzilaiBorwein (XMLreader const &params, std::size_t dimCtrl)
 Creator Function for Barzilai-Borwein.
 
template<typename S , typename C = std::vector<S>>
OptimizerLBFGS< S, C > * createOptimizerLBFGS (XMLreader const &params, std::size_t dimCtrl)
 Creator Function for LBFGS.
 
template<typename S , typename C = std::vector<S>>
OptimizerSteepestDescent< S, C > * createOptimizerSteepestDescent (XMLreader const &params, std::size_t dimCtrl)
 Creator Function for Steepest Decent.
 
template<typename PROJECTION , typename T >
std::vector< T > applyProjection (const std::vector< T > &vector)
 
template<typename PROJECTION , typename T , typename ARG >
std::vector< T > applyProjection (const std::vector< T > &vector, ARG arg)
 
template<typename S , unsigned dim>
int getMaterialGlobally (SuperGeometry< S, dim > &sGeometry, LatticeR< dim+1 > latticeR)
 Helper that gives global access to material numbers.
 
template<unsigned D, typename T >
bool evaluateSuperIndicatorFglobally (SuperIndicatorF< T, D > &f, const int input[])
 Helper that gives global access to the values of an indicator.
 
template<unsigned D, typename T , typename U = T>
bool evaluateSuperFglobally (SuperF< D, T, U > &f, U *output, const int input[])
 Helper that gives global access to the values of a functor.
 
template<typename FIELD , typename T , typename DESCRIPTOR , typename C = std::vector<T>>
serialDataFromField (SuperLattice< T, DESCRIPTOR > &sLattice, const GeometrySerializer< T, DESCRIPTOR::d > &serializer, SuperIndicatorF< T, DESCRIPTOR::d > &indicator, unsigned controlDim)
 Take values of a field and put them into a long vector Idea: FIELD[cartesianCoordinates] = result[serialIndex] -> we want to get the vector ''result''.
 
template<typename T , template< typename, SolverMode > typename SOLVER, concepts::Field CONTROLLED_FIELD, template< typename... > typename PRIMAL_DYNAMICS, typename C = std::vector<T>>
serialDataFromField (OptiCaseDual< T, SOLVER, CONTROLLED_FIELD, PRIMAL_DYNAMICS, C > &optiCase, std::shared_ptr< SOLVER< T, SolverMode::Reference > > solver)
 Take values of FIELD and put them into a long vector Idea: FIELD[cartesianCoordinates] = result[serialIndex] -> we want to get the vector ''result''.
 
template<typename T , template< typename, SolverMode > typename SOLVER, concepts::Field CONTROLLED_FIELD, template< typename... > typename PRIMAL_DYNAMICS, typename C = std::vector<T>>
getControl (OptiCaseDual< T, SOLVER, CONTROLLED_FIELD, PRIMAL_DYNAMICS, C > &optiCase, std::shared_ptr< SOLVER< T, SolverMode::Reference > > solver)
 Get control values of some simulation in the context of adjoint optimization Take values of FIELD, apply inverse projection and put them into a long vector Idea: FIELD[cartesianCoordinates] = projection(result[serialIndex]) -> we want to get the vector ''result''.
 

Detailed Description

All optimization code is contained in this namespace.

Enumeration Type Documentation

◆ OptimizerLogType

Enumerator
control 
derivative 
value 
error 
norm_derivative 

Definition at line 46 of file optimizer.h.

◆ SolverMode

enum class olb::opti::SolverMode : int
strong

Tags different simulation modes: compute either reference simulation or perform primal or dual (adjoint) simulation.

Enumerator
Reference 
Primal 
Dual 

Definition at line 39 of file adjointLbSolver.h.

◆ StartValueType

Enumerator
Control 
ProjectedControl 
Porosity 
Permeability 

Definition at line 42 of file projection.h.

Function Documentation

◆ applyProjection() [1/2]

template<typename PROJECTION , typename T >
std::vector< T > olb::opti::applyProjection ( const std::vector< T > & vector)

Definition at line 394 of file projection.h.

394 {
395 std::vector<T> projected;
396 for (auto& e : vector) {
397 projected.push_back(PROJECTION().project(e));
398 }
399 return projected;
400}

◆ applyProjection() [2/2]

template<typename PROJECTION , typename T , typename ARG >
std::vector< T > olb::opti::applyProjection ( const std::vector< T > & vector,
ARG arg )

Definition at line 403 of file projection.h.

403 {
404 std::vector<T> projected;
405 for (auto& e : vector) {
406 projected.push_back(PROJECTION(arg).project(e));
407 }
408 return projected;
409}

◆ createOptimizerBarzilaiBorwein()

template<typename S , typename C = std::vector<S>>
OptimizerBarzilaiBorwein< S, C > * olb::opti::createOptimizerBarzilaiBorwein ( XMLreader const & params,
std::size_t dimCtrl )

Creator Function for Barzilai-Borwein.

Definition at line 181 of file optimizerBarzilaiBorwein.h.

182{
183 OstreamManager clout(std::cout,"createOptimizerBarzilaiBorwein");
184
185 // create variables with default values
186 int maxIt = 100;
187
188 S controlEps = S(0);
189 S eps = S(1.e-10);
190
191 S lambda = 1.; //starting lambda for steepest descent step (it==0)
192 int maxStepAttempts = 100;
193 std::string stepCondition = "None";
194
195 bool verboseOn=true;
196 std::string fname = "control.dat";
197 std::string logFileName = "log.txt";
198
199 bool vectorBounds = false;
200 bool withUpperBound = false;
201 S upperBound = S();
202 bool withLowerBound = false;
203 S lowerBound = S();
204
205 std::vector<OptimizerLogType> gplotAnalysis = {};
206 std::string gplotAnalysisString = "";
207
208 // Read Values from XML File
209 params.readOrWarn<int>("Optimization", "MaxIter", "", maxIt);
210
211 params.readOrWarn<S>("Optimization", "Tolerance", "", eps);
212 params.readOrWarn<S>("Optimization", "ControlTolerance", "", controlEps);
213 params.readOrWarn<S>("Optimization", "Lambda", "", lambda);
214 params.readOrWarn<int>("Optimization", "MaxStepAttempts", "", maxStepAttempts);
215 params.readOrWarn<std::string>("Optimization", "StepCondition", "", stepCondition);
216
217 params.readOrWarn<bool>("Optimization", "Verbose", "", verboseOn);
218 params.readOrWarn<std::string>("Optimization", "InputFileName", "", fname);
219 params.readOrWarn<std::string>("Optimization", "LogFileName", "", logFileName);
220
221 params.readOrWarn<bool>("Optimization", "VectorBounds", "", vectorBounds);
222 if ( params.readOrWarn<S>("Optimization", "UpperBound", "", upperBound, false, false) ) {
223 withUpperBound = true;
224 }
225 if ( params.readOrWarn<S>("Optimization", "LowerBound", "", lowerBound, false, false) ) {
226 withLowerBound = true;
227 }
228
229 // get the parameters for the gnuplot Analysis from the xml file from the VisualizationGnuplot area
230 params.readOrWarn<std::string>("Optimization", "VisualizationGnuplot", "VisualizedParameters", "", gplotAnalysisString, false, false);
231 // transform the data from the xml file to the enums needed for continueing
232 getGnuplotTagsFromString(gplotAnalysisString, gplotAnalysis);
233
234 // Create Optimizer Object
235 return new OptimizerBarzilaiBorwein<S,C>(dimCtrl, eps, maxIt, lambda, maxStepAttempts, stepCondition,
236 verboseOn, fname, logFileName, withUpperBound, upperBound, withLowerBound, lowerBound,
237 vectorBounds, controlEps, gplotAnalysis);
238}
class for marking output with some text
void getGnuplotTagsFromString(std::string gplotAnalysisString, std::vector< OptimizerLogType > &gplotAnalysis)
the gplotAnalysisString is gained from the xml file and the function than separates and prepares it t...
Definition optimizer.hh:244

References getGnuplotTagsFromString(), and olb::XMLreader::readOrWarn().

+ Here is the call graph for this function:

◆ createOptimizerLBFGS()

template<typename S , typename C = std::vector<S>>
OptimizerLBFGS< S, C > * olb::opti::createOptimizerLBFGS ( XMLreader const & params,
std::size_t dimCtrl )

Creator Function for LBFGS.

Definition at line 263 of file optimizerLBFGS.h.

264{
265 OstreamManager clout(std::cout, "createOptimizerLBFGS");
266
267 // create variables with default values
268 int maxIt = 100;
269 int l = 20;
270 S lambda = 1.; //starting lambda for steepest descent step (it==0)
271 int maxStepAttempts = 100;
272 std::string stepCondition = "StrongWolfe";
273
274 //S controlEps = S(std::numeric_limits<double>::epsilon() );
275 S controlEps = S(0);
276 S eps = S(1.e-10);
277 S startCoefH = S(1e-4);
278
279 bool verboseOn=true;
280 std::string fname = "control.dat";
281 std::string logFileName = "log.txt";
282 bool vectorBounds = false;
283 bool withUpperBound = false;
284 S upperBound = S();
285 bool withLowerBound = false;
286 S lowerBound = S();
287 bool failOnMaxIter = true;
288
289 std::vector<OptimizerLogType> gplotAnalysis = {};
290 std::string gplotAnalysisString = "";
291
292 // Read Values from XML File from area "Optimization"
293 params.readOrWarn<int>("Optimization", "MaxIter", "", maxIt);
294 params.readOrWarn<int>("Optimization", "L", "", l);
295 params.readOrWarn<S>("Optimization", "Lambda", "", lambda);
296 params.readOrWarn<int>("Optimization", "MaxStepAttempts", "", maxStepAttempts);
297 params.readOrWarn<std::string>("Optimization", "StepCondition", "", stepCondition);
298
299 params.readOrWarn<S>("Optimization", "Tolerance", "", eps);
300 params.readOrWarn<S>("Optimization", "ControlTolerance", "", controlEps);
301 params.readOrWarn<S>("Optimization", "StartCoefH", "", startCoefH);
302 params.readOrWarn<bool>("Optimization", "FailOnMaxIter", "", failOnMaxIter);
303 params.readOrWarn<bool>("Optimization", "Verbose", "", verboseOn);
304 params.readOrWarn<std::string>("Optimization", "InputFileName", "", fname);
305 params.readOrWarn<std::string>("Optimization", "LogFileName", "", logFileName);
306
307 params.readOrWarn<bool>("Optimization", "VectorBounds", "", vectorBounds);
308 if ( params.readOrWarn<S>("Optimization", "UpperBound", "", upperBound, false, false) ) {
309 withUpperBound = true;
310 }
311
312 if ( params.readOrWarn<S>("Optimization", "LowerBound", "", lowerBound, false, false) ) {
313 withLowerBound = true;
314 }
315
316 // get the parameters for the gnuplot Analysis from the xml file from the VisualizationGnuplot area
317 params.readOrWarn<std::string>("Optimization",
318 "VisualizationGnuplot",
319 "VisualizedParameters", gplotAnalysisString, false, false);
320 // transform the data from the xml file to the enums needed for continueing
321 getGnuplotTagsFromString(gplotAnalysisString, gplotAnalysis);
322
323 clout << "Creating optimizer ..." << std::endl;
324 // Create Optimizer Object
325 return new OptimizerLBFGS<S,C>(dimCtrl, eps, maxIt, lambda, maxStepAttempts, stepCondition, l, startCoefH,
326 verboseOn, fname, logFileName, withUpperBound, upperBound, withLowerBound, lowerBound, vectorBounds,
327 controlEps, failOnMaxIter, gplotAnalysis);
328}

References getGnuplotTagsFromString(), and olb::XMLreader::readOrWarn().

+ Here is the call graph for this function:

◆ createOptimizerSteepestDescent()

template<typename S , typename C = std::vector<S>>
OptimizerSteepestDescent< S, C > * olb::opti::createOptimizerSteepestDescent ( XMLreader const & params,
std::size_t dimCtrl )

Creator Function for Steepest Decent.

Definition at line 93 of file optimizerSteepestDecent.h.

94{
95 OstreamManager clout(std::cout,"createOptimizerSteepestDescent");
96
97 // create variables with default values
98 int maxIt = 100;
99
100 //S controlEps = S(std::numeric_limits<double>::epsilon() );
101 S controlEps = S(0);
102 S eps = S(1.e-10);
103
104 S lambda = 1.;
105 int maxStepAttempts = 100;
106 std::string stepCondition = "Armijo";
107
108 bool vectorBounds = false;
109 bool verboseOn=true;
110 std::string fname = "control.dat";
111 std::string logFileName = "log.txt";
112
113 bool withUpperBound = false;
114 S upperBound = S();
115 bool withLowerBound = false;
116 S lowerBound = S();
117
118 std::vector<OptimizerLogType> gplotAnalysis = {};
119 std::string gplotAnalysisString = "";
120
121 // Read Values from XML File from area "Optimization"
122 params.readOrWarn<int>("Optimization", "MaxIter", "", maxIt);
123
124 params.readOrWarn<S>("Optimization", "Tolerance", "", eps);
125 params.readOrWarn<S>("Optimization", "ControlTolerance", "", controlEps);
126 params.readOrWarn<S>("Optimization", "Lambda", "", lambda);
127 params.readOrWarn<int>("Optimization", "MaxStepAttempts", "", maxStepAttempts);
128 params.readOrWarn<std::string>("Optimization", "StepCondition", "", stepCondition);
129
130 params.readOrWarn<bool>("Optimization", "Verbose", "", verboseOn);
131 params.readOrWarn<std::string>("Optimization", "InputFileName", "", fname);
132 params.readOrWarn<std::string>("Optimization", "LogFileName", "", logFileName);
133
134 params.readOrWarn<bool>("Optimization", "VectorBounds", "", vectorBounds);
135 if ( params.readOrWarn<S>("Optimization", "UpperBound", "", upperBound, false, false) ) {
136 withUpperBound = true;
137 }
138
139 if ( params.readOrWarn<S>("Optimization", "LowerBound", "", lowerBound, false, false) ) {
140 withLowerBound = true;
141 }
142
143 // get the parameters for the gnuplot Analysis from the xml file from the VisualizationGnuplot area
144 params.readOrWarn<std::string>("Optimization", "VisualizationGnuplot", "VisualizedParameters", "", gplotAnalysisString, false, false);
145 // transform the data from the xml file to the enums needed for continueing
146 getGnuplotTagsFromString(gplotAnalysisString, gplotAnalysis);
147
148 // Create Optimizer Object
149 return new OptimizerSteepestDescent<S,C>(dimCtrl, eps, maxIt, lambda, maxStepAttempts, stepCondition,
150 verboseOn, fname, logFileName, withUpperBound, upperBound, withLowerBound, lowerBound,
151 vectorBounds, controlEps, gplotAnalysis);
152}

References getGnuplotTagsFromString(), and olb::XMLreader::readOrWarn().

+ Here is the call graph for this function:

◆ evaluateSuperFglobally()

template<unsigned D, typename T , typename U = T>
bool olb::opti::evaluateSuperFglobally ( SuperF< D, T, U > & f,
U * output,
const int input[] )

Helper that gives global access to the values of a functor.

Definition at line 435 of file serialization.h.

436{
437 const auto loadBalancer = f.getSuperStructure().getLoadBalancer();
438 if ( loadBalancer.rank(input[0]) == singleton::mpi().getRank() ) {
439 f(output, input);
440 }
441#ifdef PARALLEL_MODE_MPI
442 singleton::mpi().bCast(output, f.getTargetDim(), loadBalancer.rank(input[0]));
443#endif
444 return true;
445}

References olb::singleton::MpiManager::bCast(), olb::singleton::MpiManager::getRank(), and olb::singleton::mpi().

+ Here is the call graph for this function:

◆ evaluateSuperIndicatorFglobally()

template<unsigned D, typename T >
bool olb::opti::evaluateSuperIndicatorFglobally ( SuperIndicatorF< T, D > & f,
const int input[] )

Helper that gives global access to the values of an indicator.

Definition at line 418 of file serialization.h.

419{
420 bool result = false;
421 const auto loadBalancer = f.getSuperGeometry().getLoadBalancer();
422 if ( loadBalancer.rank(input[0]) == singleton::mpi().getRank() ) {
423 result = f(input);
424 }
425#ifdef PARALLEL_MODE_MPI
426 singleton::mpi().bCast(&result, 1, loadBalancer.rank(input[0]));
427#endif
428 return result;
429}

References olb::singleton::MpiManager::bCast(), olb::singleton::MpiManager::getRank(), and olb::singleton::mpi().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getControl()

template<typename T , template< typename, SolverMode > typename SOLVER, concepts::Field CONTROLLED_FIELD, template< typename... > typename PRIMAL_DYNAMICS, typename C = std::vector<T>>
C olb::opti::getControl ( OptiCaseDual< T, SOLVER, CONTROLLED_FIELD, PRIMAL_DYNAMICS, C > & optiCase,
std::shared_ptr< SOLVER< T, SolverMode::Reference > > solver )

Get control values of some simulation in the context of adjoint optimization Take values of FIELD, apply inverse projection and put them into a long vector Idea: FIELD[cartesianCoordinates] = projection(result[serialIndex]) -> we want to get the vector ''result''.

Template Parameters
Tfloating point type
Ccontainer type, where result is written
FIELDname of the field
Parameters
optiCasedual opti case, provides the information on serialization etc.
solverthe solver, whose FIELD data is taken
Returns
vector with the field data

Definition at line 570 of file serialization.h.

572{
573 C result = serialDataFromField<T,SOLVER,CONTROLLED_FIELD,PRIMAL_DYNAMICS,C>(optiCase, solver);
574 std::transform(result.begin(), result.end(), result.begin(), [&](auto r){
575 return optiCase._projection->inverse(r);
576 });
577 return result;
578}

References serialDataFromField().

+ Here is the call graph for this function:

◆ getGnuplotTagsFromString()

void olb::opti::getGnuplotTagsFromString ( std::string gplotAnalysisString,
std::vector< OptimizerLogType > & gplotAnalysis )

the gplotAnalysisString is gained from the xml file and the function than separates and prepares it to be used in the constructor

Definition at line 244 of file optimizer.hh.

245 {
246 // part the string to get the enum vector
247 std::vector<std::string> gplotAnalysisStringVector;
248 std::istringstream iss(gplotAnalysisString);
249 std::copy(std::istream_iterator<std::string>(iss),
250 std::istream_iterator<std::string>(),
251 std::back_inserter(gplotAnalysisStringVector));
252
253 for(unsigned i = 0; i < gplotAnalysisStringVector.size(); i++){
254 if(gplotAnalysisStringVector[i] == "VALUE"){
255 gplotAnalysis.push_back(OptimizerLogType::value);
256 } else if(gplotAnalysisStringVector[i] == "CONTROL"){
257 gplotAnalysis.push_back(OptimizerLogType::control);
258 } else if(gplotAnalysisStringVector[i] == "DERIVATIVE"){
259 gplotAnalysis.push_back(OptimizerLogType::derivative);
260 } else if(gplotAnalysisStringVector[i] == "ERROR"){
261 gplotAnalysis.push_back(OptimizerLogType::error);
262 } else if(gplotAnalysisStringVector[i] == "NORM_DERIVATIVE"){
263 gplotAnalysis.push_back(OptimizerLogType::norm_derivative);
264 }
265 }
266}

References control, derivative, error, norm_derivative, and value.

+ Here is the caller graph for this function:

◆ getMaterialGlobally()

template<typename S , unsigned dim>
int olb::opti::getMaterialGlobally ( SuperGeometry< S, dim > & sGeometry,
LatticeR< dim+1 > latticeR )

Helper that gives global access to material numbers.

Definition at line 402 of file serialization.h.

403{
404 int material = 0;
405 if ( sGeometry.getLoadBalancer().rank(latticeR[0]) == singleton::mpi().getRank() ) {
406 material = sGeometry.get(latticeR);
407 }
408#ifdef PARALLEL_MODE_MPI
409 singleton::mpi().bCast(&material, 1, sGeometry.getLoadBalancer().rank(latticeR[0]));
410#endif
411 return material;
412}
int rank(int glob) const
int get(LatticeR< D+1 > latticeR) const
Read only access to the material numbers, error handling: returns 0 if data is not available.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.

References olb::singleton::MpiManager::bCast(), olb::SuperGeometry< T, D >::get(), olb::SuperStructure< T, D >::getLoadBalancer(), olb::singleton::MpiManager::getRank(), and olb::singleton::mpi().

+ Here is the call graph for this function:

◆ OptiCaseAdForSolver()

template<typename S , typename T , template< typename > typename SOLVER>
olb::opti::OptiCaseAdForSolver ( std::shared_ptr< SOLVER< S > > ,
std::shared_ptr< SOLVER< T > >  ) -> OptiCaseAdForSolver< S, T::dim, SOLVER, util::StdVector >

◆ OptiCaseAnalytical() [1/2]

template<typename S , typename C >
olb::opti::OptiCaseAnalytical ( std::function< S(const C &)> ,
std::function< void(const C &, C &)>  ) -> OptiCaseAnalytical< S, C >

◆ OptiCaseAnalytical() [2/2]

template<typename S , typename C >
olb::opti::OptiCaseAnalytical ( std::function< S(const C &)> ,
std::function< void(const C &, C &)> ,
std::function< void(void)>  ) -> OptiCaseAnalytical< S, C >

◆ OptiCaseCDQ() [1/8]

template<typename S , typename C >
olb::opti::OptiCaseCDQ ( std::function< S(const C &)> ) -> OptiCaseCDQ< S, C >

◆ OptiCaseCDQ() [2/8]

template<typename S , typename C >
olb::opti::OptiCaseCDQ ( std::function< S(const C &)> ,
S  ) -> OptiCaseCDQ< S, C >

◆ OptiCaseCDQ() [3/8]

template<typename S , typename C >
olb::opti::OptiCaseCDQ ( std::function< S(const C &)> ,
S ,
std::function< void(void)>  ) -> OptiCaseCDQ< S, C >

◆ OptiCaseCDQ() [4/8]

template<typename S , typename C >
olb::opti::OptiCaseCDQ ( std::function< S(const C &)> ,
std::function< void(void)>  ) -> OptiCaseCDQ< S, C >

◆ OptiCaseCDQ() [5/8]

template<typename S , typename C >
olb::opti::OptiCaseCDQ ( std::function< S(const C &, unsigned)> ) -> OptiCaseCDQ< S, C >

◆ OptiCaseCDQ() [6/8]

template<typename S , typename C >
olb::opti::OptiCaseCDQ ( std::function< S(const C &, unsigned)> ,
S  ) -> OptiCaseCDQ< S, C >

◆ OptiCaseCDQ() [7/8]

template<typename S , typename C >
olb::opti::OptiCaseCDQ ( std::function< S(const C &, unsigned)> ,
S ,
std::function< void(void)>  ) -> OptiCaseCDQ< S, C >

◆ OptiCaseCDQ() [8/8]

template<typename S , typename C >
olb::opti::OptiCaseCDQ ( std::function< S(const C &, unsigned)> ,
std::function< void(void)>  ) -> OptiCaseCDQ< S, C >

◆ OptiCaseFDQ() [1/8]

template<typename S , typename C >
olb::opti::OptiCaseFDQ ( std::function< S(const C &)> ) -> OptiCaseFDQ< S, C >

◆ OptiCaseFDQ() [2/8]

template<typename S , typename C >
olb::opti::OptiCaseFDQ ( std::function< S(const C &)> ,
S  ) -> OptiCaseFDQ< S, C >

◆ OptiCaseFDQ() [3/8]

template<typename S , typename C >
olb::opti::OptiCaseFDQ ( std::function< S(const C &)> ,
S ,
std::function< void(void)>  ) -> OptiCaseFDQ< S, C >

◆ OptiCaseFDQ() [4/8]

template<typename S , typename C >
olb::opti::OptiCaseFDQ ( std::function< S(const C &)> ,
std::function< void(void)>  ) -> OptiCaseFDQ< S, C >

◆ OptiCaseFDQ() [5/8]

template<typename S , typename C >
olb::opti::OptiCaseFDQ ( std::function< S(const C &, unsigned)> ) -> OptiCaseFDQ< S, C >

◆ OptiCaseFDQ() [6/8]

template<typename S , typename C >
olb::opti::OptiCaseFDQ ( std::function< S(const C &, unsigned)> ,
S  ) -> OptiCaseFDQ< S, C >

◆ OptiCaseFDQ() [7/8]

template<typename S , typename C >
olb::opti::OptiCaseFDQ ( std::function< S(const C &, unsigned)> ,
S ,
std::function< void(void)>  ) -> OptiCaseFDQ< S, C >

◆ OptiCaseFDQ() [8/8]

template<typename S , typename C >
olb::opti::OptiCaseFDQ ( std::function< S(const C &, unsigned)> ,
std::function< void(void)>  ) -> OptiCaseFDQ< S, C >

◆ serialDataFromField() [1/2]

template<typename T , template< typename, SolverMode > typename SOLVER, concepts::Field CONTROLLED_FIELD, template< typename... > typename PRIMAL_DYNAMICS, typename C = std::vector<T>>
C olb::opti::serialDataFromField ( OptiCaseDual< T, SOLVER, CONTROLLED_FIELD, PRIMAL_DYNAMICS, C > & optiCase,
std::shared_ptr< SOLVER< T, SolverMode::Reference > > solver )

Take values of FIELD and put them into a long vector Idea: FIELD[cartesianCoordinates] = result[serialIndex] -> we want to get the vector ''result''.

Template Parameters
Tfloating point type
Ccontainer type, where result is written
FIELDname of the field
Parameters
optiCasedual opti case, provides the information on serialization etc.
solverthe solver, whose FIELD data is taken
Returns
vector with the field data

Definition at line 540 of file serialization.h.

542{
543 using descriptor = typename SOLVER<T,SolverMode::Reference>::AdjointLbSolver::DESCRIPTOR;
544 return serialDataFromField<
545 CONTROLLED_FIELD, T, descriptor, C>(
546 solver->lattice(),
547 *(optiCase._serializer),
548 *(optiCase._controlIndicator),
549 optiCase._dimCtrl
550 );
551}
std::size_t _dimCtrl
upper limit for the number of control variables (#voxels * field-dimension)
std::shared_ptr< SuperIndicatorF< S, dim > > _controlIndicator
Marks, where there are active control variables.
std::shared_ptr< GeometrySerializer< S, dim > > _serializer
C serialDataFromField(SuperLattice< T, DESCRIPTOR > &sLattice, const GeometrySerializer< T, DESCRIPTOR::d > &serializer, SuperIndicatorF< T, DESCRIPTOR::d > &indicator, unsigned controlDim)
Take values of a field and put them into a long vector Idea: FIELD[cartesianCoordinates] = result[ser...

References olb::opti::OptiCaseDual< S, SOLVER, CONTROLLED_FIELD, PRIMAL_DYNAMICS, C >::_controlIndicator, olb::opti::OptiCaseDual< S, SOLVER, CONTROLLED_FIELD, PRIMAL_DYNAMICS, C >::_dimCtrl, olb::opti::OptiCaseDual< S, SOLVER, CONTROLLED_FIELD, PRIMAL_DYNAMICS, C >::_serializer, and serialDataFromField().

+ Here is the call graph for this function:

◆ serialDataFromField() [2/2]

template<typename FIELD , typename T , typename DESCRIPTOR , typename C = std::vector<T>>
C olb::opti::serialDataFromField ( SuperLattice< T, DESCRIPTOR > & sLattice,
const GeometrySerializer< T, DESCRIPTOR::d > & serializer,
SuperIndicatorF< T, DESCRIPTOR::d > & indicator,
unsigned controlDim )

Take values of a field and put them into a long vector Idea: FIELD[cartesianCoordinates] = result[serialIndex] -> we want to get the vector ''result''.

Template Parameters
Tfloating point type
DESCRIPTORlattice descriptor, must provide the field FIELD
Ccontainer type, where result is written
FIELDname of the field
Parameters
sLatticesuper lattice
serializerimplements the transformation from cartesian to serial data
indicatordescribes, at which positions FIELD is evaluated (at other positions, the default value of C remains)
controlDimlength of result vector
Returns
vector with the field data

Definition at line 466 of file serialization.h.

471{
472 constexpr unsigned dim = DESCRIPTOR::d;
473 constexpr unsigned fieldDim = DESCRIPTOR::template size<FIELD>();
474 auto result = util::ContainerCreator<C>::create(controlDim);
475 const auto& cGeometry = sLattice.getCuboidDecomposition();
476 const auto& loadBalancer = sLattice.getLoadBalancer();
477
478 LatticeR<dim+1> latticeR;
479 for (int iC=0; iC<cGeometry.size(); iC++) {
480 latticeR[0] = iC;
481 const int nX = cGeometry.get(iC).getNx();
482 const int nY = cGeometry.get(iC).getNy();
483 const int nZ = cGeometry.get(iC).getNz();
484 for (int iX=0; iX<nX; iX++) {
485 latticeR[1] = iX;
486 for (int iY=0; iY<nY; iY++) {
487 latticeR[2] = iY;
488 for (int iZ=0; iZ<nZ; iZ++) {
489 latticeR[3] = iZ;
490
491 if (evaluateSuperIndicatorFglobally<dim,T>(indicator, latticeR.data())) {
492 Vector<T,fieldDim> dataHelp;
493 if (loadBalancer.rank(iC) == singleton::mpi().getRank()) {
494 for (unsigned iDim=0; iDim<fieldDim; iDim++) {
495 const auto cell = sLattice.get(latticeR);
496 dataHelp[iDim]
497 = cell.template getFieldComponent<FIELD>(iDim);
498 }
499 }
500#ifdef PARALLEL_MODE_MPI
501 singleton::mpi().bCast(&dataHelp[0], fieldDim, loadBalancer.rank(iC));
502#endif
503 for (unsigned iDim=0; iDim<fieldDim; iDim++) {
504 const auto index = serializer.getSerializedComponentIndex(latticeR, iDim, fieldDim);
505 result[index] = dataHelp[iDim];
506 }
507 }
508 }
509 }
510 }
511 }
512 return result;
513}
Cell< T, DESCRIPTOR > get(LatticeR< DESCRIPTOR::d+1 > latticeR)
Get local cell interface.
CuboidDecomposition< T, D > & getCuboidDecomposition()
Read and write access to cuboid geometry.
Plain old scalar vector.
constexpr const T * data() const any_platform
Definition vector.h:172
std::size_t getSerializedComponentIndex(const int latticeR[], unsigned iD, unsigned fieldDim) const
Get index of field component from lattice coordinates and component index.
Creates a container of type C.

References olb::singleton::MpiManager::bCast(), olb::Vector< T, Size >::data(), evaluateSuperIndicatorFglobally(), olb::SuperLattice< T, DESCRIPTOR >::get(), olb::SuperStructure< T, D >::getCuboidDecomposition(), olb::SuperStructure< T, D >::getLoadBalancer(), olb::singleton::MpiManager::getRank(), olb::opti::GeometrySerializer< S, dim >::getSerializedComponentIndex(), and olb::singleton::mpi().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: