<commit_before>/*=========================================================================

 Program: FEMUS
 Module: System
 Authors: <NAME>, <NAME>

 Copyright (c) FEMTTU
 All rights reserved.

 This software is distributed WITHOUT ANY WARRANTY; without even
 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.  See the above copyright notice for more information.

=========================================================================*/

#ifndef __System_hpp__
#define __System_hpp__

//----------------------------------------------------------------------------
// includes :
//----------------------------------------------------------------------------
#include "MultiLevelProblem.hpp"


namespace femus {

//------------------------------------------------------------------------------
// Forward declarations
//------------------------------------------------------------------------------
class System;
class MultiLevelProblem;
class String;

/**
 * The system abstract class
 */

class System {

public:

    /** Constructor.  Optionally initializes required data structures. */
    System (MultiLevelProblem& ml_prob, const std::string& name, const unsigned int number, const MgSmoother & smoother_type);

    /** destructor */
    virtual ~System();

    /** To be Added */
    unsigned int number() const;

    /** To be Added */
    const std::string & name() const;

    /**
     * @returns the type of system, helpful in identifying
     * which system type to use when reading equation system
     * data from file.  Should be overloaded in derived classes.
    */
    virtual std::string system_type () const {
        return "Basic";
    }

    /** Associate the solution variables to the system PDE */
    void AddSolutionToSystemPDE(const char solname[]);

    typedef void (* AssembleFunctionType) (MultiLevelProblem &ml_prob, unsigned level, const unsigned &gridn, const bool &assemble_matrix);
    
    /** Register a user function to use in assembling the system matrix and RHS. */
    void SetAssembleFunction (void fptr(MultiLevelProblem &ml_prob, unsigned level,
                                           const unsigned &gridn, const bool &assemble_matrix));

    AssembleFunctionType  GetAssembleFunction();

    /** Solves the system.  Should be overloaded in derived systems. */
    virtual void solve () {};

    /** Clear all the data structures associated with the system. */
    virtual void clear();

    /** Init the system PDE structures */
    virtual void init();

    /** Get the index of the Solution "solname" for this system */
    unsigned GetSolPdeIndex(const char solname[]);

    /** Get MultiLevelProblem */
    const MultiLevelProblem &  GetMLProb() const { return _equation_systems; }
    
    /** Get MultiLevelProblem */
    MultiLevelProblem &  GetMLProb() { return _equation_systems; }
    
    /** Get Number of Levels */
    inline const unsigned GetGridn() const { return _gridn; }
    
protected:

    /** Constant reference to the \p EquationSystems object used for the simulation. */
    MultiLevelProblem& _equation_systems;

    /** Mesh vector, dimension _gridn */
    vector<Mesh*> _msh;

    /** Solution vector, dimension _gridn */
    vector<Solution*> _solution;

    /** pointer */
    MultiLevelSolution* _ml_sol;

    /** pointer */
    MultiLevelMesh* _ml_msh;

    /** indices of the solutions, dynamical dimension */
    vector <unsigned> _SolSystemPdeIndex;

    /** Number of Levels */
    unsigned _gridn;

    /** Number of Totally Refined Levels */
    unsigned _gridr;

    /** Function that assembles the system. */
    void (* _assemble_system_function) (MultiLevelProblem &ml_prob, unsigned level,
                                        const unsigned &gridn, const bool &assemble_matrix);

    /** The number associated with this system */
    const unsigned int _sys_number;

    /** A name associated with this system. */
    const std::string _sys_name;

};<commit_msg>Simplified function pointer type declaration in System<commit_after>/*=========================================================================

 Program: FEMUS
 Module: System
 Authors: <NAME>, <NAME>

 Copyright (c) FEMTTU
 All rights reserved.

 This software is distributed WITHOUT ANY WARRANTY; without even
 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.  See the above copyright notice for more information.

=========================================================================*/

#ifndef __System_hpp__
#define __System_hpp__

//----------------------------------------------------------------------------
// includes :
//----------------------------------------------------------------------------
#include "MultiLevelProblem.hpp"


namespace femus {

//------------------------------------------------------------------------------
// Forward declarations
//------------------------------------------------------------------------------
class System;
class MultiLevelProblem;
class String;

/**
 * The system abstract class
 */

class System {

protected:
  
    /** Function pointer type, easiest way to declare function pointer instantiations */
    typedef void (* AssembleFunctionType) (MultiLevelProblem &ml_prob, unsigned level, const unsigned &gridn, const bool &assemble_matrix);
  
public:

    /** Constructor.  Optionally initializes required data structures. */
    System (MultiLevelProblem& ml_prob, const std::string& name, const unsigned int number, const MgSmoother & smoother_type);

    /** destructor */
    virtual ~System();

    /** To be Added */
    unsigned int number() const;

    /** To be Added */
    const std::string & name() const;

    /**
     * @returns the type of system, helpful in identifying
     * which system type to use when reading equation system
     * data from file.  Should be overloaded in derived classes.
    */
    virtual std::string system_type () const {
        return "Basic";
    }

    /** Associate the solution variables to the system PDE */
    void AddSolutionToSystemPDE(const char solname[]);

    /** Register a user function to use in assembling the system matrix and RHS. */
    void SetAssembleFunction (AssembleFunctionType );

    AssembleFunctionType  GetAssembleFunction();

    /** Solves the system.  Should be overloaded in derived systems. */
    virtual void solve () {};

    /** Clear all the data structures associated with the system. */
    virtual void clear();

    /** Init the system PDE structures */
    virtual void init();

    /** Get the index of the Solution "solname" for this system */
    unsigned GetSolPdeIndex(const char solname[]);

    /** Get MultiLevelProblem */
    const MultiLevelProblem &  GetMLProb() const { return _equation_systems; }
    
    /** Get MultiLevelProblem */
    MultiLevelProblem &  GetMLProb() { return _equation_systems; }
    
    /** Get Number of Levels */
    inline const unsigned GetGridn() const { return _gridn; }
    
protected:
  
    /** Constant reference to the \p EquationSystems object used for the simulation. */
    MultiLevelProblem& _equation_systems;

    /** Mesh vector, dimension _gridn */
    vector<Mesh*> _msh;

    /** Solution vector, dimension _gridn */
    vector<Solution*> _solution;

    /** pointer */
    MultiLevelSolution* _ml_sol;

    /** pointer */
    MultiLevelMesh* _ml_msh;

    /** indices of the solutions, dynamical dimension */
    vector <unsigned> _SolSystemPdeIndex;

    /** Number of Levels */
    unsigned _gridn;

    /** Number of Totally Refined Levels */
    unsigned _gridr;

    /** Function that assembles the system. */
    AssembleFunctionType _assemble_system_function;

    /** The number associated with this system */
    const unsigned int _sys_number;

    /** A name associated with this system. */
    const std::string _sys_name;

};
{'fraction_non_alphanumeric': 0.19862839725679451, 'fraction_numerical': 0.0, 'mean_word_length': 2.3396946564885495, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2066520', 'n_tokens_mistral': 1948, 'n_tokens_neox': 1801, 'n_words': 691}