本文整理汇总了C++中LinearSolver::set_weak_formulation方法的典型用法代码示例。如果您正苦于以下问题:C++ LinearSolver::set_weak_formulation方法的具体用法?C++ LinearSolver::set_weak_formulation怎么用?C++ LinearSolver::set_weak_formulation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinearSolver
的用法示例。
在下文中一共展示了LinearSolver::set_weak_formulation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
// Load mesh.
load_mesh(mesh, "domain.xml", INIT_REF_NUM);
// Create an H1 space with default shapeset.
SpaceSharedPtr<double> space(new H1Space<double>(mesh, &essential_bcs, P_INIT));
solver.set_weak_formulation(&weak_formulation);
solver.set_space(space);
#pragma region Time stepping loop.
/*
solver.set_time_step(time_step_length);
do
{
std::cout << "Time step: " << time_step_number << std::endl;
#pragma region Spatial adaptivity loop.
adaptivity.set_space(space);
int adaptivity_step = 1;
do
{
std::cout << "Adaptivity step: " << adaptivity_step << std::endl;
#pragma region Construct globally refined reference mesh and setup reference space.
MeshSharedPtr ref_mesh = ref_mesh_creator.create_ref_mesh();
SpaceSharedPtr<double> ref_space = ref_space_creator.create_ref_space(space, ref_mesh);
solver.set_space(ref_space);
#pragma endregion
try
{
// Solving.
solver.solve(get_initial_Newton_guess(adaptivity_step, &weak_formulation, space, ref_space, sln_time_prev));
Solution<double>::vector_to_solution(solver.get_sln_vector(), ref_space, sln_time_new);
}
catch(Exceptions::Exception& e)
{
std::cout << e.info();
}
catch(std::exception& e)
{
std::cout << e.what();
}
// Project the fine mesh solution onto the coarse mesh.
OGProjection<double>::project_global(space, sln_time_new, sln_time_new_coarse);
// Calculate element errors and error estimate.
errorCalculator.calculate_errors(sln_time_new_coarse, sln_time_new);
double error_estimate = errorCalculator.get_total_error_squared() * 100;
std::cout << "Error estimate: " << error_estimate << "%" << std::endl;
// Visualize the solution and mesh.
display(sln_time_new, ref_space);
// If err_est too large, adapt the mesh.
if (error_estimate < ERR_STOP)
break;
else
adaptivity.adapt(&refinement_selector);
adaptivity_step++;
}
while(true);
#pragma endregion
#pragma region No adaptivity in space.
try
{
// Solving.
solver.solve(sln_time_prev);
// Get the solution for visualization etc. from the coefficient vector.
Solution<double>::vector_to_solution(solver.get_sln_vector(), space, sln_time_new);
// Visualize the solution and mesh.
display(sln_time_new, space);
}
catch(Exceptions::Exception& e)
{
std::cout << e.info();
}
catch(std::exception& e)
{
std::cout << e.what();
}
#pragma endregion
sln_time_prev->copy(sln_time_new);
// Increase current time and counter of time steps.
current_time += time_step_length;
time_step_number++;
}
while (current_time < T_FINAL);
*/
#pragma endregion
#pragma region No time stepping (= stationary problem).
try
{
//.........这里部分代码省略.........