Hermes2D  3.0
Hermes::Hermes2D::Solution< Scalar > Singleton Reference

Represents the solution of a PDE.
More...

#include <solution.h>

+ Inheritance diagram for Hermes::Hermes2D::Solution< Scalar >:

Public Member Functions

 Solution (MeshSharedPtr mesh)
 
 Solution (SpaceSharedPtr< Scalar > s, Vector< Scalar > *coeff_vec)
 
 Solution (SpaceSharedPtr< Scalar > s, Scalar *coeff_vec)
 
virtual bool isOkay () const
 State querying helpers.
 
virtual std::string getClassName () const
 
virtual void copy (const MeshFunction< Scalar > *sln)
 Copy from sln to this instance.
 
void set_dirichlet_lift (SpaceSharedPtr< Scalar > space)
 Sets solution equal to Dirichlet lift only, solution vector = 0.
 
virtual void save (const char *filename) const
 
void load (const char *filename, SpaceSharedPtr< Scalar > space)
 
Scalar get_ref_value (Element *e, double xi1, double xi2, int component=0, int item=0)
 
Scalar get_ref_value_transformed (Element *e, double xi1, double xi2, int a, int b)
 
Scalar ** get_ref_values_transformed (Element *e, double x, double y)
 
virtual Func< Scalar > * get_pt_value (double x, double y, bool use_MeshHashGrid=false, Element *e=nullptr)
 
virtual void add (MeshFunctionSharedPtr< Scalar > &other_mesh_function, SpaceSharedPtr< Scalar > target_space)
 
virtual void multiply (Scalar coef)
 Multiplies the function represented by this class by the given coefficient.
 
SolutionType get_type () const
 Returns solution type.
 
SpaceType get_space_type () const
 
virtual void set_active_element (Element *e)
 Internal.
 
virtual MeshFunction< Scalar > * clone () const
 
void set_type (SolutionType type)
 
virtual void free ()
 Frees all precalculated tables.
 
template<>
 Solution (MeshSharedPtr mesh)
 
template<>
 Solution (MeshSharedPtr mesh)
 
template<>
 Solution (SpaceSharedPtr< double > s, Vector< double > *coeff_vec)
 
template<>
 Solution (SpaceSharedPtr< std::complex< double > > s, Vector< std::complex< double > > *coeff_vec)
 
template<>
 Solution (SpaceSharedPtr< double > s, double *coeff_vec)
 
template<>
 Solution (SpaceSharedPtr< std::complex< double > > s, std::complex< double > *coeff_vec)
 
template<>
void save (const char *filename) const
 
template<>
void save (const char *filename) const
 
template<>
void load (const char *filename, SpaceSharedPtr< double > space)
 
template<>
void load (const char *filename, SpaceSharedPtr< std::complex< double > > space)
 
- Public Member Functions inherited from Hermes::Hermes2D::MeshFunction< Scalar >
 MeshFunction ()
 Empty constructor.
 
 MeshFunction (MeshSharedPtr mesh)
 Constructor.
 
virtual ~MeshFunction ()
 Destructor.
 
MeshSharedPtr get_mesh () const
 Return the mesh.
 
virtual void copy (MeshFunctionSharedPtr< Scalar > sln)
 
RefMapget_refmap (bool update=true)
 Return the reference mapping.
 
virtual Scalar get_approx_max_value (int item=H2D_FN_VAL_0)
 Return the approximate maximum value of this instance.
 
virtual Scalar get_approx_min_value (int item=H2D_FN_VAL_0)
 Return the approximate minimum value of this instance.
 
std::string getClassName () const
 Internal.
 
virtual void reinit ()
 Internal.
 
virtual void set_quad_2d (Quad2D *quad_2d)
 
virtual int get_edge_fn_order (int edge)
 Returns the order of the edge number edge of the current active element.
 
template<>
double get_approx_max_value (int item_)
 
template<>
std::complex< double > get_approx_max_value (int item_)
 
template<>
double get_approx_min_value (int item_)
 
template<>
std::complex< double > get_approx_min_value (int item_)
 
- Public Member Functions inherited from Hermes::Hermes2D::Function< Scalar >
 Function ()
 Default constructor.
 
virtual ~Function ()
 
unsigned char get_num_components () const
 Returns the number of components of the function being represented by the class.
 
virtual const Scalar * get_fn_values (int component=0) const
 Returns function values. More...
 
virtual const Scalar * get_dx_values (int component=0) const
 Returns the x partial derivative. More...
 
virtual const Scalar * get_dy_values (int component=0) const
 Returns the y partial derivative. More...
 
Scalar * deep_copy_array (int component=0, int item=0) const
 Returns function values. More...
 
Quad2Dget_quad_2d () const
 Returns the current quadrature points.
 
void set_quad_order (unsigned short order, unsigned short mask=H2D_FN_DEFAULT)
 
virtual const Scalar * get_values (int component, int item) const
 
virtual int get_fn_order () const
 Returns the polynomial degree of the function being represented by the class.
 
virtual void push_transform (int son)
 
virtual void pop_transform ()
 
virtual void set_transform (uint64_t idx)
 
- Public Member Functions inherited from Hermes::Hermes2D::Transformable
Elementget_active_element () const
 
uint64_t get_transform () const
 
- Public Member Functions inherited from Hermes::Hermes2D::Mixins::XMLParsing
 XMLParsing ()
 Constructor.
 
void set_validation (bool to_set)
 Set to validate / not to validate.
 

Static Public Member Functions

static void make_dx_coeffs (int mode, int o, Scalar *mono, Scalar *result)
 
static void make_dy_coeffs (int mode, int o, Scalar *mono, Scalar *result)
 
static void set_static_verbose_output (bool verbose)
 
static void vector_to_solutions (const Scalar *solution_vector, std::vector< SpaceSharedPtr< Scalar > > spaces, std::vector< MeshFunctionSharedPtr< Scalar > > solutions, std::vector< bool > add_dir_lift=std::vector< bool >(), std::vector< int > start_indices=std::vector< int >())
 Passes solution components calculated from solution vector as Solutions.
 
static void vector_to_solution (const Scalar *solution_vector, SpaceSharedPtr< Scalar > space, MeshFunctionSharedPtr< Scalar > solution, bool add_dir_lift=true, int start_index=0)
 
static void vector_to_solution (const Scalar *solution_vector, SpaceSharedPtr< Scalar > space, Solution< Scalar > *solution, bool add_dir_lift=true, int start_index=0)
 
static void vector_to_solutions (const Vector< Scalar > *vec, std::vector< SpaceSharedPtr< Scalar > > spaces, std::vector< MeshFunctionSharedPtr< Scalar > > solutions, std::vector< bool > add_dir_lift=std::vector< bool >(), std::vector< int > start_indices=std::vector< int >())
 
static void vector_to_solutions_common_dir_lift (const Vector< Scalar > *vec, std::vector< SpaceSharedPtr< Scalar > > spaces, std::vector< MeshFunctionSharedPtr< Scalar > > solutions, bool add_dir_lift=false)
 
static void vector_to_solutions_common_dir_lift (const Scalar *solution_vector, std::vector< SpaceSharedPtr< Scalar > > spaces, std::vector< MeshFunctionSharedPtr< Scalar > > solutions, bool add_dir_lift=false)
 
static void vector_to_solution (const Vector< Scalar > *vec, SpaceSharedPtr< Scalar > space, MeshFunctionSharedPtr< Scalar > solution, bool add_dir_lift=true, int start_index=0)
 

Public Attributes

Scalar * mono_coeffs
 Monomial coefficient array.
 
int * elem_orders
 

Static Public Attributes

static bool static_verbose_output = false
 
- Static Public Attributes inherited from Hermes::Hermes2D::Transformable
static const unsigned int H2D_MAX_TRN_LEVEL = 15
 If this changes, NeighborSearch::H2D_MAX_NEIGHBORS must change too.
 

Protected Member Functions

void enable_transform (bool enable=true)
 
virtual void init ()
 Internal.
 
virtual void set_coeff_vector (SpaceSharedPtr< Scalar > space, const Vector< Scalar > *vec, bool add_dir_lift, int start_index)
 Converts a coefficient vector into a Solution.
 
virtual void set_coeff_vector (SpaceSharedPtr< Scalar > space, const Scalar *coeffs, bool add_dir_lift, int start_index)
 
void transform_values (int order, int mask, int np)
 
virtual void precalculate (unsigned short order, unsigned short mask)
 precalculates the current function at the current integration points.
 
double ** calc_mono_matrix (int mode, unsigned char o)
 
void init_dxdy_buffer ()
 
void check_space_type_compliance (const char *space_type_to_check) const
 Internal, checks the compliance of the passed space type and owned space type.
 
void load_exact_solution (int number_of_components, SpaceSharedPtr< Scalar > space, bool complexness, double x_real, double y_real, double x_complex, double y_complex)
 Special internal method for loading exact solutions.
 
template<>
void load_exact_solution (int number_of_components, SpaceSharedPtr< double > space, bool complexness, double x_real, double y_real, double x_complex, double y_complex)
 
template<>
void load_exact_solution (int number_of_components, SpaceSharedPtr< std::complex< double > > space, bool complexness, double x_real, double y_real, double x_complex, double y_complex)
 
- Protected Member Functions inherited from Hermes::Hermes2D::MeshFunction< Scalar >
void update_refmap ()
 
- Protected Member Functions inherited from Hermes::Hermes2D::Function< Scalar >
virtual void reset_transform ()
 Empties the stack, loads identity transform.
 
virtual void force_transform (uint64_t sub_idx, Trf *ctm)
 For internal use only.
 
virtual int get_edge_fn_order (unsigned char edge) const
 Returns the polynomial degree of the function at given edge. To be overridden in derived classes. More...
 
void invalidate_values ()
 
- Protected Member Functions inherited from Hermes::Hermes2D::Transformable
double get_transform_jacobian () const
 
Trfget_ctm () const
 
unsigned int get_depth () const
 

Protected Attributes

SolutionType sln_type
 
SpaceType space_type
 
bool transform
 
int * elem_coeffs [H2D_MAX_SOLUTION_COMPONENTS]
 array of pointers into mono_coeffs
 
int num_coeffs
 
int num_elems
 
int num_dofs
 
Scalar * dxdy_coeffs [H2D_MAX_SOLUTION_COMPONENTS][H2D_NUM_FUNCTION_VALUES]
 
Scalar * dxdy_buffer
 
Scalar x [H2D_MAX_INTEGRATION_POINTS_COUNT]
 Utility.
 
Scalar y [H2D_MAX_INTEGRATION_POINTS_COUNT]
 
Scalar tx [H2D_MAX_INTEGRATION_POINTS_COUNT]
 
- Protected Attributes inherited from Hermes::Hermes2D::MeshFunction< Scalar >
ElementMode2D mode
 
MeshSharedPtr mesh
 
RefMap refmap
 
- Protected Attributes inherited from Hermes::Hermes2D::Function< Scalar >
Scalar values [H2D_MAX_SOLUTION_COMPONENTS][H2D_NUM_FUNCTION_VALUES][H2D_MAX_INTEGRATION_POINTS_COUNT]
 The data.
 
bool values_valid
 Flag that the data are not 'dirty'.
 
int order
 Current function polynomial order.
 
unsigned char num_components
 Number of vector components.
 
Quad2Dquads [H2D_MAX_QUADRATURES]
 List of available quadratures.
 
int cur_quad
 Active quadrature (index into 'quads')
 
- Protected Attributes inherited from Hermes::Hermes2D::Transformable
Elementelement
 The active element.
 
Trfctm
 Current sub-element transformation matrix.
 
uint64_t sub_idx
 Sub-element transformation index.
 
Trf stack [21]
 Transformation matrix stack.
 
unsigned int top
 Stack top.
 
- Protected Attributes inherited from Hermes::Hermes2D::Mixins::XMLParsing
bool validate
 Internal.
 

Friends

class RefMap
 
template<typename T >
class KellyTypeAdapt
 
template<typename T >
class Views::BaseView
 
template<typename T >
class Views::VectorBaseView
 
template<typename T >
class OGProjectionNOX
 
template<typename T >
class Adapt
 
template<typename T >
class Func
 
template<typename T >
class DiscontinuousFunc
 
template<typename T >
class DiscreteProblem
 
template<typename T >
class DiscreteProblemIntegrationOrderCalculator
 
template<typename T >
class NeighborSearch
 
template<typename T >
class RefinementSelectors::ProjBasedSelector
 
template<typename T >
class RefinementSelectors::H1ProjBasedSelector
 
template<typename T >
class RefinementSelectors::L2ProjBasedSelector
 
template<typename T >
class RefinementSelectors::HcurlProjBasedSelector
 

Additional Inherited Members

- Static Protected Member Functions inherited from Hermes::Hermes2D::Transformable
static void push_transforms (std::set< Transformable * > &transformables, int son)
 
static void pop_transforms (std::set< Transformable * > &transformables)
 
- Static Protected Attributes inherited from Hermes::Hermes2D::Function< Scalar >
static int idx2mask [H2D_NUM_FUNCTION_VALUES][2]
 Index to mask table. More...
 
- Static Protected Attributes inherited from Hermes::Hermes2D::Transformable
static const uint64_t H2D_MAX_IDX = (1ULL << 3 * H2D_MAX_TRN_LEVEL) - 1
 

Detailed Description

template<typename Scalar>
singleton Hermes::Hermes2D::Solution< Scalar >

Represents the solution of a PDE.

The Solution class represents the solution of a PDE. Given a space and a solution vector, it calculates the appropriate linear combination of basis functions at the specified element and integration points.

The higher-order solution on elements is best calculated not as a linear combination of shape functions (the usual approach), but as a linear combination of monomials. This has the advantage that no shape function table calculation and look-ups are necessary (except for the conversion of the solution coefficients), which means that visualization and multi-mesh calculations are much faster (all the push_transforms and table searches take the most time when evaluating the solution).

The linear combination of monomials can be calculated using the Horner's scheme, which requires the same number of multiplications as the calculation of the linear combination of shape functions. However, sub-element transforms are trivial and cheap. Moreover, after the solution on all elements is expressed as a combination of monomials, the Space can be forgotten. This is comfortable for the user, since the Solution class acts as a self-contained unit, internally containing just a copy of the mesh and a table of monomial coefficients. It is also very straight-forward to obtain all derivatives of a solution defined in this way. Finally, it is possible to store the solution on the disk easily (no need to store the Space, which is difficult).

The following is an example of the set of monomials for a cubic quad and a cubic triangle. (Note that these are actually the definitions of the polynomial spaces on these elements.)

[ x^3*y^3 x^2*y^3 x*y^3 y^3 ] [ y^3 ] [ x^3*y^2 x^2*y^2 x*y^2 y^2 ] [ x*y^2 y^2 ] [ x^3*y x^2*y x*y y ] [ x^2*y x*y y ] [ x^3 x^2 x 1 ] [ x^3 x^2 x 1 ]

The number of monomials is (p + 1)^2 for quads and (p + 1)*(p + 2)/2 for triangles, where 'p' is the polynomial degree.

Definition at line 35 of file api2d.h.

Member Function Documentation

template<typename Scalar>
void Hermes::Hermes2D::Solution< Scalar >::add ( MeshFunctionSharedPtr< Scalar > &  other_mesh_function,
SpaceSharedPtr< Scalar >  target_space 
)
virtual

Adds another mesh function on the given space. See method of parent class.

Reimplemented from Hermes::Hermes2D::MeshFunction< Scalar >.

Definition at line 628 of file solution.cpp.

template<typename Scalar >
void Hermes::Hermes2D::Solution< Scalar >::enable_transform ( bool  enable = true)
protected

Enables or disables transformation of the solution derivatives (H1 case) or values (vector (Hcurl) case). This means H2D_FN_DX_0 and H2D_FN_DY_0 or H2D_FN_VAL_0 and H2D_FN_VAL_1 will or will not be returned premultiplied by the reference mapping matrix. The default is enabled (true).

Definition at line 620 of file solution.cpp.

Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::calc_projection_errors().

template<typename Scalar >
Func< Scalar > * Hermes::Hermes2D::Solution< Scalar >::get_pt_value ( double  x,
double  y,
bool  use_MeshHashGrid = false,
Element e = nullptr 
)
virtual

Returns solution value or derivatives at the physical domain point (x, y). 'item' controls the returned value: H2D_FN_VAL_0, H2D_FN_VAL_1, H2D_FN_DX_0, H2D_FN_DX_1, H2D_FN_DY_0, .... NOTE: This function should be used for postprocessing only, it is not effective enough for calculations. Since it searches for an element sequentinally, it is extremelly slow. Prefer Solution::get_ref_value if possible.

Implements Hermes::Hermes2D::MeshFunction< Scalar >.

Definition at line 1837 of file solution.cpp.

template<typename Scalar >
Scalar Hermes::Hermes2D::Solution< Scalar >::get_ref_value ( Element e,
double  xi1,
double  xi2,
int  component = 0,
int  item = 0 
)

Returns solution value or derivatives at element e, in its reference domain point (xi1, xi2). 'item' controls the returned value: 0 = value, 1 = dx, 2 = dy, 3 = dxx, 4 = dyy, 5 = dxy. NOTE: This function should be used for postprocessing only, it is not effective enough for calculations.

Definition at line 1678 of file solution.cpp.

template<typename Scalar >
Scalar Hermes::Hermes2D::Solution< Scalar >::get_ref_value_transformed ( Element e,
double  xi1,
double  xi2,
int  a,
int  b 
)

Returns solution value or derivatives (correctly transformed) at element e, in its reference domain point (xi1, xi2). 'item' controls the returned value: 0 = value, 1 = dx, 2 = dy, 3 = dxx, 4 = dyy, 5 = dxy. NOTE: This function should be used for postprocessing only, it is not effective enough for calculations.

Definition at line 1700 of file solution.cpp.

template<typename Scalar >
Scalar ** Hermes::Hermes2D::Solution< Scalar >::get_ref_values_transformed ( Element e,
double  x,
double  y 
)

Returns solution value and derivatives (correctly transformed) at element e, in its REAL COORDINATES domain point (xi1, xi2). The values are returned. NOTE: This function should be used for postprocessing only, it is not effective enough for calculations.

Definition at line 1777 of file solution.cpp.

template<typename Scalar>
void Hermes::Hermes2D::Solution< Scalar >::load ( const char *  filename,
SpaceSharedPtr< Scalar >  space 
)

Loads the solution from a file previously created by Solution::save(). This completely restores the solution in the memory.

Member Data Documentation

template<typename Scalar>
int* Hermes::Hermes2D::Solution< Scalar >::elem_orders

Stored element orders in the mathematical sense. The polynomial degree of the highest basis function + increments due to the element shape, etc. .

Definition at line 161 of file solution.h.

Referenced by Hermes::Hermes2D::Solution< Scalar >::copy().


The documentation for this singleton was generated from the following files: