43 Eigen::MatrixXd reduced;
44 for (
int i = 0; i < rhs.cols(); i++)
48 reduced.setZero(reduced_vec.rows(), rhs.cols());
49 reduced.col(i) = reduced_vec;
59 Eigen::VectorXd partial_grad;
71 gradv = Eigen::VectorXd::Zero(
x.size());
101 return Eigen::MatrixXd::Zero(state.
ndof(), 1);
122 Eigen::VectorXd max_stress;
125 Eigen::MatrixXd local_vals;
126 assembler::ElementAssemblyValues vals;
127 for (int e = start; e < end; e++)
129 if (interested_ids_.size() != 0 && interested_ids_.find(state_.mesh->get_body_id(e)) == interested_ids_.end())
132 state_.ass_vals_cache.compute(e, state_.mesh->is_volume(), state_.bases[e], state_.geom_bases()[e], vals);
135 std::dynamic_pointer_cast<assembler::ElasticityAssembler>(state_.assembler)->compute_stress_tensor(assembler::OutputData(t, e, state_.bases[e], state_.geom_bases()[e], vals.quadrature.points, state_.diff_cached.u(time_step)), ElasticityTensorType::PK1, local_vals);
137 Eigen::VectorXd stress_norms = local_vals.rowwise().norm();
138 max_stress(e) = std::max(max_stress(e), stress_norms.maxCoeff());
142 return max_stress.maxCoeff();
147 return Eigen::VectorXd();
main class that contains the polyfem solver and all its state
std::shared_ptr< assembler::Problem > problem
current problem, it contains rhs and bc
json args
main input arguments containing all defaults
solver::DiffCache diff_cached
std::vector< basis::ElementBases > bases
FE bases, the size is #elements.
solver::SolveData solve_data
timedependent stuff cached
std::unique_ptr< polysolve::linear::Solver > lin_solver_cached
std::shared_ptr< solver::NLProblem > nl_problem
Eigen::VectorXd compute_adjoint_term(const Eigen::VectorXd &x) const
Computes the sum of adjoint terms for all VariableToSimulation.
void maybe_parallel_for(int size, const std::function< void(int, int, int)> &partial_for)
spdlog::logger & adjoint_logger()
Retrieves the current logger for adjoint.
void log_and_throw_adjoint_error(const std::string &msg)
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix