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
242 old_es.print_info();
243
244 const unsigned int sysnum =
246
247 libmesh_assert_less(sysnum, old_es.n_systems());
248
249 System & old_sys = old_es.get_system(sysnum);
250
252
253 goal_function =
254 std::make_unique<ParsedFEMFunction<Number>>(old_sys, calcfunc);
255 }
256 else
257 {
259
260
262
263
264
265
267 Utility::string_to_enum<FEFamily>(family));
268
269 old_es.init();
270
271 old_es.print_info();
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 Mesh new_mesh(
init.comm(), requested_dim);
298 new_mesh.read(meshname);
299
301
303
305
307
309 std::make_unique<SteadySolver>(new_sys);
310
313
315
317
319
320 if (solnname != "")
322
324
326 solver.
quiet =
false;
329
331
332
334 {
335 const unsigned int error_q =
337
338
340 {
342 exact_sol.attach_exact_value(0, goal_function.get());
344 exact_sol.attach_exact_deriv(0, &fdm_gradient);
345 exact_sol.extra_quadrature_order(error_q);
346
349
352 std::endl;
353
356 std::endl;
357
359 {
362 std::endl;
363
366 std::endl;
367 }
368 }
369 }
370
371
373 {
374 const unsigned int jump_error_hilbert =
376
378 {
379 std::unique_ptr<JumpErrorEstimator> error_estimator;
384
385 if (jump_error_hilbert == 0)
386 {
387 error_estimator = std::make_unique<DiscontinuityMeasure>();
389 }
390 else if (jump_error_hilbert == 1)
391 {
392 error_estimator = std::make_unique<KellyErrorEstimator>();
394 }
395 else if (jump_error_hilbert == 2)
396 {
397 error_estimator = std::make_unique<LaplacianErrorEstimator>();
399 }
400 else
401 libmesh_not_implemented();
402
404 error_estimator->integrate_slits = true;
405
407 error_estimator->error_norm = error_norm;
408 error_estimator->estimate_error(new_sys, error_per_cell);
409
411
412
413
414
416 for (auto cell_error : error_per_cell)
417 total_error += cell_error;
418
419 if (jump_error_hilbert == 0)
421 else
423
424 libMesh::out <<
" error estimate for " << var_name <<
": " <<
425 total_error << std::endl;
426 }
427 }
428
429
430 new_es.write(outsolnname.c_str(),
433 libMesh::out <<
"Wrote solution " << outsolnname << std::endl;
434 }
435 else
436 {
437
439
441 (old_mesh.active_local_elements_begin(),
442 old_mesh.active_local_elements_end());
443
444 Integrate integrate(old_sys, *goal_function);
445
447 integrate);
448
449 Number integral = integrate.integral();
450 old_mesh.comm().sum(integral);
451 libMesh::out <<
"Integral is " << integral << std::endl;
452 }
453
454 return 0;
455}
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...
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