Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to changes on dolfinx main branch #164

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/cgpoisson_problem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ cgpoisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order,
basix::element::lagrange_variant::gll_warped,
basix::element::dpc_variant::unset, false);

auto dolfinx_element
= std::make_shared<const fem::FiniteElement<double>>(element);

auto V = std::make_shared<fem::FunctionSpace<double>>(
fem::create_functionspace(mesh, element, {}));
fem::create_functionspace(mesh, dolfinx_element));

t0.stop();

Expand Down Expand Up @@ -129,14 +132,14 @@ cgpoisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order,

// Define variational forms
auto L = std::make_shared<fem::Form<T>>(fem::create_form<T>(
*form_poisson_L.at(order - 1), {V}, {{"w0", f}, {"w1", g}}, {}, {}, {}));
*form_poisson_L.at(order - 1), {V}, {{"w0", f}, {"w1", g}}, {}, {}, {}));
// auto a = std::make_shared<fem::Form<T>>(fem::create_form<T>(
// *form_poisson_a.at(order - 1), {V, V},
// std::vector<std::shared_ptr<const fem::Function<T>>>{}, {}, {}));

auto un = std::make_shared<fem::Function<T>>(V);
auto M = std::make_shared<fem::Form<T>>(fem::create_form<T>(
*form_poisson_M.at(order - 1), {V}, {{"w0", un}}, {{}}, {}, {}));
*form_poisson_M.at(order - 1), {V}, {{"w0", un}}, {{}}, {}, {}));

// Create la::Vector
la::Vector<T> b(L->function_spaces()[0]->dofmap()->index_map,
Expand Down
18 changes: 10 additions & 8 deletions src/elasticity_problem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ elastic::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
basix::element::lagrange_variant::gll_warped,
basix::element::dpc_variant::unset, false);

auto dolfinx_element = std::make_shared<const fem::FiniteElement<double>>(
element, std::vector<std::size_t>{3});
auto V = std::make_shared<fem::FunctionSpace<double>>(
fem::create_functionspace(mesh, element, {3}));
fem::create_functionspace(mesh, dolfinx_element));

t0.stop();

Expand Down Expand Up @@ -139,7 +141,7 @@ elastic::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
*V->mesh()->topology_mutable(), *V->dofmap(), tdim - 1, bc_facets);

// Bottom (x[1] = 0) surface
auto bc = std::make_shared<fem::DirichletBC<T>>(u0, bdofs);
auto bc = std::make_shared<const fem::DirichletBC<T>>(u0, bdofs);

t0a.stop();

Expand Down Expand Up @@ -182,7 +184,7 @@ elastic::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
= {form_Elasticity_a1, form_Elasticity_a2, form_Elasticity_a3};
auto L = std::make_shared<fem::Form<T, double>>(fem::create_form<T>(
*form_elasticity_L.at(order - 1), {V}, {{"w0", f}}, {}, {}, {}));
auto a = std::make_shared<fem::Form<T, double>>(fem::create_form<T>(
auto a = std::make_shared<const fem::Form<T, double>>(fem::create_form<T>(
*form_elasticity_a.at(order - 1), {V, V}, {}, {}, {}, {}));
t0c.stop();

Expand All @@ -196,11 +198,11 @@ elastic::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
fem::pack_coefficients(*a, coeffs_a);
fem::assemble_matrix(la::petsc::Matrix::set_block_fn(A->mat(), ADD_VALUES),
*a, std::span(constants_a),
fem::make_coefficients_span(coeffs_a), {bc});
fem::make_coefficients_span(coeffs_a), {*bc});
MatAssemblyBegin(A->mat(), MAT_FLUSH_ASSEMBLY);
MatAssemblyEnd(A->mat(), MAT_FLUSH_ASSEMBLY);
fem::set_diagonal<T>(la::petsc::Matrix::set_fn(A->mat(), INSERT_VALUES), *V,
{bc});
{*bc});
MatAssemblyBegin(A->mat(), MAT_FINAL_ASSEMBLY);
MatAssemblyEnd(A->mat(), MAT_FINAL_ASSEMBLY);
t2.stop();
Expand All @@ -215,9 +217,9 @@ elastic::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
fem::pack_coefficients(*L, coeffs_L);
fem::assemble_vector<T>(b.mutable_array(), *L, constants_L,
fem::make_coefficients_span(coeffs_L));
fem::apply_lifting<T, double>(b.mutable_array(), {a}, {constants_L},
{fem::make_coefficients_span(coeffs_L)}, {{bc}},
{}, 1.0);
fem::apply_lifting<T, double>(b.mutable_array(), {*a}, {constants_L},
{fem::make_coefficients_span(coeffs_L)},
{{*bc}}, {}, 1.0);
b.scatter_rev(std::plus<>());
bc->set(b.mutable_array(), std::nullopt);
t3.stop();
Expand Down
21 changes: 12 additions & 9 deletions src/poisson_problem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ poisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
basix::element::lagrange_variant::gll_warped,
basix::element::dpc_variant::unset, false);

auto dolfinx_element
= std::make_shared<const fem::FiniteElement<double>>(element);

auto V = std::make_shared<fem::FunctionSpace<double>>(
fem::create_functionspace(mesh, element, {}));
fem::create_functionspace(mesh, dolfinx_element));

t0.stop();

Expand Down Expand Up @@ -108,9 +111,9 @@ poisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)

// Define variational forms
auto L = std::make_shared<fem::Form<T>>(fem::create_form<T>(
*form_poisson_L.at(order - 1), {V}, {{"w0", f}, {"w1", g}}, {}, {}, {}));
auto a = std::make_shared<fem::Form<T>>(
fem::create_form<T>(*form_poisson_a.at(order - 1), {V, V}, {}, {}, {}, {}));
*form_poisson_L.at(order - 1), {V}, {{"w0", f}, {"w1", g}}, {}, {}, {}));
auto a = std::make_shared<fem::Form<T>>(fem::create_form<T>(
*form_poisson_a.at(order - 1), {V, V}, {}, {}, {}, {}));

// Create matrices and vector, and assemble system
std::shared_ptr<la::petsc::Matrix> A = std::make_shared<la::petsc::Matrix>(
Expand All @@ -122,11 +125,11 @@ poisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
fem::pack_coefficients(*a, coeffs_a);
fem::assemble_matrix<T>(la::petsc::Matrix::set_block_fn(A->mat(), ADD_VALUES),
*a, constants_a,
fem::make_coefficients_span(coeffs_a), {bc});
fem::make_coefficients_span(coeffs_a), {*bc});
MatAssemblyBegin(A->mat(), MAT_FLUSH_ASSEMBLY);
MatAssemblyEnd(A->mat(), MAT_FLUSH_ASSEMBLY);
fem::set_diagonal<T>(la::petsc::Matrix::set_fn(A->mat(), INSERT_VALUES), *V,
{bc});
{*bc});
MatAssemblyBegin(A->mat(), MAT_FINAL_ASSEMBLY);
MatAssemblyEnd(A->mat(), MAT_FINAL_ASSEMBLY);
t4.stop();
Expand All @@ -141,9 +144,9 @@ poisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
fem::pack_coefficients(*L, coeffs_L);
fem::assemble_vector<T>(b.mutable_array(), *L, constants_L,
fem::make_coefficients_span(coeffs_L));
fem::apply_lifting<T, double>(b.mutable_array(), {a}, {constants_L},
{fem::make_coefficients_span(coeffs_L)}, {{bc}},
{}, 1.0);
fem::apply_lifting<T, double>(b.mutable_array(), {*a}, {constants_L},
{fem::make_coefficients_span(coeffs_L)},
{{*bc}}, {}, 1.0);
b.scatter_rev(std::plus<>());
bc->set(b.mutable_array(), std::nullopt);
t5.stop();
Expand Down
Loading