164{
166
167
168
169 const unsigned char requested_dim =
171
172
173
174
175 Mesh old_mesh(
init.comm(), requested_dim);
176
177 const std::string meshname =
179
180 libMesh::out <<
"Reading mesh " << meshname << std::endl;
181 old_mesh.read(meshname);
182
183 const std::string matname =
185
186 if (matname != "")
187 {
188 libMesh::out <<
"Reading matrix " << matname << std::endl;
189
190
191
192
194 matrix->read(matname);
195 matrix->get_transpose(*matrix);
196
197 old_mesh.copy_constraint_rows(*matrix);
198 }
199
201 old_mesh.print_info();
202
203
204 if (old_mesh.is_serial_on_zero())
205 {
208
211 libMesh::out <<
"Mesh has " << n_components <<
" connected components." << std::endl;
212 }
213
214 const std::string solnname =
216
217
218
221
222 const std::string calcfunc =
224
225 const std::string family =
227
229
230 std::unique_ptr<FEMFunctionBase<Number>> goal_function;
231
232 if (solnname != "")
233 {
234 libMesh::out <<
"Reading solution " << solnname << std::endl;
235
236 old_es.read(solnname,
241
243
244 old_es.print_info();
245
246 const unsigned int sysnum =
248
249 libmesh_assert_less(sysnum, old_es.n_systems());
250
251 System & old_sys = old_es.get_system(sysnum);
252
254
255 goal_function =
256 std::make_unique<ParsedFEMFunction<Number>>(old_sys, calcfunc);
257 }
258 else
259 {
261
262
264
265
266
267
269 Utility::string_to_enum<FEFamily>(family));
270
271 old_es.init();
272
273 goal_function =
275 }
276
278
279
280 std::vector<libMesh::subdomain_id_type> subdomain_vec;
282 std::set<libMesh::subdomain_id_type> subdomains_list(subdomain_vec.begin(),
283 subdomain_vec.end());
284
285 std::string default_outsolnname = "out_soln.xda";
286 if (solnname != "")
287 default_outsolnname = "out_"+solnname;
288 const std::string outsolnname =
290
291
292 libMesh::out << std::setprecision(std::numeric_limits<Real>::max_digits10);
293
295 {
296
297
298
299 Mesh new_mesh(old_mesh);
300
302
304
307
310
313
316
319
322
324
326
328 std::make_unique<SteadySolver>(new_sys);
329
332
334
336
338
339 if (solnname != "")
341
343
345
346 new_es.print_info();
347
349 solver.
quiet =
false;
352
354
355
357 {
358 const unsigned int error_q =
360
361
363 {
365 exact_sol.attach_exact_value(0, goal_function.get());
367 exact_sol.attach_exact_deriv(0, &fdm_gradient);
368 exact_sol.extra_quadrature_order(error_q);
369
372
375 std::endl;
376
379 std::endl;
380
382 {
385 std::endl;
386
389 std::endl;
390 }
391 }
392 }
393
394
396 {
397 const unsigned int jump_error_hilbert =
399
401 {
402 std::unique_ptr<JumpErrorEstimator> error_estimator;
407
408 if (jump_error_hilbert == 0)
409 {
410 error_estimator = std::make_unique<DiscontinuityMeasure>();
412 }
413 else if (jump_error_hilbert == 1)
414 {
415 error_estimator = std::make_unique<KellyErrorEstimator>();
417 }
418 else if (jump_error_hilbert == 2)
419 {
420 error_estimator = std::make_unique<LaplacianErrorEstimator>();
422 }
423 else
424 libmesh_not_implemented();
425
427 error_estimator->integrate_slits = true;
428
430 error_estimator->error_norm = error_norm;
431 error_estimator->estimate_error(new_sys, error_per_cell);
432
434
435
436
437
439 for (auto cell_error : error_per_cell)
440 total_error += cell_error;
441
442 if (jump_error_hilbert == 0)
444 else
446
447 libMesh::out <<
" error estimate for " << var_name <<
": " <<
448 total_error << std::endl;
449 }
450 }
451
452
453 new_es.write(outsolnname.c_str(),
456 libMesh::out <<
"Wrote solution " << outsolnname << std::endl;
457 }
458 else
459 {
460
462
464 (old_mesh.active_local_elements_begin(),
465 old_mesh.active_local_elements_end());
466
467 Integrate integrate(old_sys, *goal_function);
468
470 integrate);
471
472 Number integral = integrate.integral();
473 old_mesh.comm().sum(integral);
474 libMesh::out <<
"Integral is " << integral << std::endl;
475 }
476
477 return 0;
478}
T assert_argument(const std::string &argname, const char *progname, const T &defaultarg)
std::set< libMesh::subdomain_id_type > & subdomains_list()
libMesh::System * input_system
void set_fdm_eps(libMesh::Real eps)
void set_goal_func(libMesh::FEMFunctionBase< libMesh::Number > &goal)
unsigned int & fe_order()
std::string & fe_family()
unsigned int & hilbert_order()
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
Real relative_step_tolerance
bool verbose
The DiffSolver may print a lot more to libMesh::out if verbose is set to true; default is false.
bool quiet
The DiffSolver should not print anything to libMesh::out unless quiet is set to false; default is tru...
bool print_jacobians
Set print_jacobians to true to print J whenever it is assembled.
bool print_residuals
Set print_residuals to true to print F whenever it is assembled.
bool print_element_jacobians
Set print_element_jacobians to true to print each J_elem contribution.
bool print_solutions
Set print_solutions to true to print U whenever it is used in an assembly() call.
bool print_element_solutions
Set print_element_solutions to true to print each U_elem input.
bool print_element_residuals
Set print_element_residuals to true to print each R_elem contribution.
std::unique_ptr< TimeSolver > time_solver
A pointer to the solver object we're going to use.
This is the EquationSystems class.
The ErrorVector is a specialization of the StatisticsVector for error data computed on a finite eleme...
This class handles the computation of the L2 and/or H1 error for the Systems in the EquationSystems o...
virtual void solve() override
Invokes the solver associated with the system.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
A Function generated (via FParser) by parsing a mathematical expression.
static std::unique_ptr< SparseMatrix< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package(), const MatrixBuildType matrix_build_type=MatrixBuildType::AUTOMATIC)
Builds a SparseMatrix<T> using the linear solver package specified by solver_package.
The StoredRange class defines a contiguous, divisible set of objects.
This class defines a norm/seminorm to be applied to a NumericVector which contains coefficients in a ...
void set_type(unsigned int var, const FEMNormType &t)
Sets the type of the norm in variable var, as well as for any unset variables with index less than va...
void set_weight(unsigned int var, Real w)
Sets the weight corresponding to the norm in variable var, as well as for any unset variables with in...
Manages consistently variables, degrees of freedom, and coefficient vectors.
const std::string & name() const
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
void init()
Initializes degrees of freedom on the current mesh.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
const std::string & variable_name(const unsigned int i) const
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
void parallel_reduce(const Range &range, Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided reduction operation in parallel on the specified range.
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
DIE A HORRIBLE DEATH HERE typedef float ErrorVectorReal
void command_line_vector(const std::string &, std::vector< T > &)
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
std::string current_sys_name