Skip to content

Commit

Permalink
Working example
Browse files Browse the repository at this point in the history
  • Loading branch information
larsson4 committed Feb 28, 2024
1 parent b9f35cc commit b87d221
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/linelast/linelast.force_cantilever.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ visualization:
enabled: false
unified_paraview: true
file_path:
prefix: lattice_output
prefix: paraview_output

parameterized_problem:
name: linelast_force_cantilever
Expand Down
13 changes: 13 additions & 0 deletions include/parameterized_problem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ extern double rdisp_f;
void init_disp(const Vector &x, Vector &u);
}

namespace linelast_force
{
extern double rforce_f;

void tip_force(const Vector &x, Vector &u);
}

}

class ParameterizedProblem
Expand Down Expand Up @@ -240,6 +247,12 @@ class LinElastDispLattice : public LinElastProblem
LinElastDispLattice();
};

class LinElastForceCantilever : public LinElastProblem
{
public:
LinElastForceCantilever();
};

ParameterizedProblem* InitParameterizedProblem();

#endif
69 changes: 69 additions & 0 deletions src/parameterized_problem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,18 @@ void init_disp_lcantilever(const Vector &x, Vector &u)

} // namespace linelast_disp

namespace linelast_force
{

double rforce_f;

void tip_force(const Vector &x, Vector &f)
{
f = 0.0;
f(f.Size()-1) = -1.0e-2 * rforce_f;
}

} // namespace linelast_force

} // namespace function_factory

Expand Down Expand Up @@ -287,6 +299,10 @@ ParameterizedProblem* InitParameterizedProblem()
{
problem = new LinElastDispLattice();
}
else if (problem_name == "linelast_force_cantilever")
{
problem = new LinElastForceCantilever();
}
else
{
mfem_error("Unknown parameterized problem name!\n");
Expand Down Expand Up @@ -702,3 +718,56 @@ if (i<2)
general_vector_ptr[0] = NULL;

}


LinElastForceCantilever::LinElastForceCantilever()
: LinElastProblem()
{
// pointer to static function.
bdr_type.SetSize(3);
battr.SetSize(3);
vector_bdr_ptr.SetSize(3);
for (size_t i = 0; i < vector_bdr_ptr.Size(); i++)
{
battr[i] = i+1;
if (i==0)
{
bdr_type[i] = LinElastProblem::DIRICHLET;
vector_bdr_ptr[i] = &(function_factory::linelast_disp::init_disp);
}
else if (i==1)
{
bdr_type[i] = LinElastProblem::NEUMANN;
vector_bdr_ptr[i] = &(function_factory::linelast_force::tip_force);

}
else if (i==2)
{
bdr_type[i] = LinElastProblem::ZERO;
vector_bdr_ptr[i] = NULL;
}

}

// Set materials
general_scalar_ptr.SetSize(2);
general_scalar_ptr[0] = function_factory::linelast_problem::lambda;
general_scalar_ptr[1] = function_factory::linelast_problem::mu;

// Default values.
function_factory::linelast_force::rforce_f = 1.0;
function_factory::linelast_problem::_lambda = 1.0;
function_factory::linelast_problem::_mu = 1.0;

param_map["rforce_f"] = 0;
param_map["lambda"] = 1;
param_map["mu"] = 2;

param_ptr.SetSize(3);
param_ptr[0] = &(function_factory::linelast_force::rforce_f);
param_ptr[1] = &(function_factory::linelast_problem::_lambda);
param_ptr[2] = &(function_factory::linelast_problem::_mu);

general_vector_ptr.SetSize(1);
general_vector_ptr[0] = NULL;
}

0 comments on commit b87d221

Please sign in to comment.