55 Eigen::MatrixXd reduced;
56 for (
int i = 0; i < rhs.cols(); i++)
60 reduced.setZero(reduced_vec.rows(), rhs.cols());
61 reduced.col(i) = reduced_vec;
71 Eigen::VectorXd partial_grad;
83 gradv = Eigen::VectorXd::Zero(
x.size());
88 return Eigen::MatrixXd::Zero(state.
ndof(), diff_cache.
size());
113 return Eigen::MatrixXd::Zero(state.
ndof(), 1);
119 Eigen::MatrixXd term = Eigen::MatrixXd::Zero(state.
ndof(), diff_cache.
size());
133 const double t =
state_->problem->is_time_dependent() ? time_step *
state_->args[
"time"][
"dt"].get<
double>() +
state_->args[
"time"][
"t0"].get<
double>() : 0;
134 Eigen::VectorXd max_stress;
135 max_stress.setZero(
state_->bases.size());
137 Eigen::MatrixXd local_vals;
138 assembler::ElementAssemblyValues vals;
139 for (int e = start; e < end; e++)
141 if (interested_ids_.size() != 0 && interested_ids_.find(state_->mesh->get_body_id(e)) == interested_ids_.end())
144 state_->ass_vals_cache.compute(e, state_->mesh->is_volume(), state_->bases[e], state_->geom_bases()[e], vals);
147 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, diff_cache_->u(time_step)), ElasticityTensorType::PK1, local_vals);
149 Eigen::VectorXd stress_norms = local_vals.rowwise().norm();
150 max_stress(e) = std::max(max_stress(e), stress_norms.maxCoeff());
154 return max_stress.maxCoeff();
159 return Eigen::VectorXd();
Storage for additional data required by differntial code.
main class that contains the polyfem solver and all its state
bool is_homogenization() const
std::shared_ptr< assembler::Problem > problem
current problem, it contains rhs and bc
solver::SolveData solve_data
timedependent stuff 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