Program Listing for File t8_geometry_base.hxx

Return to documentation for file (src/t8_geometry/t8_geometry_base.hxx)

/*
  This file is part of t8code.
  t8code is a C library to manage a collection (a forest) of multiple
  connected adaptive space-trees of general element classes in parallel.

  Copyright (C) 2015 the developers

  t8code is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  t8code is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with t8code; if not, write to the Free Software Foundation, Inc.,
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef T8_GEOMETRY_BASE_HXX
#define T8_GEOMETRY_BASE_HXX

#include <t8.h>
#include <t8_cmesh/t8_cmesh.h>
#include <t8_forest/t8_forest.h>
#include <t8_geometry/t8_geometry.h>
#include <t8_geometry/t8_geometry_hash.hxx>

#include <functional>

T8_EXTERN_C_BEGIN ();

struct t8_geometry
{
 public:
  t8_geometry (std::string name): name (name), hash (t8_geometry_compute_hash (name))
  {
    if (t8_geometry_hash_is_null (hash)) {
      SC_ABORTF ("Registering geometry with invalid name\"%s\"\n.", name.c_str ());
    }
  }

  /* Base constructor with no arguments. We need this since it
   * is called from derived class constructors.
   * Sets the name to an invalid value. */
  t8_geometry (): t8_geometry ("Invalid")
  {
  }

  virtual ~t8_geometry ()
  {
  }

  virtual void
  t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords,
                    double *out_coords) const
    = 0;

  virtual void
  t8_geom_evaluate_jacobian (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords,
                             double *jacobian) const
    = 0;

  virtual void
  t8_geom_load_tree_data (const t8_cmesh_t cmesh, const t8_gloidx_t gtreeid);

  virtual void
  t8_geom_point_batch_inside_element ([[maybe_unused]] t8_forest_t forest, [[maybe_unused]] t8_locidx_t ltreeid,
                                      [[maybe_unused]] const t8_element_t *element,
                                      [[maybe_unused]] const double *points, [[maybe_unused]] const int num_points,
                                      [[maybe_unused]] int *is_inside, [[maybe_unused]] const double tolerance) const
  {
    SC_ABORTF ("Point batch inside element function not implemented");
  };

  virtual bool
  t8_geom_tree_negative_volume () const
  {
    SC_ABORTF ("Tree negative volume function not implemented");
    /* To suppress compiler warnings. */
    return 0;
  };

  virtual bool
  t8_geom_check_tree_compatibility () const
    = 0;

  inline const std::string &
  t8_geom_get_name () const
  {
    return name;
  }

  virtual bool
  get_tree_bounding_box ([[maybe_unused]] const t8_cmesh_t cmesh, [[maybe_unused]] double bounds[6]) const
  {
    t8_errorf ("Tree bounding box function not implemented");
    return false;
  }

  inline t8_geometry_hash
  t8_geom_get_hash () const
  {
    return hash;
  }

  virtual t8_geometry_type_t
  t8_geom_get_type () const
    = 0;

 protected:
  std::string name;
  t8_geometry_hash hash;
  t8_gloidx_t active_tree;
  t8_eclass_t active_tree_class;
};

T8_EXTERN_C_END ();

#endif /* !T8_GEOMETRY_BASE_HXX */