<commit_before>/**
 * FILE : finite_element_field.hpp
 *
 * Internal class for field interpolated over finite elements.
 */
/* OpenCMISS-Zinc Library
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if !defined (FINITE_ELEMENT_FIELD_HPP)
#define FINITE_ELEMENT_FIELD_HPP

#include "opencmiss/zinc/types/elementid.h"
#include "finite_element/finite_element_mesh.hpp"
#include "general/change_log.h"
#include "general/enumerator.h"
#include "general/geometry.h"
#include "general/value.h"
#include "general/list.h"

/*
Global types
------------
*/

/**
 * FE_field maintains pointer to owning FE_region.
 */
struct FE_region;

class FE_field_parameters;

/** Information about what the field represents physically.
 * It is derived from how fields are used in cm, but does not correspond to a
 * field type in cm or identify fields in cm.
 * Note: the first value will be 0 by the ANSI standard, with each subsequent entry
 * incremented by 1. This pattern is expected by the ENUMERATOR macros.  Must
 * ensure the ENUMERATOR_STRING function returns a string for each value here. */
enum CM_field_type
{
	CM_ANATOMICAL_FIELD,
	CM_COORDINATE_FIELD,
	CM_GENERAL_FIELD
};

/** Legacy internal storage/function type for FE_field */
enum FE_field_type
{
	CONSTANT_FE_FIELD, /* fixed values */
	INDEXED_FE_FIELD,  /* indexed set of fixed values */
	GENERAL_FE_FIELD,  /* values held in nodes, elements */
	UNKNOWN_FE_FIELD
};

/** Internal class for field interpolated over finite elements. */
struct FE_field
{
	friend struct FE_region;
	friend bool FE_fields_match_fundamental(struct FE_field *field1,
		struct FE_field *field2);
	friend bool FE_fields_match_exact(struct FE_field *field1, struct FE_field *field2);
	friend int set_FE_field_number_of_components(struct FE_field *field,
		int number_of_components);
	friend int set_FE_field_type_constant(struct FE_field *field);
	friend int set_FE_field_type_general(struct FE_field *field);
	friend int get_FE_field_type_indexed(struct FE_field *field,
		struct FE_field **indexer_field, int *number_of_indexed_values);
	friend int set_FE_field_type_indexed(struct FE_field *field,
		struct FE_field *indexer_field, int number_of_indexed_values);
	friend int set_FE_field_value_type(struct FE_field *field, enum Value_type value_type);
	friend int set_FE_field_string_value(struct FE_field *field, int value_number,
		char *string);
	friend int set_FE_field_FE_value_value(struct FE_field *field, int number,
		FE_value value);
	friend int set_FE_field_int_value(struct FE_field *field, int number, int value);

protected:
	/* the name of the field, which is its identifier */
	const char *name;

private:
	FE_region *fe_region;  // owning FE_region, not accessed
	enum CM_field_type cm_field_type;  // anatomical/coordinate/general
	enum FE_field_type fe_field_type;  // constant/general/indexed
	/* following two for INDEXED_FE_FIELD only */
	struct FE_field *indexer_field;
	int number_of_indexed_values;
	/* the number of components (allows vector valued fields) */
	int number_of_components;
	/* the names of the different vector components */
	char **component_names;
	/* the coordinate system for the vector */
	Coordinate_system coordinate_system;
	/* the number of global values/derivatives that are stored with the field */
	int number_of_values;
	/* the type of the values returned by the field */
	enum Value_type value_type;
	// with element_xi_host_mesh, embedded node field data for 0=nodes, 1=datapoints
	FE_mesh_embedded_node_field *embeddedNodeFields[2];
	// for value_type == ELEMENT_XI_VALUE, accessed host mesh
	// or nullptr if not yet determined from legacy input
	FE_mesh *element_xi_host_mesh;
	/* array of global values/derivatives that are stored with the field.
	 * The actual values can be extracted using the <value_type> */
	Value_storage *values_storage;

	// field definition and data on FE_mesh[dimension - 1]
	// Future: limit to being defined on a single mesh; requires change to current usage
	FE_mesh_field_data *meshFieldData[MAXIMUM_ELEMENT_XI_DIMENSIONS];

	// non-accessed handle to object indexing parameters, when exists
	// clients access it, and it accesses this FE_field
	FE_field_parameters *fe_field_parameters;

	/* the number of computed fields wrapping this FE_field */
	int number_of_wrappers;
	/* the number of structures that point to this field.  The field cannot be
		destroyed while this is greater than 0 */
	int access_count;

protected:

	// used only by FE_field_identifier pseudo class
	FE_field() :
		name(nullptr),
		indexer_field(nullptr),
		component_names(nullptr),
		element_xi_host_mesh(nullptr),
		values_storage(nullptr),
		fe_field_parameters(nullptr),
		access_count(0)
	{
		for (int d = 0; d < MAXIMUM_ELEMENT_XI_DIMENSIONS; ++d)
			this->meshFieldData[d] = nullptr;
	}

	FE_field(const char *nameIn, struct FE_region *fe_regionIn);

	~FE_field();

private:

	// called on merge or to clear when owning FE_region destroyed
	void set_FE_region(FE_region *fe_regionIn)
	{
		this->fe_region = fe_regionIn;
	}

public:

	static FE_field *create(const char *nameIn, FE_region *fe_regionIn);

	inline FE_field *access()
	{
		++access_count;<commit_msg>Fix compiler warnings for uninitialised members<commit_after>/**
 * FILE : finite_element_field.hpp
 *
 * Internal class for field interpolated over finite elements.
 */
/* OpenCMISS-Zinc Library
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if !defined (FINITE_ELEMENT_FIELD_HPP)
#define FINITE_ELEMENT_FIELD_HPP

#include "opencmiss/zinc/types/elementid.h"
#include "finite_element/finite_element_mesh.hpp"
#include "general/change_log.h"
#include "general/enumerator.h"
#include "general/geometry.h"
#include "general/value.h"
#include "general/list.h"

/*
Global types
------------
*/

/**
 * FE_field maintains pointer to owning FE_region.
 */
struct FE_region;

class FE_field_parameters;

/** Information about what the field represents physically.
 * It is derived from how fields are used in cm, but does not correspond to a
 * field type in cm or identify fields in cm.
 * Note: the first value will be 0 by the ANSI standard, with each subsequent entry
 * incremented by 1. This pattern is expected by the ENUMERATOR macros.  Must
 * ensure the ENUMERATOR_STRING function returns a string for each value here. */
enum CM_field_type
{
	CM_ANATOMICAL_FIELD,
	CM_COORDINATE_FIELD,
	CM_GENERAL_FIELD
};

/** Legacy internal storage/function type for FE_field */
enum FE_field_type
{
	CONSTANT_FE_FIELD, /* fixed values */
	INDEXED_FE_FIELD,  /* indexed set of fixed values */
	GENERAL_FE_FIELD,  /* values held in nodes, elements */
	UNKNOWN_FE_FIELD
};

/** Internal class for field interpolated over finite elements. */
struct FE_field
{
	friend struct FE_region;
	friend bool FE_fields_match_fundamental(struct FE_field *field1,
		struct FE_field *field2);
	friend bool FE_fields_match_exact(struct FE_field *field1, struct FE_field *field2);
	friend int set_FE_field_number_of_components(struct FE_field *field,
		int number_of_components);
	friend int set_FE_field_type_constant(struct FE_field *field);
	friend int set_FE_field_type_general(struct FE_field *field);
	friend int get_FE_field_type_indexed(struct FE_field *field,
		struct FE_field **indexer_field, int *number_of_indexed_values);
	friend int set_FE_field_type_indexed(struct FE_field *field,
		struct FE_field *indexer_field, int number_of_indexed_values);
	friend int set_FE_field_value_type(struct FE_field *field, enum Value_type value_type);
	friend int set_FE_field_string_value(struct FE_field *field, int value_number,
		char *string);
	friend int set_FE_field_FE_value_value(struct FE_field *field, int number,
		FE_value value);
	friend int set_FE_field_int_value(struct FE_field *field, int number, int value);

protected:
	/* the name of the field, which is its identifier */
	const char *name;

private:
	FE_region *fe_region;  // owning FE_region, not accessed
	enum CM_field_type cm_field_type;  // anatomical/coordinate/general
	enum FE_field_type fe_field_type;  // constant/general/indexed
	/* following two for INDEXED_FE_FIELD only */
	struct FE_field *indexer_field;
	int number_of_indexed_values;
	/* the number of components (allows vector valued fields) */
	int number_of_components;
	/* the names of the different vector components */
	char **component_names;
	/* the coordinate system for the vector */
	Coordinate_system coordinate_system;
	/* the number of global values/derivatives that are stored with the field */
	int number_of_values;
	/* the type of the values returned by the field */
	enum Value_type value_type;
	// with element_xi_host_mesh, embedded node field data for 0=nodes, 1=datapoints
	FE_mesh_embedded_node_field *embeddedNodeFields[2];
	// for value_type == ELEMENT_XI_VALUE, accessed host mesh
	// or nullptr if not yet determined from legacy input
	FE_mesh *element_xi_host_mesh;
	/* array of global values/derivatives that are stored with the field.
	 * The actual values can be extracted using the <value_type> */
	Value_storage *values_storage;

	// field definition and data on FE_mesh[dimension - 1]
	// Future: limit to being defined on a single mesh; requires change to current usage
	FE_mesh_field_data *meshFieldData[MAXIMUM_ELEMENT_XI_DIMENSIONS];

	// non-accessed handle to object indexing parameters, when exists
	// clients access it, and it accesses this FE_field
	FE_field_parameters *fe_field_parameters;

	/* the number of computed fields wrapping this FE_field */
	int number_of_wrappers;
	/* the number of structures that point to this field.  The field cannot be
		destroyed while this is greater than 0 */
	int access_count;

protected:

	// used only by FE_field_identifier pseudo class
	FE_field() :
		name(nullptr),
		fe_region(nullptr),
		cm_field_type(CM_GENERAL_FIELD),
		fe_field_type(GENERAL_FE_FIELD),
		indexer_field(nullptr),
		number_of_indexed_values(0),
		number_of_components(0),
		component_names(nullptr),
		number_of_values(0),
		value_type(UNKNOWN_VALUE),
		element_xi_host_mesh(nullptr),
		values_storage(nullptr),
		fe_field_parameters(nullptr),
		number_of_wrappers(0),
		access_count(0)
	{
		embeddedNodeFields[0] = nullptr;
		embeddedNodeFields[1] = nullptr;
		for (int d = 0; d < MAXIMUM_ELEMENT_XI_DIMENSIONS; ++d)
			this->meshFieldData[d] = nullptr;
	}

	FE_field(const char *nameIn, struct FE_region *fe_regionIn);

	~FE_field();

private:

	// called on merge or to clear when owning FE_region destroyed
	void set_FE_region(FE_region *fe_regionIn)
	{
		this->fe_region = fe_regionIn;
	}

public:

	static FE_field *create(const char *nameIn, FE_region *fe_regionIn);

	inline FE_field *access()
	{
		++access_count;
{'fraction_non_alphanumeric': 0.08091116173120728, 'fraction_numerical': 0.0036446469248291574, 'mean_word_length': 4.9458288190682556, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5655372', 'n_tokens_mistral': 3610, 'n_tokens_neox': 3475, 'n_words': 1116}