Skip to content

Commit

Permalink
some stuff for invm handler and different solve types
Browse files Browse the repository at this point in the history
  • Loading branch information
landinjm committed Jan 30, 2025
1 parent c8d20e8 commit 79e2004
Show file tree
Hide file tree
Showing 8 changed files with 241 additions and 0 deletions.
142 changes: 142 additions & 0 deletions include/core/invm_handler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#ifndef invm_handler_h
#define invm_handler_h

#include <deal.II/lac/la_parallel_vector.h>

#include <core/exceptions.h>
#include <core/user_inputs/user_input_parameters.h>
#include <core/variable_attributes.h>

/**
* \brief This class handles the computation and access of the inverted mass matrix for
* explicit solves.
*/
template <int dim, int degree>
class invmHandler
{
public:
/**
* \brief Constructor.
*/
invmHandler(const AttributesList &_variable_attributes);

/**
* \brief Destructor.
*/
~invmHandler();

/**
* \brief Compute the mass matrix for scalar/vector fields.
*/
void
compute_invm();

/**
* \brief Recompute the mass matrix for scalar/vector fields. This just points to
* compute_invm() and is used for style.
*/
void
recompute_invm();

/**
* \brief Getter function for the mass matrix for the given field index (constant
* reference).
*/
const dealii::LinearAlgebra::distributed::Vector<double> &
get_invm(const uint &index);

private:
/**
* \brief Variable attributes. This is used to determine the proper return type for the
* invm when given a field index.
*/
const AttributesList &variable_attributes;

/**
* \brief Inverse of the mass matrix for scalar fields.
*/
dealii::LinearAlgebra::distributed::Vector<double> invm_scalar;

/**
* \brief Inverse of the mass matrix for vector fields.
*/
dealii::LinearAlgebra::distributed::Vector<double> invm_vector;

/**
* \brief Whether a scalar invm is needed.
*/
bool scalar_needed = false;

/**
* \brief Whether a vector invm is needed.
*/
bool vector_needed = false;
};

template <int dim, int degree>
invmHandler<dim, degree>::invmHandler(const AttributesList &_variable_attributes)
: variable_attributes(_variable_attributes)
{
for (const auto &[index, variable] : variable_attributes)
{
if (variable.field_type == fieldType::SCALAR)
{
scalar_needed = true;
}
if (variable.field_type == fieldType::VECTOR)
{
vector_needed = true;
}
}
}

template <int dim, int degree>
inline void
invmHandler<dim, degree>::compute_invm()
{}

template <int dim, int degree>
inline void
invmHandler<dim, degree>::recompute_invm()
{
this->compute_invm();
}

template <int dim, int degree>
inline const dealii::LinearAlgebra::distributed::Vector<double> &
invmHandler<dim, degree>::get_invm(const uint &index)
{
Assert(variable_attributes.at(index) != variable_attributes.end(),
dealii::ExcMessage(
"Invalid index. The provided index does not have an entry in the variable "
"attributes that were provided to the constructor."));

if (variable_attributes.at(index).field_type == fieldType::SCALAR)
{
Assert(scalar_needed,
dealii::ExcMessage(
"The invm for scalar fields is marked as not needed. Make sure the "
"variable attributes correspond with the provided index."));
Assert(invm_scalar.size() == 0,
dealii::ExcMessage("The scalar invm has size 0. Please make sure to call "
"compute_invm() prior to calling the getter function."));

return invm_scalar;
}
else if (variable_attributes.at(index).field_type == fieldType::VECTOR)
{
Assert(vector_needed,
dealii::ExcMessage(
"The invm for vector fields is marked as not needed. Make sure the "
"variable attributes correspond with the provided index."));
Assert(invm_vector.size() == 0,
dealii::ExcMessage("The vector invm has size 0. Please make sure to call "
"compute_invm() prior to calling the getter function."));

return invm_vector;
}

Assert(false, dealii::ExcMessage("Invalid field type."));
}

#endif
10 changes: 10 additions & 0 deletions include/core/solvers/explicit_constant_solver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef explicit_constant_solver_h
#define explicit_constant_solver_h

/**
* \brief This class handles the explicit solves of all constant fields
*/
class explicitConstantSolver
{};

#endif
10 changes: 10 additions & 0 deletions include/core/solvers/explicit_postprocess_solver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef explicit_postprocess_solver_h
#define explicit_postprocess_solver_h

/**
* \brief This class handles the explicit solves of all postprocessed fields
*/
class explicitPostprocessSolver
{};

#endif
39 changes: 39 additions & 0 deletions include/core/solvers/explicit_solver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef explicit_solver_h
#define explicit_solver_h

/**
* \brief This class handles the explicit solves of all explicit fields
*/
class explicitSolver
{
public:
/**
* \brief Constructor.
*/
explicitSolver();

/**
* \brief Destructor.
*/
~explicitSolver();

/**
* \brief Initialize system.
*/
void
init_system();

/**
* \brief Reinitialize system.
*/
void
reinit_system();

/**
* \brief Solve a single update step.
*/
void
solve();
};

#endif
10 changes: 10 additions & 0 deletions include/core/solvers/nonexplicit_auxiliary_solver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef nonexplicit_auxiliary_solver_h
#define nonexplicit_auxiliary_solver_h

/**
* \brief This class handles the explicit solves of a single nonexplicit field
*/
class nonexplicitAuxiliarySolves
{};

#endif
10 changes: 10 additions & 0 deletions include/core/solvers/nonexplicit_co_nonlinear_solver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef nonexplicit_co_nonlinear_solver_h
#define nonexplicit_co_nonlinear_solver_h

/**
* \brief This class handles the nonlinear solves of a several nonexplicit fields
*/
class nonexplicitCoNonlinearSolver
{};

#endif
10 changes: 10 additions & 0 deletions include/core/solvers/nonexplicit_linear_solver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef nonexplicit_linear_solver_h
#define nonexplicit_linear_solver_h

/**
* \brief This class handles the linear solves of a single nonexplicit field
*/
class nonexplicitLinearSolver
{};

#endif
10 changes: 10 additions & 0 deletions include/core/solvers/nonexplicit_self_nonlinear_solver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef nonexplicit_self_nonlinear_solver_h
#define nonexplicit_self_nonlinear_solver_h

/**
* \brief This class handles the self-nonlinear solves of a single nonexplicit field
*/
class nonexplicitSelfNonlinearSolver
{};

#endif

0 comments on commit 79e2004

Please sign in to comment.