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

Update clang format #1214

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
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
62 changes: 31 additions & 31 deletions examples/buckling/cylinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,36 +53,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 @@ -117,15 +117,15 @@ 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 pmesh = mesh::refineAndDistribute(std::move(mesh), serial_refinement, parallel_refinement);
auto mesh = serac::buildMeshFromFile(filename);
auto pmesh = mesh::refineAndDistribute(std::move(mesh), serial_refinement, parallel_refinement);
serac::StateManager::setMesh(std::move(pmesh), mesh_tag);

// Surface attributes for boundary conditions
Expand All @@ -142,25 +142,25 @@ int main(int argc, char* argv[])
serac::GeometricNonlinearities::On, 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, xneg, contact_options);
solid_solver = std::move(solid_contact_solver);
} else {
solid_solver = std::make_unique<serac::SolidMechanics<p, dim>>(nonlinear_options, linear_options,
serac::solid_mechanics::default_quasistatic_options,
serac::GeometricNonlinearities::On, name, mesh_tag);
auto domain = serac::Domain::ofBoundaryElements(
StateManager::mesh(mesh_tag), [&](std::vector<vec3>, int attr) { return xpos.find(attr) != xpos.end(); });
auto domain = serac::Domain::ofBoundaryElements(
StateManager::mesh(mesh_tag), [&](std::vector<vec3>, int attr) { return xpos.find(attr) != xpos.end(); });
solid_solver->setPressure([&](auto&, double t) { return 0.01 * t; }, domain);
}

// 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};

solid_solver->setMaterial(mat);
Expand All @@ -176,7 +176,7 @@ int main(int argc, char* argv[])
// Top of cylinder has prescribed displacement of magnitude in x-z direction
auto compress = [&](const mfem::Vector&, double t, mfem::Vector& u) {
u.SetSize(dim);
u = 0.0;
u = 0.0;
u(0) = u(2) = -1.5 / std::sqrt(2.0) * t;
};
solid_solver->setDisplacementBCs(top, compress);
Expand Down
24 changes: 12 additions & 12 deletions examples/contact/beam_bending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ 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");

Expand All @@ -44,16 +44,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,
Expand All @@ -63,7 +63,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 @@ -72,7 +72,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 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);
Expand All @@ -87,12 +87,12 @@ int main(int argc, char* argv[])
});
solid_solver.setDisplacementBCs({6}, [](const mfem::Vector&, double t, mfem::Vector& u) {
u.SetSize(dim);
u = 0.0;
u = 0.0;
u[2] = -0.05 * t;
});

// 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
22 changes: 11 additions & 11 deletions examples/contact/ironing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ 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");

Expand All @@ -44,16 +44,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,
Expand All @@ -63,7 +63,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 @@ -72,7 +72,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 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);
Expand All @@ -97,7 +97,7 @@ int main(int argc, char* argv[])
});

// 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
18 changes: 9 additions & 9 deletions examples/contact/sphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,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 Down Expand Up @@ -60,16 +60,16 @@ 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,
Expand Down Expand Up @@ -98,7 +98,7 @@ int main(int argc, char* argv[])
});

// 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
18 changes: 9 additions & 9 deletions examples/contact/twist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int main(int argc, char* argv[])
constexpr int dim = 3;

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

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-4,
serac::NonlinearSolverOptions nonlinear_options{.nonlin_solver = serac::NonlinearSolver::Newton,
.relative_tol = 1.0e-7,
.absolute_tol = 1.0e-4,
.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.0e5};
.type = serac::ContactType::Frictionless,
.penalty = 1.0e5};

serac::SolidMechanicsContact<p, dim> solid_solver(nonlinear_options, linear_options,
serac::solid_mechanics::default_quasistatic_options,
Expand Down Expand Up @@ -84,7 +84,7 @@ int main(int argc, char* argv[])
});

// Add the contact interaction
auto contact_interaction_id = 0;
auto contact_interaction_id = 0;
std::set<int> surface_1_boundary_attributes({4});
std::set<int> surface_2_boundary_attributes({5});
solid_solver.addContactInteraction(contact_interaction_id, surface_1_boundary_attributes,
Expand Down
8 changes: 4 additions & 4 deletions examples/simple_conduction/without_input_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ int main(int argc, char* argv[])
// _create_module_start
// Create a Heat Transfer class instance with Order 1 and Dimensions of 2
constexpr int order = 1;
constexpr int dim = 2;
constexpr int dim = 2;

serac::HeatTransfer<order, dim> heat_transfer(
serac::heat_transfer::default_nonlinear_options, serac::heat_transfer::default_linear_options,
serac::heat_transfer::default_static_options, "thermal_solver", mesh_tag);
// _create_module_end

// _conductivity_start
constexpr double kappa = 0.5;
constexpr double kappa = 0.5;
serac::heat_transfer::LinearIsotropicConductor mat(1.0, 1.0, kappa);
heat_transfer.setMaterial(mat);

// _conductivity_end
// _bc_start
const std::set<int> boundary_constant_attributes = {1};
constexpr double boundary_constant = 1.0;
constexpr double boundary_constant = 1.0;

auto ebc_func = [boundary_constant](const auto&, auto) { return boundary_constant; };
heat_transfer.setTemperatureBCs(boundary_constant_attributes, ebc_func);

const std::set<int> boundary_function_attributes = {2, 3};
auto boundary_function_coef = [](const auto& vec, auto) { return vec[0] * vec[0] + vec[1] - 1; };
auto boundary_function_coef = [](const auto& vec, auto) { return vec[0] * vec[0] + vec[1] - 1; };
heat_transfer.setTemperatureBCs(boundary_function_attributes, boundary_function_coef);
// _bc_end

Expand Down
Loading