Skip to content

Commit

Permalink
Added overloaded advance_postprocessing_timestep method to TimeSolver…
Browse files Browse the repository at this point in the history
… and its 1st level derived classes.

1) The new advance_postprocessing_timestep takes a vector of std::function as arguments and provides
these functions with the right time integration quadrature.
2) advance_postprocessing_timestep manages the time incrementation, retrieval of solutions and meshes.
  • Loading branch information
vikramvgarg committed Apr 23, 2022
1 parent bbb582f commit 112b78c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/solvers/steady_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ class SteadySolver : public TimeSolver
virtual void integrate_adjoint_refinement_error_estimate(AdjointRefinementEstimator & adjoint_refinement_error_estimator, ErrorVector & QoI_elementwise_error) override;
#endif // LIBMESH_ENABLE_AMR

virtual void advance_postprocessing_timestep(std::vector<std::function<void(Real, System &)>> integration_operations) override;

protected:

/**
Expand Down
11 changes: 11 additions & 0 deletions include/solvers/time_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace libMesh
class DiffContext;
class DiffSolver;
class DifferentiablePhysics;
class System;
class DifferentiableSystem;
class ParameterVector;
class SensitivityData;
Expand Down Expand Up @@ -156,6 +157,16 @@ class TimeSolver : public ReferenceCountedObject<TimeSolver>
virtual void integrate_adjoint_refinement_error_estimate(AdjointRefinementEstimator & adjoint_refinement_error_estimator, ErrorVector & QoI_elementwise_error);
#endif // LIBMESH_ENABLE_AMR


/**
* A method to evaluate generic integrals of the form:
* int_{0}^{T} f(u,z;p) dt ~ (sum_{i=1}^{N_outer_timesteps} sum_{k=1}^{K} ( sum_{j=1}^{N_inner_steps} w_ij f_k(u^j,z^j; p^j) )
* The library will supply the weights w_ij and current time t_ij to the user supplied function integration_operations.
* Also provided will be the primal and adjoint solution(s) values, u^j, u^j-1 and z^j, z^j+1
* The user defined integration_operations function will evaluate w_ij * f_k(u^j,z^j; p^j).
*/
virtual void advance_postprocessing_timestep(std::vector<std::function<void(Real, System &)>> integration_operations) = 0;

/**
* This method uses the DifferentiablePhysics
* element_time_derivative(), element_constraint(), and
Expand Down
2 changes: 2 additions & 0 deletions include/solvers/unsteady_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class UnsteadySolver : public TimeSolver
virtual void integrate_adjoint_refinement_error_estimate(AdjointRefinementEstimator & /*adjoint_refinement_error_estimator*/, ErrorVector & /*QoI_elementwise_error*/) override;
#endif // LIBMESH_ENABLE_AMR

virtual void advance_postprocessing_timestep(std::vector<std::function<void(Real, System &)>> integration_operations) override = 0;

/**
* This method should return the expected convergence order of the
* (non-local) error of the time discretization scheme - e.g. 2 for the
Expand Down
13 changes: 13 additions & 0 deletions src/solvers/steady_solver.C
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,17 @@ void SteadySolver::integrate_adjoint_refinement_error_estimate
}
#endif // LIBMESH_ENABLE_AMR

void SteadySolver::advance_postprocessing_timestep(std::vector<std::function<void(Real, System &)>> integration_operations)
{
// For a steady state solve, time quadrature weight is simply 1.0
Real time_quadrature_weight = 1.0;
for(auto integration_operations_iterator:integration_operations)
{
auto f = integration_operations_iterator;
f(time_quadrature_weight, dynamic_cast<System&>(_system));
}

return;
}

} // namespace libMesh

0 comments on commit 112b78c

Please sign in to comment.