FEProblemInterface

class FEProblemInterface : public godzilla::DiscreteProblemInterface, public godzilla::DependencyEvaluator

Interface for FE problems.

Any problem using PetscFE should inherit from this for unified API

Subclassed by godzilla::FENonlinearProblem

Public Functions

virtual Int get_num_fields() const override

Get number of fields.

Returns:

The number of fields

virtual std::vector<std::string> get_field_names() const override

Get list of all field names.

Returns:

List of field names

virtual const std::string &get_field_name(Int fid) const override

Get field name.

Parameters:

fid – Field ID

virtual Int get_field_num_components(Int fid) const override

Get number of field components.

Parameters:

fid – Field ID

Returns:

Number of components

virtual Int get_field_id(const std::string &name) const override

Get field ID.

Parameters:
  • name – Field name

  • Field – ID

virtual bool has_field_by_id(Int fid) const override

Do we have field with specified ID.

Parameters:

fid – The ID of the field

Returns:

True if the field exists, otherwise False

virtual bool has_field_by_name(const std::string &name) const override

Do we have field with specified name.

Parameters:

name – The name of the field

Returns:

True if the field exists, otherwise False

virtual Int get_field_order(Int fid) const override

Get field order.

Parameters:

fid – Field ID

Returns:

Field order

virtual std::string get_field_component_name(Int fid, Int component) const override

Get component name of a field.

Parameters:
  • fid – Field ID

  • component – Component index

Returns:

Component name

virtual void set_field_component_name(Int fid, Int component, const std::string &name) override

Set the name of a component of afield variable.

Parameters:
  • fid – Field ID

  • component – Component index

  • name – Component name

virtual Int get_num_aux_fields() const override

Get number of auxiliary fields.

Returns:

The number of auxiliary fields

virtual std::vector<std::string> get_aux_field_names() const override

Get all auxiliary field names.

Returns:

All auxiliary field names

virtual const std::string &get_aux_field_name(Int fid) const override

Get auxiliary field name.

Parameters:

fid – Auxiliary field ID

Returns:

Auxiliary field name

virtual Int get_aux_field_num_components(Int fid) const override

Get number of auxiliary field components.

Parameters:

fid – Auxiliary field ID

Returns:

Number of components

virtual Int get_aux_field_id(const std::string &name) const override

Get auxiliary field ID.

Parameters:

name – Auxiliary field name

Returns:

Auxiliary field ID

virtual bool has_aux_field_by_id(Int fid) const override

Do we have auxiliary field with specified ID.

Parameters:

fid – The ID of the auxiliary field

Returns:

True if the auxiliary field exists, otherwise False

virtual bool has_aux_field_by_name(const std::string &name) const override

Do we have auxiliary field with specified name.

Parameters:

name – The name of the auxiliary field

Returns:

True if the auxiliary field exists, otherwise False

virtual Int get_aux_field_order(Int fid) const override

Get auxiliary field order.

Parameters:

fid – Auxiliary field ID

Returns:

Auxiliary field order

virtual std::string get_aux_field_component_name(Int fid, Int component) const override

Get component name of an auxiliary field.

Parameters:
  • fid – Auxiliary field ID

  • component – Component index

Returns:

Component name

virtual void set_aux_field_component_name(Int fid, Int component, const std::string &name) override

Set the name of a component of an auxiliary field variable.

Parameters:
  • fid – Field ID

  • component – Component index

  • name – Component name

Int add_field(const std::string &name, Int nc, Int k, const Label &block = Label())

Adds a volumetric field.

Parameters:
  • name – The name of the field

  • nc – The number of components

  • k – The degree k of the space

  • block – The mesh region this field is restricted to

Returns:

ID of the new field

void set_field(Int id, const std::string &name, Int nc, Int k, const Label &block = Label())

Set a volumetric field.

Parameters:
  • id – The field ID

  • name – The name of the field

  • nc – The number of components

  • k – The degree k of the space

  • block – The mesh region this field is restricted to

Int add_aux_field(const std::string &name, Int nc, Int k, const Label &block = Label())

Adds a volumetric auxiliary field.

Parameters:
  • name – The name of the field

  • nc – The number of components

  • k – The degree k of the space

  • block – The mesh region this field is restricted to

Returns:

ID of the new field

void set_aux_field(Int id, const std::string &name, Int nc, Int k, const Label &block = Label())

Set a volumetric auxiliary field.

Parameters:
  • id – The field ID

  • name – The name of the field

  • nc – The number of components

  • k – The degree k of the space

  • block – The mesh region this field is restricted to

virtual void add_residual_block(Int fid, ResidualFunc *f0, ResidualFunc *f1, const std::string &region = "")

Add residual statement for a field variable.

Parameters:
  • fid – Field ID

  • f0 – Integrand for the test function term

  • f1 – Integrand for the test function gradient term

  • region – Region name where this residual statement is active

virtual void add_boundary_residual_block(Int fid, ResidualFunc *f0, ResidualFunc *f1, const std::string &boundary)

Add boundary residual statement for a field variable.

Parameters:
  • fid – Field ID

  • f0 – Integrand for the test function term

  • f1 – Integrand for the test function gradient term

  • boundary – Boundary name where this residual statement is active

virtual void add_jacobian_block(Int fid, Int gid, JacobianFunc *g0, JacobianFunc *g1, JacobianFunc *g2, JacobianFunc *g3, const std::string &region = "")

Add Jacobian statement for a field variable.

Parameters:
  • fid – Test field number

  • gid – Field number

  • g0 – Integrand for the test and basis function term

  • g1 – Integrand for the test function and basis function gradient term

  • g2 – Integrand for the test function gradient and basis function term

  • g3 – Integrand for the test function gradient and basis function gradient term

  • region – Region name where this Jacobian statement is active

virtual void add_jacobian_preconditioner_block(Int fid, Int gid, JacobianFunc *g0, JacobianFunc *g1, JacobianFunc *g2, JacobianFunc *g3, const std::string &region = "")

Add Jacobian preconditioner statement for a field variable.

Parameters:
  • fid – Test field number

  • gid – Field number

  • g0 – Integrand for the test and basis function term

  • g1 – Integrand for the test function and basis function gradient term

  • g2 – Integrand for the test function gradient and basis function term

  • g3 – Integrand for the test function gradient and basis function gradient term

  • region – Region name where this Jacobian statement is active

virtual void add_boundary_jacobian_block(Int fid, Int gid, JacobianFunc *g0, JacobianFunc *g1, JacobianFunc *g2, JacobianFunc *g3, const std::string &boundary)

Add boundary Jacobian statement for a field variable.

Parameters:
  • fid – Test field number

  • gid – Field number

  • g0 – Integrand for the test and basis function term

  • g1 – Integrand for the test function and basis function gradient term

  • g2 – Integrand for the test function gradient and basis function term

  • g3 – Integrand for the test function gradient and basis function gradient term

  • boundary – Boundary name where this Jacobian statement is active

void integrate_residual(PetscDS ds, const WeakForm::Key &key, Int n_elems, PetscFEGeom *cell_geom, const Scalar coefficients[], const Scalar coefficients_t[], PetscDS ds_aux, const Scalar coefficients_aux[], Real t, Scalar elem_vec[])

Integrate residual.

void integrate_bnd_residual(PetscDS ds, const WeakForm::Key &key, Int n_elems, PetscFEGeom *face_geom, const Scalar coefficients[], const Scalar coefficients_t[], PetscDS ds_aux, const Scalar coefficients_aux[], Real t, Scalar elem_vec[])

Integrate residual over a boundary.

void integrate_jacobian(PetscDS ds, PetscFEJacobianType jtype, const WeakForm::Key &key, Int n_elems, PetscFEGeom *cell_geom, const Scalar coefficients[], const Scalar coefficients_t[], PetscDS ds_aux, const Scalar coefficients_aux[], Real t, Real u_tshift, Scalar elem_mat[])

Integrate Jacobian.