Skip to content

Commit

Permalink
Merge pull request #1309 from LLNL/tupek/clang_style
Browse files Browse the repository at this point in the history
Update clang style to avoid changing lines abore and below.
  • Loading branch information
tupek2 authored Jan 8, 2025
2 parents b90c3dd + 081a5c6 commit eed6b04
Show file tree
Hide file tree
Showing 175 changed files with 3,005 additions and 3,007 deletions.
4 changes: 1 addition & 3 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
BasedOnStyle: Google
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AccessModifierOffset: -2
AccessModifierOffset: -1
ColumnLimit: 120
BreakBeforeBraces: Custom
BraceWrapping:
Expand Down
70 changes: 35 additions & 35 deletions examples/buckling/cylinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,36 +55,36 @@ std::function<std::string(const std::string&)> petscPCTypeValidator = [](const s
int main(int argc, char* argv[])
{
constexpr int dim = 3;
constexpr int p = 1;
constexpr int p = 1;

// Command line arguments
// Mesh options
int serial_refinement = 0;
int parallel_refinement = 0;
double dt = 0.1;
int serial_refinement = 0;
int parallel_refinement = 0;
double dt = 0.1;

// Solver options
NonlinearSolverOptions nonlinear_options = solid_mechanics::default_nonlinear_options;
LinearSolverOptions linear_options = solid_mechanics::default_linear_options;
nonlinear_options.nonlin_solver = serac::NonlinearSolver::TrustRegion;
nonlinear_options.relative_tol = 1e-6;
nonlinear_options.absolute_tol = 1e-10;
nonlinear_options.min_iterations = 1;
nonlinear_options.max_iterations = 500;
NonlinearSolverOptions nonlinear_options = solid_mechanics::default_nonlinear_options;
LinearSolverOptions linear_options = solid_mechanics::default_linear_options;
nonlinear_options.nonlin_solver = serac::NonlinearSolver::TrustRegion;
nonlinear_options.relative_tol = 1e-6;
nonlinear_options.absolute_tol = 1e-10;
nonlinear_options.min_iterations = 1;
nonlinear_options.max_iterations = 500;
nonlinear_options.max_line_search_iterations = 20;
nonlinear_options.print_level = 1;
nonlinear_options.print_level = 1;
#ifdef SERAC_USE_PETSC
linear_options.linear_solver = serac::LinearSolver::GMRES;
linear_options.linear_solver = serac::LinearSolver::GMRES;
linear_options.preconditioner = serac::Preconditioner::HypreAMG;
linear_options.relative_tol = 1e-8;
linear_options.absolute_tol = 1e-16;
linear_options.relative_tol = 1e-8;
linear_options.absolute_tol = 1e-16;
linear_options.max_iterations = 2000;
#endif

// Contact specific options
double penalty = 1e3;
bool use_contact = true;
auto contact_type = serac::ContactEnforcement::Penalty;
double penalty = 1e3;
bool use_contact = true;
auto contact_type = serac::ContactEnforcement::Penalty;

// Initialize Serac and all of the external libraried
serac::initialize(argc, argv);
Expand Down Expand Up @@ -119,24 +119,24 @@ int main(int argc, char* argv[])
nonlinear_options.force_monolithic = linear_options.preconditioner != Preconditioner::Petsc;

// Create DataStore
std::string name = use_contact ? "buckling_cylinder_contact" : "buckling_cylinder";
std::string mesh_tag = "mesh";
std::string name = use_contact ? "buckling_cylinder_contact" : "buckling_cylinder";
std::string mesh_tag = "mesh";
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore, name + "_data");

// Create and refine mesh
std::string filename = SERAC_REPO_DIR "/data/meshes/hollow-cylinder.mesh";
auto mesh = serac::buildMeshFromFile(filename);
auto refined_mesh = mesh::refineAndDistribute(std::move(mesh), serial_refinement, parallel_refinement);
auto& pmesh = serac::StateManager::setMesh(std::move(refined_mesh), mesh_tag);
std::string filename = SERAC_REPO_DIR "/data/meshes/hollow-cylinder.mesh";
auto mesh = serac::buildMeshFromFile(filename);
auto refined_mesh = mesh::refineAndDistribute(std::move(mesh), serial_refinement, parallel_refinement);
auto& pmesh = serac::StateManager::setMesh(std::move(refined_mesh), mesh_tag);

// Surfaces for boundary conditions
constexpr int xneg_attr{2};
constexpr int xpos_attr{3};
auto xneg = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(xneg_attr));
auto xpos = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(xpos_attr));
auto bottom = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(1));
auto top = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(4));
auto xneg = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(xneg_attr));
auto xpos = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(xpos_attr));
auto bottom = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(1));
auto top = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(4));

// Create solver, either with or without contact
std::unique_ptr<SolidMechanics<p, dim>> solid_solver;
Expand All @@ -145,11 +145,11 @@ int main(int argc, char* argv[])
nonlinear_options, linear_options, serac::solid_mechanics::default_quasistatic_options, name, mesh_tag);

// Add the contact interaction
serac::ContactOptions contact_options{.method = serac::ContactMethod::SingleMortar,
serac::ContactOptions contact_options{.method = serac::ContactMethod::SingleMortar,
.enforcement = contact_type,
.type = serac::ContactType::Frictionless,
.penalty = penalty};
auto contact_interaction_id = 0;
.type = serac::ContactType::Frictionless,
.penalty = penalty};
auto contact_interaction_id = 0;
solid_contact_solver->addContactInteraction(contact_interaction_id, {xpos_attr}, {xneg_attr}, contact_options);
solid_solver = std::move(solid_contact_solver);
} else {
Expand All @@ -159,10 +159,10 @@ int main(int argc, char* argv[])
}

// Define a Neo-Hookean material
auto lambda = 1.0;
auto G = 0.1;
auto lambda = 1.0;
auto G = 0.1;
solid_mechanics::NeoHookean mat{.density = 1.0, .K = (3 * lambda + 2 * G) / 3, .G = G};
Domain whole_mesh = EntireDomain(pmesh);
Domain whole_mesh = EntireDomain(pmesh);
solid_solver->setMaterial(mat, whole_mesh);

// Set up essential boundary conditions
Expand Down
28 changes: 14 additions & 14 deletions examples/contact/beam_bending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ int main(int argc, char* argv[])
constexpr int dim = 3;

// Create DataStore
std::string name = "contact_beam_example";
std::string name = "contact_beam_example";
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore, name + "_data");

// Construct the appropriate dimension mesh and give it to the data store
std::string filename = SERAC_REPO_DIR "/data/meshes/beam-hex-with-contact-block.mesh";

auto mesh = serac::mesh::refineAndDistribute(serac::buildMeshFromFile(filename), 2, 0);
auto mesh = serac::mesh::refineAndDistribute(serac::buildMeshFromFile(filename), 2, 0);
auto& pmesh = serac::StateManager::setMesh(std::move(mesh), "beam_mesh");

// create boundary domains for boundary conditions
auto support = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(1));
auto support = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(1));
auto applied_displacement_surface = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(6));

serac::LinearSolverOptions linear_options{.linear_solver = serac::LinearSolver::Strumpack, .print_level = 1};
Expand All @@ -48,16 +48,16 @@ int main(int argc, char* argv[])
return 1;
#endif

serac::NonlinearSolverOptions nonlinear_options{.nonlin_solver = serac::NonlinearSolver::Newton,
.relative_tol = 1.0e-12,
.absolute_tol = 1.0e-12,
serac::NonlinearSolverOptions nonlinear_options{.nonlin_solver = serac::NonlinearSolver::Newton,
.relative_tol = 1.0e-12,
.absolute_tol = 1.0e-12,
.max_iterations = 200,
.print_level = 1};
.print_level = 1};

serac::ContactOptions contact_options{.method = serac::ContactMethod::SingleMortar,
serac::ContactOptions contact_options{.method = serac::ContactMethod::SingleMortar,
.enforcement = serac::ContactEnforcement::Penalty,
.type = serac::ContactType::Frictionless,
.penalty = 1.0e3};
.type = serac::ContactType::Frictionless,
.penalty = 1.0e3};

serac::SolidMechanicsContact<p, dim, serac::Parameters<serac::L2<0>, serac::L2<0>>> solid_solver(
nonlinear_options, linear_options, serac::solid_mechanics::default_quasistatic_options, name, "beam_mesh",
Expand All @@ -67,7 +67,7 @@ int main(int argc, char* argv[])
// each vector value corresponds to a different element attribute:
// [0] (element attribute 1) : the beam
// [1] (element attribute 2) : indenter block
mfem::Vector K_values({10.0, 100.0});
mfem::Vector K_values({10.0, 100.0});
mfem::PWConstCoefficient K_coeff(K_values);
K_field.project(K_coeff);
solid_solver.setParameter(0, K_field);
Expand All @@ -76,13 +76,13 @@ int main(int argc, char* argv[])
// each vector value corresponds to a different element attribute:
// [0] (element attribute 1) : the beam
// [1] (element attribute 2) : indenter block
mfem::Vector G_values({0.25, 2.5});
mfem::Vector G_values({0.25, 2.5});
mfem::PWConstCoefficient G_coeff(G_values);
G_field.project(G_coeff);
solid_solver.setParameter(1, G_field);

serac::solid_mechanics::ParameterizedNeoHookeanSolid mat{1.0, 0.0, 0.0};
serac::Domain whole_mesh = serac::EntireDomain(pmesh);
serac::Domain whole_mesh = serac::EntireDomain(pmesh);
solid_solver.setMaterial(serac::DependsOn<0, 1>{}, mat, whole_mesh);

// Pass the BC information to the solver object
Expand All @@ -97,7 +97,7 @@ int main(int argc, char* argv[])
solid_solver.setDisplacementBCs(applied_displacement, applied_displacement_surface);

// Add the contact interaction
auto contact_interaction_id = 0;
auto contact_interaction_id = 0;
std::set<int> surface_1_boundary_attributes({7});
std::set<int> surface_2_boundary_attributes({5});
solid_solver.addContactInteraction(contact_interaction_id, surface_1_boundary_attributes,
Expand Down
32 changes: 16 additions & 16 deletions examples/contact/ironing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ int main(int argc, char* argv[])
constexpr int dim = 3;

// Create DataStore
std::string name = "contact_ironing_example";
std::string name = "contact_ironing_example";
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore, name + "_data");

// Construct the appropriate dimension mesh and give it to the data store
std::string filename = SERAC_REPO_DIR "/data/meshes/ironing.mesh";

auto mesh = serac::mesh::refineAndDistribute(serac::buildMeshFromFile(filename), 2, 0);
auto mesh = serac::mesh::refineAndDistribute(serac::buildMeshFromFile(filename), 2, 0);
auto& pmesh = serac::StateManager::setMesh(std::move(mesh), "ironing_mesh");

serac::LinearSolverOptions linear_options{.linear_solver = serac::LinearSolver::Strumpack, .print_level = 1};
Expand All @@ -46,16 +46,16 @@ int main(int argc, char* argv[])
return 1;
#endif

serac::NonlinearSolverOptions nonlinear_options{.nonlin_solver = serac::NonlinearSolver::Newton,
.relative_tol = 1.0e-7,
.absolute_tol = 1.0e-7,
serac::NonlinearSolverOptions nonlinear_options{.nonlin_solver = serac::NonlinearSolver::Newton,
.relative_tol = 1.0e-7,
.absolute_tol = 1.0e-7,
.max_iterations = 200,
.print_level = 1};
.print_level = 1};

serac::ContactOptions contact_options{.method = serac::ContactMethod::SingleMortar,
serac::ContactOptions contact_options{.method = serac::ContactMethod::SingleMortar,
.enforcement = serac::ContactEnforcement::Penalty,
.type = serac::ContactType::TiedNormal,
.penalty = 1.0e3};
.type = serac::ContactType::TiedNormal,
.penalty = 1.0e3};

serac::SolidMechanicsContact<p, dim, serac::Parameters<serac::L2<0>, serac::L2<0>>> solid_solver(
nonlinear_options, linear_options, serac::solid_mechanics::default_quasistatic_options, name, "ironing_mesh",
Expand All @@ -65,7 +65,7 @@ int main(int argc, char* argv[])
// each vector value corresponds to a different element attribute:
// [0] (element attribute 1) : the substrate
// [1] (element attribute 2) : indenter block
mfem::Vector K_values({10.0, 100.0});
mfem::Vector K_values({10.0, 100.0});
mfem::PWConstCoefficient K_coeff(K_values);
K_field.project(K_coeff);
solid_solver.setParameter(0, K_field);
Expand All @@ -74,22 +74,22 @@ int main(int argc, char* argv[])
// each vector value corresponds to a different element attribute:
// [0] (element attribute 1) : the substrate
// [1] (element attribute 2) : indenter block
mfem::Vector G_values({0.25, 2.5});
mfem::Vector G_values({0.25, 2.5});
mfem::PWConstCoefficient G_coeff(G_values);
G_field.project(G_coeff);
solid_solver.setParameter(1, G_field);

serac::solid_mechanics::ParameterizedNeoHookeanSolid mat{1.0, 0.0, 0.0};
serac::Domain whole_mesh = serac::EntireDomain(pmesh);
serac::Domain whole_mesh = serac::EntireDomain(pmesh);
solid_solver.setMaterial(serac::DependsOn<0, 1>{}, mat, whole_mesh);

// Pass the BC information to the solver object
serac::Domain bottom_of_substrate = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(5));
solid_solver.setFixedBCs(bottom_of_substrate);

serac::Domain top_of_indenter = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(12));
auto applied_displacement = [](serac::tensor<double, dim>, double t) {
constexpr double init_steps = 2.0;
serac::Domain top_of_indenter = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(12));
auto applied_displacement = [](serac::tensor<double, dim>, double t) {
constexpr double init_steps = 2.0;
serac::tensor<double, dim> u{};
if (t <= init_steps + 1.0e-12) {
u[2] = -t * 0.3 / init_steps;
Expand All @@ -102,7 +102,7 @@ int main(int argc, char* argv[])
solid_solver.setDisplacementBCs(applied_displacement, top_of_indenter);

// Add the contact interaction
auto contact_interaction_id = 0;
auto contact_interaction_id = 0;
std::set<int> surface_1_boundary_attributes({6});
std::set<int> surface_2_boundary_attributes({11});
solid_solver.addContactInteraction(contact_interaction_id, surface_1_boundary_attributes,
Expand Down
22 changes: 11 additions & 11 deletions examples/contact/sphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int argc, char* argv[])
constexpr int dim = 3;

// Create DataStore
std::string name = "contact_sphere_example";
std::string name = "contact_sphere_example";
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore, name + "_data");

Expand All @@ -52,7 +52,7 @@ int main(int argc, char* argv[])
cube_mesh.SetCurvature(p);

std::vector<mfem::Mesh*> mesh_ptrs{&ball_mesh, &cube_mesh};
auto mesh = serac::mesh::refineAndDistribute(mfem::Mesh(mesh_ptrs.data(), static_cast<int>(mesh_ptrs.size())), 0, 0);
auto mesh = serac::mesh::refineAndDistribute(mfem::Mesh(mesh_ptrs.data(), static_cast<int>(mesh_ptrs.size())), 0, 0);
auto& pmesh = serac::StateManager::setMesh(std::move(mesh), "sphere_mesh");

auto fixed_boundary = serac::Domain::ofBoundaryElements(pmesh, serac::by_attr<dim>(3));
Expand All @@ -64,22 +64,22 @@ int main(int argc, char* argv[])
return 1;
#endif

serac::NonlinearSolverOptions nonlinear_options{.nonlin_solver = serac::NonlinearSolver::Newton,
.relative_tol = 1.0e-8,
.absolute_tol = 1.0e-5,
serac::NonlinearSolverOptions nonlinear_options{.nonlin_solver = serac::NonlinearSolver::Newton,
.relative_tol = 1.0e-8,
.absolute_tol = 1.0e-5,
.max_iterations = 200,
.print_level = 1};
.print_level = 1};

serac::ContactOptions contact_options{.method = serac::ContactMethod::SingleMortar,
serac::ContactOptions contact_options{.method = serac::ContactMethod::SingleMortar,
.enforcement = serac::ContactEnforcement::Penalty,
.type = serac::ContactType::Frictionless,
.penalty = 1.0e4};
.type = serac::ContactType::Frictionless,
.penalty = 1.0e4};

serac::SolidMechanicsContact<p, dim> solid_solver(
nonlinear_options, linear_options, serac::solid_mechanics::default_quasistatic_options, name, "sphere_mesh");

serac::solid_mechanics::NeoHookean mat{1.0, 10.0, 0.25};
serac::Domain whole_mesh = serac::EntireDomain(pmesh);
serac::Domain whole_mesh = serac::EntireDomain(pmesh);
solid_solver.setMaterial(mat, whole_mesh);

// Pass the BC information to the solver object
Expand All @@ -102,7 +102,7 @@ int main(int argc, char* argv[])
solid_solver.setDisplacementBCs(applied_displacement, driven_surface);

// Add the contact interaction
auto contact_interaction_id = 0;
auto contact_interaction_id = 0;
std::set<int> surface_1_boundary_attributes({5});
std::set<int> surface_2_boundary_attributes({7});
solid_solver.addContactInteraction(contact_interaction_id, surface_1_boundary_attributes,
Expand Down
Loading

0 comments on commit eed6b04

Please sign in to comment.